VMware {code} Community
rpo
Contributor
Contributor
Jump to solution

Is it possible to set VMsafe configuration options through the vSphere Web Service SDK?

Is it possible to set VMsafe configuration options through the vSphere web service SDK?

I noticed that the options in question are "OptionValue"s contained in the config.extraConfig property of the VM, so I've attempted to change them using the ReconfigVM_Task method of the SOAP API.

This fails however, even though the SOAP request seems to be valid:

<?xml version='1.0' ?>

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">

<env:Header />

<env:Body>

<n1:ReconfigVM_Task xmlns:n1="urn:vim25">

<n1:_this type="VirtualMachine">vm-448</n1:_this>

<n1:spec xsi:type="VirtualMachineConfigSpec">

<n1:extraConfig xsi:type="n1:OptionValue">

<n1:key>vmsafe.enable</n1:key>

<n1:value>FALSE</n1:value>

</n1:extraConfig>

</n1:spec>

</n1:ReconfigVM_Task>

</env:Body>

</env:Envelope>

This request generates the following fault:

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

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

<soapenv:Body>

<soapenv:Fault><faultcode>ServerFaultCode</faultcode><faultstring>Invalid argument : value</faultstring><detail><InvalidRequestFault xmlns="urn:vim25" xsi:type="InvalidRequest"/></detail></soapenv:Fault>

</soapenv:Body>

</soapenv:Envelope>

Any assistance in resolving this issue will be greatly appreciated.

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

glad it worked out! Don't forget to aware helpful or correct points Smiley Wink

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
5 Replies
lamw
Community Manager
Community Manager
Jump to solution

Yep, you can definitely add advanced parameter configuration to a given VM, so long as it's in a powered off mode, else you will not be able to update. You're also correct to use ReconfigureVM_Task() and specifying a new paired value/key to update.

I'm no WSDL/SOAP expert, but it's not liking your input, if you take a look at the API docs, you'll notice that extraConfig takes in an array of paired values, so long as that's correct and the VM is powered off, it 'should' work.

I've quickly put together a vSphere SDK for Perl script that does this:

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

rpo
Contributor
Contributor
Jump to solution

Thanks for the reply.

The VM is powered off, so that's not the problem. As for the SOAP, the fact that extraConfig is an array just means that there can be one or more instances if the extraConfig element in the SOAP payload, so I don' think that's the problem.

I did discover something interesting. The documentation states that if a key is provided without a value, the entry identified by that key is cleared. When I remove the value parameter from the request, the ReconfigureVM_Task() completes successfully, but the value remaines unchanged - both, in the vSphere inventory and in the .vmx file of the VM.

Now that I know that I should be able to change these values via the API, I must assume there is something wrong with the SOAP request I'm sending. The request is fairly simple however, and I just can't see the problem. I'll keep digging, but if anyone sees the problem, please let me know.

Thanks again.

rpo

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

Yep, it's definitely possible and it does sound like there might be something wrong with the SOAP request, unfortunately I'm not too familiar with WSDL/SOAP calls. Good luck

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

rpo
Contributor
Contributor
Jump to solution

I just wanted to let you know that the perl script you provided was instrumental in helping me determine the cause of this problem.

As we suspected, there was something wrong with the SOAP request. I ran your script with the --verbose option and it produced a wiredump listing of the SOAP transactions it was using.

In comparing its SOAP request to mine, I noticed that the "value" node was missing a type attribute: <value> instead of <value xsi:type="xsd:string">. I've updated the CLI binding accordingly, and now it works.

Thanks again for your help.

- rpo

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

glad it worked out! Don't forget to aware helpful or correct points Smiley Wink

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos