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

vSphere-WS SDK Packages and JavaDoc

$
0
0

Hello guys,

 

I do have a bunch of question regarding to the java vsphere-ws sdk. I have build the vim25.jar and samples.jar following the instructions here:

http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.wssdk.dsg.doc/sdk_java_development.4.4.html

  • Is it possible to get the java doc for the vim25.jar into Netbeans?, I only found the Javadoc for the samples?
  • Is there a current documentation for all the classes at all? For example I was not able to find any documentation for the class "VimPortType"?
  • A lot of examples that I consulted in order to get startet with the sdk do import something from the package “mo”, like these:
    • importcom.vmware.vim25.mo.ClusterComputeResource;
    • importcom.vmware.vim25.mo.Datastore;
    • importcom.vmware.vim25.mo.Folder;
    • importcom.vmware.vim25.mo.HostSystem;
    • importcom.vmware.vim25.mo.InventoryNavigator;
    • importcom.vmware.vim25.mo.ServiceInstance;
    • importcom.vmware.vim25.mo.VirtualMachine;

     But somehow I do not have the “mo” package at all. Is this deprecated in 6.0 or why am I unable to see them?


Setting VM annotation/notes via SDK.

$
0
0

 

I'm interested in setting the annotation/notes property of a VM programatically via the Java/vSphere Web service SDK.  It seems that the annotation field is available in the following types:

 

  • VirtualMachineConfigSummary

  • VirtualMachineConfigInfo

  • VirtualMachineConfigSpec

 

So I guess I have a two part question.  One, which of the above types should I operate on in order to set the "Notes" field and secondly, what is the most direct way to accomplish this via Java and the SDK?

pyvmomi - add disk - RecommendDatastores

$
0
0

I am trying to add a disk to an existing VM.

if vm:    for cluster in ds_cluster:        print cluster.name        spec = vim.vm.ConfigSpec()        # get all disks on a VM, set unit_number to the next available        for dev in vm.config.hardware.device:            if hasattr(dev.backing, 'fileName'):                unit_number = int(dev.unitNumber) + 1                # unit_number 7 reserved for scsi controller                if unit_number == 7:                    unit_number += 1                if unit_number >= 16:                    print "we don't support this many disks"                    return            if isinstance(dev, vim.vm.device.VirtualSCSIController):                controller = dev        # add disk here        dev_changes = []        new_disk_kb = INSTANCE_TYPE['standard']['diskSize']  * 1024 * 1024 #int(args.disksize) * 1024 * 1024        disk_spec = vim.vm.device.VirtualDeviceSpec()        disk_spec.fileOperation = "create"        disk_spec.operation = vim.vm.device.VirtualDeviceSpec.Operation.add        disk_spec.device = vim.vm.device.VirtualDisk()        disk_spec.device.backing = \            vim.vm.device.VirtualDisk.FlatVer2BackingInfo()        disk_spec.device.backing.datastore = datastore        disk_spec.device.backing.thinProvisioned = True        disk_spec.device.backing.diskMode = 'persistent'        disk_spec.device.unitNumber = unit_number        disk_spec.device.capacityInKB = new_disk_kb        disk_spec.device.controllerKey = controller.key        dev_changes.append(disk_spec)        spec.deviceChange = dev_changes        spec.name = vm.summary.config.name        podsel = vim.storageDrs.PodSelectionSpec()        podsel.storagePod = cluster        vmpodconfig = vim.storageDrs.PodSelectionSpec.VmPodConfig()        vmpodconfig.storagePod = cluster        disklocator=vim.storageDrs.PodSelectionSpec.DiskLocator()        disklocator.diskId = unit_number        disklocator.diskBackingInfo = disk_spec.device.backing        vmconfiginfo = vim.storageDrs.VmConfigInfo()        vmconfiginfo.vm  = vm        vmconfiginfo.enabled = True        vmpodconfig.vmConfig = vmconfiginfo        vmpodconfig.disk.append(disklocator)        podsel.initialVmConfig.append(vmpodconfig)        storagespec = vim.storageDrs.StoragePlacementSpec()        storagespec.podSelectionSpec = podsel        storagespec.vm = vm        storagespec.type = 'reconfigure'        storagespec.folder = datacenter.vmFolder        storagespec.configSpec = spec        storagespec.resourcePool = resource_pool        print storagespec        rec = content.storageResourceManager.RecommendDatastores(storageSpec=storagespec)        rec_key = rec.recommendations[0].key        print rec_key        #task = content.storageResourceManager.ApplyStorageDrsRecommendation_Task(rec_key)        #wait_for_task(task, 'Applying Disk Recommendations')        #task = vm.ReconfigVM_Task(spec=spec)        #wait_for_task(task,"Adding disk")        print "%sGB disk added to %s" % ('4', vm.config.name)    #reboot(vm,content,args)else:    print 'VM not found'

 

