Skip to content

Instantly share code, notes, and snippets.

@aussielunix
Forked from jedi4ever/gist:1216529
Created December 7, 2011 23:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aussielunix/1445258 to your computer and use it in GitHub Desktop.
Save aussielunix/1445258 to your computer and use it in GitHub Desktop.
Quick gist on getting vsphere and vcenter and fog/vsphere going
Quick gist on getting vsphere and vcenter and fog/vsphere going
# Things to download
- Download free evaluation version of window 2008
- Download free evaluation of esxi v5
- Download free evaluation of esxi vsphere (control center) iso
# Install esxi in vmware fusion
1)Install esxi in vmware (select vmware/esx as host)
create a user root/pipopopo
results in http://172.16.44.140/
# Install windows 2008
In a second fusion vm install win2008 in Vmware fusion (select Enterprise version)
win2008-enterprise-vsphere-v5
mount the vm-all...-iso
# On windows 2008 + Vcenter
- install vcenter server
- English,
will install visual C++ 5 , .NET framework
agree to license
username: some name, organization: some org, license key: blank
Install SQL Server 2008 Express
Use System Account
Warning on FQDN not resolvable
Stand alone Vcenter Server instance
Agree to ports
HTTPS port 10443, Smgt port 10109 Linked Communications Port 10111
Inventory size (small)
Don't need extra ephemeral ports
- install vsphere client
installs visual j, ....
Note the Ip address 172.16.44.141
# On win2008 install vsphere client
Login to the vsphere machine (windows machine IP-address) using vsphere client
ignore the SSL certificate mismatch
use windows session credentials
# Start vsphere client and import esxi (ip from first vm)
See http://blogs.vmware.com/kbtv/2011/08/getting-started-with-vsphere-5-adding-esx-hosts-into-vcenter-server.html
- login and select datacenters tab
right click -> new datacenter
rename it to Test Datacenter
now add a host (root/pipopopo, IP address)
trust the certificate
Continue the wizard
No license key
Don't enable lockdown
e) set a password for the user (under which you installed vcenter)
needs to be an administrator
Needs to be a complex password
pipo1234**
# On the ruby side
- Install rbvmomi (1.3.0 installed)
- get the latest fog from github (0.11)
# Login via the vsphere console + create vm
create a vm
clone it as a template (test template)
#Connect to the *vcenter* machine fog (windows vm)
Correct hash if needed
f=Fog::Compute.new(:provider => "vsphere", :vsphere_username => "patrick", :vsphere_password=> "pipo1234**", :vsphere_server => "172.16.44.141", :vsphere_expected_pubkey_hash => "74e6f3f9a9d50be352aa0fabcdc1df9977016af38da538cf76b3ba56a6363d11")
# FYI you can also connect to the vshere directly but no write/cloning possible)
>> Fog::Compute.new(:provider => "vsphere", :vsphere_username => "root", :vsphere_password=> "pipopopo", :vsphere_server => "172.16.44.140")
Fog::Vsphere::Errors::SecurityError: The remote system presented a public key with hash 39b9675b5e8ac71bae40a3fc22ee0a648a250c0997d69aedc181cccb4185f9f0 but we're expecting a hash of <unset>. If you are sure the remote system is authentic set vsphere_expected_pubkey_hash: <the hash printed in this message> in ~/.fog
# List the servers
>> f.servers
<Fog::Compute::Vsphere::Servers
[
<Fog::Compute::Vsphere::Server
id="501b12d9-18c1-e123-ceff-97292ef15bdf",
name="test template",
uuid="421bcca9-14b5-2a5f-a564-f3ec8f07ea4f",
instance_uuid="501b12d9-18c1-e123-ceff-97292ef15bdf",
hostname=nil,
operatingsystem=nil,
ipaddress=nil,
power_state="poweredOff",
tools_state="toolsNotInstalled",
tools_version="guestToolsNotInstalled",
mac_addresses={"Network adapter 1"=>"00:50:56:9b:67:33"},
hypervisor="172.16.44.140",
is_a_template=true,
connection_state="connected",
mo_ref="vm-13"
>,
<Fog::Compute::Vsphere::Server
id="52cc1f29-1015-577c-a2bb-ceb37a8b6675",
name="testvm",
uuid="564d7664-78ee-ae6b-cd0e-ce8754385c09",
instance_uuid="52cc1f29-1015-577c-a2bb-ceb37a8b6675",
hostname=nil,
operatingsystem=nil,
ipaddress=nil,
power_state="poweredOff",
tools_state="toolsNotInstalled",
tools_version="guestToolsNotInstalled",
mac_addresses={"Network adapter 1"=>"00:50:56:9b:67:32"},
hypervisor="172.16.44.140",
is_a_template=false,
connection_state="connected",
mo_ref="vm-12"
>
]
>
#Clone a template
new_vm=f.vm_clone('instance_uuid' => '501b12d9-18c1-e123-ceff-97292ef15bdf', 'name' => 'clonedvm'){"vm_ref"=>"vm-14", "task_ref"=>"task-5"}
>> f.servers.all
<Fog::Compute::Vsphere::Servers
[
<Fog::Compute::Vsphere::Server
id="501b928f-1935-7823-0600-459ff79cc783",
name="clonedvm",
uuid="421bf66f-cf21-0985-f604-2866ed1e59fd",
instance_uuid="501b928f-1935-7823-0600-459ff79cc783",
hostname=nil,
operatingsystem=nil,
ipaddress=nil,
power_state="poweredOn",
tools_state="toolsNotInstalled",
tools_version="guestToolsNotInstalled",
mac_addresses={"Network adapter 1"=>"00:50:56:9b:67:34"},
hypervisor="172.16.44.140",
is_a_template=false,
connection_state="connected",
mo_ref="vm-14"
>,
<Fog::Compute::Vsphere::Server
id="501b12d9-18c1-e123-ceff-97292ef15bdf",
name="test template",
uuid="421bcca9-14b5-2a5f-a564-f3ec8f07ea4f",
instance_uuid="501b12d9-18c1-e123-ceff-97292ef15bdf",
hostname=nil,
operatingsystem=nil,
ipaddress=nil,
power_state="poweredOff",
tools_state="toolsNotInstalled",
tools_version="guestToolsNotInstalled",
mac_addresses={"Network adapter 1"=>"00:50:56:9b:67:33"},
hypervisor="172.16.44.140",
is_a_template=true,
connection_state="connected",
mo_ref="vm-13"
>,
<Fog::Compute::Vsphere::Server
id="52cc1f29-1015-577c-a2bb-ceb37a8b6675",
name="testvm",
uuid="564d7664-78ee-ae6b-cd0e-ce8754385c09",
instance_uuid="52cc1f29-1015-577c-a2bb-ceb37a8b6675",
hostname=nil,
operatingsystem=nil,
ipaddress=nil,
power_state="poweredOff",
tools_state="toolsNotInstalled",
tools_version="guestToolsNotInstalled",
mac_addresses={"Network adapter 1"=>"00:50:56:9b:67:32"},
hypervisor="172.16.44.140",
is_a_template=false,
connection_state="connected",
mo_ref="vm-12"
>
]
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment