Quantcast
Channel: VMware Communities : All Content - vSphere Management SDK
Viewing all 1860 articles
Browse latest View live

vVol disk WWN ?

$
0
0


Hello Experts,


Is there a way (in MOB) to identify the VM disk WWN when the disk is using the vVols as Datastore ?


Thanks,


Balu


Getting CBT Change ID using vSphere API

$
0
0

Hi,

 

I am using following vSphere API to get the changed areas

 

vimPortType.queryChangedDiskAreas()

 

the change ID is passed as parameter to this API and I am giving as "*" initially.

Now for incremental changes I want to execute this API with a change ID other than "*".

Using power CLI I can get it by executing following command.

 

PS:> $vm = Get-VM -Name {VM_NAME}

PS:> $vmview = $vm | Get-View 

PS:> $newSnap = $vm | New-Snapshot -Name "SnapShotName" 

PS:> $newSnapview = $newSnap | Get-View 

PS:> $changes=$vmview.QueryChangedDiskAreas($newSnapview.MoRef, 2000, 0, "*")

PS:> $thischange=($newsnapview.Config.Hardware.Device | where { $_.Key -eq 2000 }).backing.changeid

PS:> echo $thischange

52 dd 70 e2 95 fd d1 2b-4c eb aa c3 90 b2 ce 3d/2


I am looking for the vSphere SDK API to get the change ID like this, any help would be highly appreciated.

Create a VmGroup in DRS and populate with VM (pyVmomi)

$
0
0


Hello,


I'm trying to create a VmGroup and populate it with some VM in order to configure DRS to keep some virtual machines together.


I wrote it in this way:


def add_vm_to_vm_group(self, vm, cluster):
# check if VmGroup Exists windows_group = filter(lambda x: x.name == 'Windows', filter(lambda x: x.__class__.__name__ == 'vim.cluster.VmGroup', cluster.configurationEx.group)
)
spec = vim.cluster.ConfigSpecEx()
if windows_group:
operation = "edit" vm = vm if type(vm) is list else [vm]
group_vm = vim.cluster.GroupSpec()
group_vm.info = windows_group[0]
else:
operation = "add" vm = []
group_vm = vim.cluster.GroupSpec()
group_vm.info = vim.cluster.VmGroup()
group_vm.operation = operation
if not windows_group:
group_vm.info.name = "Windows" group_vm.info.vm = vm
spec.groupSpec.append(group_vm)
task = cluster.ReconfigureComputeResource_Task(spec, True)
wait_for_task(task)




Actually, the group is created but it has no VM inside of it. Watching at the group_vm object I can see the VirtualMachine on the property and the request is made according to it. I receive no errors from vCenter but still I'm not able to add the virtual machine to the group.


Could someone help me? I'm going crazy about this...


 


Thanks!

Custom Task setTaskState Error example

$
0
0


I'm trying to set error messages for my custom tasks when some unexpected error occurs.   From the vSphere 5.5 docs, I understand I need to invoke Task.setTaskState with the following parameters:


    _this    ManagedObjectReference    // reference to task


    state    TaskInfoState    // must be TaskInfoState.ERROR for errors


    result   xsd:anyType      // valid only if TaskInfo.State.success SKIP


    fault     MethodFault     //  must directly or indirectly extend VimFault


 


In the Eclipse IDE, the method VimPortType.setTaskState says the final argument is of type LocalizedMethodFault, not MethodFault.   So, I created a LocalizedMethodFault variable and set its properties.  One property setter is setFault, which takes a MethodFault.  I know VimFault extends MethodFault, so I create a VimFault instance and use with setFault. 


However, I see VimFault has a setter setFaultCause, which takes an argument of, LocalizedMethodFault.   So this fault assignment is starting to get recursive.


                LocalizedMethodFault fault = new LocalizedMethodFault();
                VimFault vimFault = new VimFault();


            
                fault.setDynamicType("Runtime Error");
                fault.setLocalizedMessage(message);
                fault.setFault(vimFault);


                vimFault.setDynamicType("Runtime Error");
                vimFault.setFaultCause(fault);


In any case, I tried to use this code but it did not work.  Any ideas or example code that works would be greatly appreciated.


-E

Building and Running Samples (vSphere Web Services SDK 6.0 and JDK 8 (1.8.0_x) and make code

$
0
0


What are the necessary actions in order to build and run vSphere Management SDK 6.0 samples using Java JDK 8 (1.8.0_x)

 


I have followed the Developer's setup guide. Aparently samples and stubs are correctly generated but when running one sample, errors are displayed.


run.bat com.vmware.general.SimpleClient --url https://IP_addr/sdk  --username user --password pwd --ignorecert ignorecert



WARNING: Java is now set to trust all SSL certificates.
-- VMware samples in Java --
java.security.cert.CertificateException: Subject class type invalid.
        at sun.security.x509.X509CertInfo.setSubject(X509CertInfo.java:888)
        at sun.security.x509.X509CertInfo.set(X509CertInfo.java:415)


Thanks


 

vSphere4.x SDK compatiabilty with vSphere6

$
0
0

hello,

Does product buit on VMware vsphere sdk 4.x works on the newly released vSphere6?

it works fine on 5.1 and 5.5 but not sure about vSphere6.

How to configure VLAN in VSWITCH from VM?

$
0
0

I know how to configure VLAN in vswitch through vsphere client. But i want to know if it is possible to add vlan in vswitch from a virtual machine running in ESX server. Is there a way to use any vmware tools to achieve this?

How to install bundle on ESXi 5 using VI SDK 4.0/5.0

$
0
0

Hi,

 

I am trying to install a bundle on ESXi 5 machine remotely using vSphere SDK but it seems VMware no longer supports "esxupdate" command. VMware says to use esxcli instead of esxupdate but for running esxcli remotly i need to install vCli on my client machine, which i don't want to. Is there any way to install bundle on ESXi 5 using vSphere SDK 4.0 or 5.0?

 

What API does vCli(esxcli) command uses to install and uninstall bundle/depot?

 

I need to install, uninstall and query bundle list on ESXi5 using vSphere SDK.

 

Note: I can install and uninstall vib in ESXi 5 using vSphere SDK but i want to install bundle and not vib.

 

 

Thanks


ResolveMultipleUnresolvedVmfsVolumesEx_Task() - VMware vSphere Web Services API displays "host.StorageSystem.resolveMultipleUnresolvedVmfsVolumesEx" as task name

$
0
0

ResolveMultipleUnresolvedVmfsVolumesEx_Task() - VMware vSphere Web Services API displays "host.StorageSystem.resolveMultipleUnresolvedVmfsVolumesEx" as task name.

 

There is no specification object, another API that can be used to update the respective Task Name description with user friendly message string instead of class name id.

 

Please let me know what can done for updating Task Name description for ResolveMultipleUnresolvedVmfsVolumesEx_Task() VMware vSphere Web Services API call with user friendly message string instead of class name id "host.StorageSystem.resolveMultipleUnresolvedVmfsVolumesEx".

 

Also the "XXX host.StorageSystem" is displayed which also needs to be updated.

 

vSphere Web Client - Version 5.5.0 Build 1300321

VMware vCenter Server - Version 5.5.0 Build 1312298

 

ResolveMultipleUnresolvedVmfsVolumesEx_Task_TASK_LABEL.png

 

Thanks!

How do I determine the age of a virtual machine?

$
0
0

I've seen some Powershell to go through all the events and find the creation event, but this method doesn't seem ideal, as I understand it can get confused by software version upgrades, and the events may not be retained depending on settings.  

I can get the creation time of the first root snapshot, e.g. vm.snapshot.rootSnapshotList[0].createTime.   This is quite useful, and coincides with creation dates for many machines, however some VMs don't have a root snapshot.

Can I do better?

Thanks!

PS:  I am using pyVmomi, however I don't think this is the problem, and can switch to another language if necessary.

Creating a VMFS Datastore using Vi Perl Toolkit Question

$
0
0

 

Hello,

 

 

I am trying to use the VI PerlToolkit to create a VMFS datastore on an ESX Sever.  I found a method called CreateVmfsDatastore which is a managed object of type HostDatastoreSystem.  (See below for a link to the documentation for this method). To make the call to CreateVmfsDatastore, I get the datastoreSystem object, which is of type "HostDatastoreSystem'. When I try to call CreateVmfsDatastore in the below code, I get the following error.  Does anyone have any idea what I may be doing wrong?

 

 

Error Message:

 

 

Can't locate object method "CreateVmfsDatastore" via package "ManagedObjectReference"

 

 

http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.host.DatastoreSystem.html#createVmfsDatastore

 

sub _createDataStore

 

 

               {

 

 

                      my $host_view = Vim::find_entity_view(view_type => 'HostSystem');

 

 

                      print "\nThe name of this host is ", $host_view->name . "\n\n";

 

 

                      my $hostDiskPartitionSpec = new HostDiskPartitionSpec();

 

 

                      my $hostScsiDiskPartition = new HostScsiDiskPartition( diskName => 'vmhba3:0:0', partition => 3 );

 

 

                      my $hostVmfsSpec = new HostVmfsSpec( blockSizeMb => 262144, extent => $hostScsiDiskPartition, majorVersion => 3,  volumeName => 'datastore2');

 

 

                      my $vmfsDatastoreCreateSpec = new VmfsDatastoreCreateSpec( extent => $hostScsiDiskPartition, partition => $hostDiskPartitionSpec, vmfs => $hostVmfsSpec );

 

 

                      my $dataStoreSystem = $host_view->configManager->datastoreSystem;

 

 

                      $dataStoreSystem->CreateVmfsDatastore( spec => $vmfsDatastoreCreateSpec );

 

 

               }

 

The variable String of the fault message in customized task can not be replaced in web client 5.1

$
0
0

I registered a customized Task to my web client Extension with the task id: com.test.my_task.

After that, I also registered the Extension Fault for this Task, the content of the fault.vmsg is as below:

com.test.my_fault.summary = " This is a test fault message for task,detail: {data.message}".

 

To use this customized task and fault, I called the API setTaskState():

VimPortType.setTaskState(task, TaskInfoState.ERROR, null, localizedMethodFault);

the param "task" is ManagedObjectRefrence of the Task, and the content of the param "localizedMethodFault" is as below:

 

LocalizedMethodFault localizedMethodFault = new LocalizedMethodFault();

ExtendedFault extendedFault = new ExtendedFault();

KeyValue keyValue = new KeyValue();

keyValue.setKey("message");

keyValue.setValue("the detail message for test");

extendedFault.getData().add(keyValue);

extendedFault.setFaultTypeId("com.test.my_fault");

localizedMethodFault.setFault(extendedFault);

 

Then I do a test in web client 5.1, 5.5 and 6.0, the results is:

In the web client 5.5 and 6.0, my customized Task and Fault message show up in the Task Console,and the String {data.message} is replaced by "the detail message for test".

But in the web client 5.1, the String {data.message} of the customized Fault message is not be replaced.

 

The API is vSphere Management SDK 5.1.

 

Could anyone can help me solve this confused problem?

 

Thank you very much

How to get performance data from CIM/SMASH for processor, memory etc. ?

$
0
0

I need to get some data for monitoring purposes concerning processor usage, memory usage, storage and similar. Right now, I'm using a system which manages its own Http packets and uses WS Management to send Soap Xml Enumerate/Pull request and interprets the responses. I am able to query the OMC_Processor table from which the column LoadPercentage seem to be what I want but it is empty. As for memory and storage, I haven't found a table which contains data I want since OMC_Memory and related tables do not seem to have memory used/free columns.

 

Is there some configuration I need to change for the server to updates its live data in those tables?
If there is, which columns of which table would be appropriate for Memory and Storage monitoring?

 

I'm hoping there is way to get what I want through CIM/SMASH, but if not, how can I access such data efficiently? I know the vSphere Client is able to get it so it must be possible. I have read on other parts of the forum that it is possible through PowerCLI script, but that seems inefficient for my purpose.

 

I am currently testing on a local server running vSphere 5.5, but I'm going for something that has as much compatibility as possible for other versions, older and newer.

Create Schedule task throwing invalid argument error.

$
0
0

Hi,

Currently we are using DailyTaskScheduler for SOME activity in our plugin.

Code Snip :

 

    taskSpec details :

                name : "task name"

                description : "some desc"

                enabled = true;

                scheduler = dailyScheduler.

              

               CreateTaskAction taskAction = new CreateTaskAction();

               taskAction.cancelable = true;

               taskAction.taskTypeId = "XXX_ID"

 

               taskSpec.action = taskAction;

              scheduledTaskManager.createScheduledTask(me, taskSpec);  //for creating schedule task.

 

Above code works fine with vCenter 5.1 and 5.5 but while deployed in VC 6.0 it throws

com.vmware.vim25.InvalidRequest

 

While checking on web client task details it says : You have attempted to use scheduler vim.scheduler.TaskScheduler that is unknown to VCenter.

Object is NULL if querying a VM with brackets in DisplayName

$
0
0

Hello everybody,

 

I just started using the VimClient with C#/.NET

I have the following code:

 

        VimClient client = new VimClient();
        client.Connect(serviceUrl);
        client.Login(userName, password);
        NameValueCollection filter = new NameValueCollection();

 

      
        int countCheckedVMs = clbVMsToolsNeedUpgrade.CheckedItems.Count - 1;
        for (int i = 0; i <= countCheckedVMs; i++ )
        {
            string displayName = clbVMsToolsNeedUpgrade.CheckedItems[i].ToString();

 

            filter.Add("Config.Name", displayName);
            MessageBox.Show(filter[0].ToString());
          
            IList<EntityViewBase> vmList = client.FindEntityViews(typeof(VirtualMachine), null, filter, null);
          
            foreach (VirtualMachine vm in vmList)
            {
                vm.UpgradeTools("/S /v\"/qn REBOOT=ReallySuppress\"");
                rtbLog.AppendText("VMware Tools-Upgrade for VM " + displayName + " started\n");
            }
          

 

            filter.Remove("Config.Name");
                       
        }
          

 

        client.Disconnect();

 

This is working good until it comes to a VM which has brackets in its displayname.

So a VM called "My Server" is working but not "My Server (rellay)"

I have no idea why, cant the VimClient handle the brackets?


How to get ESXi information from vCenter via scripts

$
0
0

Hello Guru's,

How do I collect all the ESXi hosts information in a cluster by doing SSH to vCenter. Basically, I want to do SSH to vCenter and get the host version, enic, fnic driver versions. I have a hard limit that my tool can use either SSH or python api's. Appreciate if anyone can point me the right set of commands.

Thanks, Karthick.

SSO Client Samples return 400 bad request

$
0
0

I'm using VMware-vSphere-SDK-6.0.0-2561048 and trying to obtain a token from vSphere SSO. Both the Java and .NET samples for AcquireHoKTokenByUserCredentialSample return a 400 http error code. I've tried using VCSA as well as an installed copy of build 2559268 and both give the same errors.


I'm using https://hostname:443/STS/STSService and administrator@vsphere.local

 

I'm also getting a bunch of warnings when the STS service object is created:

 

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}TransportBinding" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}EndorsingSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedSupportingTokens" was evaluated as "UNKNOWN".

Jun 22, 2015 3:56:06 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector]  selectAlternatives

WARNING: WSP0075: Policy assertion "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SignedSupportingTokens" was evaluated as "UNKNOWN".

Failure in CreateVM_Task: The request refers to an unexpected or unknown type.

$
0
0

I am trying to create a VM by constructing my own VirtualMachineConfigSpec object and calling CreateVM_Task but the operation is failing with the error: The request refers to an unexpected or unknown type.

vCenter 5.5 logs show:

2015-06-27T16:32:11.005-07:00 [05908 error 'Default' opID=58d52058] Section for VMware VirtualCenter, pid=6292, version=5.5.0, build=1312298, option=Release

-->

2015-06-27T16:32:11.011-07:00 [05908 info 'commonvpxLro' opID=58d52058] [VpxLRO] -- FINISH task-2650 -- group-v165 -- vim.Folder.createVm --

2015-06-27T16:32:11.011-07:00 [05908 info 'Default' opID=58d52058] [VpxLRO] -- ERROR task-2650 -- group-v165 -- vim.Folder.createVm: vmodl.fault.InvalidType:

--> Result:

--> (vmodl.fault.InvalidType) {

-->    dynamicType = <unset>,

-->    faultCause = (vmodl.MethodFault) null,

-->    argument = "ManagedObjectReference",

-->    msg = "",

--> }

--> Args:

-->

My VirtualMachineConfigSpec XML is as follows.

Execute SOAP request to Add Virtual Machine to DRS Group

$
0
0

Hi, I've been working with SOAP messages and the vSphere vimService lately. I've ran into a snag. I want to add a virtual machine to an existing DRS group by send a soap call to the API. Here's what I'm trying:

 

<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

  <soap:Header>

  </soap:Header>

  <soap:Body>

    <ReconfigureComputeResource_Task xmlns="urn:internalvim25">

      <_this xsi:type="ManagedObjectReference" type="ClusterComputeResource">domain-c22</_this>

      <spec xsi:type="ClusterConfigSpecEx">

        <groupSpec>

          <operation>edit</operation>

          <info xsi:type="ClusterVmGroup">

            <name>migrateVMs</name>

            <vm type="VirtualMachine" >vm-2261</vm>

          </info>

        </groupSpec>

      </spec>

      <modify>true</modify>

    </ReconfigureComputeResource_Task>

  </soap:Body>

</soap:Envelope>

 

Error Message:

 

Unable to find specified dynamic type &quot;ClusterVmGroup&quot;

Specified dynamic type ClusterVmGroup is not a DataObject type.

 

If I watch this call happen in Project Onyx using both the VI Client and PowerCLI the exact same call is pretty much being made, without failure. Can anyone provide an explanation on how format my SOAP to make this work? I use onyx for similar operations making SOAP calls and never have problems. I've reviewed the reference API docs, and it looks right...

 

Kind Regards

Getting Tags Assigned to a Virtual Machine via the API

$
0
0

Hey All,

 

By reading about various posts i see that until version 6 the tags assigned via the web client is only available to the web client is that true?

 

I currently have a script to iterate each of the vm's in the environment to gather information and i was wanting to use tags as a way of identifying some things specifically about the vm

 

Can someone confirm this is still the case in 5.5 and that it will only be available in 6.0 on wards?

 

Thanks

Viewing all 1860 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>