I keep getting the error:

Caught vmodl fault : A specified parameter was not correct: StoragePlacementSpec.podSelectionSpec and configSpec

Any idea what i am missing?

The documentation here https://github.com/vmware/pyvmomi/blob/master/docs/vim/StorageResourceManager.rst#recommendDatastores

seems confusing.

Need help in identifying right vmware API Property to check whether a Datastore supports Hardware Acceleration or not

$
0
0

Hi ,

We are developing a datastore view screen where we need to bring in a column to check if  "Hardware Accelearation" is Supported/Not Supported. Can someone help me in identifying the right vmware API property to get "Hardware Acceleration" status for a Datastore? 

Currently I am using HostSystem.capability.vStorageCapable as the property get this value. Here HostSystem is the host on which datastore is created. But I am not able to confirm if this is the right property. I tried to disable Hardware Acceleration of Host from ESXi and check if the value changes for datastore.But this does not have any impact on the Hardware Acceleration of  the Datastore.

It is also good if any one can suggest a way to disable "Hardware Acceleration" for a datastore. Atleast this helps us in .confirming whether the property we are using is valid or not.

Thanks in Advance

Rajendra

vim25.jar with Axis2's jar file can't be compatible

$
0
0

Does anyone use both Apache Axis2 and vim25.jar??

Please tell me how to solve the problem..Thanks!!

 

PowerCLI 6.3 changes with VimClient.Connect() for C# - SSL/TLS Error

$
0
0

I have been developing a c# app and was using the VMWare.Vim DLL from PowerCLI 6.0. I updated my PowerCLI and now i am unable to connect to the vCenter. The connection now throws an error of "The underlying connection was closed: could not establish trust relationship for the SSL/TLS secure channel". I never had this problem before i upgraded PowerCLI. Is there a way to disable checking the certificate?

 

Thanks

How to log in to SSO with SAML Token string

$
0
0

I'm trying to connect to vCloud Suite API via vSphere Web Client Plug-in and assign a tag to a datastore.
But I want to avoid having users enter user name and password on vSphere Web Client Plug-in GUI because it is not user-friendly.
Therefore, I want to connect to vCloud Suite API without having users enter user name and password.

I thought I could log in to SSO using SAML Token XML(UserSession.samlTokenXml) that can be obtained from Web Client SDK, but failed.

Following is the code I created using vCloud Suite API sample code.

 

Code :
com\vmware\vcloud\suite\samples\common\ServiceManager.java

public void connect()
            throws com.vmware.vcloud.suite.lookup.RuntimeFaultFaultMsg,
            RuntimeFaultFaultMsg, InvalidLocaleFaultMsg, InvalidLoginFaultMsg, InvalidTokenException {
           
    ...
   
    // login to vAPI service end point
    vapi = new VapiServiceEndpoint(vapiUrl);
    String samltokenXml = "<saml2:Assertion xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\" ... </saml2:Assertion>";
    vapi.login(DefaultTokenFactory.createToken(samltokenXml));

    ...
}

com\vmware\vcloud\suite\samples\vapi\endpoint\ServiceEndpoint.java

    public void login(SamlToken samlToken) {
        StubConfiguration tmp = new StubConfiguration();
        // Create a PrivateKey
        SecurityUtil su = SecurityUtil.generateKeyCertPair();
        tmp.setSecurityContext(SecurityContextFactory.createSamlSecurityContext(samlToken, su.getPrivateKey()));
        T session = stubFactory.createStub(clazz, tmp);
        char[] sessionId = login(session);
        stubConfiguration.setSecurityContext(SecurityContextFactory.createSessionSecurityContext(sessionId));
    }

 

