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

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.


Can we get password of vCenter Server within vCenter Plugin?

$
0
0
I want to create a vCenter Plugin. In the plugin, I want to get password of vCenter Server and send it to another machine. I don't want user to input it manually. Can I get password of vCenter Server in the plugin?

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?

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


 

VIX error codes equivalent API in vsphere SDK

$
0
0

While trying to migrate from VIX to guest operations of vsphere API, I see that there is an equivalent API for running a program on guest, ie, VixVM_RunProgramInGuest ~ StartProgramInGuest. With this API we can fetch exit codes but is there a way to fetch error messages . Also is there an equivalent API for VIX_GetErrorText to fetch SDK error codes smilar to VIX.

 

Thanks in advance.

How to generate credential file from SAML token

$
0
0

I want to create a vCenter Plugin using SDK 6.0 , in the vCenter Plugin I want to generate credentials file of vCenter Server to send to another machine and from this machine, it login vCenter automatic, I don't want user to input it manually. Can we create a credentials file from user session or SAML token ?

Is vSphere 5.0 SDK compatible with vCenter 6.0?

$
0
0

Our portal application is using the vSphere 5.0 SDK. When our application went live, it was making web service calls to vCenter 5.0. At the beginning of the year, vCenter was upgraded to 5.5 update 3b, and there seemed to be only one issue with this upgrade (documented here: Get-Stat error while querying vCenter 5.5u3)

 

Now vCenter is going to be upgraded to 6.0.

 

Is vCenter 6.0 compatible with the vSphere 5.0 SDK? Are there going to be any issues like the one we encountered when going from 5.0 to 5.5?

vSphere SDK which is compatible with both vCenter 5.5 and 6.0

$
0
0

Dear all

I want to create a vCenter plugin, which supports both vCenter 5.5 and vCenter 6.0. Which version of vSphere SDK should I use for developping the plugin?


Unable to apply profile to a VM programmatically at the time of configure and clone of a VM.

$
0
0

We are encountering an issue while asigning policy to a VM using vSphere SDK.

Issue: at the time of un-registering a VM the VM loses its profile, while registering it again we wish to reapply the policy.

As per our understanding this can be done using re-configuring the VM. We tried to apply the policy to the VM at the time of reconfiguration using the property VirtualMachineDefinedProfileSpec.

https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.vm.DefinedProfileSpec.html#field_detail

 

Please find the code snippet for the same below:

 

l_VMConfSpec --> configuration specs for VM config specification.

ns2__VirtualMachineDefinedProfileSpec *pVDevProfileConfSpec2 = soap_new_ns2__VirtualMachineDefinedProfileSpec(m_vim.soap, -1);

pVDevProfileConfSpec2->profileData = soap_new_ns2__VirtualMachineProfileRawData(m_vim.soap, -1);

pVDevProfileConfSpec2->profileId = m_wsStoragePolicyId; //unique id of profile

l_VMConfSpec.vmProfile.push_back(pVDevProfileConfSpec2);

 

No error is returned from VMware at the time of reconfiguration.

 

 

Is this the correct way to assign profile to a VM?


tianhao64

Is it possible to use vSphere scheduled task to call my own script in vSphere web client

$
0
0


I have written a script which can be called using command line, and i want it can be called when triggering vSphere scheduled task.


The API to create scheduled task is "createScheduledTask" method of ScheduledTaskManager object, but i don't know which action i can use to call my own script, "MethodAction" seems impossible, how is the "RunScriptAction"? Can anyone help me?

 

thank you very very much.

how to authenticate for rest api with vCenter 6.5 appliance

$
0
0

Hello,

vCenter Appliance 6.5 has a feature to create a backup that can be restored with the installer gui. To create this backup one must access the appliance portal at port 5480. I would like to automate and schedule that backup. It can be accessed with the API's from the SDK. It must be possible to execute this via REST API. A bash sample is documented: 

https://pubs.vmware.com/vsphere-65/index.jsp#com.vmware.vsphere.vcsapg-rest.doc/GUID-222400F3-678E-4028-874F-1F83036D2E85.html

I have tried to authenticate to vCenter to invoke a rest operation from Orchestrator but I have not had any success.

I think that I can't use the right authentication mechanism, when I try to invoke the REST operation i get a 401 error. I have tried the basic authentication and I have looked at using the other mechanisms that are listed when adding a REST host in Orchestrator but can't figure out what to use.

If anyone has earlier connected with vCenter Appliance via REST and could share how to authenticate that information would be greatly appreciated.

Can I invoke a specific method instead of a "*_Task" like operation when create a task action

$
0
0

MethodAction action = new MethodAction();

action.setName("PowerOffVM_Task");

 

Can I invoke my own method instead of "PowerOffVM_Task"?

SOAP API Usage to Retrieve properties

$
0
0

Hello,

 

I need to implement an automation integration with vSphere using SOAP HTTP API call.

I am testing now each call I need using SoapUI interface, in order to implement later the call using an automation tool from where I can run HTTP methods.

At the moment I am able to run the login and to retrieve the responseHeaders, so that with the next call I can use the Cookie header.

It is working, I have also found in this forum an old post and I got from it the example.

 

What I need to do is to rescan, attach a new LUN as new datastore, format the disk and make it available.

At the moment I am able to check which disk are available, using the QueryAvailableDisksForVmfs call, but to do that I need the datastoreSystem name.

I am trying to use the RetrieveProperties call but from the documentation it is totally unclear, for me of course, which are the parameters to use in the several option.

 

I am trying in this way but it is not working

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">

   <soapenv:Header/>

   <soapenv:Body>

      <urn:RetrieveProperties>

        <urn:_this type="PropertyCollector">PropertyCollector</urn:_this>

        <urn:specSet>

            <urn:propSet>

               <urn:type>Datastore</urn:type>

            </urn:propSet>

            <!--1 or more repetitions:-->

            <urn:objectSet>

               <urn:obj type="HostSystem">172.24.0.10</urn:obj>

            </urn:objectSet>

         </urn:specSet>

      </urn:RetrieveProperties>

   </soapenv:Body>

</soapenv:Envelope>

 

Let me know where I can find a more clear documentation on the usage of the SOAP call from a SoapUI client.

 

Thanks for your help

 

Mirco

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?

FSS_LookupPath & FSS_Readdir on Nutanix array

$
0
0

Hi 

When trying to use FSS_LookupPath & FSS_Readdir on a Nutanix array I am getting an empty answer although  the VMDK is there when browse the folder 


InstantClone APi ??

Cleanup files using vSphere SDK?

$
0
0

Hi experts,

 

Is there a way that i can cleanup the files on vCenter/VCSA using the vSphere SDK ?

 

Most of the vSphere SDK APIs are to work with the VMs/ESX and not for the vCenter Server or VCSA ?

 

Thanks,

Balu

SDK for Adding SCSI controller

$
0
0

Hello,

I am trying to add a SCSI controller using MOB/SDK. The VM reconfigure is happening, but SCSI Controllers are not added. Following is the payload I am using.

<device-change>
<operation>add</operation>
<device type="VirtualBusLogicController">
<bus-number>0</bus-number>
<device>-1</device>
<shared-bus>noSharing</shared-bus>
</device>
</device-change>

Also, I would need to add specifc controllers(Like SCSI controller 1, 2 etc). Can someone help?

Example code for adding to Recent Tasks

$
0
0


I would like to track action progress using the Recent Tasks view.   I can't seem to find any sample code to help.   I saw some other threads that suggested looking at the WSSDK, but I didn't find anything there either.


I see there are objects such as TaskManager and TaskInfo, but I can't figure out how to createTask properly.  Also, it looks like I would need to register my custom task, and I don't know how to do that either.


Suggestions?


-E

c# Simple CreateVM like PowerCLI command

$
0
0

Hello,

Main-Problem:
I need to dev a Webpage to create VMs in our vSphere. For Info: In the enviroment we have multiple clusters with multiple hosts with many VMs.
We alrady have the following Powershell-script, but I need to use C# because I will create the new VM directly from the page.

 

POWERSHELL:

 

Add-PSSnapin VMware.VimAutomation.Core
$a = Connect-VIServer -Server $VM_Server -Protocol https -User $VM_Username -Password $VM_Password
# Create VM               
$newVM = new-vm `
-name $newVmName `
-ResourcePool $VM_RessourcePool `
-Datastore $VM_Datastore `
-DiskGB $VM_DiskGB `
-diskstorageformat EagerZeroedThick `
-MemoryGB $VM_MemoryGB `
-NumCpu $VM_NumCpu `
-CD `
-GuestID $VM_GuestID `
-NetworkName $VM_NetworkName `
-Location $VM_Location `
-Notes $VM_Notes
$mac $newVM_NetworkAdapter.MacAddress
# [...]
# Some Configurations like
# - NetworkAdatper = VMXNET3
# - Bootorder: 1. NetworkAdapter, 2. CDRom, 3. HDD
# - VideoRamSize
# [...]

 

Well, this is what i wrote, but it wont work. I have try to use only the parameters, that it will be used in the Powershell-Script.

 

C#:

using VMware.Vim;
namespace TEST
{
public classVmware
{
  public static void TestCreateVm()
  {
   var client = new VimClientImpl();
   client.Login(VM_Server, VM_Username, VM_Password);
  
   var folderFilter = new NameValueCollection {{"name", VM_Location}};
   var folder = (Folder)client.FindEntityView(typeof(Folder), null, folderFilter, null);
  
   var pool = new ManagedObjectReference(VM_RessourcePool);

   var config = new VirtualMachineConfigSpec();
   config.Name = newVmName;
   config.MemoryMB = VM_MemoryGB*1024;
   config.NumCPUs = VM_NumCpu;

   var disk = new VirtualDisk {CapacityInKB = VM_DiskGB*1024*1024};  
   var deviceSpec = new[] { new VirtualDeviceConfigSpec() };
   deviceSpec[0].Operation = VirtualDeviceConfigSpecOperation.add;
   deviceSpec[0].Device = disk;
   config.DeviceChange = deviceSpec;

   config.GuestId = VM_GuestID;

 

   folder.CreateVM(config, pool, null);

 

client.Logout();
}}}

 

 

 

The Exception-Message is that "a specific parameter was not correct: config.files".
I can not imagine that i have to specify the config.files parameter because I dont need to specify in the powershell command.
I think this exception is generated becaus I dont set the datastore-parameter - but i dont know how to set - therefor i have try to set the config.files-parameter:

[...]
var files = new VirtualMachineFileInfo();
files.VmPathName = $"[{VM_Datastore}] {newVmName}/{newVmName}.vmx";
//files.VmPathName = $"[{VM_Datastore}]"; --> this wont be work too
config.Files = files;
folder.CreateVM(config, pool, null);
[...]

This correction wont work too. The new exception is, that "The object has already been deleted or has not been completely created"
Normaly (in the script and in the vSphere Web Client) vSphere decides automatically the location of the files.


Is the solution of my problem to set the datastore-parameter? And when it is so - how can i specify this? Or I have to set the files-Property - but how?
Or I have to do it completely differently?

 

PS:

I have check the class VMCreate.cs of the Vmware-Samples2008. But this is much more complex then the simple script. There must be a simple solution or not?

Viewing all 1860 articles
Browse latest View live


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