Trondesson's Posts

Hello, At first, I'm new to the vSphere SDK for Perl and to Perl itself. I managed to install the vSphere SDK for Perl on an Ubuntu 14.04 machine. I'm able to connect to my vCenter Servers and... See more...
Hello, At first, I'm new to the vSphere SDK for Perl and to Perl itself. I managed to install the vSphere SDK for Perl on an Ubuntu 14.04 machine. I'm able to connect to my vCenter Servers and run the sample scripts provided with the SDK. In our vCenter Environment we use a global custom field called "email" to store the email address of the virtual machine maintainer with the virtual machine. I'd like to have a script that checks virtual machines for existing snapshots. If a snapshot exists I like the script to gather the email address of the maintainer from the custom field and send an information email to the maintainer. Maybe a script like the one just described already exists. If this is the case it would be nice if someone could show me where to find it. Otherwise I would appreciate it if someone with experience could help me  build such a script. But remember, I'm a newbie to this. So bear with me, please. Thank you in advance for your assistance. Best regards, Tronde
For gods sake, what a stupid typo. :smileyblush: Thank you for your help. Now I get with this code: my $vms = Vim::find_entity_views(view_type => 'VirtualMachine', properties => ['summar... See more...
For gods sake, what a stupid typo. :smileyblush: Thank you for your help. Now I get with this code: my $vms = Vim::find_entity_views(view_type => 'VirtualMachine', properties => ['summary.customValue','name',], ); for my $vm (@$vms) {         my $cv_ref = $vm->{'summary.customValue'};         next unless defined($vm->{'summary.customValue'});         print $vm->name . "\n";         for (@$cv_ref) {                 next unless defined $_->value;                 print "key: ",$_->key,"\tvalue: ",$_->value,"\n";         } } This output: ./SnapshotReminder.pl --url https://<fqdn>/sdk/webService Enter username: ********* Enter password: UHRZ-Ubuntu-E01 key: 2006       value: joerg.kastning@uni-bielefeld.de In line number 5, is 2006 a unique value for the custom field? Is it possible to get the current name of the custom field instead of the id? Thanks a lot for your help and your patience with me.
The following code prints the Name of the VirtualMachine that has an value for the custom field, but it don't print the value as well. my $vms = Vim::find_entity_views(view_type => 'VirtualMac... See more...
The following code prints the Name of the VirtualMachine that has an value for the custom field, but it don't print the value as well. my $vms = Vim::find_entity_views(view_type => 'VirtualMachine', properties => ['summary.customValue','name',], ); for my $vm (@$vms) {         my $cv_ref = $vm->{'summery.customValue'};         next unless defined($vm->{'summary.customValue'});         print $vm->name . "\n";         for (@$cv_ref) {                 next unless defined $_->value;                 print "key: ",$_->key,"\tvalue: ",$_->value,"\n";         } }
Ok. Now my code looks like this: my $vms = Vim::find_entity_views(view_type => 'VirtualMachine', properties => ['summary.customValue',], ); for my $vm (@$vms) {         my $cv_ref = $vm... See more...
Ok. Now my code looks like this: my $vms = Vim::find_entity_views(view_type => 'VirtualMachine', properties => ['summary.customValue',], ); for my $vm (@$vms) {         my $cv_ref = $vm->{'summery.customValue'};         next unless defined($vm->{'summary.customValue'});         print $vm->name . "\n";         for (@$cv_ref) {                 next unless defined $_->value;                 print "key: ",$_->key,"\tvalue: ",$_->value,"\n";         } } For line 6 I got the following error when I tried to run my script. Use of uninitialized value in concatenation (.) or string at ./SnapshotReminder.pl I think I have to use something different than "name". Thank you for your patience.
Sorry, but I didn't get it, yet. At first, I believe that I don't have to skip any VM's in the loop. My custom field is global an all VM's on the cluster have this field. But  not all VM's hav... See more...
Sorry, but I didn't get it, yet. At first, I believe that I don't have to skip any VM's in the loop. My custom field is global an all VM's on the cluster have this field. But  not all VM's have an value for this field. natxoasenjo schrieb: o, and you need to retrieve the 'name' property of the vm as well if you copy paste that From reading the Documentation I guess I have to do something like: my $entity_type = Opts::get_option('VirtualMachine'); my $entity_views = Vim::find_entity_views(view_type => $entity_type); foreach my $entity_view (@$entity_views) { my $entity_name = $entity_view->name; } Could you explain to me how to do this, please?
Good Morning. I tried to adopt your code for my script but it didn't work. my $vms = Vim::find_entity_views(view_type => 'VirtualMachine', filter => { 'guest.guestState' => 'running' }, pro... See more...
Good Morning. I tried to adopt your code for my script but it didn't work. my $vms = Vim::find_entity_views(view_type => 'VirtualMachine', filter => { 'guest.guestState' => 'running' }, properties => ['summary.customValue',], ); for my $value (@$vms) {         my $cv_ref = $value->{'summary.customValue'};         for (@$cv_ref) {                 print "key: ",$_->key, "\tvalue: ",$_->value, "\n";         } } On my vCenter I created the custom field "email" and put for one VM the value "foo@bar.com" in. When I run the script I didn't get any output. Could you explain where I'm wrong?
Hello  @all. In my vCenter I've created a custom field "email". The value for this field is set to the e-mail address of the operator a VM belongs to. I like to retrieve these values in a p... See more...
Hello  @all. In my vCenter I've created a custom field "email". The value for this field is set to the e-mail address of the operator a VM belongs to. I like to retrieve these values in a perl script. But I only found a method to set values for custom fields. For example: $CustomFieldsManager -> SetField(entity => $_, key=> $emailKey, value => "foo@bar.com"); What do I have to do to retrieve the value for the key $emailKey? Could somebody provide a quick and dirty code-snippet, please? Best Regards Trondesson
Hi. I'm very new to Perl-Scripting and the use of the VMware SDK for Perl. Do you have a small example script, that shows how to do that?
Hi. Could you solve your issue in the meantime? I like to do the same, but I have no idea how to get the creator of a snapshot. Regards Trondesson