Error :
com.vmware.vapi.std.errors.Unauthenticated: Unauthenticated (com.vmware.vapi.std.errors.unauthenticated) => {
    messages = [LocalizableMessage (com.vmware.vapi.std.localizable_message) => {
    id = vapi.method.authentication.required,
    defaultMessage = This method requires authentication.,
    args = []
}],
    data = <null>
}
    at com.vmware.vapi.std.errors.Unauthenticated._newInstance(Unauthenticated.java:164)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.vmware.vapi.internal.bindings.convert.impl.JavaClassStructConverter.createStructBinding(JavaClassStructConverter.java:167)
    at com.vmware.vapi.internal.bindings.convert.impl.JavaClassStructConverter.fromValue(JavaClassStructConverter.java:66)
    at com.vmware.vapi.internal.bindings.convert.impl.JavaClassStructConverter.fromValue(JavaClassStructConverter.java:36)
    at com.vmware.vapi.internal.bindings.TypeConverterImpl$ValueToJavaVisitor.visit(TypeConverterImpl.java:318)
    at com.vmware.vapi.bindings.type.ErrorType.accept(ErrorType.java:31)
    at com.vmware.vapi.internal.bindings.TypeConverterImpl.convertToJava(TypeConverterImpl.java:632)
    at com.vmware.vapi.internal.bindings.Stub.convert(Stub.java:389)
    at com.vmware.vapi.internal.bindings.Stub.convertError(Stub.java:406)
    at com.vmware.vapi.internal.bindings.Stub.access$300(Stub.java:58)
    at com.vmware.vapi.internal.bindings.Stub$2.setResult(Stub.java:220)
    at com.vmware.vapi.internal.bindings.Stub$2.setResult(Stub.java:211)
    at com.vmware.vapi.internal.protocol.client.msg.json.JsonApiProvider$ResponseCallbackImpl.received(JsonApiProvider.java:221)
    at com.vmware.vapi.internal.protocol.client.msg.json.JsonApiProvider$1.received(JsonApiProvider.java:249)
    at com.vmware.vapi.internal.protocol.client.rpc.http.HttpClient.handleContent(HttpClient.java:269)
    at com.vmware.vapi.internal.protocol.client.rpc.http.HttpClient.send(HttpClient.java:236)
    at com.vmware.vapi.internal.protocol.client.msg.json.JsonApiProvider.sendRequest(JsonApiProvider.java:126)
    at com.vmware.vapi.internal.protocol.client.msg.json.JsonApiProvider.invoke(JsonApiProvider.java:307)
    at com.vmware.vapi.internal.bindings.Stub.invoke(Stub.java:206)
    at com.vmware.vapi.internal.bindings.Stub.invoke(Stub.java:187)
    at com.vmware.vapi.internal.bindings.Stub.invokeMethodAsync(Stub.java:151)
    at com.vmware.vapi.internal.bindings.Stub.invokeMethod(Stub.java:119)
    at com.vmware.cis.SessionStub.create(SessionStub.java:37)
    at com.vmware.cis.SessionStub.create(SessionStub.java:30)
    at com.vmware.vcloud.suite.samples.vapi.endpoint.VapiServiceEndpoint.login(VapiServiceEndpoint.java:13)
    at com.vmware.vcloud.suite.samples.vapi.endpoint.VapiServiceEndpoint.login(VapiServiceEndpoint.java:1)
    at com.vmware.vcloud.suite.samples.vapi.endpoint.ServiceEndpoint.login(ServiceEndpoint.java:42)
    at com.vmware.vcloud.suite.samples.common.ServiceManager.connect(ServiceManager.java:138)
    at com.vmware.vcloud.suite.samples.common.ServiceManagerFactory.getServiceManager(ServiceManagerFactory.java:38)
    at com.vmware.vcloud.suite.samples.common.SamplesAbstractBase.getServiceManager(SamplesAbstractBase.java:151)
    at com.vmware.vcloud.suite.samples.cis.tagging.TagDatastore.setup(TagDatastore.java:80)
    at com.vmware.vcloud.suite.samples.common.SamplesAbstractBase.init(SamplesAbstractBase.java:127)
    at Main.tagCreateTest(Main.java:32)
    at Main.main(Main.java:19)

 

Login by the above code fails.

What kind of code should I create to log in to SSO using SAML Token XML?

Also, is there a way to connect to vCloud Suite API without using SSO's user name and password other than using SAML Token XML?

Clone a VM with THIN disk type as FLAT

$
0
0

I'm trying to clone a VM from a template. For that, I have a code as below 
 

VirtualMachineRelocateSpec rSpec = new VirtualMachineRelocateSpec();
...
rSpec.setTransform(VirtualMachineRelocateTransformation.FLAT);

 

As per this link

for thin provisioning , use sparse
for thick provisioning , use flat

Now, I want to check a condition where the underlying datastore doesn't support thick provisioning but I'm still passing transformation as flat (according to VMWare documentation here, which is a requirement)

In my case, the VM gets created with Thin provisioning. I want to know whether this is expected behavior or not. Should VMWare API throw an exception saying thick provision is not supported on this datastore.

Can anyone verify this?
 


Can't building the C# SSO DLL with Error: pvk2pfx command not found.

$
0
0

Visual Studio 2015 Community, Windows Driver Kit 10, Windows 10. I follow this doc http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.wssdk.dsg.doc/sdk_c_sharp_development.5.4.html?path=7_1_0_0_2_2_0#1002265

I navigate to the .NET subdirectory for SSO client samples.

cd %WS_SDK_HOME%\ssoclient\dotnet\cs\samples

and then generate a test certificate and STSService stubs using the build.bat script.

.\build.bat

I get this error:

'Files' is not recognized as an internal or external command,

operable program or batch file.

Error: pvk2pfx command not found.

       Please ensure that you have added path to pvk2pfx.exe to the PATH variable

I do file search, and pvk2pfx.exe doesn't not exist on a computer. MSDN says pvk2pfx.exe is included in WDK, but it's probably outdated info and after WDK installation, I still can't find pvk2pfx.exe

How to build the dll with VS2015?

Modifying virtual machine custom attributes values using pyvmomi

$
0
0

There is a discussion https://communities.vmware.com/thread/474322?start=0&tstart=0 which talks about creating virtual machine custom attribute using pyvmomi.

I want to set and get virtual machine custom attribute values using pyvmomi. What are the steps I can take to do that. 

For example I create a custom attribute like this

Name : owner

Type : Virtual Machine

Value : {not set}

 

I want steps to set the value to "Tom" for a specific vm whose name is "myvm". Then read the value for the vm "myvm" to check if it is still "Tom".

Incompatible device backing error when editing network adapter

$
0
0

Hello Expert Developer,


I am working on an automatic VM deployment project for vSphere. I am trying to reconfigure deployed VM and change the MAC address of its network adapter. Device type which is being edited is Vmxnet3. I am using the following code snippet to reconfigure the VM in php using VMWarephp library.


