kri-2's Accepted Solutions

Just got the solution: The filter must not be the friendly name of the cluster, but the id of the cluster e.g. cluster-2 (which can be queried by using /vcenter/cluster).
Hi, You don't need the host_view for this action. Why don't you use begin_entity for the vm views? my $cluster ="cluster1"; my $cluster_view = Vim::find_entity_view (     view_type => 'Clu... See more...
Hi, You don't need the host_view for this action. Why don't you use begin_entity for the vm views? my $cluster ="cluster1"; my $cluster_view = Vim::find_entity_view (     view_type => 'ClusterComputeResource',                                                                    filter => { 'name' => qr/^$cluster/i } ); if($cluster_view) {      my $vm_views = Vim::find_entity_views(  view_type => 'VirtualMachine',                                                                  begin_entity => $cluster_view,                                                                  properties => [ 'name' ] );      foreach my $vm_ref(@$vm_views) {           print $vm_ref->name."\n";      } } Hope that helps! Greetings, Chris
hi, this works for me, and is much faster: my $host_view = Vim::get_view(mo_ref=>$vm_view->summary->runtime->host, properties => \['name'\]); if($host_view){ print $host_... See more...
hi, this works for me, and is much faster: my $host_view = Vim::get_view(mo_ref=>$vm_view->summary->runtime->host, properties => \['name'\]); if($host_view){ print $host_view->name; }
Hi, did you get it working? If not here is a litte sub which should do it. Just call it at the end of the main, giving a ref to @dcstruct with it: sub createmyfolders{ my $ref_dcstruct =... See more...
Hi, did you get it working? If not here is a litte sub which should do it. Just call it at the end of the main, giving a ref to @dcstruct with it: sub createmyfolders{ my $ref_dcstruct = $_[0]; my $dc = "datacenter2"; my $datacenter_view = Vim::find_entity_view(view_type => 'Datacenter', filter=>\{name=>$dc}); foreach my $entry (@\{$ref_dcstruct}){ my $cnt = 0; my $folder_view = Vim::find_entity_view(view_type => 'Folder', begin_entity => $datacenter_view); foreach my $foldername (@\{$entry}){ $cnt++; next if $cnt<4; #skip the vmware internal folders (Datacenters, host and the datacenter itself, not nice but works) print "$cnt: Creating $foldername\n"; eval{ $folder_view = $folder_view->CreateFolder(name => \[$foldername]); $folder_view = Vim::find_entity_view(view_type => 'Folder', begin_entity => $folder_view); }; if ($@) { if($@->detail =~ /DuplicateName/){ print "$foldername allready exists, getting view of the existing one\n"; $folder_view = Vim::find_entity_view(view_type => 'Folder', begin_entity => $@->\{detail}->\{object}); } } } } } sub main{ ..... createmyfolders(\@dcstruct); }
Hi, try this one: my $vm = Vim::find_entity_views(view_type => "VirtualMachine"); foreach (@$vm) { print $_->\{guest}->\{'hostName'} ; }