Quantcast
Channel: VMware Communities : Discussion List - vSphere SDK for Perl

vSphere Perl SDK - querying Baseboard Management Controller address

$
0
0

Does anyone know if its possible to query the Baseboard Management Controller object using the vSphere Perl SDK? This is the object that is defined under the Hardware Status tab for an ESXi host.

All my Dell servers have DRAC modules installed, which come up as a baseboard management controller in vCenter. I'd like to programmatically query these ESXi hosts and return the Management Controller IP Interface of this device.

Based on the SDK, I'd assume this data would be under HostNumericSensorInfo, but when I query that object's name and currentReading properties, I don't get anything close to resembling DRAC/BMC data.

Am I looking at the wrong data object? FYI, the data I'm looking for is not the same as what's in HostIpmiInfo, as that's a user configurable option for DPM.


Hostinfo.pl script printing out too much information

$
0
0

Hi,

I'm new to Perl and the Perl SDK so please go easy on me if this is a known issue or if I'm just doing something wrong. I'm using hostinfo.pl to obviously get some host information but sometimes it returns a crazy amount of information in XML format it looks like. Please see screenshot. This happens a lot like 1/5 runs. I'm on Ubuntu 14.04 using VMWare-vSphere-CLI-6.0.0-351779.x86_64 version. Any ideas? Any help would be greatly appreciated.

Upgraded to vSphere 6 perl SDK , SOAP errors

$
0
0

After successful upgrade to vSphere 6u2, I can no longer run API scripts:


vmcreate.pl --url https://${vcenter}:443/sdk/webService  <parameters>

 

Results in:

Error creating VM 'testVM':

SOAP Fault:
-----------
Faultstring: Permission to perform this operation was denied.
Fault detail: NoPermissionFault

 

 

I have updated and tried the latest perl SDK as well, same error.

I have administrator rights on vCenter level , propagating all the objects.

 

Any suggestions more than welcome!

 

Thanks!

PHP with Perl SDK won't run properly

$
0
0

Hi,

I have a simple Perl script (see below) that grabs the hosts from my vCenter and prints it out to the terminal.

#!/usr/bin/perl -w  
use strict;   
use VMware::VIRuntime;  

Opts::parse();  
Opts::validate();  
Util::connect();  

my $host_views = Vim::find_entity_views( view_type => 'HostSystem');
foreach my $host_view (@$host_views) {               
                print $host_view."=>";             
                print $host_view->name."\n";             
            }
   
Util::disconnect();

When I use PHP's shell_exec(), exec(), passthru(), or popen() to grab the output of the script, I keep getting this error from Apache:

PHP line:

$hosts = shell_exec("/var/www/cgi-bin/gethosts.pl --server <MyvCenterIP> --username <MyUsername> --password '<MyPassword>'");

Error after running PHP:

Error connecting to server at 'https://<MyvCenterIP>/sdk/webService': Perhaps host is not a vCenter or ESX server

But when I run the script in a terminal, it works fine.

# /var/www/cgi-bin/gethosts.pl --server <MyvCenterIP> --username <MyUsername> --password <MyPassword>
HostSystem=HASH(0x3340110)=> <Host1IP>
HostSystem=HASH(0x643b088)=> <Host2IP>
HostSystem=HASH(0x6707778)=> <Host3IP>

I also tried writing a Hello world script just to see if mod_perl is working fine with PHP and it was ok.

Just for more info, I am on CentOS 6. This script worked somewhat in Ubuntu with PHP but had other issues.

Any help would be greatly appreciated.

Trying to return the naa.XXX value for the datatores of a VM

$
0
0

I have been unable to return the Device number for the datastores associated with VMs. Our admins poorly named the datastores so the only way to see what array the VMDKs are being housed on is by looking at the device name.

 

Is a formate like naa.XXXXX etc.

 

thanks

 

 

 

 

 

my$vm_view = Vim::find_entity_views(view_type=>'VirtualMachine',properties=>['name','config'],begin_entity=>$each_host);

 

print"\n\tVirtual Machines on this Host:\n";

 

        foreachmy$each_vm(@$vm_view){

                print"\t\t".$each_vm->name."\n";

                my$datastore = $each_vm->datastore->name;

                print"Datastore:".$datastore;

                my$hardware = $each_vm->config->hardware->device;

                        foreachmy$hw(@$hardware){

                                if(ref$hweq'VirtualDisk'){

                                        print"\t\t\tVirtualDisk:".$hw->backing->fileName."\t".length($hw->backing->fileName)."\t\t".$hw->capacityInKB."\n";

                                        if(length($hw->backing->fileName)>$strlen){ $strlen = length($hw->backing->fileName);}

                                #       $query1->execute($each_vm->name,$hw->backing->fileName,($hw->capacityInKB/1024)) or die(storelater());

                                }

                        }

               

                }

 

}

Newbie question Regarding Opts::validate()

$
0
0

Hey,

 

I have just started using the SDK and have a query regarding the opts::validate().

 

I have implemented perl a script which will loop through an array of vCenters calling a connect subroutine for each vcenter and connect into each one using predefined usernames & passwords.

 

This works great, however, only if the username & password are correct, if not, the script quits..

 

I understand that opts::validate, checks all credentials are valid and if not will display an error message & quit.

In a situation where the credentials for a given vcenter may be incorect is there a way to avoid the script quiting and just move on to the next vcenter?

eg : if(opts::validate == true){login}else{next vcenter}

 

See below for my requirement :

#####

foreach vcenter{

    connect(vcenter, vcenterCredentials)

}

#####

sub connect{

    Opts::set_option('server',      <passed_vcenter>);

    Opts::set_option('username',    <passed_username>);

    Opts::set_option('password',    <passed_password>);

    #~#

    Opts::parse();

    Opts::validate(); <------------- if valid:

                                                  Util::connect()

                                                      ### Do stuff ###

                                                  Util:: disconnect()

                                             else:

                                                     ### Break out of sub connect ###

 

 

}

 

Any help would be appreciated.

Get WWN of a ESXi host by using vSphere SDK for Perl

Determine configure file (.vmx) of a VM by using Vsphere Perl SDK

$
0
0
I have a VM which is deployed in an ESXi of a vCenter. For each harddisk of the VM, I can get path to the place it's stored in the database. So, can I get path of configure file (.vmx) of the VM in the datastore by using vSphere Perl SDK

Determine the VM which are using the configure file (.vmx) in datastore

$
0
0
In the vCenter Server, from the vmx file inside a directory in a datastore, how to detect the VM name which are using this file by using vSphere SDK for Perl. Thanks in advance

Rename a file or folder inside datastore of vCenter using vSphere SDK for perl

$
0
0

Dear all

I want to rename a file or folder in a datastore of an ESXi. How to do this by using vSphere SDK for perl.

Moving vNIC on existing VM to new DVS portgroup

$
0
0

This code: http://pastebin.com/GRsniSVe will run to completion with no errors, but doesn't actually move the vNIC to the designated portgroup.  It successfully finds the portgroup by its VLAN id [Line 79], finds the VM by its name [Line 96], and finds the first vNIC on the VM [Line 121]... after that I'm attempting to:

  1. [Line 126] Create a new connection to the portgroup with DistributedVirtualSwitchPortConnection->new
  2. [Line 130] Create new vNIC backing info using that connection with VirtualEthernetCardDistributedVirtualPortBackingInfo->new
  3. [Line 131] Update the vNIC's "backing" property to the new backing info, preserving any other config it may have **
  4. [Line 147] Create a new device config spec with the updated vNIC using VirtualDeviceConfigSpec->new
  5. [Line 168] Creating a new VM config spec using the new device config spec using VirtualMachineConfigSpec->new
  6. [Line 178] Calling ReconfigVM( ) on the VM, passing in the new VM config spec

 

Printing out these objects at various points appears to show all the correct properties.  Even after the error-free ReconfigVM( ) call, printing out the VM data model at the end of the script [Line 207] shows the updated portgroup connection.  But the vNIC never actually moves.  I'd really appreciate any guidance on what I've done wrong here.

 

** I have a hunch it has something to do with updating the vNIC vs. creating a new empty one, but I don't want to change the vNIC's MAC or any other properties.  I'm thinking if make an empty vNIC with nothing but this new backing info, how will ReconfigVM know which vNIC to update?

 

Thanks!

 

Message was edited by: herrdr (adding line numbers)

Change LUN of RDM of VM using vSphere SDK for perl

$
0
0

I have a VM, which have a raw device mapper disk (RDM). The RDM is added by using LUN 6 of my storage device. Now, I want to change the RDM to LUN 9 (same properties as LUN 6), but it does not success. My source code as below:

my $backing = $disk->backing;

$backing->lunUuid("01000900003030303935374342313743385453315f5343");

$backing->deviceName("vml.01000900003030303935374342313743385453315f5343");

$disk->backing($backing);

$devspec = VirtualDeviceConfigSpec->new(operation => VirtualDeviceConfigSpecOperation>new('edit'), device => $disk, fileOperation=>VirtualDeviceConfigSpecFileOperation->new('replace'));

$vmspec = VirtualMachineConfigSpec->new(deviceChange => [$devspec] );

$task = $vm->ReconfigVM_Task( spec => $vmspec );

But when I run, it return error: "Invalid operation for device '0'". By the same way, I can change mapping file of RDM successfully. Do you have any idea how to change LUN for RDM?

$backing->deviceName("vml.01000900003030303935374342313743385453315f5343");
    $disk->backing($backing);

Create VMFS datastore without format the disk

$
0
0

When I use method CreateVmfsDatastore, it create datastore successfully, but the content of LUN is formated. So, is there any way to create the vmfs datastore but still keep the content of LUN.

Copy delta file of virtual disk (snapshot file) using vsphere sdk for perl

$
0
0
I can use method CopyVirtualDisk_Task (https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.VirtualDiskManager.html#deleteVirtualDisk) to copy normal virtual disk file (.vmdk). But when I copy a delta file (for example -000001.vmdk), the delta file will be change to a normal disk file (it does not keep format). I added parameter destSpec for method CopyVirtualDisk_Task to specify virtualDiskType is delta, but I got error: "The requested operation is not implemented by the server". I'm using vsphere sdk for Perl 5.5, and follow the link https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.VirtualDiskManager.VirtualDiskType.html, delta virtualDiskType is supported from API v5.5. Does anybody know how to resolve this problem? 

creating a virtual machine with php

$
0
0
Perhapsfor someonehandy. Creating a virtual machine with php

Does vSphere Perl SDK for vSphere 6.0 support vSphere 6.5 (VCSA 6.5) ?

$
0
0

I have found out that the behavior of vSphere Perl SDK for vSphere 6.0 is defferent on vSphere 6.5 .

Need Help to solve this issue.

There is no issue on vSphere Perl SDK for vSphere 6.0.

 

If there is a vSphere Perl SDK for vSphere 6.5 please let me know.

Thanks.

 

For example :

 

Running command on vSphere 6.5

Vim::save_session(session_file => $session_file);

Warning: The session being saved to '/tmp/session_api_session7_7_2016_16_5_36' is expired or not authenticated.

 

Vim::load_session(session_file => $session_file);

 

lib/perl5db.pl:197] line 1, near "/tmp/session_api_session7_7_2016_16_5_36"

                (Missing operator before session_api_session7_7_2016_16_5_36?)

Warning: The session being saved to '/tmp/session_api_session7_7_2016_16_5_36' is expired or not authenticated.

 

Error while testing status of connection 'https://10.214.115.9/sdk': Unsupported namespace "urn:vim2" in content of SOAP body

 

while parsing SOAP body

at line 1, column 213

 

while parsing SOAP envelope

at line 1, column 38

 

while parsing HTTP request before method was determined

