Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rbvmomi';
- credentials = { :host => "192.168.1.10", :user => "administrator@vsphere.local", :password => "vmware", :insecure => true };
- vim = RbVmomi::VIM.connect(credentials);
- datacenters = {};
- vim.rootFolder.childEntity.each { |datacenter|
- datacenter_info = {}
- datacenter.hostFolder.childEntity.each { |cluster|
- cluster_info = {}
- cluster.host.each { |host|
- host_info = {}
- host.config.network.vnic.each { |vnic|
- vnic_info = {}
- vnic_info[:portgroup] = vnic.portgroup
- vnic_info[:dhcp_enabled] = vnic.spec.ip.dhcp
- vnic_info[:ip_address] = vnic.spec.ip.ipAddress
- vnic_info[:subnet_mask] = vnic.spec.ip.subnetMask
- host_info[vnic.device.to_sym] = vnic_info
- }
- cluster_info[host.name.to_sym] = host_info
- }
- datacenter_info[cluster.name.to_sym] = cluster_info
- }
- datacenters[datacenter.name.to_sym] = datacenter_info
- };
- datacenters
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement