Aristizabal's Posts

Perfect, thanks for the quick reply.
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 VMwa... See more...
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.
According to VMware support this is not possible.
Hi, I would like to have the VM swap file on a different directory from the snapshot files. I can change the snapshot directory on the fly using a Perl script, but the problem is that after... See more...
Hi, I would like to have the VM swap file on a different directory from the snapshot files. I can change the snapshot directory on the fly using a Perl script, but the problem is that after I do so and power cycle the VM, the swap file is created on the snapshot directory. There is a KB that explains how to force the creation of the swap file to a particular directory, http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002929 by setting the option sched.swap.dir; the problem is that if I do it while the VM is power on the change doesn't have any impact after the VM is power cycled. Is it possible to set the sched.swap.dir option through the API?, or use any other routine to change the VM config spec?. I am aware of the global policy that can be set to store all the VM swap files in one datastore but I prefer to stay away from an option that involves changes for all the VMs on the host. Any help is highly appreciated, Juan.
Thanks William, that makes sense; I got it working now. Juan.
Thanks for the reply William. I modified my script and now I run it against a vCenter server. I get the HostSystem object and then I try to get the LicenseManager object from it, but now the o... See more...
Thanks for the reply William. I modified my script and now I run it against a vCenter server. I get the HostSystem object and then I try to get the LicenseManager object from it, but now the object is undefined. Before I was able to get the LicenseManager talking directly to the ESX host. Here is the code I am using: my $hostname = Opts::get_option('hostname'); my $host_view = Vim::find_entity_view(view_type => 'HostSystem',filter => {name => $hostname}); my $licenseSystem = $host_view->configManager->licenseManager; print $licenseSystem; And this is the error I get when I run it: Use of uninitialized value in print at ./check_license.pl line 33. Juan.
Hello, I am trying to obtain the list of licensed features for a vSphere 4.0 host using the the QueryAssignedLicenses method via perl SDK. I can get the license Manager object but every tim... See more...
Hello, I am trying to obtain the list of licensed features for a vSphere 4.0 host using the the QueryAssignedLicenses method via perl SDK. I can get the license Manager object but every time I get the managed object "LicenseAssignmentManager" it is undefined. Here is the code I am using: my $host; my $host_views = Vim::find_entity_views(view_type => 'HostSystem'); $host = @$host_views[0]; my $licenseSystem = Vim::get_view(mo_ref => ($host->configManager->licenseManager) ); my $licenses = Vim::get_view(mo_ref => ($licenseSystem->licenseAssignmentManager) ); my $licenseDummy = $licenses->QueryAssignedLicenses(); And this is the error message: "Can't call method "type" on an undefined value at /usr/share/perl/5.8/VMware/VICommon.pm line 1244." I have tried assigning the return value of QueryAssignedLicenses(); directly to an object but the result is the same, and I think the method can't be called since the LicenseAssignmentManager" object is undefined. As pointed out on the thread: http://communities.vmware.com/message/1271444, I tried with different methods but all of them are deprecated for vSphere and I get a SOAP error. Any help is highly appreciated. Thanks. Juan Aristizabal.
I found out from Veeam that this kind of script won't interfere with their CBT use for incremental backups. They say it is normal for the changeId to increase multiple times, although I think the... See more...
I found out from Veeam that this kind of script won't interfere with their CBT use for incremental backups. They say it is normal for the changeId to increase multiple times, although I think there should be a limit. It would be nice to know from VMware if there is any limitation.
Hello, I wrote a program that by using CBT will give me the amount of changes on a particular VM. My concern is that if this program will introduce problems to any backup solution that uses CB... See more...
Hello, I wrote a program that by using CBT will give me the amount of changes on a particular VM. My concern is that if this program will introduce problems to any backup solution that uses CBT to enable incremental backups, like Veeam or vRanger on the same VM. Let's say I need a good resolution from my CBT script, and through the day I take 24 data points; now if my backup solution generates a backup job every 2 or 3 days, how can I be sure that it can still use that "old" changeId from 2 or 3 days ago? In other words, how many points in time (changeId's) can I have and be able to call QueryChangedDiskAreas to get the changed blocks. Any help is highly appreciated, Juan Aristizabal.
Hello. I have the following code to verify if a LUN can be seen from the ESX using the Perl API: sub checklun() { my $success = 0; my $storageSystem = Vim::get_view(mo_ref => ($... See more...
Hello. I have the following code to verify if a LUN can be seen from the ESX using the Perl API: sub checklun() { my $success = 0; my $storageSystem = Vim::get_view(mo_ref => ($host->configManager->storageSystem) ); my $scsiLUN = $storageSystem->storageDeviceInfo->scsiLun; foreach (@$scsiLUN) { my $id= hex(substr $_->uuid, 2, 4); if ($id == $lun) { $success = 1; return $success; } } return $success; } Occasionally I get the following error when I call the script: exit code: '139' (0x0000008b) stdout: '' stderr: 'Segmentation fault (core dumped) As I said, it only happens once in a while under no special conditions, has anybody experienced this kind of problem using the Perl API. The core file is available if it helps someone to troubleshoot the issue. Thanks. Juan Aristizabal.
Thanks William, you put me on the right track. The following thread is also helpful: http://communities.vmware.com/thread/117162
Hello, I have been reading the Perl API documentation but I cannot find a way to monitor when a particular HBA is doing a rescan operation. We have a shared environment where multiple peopl... See more...
Hello, I have been reading the Perl API documentation but I cannot find a way to monitor when a particular HBA is doing a rescan operation. We have a shared environment where multiple people start rescan operations, which decreases the performance of the storage and even hangs the ESX server sometimes. Is there any way to create a custom event for the rescan operation, or maybe get the whole list of tasks being executed at the ESX and then parse it for the rescan operation. Any help is highly appreciated. Juan Aristizabal.
Thanks a lot William, your suggestion works great.
I have an iSCSI target that has been formatted and partitioned to create a volume. I want to be able to map the LUN of iSCSI target to the volume UUID. esxcfig-vmhbadev -m does this directly... See more...
I have an iSCSI target that has been formatted and partitioned to create a volume. I want to be able to map the LUN of iSCSI target to the volume UUID. esxcfig-vmhbadev -m does this directly, for example in the bottom line LUN 207 maps to the UUID 4ac128de-d4b8f7c3-a4a5-001ec9ab7607. vmhba0:1:0:1 /dev/sdb1 47a3995d-bf8312ea-aa8a-0019b9f36fbf vmhba0:0:0:3 /dev/sda3 479f6ab3-636688b2-277b-0019b9f36fc1 vmhba1:4:200:1 /dev/sdc1 4ac127e9-81fb1fcf-1138-001ec9ab7607 vmhba1:15:207:1 /dev/sdd1 4ac128de-d4b8f7c3-a4a5-001ec9ab7607 How do I do this using the Perl API? I can get two halfs of the information, but I can't see how to map them. This code snippet gives me information about the LUN, and the SCSI UUID print " Canonical Name, UUID\n"; my $scsiLUN = $storageSystem->storageDeviceInfo->scsiLun; foreach (@$scsiLUN) { print " ". $_->canonicalName . ", " . $_->uuid . "\n"; } Canonical Name, UUID vmhba1:15:207, 0100cf000020202020564952545541 vmhba0:1:0, 020000000050014ee0004544c3574443205744 vmhba0:0:0, 020000000050014ee0004544d2574443205744 vmhba1:4:200, 0100c8000020202020564952545541 Then this snippet give me information about the volume: my $mountInfo = $storageSystem->fileSystemVolumeInfo->mountInfo; print " Volume Name, Path, Type, Capacity\n"; foreach (@$mountInfo) { print " ". $_->volume->name . ", " . $_->mountInfo->path . ", " . $_->volume->type . ", " . $_->volume->capacity . "\n"; } Volume Name, Path, Type, Capacity esx7_local_storage2, /vmfs/volumes/47a3995d-bf8312ea-aa8a-0019b9f36fbf, VMFS, 79725330432 esx7_local_storage1, /vmfs/volumes/479f6ab3-636688b2-277b-0019b9f36fc1, VMFS, 71672266752 vol_2_1, /vmfs/volumes/4ac127e9-81fb1fcf-1138-001ec9ab7607, VMFS, 805306368 snap-0e22598d-vol_2_1, /vmfs/volumes/4ac128de-d4b8f7c3-a4a5-001ec9ab7607, VMFS, 805306368 But then how do I map vmhba1:15:207 to /vmfs/volumes/4ac128de-d4b8f7c3-a4a5-001ec9ab7607? Thanks
Thanks a lot.
Do you mean that the code 408 is equivalent to 008?
Hi. I am working with the ViX API to get the state of a VM, according to the documentation here are the expected return values: typedef int VixPowerState; enum { VIX_POWERSTATE_POWE... See more...
Hi. I am working with the ViX API to get the state of a VM, according to the documentation here are the expected return values: typedef int VixPowerState; enum { VIX_POWERSTATE_POWERING_OFF = 0x0001, VIX_POWERSTATE_POWERED_OFF = 0x0002, VIX_POWERSTATE_POWERING_ON = 0x0004, VIX_POWERSTATE_POWERED_ON = 0x0008, VIX_POWERSTATE_SUSPENDING = 0x0010, VIX_POWERSTATE_SUSPENDED = 0x0020, VIX_POWERSTATE_TOOLS_RUNNING = 0x0040, VIX_POWERSTATE_RESETTING = 0x0080, VIX_POWERSTATE_BLOCKED_ON_MSG = 0x0100, VIX_POWERSTATE_PAUSED = 0x0200, VIX_POWERSTATE_RESUMING = 0x0800, }; But I am getting the code 0x0408 sometimes when the VM is currently powered on, can somebody tell me the meaning of this code, is it providing extra information about the VM?? Thank you.
Thanks a lot for the clarification.
Hi. I have configured an alarm to call a script whenever a VM is vMotioned with the following code: my $alarmScript = 'C:\event-reporter.bat'; my $alarmMgr = Vim::get_service_content()->al... See more...
Hi. I have configured an alarm to call a script whenever a VM is vMotioned with the following code: my $alarmScript = 'C:\event-reporter.bat'; my $alarmMgr = Vim::get_service_content()->alarmManager; my $alarm = Vim::get_view(mo_ref => $alarmMgr); my $alarmExpr = EventAlarmExpression->new (eventType=>'VmMigratedEvent'); my $alarmAction = RunScriptAction->new( script => $alarmScript ); my $alarmTrigger = AlarmTriggeringAction->new( action => $alarmAction, red2yellow => 1, green2yellow => 1, yellow2red => 1, yellow2green => 1 ); my $alarmSpec = AlarmSpec->new( name => 'VM vMotioned', description => 'Trigger to run script when VM is started' , enabled => 1, expression => $alarmExpr, action => $alarmTrigger, ); my $newAlarm = $alarm->CreateAlarm(entity => $vm, spec=>$alarmSpec); I would like to improve this alarm by passing runtime parameters to the script when the VM is migrated, more specifically the host IP of the ESX hosting the recently migrated VM. I know that by using the ActionParameter constants you can pass runtime info, but I don't know if is possible to pass information of the object (VM) the alarm is associated to. Thanks. Juan Aristizabal.
Perfect, I just added this code to my script and everything works now. Thank you very much.