Skip to content

Instantly share code, notes, and snippets.

@chris1984
Created January 8, 2019 20:40
Show Gist options
  • Save chris1984/4eb7282ee81f7895cce5afd26ea8896d to your computer and use it in GitHub Desktop.
Save chris1984/4eb7282ee81f7895cce5afd26ea8896d to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'fog'
client = ::Fog::Compute.new(
:provider => 'vsphere',
:vsphere_username => '',
:vsphere_password => '',
:vsphere_server => '',
:vsphere_expected_pubkey_hash => '',
)
interface_attrs = {
network: 'LX-LAN-VLAN-775',
type: 'VirtualE1000'
}
attrs = {
:name => 'some.example.com',
:memory_mb => '768',
:interfaces => [ interface_attrs ],
:volumes => [
{
:storage_pod => 'Some-Mirror-Pod',
:name => 'Hard disk',
:size_gb => '10',
:thin => 'true',
:eager_zero => 'false'
}
],
:scsi_controller=> {
:type=>"VirtualLsiLogicController"
},
:datacenter => "Toledo",
:boot_order => ["network", "disk"],
:cpus => "1",
:corespersocket => "1",
:cluster=>"Some-Cluster",
:resource_pool=>"default",
:path => "/Datencenter/Some/path",
:guest_id=>"rhel7_64Guest",
:memoryHotAddEnabled=>"1",
:cpuHotAddEnabled=>"1",
:start=>"1",
:annotation=>"test vm"
}
vm = client.servers.new(attrs)
vm.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment