kri-2's Posts

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, I am just on trying my first steps with the new great REST API of vCenter 6.5. One Task that often arises, is listing all Hosts of a given Cluster. I first tried to accomplish this Task vi... See more...
Hi, I am just on trying my first steps with the new great REST API of vCenter 6.5. One Task that often arises, is listing all Hosts of a given Cluster. I first tried to accomplish this Task via the APIExplorer. So first step I got a sessionid (token), no Problem. (rest/com/vmware/cis/session) Second step I tried to list all Hosts of the vCenter, fine. All Hosts are returned in a nice json string. (rest/vcenter/host/) But now I want to set a filter as documented. So I entered the name of an existing cluster in the textfield "filter.clusters" And now I allways get an empty result, no matter what kind of Format I give the filter: test_cluster "test_cluster" ["test_cluster"] <- this should be correct, since it is expecting a Array of strings {["test_cluster"]} A Little python script confirms the problem - no data, when a filter is given. Did anybody had yet the task to filter the result of a REST query? Any ideas here? Chris
Hi folks, we have installed our first vCenter 6.5 appliance and now a script that ever worked without any problems doesn't work anymore. The PerlSDK is still on 6.0, but I can not believe tha... See more...
Hi folks, we have installed our first vCenter 6.5 appliance and now a script that ever worked without any problems doesn't work anymore. The PerlSDK is still on 6.0, but I can not believe that they did such a change in this fundamental function. To simplify it, I try to find a given host: $host_view = Vim::find_entity_view( view_type => "HostSystem",                                     filter    => {'name' => qr/^$host/i} );       This won't give a object back although everthing in the name is correct of course. In vCenter 5.5 this works. What I found out, that script needs the properties attribut newly: $host_view = Vim::find_entity_view( view_type => "HostSystem",                                     filter    => {'name' => qr/^$host/i},                                     properties => [ 'name'], ); this works again, but e.g. properties => [ 'name', 'summary', 'config'] does not again. Since I need more properties (summary and config for the configManager) this does not realy help me. So as summary: find_entity_view() seems to need the properies attribut now, but than accepts exact only one property. Did anyone hit the same problem yet? Is this a known bug? Any idea how to work around this problem? Any help would be appreciated. Chris
Thanks stumpr! The floppy is needed for an automated installation. Chris
Hi all, another question came up today. I have to create a vm and add a floppy drive. Sometimes the floppy drive should be backed by an Image, sometimes not. I could create two VirtualFloppy ... See more...
Hi all, another question came up today. I have to create a vm and add a floppy drive. Sometimes the floppy drive should be backed by an Image, sometimes not. I could create two VirtualFloppy Objects, depending on having an image or not. This blows up my code, so it would be nice to add the backing to the objects afterwards if needed. In my opinion the code should look roughly like this, but this throws an error: Can't modify non-lvalue subroutine call at.... sub getFloppy{ my $image =$_[0]; my $virFloppy = VirtualFloppy->new( connectable => VirtualDeviceConnectInfo->new(allowGuestControl => 'false',                                                                                                                                           startConnected => 'true',                                                                                                                                           connected => 'true'),                                                             controllerKey => 400,                                                             key => 8000,          ); if($image){       $virFloppy->backing=VirtualFloppyImageBackingInfo->new(fileName => $image); } return $virFloppy } Any ideas? Thanks, Chris
great stumpr! Thank you very much! Would you mind using it in production, since it is not documented? Chris
Hi all, I am looking for some performance improvements for some of my scripts. One thing that would help me a lot would be to expand a view afterwards. Lets have an example. I get a trimed d... See more...
Hi all, I am looking for some performance improvements for some of my scripts. One thing that would help me a lot would be to expand a view afterwards. Lets have an example. I get a trimed down HostSystem view by using "properties". Later in the script I need to view some values from the summary of this host and now it would be great to expand the view to the properties "name" and "summary". my $host_view = Vim::find_entity_view(view_type => 'HostSystem', properties => ['name'], filter => {'name' => qr/hostname/i}); print $host_view->{name}; #.... #expand $host_view to have summary hash print $host_view->{summary}->{runtime}; Of course I could insert 'summary' in the properties array in this simple example. But, there are situations where maby the summary hash is not used due some not matched conditions and so it would have been loaded for nothing. Any ideas how to do this? Thanks in advance, Chris
Hi all, a rarely accident today brings me here again. Today morning a customer tried to create a vm via a website that is talking to our own perlscripts. The objective cluster was the one... See more...
Hi all, a rarely accident today brings me here again. Today morning a customer tried to create a vm via a website that is talking to our own perlscripts. The objective cluster was the one that we were updating at this moment. And the loop that picks a host randomly picked a host that was going to maintenance at this moment :-(. Of course the loop skips host that have "inMaintenanceMode" set to 1. But this is not the case while hosts are going to maintenance but are not ready yet. vCenter throws a fault.InvalidState.summary error. Should we really catch this one or is there a way to query the host if it accecpts the creation of a vm at the moment? Chris
The logs were allready lost the next day. So no more debugging... Chris
Hi and thanks stumpr, yes I have not seen this error yet too, although using the Perltoolkit since years. Anyhow this error was reality and stopped my scripts. I also wrote a short script (to be... See more...
Hi and thanks stumpr, yes I have not seen this error yet too, although using the Perltoolkit since years. Anyhow this error was reality and stopped my scripts. I also wrote a short script (to be sure nothing else is wrong), only trying to log in and this was hanging too (also from different clients). Whatever, I have a timeout around this part now which does not interfere. I did not analyse the logs, but this i a good hint. Maby I find the time today... Chris
For those having a similar problem, I have solved it using the alarm function.         my $LoginTimeout = 10;            eval {                      local $SIG{ALRM} = sub { die "a... See more...
For those having a similar problem, I have solved it using the alarm function.         my $LoginTimeout = 10;            eval {                      local $SIG{ALRM} = sub { die "alarm" };                        alarm $LoginTimeout;                          Vim::login(service_url => $s, user_name => $u, password => $p);                      alarm 0;         };          if($@ eq "alarm"){              print "timeout after $LoginTimeout s...";          }         catch other $@....<br>
Hi all, I have a script that is connecting to a few vCenter servers and reading some information. This had a problem today morning. It figured out that one vCenter is not accepting t... See more...
Hi all, I have a script that is connecting to a few vCenter servers and reading some information. This had a problem today morning. It figured out that one vCenter is not accepting the login although the service is running. If I connect via vCenter Client I get the message "could not login. The vCenter Server took too long to response".  If I would get this answer as an error from Vim::Login this would be great as I am using a eval block around it. But I don't get a timeout...Vim::Login tries forever and does not come back, even after minutes and hours. I know, this is an error which does not come often and it can be solved by restarting the vCenter server. But it would be very important for me to catch this error in perl to. Do I have to write my own timeout routine around the Vim::Login? Any ideas why Vim::Login does not timeout here? Any help would be appreciated. Chris
Hi, I am trying to reboot a host with the rebootHost_Task (MOR _this, boolean force). Therefor I need a MOR of he host. But how do I get this, if I am directly connectet and not via vCenter... See more...
Hi, I am trying to reboot a host with the rebootHost_Task (MOR _this, boolean force). Therefor I need a MOR of he host. But how do I get this, if I am directly connectet and not via vCenter? I tried: ManagedObjectReference mor = si.getServerConnection().getServiceInstance().getMOR(); si.getServerConnection().getVimService().rebootHost_Task(mor, true); But this throws an error: The request refers to an unexpected or unknown type. Any help would be appreciated. Chris
Hi all, I am trying to read the vCenter inventory step by step (not recursive) to lazy fill a TreeView. Starting with the rootFolder I want to get deeper into the vCenter structure without hav... See more...
Hi all, I am trying to read the vCenter inventory step by step (not recursive) to lazy fill a TreeView. Starting with the rootFolder I want to get deeper into the vCenter structure without having to differ if the child object is a HostSystem, ClusterComputeResource, Folder, Datacenter, ... For each Folder I can use folder.getChildEntity(); But how do I get the childs of all the others (Datacenter, ClusterComputeResource,...) ? I saw some examples using the InventoryNavigator, but they all used rootFolder as start. Is it somehow possible to pass any ManagedEntity? I think of an method like this: public static ManagedEntity[] returnChilds (ManagedEntity mE){      // get all childs of mE (HostSystem, ClusterComputeResource, Datacenter, Folder, VM)      ManagedEntity[] mEs = mE.getChilds();      // and return them      return mEs; } Any help would be appreciated! Greatings, Chris
Thanks for this. I will have a look at this script.
Hi, I studied the performance example "viperformance.pl" to understand how to retrieve performance data. But it is really hard for me to alter the script doing what I need. I need a script th... See more...
Hi, I studied the performance example "viperformance.pl" to understand how to retrieve performance data. But it is really hard for me to alter the script doing what I need. I need a script that prints the physical read and write latency of each LUN of a host. Did anyone wrote a script that does something similar? Any help would be appreciated, Chris
Nice to hear, that it speeds up your script Chris
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, I am trying to change the Subnetmask of a Vmotion Network via Perl SDK. For this I wanted to use the method UpdateIpConfig from the HostVMotionSystem. But the documentantion mentions, that... See more...
Hi, I am trying to change the Subnetmask of a Vmotion Network via Perl SDK. For this I wanted to use the method UpdateIpConfig from the HostVMotionSystem. But the documentantion mentions, that HostVMotionSystem ist deprecated and you should use virtualNicManager. But where has the UpdateIpConfig gone? It is not known in the virtualNicManager. Your help is greatly appreciated Greetings, Chris
Hi Nz3k, great, thanks! Chris