Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2017
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. require 'rbvmomi'
  2. credentials = { :host => "192.168.1.10", :user => "administrator@vsphere.local", :password => "vmware", :insecure => true }
  3.  
  4. vim = RbVmomi::VIM.connect(credentials)
  5. datacenter = vim.rootFolder.childEntity.first # grab the first datacenter
  6. datacenter.hostFolder.childEntity # this will return an array of all the clusters in the datacenter
  7. cluster = datacenter.hostFolder.childEntity.first # grab the first cluster from the datacenter
  8. cluster.host # this will return an array of all the ESXi hosts in the first cluster
  9. host = cluster.host.first # grab the first host in the cluster
  10. host.config.network.vnic # display all the vnics on the host
  11. host.config.network.vnic.first.spec.ip.ipAddress # display the ip address bound the to first vnic on the host
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement