Sergio81's Posts

Thank you very much Stumpr, now i have all i need Bye!!
Hi, now i use this code to  find the Portgroup name: my $portgroupKey = $nic->{backing}->{port}->{portgroupKey};                            my $dvsPortgroup = Vim::find_entity_view (        ... See more...
Hi, now i use this code to  find the Portgroup name: my $portgroupKey = $nic->{backing}->{port}->{portgroupKey};                            my $dvsPortgroup = Vim::find_entity_view (                                  view_type => "DistributedVirtualPortgroup",                                  begin_entity => $datacenter_view,                                  properties => [ 'name', 'key', 'config.distributedVirtualSwitch' ],                                  filter => { 'key' => $portgroupKey }                            );   my $Portgroup_name = $dvsPortgroup->name; this work. and with this i can retrive the switch UUID: my $SwitchUuid = $nic->{backing}->{port}->{switchUuid}; it's look like: 90 2d 05 40 1e 9f ba 9b-ea fe 3d ec 93 21 a1 ba now i need to retrieve the DVSwitch real name, something like "dvs_TEST-DR"...can i use the UUID to find the associated DVS name, how? Maybe is there a better way? Thank You!!
Again thank you so much !! The problem is that the most important information i want collect is the label of the NICs with Distributed Virtual Switch ... the only one who doesn't work)
Thanks a lot!!!! I did some tests and almost everything works. The only problem I encounter is with a VM that has two NICs with Distributed Virtual Switch: The name of this VM is LABO-TE... See more...
Thanks a lot!!!! I did some tests and almost everything works. The only problem I encounter is with a VM that has two NICs with Distributed Virtual Switch: The name of this VM is LABO-TEST-MACHINE, and this is the output of the perl scripts: [...] VM Name: LABMXXXXX     NIC type: VirtualE1000   nic 'Network adapter 1':     network portgroup: LANBACKUP_LABO     NIC type: VirtualE1000     NIC type: VirtualE1000   nic 'Network adapter 2':     network portgroup: HEARTBEAT_XXX     NIC type: VirtualE1000 VM Name: LABO-TEST-MACHINE     NIC type: Flexible   nic 'Network adapter 1':     network portgroup: LANBACKUP_LABO     NIC type: Flexible     NIC type: Flexible Can't call method "type" on an undefined value at /usr/share/perl/5.10/VMware/VICommon.pm line 1026. How you can see, i receive the error above, only when the script try to extract the Network Portgroup of that VM. I think the code line with the problem is: $pg = Vim::get_view(mo_ref => $pg_mo, properties => ['name']); Instead with the Standard Virtual Switch, i didn't encounter problems. Here's all new code: my $datacenter = $DCFILTER; my $clusterFilter = $CLFILTER ; my $datacenter_view = Vim::find_entity_view(view_type => 'Datacenter', filter => { name => $datacenter }); my @values = split(/\|/, $clusterFilter); foreach my $val (@values) {         my $cluster_view = Vim::find_entity_view(view_type => 'ClusterComputeResource', filter => { name => qr/$val/});         my $vm_views = Vim::find_entity_views(view_type => 'VirtualMachine', properties => ['name', 'config.hardware.device'], begin_entity => $cluster_view);                 foreach (@$vm_views) {                 print $_->name . "\n"; #                       $vm = $_->name;                         my @devs = @{ $_->{'config.hardware.device'} };                         my @net_devs = grep { $_->isa('VirtualEthernetCard') } @devs;                         foreach my $nic ( @net_devs ) {                                 my ($name, $type, $network, $connect, $pg_mo, $pg);                                 # NIC type                                 if ($nic->isa('VirtualPCNet32')) {                                         $type = 'Flexible';                                 } else {                                 $type = ref $nic;                        }                            print "    NIC type: $type\n";                            $pg_mo = $nic->{'backing'}{'network'};                           $pg = Vim::get_view(mo_ref => $pg_mo, properties => ['name']);                            $network = $pg->{'name'}; #                          $connect = ( eval {$nic->{'connectable'}{'startConnected'} ) ? 1 : 0;                            $name = $nic->{'deviceInfo'}{'label'};                            print "  nic '$name':\n"; #                          print "    connect on power on: $connect\n";                            print "    network portgroup: $network\n";                            print "    NIC type: $type\n";                         }                 } } Util::disconnect();
Hi, I have this simple code to retrieve the name of all VirtualMachines in my infrastructure (filtered for datacenter) [...other code...] use VMware::VILib;     Opts::add_options... See more...
Hi, I have this simple code to retrieve the name of all VirtualMachines in my infrastructure (filtered for datacenter) [...other code...] use VMware::VILib;     Opts::add_options(%opts);     Opts::parse();     Opts::validate();     Util::connect(); my $datacenter = $DCFILTER; my $clusterFilter = $CLFILTER ; my $datacenter_view = Vim::find_entity_view(view_type => 'Datacenter', filter => { name => $datacenter }); my @values = split(/\|/, $clusterFilter); foreach my $val (@values) {     my $cluster_view = Vim::find_entity_view(view_type => 'ClusterComputeResource', filter => { name => qr/$val/});     my $vm_views = Vim::find_entity_views(view_type => 'VirtualMachine', begin_entity => $cluster_view);     foreach (@$vm_views) {    print $_->name . "\n";    $vm = $_->name;     } } Util::disconnect(); This code runs, but now I need to recover some information about network of each VM, specifically: 1)the network labels of each NIC  (for each VM) 2)the Adapter  Type (optionally) 3)Device status: Connected at power on (yes/no) (optionally). I saw that exists the Managed Object - Network, property of Managed Object - VirtualMachine, but i don't know how to use it in my code and if contains the information i need (maybe "Summary") Here one example: in this case i would like to know for this VM 1)LANBACKUP.... ; dvPP_LABO...; dvp_LABO... and if is possible the information 2) and 3) for each NIC...in this case for NIC LANBAKUP... 2)Flexible 3)Connected at the power on: Yes Can you help me to integrate my code for retrieve the above information? Thank you very much, for your help. Sergio