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

Network configuration of VM after deploy from template

$
0
0

Hi All,

 

We have deployed the VM from template thanks to this discussion forum, Now we need to configure the new VM with all the network related configuration to bring the host live.

 

Do we have any Perl script which take care of such steps, any pointer should help us.?

 

Thanks,

Nilesh


Deep Recursion in Perl API Script

$
0
0

We're running vSphere CLI 5.0.0 on a RHEL 5.8 server for many things, including VM backups.  The backup script hasn't changed in quite some time, but now I'm seeing the following error messages on one on my datastores: Deep recursion on subroutine "ComplexType::deserialize" at
/usr/lib/perl5/5.8.8/VMware/VICommon.pm line 2346.  As far as I can tell the datastore is fully operational & it has no obvious errors.  I'm not sure if this is a true problem which is killing some VM backups, or if it is just a warning. Does anyone know what is causing this, and where I can go to further research it?

Set Management traffic vSphere CLI

$
0
0

Hi,

 

Thanks in advance, I don't now if I'm in the correct forum.

 

I'm trying to config an ESXi 4.1 U3 (We need to config over 200) using vSphere CLI script as my manager wants it like that, I'm making a .bat in windows that calls al .pl needed for my config, I have almost everything done. I've searched almost all internet without luck for two operations:

 

- Set Management traffic to portgroup

- Set nic order policy (via CLI I didn't tried yet but seems running vim-cmd should work)

 

For the first I have seen:

 

vim-cmd hostsvc/advopt/update Net.ManagementIface string vmkX

 

I have tried that, as vim-cmd is not a vSphere CLI command, I included it using a line in the .bat, that makes ssh connection (plink - putty) to the host an runs locally at the ESXi the command, the command returns the prompt with no error, but when you go to vSphere Client the Management traffic is still not selected.

The same command for vmotion or FT works fine.

 

Also seen the option of editing: /etc/vmware/hostd/hostsvc.xml

That doesn't seem to work either.

 

For the nic oder policy I'm going to try to make de ssh stuff and run locally de vim-cmd.

 

Any idea please?

When the script is fully fuctional I will share it for the comunity.

 

Thanks

find_entity_views sometimes gets error '500 read failed'

$
0
0

I've got a perl program that uses the vSphere api talking to a vcenter 5.1.0 947673.  Every minute the program issues a call to find_entity_views to get the list of VirtualMachines on the VCenter.  We have one deployment where the call fails sometimes with a perl exception like this:

 

exception = $VAR1 = bless( {

                 '-file' => '/usr/lib/perl5/site_perl/5.8.8/Error.pm',

                 '-text' => 'SOAP request error - possibly a protocol issue: 500 read failed:',

                 '-line' => 38,

                 '-package' => 'Error'

               }, 'Error::Simple' );

 

In looking at the logs on the VCenter I see this:

 

[viclient:SoapTran:W:15] 2013-07-12 15:27:06.150  Invoke 7787 Finish WaitForUpdates on PropertyCollector:propertyCollector [vcenter] - Serial:0.000, Server:300.013

Suppressed: VirtualInfrastructure.Soap.MethodInvocationSoapImpl: The request failed because the remote server 'vcenter' took too long to respond. (The command has timed out as the remote server is taking too long to respond.)

[viclient:Error   :W:15] 2013-07-12 15:27:06.150  ConnectionError occurred while executing WFU

VirtualInfrastructure.Exceptions.RequestTimedOut: The request failed because the remote server 'vcenter' took too long to respond. (The command has timed out as the remote server is taking too long to respond.)

   at VirtualInfrastructure.Soap.SoapServiceWrapper.DoInvokeSync(ManagedObject mo, MethodName methodName, Object[] parameters, Int32 timeoutSecs)

   at VirtualInfrastructure.Soap.SoapTransport.VirtualInfrastructure.Transport.InvokeMethod(ManagedObject mo, MethodName methodName, Object[] pars)

   at VirtualInfrastructure.ManagedObject.InvokeMethod(MethodName methodName, Object[] pars)

   at Vmomi.Core.PropertyCollector.WaitForUpdates(String version)

   at VirtualInfrastructure.Updates.PollerDispatcherImpl.ExecuteSingleWFU()

   at VirtualInfrastructure.Updates.PollerDispatcherImpl.PollWaitForUpdates()

System.Net.WebException: The command has timed out as the remote server is taking too long to respond.

 

 

   --- End of inner exception stack trace ---

 

The call doesn't always fail -- it'll go for a period where it actually works then slips back into not working with the above error.  It's very strange.

 

Does anyone have any ideas as to what it could be or at least where I could start looking?  Any and all information would be greatly appreciated!

 

Jonny L.

How to Install 3ware RAID Controller Management

$
0
0

I have 3ware 9690SA and I installed the driver under ESXi4.1, how I can install 3ware RAID Controller Management console under Vsphere 4.1 or under CLI  (Perl). By the way I find the following documents, but how I can run UNIX commands under Windows XP 64bit, Vsphere 4.1 or  Vsphere CLI command line.

Installing 3ware RAID Controller Management

Software for VMware

3ware RAID controller management software includes 3DM2 and CLI. CLI

can run locally on the VMware server in a console window.

By default, VMware ESX Server 4.0 does not have a GUI and therefore you

cannot access 3DM2 locally. You must use another system that has a GUI and

a web browser to access 3DM2.

After initial installation and setup, administration will typically be done

remotely through CLI or 3DM2.

If you have not yet installed 3DM2 and CLI, use the steps below to do so.

1 Mount the 3ware software image CD.

mount -t iso9660 /dev/cdrom /mnt/cdrom

2 Navigate to the appropriate directory where the 3DM2 and CLI rpm files

are located.

cd /mnt/cdrom/packages/installers/tools/vmware/esx40/

3 Run the install commands for CLI and 3DM2.

rpm -ivh <LSI-3ware-CommandLine-Management-Utility-xxx.rpm>

rpm -ivh <LSI-3ware-3dm2-Management-Utility-xxx.rpm>

4 Note the URL supplied by 3DM2 at the end of installation, (for example,

https://10.0.0.2:888), as it will be required in order to connect to 3DM2

through a web browser.

 

Possible Bug / Implementation Fault with Adding Delta Backed Disks

$
0
0

Through the perl SDK I have created a number of delta disks on a virtual machine that all point back to the original backing, not through each other.  The disks seem to work wonderfully, however when I go to delete them I get a handful of faults.  It seems that the first delta disk that is deleted also removes the primary backing, and the other disks have no where else to point to, and will throw faults when you try and remove them, citing a lack of the primary backing.  Even if I attempt a batch operation, deleting them all at once, a fault will be thrown saying I can not complete the operation that way as well.  Is there any way to delete the delta vmdks with out deleting the primary backing?  Alternatively is there a way to not have the primary backing be deleted until the last delta disk backed on it is removed?

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.

 

 

Change a VM's network label

$
0
0

I'm having some trouble trying to use the perl SDK to automate changing an existing NIC on an existing VM to a different "network label".

 

The VM gets automatically deployed and built in one of our internal networks, but needs to be moved onto the 'live' network. At the moment it's a case of going into the NIC properties in the GUI and selecting the correct "network label" from the dropdown box.

 

Can anyone show me how to retrieve/set this variable via the perl SDK?

 

Thanks!


how to transfer to english ?

$
0
0

the srcript output is not english ,how to transfer to english ?

set locale while connecting to VC from VI perl sdk application

$
0
0

 

All,

 

 

  Is there a way to set the locale to en_US in my perl application, so that the VC responds back with english text to all my api queries.

 

 

I know the vpx client UI can support this. From the release notes

 

 

"The following vSphere Client command will cause the individual session to appear in English:

vpxClient -locale en_US"

 

 

Thanks

 

 

Error: Server version unavailable at 'https://1.1.1.1/sdk/vimService.wsdl' when connecting to virtual center with connect.pl

$
0
0

 

Hi,

 

 

 

 

 

I have a strange problem, I have 3 RHEL 5.4 servers that are clones of each other, I have install the SDK on all 3 of them, version:

 

 

I have installed VMware-vSphere-SDK-for-Perl-4.0.0-161974

 

 

and on 2 servers whith connect.pl it works great:

 

 

  1. /usr/lib/vmware-vcli/apps/general/connect.pl --server 1.1.1.1 --username XXX --password XX

 

 

Connection Successful

Server Time : 2009-11-04T11:53:30.449415Z

 

 

On the third server it doesn't work:

 

 

  1. /usr/lib/vmware-vcli/apps/general/connect.pl --server 1.1.1.1 --username XXX --password XX

 

 

Error: Server version unavailable at 'https://1.1.1.1/sdk/vimService.wsdl'

 

 

I am connecting to a VC with esx 3.5, on the third server I can access the url 'https://1.1.1.1/sdk/vimService.wsdl' with no problems

 

 

Any idea what can be the problem ?

 

 

 

 

 

Thnx

 

 

retreive list of active processes from guest

$
0
0

Hi all,

 

I'm trying to rewrite some of our monitoring checks so I can monitor our vCloud customers without needing any network connectivity for fe. snmp. I've tried writing something in Perl, but am now stuck at the following point:

 

I can get to the view of ProcessManager, but I can't get the listProcessesInGuest() method to work. If I execute the following bit of code, I just get the response: Undefined subroutine &GuestOperationsManager::listProcessesInGuest

 

The relevant piece of code is as follows:

my $serviceContent = Vim::get_service_content(

    filter => {'name' => $vmNameInVcenter }

);

my $operationsManager = Vim::get_view(mo_ref => $serviceContent->guestOperationsManager);

my $processManager = Vim::get_view(mo_ref => $operationsManager->processManager);

my $processlist = $processManager->listProcessesInGuest();

 

Regards,

 

MrBoogiee

How to add virtual adapter (vmk0, vmk1..) per esx host onto vsphere distributed switch?

$
0
0

Dear All,

 

I was looking for a method to automate 'how to add virtual adapter per esx host onto dvs? Does anybody has any idea? Has any one already automated it. Please give me pointers to start with.

Manually here is the procesdure.

1. Select a ESX host on vcenter server.

2. Go to Configuration tab

3. Click on Networking -> vSphere Distributed Switch

4. click on Manage Virtual Adapters

5. Select Add -> Select Creation Type -> Select Virtual Adapter Types -> Select Network Connection -> Specify VMKernel IP settings

 

There is a requirement to automate the same. We are dealing with 100+ esx hosts on one DVS which needs vmk1 (for vMotion) to be added. Any help here would be appreciated.

 

Regards,

Pranesh

ApplyStorageDrsRecommendation_Task crashes vCente

$
0
0

Folks, I am trying to write a script to create VM's in my cluster. Right now, I have a script, but it is crashing my vCenter server completely. I posted the script and asked question to vSphere Management SDK forum already( http://communities.vmware.com/message/2229982#2229982). I'm hoping the people in this forum can help identify the bug in the script below that causes the crash.

 

The requirements for building a host are that I define the hostname, folder, CPU, memory, disk space and network to use. The script specifies the storage cluster to use and should pick the correct datastore for me to put the guest and its vmdk on.

 

Any advice with the script would be helpful. Should I be using ApplyStorageDrsRecommendation_Task, or is there something more appropriate. Am I doing something wrong that would cause this to crash?

 

Thanks,

Scott

 

 

#!/usr/bin/perl
use strict;
use VMware::VIRuntime;
use VMware::VILib;
use Data::Dumper;
# Connect to vSphere and collect information
Opts::parse();
Opts::validate();
Util::connect();
my $dscluster = Vim::find_entity_view(view_type => 'StoragePod', filter => {'name' => "SANCLUST" }, properties => ['name']);
if ( ! defined( $dscluster ) ) {
        print "Unable to locate datastore cluster: $dscluster!\n";
        Util::disconnect();
        exit 1;
}
my $folder = Vim::find_entity_view(view_type => 'Folder', filter => {'name' => "Folder-blah"}, properties => ['name']);
if ( ! defined( $folder ) ) {
        print "Unable to find folder to use!\n";
        Util::disconnect();
        exit 1;
}
# Create some devices
my @vm_devices;
push( @vm_devices, create_controller_spec() );
push( @vm_devices, create_virtual_disk( 60 ) );
my $configSpec = VirtualMachineConfigSpec->new(
                                             name => "test-vm",
                                             memoryMB => 2048,
                                             numCPUs => 2,
                                             deviceChange => \@vm_devices);
# We only have one resource pool. Use that one for the storageplacementspec
my $resourcePools = Vim::find_entity_views( view_type => "ResourcePool" );
my $storageMgr = Vim::get_view(mo_ref => Vim::get_service_content()->storageReso
urceManager);
my $podSpec = StorageDrsPodSelectionSpec->new(storagePod => $dscluster);
my $storageSpec = StoragePlacementSpec->new( type => "create",
                                             podSelectionSpec => $podSpec,
    folder => $folder,
    configSpec => $configSpec,
                                             resourcePool => $resourcePools->[0]
   );
# Figure out which datastore to put the guest on
my $result = $storageMgr->RecommendDatastores(storageSpec => $storageSpec);
my $curRec;
my $curRecFree = 100;
foreach my $rec ( @{$result->recommendations} ) {
    #print Dumper( $rec->{action}->[0]->spaceUtilAfter ) ; exit 0;
    if ( $rec->action->[0]->spaceUtilAfter < $curRecFree ) {
        $curRecFree = $rec->action->[0]->spaceUtilAfter;
        $curRec = $rec->key;
    }
}
# Create the VM
#$storageMgr->ApplyStorageDrsRecommendation_Task( key => [ $curRec ] );
print $curRec . "\n";
sub create_virtual_disk {
   my ( $space ) = @_;
   my $backing = new VirtualDiskFlatVer2BackingInfo( diskMode => "persistant",
                                              split => 0, thinProvisioned => 1,
                                              fileName => "[ test-vm ]" );
   my $device =  new VirtualDisk( backing => $backing, controllerKey => 0,
                                  key => 0, unitNumber => 0,
                                  capacityInKB => ( $space * 1024 * 1024 ) );
   return new VirtualDeviceConfigSpec( device => $device,
          fileOperation => VirtualDeviceConfigSpecFileOperation->new('create'),
          operation => VirtualDeviceConfigSpecOperation->new('add'));
}
sub create_controller_spec {
   my $controller =
      VirtualBusLogicController->new(key => 0,
                                     device => [0],
                                     busNumber => 0,
                                     sharedBus => VirtualSCSISharing->new('noSharing'));
   my $controller_vm_dev_conf_spec =
      VirtualDeviceConfigSpec->new(device => $controller,
         operation => VirtualDeviceConfigSpecOperation->new('add'));
   return $controller_vm_dev_conf_spec;
}

 

Linked VM creation, overiting my template configuration

$
0
0

Dear All,

 

I am creating Linked VM using perl SDK. Which works well for linux, but for windows, during goes customization it remove existing setting of template VM and disturbs the setting.

 

My question is:

 

1. Why i need to mentioned customization user data, which require product key, username, etc as mandatory, i guess due to this its taking long time to bring VM up. If my template is properly created from cloned VM this should not require.

2. I want VM to get AutoLogon with domain user not with Administrator user, for this what extra configuration i need to do.

3. is there any way i can do post customization, my vcenter server is 4.1, which will reduce the time for ready to use.

4. How should i know My windows VM is ready to use.

 

Your help us needed.

 

Regards,

Nilesh J


Adding new SCSI controller: "Fault string: Invalid operation for device '0'."

$
0
0

Hello,

 

I have an issue when I try to add a SCSI controller to a virtual machine.

 

I have this error:

 

Fault string: Invalid operation for device '0'.

Fault detail: InvalidDeviceOperation

 

Here is my code:

 

my $info = Description->new(label => "SCSI Controller 2", summary => "LSI Logic Parallel");

 

my $controller = VirtualLsiLogicController->new(

                deviceInfo => $info,

                scsiCtlrUnitNumber => '7',

                sharedBus => VirtualSCSISharing->new('noSharing'),

                busNumber => -1,

                key => -1,

                backing => $backing_info,

                controllerKey => 100,

                );

 

 

my $devspec = VirtualDeviceConfigSpec->new(operation => VirtualDeviceConfigSpecOperation->new('add'),

                device => $controller ,

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

                );

 

 

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

eval {

        $vm_view->ReconfigVM( spec => $vmspec );

        Util::trace(0,"Controller has been created.\n");

};

 

I don't know how to handle it, or even how to troubleshoot.

 

Any ideas would be greatly appreciated.

 

Regards,

 

Jeremy

how to dynamic and proactive monitor the vm's delete action.

$
0
0

I have met a problem like following, hope u guys can help me.

    my virtual enviroment contains Vmware vCenter 4.1 and 5.1,  i want to monitor the VM's deleting action/event dynamic by using the perl sdk.   When  VMs be sucessfully deleted , then gather the deleted VM's info and store it.

How to use quickprep

$
0
0

Dear All,

 

Can anybody help me know how to use quickprep for customization using SDK perl, using SDK perl we do customization using customization object CustomizationSysprep do we have similar object for QuickPrep.

 

Regards,

Nilesh

How to access Data Object from Perl thread

$
0
0


I am trying to import OVF. I have gotten as far as getting a Lease and starting VMDK upload. I see the data going through, but connection times out because I need to call HttpNfcLeaseProgress periodically from a separate thread to keep the connection open. The problem is I cannot seem to figure out how to share the HttpNfcLease Data Object with a Perl thread, so that the thread can call the HttpNfcLeaseProgress method. I have tried sharing the type and value fields of the HttpNfcLease MOR and the constructing a new MOR in the thread and calling get_view, but I get a segmentation fault. Any help or examples on how to do this would be greatly appreciated!

how to get the dns name of vm ?

$
0
0

i need a perl api script to get the dns name of vm from vshere webclient ..

Viewing all 1577 articles
Browse latest View live




Latest Images