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

How to get alarms list on a datacenter with sdk ?

$
0
0

Hello,

 

i'm trying to get the alarms triggered on each datacenter objects.

On the VSphere client I can see 5 alarms (4 warnings, 1 Alert)  triggered, and

I didn't succeded in retrieving this alarms through perl scripts.

 

Can I get some help on that ?

 

This is a part of my perl code :

 

 

        my $alarmMgr  = Vim::get_view(mo_ref => Vim::get_service_content()->alarmManager);
        my $alarmList = $alarmMgr->GetAlarm();
        foreach (@$alarmList)
        {
                my $alarm_moref = Vim::get_view(mo_ref => $_);
                my $alarm = $alarm_moref->info;
                if( $alarm->enabled )
                {
                        my $alarm_entity_moref = Vim::get_view(mo_ref => $alarm->entity);
                        my $alarmStates = $alarmMgr->GetAlarmState(entity => $alarm_entity_moref);
                        print Dumper($alarmStates);
                }
        }

 

Thanks for any help.


Script need to deploy a VM from a template

$
0
0

Hi All,

 

greetings !

 

I am pretty new to vmware,  It would be great if any of you could provide me with a Script to Deploy VM from an existing VM template ?

 

The VM templates resides on a ESXserver part of a DATACENTER , the Datacenter is on a VC(virtual center server) & the script should be able to handle deploying the Template to a different Datacenter under the same VC & also have provision to specify the <datastore> for deploying VM.

 

Thanks in advance !

 

Regards,

Vijay

Options supported by CustomizationLinuxOptions

$
0
0

Hi,

 

I am trying to understand what options are supported by the CustomizationLinuxOptions object, And you to use it (Maybe someone have an example)?

 

Thanks you,

 

Dori

Guest customization with cloneVM task: IP & default GW

$
0
0

Hi All,

 

I am using the cloneVM_task to clone a VM machine with customiztion object. The VM is linux (rhel5) installed with vmware-tools and i am using vSphere 5.0.

 

 

I have 2 question about network customiziton:

 

1. Can i customize the VM Guest NICS to not start at all - I mean not to run at all on startup (i.e setting "ONBOOT=NO" in the ifcfg-eth* file).

    I tried using CustomizationUnknownIpGenerator as an IP for each device - but it fails. Setting DHCP is working.

 

2. Can I configure a default GW for the guest VM, and if so - how? (i.e - i mean to change the /etc/sysconfig/network file enty "GATEWAY=...")

 

Thanks for your help,

 

Dori

Download a file from datastore

$
0
0

Hi,

 

is there a way to use the datastorebrowser to download/put a file from a datastore?

As there is a way in the vCenter to do this there should also be one doing it with the viperltoolkit.

 

Any ideas?

 

Bye, Chris

Example of using the "CustomizationCustomIpGenerator"

$
0
0

Hi all,

 

I'm trying to use the "CustomizationCustomIpGenerator" (- Use a command-line program configured with the VirtualCenter server), to customize nic IP setting on linux Rhel5 VM. The argument i'm passing usint the "#argument" property is a script on my VM.

So far it failed.

 

Does anyone have an example on how to use it?

 

Regards,

Dori

openSSL certificate verification

$
0
0

 

I have seen others talk about this issue but they never stated what resolved their problem.

 

 

Problem: When you do a connect.pl from the Perl utilities and get Error: Server version unavailable at 'https://asciesx1/sdk/vimService.wsdl'. If you do a wget it returns.

 

 

16:02:15  https://asciesx1/sdk/vimService.wsdl

Resolving asciesx1... 172.29.59.25

Connecting to asciesx1|172.29.59.25|:443... connected.

ERROR: cannot verify asciesx1's certificate, issued by `/C=US/ST=California/L=Palo Alto/O=VMware, Inc./emailAddress=ssl-certificates@vmware.com/OU=VMware ESX Server Certificate/CN=asciesx1/unstructuredName=1250522187,564d7761726520496e632e':

  Self-signed certificate encountered.

To connect to asciesx1 insecurely, use `--no-check-certificate'.

Unable to establish SSL connection.

 

 

I have tried to configure openssl and give the ca certificate to the client machine so that it could use it for verifying. These are self-signed certificates.

 

 

unable to clone vm get error-A specified parameter was not correct. spec.identity

$
0
0

I am using vmclone2.pl (ref -http://communities.vmware.com/docs/DOC-12270) to customize guest OS to set a specific IP address (and other network settings. ) I am using VSphere SDK for Vsphere 4.1 ESXi and I am trying to clone a linux vm from a template which has RHEL_57_64 bit.

 

I am getting the following error

Fault string: A specified parameter was not correct.spec.identity

 

Can someone give me pointers as to why it could be failing?


What is --datacenter referring to?

$
0
0

Hello i am trying to validate my insatllation of vSphere 4.1 SDK Perl.

 

The command syntax to validate is the following:

 

perl discovery/datacenterlisting.pl --server --datacenter --username --password

 

I do not know what my datacenter is.  Ive tried my Vcenter Server hostname, i've tried both of my hosts, nothing will work.

 

my question is what is the --datacenter referring to?

 

how do i find out the hostname of my datacenter?

VMware Auto Deploy and vSphere SDK for Perl

$
0
0

Hello,

 

I know VMware PowerCLI has few cmdlets which helps us to add  ESX Software depot, create rules and apply rules. is there any way to achive the same in vSphere SDK for Perl?

 

Thanks

Creating virtual disks on specific SCSI Controllers (vdiskcreate.pl)

$
0
0

I have virtual machines that just have the default SCSI Controller 0 installed with one disk attached.

 

What I want to do is create additional SCSI controllers up to the limit (SCSI Controllers 1, 2 and 3) and attach a single disk to each one.

 

vdiskcreate.pl looks like it would work fine for attaching new disks to SCSI Controller 0, but it doesn't seem to allow the creation of new SCSI Controllers in it or attachment of disks to specific SCSI Controllers.

 

I didn't find a script that specifically allows for the creation of new SCSI Controllers (vmreconfig.pl doesn't seem to do this).

 

What is the "best" way to go about adding 3 new disks on 3 new SCSI Controllers to a VM?  The vSphere GUI allows you to do this pretty easy (add a disk and choose a SCSI Controller and address for the disk). What's cool about the GUI is that it creates the SCSI Controller for you when you do this, you don't have to specifically add the SCSI controller first when you are adding a disk.

 

But manually running the GUI for tons of VMs would be a pain.

 

Thanks for any recommendations!

 

CJ

VMware Scripting API - Installation fails on Debian Squeeze

$
0
0

Hi!

 

I get an error while installing (compiling) the VMware Scripting API package. It is reproduceable on at least 2 different Debian Squeeze systems.

 

Here you can see the last make lines:

 

/build/mts/release/bora-39850/bora/lib/keyLocator/error.c:81: undefined reference to `pow'
vmcontrol.o:/build/mts/release/bora-39850/bora/lib/keyLocator/error.c:81: more undefined references to `pow' follow
/usr/bin/ld: final link failed: No space left on device
collect2: ld returned 1 exit status
make: *** [blib/arch/auto/VMware/VmPerl/VmPerl.so] Error 1

It indicates a full disk but df shows:

 

Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sdb1     ext3     65G   34G   28G  55% /
tmpfs        tmpfs    4.0G     0  4.0G   0% /lib/init/rw
udev         tmpfs     10M  652K  9.4M   7% /dev
tmpfs        tmpfs    4.0G     0  4.0G   0% /dev/shm

Please move this topic to the correct forum if I choose the wrong one.

 

Best regards,

Sebastian

"esxupdate -l query" equivalent for Perl SDK

$
0
0

Hey Guys,

 

Is there a way to get a list of patches installed on a given list of hosts within a vCenter environment in a similar manner to the output of "esxupdate -l query" ?  I've found several PowerCLI examples online, but nothing for Perl.

 

Appreciate the help in advance!

applying a host profile to an ESX host

$
0
0

Having trouble doing this, likely because I don't understand quite what I'm doing.  From the UI, you can associate a profile with a cluster.  Then, you can right-click on a host within the cluster and do "Apply Profile".  Works great, and requires no extra inputs.  From the perl SDK, it's not so easy.

 

From the docs, it looks like it's two steps: (a) ExecuteHostProfile followed by (b) ApplyHostConfig_Task.

 

So, my code looks like this.  First I look up the profile, by name:

 

     my $sc = Vim::get_service_content();
     my $hostProfileManager = Vim::get_view(mo_ref => $sc->hostProfileManager);
     my $profiles = $hostProfileManager->profile;
     my $profile;
     for my $ref (@{ $profiles }) {
          my $obj = Vim::get_view(mo_ref => $ref);
          if ($obj->name eq $profileName) {
               $profile = $obj;
          }
     }

     die unless defined $profile;

 

then I apply it like so:

 

     my $res = $profile->ExecuteHostProfile(host => $host);

     my $taskRef = $hostProfileManager->ApplyHostConfig_Task(host => $host, configSpec => $res->configSpec);

 

Using the 4.x API, this fails with "Cannot apply the host configuration".  If I take the contents of $res->requireInput (which contains two items) and feed it back into ExecuteHostProfile as a "deferredParam", the resulting configuration doesn't seem to change...  I continually get the same two items back in $res->requireInput, regardless how many times I feed them back tino ExecuteHostProfile.

 

If I use the 5.x API in order to get access to the "userInput" parameter in the ApplyHostConfig_Task call, and pass the same $res->requireInput via that parameter like so:

 

     my $taskRef = $hostProfileManager->ApplyHostConfig_Task(host => $hostObject, configSpec => $res->configSpec, userInput => $res->requireInput);

 

I get this instead:

 

     Can't call method "serialize" on unblessed reference at .../vsphere-sdk-5.0/lib/VMware/share/VMware/VICommon.pm line 2435.

 

Can anybody shed some light on how this is supposed to work, and what I might be doing wrong?

VM on HOST?

$
0
0

Hello Guys,

since a few days I'm palying around with the vSphere™ SDK for Perl API V5.0.

hostinfo.pl and vminfo.pl works fine as well as my own developed scripts.

But I cannot find the relation between a HOST and a VM or in other words, I need to know on which host my VMs are resides.

Can you give me a hint or a solution?

 

At the end I would like to have a structured report like this:

 

VC1 (uuid, name, type, ......)

     |

     + DataCenter1 (uuid, name, .........)

          |

          + Host1 (uuid, name, CPUs, MEM, ......)

               |

               + VM1.1 (uuid, name, CPUs, MEM, ......)

               + VM1.2 (uuid, name, CPUs, MEM, ......)

          |

          + Host2 (uuid, name, CPUs, MEM, ......)

               |

               + VM2.1 (uuid, name, CPUs, MEM, ......)

               + VM2.2 (uuid, name, CPUs, MEM, ......)

     |

     + DataCenter1 (uuid, name, .........)

a.s.o.

 

I know, this view is available with VMware VSphere Client GUI but I need it as xml or csv.

 

Any  tips or ideas?

 

Many thanks in advance!


esxcli doesn't work with credstore

$
0
0

Anyone encountered and found a solution to this?

 

Welcome to vSphere Management Assistant
vi-admin@vmat:~> /usr/lib/vmware-vcli/apps/general/credstore_admin.pl add --server VLT02000 --username root
Enter password:
Re-enter password:
New entry added successfully
vi-admin@vmat:~> /usr/lib/vmware-vcli/bin/esxcli/esxcli --debug --server VLT02000 network ip connection list
Connect to VLT02000 failed:
Error returned by expat parser: not well-formed (invalid token)
while parsing serialized value of type string
at line 3, column 114
while parsing call information for method Login
at line 3, column 14
while parsing SOAP body
at line 3, column 0
while parsing SOAP envelope
at line 2, column 0
while parsing HTTP request for method login
on object of type vim.SessionManager
at line 1, column 0
vi-admin@vmat:~> /usr/lib/vmware-vcli/apps/general/credstore_admin.pl remove --server VLT02000 --username root
Existing entry deleted successfully.
vi-admin@vmat:~> /usr/lib/vmware-vcli/bin/esxcli/esxcli --debug --server VLT02000 network ip connection list
Enter username: root
Enter password:
Proto  Recv Q  Send Q  Local Address      Foreign Address      State        World ID  World Name   
-----  ------  ------  -----------------  -------------------  -----------  --------  ---------------
tcp         0       0  127.0.0.1:8307     127.0.0.1:53120      ESTABLISHED   7857968  hostd-worker 
tcp         0       0  127.0.0.1:53120    127.0.0.1:8307       ESTABLISHED      3499  hostd-worker 
tcp         0       0  127.0.0.1:55214    127.0.0.1:8089       TIME_WAIT           0               
tcp         0       0  127.0.0.1:55664    127.0.0.1:8307       TIME_WAIT           0               
tcp         0       0  127.0.0.1:5988     127.0.0.1:54962      FIN_WAIT_2          0               
tcp         0       0  127.0.0.1:54962    127.0.0.1:5988       CLOSE_WAIT       3501  hostd-worker 
tcp         0       0  127.0.0.1:8307     127.0.0.1:57388      ESTABLISHED      3501  hostd-worker 
tcp         0       0  127.0.0.1:57388    127.0.0.1:8307       ESTABLISHED      2786  hostd-worker 
tcp         0       0  127.0.0.1:80       127.0.0.1:59555      ESTABLISHED      3500  hostd-worker 
tcp         0       0  127.0.0.1:59555    127.0.0.1:80         ESTABLISHED    523245  sfcb-vmware_bas
tcp         0    1403  127.0.0.1:8307     127.0.0.1:50322      ESTABLISHED      3096  hostd-worker 
tcp         0       0  127.0.0.1:50322    127.0.0.1:8307       ESTABLISHED      3038  vpxa-worker  
tcp         0       0  127.0.0.1:8307     127.0.0.1:49948      ESTABLISHED      3385  hostd-worker 
tcp         0       0  127.0.0.1:49948    127.0.0.1:8307       ESTABLISHED      3041  vpxa-worker  
tcp         0       0  127.0.0.1:8307     127.0.0.1:50022      ESTABLISHED      3499  hostd-worker 
tcp         0       0  127.0.0.1:50022    127.0.0.1:8307       ESTABLISHED      3038  vpxa-worker  
tcp         0       0  127.0.0.1:8089     127.0.0.1:60654      ESTABLISHED   1208202  vpxa-worker  
tcp         0       0  127.0.0.1:60654    127.0.0.1:8089       ESTABLISHED      3710  hostd-worker 
tcp         0       0  127.0.0.1:8089     127.0.0.1:53790      ESTABLISHED   1208202  vpxa-worker  
tcp         0       0  127.0.0.1:53790    127.0.0.1:8089       ESTABLISHED      2789  hostd-worker 
tcp         0       0  127.0.0.1:8307     127.0.0.1:57526      ESTABLISHED      3501  hostd-worker 
tcp         0       0  127.0.0.1:57526    127.0.0.1:8307       ESTABLISHED      3385  hostd-worker 
tcp         0       0  127.0.0.1:80       127.0.0.1:57324      ESTABLISHED      3711  hostd-worker 
tcp         0       0  127.0.0.1:57324    127.0.0.1:80         ESTABLISHED    517224  sfcb-vmware_bas
tcp         0       0  127.0.0.1:8089     0.0.0.0:0            LISTEN           3034  vpxa-worker  
tcp         0       0  127.0.0.1:12000    0.0.0.0:0            LISTEN           3034  vpxa-worker  
tcp         0       0  127.0.0.1:8307     127.0.0.1:51261      ESTABLISHED      3385  hostd-worker 
tcp         0       0  127.0.0.1:51261    127.0.0.1:8307       ESTABLISHED      3100  vpxa-worker  
tcp         0       0  127.0.0.1:8307     127.0.0.1:51255      CLOSE_WAIT       3096  hostd-worker 
tcp         0       0  127.0.0.1:51255    127.0.0.1:8307       FIN_WAIT_2       2843  hostd-worker 
tcp         0       0  127.0.0.1:5988     0.0.0.0:0            LISTEN              0               
tcp         0       0  0.0.0.0:5989       0.0.0.0:0            LISTEN              0               
tcp         0       0  127.0.0.1:8889     0.0.0.0:0            LISTEN           3191  openwsmand   
tcp         0       0  127.0.0.1:49152    0.0.0.0:0            LISTEN           2786  hostd-worker 
tcp         0       0  127.0.0.1:8307     0.0.0.0:0            LISTEN           2786  hostd-worker 
tcp         0       0  127.0.0.1:8309     0.0.0.0:0            LISTEN           2786  hostd-worker 
tcp         0       0  0.0.0.0:80         0.0.0.0:0            LISTEN           2786  hostd-worker 
tcp         0       0  0.0.0.0:443        0.0.0.0:0            LISTEN           2786  hostd-worker 
tcp         0       0  127.0.0.1:12001    0.0.0.0:0            LISTEN           2786  hostd-worker 
tcp         0       0  127.0.0.1:427      0.0.0.0:0            LISTEN              0               
tcp         0       0  0.0.0.0:22         0.0.0.0:0            LISTEN              0               
tcp         0       0  0.0.0.0:902        0.0.0.0:0            LISTEN              0               
tcp         0       0  0.0.0.0:8000       0.0.0.0:0            LISTEN           2626               
tcp         0       0  0.0.0.0:8100       0.0.0.0:0            LISTEN           2626               
udp         0       0  0.0.0.0:0          0.0.0.0:0                             2786  hostd-worker 
udp         0       0  0.0.0.0:161        0.0.0.0:0                             2786  hostd-worker 
udp         0       0  0.0.0.0:427        0.0.0.0:0                                0               
udp         0       0  0.0.0.0:8200       0.0.0.0:0                             2626               
udp         0       0  0.0.0.0:8301       0.0.0.0:0                             2626               
udp         0       0  0.0.0.0:8302       0.0.0.0:0                             2626               
vi-admin@vmat:~>

 

The esxcli command works fine when using username/password but not when using the credstore authentication.

This wouldn't normally be a problem but I want to use this in scripts and having a clear text password in there isn't making me happy.

 

regards

Gudmo

About:CloneVM

$
0
0

Dear All,

     I am trying to clone the vm ,but it not work, following is the source code, any Idea ?

sub cloneVM
{
     my $this = shift;
     my $vmList = $this->{vm};
     $len = scalar @$vmList;
for ($i = 0;$i<$len;$i++)
{
     @$vmList[$i]->update_view_data();
     my $vm_name = @$vmList[$i]->summary->config->name;
     my $status;
if ($vm_name eq 'Ubuntu1204_64b_Srv01')
{
     print "Try to clone VM\n";
     my $cloneName = 'Ubuntu1204_64b_Srv100';
     my $pool = VirtualMachineRelocateSpec->new
(
     pool => @$vmList[$i]->resourcePool
);
     my $cloneSpec = VirtualMachineCloneSpec->new(
     powerOn => 1,
     template => 0,
     location => $pool
);
     @$vmList[$i]->CloneVM(folder=>@$vmList[$i]->parent,name=>$cloneName, spec => $cloneSpec);
     print "Complate to Clone\n";
}
}
}
Above code objective is clone Ubuntu1204_64b_Srv01 to Ubuntu1204_64b_Srv100

so that, i run the code.

I received following message.

     Try to clone VM

 

SOAP Fault:

-----------

Fault string: The operation is not supported on the object.

Fault detail: NotSupported

 

If above coding change the CloneVM to CloneVM_Task

 

It not received Fault Message, but I found Ubuntu1204_64b_Srv100 not cloned succssfully!

 

Any Idea for here???

 

Thank.

Set VM OS Type Using SDK Perl v5?

$
0
0

I am trying to set the operating system type of a virtual machine shell using the Perl version 5 SDK and am receiving an error.

 

Snippet of code:

 

     $guestid = "sles11_64Guest"

     my $guestid = VirtualMachineConfigInfo->new(guestId => $guestid);

     my $spec = VirtualMachineConfigSpec->new(guestId => $guestid);

     my $task = $vm_view->ReconfigVM_Task(spec => $spec);

 

The error that is returned is as follows:

 

          String: An error occurred during host configuration.

     Detail: PlatformConfigFault

 

Any assistance that can be provided would be greatly appreciated.

 

Thanks.

 

vicfg-hostops question

$
0
0

Hi All,

 

    I just got through the installation of vCLI and perl SDK. I installed all  this in my vCenter SUSE VM it self. The vCenter is bootstrapped into the  cluster. I am trying to reboot a host in my cluster using,

 

    vicfg-hostsops --operation reboot --server 10.243.xxx.xxx --username root  --password <server_password>

 

    I get this error - Server version unavailable at  'https://<server>/sdk/vimService.wsdl' at  /usr/lib/perl5/5.8.8/VMware/VICommon.pm line 545

 

     The solution for this from vmware support site is

 

Workaround: Follow these steps to resolve the  issue:

  1. Make sure the version of the LWP::UserAgent Perl module is above  6.0.4.
  2. Turn off host name verification by running the following  command:
    export  PERL_LWP_SSL_VERIFY_HOSTNAME=0

 

       The latest LWP::UserAgent perl module is 6.04 and nothing here which I  have installed.

       Exported the variable and assigned it to 0.

 

I did all this but I still get the same error - server version  unavailable.

 

Any ideas?

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?

 

 

Viewing all 1577 articles
Browse latest View live




Latest Images