at line 1, column 0[0m

 

 

while testing status of connection 'https://10.214.115.9/sdk': Unsupported namespace "urn:vim2" in content of SOAP body

 

while parsing SOAP body

at line 1, column 213

 

while parsing SOAP envelope

at line 1, column 38

 

while parsing HTTP request before method was determined

at line 1, column 0[0m

 

 

Error while testing status of connection 'https://10.214.115.9/sdk': Unsupported namespace "urn:vim2" in content of SOAP body

 

while parsing SOAP body

at line 1, column 213

 

while parsing SOAP envelope

at line 1, column 38

 

while parsing HTTP request before method was determined

at line 1, column 0[0m

 

 

Error while testing status of connection 'https://10.214.115.9/sdk': Unsupported namespace "urn:vim2" in content of SOAP body

 

while parsing SOAP body

at line 1, column 213

 

while parsing SOAP envelope

at line 1, column 38

 

while parsing HTTP request before method was determined

at line 1, column 0[0m

 

Warning: The session being saved to '/tmp/session_api_session7_7_2016_16_5_36' is expired or not authenticated.

Info from host cat session file:

cat /tmp/session_api_session7_7_2016_16_5_36

#LWP-Cookies-1.0

Set-Cookie3: vmware_soap_session="\"edaf96069f84a42accbc1f9f7f5081b823f50e95\""; path="/"; domain=10.214.115.9; path_spec; secure; discard; HttpOnly; version=0

 

Task which is created by vsphere SDK can be suspended forever

$
0
0

Dear all

I have a perl script, which use vSphere SDK for Perl to create a task (Please refer to https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.TaskManager.html#createTask), update task progress and set task status. The script and vCenter Server are in different machines. After I create a task, the connection between the two machines are lost, so I cannot set status of task to be completed, and the task will be suspend forever on vCenter Server. Is there any way to resolve that problem?

Thanks and best regards

ThuyNB

Create a schedule task for multiple actions

Querty tags via Perl SDK

$
0
0

Hi,

 

We recently changed from the use of Custom attributes to Tags. Custom attributes can be read, set etc via Perl SDK, no problems there.

 

Now, there seems to be no way to use or at least read Tags using Perl SDK? I'm using the latest Perl SDK vSphere SDK: 6.5.0.

 

Or do I need to use the VMware vCloud API? But how do they work together?

 

Would be awsome if somebody had an example script.

 

Thanks

VIncent

Simple Perl code to get VM parent host

$
0
0

Hello,

 

I am struggling with the object usage in perl; my goal is to pass a VM name as parameter and return some information of the ESXi parent host:

 

use strict;

use Data::Dumper;

use VMware::VIRuntime;

# Auth options

Opts::set_option('server', 'vCenter');

Opts::set_option('username', 'user1l');

Opts::set_option('password', 'password1');

print "Connecting \n";

Util::connect();

print "Connected \n";

my $VMView = Vim::find_entity_view(

'view_type' => 'VirtualMachine',

'filter' => { 'name' => 'eduv0002',}

);

print $VMView->summary->config->name,"\n";

                  print $VMView->runtime->host,"\n";

my $HostRef = $VMView->runtime->host;

print $HostRef;

Util::disconnect();

 

 

But the output is:


Connecting

Connected

vm-test

ManagedObjectReference=HASH(0x2435648)

Undefined subroutine &ManagedObjectReference::name called at ./test.pl line 24

 

So it looks like I can get the host with no issues but I don't know how to access its properties having a Managed Object Reference.

 

Any help is appreciated, thank you.

 

Juan.

Perl SDK 6.5 and Vsphere

$
0
0

Hello,

We are using a Perl script which querry the VCenter and collect the VM annotation property. But we want to change and collect the tags of the VM. But (thanks to this forum) apparently you can use tags with Perl only with if you are 6.5 release vSphere Automation SDK for Perl.

The problem is our version of vSphere is 6.0, if i upgrade my version of SDK Perl to 6,5 will be some problems ?

Thanks in advance (and sorry for my English).

License of vSphere SDK for Perl

$
0
0

Dear all.

I want to know what kind of license of vSphere SDK for Perl (for example: GNU, GPL ...), but I cannot find it anywhere in the Internet.

Do anyone know where to get this information.

Thank you


Redhat 7.3 Perl SDK break python libs

$
0
0

Hello,

 

after we are installing per sdk, ansible and other python related tools are broken.

 

So you has to rm the file /usr/bin/six.pyc.

 

I installed VMware-vSphere-Perl-SDK-6.5.0-4566394.x86_64.tar.gz

 

So why is that included in a perl SDK ?!?

 

rg

Marcel

Adding a disk using SDRS

$
0
0

Hello,

 

I'm trying to add a disk to a VM using SDRS. Here's my piece of code:

 

    my ($vm, $sp, $controllerKey, $unit, $disksize) = @_

 

    my $disk_backing_info =

      VirtualDiskFlatVer2BackingInfo->new(diskMode => 'persistent', fileName => "");

 

    my $disk_spec = VirtualDisk->new(backing => $disk_backing_info,

                                controllerKey => $controllerKey,

                                key => $unit,

                                unitNumber => $unit,

                                capacityInKB => $disksize);

 

    my $disk_vm_dev_conf_spec = VirtualDeviceConfigSpec->new(device => $disk_spec,

                                   fileOperation => VirtualDeviceConfigSpecFileOperation->new('create'),

                                   operation => VirtualDeviceConfigSpecOperation->new('add'));

 

    my $storageMgr = Vim::get_view(mo_ref => Vim::get_service_content()->storageResourceManager);

    my $podSpec = StorageDrsPodSelectionSpec->new(storagePod => $sp->{mo_ref});

    my $configSpec = VirtualMachineConfigSpec->new(deviceChange => [$disk_vm_dev_conf_spec]);

    my $storageSpec = StoragePlacementSpec->new(type => 'reconfigure', podSelectionSpec => $podSpec, vm => $vm->{mo_ref}, configSpec => $configSpec);

    get_logger->debug("got storageSpec: ".Dumper($storageSpec));

 

    my $result = $storageMgr->RecommendDatastores(storageSpec => $storageSpec);

 

 

In my logfile, dumping the $storageSpec leads to this output:

 

2017/04/06 13:21:52 [DEBUG] XXX::YYY::VMDisks::create_disk_on_storagepod:359 - got storageSpec: $VAR1 = bless( {

                 'vm' => bless( {

                                  'value' => 'vm-236336',

                                  'type' => 'VirtualMachine'

                                }, 'ManagedObjectReference' ),

                 'configSpec' => bless( {

                                          'deviceChange' => [

                                                              bless( {

                                                                       'fileOperation' => bless( {

                                                                                                   'val' => 'create'

                                                                                                 }, 'VirtualDeviceConfigSpecFileOperation' ),

                                                                       'operation' => bless( {

                                                                                               'val' => 'add'

                                                                                             }, 'VirtualDeviceConfigSpecOperation' ),

                                                                       'device' => bless( {

                                                                                            'capacityInKB' => 139264,

                                                                                            'backing' => bless( {

                                                                                                                  'fileName' => '',

                                                                                                                  'diskMode' => 'persistent'

                                                                                                                }, 'VirtualDiskFlatVer2BackingInfo' ),

                                                                                            'unitNumber' => 4,

                                                                                            'controllerKey' => '1000',

                                                                                            'key' => 4

                                                                                          }, 'VirtualDisk' )

                                                                     }, 'VirtualDeviceConfigSpec' )

                                                            ]

                                        }, 'VirtualMachineConfigSpec' ),

                 'podSelectionSpec' => bless( {

                                                'storagePod' => bless( {

                                                                         'value' => 'group-p201254',

                                                                         'type' => 'StoragePod'

                                                                       }, 'ManagedObjectReference' )

                                              }, 'StorageDrsPodSelectionSpec' ),

                 'type' => 'reconfigure'

               }, 'StoragePlacementSpec' );

 

 

Right after that, calling RecommendDatastores throws this error:

 

2017/04/06 13:21:52 [ERROR] XXX::Mojo::Webvm::__ANON__:310 -

SOAP Fault:

-----------

Fault string: A specified parameter was not correct.

StoragePlacementSpec.podSelectionSpec.storagePod

Fault detail: InvalidArgumentFault

 

I don't get what's wrong here and I've tried many different ways of passing the storagePod mo_ref without any success so far. Years ago, the very same problem has been posted here Add VMDK to VM using SDRS recommendation  without getting any response.

 

VMWare SDK for Perl is 6.5.0 (but also tried with 6.0.0 before).

 

Could anyone give me any hint how to call RecommendDatastores correctly?

 

Regards, Andreas

Perk SDK script returns nothing

$
0
0

I'm trying to configure Icinga to monitor my VMware environment and I've hit a wall.

 

I am using Ubuntu 16.4 LTS as the base OS. I've installed all of the perl modules for the SDK and installed the SDK. However when I try and run vminfo.pl for exmaple, it just sits there.

 

My perl version is 5.22, is there any checks or logs I can view to try and fix this?

 

Thanks

How vmware mob is implemented?

$
0
0

I need to redesign our existing perl code, currently we look for objects like VM and Hosts using the name then make vix call to get the object reference this approach is slow in some environments.

We need to redesign this approach to make things faster so I am looking for some helpful info. I noticed that mob accesses the objects using moref_id so may be if we do that it will make thinsg faster. But when I went to implement it I realized that I need to make same vix api call to find moref_id so it will be slow again so I was wondering how mob is implemented. Do they use any cache for name and moref_id? Any information in this area will be very helpful?

Vim::find_entity_view in vSphere 6.5

$
0
0

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

new to perl SDK, can i use 6.0 sdk to contact and do things with esxi 6.5

$
0
0

Hell all,

 

I am new to perl sdk, i am wondering if i can use sdk 6.0 with esxi version 6.5

trouble matching snapshot

$
0
0

I have these 2 subroutines:

sub _remove_snap {
    my ( $vm ) = @_;

    # skip if no snapshots on vm
    unless ( defined $vm->snapshot ) {
        print $vm->name . " has no snapshots, skipping\n";
        return;
    }
    my $snaps = _find_snapname( $vm->snapshot->currentSnapshot,
        $vm->snapshot->rootSnapshotList );

    print Dumper $snaps;
}

sub _find_snapname {
    my ( $ref, $tree ) = @_;
    my @snaps;
    foreach my $node (@$tree) {
        print $node->name, "\t" . $node->createTime . "\n";
        if ( $node->name eq $snapname ) {
            push @snaps, $node
        }
        _find_snapname( $ref, $node->childSnapshotList );
    }

    return \@snaps;
}

And I cannot seem to return the snapshot information from _find_snapname back to _remove_snap. If I print with Dumper at the end of _find_snapname right before the return \@snaps statement, I see the correct info displayed on screen, but when dumping it on the _remove_snap subroutine, then I get an empty $VAR1 = [];

I am obviously missing something obvious, but I do not see it. Any help greatly appreciated.


How to remove permission for vm with perl script?

Assign IP to a Windows VM via API

$
0
0

Hi,

 

Can someone guide me on how we can assign ip to a Windows VM dynimically i.e., assigning IP later point of time after initial customization using API or any other alternate method?

 

Thanks

Unexpected arguments while elevating FolderOperations::CreateFolder subroutine

$
0
0

Hi! We have vCenter v6.0 installation and i'm trying to write a Perl script. One part of this script should create a folder. For example - called "123"

Here is the perl code I wrote:

$folder = Vim::find_entity_view( view_type => 'Folder', filter => { 'name' => $folder_name } );

$folder=$folder->CreateFolder("123");

 

Unfortunately, an error occured:

 

Odd number of elements in hash assignment at (eval 186) line 4.

Unexpected arguments: 123 at (eval 52) line 143.

VimService::build_arg_string(ARRAY(0x37ccdd8), HASH(0x37ccd60)) called at (eval 52) line 1183

VimService::CreateFolder(VimService=HASH(0x32b2c98), "_this", ManagedObjectReference=HASH(0x42623a8), 123, undef) called at /usr/share/perl/5.22/VMware/VICommon.pm line 1884

ViewBase::invoke(Folder=HASH(0x418b420), "CreateFolder", 123, undef) called at (eval 186) line 5

FolderOperations::CreateFolder(Folder=HASH(0x418b420), 123) called at /var/www/html/perl/createvm.pl line 94

main::deploy_template() called at /var/www/html/perl/createvm.pl line 174

 

Can somebody assist? How should i fix this?

Install VMWare Perl SDK on Debian 9

$
0
0

Dear All

 

I try to install VMWare Perl SDK 5.5 and I also tried 6.5 on Debian9 so I'm able to monitor it over Nagios.

 

But the installation always fails with:

Openssl-devel is not installed on the system.

openssl-devel 0.9.7 is required for encrypted connections.

Please install openssl-devel version 0.9.7 or greater.

 

e2fsprogs is not installed on the system

 

e2fsprogs 1.38 is required for UUID.

Please install e2fsprogs 1.38 or greater.

 

I googled it but couldn't find a solution. First of all I can't find openssl-devel anywhere to install and second when I do apt-get install e2fsprogs, I get the message that I have already have the newest one installed.

e2fsprogs is already the newest version (1.43.4-2).

 

Any idea what how I can make it work?

Tutorial: Create inventory tree using vSphere SDK for Perl

Tutorial: Get VM performance data using vSphere SDK for Perl

Modify vApp properties with VI Perl

$
0
0

Hello,

 

I have some VMs I'm using as templates, with custom OVF properties, like shown below :

 

On this VM there is a script run at boot time that retrieves these properties and configure some stuff in the VM.

This way, to instanciate my template, I can clone the VM, change the properties, and restart the new VM. This is working fine.

 

I can run this entire process with ovftool , from a linux host.

 

However, I would like to change my current process, and do it using VI Perl api.
I can clone the VM, but I'm stuck at modifying these vapp properties. I'm able to display them but not update.

 

Does some one have any pointer on this topic?

 

Thanks!

 

chris


Deleting a template from vSphere

$
0
0

Does anyone know a way to delete a template from vSphere, e.g. using the Perl SDL?

I can delete VMs using the SDK, or the rest API (using Curl).

But templates don't show up in the list of VMs. I can see the vm-id in the Managed Object Browser, but can't see anyway to get it from the rest API.

EventFilterSpecByTime not working ?

$
0
0

Hello,

I'm trying to write a little perl script to collect events related to VM from the last 24H on a vCenter with the Perl VMware SDK 6.5

I use this code:

my ($Y,$M,$D,$H,$Min,$S,$st,$et);


    my $today = DateTime->now;
    $Y = $today->year;
    $M = $today->month;
    $D = $today->day;
    $H = $today->hour;
    $Min = $today->minute;
    $S = $today->second;
    $st = DateTime->new( year => $Y, month => $M, day => $D-1, hour => $H , minute => $Min , second => $S);

    $et = DateTime->new( year => $Y, month => $M, day => $D , hour => $H , minute => $Min , second => $S);
 
    
    my $timeSpec = EventFilterSpecByTime->new(beginTime => $st);

    my $filterSpec = EventFilterSpec->new(time => $timeSpec, type => ["VmCreatedEvent", "VmClonedEvent","VmDeployedEvent", "VmRegisteredEvent","VmRemovedEvent"]);
    my $content = Vim::get_service_content();
    my $eventMgr = Vim::get_view(mo_ref => $content->eventManager);
    my $results = $eventMgr->CreateCollectorForEvents(filter => $filterSpec);
    my $eventCollector = Vim::get_view(mo_ref => $results);
    $eventCollector->ResetCollector();
    my $events = $eventCollector->latestPage;

But the time filter seems to be not working, I have some result from the last few days, if i change the range I have alway the same result, same if I delete the filterSpec.

With powercli and getvi-event I can get events from several month but for this need I need to use Perl.

Did you already success to use a filterspec with Perl?

 

Thanks,

 

Raphaël

find_entity_views API is failing

$
0
0
One of our cusotmer has reported two issues related to vmware API on same vcenter and hence putting the details of both issues :

Issue 1 (Wrapper timeout issue): Customer reported that our product's backup is failing with wrapper timeout issue and when we deep dived into it, it was observed that "find_entity_views( view_type => 'Datacenter' )" API is not returing any response and hence the application is throwing timeout issue.
Important point to notice here is when we moved a datastore to another datacenter, the backup was successful. But as customer has huge environment they are not willing to move their datastores to another datacenter. Hence we need your help to look into this from API side and want to know what may be the possible reason for failures on a particular datacenter.

Issue 2(Java Heap Issue): Customer reported that the backup is failing with Java Heap issue(OutOfMemmory error) and when we looked into it, it was observed that when tapplication tries to get details of virtual machines through API "find_entity_views( view_type => 'VirtualMachine')", it fails with OutOfMemory issue.
This issue is occurring on all the datastores of a particular datacenter. The number of virtual machines are 6000+ but the same configuration was working fine till the customer observed this issue. We suspect the response returned by this API might have some garbage/irrelevant data due to which it is not able to store the API response now and end up with outOfMemory issue.

Kindly note that both the issues started occurring from a particular day and customer denied any configuration changes on that day. Prior to that everything was working as expected. 

6.5 DATA STORE VMF6 SPACE RECLAIM

$
0
0

Hello Team

 

I have removed few vms from tthe data store , unfortunately, i am not able to reclaim the space and there  is no auto reclaim , anybody have idea how to reclaim the space. I did " Edit space reclamation" but no use this option.

 

Thanks

Yoonus

SSPI = Cannot complete login due to an incorrect user name or password.

$
0
0

HI

We use perl scripts to log into vCenter 5.5 with Single Sign On. However if I use the same script to point to our 6.0 or 6.5 vCenter it fails. I updated to the latest SDK and still the same. Powercli and pyvmoni just work

Example 

    vminfo.pl --server myserver.internal --passthroughauth --passthroughauthpackage Kerberos

 

Our 5.5 vCenter was Windows and the newer ones are vcsa, in case that makes a difference.

 

Thanks

Error while provisioning a vm in RegisterVM_Task for vsphere 6.5 using vim jar

$
0
0

<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
soapenv:Body
soapenv:FaultServerFaultCode
Required parameter path is missing

while parsing call information for method RegisterVM_Task
at line 1, column 88

while parsing SOAP body
at line 1, column 82

while parsing SOAP envelope
at line 1, column 22

while parsing HTTP request for method registerVm
on object of type vim.Folder
at line 1, column 0</soapenv:Fault>
</soapenv:Body>

How to get tagging related objects

$
0
0

Hi guys,

I'm looking for a way to list on a vcenter, all tags.

Then, all objects associated to those tags.

I Know that I'm supposed to use Vapi on Vcenter 6.0+, and I mannaged to use correctly the script of the Automation SDK GitHub 

But I am not familiar enough with Perl to achieve what I want.

Any help will be appreciated !


How we can collect vCenter Cluster Used or Available reservation

$
0
0

Hi,

I am looking for a way to find out Cluster's Resource Reservation info at least for CPU and Memory...

 

I collected total reserved capacity some how like...

my $cluster_view = Vim::find_entity_views(view_type => 'ClusterComputeResource', filter => { name => "$cluster" }, properties => [ 'summary' ]);

# Total Reservation Capacities

my $effectiveCpu = $$cluster_view[0]->summary->effectiveCpu;

my $effectiveMemory = $$cluster_view[0]->summary->effectiveMemory;

 

I really appreciate if any suggest me which views will give me the Used or Available Reservation...

 

Used_Reservation.png

Provisioning virtual NVDIMM with Perl SDK

$
0
0

Hi everyone!

I am trying to provision a virtual NVDIMM device using the Perl SDK. Specifically how the default storage policy for the PMEM datastore backing the device is determined / used.

I actually have been able to provision the virtual NVDIMM using a storage policy ID I  have determined with a REST call against the vSphere RESTful API service. But that requires a vCenter server and I was hoping to run this script against standalone hosts as well.

I was hoping some folks here might have some examples of provisioning a virtual NVDIMM device using the Perl SDK

Thanks!

How to get alarm definations list on a datacenter with sdk ?

$
0
0

Hello,

 

i'm trying to get the preset alarm definations list on datacenter

but all I can find is the powerCLI scripts which is not what I need,   like get-alarmDefination

Does the sdk provide the interface to achieve the function?  How I can get the list of all preset alarm definations?

 

 

 

Thanks for any help.

Binding ip-address into a newly-generated virtualNic

$
0
0

I'm writing perl application about  creating virtualNic  in  vCenter.  Until now, the virtualNic is generated successfully  and  the mac-address can  be  retrieved,  but  I  have to wait fourty-second  for  the  ip-address  returned.  I  want to know is there any efficient way to  get  ip-address  immediately  after  generating the  virtualNic? Or,  if  there is another way to  allow me  bind  a  newly-generated  ip-address  into the  virtualNic?  thank  you  for  help.  

vSphere SDK for non-system Perl

$
0
0

Hi All,

Is installing the vSphere SDK for Perl using a non-system Perl suppotred?  Meaning, if I download, compile and install a specific version of Perl on my Linux server can I install the vSphere SDK for Perl on that version?

I do see a comment in vmware-vsphere-cli-distrib/vmware-install.pl which says, "If your copy of perl is not in /usr/bin, please adjust the line above." (to change the interpretter of the script).  Even after changing that to my non-system Perl I am having issues making it work.  So would like to know if this is even possible.  I've tried Perl 5.28.2 and also 5.20.3.  

Thanks,

Chris

VMWare perl SDK - What packages are required in addition to main package

$
0
0

Hi,

I'm try to run list_vms.pl using perl sdk vmware.

 

So I installed:

VMware-vSphere-Perl-SDK-6.7.0-8156551.x86_64.tar.gz

 

However the perl sdk vmware does not appear to install:

Com::Vmware::Vapi::Util::Logger

which is required by the perl script, list_vms.pl

 

Question

Is this by design or did I do something wrong during the install?

If not, what other perl VMWare SDK packages do I need?

 

ps. perl is not very helpful as the main SDK requires lots of modules

and even using cpanm [cpanminus] there were many packages that I need that

needs to be done by hand. This is not an VMWare problem but more of a perl

problem.

Next VMware Perl SDK version

$
0
0

Hi VMware team,

The last Perl SDK 6.7 was released April 2018 and I'm having some issues while using it:

Can't load class 'ArrayOfDatastoreEventArgument' at /usr/share/perl5/VMware/VIMRuntime.pm line 52, <IFS> line 11.

Can't load class 'HostSubSpecificationUpdateEvent' at /usr/share/perl5/VMware/VIMRuntime.pm line 52, <IFS> line 51.

Undefined subroutine &HostSubSpecificationUpdateEvent::get_property_list called at /usr/share/perl5/VMware/VICommon.pm line 2543

I understand these are fixed in a future release according to https://github.com/vmware/vsphere-automation-sdk-.net/issues/19

Do you have a roadmap of when the next VMware Perl SDK version will be released?

I appreciate your help.

 

Best regards,

Miguel Molina






Latest Images