[code]

    $deviceConfigSpec = new VirtualDeviceConfigSpec();

    $deviceConfigSpec->operation = 'edit';

    $deviceConfigSpec->device = new VirtualVmxnet3();

 

    foreach ($configInfo->hardware->device as $device) {

      if (get_class($device) == 'VirtualVmxnet3') {

          $deviceConfigSpec->device->key = $device->key;

          $deviceConfigSpec->device->controllerKey = $device->controllerKey;

          $deviceConfigSpec->device->unitNumber = $device->unitNumber;;

          $deviceConfigSpec->device->addressType = 'Manual';

          $deviceConfigSpec->device->macAddress = $mac;

      }

    }

 

    $configSpec = array('deviceChange' => array($deviceConfigSpec));

    $vm->ReconfigVM_Task(array('_this'=>$vm->reference, 'spec'=>$co

[/code]

 

When this code is ran, I get the following error in vSphere Client's task list:

 

[code]

   Incompatible device backing specified for device '0'

[/code]

 

I will appreciate if you can help me

 

Thanks in advance.

Clone VM from TPL, Change DVS Backing - Not allowed in current state

$
0
0

Hi all, having some issues with the cloning of a template and modifying the existing virtual network device on the way through. I am getting the error "The operation is not allowed in the current state"

I am using ApplyStorageDrsRecommendation_Task due to us using SDRS clusters - wondering if there is something specific here i need to do differently when not using the CloneVM task?

Basic code for changing the backing below;

The configSpec object is a VirtualMachineConfigSpec which is attached to the VirtualMachineCloneSpec.config

I am finding the "networkDevice" object by iterating the VirtualMachineConfigInfo.hardware.device - FYI getting this via (VirtualMachineConfigInfo)cb.getServiceUtil().GetDynamicProperty(vmRef, "config");, vmRef is found via _service.FindByInventoryPath which is the template path.

            VirtualDeviceConfigSpec[] devSpec = new VirtualDeviceConfigSpec[0];
            configSpec.deviceChange = new VirtualDeviceConfigSpec[1];
            configSpec.deviceChange[0] = new VirtualDeviceConfigSpec();
            configSpec.deviceChange[0].operation = VirtualDeviceConfigSpecOperation.edit;
            configSpec.deviceChange[0].device = networkDevice;
 
 
            VirtualEthernetCardDistributedVirtualPortBackingInfo nicBack = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
            nicBack.port = new DistributedVirtualSwitchPortConnection();
            nicBack.port.switchUuid = dvsUUID;
            nicBack.port.portgroupKey= phKey;
 
            configSpec.deviceChange[0].device.backing = nicBack;
 
            configSpec.deviceChange[0].device.connectable = new VirtualDeviceConnectInfo();
            configSpec.deviceChange[0].device.connectable.startConnected = true;
            configSpec.deviceChange[0].device.connectable.allowGuestControl = true;
            configSpec.deviceChange[0].device.connectable.connected = true;

           VirtualDeviceConfigSpec[] devSpec = new VirtualDeviceConfigSpec[0];

            configSpec.deviceChange = new VirtualDeviceConfigSpec[1];

            configSpec.deviceChange[0] = new VirtualDeviceConfigSpec();

            configSpec.deviceChange[0].operation = VirtualDeviceConfigSpecOperation.edit;

            configSpec.deviceChange[0].device = networkDevice;

            VirtualEthernetCardDistributedVirtualPortBackingInfo nicBack = new VirtualEthernetCardDistributedVirtualPortBackingInfo();

            nicBack.port = new DistributedVirtualSwitchPortConnection();

            nicBack.port.switchUuid = dvsUUID;

            nicBack.port.portgroupKey= pgKey;

 

            configSpec.deviceChange[0].device.backing = nicBack;

 

            configSpec.deviceChange[0].device.connectable = new VirtualDeviceConnectInfo();

            configSpec.deviceChange[0].device.connectable.startConnected = true;

            configSpec.deviceChange[0].device.connectable.allowGuestControl = true;

            configSpec.deviceChange[0].device.connectable.connected = true;

 

Am i meant to be adding the device changes to something else such as the StoragePlacementResult?

I have also tried a simple remove of the NIC also which gives the same not allowed in current state error. 

Any help/direction/things to trial would be much appreciated!

Help with creating baremetal VM on Storage DRS Cluster (vSphere SDK)

$
0
0

Hello,

 

I would appreciate any help from anyone who has successfully built a baremetal VM on a Storage DRS Cluster in the vSphere SDK.  I am using c#.

I can clone vm's fine on the Storage DRS cluster, but when I am creating a baremetal VM, I am having issues with the ConfigSpec and the PodSelectionSpec.  Specifically, what do I put for the Datastore and fileName properties of the VirtualDiskFlatVer2BackingInfo properties.  I get an error that I have an incorrect parameter in the ConfigSpec and PodSelectionSpec.  Here is some code to create the PodSelectionSpec:

StorageDrsPodSelectionSpec podSelectionSpec = newStorageDrsPodSelectionSpec();

podSelectionSpec.StoragePod = vmOBJ.DataStore.Item2;

StoragePlacementSpec podPlacement = newStoragePlacementSpec();

podPlacement.DisallowPrerequisiteMoves = true;

podPlacement.Folder = vmOBJ.Folder.Item2;

podPlacement.Type = "create";

podPlacement.ConfigSpec = (VirtualMachineConfigSpec)Session["ConfigSpec"];

podPlacement.ResourcePool = vmOBJ.ResourcePool.Item2;

podPlacement.Host = hostMoref;

  

VmPodConfigForPlacement vmPodConfig = newVmPodConfigForPlacement();

vmPodConfig.StoragePod = vmOBJ.DataStore.Item2;

List<PodDiskLocator> podDiskConfig = newList<PodDiskLocator>();

VirtualMachineConfigSpec tempcfgspec = (VirtualMachineConfigSpec)Session["ConfigSpec"];

VirtualDeviceConfigSpec[] tempVDCfg = tempcfgspec.DeviceChange;

foreach (VirtualDeviceConfigSpec vd in tempVDCfg)

{

VirtualDevice VD = vd.Device;

if (VD.DeviceInfo.Label.Equals("Disk"))

{

PodDiskLocator temppodloc = newPodDiskLocator();

temppodloc.DiskId = vd.Device.Key;

VirtualDiskFlatVer2BackingInfo flatBack = newVirtualDiskFlatVer2BackingInfo();

flatBack.ThinProvisioned = true;

flatBack.DiskMode = "persistent";

flatBack.Datastore = null;

flatBack.FileName = "";

temppodloc.DiskBackingInfo = flatBack;

podDiskConfig.Add(temppodloc);

}

}

vmPodConfig.Disk = podDiskConfig.ToArray();

podSelectionSpec.InitialVmConfig = newVmPodConfigForPlacement[]{ vmPodConfig };

podPlacement.PodSelectionSpec = podSelectionSpec;

 

And here is the code to create the backinginfo:

VirtualDiskFlatVer2BackingInfo backInfo = newVirtualDiskFlatVer2BackingInfo();

backInfo.ThinProvisioned = thinProvisioned;

backInfo.DiskMode = "persistent";

backInfo.Datastore = null;

backInfo.FileName = "";

VirtualDisk tempDisk = newVirtualDisk();

tempDisk.Backing = backInfo;

tempDisk.CapacityInKB = size;

tempDisk.ControllerKey = controllerKey;

tempDisk.Key = (1 + i);

tempDisk.UnitNumber = unitNumber;

tempDisk.DeviceInfo = newDescription();

tempDisk.DeviceInfo.Label = "Disk";

tempDisk.DeviceInfo.Summary = "Disk";

VirtualDeviceConfigSpec tempConfigSpec = newVirtualDeviceConfigSpec();

tempConfigSpec.Device = tempDisk;

tempConfigSpec.FileOperation = VirtualDeviceConfigSpecFileOperation.create;

tempConfigSpec.Operation = VirtualDeviceConfigSpecOperation.add;

 

I realize that there is a lot going on but what I can't find the answer to, is how do I let vSphere choose the datastore and what do I need to have in there to create a VM on a Storage DRS Cluster?

Incompatible device backing error when changing network adapter address type

$
0
0

Hello Expert Developer,

I am working on an automatic VM deployment project for vSphere. I am trying to reconfigure deployed VM and change the MAC address of its network adapter. Device type which is being edited is Vmxnet3. I am using the following code snippet to reconfigure the VM in php using VMWarephp library.

[code]

   $deviceConfigSpec = new VirtualDeviceConfigSpec();

    $deviceConfigSpec->operation = 'edit';

    $deviceConfigSpec->device = new VirtualVmxnet3();

     foreach ($configInfo->hardware->device as $device) {

      if (get_class($device) == 'VirtualVmxnet3') {

          $deviceConfigSpec->device->key = $device->key;

          $deviceConfigSpec->device->controllerKey = $device->controllerKey;

          $deviceConfigSpec->device->unitNumber = $device->unitNumber;;

          $deviceConfigSpec->device->addressType = 'Manual';

          $deviceConfigSpec->device->macAddress = $mac;

      }

    } 

    $configSpec = array('deviceChange' => array($deviceConfigSpec));

    $vm->ReconfigVM_Task(array('_this'=>$vm->reference, 'spec'=>$co

[/code]

When this code is ran, I get the following error in vSphere Client's task list:

Incompatible device backing specified for device '0'

I will appreciate if you can help me

Thanks in advance.

[code]
    $deviceConfigSpec = new VirtualDeviceConfigSpec();
    $deviceConfigSpec->operation = 'edit';
    $deviceConfigSpec->device = new VirtualVmxnet3();
 
    foreach ($configInfo->hardware->device as $device) {
      if (get_class($device) == 'VirtualVmxnet3') {
          $deviceConfigSpec->device->key = $device->key;
          $deviceConfigSpec->device->controllerKey = $device->controllerKey;
          $deviceConfigSpec->device->unitNumber = $device->unitNumber;;
          $deviceConfigSpec->device->addressType = 'Manual';
          $deviceConfigSpec->device->macAddress = $mac;
      }
    }
 
    $configSpec = array('deviceChange' => array($deviceConfigSpec));
    $vm->ReconfigVM_Task(array('_this'=>$vm->reference, 'spec'=>$co
[/code]

mount a volume always fail invoked by vmtools

$
0
0

Hi,

 

I wrote a python script to execute command in guest OS by pyvmomi 6.0. The main function I used is "GuestProcessManager.StartProgramInGuest" to talk with vmtools in guest OS to execute specific command.  this script is working well with almost LVM related command such as lvdisplay, lvcreate ..., but got failed with command "mount" a existing LV to a mount point which  is last step for us automating create new volume in guest OS(RHEL 7.2). I observed in /var/log/message, it always complain the volume already mounted in guest system, but actually I can't see this LV in guest by root. below is specific information about my script and steps

 

python script:

ps = vim.vm.guest.ProcessManager.ProgramSpec(programPath=vm_command, arguments=vm_param, envVariables=all_envs)

res = pm.StartProgramInGuest(vm, creds, ps)

 

programPath=/usr/bin/mount

vm_param=/dev/vgdata/jason1 /sutton3  (vgdata is a existing VG,and jason1 is a existing LV, the directory /sutton3 is point I want to mount)

 

 

Run script to mount volume in guest(actually vmtools to do execution), /var/log/message complaints like this:

 

Sep 17 19:46:03 vpc4219 vmtoolsd: mount: /dev/mapper/vgdata-jason1 is already mounted or /sutton3 busy

Sep 17 19:46:03 vpc4219 vmtoolsd: /dev/mapper/vgdata-jason1 is already mounted on /sutton3

 

 

 

Actually run command in guest by root, I didn't see this volume show up

[root@vpc4219 ~]# mount -l | grep sutton3

[root@vpc4219 ~]# df -hT

Filesystem            Type      Size  Used Avail Use% Mounted on

/dev/mapper/rhel-root xfs        63G   14G   50G  22% /

devtmpfs              devtmpfs  7.8G     0  7.8G   0% /dev

tmpfs                 tmpfs     7.8G   88K  7.8G   1% /dev/shm

tmpfs                 tmpfs     7.8G   25M  7.8G   1% /run

tmpfs                 tmpfs     7.8G     0  7.8G   0% /sys/fs/cgroup

/dev/sda1             xfs       497M  211M  287M  43% /boot

tmpfs                 tmpfs     1.6G   16K  1.6G   1% /run/user/42

tmpfs                 tmpfs     1.6G     0  1.6G   0% /run/user/0

 

 

Afterward, I manually run mount command in guest by root, rather than script. It is successful easily without any error/warning. the question is why vmtools always failed command and how to fix this issue? Does anybodyhelp on this? thanks in advance.


Create a VM through CreateVM_Task and SOAP WebServices

$
0
0

Hello,

 

I am facing a strange problem here, trying to create a VM with Php & SOAP !

 

I managed to connect to my vCenter, and creating an "empty" VM with no additional hardware (no deviceChange section) is working fine ! As soon as I try to add a hardware element (CDRom in this case) It stops working.

 

Here's the XML code from my SOAP Request :

 

<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:vim25" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

     <SOAP-ENV:Body>

          <ns1:CreateVM_Task>

               <ns1:_this>group-v689</ns1:_this>

               <ns1:config>

                    <name>testSOAPh</name>

                    <version>vmx-11</version>

                    <guestId>RHEL7_64guest</guestId>

                    <files>

                         <vmPathName>[vsanDatastore]</vmPathName>

                    </files>

                    <numCPUs>1</numCPUs>

                    <memoryMB>4096</memoryMB>

                    <deviceChange>

                         <VirtualDeviceConfigSpec>

                              <device type="VirtualCdrom">

                                   <key>-42</key>

                                   <connectable>

                                        <startConnected>true</startConnected>

                                        <allowGuestControl>true</allowGuestControl>

                                        <connected>false</connected>

                                   </connectable>

                                   <controllerKey>200</controllerKey>

                                   <unitNumber>0</unitNumber>

                              </device>

                              <operation>add</operation>

                         </VirtualDeviceConfigSpec>

                    </deviceChange>

               </ns1:config>

               <ns1:pool>resgroup-27</ns1:pool>

          </ns1:CreateVM_Task>

     </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

 

And the error message :

 

Required property device is missing from data object of type VirtualDeviceConfigSpec

 

while parsing serialized DataObject of type vim.vm.device.VirtualDeviceSpec

at line 2, column 400

 

while parsing property &quot;deviceChange&quot; of static type ArrayOfVirtualDeviceConfigSpec

 

while parsing serialized DataObject of type vim.vm.ConfigSpec

at line 2, column 213

 

while parsing call information for method CreateVM_Task

at line 2, column 169

 

while parsing SOAP body

at line 2, column 154

 

while parsing SOAP envelope

at line 2, column 0

 

while parsing HTTP request for method createVm

on object of type vim.Folder

 


I think I am missing something pretty simple ! Like how to imbricate the device type (how to specify that you want to create a VirtualCdrom which is a special type of VirtualDevice) and how to design an ArrayOfVirtualDeviceConfigSpec !


Any ideas ?


Thanks,

GS

Is there any way to call system calls(like ioctl) in the SDK?

$
0
0

I need send a message a vmk device driver in the Java service, but I don't know whether current SDK support this.
In a local application, I can use system calls to open the device and call ioctl to operate it, as below:
    fd = open(dev, O_RDWR);
    ioctl(fd, IOCTL_GET_SOMETHING, some_info)
So now, I want to call the ioctl in the Java services through the SDK.
Is there any APIs in the SDK(like VI SDK) to run such system calls?

If there isn't, then what is the official method to send messages to a vmk device driver in the SDK?

Thanks a lot.

How to get the uuid of a host system

$
0
0

Actually I want to add a PCIPassthrough device to a VM. In the VirtualPCIPassthroughDeviceBackingInfo, it need to set a systemId.
systemId    xsd:string    The ID of the system the PCI device is attached to. 

I have tried that this systemId is not the one in the HostSystemInfo. The uuid in the HostSystemInfo is just a hardware BIOS uuid, it's not the uuid for the ESXi host.
In the Esxi shell, I found the correct id is saved in the /etc/vmware/esx.conf file, as below:
/system/uuid = "57920319-a8d9-2180-4501-3497f6000f91"

The problem is how to get it.
I have tried to print the advancedOption in the HostConfigManager in the HostSystem, but it doesn't contain this UUID.
I know that this file can be printed by the path https://[HOST_NAME]/host/esx.conf, but it seems not an official method and I'm afraid that this method can be closed for some security reasons.
So how can I get this uuid?

Thanks a lot.

"vDS dvs port cannot be found" when deleting a port mirroring session

$
0
0

Hi,

I have the following scenario:

- create a distributed port mirroring session

- add one source port and one destination port

- delete the vm marked as destination together with the portgroup it belongs to

Then when I try to edit/delete the mirroring session, I get the following error:

"The object or item referred could not be found. vDS dvs port 160 cannot be found".

Is there any workaround for deleting the port mirroring session (without deleting the distributed switch)?

Thanks,

Adriana

Adding vGPU using pyVmomi

$
0
0

Hi Everyone

 

I have been trying to add a vGPU using pyVmomi. I found a way of doing it in powershell from a blog which is as follows:

 

Param ($VM, $vGPUProfile)

    $VM = Get-VM $VM

    $spec = New-Object VMware.Vim.VirtualMachineConfigSpec

    $spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)

    $spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec

    $spec.deviceChange[0].operation = 'add'

    $spec.deviceChange[0].device = New-Object VMware.Vim.VirtualPCIPassthrough

    $spec.deviceChange[0].device.deviceInfo = New-Object VMware.Vim.Description

    $spec.deviceChange[0].device.deviceInfo.summary = ''

    $spec.deviceChange[0].device.deviceInfo.label = 'New PCI device'

    $spec.deviceChange[0].device.backing = New-Object VMware.Vim.VirtualPCIPassthroughVmiopBackingInfo

    $spec.deviceChange[0].device.backing.vgpu = "$vGPUProfile"

    $vmobj = $VM | Get-View

    $reconfig = $vmobj.ReconfigVM_Task($spec)

    if ($reconfig) {

        $ChangedVM = Get-VM $VM

        $vGPUDevice = $ChangedVM.ExtensionData.Config.hardware.Device | Where { $_.backing.vgpu}

        $vGPUDevice | Select Key, ControllerKey, Unitnumber, @{Name="Device";Expression={$_.DeviceInfo.Label}}, @{Name="Summary";Expression={$_.DeviceInfo.Summary}}

 

However, I need a pyVmomi equivalent. The problem I am facing it is pyVmomi is not recognizing VirtualPCIPassthroughVmiopBackingInfo class.

 

Any ideas?

Viewing all 1860 articles
Browse latest View live


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