Skip to content

Instantly share code, notes, and snippets.

@rcreasey
Created October 26, 2009 20:19
Show Gist options
  • Save rcreasey/219001 to your computer and use it in GitHub Desktop.
Save rcreasey/219001 to your computer and use it in GitHub Desktop.
#!/bin/env ruby
vm_label = ARGV[0]
if vm_label.nil?
puts "You need to specify a new vm label."
exit
end
sr_uuid = ARGV[1]
sr_uuid = "bb50e600-55b9-f383-ffc9-7dc7c976e259" if sr_uuid.nil?
vm_uuid = %x{xe vm-install template="CentOS 5.3 x64" new-name-label=#{vm_label} sr_uuid=#{sr_uuid}}.chomp
vif_uuid = %x{xe vif-create mac=random device=0 network-uuid=2d7f66c1-f3fc-0cad-92fa-a724f05bfbb1 vm-uuid=#{vm_uuid}}.chomp
%x{xe vm-param-set PV-args="ks=http://10.15.0.50/ks/ks-skynet_cloud.cfg ksdevice=eth0" uuid=#{vm_uuid}}
%x{xe vm-param-set other-config:install-repository=http://10.15.0.50/centos/5/os/x86_64/ uuid=#{vm_uuid}}
puts "Starting new vm '#{vm_label}'."
%x{xe vm-start uuid=#{vm_uuid}}
dom_id = $1 if %x{xe vm-list params=dom-id uuid=#{vm_uuid}}.chomp =~ /dom-id.*: (\d+).*/
puts "Console is at DOM ID '#{dom_id}'. To connect to console, use:"
puts "/usr/lib/xen/bin/xenconsole #{dom_id}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment