Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'fog'
- require 'pp'
- conn = Fog::Compute.new({
- :provider => 'XenServer',
- :xenserver_url => 'xenserver-test',
- :xenserver_username => 'root',
- :xenserver_password => 'changeme',
- :xenserver_defaults => {
- :template => "squeeze-test"
- }
- })
- # Create a VM using the default template
- #vm = conn.servers.create :name => 'foobar'
- #
- #
- # Create a VM using a specific template
- #
- vm = conn.servers.create :name => 'foobarXX',
- :template_name => 'squeeze-test'
- #
- # Create a VM with 2 nics
- #
- vm2 = conn.servers.create :name => 'foobar2NIC',
- :template_name => 'squeeze-test',
- :networks => [conn.default_network, conn.default_network, conn.default_network]
- #
- # Force shutdown
- vm.hard_shutdown
- vm2.hard_shutdown
- #
- # Destroy VM and associated VDIs
- # Force shutdown the VM too
- vm.destroy
- vm2.destroy
- # Create the server from template squeeze-test
- # plus two additional NICs in network 'Integration-VLAN'
- net = conn.networks.find { |n| n.name == "Integration-VLAN" }
- s = conn.servers.create :name => 'my-foo-server',
- :template_name => 'squeeze-test',
- :networks => [net, net]
- # Advanced VIF creation mode
- # with custom MAC and device number
- config = {
- 'MAC_autogenerated' => 'False',
- 'VM' => s.reference,
- 'network' => net.reference,
- 'MAC' => '11:22:33:44:55:66',
- 'device' => '4',
- 'MTU' => '0',
- 'other_config' => {},
- 'qos_algorithm_type' => 'ratelimit',
- 'qos_algorithm_params' => {}
- }
- conn.create_vif_custom config
Add Comment
Please, Sign In to add comment