Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2017
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. require 'rbvmomi';
  2. credentials = { :host => "192.168.1.10", :user => "administrator@vsphere.local", :password => "vmware", :insecure => true };
  3. vim = RbVmomi::VIM.connect(credentials);
  4. datacenters = {};
  5. vim.rootFolder.childEntity.each { |datacenter|
  6. datacenter_info = {}
  7. datacenter.hostFolder.childEntity.each { |cluster|
  8. cluster_info = {}
  9. cluster.host.each { |host|
  10. host_info = {}
  11. host.config.network.vnic.each { |vnic|
  12. vnic_info = {}
  13. vnic_info[:portgroup] = vnic.portgroup
  14. vnic_info[:dhcp_enabled] = vnic.spec.ip.dhcp
  15. vnic_info[:ip_address] = vnic.spec.ip.ipAddress
  16. vnic_info[:subnet_mask] = vnic.spec.ip.subnetMask
  17. host_info[vnic.device.to_sym] = vnic_info
  18. }
  19. cluster_info[host.name.to_sym] = host_info
  20. }
  21. datacenter_info[cluster.name.to_sym] = cluster_info
  22. }
  23. datacenters[datacenter.name.to_sym] = datacenter_info
  24. };
  25. datacenters
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement