Hi Guys,
How to get the memory utilization of vm in datacenter through perl sdk file? any links and files pls
Hi Guys,
How to get the memory utilization of vm in datacenter through perl sdk file? any links and files pls
Dear All,
I read many documents regarding suse11sp2 linux cloning using vSphere SDK, but could not get my answer.
Did anyone faces guest customization issue with suse11sp2 linux. My suse11sp2 template has the configuration which will enable mounting /home/username directory after cloning, which as the .ssh/authorization_keys to make VM password less for a given user monty. But after cloning my suse VM does have home directory mounted which is causing issue.
After loging it says
Last login: Sun May 4 12:52:05 2014
Could not chdir to home directory /home/monty: No such file or directory
After logging into the VM i see home directory present but it has following permission.
> ls -lrt | grep monty
ls: cannot access monty: No such file or directory
d????????? ? ? ? ? ? monty
What is missing in my suse template.
Please help.
Regards,
Nilesh
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:
/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:
/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
Hi All,
Can you provide any link or perl API script to list the networks in/using Datacenter or Host.
Sam
Here For Example:-
my $dc_view = Vim::find_entity_view(view_type => 'Datacenter'); | |
if($dc_view->network){ | |
foreach(@{$dc_view->network}){ | |
print "\t\t$_->{'value'}\n"; | |
// Here I am getting Only Network ID (which is listed in datacenter) my $network=$_->{'value'}; | |
my $nw_view = Vim::find_entity_view(view_type => 'Network', filter => {"name" =>$network}); | |
} | |
} |
I am getting network id at the variable ($network) I am using 'value' as a key .. but how to get the network name instead of network id. can any one help me ?
When I am checking the status of the task (ReconfigureComputeResource_Task) for vSAN to be enable on the host, I am getting error "Can't load class 'NotSupportedHostForVsan' at /usr/share/perl/5.14/VMware/VIMRuntime.pm line 52." when updating the task data.
Code for enabling the vSAN:
else {
print "vSAN is not enabled on Cluster:". $clusterView->name."\n";
print "Enabling the cluster for vSAN feature\n";
my $enablevSAN = $clusterView->configurationEx->vsanHostConfig;
my $vSANDefaultConfig = VsanClusterConfigInfoHostDefaultInfo->new(autoClaimStorage=>'true');
my $vSANEnable = VsanClusterConfigInfo->new(enabled=>'true',defaultConfig=>$vSANDefaultConfig);
my $clusterConfigSpec = ClusterConfigSpecEx->new(vsanConfig => $vSANEnable);
my $vSANEnableTask = $clusterView->ReconfigureComputeResource_Task(spec=>$clusterConfigSpec,modify=>'true');
$msg = "Successfully enabled vSAN on Host";
&getStatus($vSANEnableTask,$msg);
}
Code for checking the status of the task:
sub getStatus {
my ($taskRef,$message) = @_;
my $task_view = Vim::get_view(mo_ref => $taskRef);
my $taskinfo = $task_view->info->state->val;
my $continue = 1;
while ($continue) {
my $info = $task_view->info;
Some code ......... {
}
sleep 5;
$task_view->ViewBase::update_view_data(); <<<<<<<<<, Here it is getting die for the second time, when task gets completed where host is not supported for vSAN.
}
}
$task_view->info->state->val is not getting into "error" where code can print manual error. But it is getting die in the code
Can someone please let me if I am missing any step or need to change the code for checking the status of the task?
Hi
I am trying to provisioning using cluster . Can any one have any link or Perl sdk file ?
I am using the "datastoreClusterManagement.pl" script . These are the params I am passing
"--url 'https://0.0.0.0:443/sdk/webService' --username 'xxxxx' --password 'xxxxx' --vmname test-linux-template --customize_guest yes --customize_vm yes --filename sampledata/vmclone_test1.xml --schema schema/default.xsd --datastorecluster 'DSSDSDS' --cluster 'MN_Production_Cluster' --vmname_destination test-linux-clone5".
can someone any idea regarding provisioning using cluster
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
Hi
Using this below script(click the below link) how we can provisioned using "VM_TEMPLATE instead of VMNAME" and "CLUSTER instead of VMHOST". can you please let me know if its possible.https://communities.vmware.com/servlet/JiveServlet/download/2259564-110735/deployVMLinked.pl . the parameters for this script are
"--username myuser --password mypassword --vmhost <hostname/ipaddress> --vmname DVM1 --vmname_destination DVM99 --url https://<ipaddress>:<port>/sdk/webService --customize_guest yes --customize_vm yes --filename clone_vm.xml --schema clone_schema.xsd"
Our need is like
"--username myuser --password mypassword --cluster $cluster --vmtemplate $vmtemplate --vmname_destination DVM99 --url https://<ipaddress>:<port>/sdk/webService --customize_guest yes --customize_vm yes --filename clone_vm.xml --schema clone_schema.xsd"
Thanks In Advance
I'm a little lost at figuring out if this is even possible or feasible, but can one use "VI Perl" to create a VM with Hardware Version 9 and Server 2012 as the Guest OS?
Hi All,
Can someone please explain why the results below are different and how to get host ip address instead of name when using ESXi API?
Util::connect( "https://$server/sdk", $username, $password );
my $service_content = Vim::get_service_content();
my $apiType = $service_content->about->apiType;
if ( $apiType eq 'VirtualCenter' ) {
my $host_views = Vim::find_entity_views( view_type => 'HostSystem' );
foreach my $host_view (@$host_views) {
print $host_view->name; # prints ip address
}
} else {
my $host_view = Vim::find_entity_view( view_type => 'HostSystem' );
print $host_view->name; # prints name for the same host
}
You should be able to observe the same behavior when you browse your vCenter and ESXi hosts from https://<your-vcenter-or-esxi>/mob/.
Thanks,
Ymnick
Hi All,
I need to fetch the information about VM's cpu usage, disk space usage , Can any one have perl API script to fetch these information.
I've been trying to get vmcloneLin.pl working for awhile now.
the Perl SDK is installed on:
Redhat 6 x86_64
with version: VMware-vSphere-Perl-SDK-5.1.0-780721.x86_64.tar.gz
running against:
The script mods are provided here:
He provides the Distributed Port Group script in full, and we use Standard Port Groups, so I carefully (many times) applied the Standard Port Group mods to the script. I consistently get errors like this:
Cloning virtual machine 'TestVM01' ...
FaultCannot serialize network as ManagedObjectReference at /usr/share/perl5/VMware/VICommon.pm line 2432
ComplexType::serialize('VirtualEthernetCardNetworkBackingInfo=HASH(0x445f0c0)', 'backing', 1) called at /usr/share/perl5/VMware/VICommon.pm line 2439
ComplexType::serialize('VirtualVmxnet3=HASH(0x38826e8)', 'device', 1) called at /usr/share/perl5/VMware/VICommon.pm line 2439
ComplexType::serialize('VirtualDeviceConfigSpec=HASH(0x492b438)', 'deviceChange', undef) called at /usr/share/perl5/VMware/VICommon.pm line 2439
ComplexType::serialize('VirtualMachineConfigSpec=HASH(0x492c7f0)', 'config', undef) called at /usr/share/perl5/VMware/VICommon.pm line 2439
ComplexType::serialize('VirtualMachineCloneSpec=HASH(0x38c9e18)', 'spec') called at (eval 39) line 111
VimService::get_arg_string('VirtualMachineCloneSpec=HASH(0x38c9e18)', 'spec', 'VirtualMachineCloneSpec') called at (eval 39) line 132
VimService::build_arg_string('ARRAY(0x2b331f8)', 'HASH(0x2b33138)') called at (eval 39) line 2923
VimService::CloneVM_Task('VimService=HASH(0x2dad830)', '_this', 'ManagedObjectReference=HASH(0x2e73558)', 'spec', 'VirtualMachineCloneSpec=HASH(0x38c9e18)', 'name', 'TestVM_new01', 'folder', 'ManagedObjectReference=HASH(0x3077218)', ...) called at /usr/share/perl5/VMware/VICommon.pm line 1693
ViewBase::invoke('VirtualMachine=HASH(0x2e996d8)', 'CloneVM_Task', 'spec', 'VirtualMachineCloneSpec=HASH(0x38c9e18)', 'name', 'TestVM_new01', 'folder', 'ManagedObjectReference=HASH(0x3077218)') called at (eval 48) line 201
VirtualMachineOperations::CloneVM_Task('VirtualMachine=HASH(0x2e996d8)', 'spec', 'VirtualMachineCloneSpec=HASH(0x38c9e18)', 'name', 'TestVM_new01', 'folder', 'ManagedObjectReference=HASH(0x3077218)') called at (eval 48) line 207
VirtualMachineOperations::CloneVM('VirtualMachine=HASH(0x2e996d8)', 'folder', 'ManagedObjectReference=HASH(0x3077218)', 'name', 'TestVM_new01', 'spec', 'VirtualMachineCloneSpec=HASH(0x38c9e18)') called at ./vmcloneLin.pl line 189
eval {...} called at ./vmcloneLin.pl line 188
main::clone_vm() called at ./vmcloneLin.pl line 76
Any help troubleshooting this would be greatly appreciated.
Anyone have this working with Standard Port Groups?
Hi All,
I need a perl CLI script to get the all VM's root password in a datacenter . Can any one have the script or link?
Hello,
In my current solution, for disaster recovery I SRDF our VM's datastore's to my offsite location. Before the VM's can boot up the raw device mapping's need to be re-mapped (somehow the RDM's do not carry over through SRDF and are not recognized as RDM's but as Virtual Disk), then they need to be re-IP'd to match the network at the offsite location. I was able to manage this task within the PowerCLI plugin for PowerShell (only windows), however I would like to be able to run this on a Linux server. vShpere SDK for Perl seemed to be the best option. I've been able to run many of the basic scripts that come with the installation; however, my Perl coding abilities are far limited and was wondering if someone could help me write a script that would configure both the RDM's and re-IP'ing.
Thanks,
eslatts
Hi All,
StandbyGuest and SuspendVM_Task methods both put the VM into 'suspended' state, and the only difference I noticed is that standby process initiated by StandbyGuest command completes instantly, and then the VM gets suspended 'in the background' without any indication in the vSphere Client UI, while the process started by SuspendVM_Task takes a few long seconds to complete and there is a progress bar in the UI indicating the suspension progress. Is there anything else, except of VMware Tools presence requirement for StandbyGuest?
Thanks,
Ymnick
I'm fairly new to perl and VMware which I believe is a double whammy...but here is the question I have.
I created a script which will look at all the datacenters:
my $dc_view = Vim::find_entity_views(view_type=>'Datacenter',properties=>['name']);
then loop through the hosts of the datacenters...then through the VMs of the hosts...
What I found though is that some of the hosts are in clusters and others aren't.
How can I determine what cluster a host is in? or even if it is in a cluster?
Thanks
Robert
I just had a co-worker ask for some help on automation with the Perl SDK around DistributedVirtualPortgroups.
What I quickly found out is that find_entity_view calls will not work. And for a very simple reason. TraversalSpecs for networkFolder and datastoreFolder were not added to the subroutine get_search_filter_spec in VICommon.pm.
It seems like an oversight to have skipped TraversalSpecs for these folders. Without modifying VICommon.pm or calling RetrieveProperties directly, you'll need to do some klunky enumeration of Datacenter(s) and Network properties.
Is this something that others have run into or at least something that is slated to be fixed in a future release of the VI Perl SDK?
I updated the subroutine get_search_filter_spec in VICommon.pm to the following and it works quite simply. Similar specs would have to be added for the datastoreFolder
sub get_search_filter_spec { my ($class, $mo_ref, $property_spec) = @_; my $resourcePoolTraversalSpec = TraversalSpec->new(name => 'resourcePoolTraversalSpec', type => 'ResourcePool', path => 'resourcePool', skip => 0, selectSet => [SelectionSpec->new(name => 'resourcePoolTraversalSpec'), SelectionSpec->new(name => 'resourcePoolVmTraversalSpec')]); my $resourcePoolVmTraversalSpec = TraversalSpec->new(name => 'resourcePoolVmTraversalSpec', type => 'ResourcePool', path => 'vm', skip => 0); my $computeResourceRpTraversalSpec = TraversalSpec->new(name => 'computeResourceRpTraversalSpec', type => 'ComputeResource', path => 'resourcePool', skip => 0, selectSet => [SelectionSpec->new(name => 'resourcePoolTraversalSpec'), SelectionSpec->new(name => 'resourcePoolVmTraversalSpec')]); my $computeResourceHostTraversalSpec = TraversalSpec->new(name => 'computeResourceHostTraversalSpec', type => 'ComputeResource', path => 'host', skip => 0); my $datacenterHostTraversalSpec = TraversalSpec->new(name => 'datacenterHostTraversalSpec', type => 'Datacenter', path => 'hostFolder', skip => 0, selectSet => ); my $datacenterVmTraversalSpec = TraversalSpec->new(name => 'datacenterVmTraversalSpec', type => 'Datacenter', path => 'vmFolder', skip => 0, selectSet => ); my $hostVmTraversalSpec = TraversalSpec->new(name => 'hostVmTraversalSpec', type => 'HostSystem', path => 'vm', skip => 0, selectSet => ); my $datacenterNetTraversalSpec = TraversalSpec->new(name => 'datacenterNetTraversalSpec', type => 'Datacenter', path => 'networkFolder', skip => 0, selectSet => ); my $folderTraversalSpec = TraversalSpec->new(name => 'folderTraversalSpec', type => 'Folder', path => 'childEntity', skip => 0, selectSet => [SelectionSpec->new(name => 'folderTraversalSpec'), SelectionSpec->new(name => 'datacenterHostTraversalSpec'), SelectionSpec->new(name => 'datacenterVmTraversalSpec',), SelectionSpec->new(name => 'computeResourceRpTraversalSpec'), SelectionSpec->new(name => 'computeResourceHostTraversalSpec'), SelectionSpec->new(name => 'hostVmTraversalSpec'), SelectionSpec->new(name => 'resourcePoolVmTraversalSpec'), SelectionSpec->new(name => 'datacenterNetTraversalSpec'), ]); my $obj_spec = ObjectSpec->new(obj => $mo_ref, skip => 0, selectSet => [$folderTraversalSpec, $datacenterVmTraversalSpec, $datacenterHostTraversalSpec, $computeResourceHostTraversalSpec, $computeResourceRpTraversalSpec, $resourcePoolTraversalSpec, $hostVmTraversalSpec, $datacenterNetTraversalSpec, $resourcePoolVmTraversalSpec]); return PropertyFilterSpec->new(propSet => $property_spec, objectSet => [$obj_spec]); }
The following code is much simpler than having to do a few nested soap calls on network objects from each Datacenter in the inventory.
#!/usr/bin/perl use strict; use warnings; use VMware::VIRuntime; Opts::parse(); Opts::validate(); Util::connect(); my $dvpgs = Vim::find_entity_views(view_type => "DistributedVirtualPortgroup", properties => \['name']); foreach (@{$dvpgs}) { my $portgroup = $_->{'name'}; print "Distributed Virtual Portgroup: $portgroup\n"; }
Just a quick note in case someone else has run into this snag with the VI Perl SDK and needed a fix. Obviously this requires modifying the VICommon.pm module provided by the SDK. The other option would be to build PropertyFilterSpecs and call RetrieveProperties, skipping the utility function find_entity_view.
EDIT: Ugh, the forum code mangled the function, watch directly copying and pasting from this post! Look at datacenterNetTraversalSpec which I added to the subroutine to support the networkFolder with find_entity_view.
Hi,
I have a slight problem trying to login to vsphere using a credentials store. The Virtual Center server at my site requires to log on using a user name prefixed by a Windows domain name (domain\username). I verified the account using Virtual Infrastructure Client. I am at loss on what to put inside the <username> tags in my credentials file, however. Testing the connection using: /usr/lib/vmware-vcli/apps/general/connect.pl --username 'domain\username' works, but putting the same thing in the credentials file errors:
Error :: Failed to parse file for /etc/vicredentials.xml at /usr/share/perl/5.14/VMware/VICredStore.pm line 159.
I'll start off by saying Perl is not one of my strong scripting langs. The following is using bash wrappers around perl to create guests via vmcreate.pl:
Has anyone found a way to pass the HW version through this perl script? We have multiple clusters and we are not ready to force an entire team of engineers off vSphere client into the sluggish web interface.
Currently we use vmcreate.pl to create guests on clustered and non-clustered esxi5.0/5.1/5.5 hosts. VMX-10 is the default created guest on 5.5 and it's basically killing the use of this wrapper. VMWorkstation and standalone converter are not options as a workaround and editing the HW version config var in the .vmx seems like a dirty workaround. I don't have the option of using the PowerCLI so it has to be scripted from *nix. Any insight on how people have dealt with this is greatly appreciated.
Target: vmx-8 for all guests created via vmcreate.pl.
Thanks in adavnce.