class Chef::Knife::VsphereVmNetworkList
VsphereVmNetworklist extends the BaseVspherecommand
Public Instance Methods
run()
click to toggle source
The main run method for vm_network_list
# File lib/chef/knife/vsphere_vm_network_list.rb, line 22 def run $stdout.sync = true vmname = @name_args[0] if vmname.nil? show_usage fatal_exit("You must specify a virtual machine name") end vm = get_vm_by_name(vmname, get_config(:folder)) || fatal_exit("Could not find #{vmname}") dc = datacenter vm.config.hardware.device.each.grep(RbVmomi::VIM::VirtualEthernetCard).map do |nic| dc.network.grep(RbVmomi::VIM::DistributedVirtualPortgroup) do |net| if nic.backing.port.portgroupKey.eql?(net.key) puts "NIC: #{nic.deviceInfo.label} VLAN: #{net.name}" break end end end end