Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Created --vm-domain parameter to allow for the passing of domaini nam…

…e to xenstore to be subsequently read by the xe-automater scripts.

Updated README.md to include example call for setting network configuration.
  • Loading branch information...
commit 704ddf18431d0e77822de3889e52237afcca17b3 1 parent 16b1920
@adamlau adamlau authored committed
Showing with 14 additions and 1 deletion.
  1. +7 −0 README.md
  2. +7 −1 lib/chef/knife/xenserver_vm_create.rb
View
7 README.md
@@ -61,6 +61,13 @@ Create a VM from template and add two custom VIFs in networks 'Integration-VLAN'
--vm-networks 'Integration-VLAN,Another-VLAN' \
--mac-addresses 11:22:33:44:55:66
+Create a VM from template and supply ip/host/domain configuration. Requires installation of xe-automater scripts (https://github.com/adamlau/xenserver-automater)
+
+ knife xenserver vm create --vm-template my-template -x root --keep-template-networks \
+ --vm-name my-hostname \
+ --vm-ip 172.20.1.25 --vm-netmask 255.255.0.0 --vm-gateway 172.20.0.1 --vm-dns 172.20.0.3 \
+ --vm-domain my-domain.local
+
List hypervisor networks
knife xenserver network list
View
8 lib/chef/knife/xenserver_vm_create.rb
@@ -55,7 +55,7 @@ class XenserverVmCreate < Knife
option :vm_memory,
:long => "--vm-memory AMOUNT",
:description => "The memory limits of the Virtual Machine",
- :default => '512'
+ :default => '1024'
option :vm_cpus,
:long => "--vm-cpus AMOUNT",
@@ -156,6 +156,10 @@ class XenserverVmCreate < Knife
:long => '--vm-dns NAMESERVER',
:description => 'DNS servers to set in xenstore'
+ option :vm_domain,
+ :long => '--vm-domain DOMAIN',
+ :description => 'DOMAIN of host to set in xenstore'
+
def tcp_test_ssh(hostname)
tcp_socket = TCPSocket.new(hostname, 22)
readable = IO.select([tcp_socket], nil, nil, 5)
@@ -198,6 +202,7 @@ def run
config[:vm_netmask] ||= Chef::Config[:knife][:xenserver_default_vm_netmask] || '255.255.255.0'
config[:vm_dns] ||= Chef::Config[:knife][:xenserver_default_vm_dns]
+ config[:vm_domain] ||= Chef::Config[:knife][:xenserver_default_vm_domain]
template = connection.servers.templates.find do |s|
(s.name == config[:vm_template]) or (s.uuid == config[:vm_template])
@@ -233,6 +238,7 @@ def run
vm.add_attribute('to_xenstore_data', 'vm-data/gw', config[:vm_gateway]) if config[:vm_gateway]
vm.add_attribute('to_xenstore_data', 'vm-data/nm', config[:vm_netmask]) if config[:vm_netmask]
vm.add_attribute('to_xenstore_data', 'vm-data/ns', config[:vm_dns]) if config[:vm_dns]
+ vm.add_attribute('to_xenstore_data', 'vm-data/dm', config[:vm_domain]) if config[:vm_domain]
if config[:vm_tags]
vm.set_attribute 'tags', config[:vm_tags].split(',')
Please sign in to comment.
Something went wrong with that request. Please try again.