Quantcast
Channel: VMware Communities : Discussion List - vSphere SDK for Perl
Viewing all 1577 articles
Browse latest View live

Can't install vSphere SDK for Perl on Linux

$
0
0

 

I'm trying to install the SDK on a Dell Inspiron 9300 laptop with Ubuntu 9.10 Desktop as the operating system.  This computer is not connected to the internet, it is on an internal network.  I'm trying to install the SDK  from source code per the instructions on page 17 of the "vSphere SDK for Perl Installation Guide."  I'm getting the following output when I run 'perl Makefile.PL':

 

 

 

 

 

Warning: prerequisite SOAP::Lite 0.67 not found.

 

 

Warning: prerequisite UUID 0.03 not found. We have 0.02.

 

 

Warning: prerequisite XML::LibXML 1.58 not found.

 

 

Writing Makefile for VIPerlToolkit

 

 

 

 

 

Is Makefile.PL looking for prerequisits whithin it's own source tree or is it looking for packages installed on the system?

 

 


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

Add VM to DRS Rule

$
0
0

I am working on a script and a PowerCLI commandlet seems to already be written for it. The script adds an existing vm to an existing DRS Rule.

 

Here is the code for the commandlet I would like to replicate:

 

$spec=New-ObjectVMware.Vim.ClusterConfigSpecEx
$spec.groupSpec =New-ObjectVMware.Vim.ClusterGroupSpec[] (1)
$spec.groupSpec[0] =New-ObjectVMware.Vim.ClusterGroupSpec
$spec.groupSpec[0].operation ="edit"
$spec.groupSpec[0].info =$DrsGroup
$spec.groupSpec[0].info.vm +=$VM.ExtensionData.MoRef

$Cluster.ExtensionData.ReconfigureComputeResource_Task($spec, $true)


To my understanding, something along the following lines can be done to translate this to Perl:

1. Create a ClusterGroupSpec object with the correct information. I fail here, and am unsure of how to add "info.vm" into ClusterGroupSpec in Perl.

     my $cluster_group_spec = ClusterGroupSpec->new(operation => "edit", info => $drs_rule_name...


2. Pass this as a ClusterConfigSpecEx object into rulesSpec

     my $cluster_config_spec = ClusterConfigSpecEx->new(rulesSpec => [$cluster_group_spec]);


3. Reconfigure with spec as $cluster_config_spec.


What I am confused about is how to pass in info.vm from the PowerCLI. There is no member of info or ClusterConfigInfo called "vm". How would I tell the Group Spec what VM to use?



 

Updated the title to be more informative (it is no longer solely a "translation", the thread contains the answer to the title now).


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?

How to retrieve the value from a custom field

$
0
0

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

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

Problem using vSphere™ SDK for Perl instead of VI Perl Toolkit 1.6

$
0
0

 

We are currently running VI Perl Toolkit 1.6 on SLES 10 SP1 64bit.  When I run a test query using 1.6 I get the expected result.  When I uninstall 1.6 and install vSphere SDK for Perl and run the same query I get this response:

 

 

Can't load '/usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/auto/XML/LibXML/Common/Common.so' for module XML::LibXML::Common: /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/auto/XML/LibXML/Common/Common.so: wrong ELF class: ELFCLASS32 at /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/DynaLoader.pm line 230.

at /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/XML/LibXML.pm line 12

Compilation failed in require at /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/XML/LibXML.pm line 12.

BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/XML/LibXML.pm line 12.

Compilation failed in require at /usr/lib/perl5/5.8.8/VMware/VICommon.pm line 11.

BEGIN failed--compilation aborted at /usr/lib/perl5/5.8.8/VMware/VICommon.pm line 11.

Compilation failed in require at /usr/lib/perl5/5.8.8/VMware/VIRuntime.pm line 15.

Compilation failed in require at /usr/lib/vmware-vcli/apps/performance/viperformance.pl line 11.

BEGIN failed--compilation aborted at /usr/lib/vmware-vcli/apps/performance/viperformance.pl line 11.

 

 

I have installed a prerequisite perl modules and rpms.  Any ideas?

 

 

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?

Globalization - creating non-english language VM

$
0
0


Hi,


I am trying to create a VM with French language words.


vSphere Client allowing and creating fine, but I am getting below error with Perl API call.


Failed to Create virtual machine "fenêtres" due to 


SOAP Fault:


----


 


Fault string: 


Error returned by expat parser: unclosed token


 


while parsing SOAP envelope


at line 2, column 3


 


while parsing HTTP request for method createVm


on object of type vim.Folder


at line 1, column 0


Fault detail: InvalidRequestFault .

Failed to Create virtual machine "fenêtres" due to 



SOAP Fault:



----




Fault string: 



Error returned by expat parser: unclosed token



 



while parsing SOAP envelope



at line 2, column 3



 



while parsing HTTP request for method createVm



on object of type vim.Folder



at line 1, column 0



Fault detail: InvalidRequestFault .




 


Do we have to set any language related parameters ?
For connection i set default local to "en_US" to connect non-english vCenter.


Thanks in advance

How can I build my own ViPerlToolKit from the "Perl SDK for vsphere" we can download here?

$
0
0

Hi there,

 

Did you have any experience on how to build the VIPerlToolKit from the resource here please?

 

What I want to do is to let people get the new APIs in SDK 6.0 by run "ppm install viperltoolkit", but seems ppm only supports version 5.5 now. Is there any way I can make that work please?

 

Thanks

Louis

Viewing all 1577 articles
Browse latest View live




Latest Images