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

C# application using vSphere SDK 5.5 fails to retrieve VM's data from VMware ESXi 4

$
0
0

Hi,

I am using vSphere 5.5  SDK to retrieve hosts and vm's data from VMware ESXi 4. The application successfully fetches data for hosts but it fails with the below exception when I try to retrieve data for datastores or vm's

 

at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

   at Vim25Api.VimService.RetrieveServiceContent(ManagedObjectReference _this)

 

It fails (at highlighted red line) when I try to use below get properties method. Any help to resolve this would be greatly appreciated.

 

public static Object[] getProperties(ManagedObjectReference moRef, String[] properties) {

 

 

              // PropertySpec specifies what properties to retrieve and from type of Managed Object

              PropertySpec pSpec = new PropertySpec();

              pSpec.type = moRef.type;

              pSpec.pathSet = properties;

 

 

              // ObjectSpec specifies the starting object and any TraversalSpecs used to specify other objects for consideration

              ObjectSpec oSpec = new ObjectSpec();

              oSpec.obj = moRef;

 

 

             // PropertyFilterSpec is used to hold the ObjectSpec and PropertySpec for the call

              PropertyFilterSpec pfSpec = new PropertyFilterSpec();

              pfSpec.propSet = new PropertySpec[] { pSpec };

              pfSpec.objectSet = new ObjectSpec[] { oSpec };

 

 

             // retrieveProperties() return the properties selected from PropertyFilterSpec

              ManagedObjectReference _svcRef1 = new ManagedObjectReference();

              _svcRef1.type = "Service Instance";

              _svcRef1.Value = "Service Instance";

              ServiceContent sic1 = null;

              vim_svc.Timeout = 600000; //The value can be set to some higher value also.

             sic1  = vim_svc.RetrieveServiceContent(_svcRef1);

              ObjectContent[] ocs = new ObjectContent[20];

              ocs = vim_svc.RetrieveProperties(sic1.propertyCollector, new PropertyFilterSpec[] { pfSpec });

 

 

              // Return value, one object for each property specified

              Object[] ret = new Object[properties.Length];

 

              if (ocs != null) {

                  for (int i = 0; i < ocs.Length; i++) {

                      ObjectContent oc = ocs[i];

                      DynamicProperty[] dps = oc.propSet;

                      if (dps != null) {

                          for (int j = 0; j < dps.Length; ++j) {

                              DynamicProperty dp = dps[j];

                              //Find property path index

                              for (int p = 0; p < ret.Length; ++p) {

                                  if (properties[p].Equals(dp.name)) {

                                      ret[p] = dp.val;

                                  }

                              }

                          }

                     

                      }

          

                  }      

              }

              return ret;   

          }


Need Create Datastore .NET Code to specify the capacity of datastore

$
0
0

Hi,

 

We are using .NET Vimapi to commuicate to Vmware Server. How can set Datastore Capacity? Can we .NET sample code to specify datastore capacity.

 

Thanks,

Sainath

Add RDM device 0 error

$
0
0

Hi

i am using c# api to add rdm ,i was able to add new disk(just regular virtual disk) but  when it come to rdm 

i am getting Device 0 error

this is my code

 

            var diskSpec = new VirtualDeviceConfigSpec();

            var vmConfigInfo = (VirtualMachineConfigInfo)PropertyCollectorHandler.GetDynamicProperty(vmMor, "config");

            var diskfileBacking = new VirtualDiskRawDiskMappingVer1BackingInfo();

 

            var disk = new VirtualDisk();

 

            int tempInt;

            bool IsLunNum = int.TryParse(uniqueid, out tempInt);

             

            ManagedObjectReference computeResMOR = (ManagedObjectReference)PropertyCollectorHandler.GetDynamicProperty(GeneralMorContainer.GetHostMor(HostiP),"parent");

        

            ManagedObjectReference BrowserMOR =(ManagedObjectReference) PropertyCollectorHandler.GetDynamicProperty(computeResMOR, "environmentBrowser");

 

            VirtualMachineScsiDiskDeviceInfo[] arrDevices = PropertyCollectorHandler.GetScsiDeviceInfo(BrowserMOR, HostiP);

 

            foreach (VirtualMachineScsiDiskDeviceInfo virtualMachineScsiDiskDeviceInfo in arrDevices)

            {

                if (!IsLunNum && virtualMachineScsiDiskDeviceInfo.disk.canonicalName.ToLower().Contains(uniqueid.ToLower()))

                {

                    diskfileBacking.deviceName = virtualMachineScsiDiskDeviceInfo.disk.canonicalName; 

                    

                }

                else if (IsLunNum && virtualMachineScsiDiskDeviceInfo.lunNumber == Convert.ToInt32(uniqueid))

                {

                    diskfileBacking.deviceName = virtualMachineScsiDiskDeviceInfo.disk.canonicalName;

                }

               

            }

           if(diskfileBacking.deviceName==null)

           {

               Log.GetSingleLogInst().InternalLogLine(DateTime.Now,

                                                   string.Format(

                                                       "Unable to find device name for {0}", uniqueid),MsGtype.Warnning);

               return null;

           }

 

            int ckey = 0;

            int unitNumber = 0;

 

            VirtualDevice[] test = vmConfigInfo.hardware.device;

            for (int k = 0; k < test.Length; k++)

            {

                if (test[k].deviceInfo.label.Equals("SCSI controller "+scsi_id.ToString()))

                {

                    ckey = test[k].key;

                    break;

                }

            }

 

            if (ckey == 0)

            {

                Log.GetSingleLogInst().InternalLogLine(DateTime.Now,

                                                  string.Format(

                                                      "Unable to find CONTROL Key for {0} Lun.", uniqueid), MsGtype.Warnning);

                return null;

            }

 

            if (scsi_unit >= 7) //there is no slot 7 when ordering the disk device

                scsi_unit++;

            unitNumber =  scsi_unit;

           

 

 

            diskfileBacking.fileName = datastorePath + RDMfileName + ".vmdk";

 

            diskfileBacking.diskMode = DiskMode.persistent.ToString(); // const will be changed by demand

            diskfileBacking.datastore = new ManagedObjectReference();

            diskfileBacking.diskMode = DiskMode.independent_persistent.ToString();

            diskfileBacking.compatibilityMode = "physicalMode";

            

 

            disk.unitNumber = unitNumber;

            disk.backing = diskfileBacking;

            

          //  int size = GB * sizeGB;

          //  disk.capacityInKB = size;

            disk.key = _keyOperation; //-1 + (-1 * scsi_unit);//unique key, for set seperate operations

            _keyOperation--;

            disk.controllerKeySpecified = true;

            disk.unitNumberSpecified = true;

            disk.controllerKey = ckey;

 

            diskSpec.operation = VirtualDeviceConfigSpecOperation.add;

            diskSpec.fileOperation = VirtualDeviceConfigSpecFileOperation.create;

            diskSpec.device = disk;

            diskSpec.fileOperationSpecified = true;

            diskSpec.operationSpecified = true;

 

 

            return diskSpec;

can u pls help me

thx

 
            var diskSpec = new VirtualDeviceConfigSpec();
            var vmConfigInfo = (VirtualMachineConfigInfo)PropertyCollectorHandler.GetDynamicProperty(vmMor, "config");
            var diskfileBacking = new VirtualDiskRawDiskMappingVer1BackingInfo();
 
            var disk = new VirtualDisk();
 
            int tempInt;
            bool IsLunNum = int.TryParse(uniqueid, out tempInt);
             
            ManagedObjectReference computeResMOR = (ManagedObjectReference)PropertyCollectorHandler.GetDynamicProperty(GeneralMorContainer.GetHostMor(HostiP),"parent");
        
            ManagedObjectReference BrowserMOR =(ManagedObjectReference) PropertyCollectorHandler.GetDynamicProperty(computeResMOR, "environmentBrowser");
 
            VirtualMachineScsiDiskDeviceInfo[] arrDevices = PropertyCollectorHandler.GetScsiDeviceInfo(BrowserMOR, HostiP);
 
            foreach (VirtualMachineScsiDiskDeviceInfo virtualMachineScsiDiskDeviceInfo in arrDevices)
            {
                if (!IsLunNum && virtualMachineScsiDiskDeviceInfo.disk.canonicalName.ToLower().Contains(uniqueid.ToLower()))
                {
                    diskfileBacking.deviceName = virtualMachineScsiDiskDeviceInfo.disk.canonicalName; 
                    
                }
                else if (IsLunNum && virtualMachineScsiDiskDeviceInfo.lunNumber == Convert.ToInt32(uniqueid))
                {
                    diskfileBacking.deviceName = virtualMachineScsiDiskDeviceInfo.disk.canonicalName;
                }
               
            }
           if(diskfileBacking.deviceName==null)
           {
               Log.GetSingleLogInst().InternalLogLine(DateTime.Now,
                                                   string.Format(
                                                       "Unable to find device name for {0}", uniqueid),MsGtype.Warnning);
               return null;
           }
 
            int ckey = 0;
            int unitNumber = 0;
 
            VirtualDevice[] test = vmConfigInfo.hardware.device;
            for (int k = 0; k < test.Length; k++)
            {
                if (test[k].deviceInfo.label.Equals("SCSI controller "+scsi_id.ToString()))
                {
                    ckey = test[k].key;
                    break;
                }
            }
 
            if (ckey == 0)
            {
                Log.GetSingleLogInst().InternalLogLine(DateTime.Now,
                                                  string.Format(
                                                      "Unable to find CONTROL Key for {0} Lun.", uniqueid), MsGtype.Warnning);
                return null;
            }
 
            if (scsi_unit >= 7) //there is no slot 7 when ordering the disk device
                scsi_unit++;
            unitNumber =  scsi_unit;
           
 
 
            diskfileBacking.fileName = datastorePath + RDMfileName + ".vmdk";
 
            diskfileBacking.diskMode = DiskMode.persistent.ToString(); // const will be changed by demand
            diskfileBacking.datastore = new ManagedObjectReference();
            diskfileBacking.diskMode = DiskMode.independent_persistent.ToString();
            diskfileBacking.compatibilityMode = "physicalMode";
            
 
            disk.unitNumber = unitNumber;
            disk.backing = diskfileBacking;
            
          //  int size = GB * sizeGB;
          //  disk.capacityInKB = size;
            disk.key = _keyOperation; //-1 + (-1 * scsi_unit);//unique key, for set seperate operations
            _keyOperation--;
            disk.controllerKeySpecified = true;
            disk.unitNumberSpecified = true;
            disk.controllerKey = ckey;
 
            diskSpec.operation = VirtualDeviceConfigSpecOperation.add;
            diskSpec.fileOperation = VirtualDeviceConfigSpecFileOperation.create;
            diskSpec.device = disk;
            diskSpec.fileOperationSpecified = true;
            diskSpec.operationSpecified = true;
 
 
            return diskSpec;

check if a host is in a HA cluster by pyvmomi

$
0
0

Hi,

 

I am trying to check if a host is in HA cluster.

I am using Version 5.5.0 Build 2414847

I found that: https://www.vmware.com/support/developer/converter-sdk/conv50_apireference/vim.host.ConnectInfo.html

and inside of it:

inDasCluster*xsd:boolean  If the host is already being managed by a vCenter Server, this property reports true if the host is also part of a vSphere HA enabled cluster. If this is the case, remove or disconnect the host from this cluster before adding it to another vCenter Server.

I am preforming the following steps:

info = host.QueryConnectionInfo()

info.inDasCluster return nothing - not True and not False

 

Am I missing something? Is there a different to check if a host is in HA cluster?

Maybe to get the cluster and ask the cluster but is there a way to get a cluster from a host?

 

Thanks

The problem of writing logs with the web client plugin under vsphere 6.0

$
0
0

I have developed a vSphere web client plugin under vSphere 6.0. In my plugin, I want to write logs using JAVA Logging to the directory c:\test\log\. At first, I ran my plugin on Windows Server 2008 R2, and this is a single server without domain (not in the Active Directory), It is succeed to write logs.

 

But when I ran my plugin on Windows Server 2012 R2 with domain (in the Active Directory), It is failed to write logs.


After checking the web client logs, I found the following errors:

[2015-11-06T17:52:20.451+09:00] [ERROR] P Connection(2)-172.16.8.231  System.err    java.io.IOException: Couldn't get lock for C:\test\log\command

[2015-11-06T17:52:20.452+09:00] [ERROR] P Connection(2)-172.16.8.231  System.err    at java.util.logging.FileHandler.openFiles(FileHandler.java:389)

[2015-11-06T17:52:20.452+09:00] [ERROR] P Connection(2)-172.16.8.231  System.err    at java.util.logging.FileHandler.<init>(FileHandler.java:363)

 

I suspected that maybe this is a problem about permission, So I check the properties of the successful log file on Windows Server 2008 R2:

log_file_property.jpg

As the picture shows, I think the account who wrote the log is NT Service\vspherewebclientsvc, which is the virtual logon account of vSphere Web Client Service. It is the new feature of vSphere 6.0 and I can not find the permission of this account. but since It is succeed to write the log files under the Windows Server 2008 R2, I think this account has the permission to write files to c:\test\log\.


I am so confused with this problem, the reason is related to windows server version? or the Active Directory?  Can anybody help me?

 

Thank you.

How to delete "Virtual Machines to Hosts" DRS rules using pyvmomi?

$
0
0

Hi,

I am using the following code to remove a DRS VmHostRule. The vm group and the host group used in the rule do not exist anymore when trying to delete the rule (they were deleted previously).

spec = vim.cluster.ConfigSpecEx()
spec.rulesSpec = []
rules = cluster.configurationEx.rule
if rules:    for rule in rules:        if rule.name == "my_rule":            rule_spec = vim.cluster.RuleSpec()            rule_spec.operation = "remove"            rule_spec.removeKey = rule.key            rule_info = vim.cluster.VmHostRuleInfo()            rule_info.enabled = rule.enabled            rule_info.name = rule.name            rule_info.key = rule.key            rule_info.mandatory = rule.mandatory            rule_info.vmGroupName = rule.vmGroupName            rule_info.affineHostGroupName = rule.affineHostGroupName            rule_info.userCreated = rule.userCreated            rule_spec.info = rule_info            spec.rulesSpec.append(rule_spec)
if spec.rulesSpec:    try:        task = cluster.ReconfigureComputeResource_Task(spec, True)        wait_for_reconfig_tasks(self.content, [task])    except Exception:        print("Failed to remove affinity rule")

Sometimes, the code doesn't work and the following result is received:

pyVmomi.VmomiSupport.vmodl.fault.InvalidArgument: (vmodl.fault.InvalidArgument) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = 'A specified parameter was not correct: ',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) [],
   invalidProperty = <unset>
}

The vCenter vpxd.log contains the following:

2015-11-09T13:47:00.415Z info vpxd[7F35A15DC700] [Originator@6876 sub=Default opID=206261f7] [VpxLRO] -- ERROR task-30451 -- domain-c822 -- vim.ComputeResource.reconfigureEx: vmodl.fault.InvalidArgument:
 Result:
 (vmodl.fault.InvalidArgument) {
    faultCause = (vmodl.MethodFault) null,
    invalidProperty = <unset>,
    msg = ""
 }
 Args:

 Arg spec:
 (vim.cluster.ConfigSpecEx) {
    vmSwapPlacement = <unset>,
    spbmEnabled = <unset>,
    defaultHardwareVersionKey = <unset>,
    dasConfig = (vim.cluster.DasConfigInfo) null,
    drsConfig = (vim.cluster.DrsConfigInfo) null,
    rulesSpec = (vim.cluster.RuleSpec) [
       (vim.cluster.RuleSpec) {
          operation = "remove",
          removeKey = 103,
          info = (vim.cluster.VmHostRuleInfo) {
             key = 103,
             status = <unset>,
             enabled = true,
             name = "my_rule",
             mandatory = true,
             userCreated = <unset>,
             inCompliance = <unset>,
             ruleUuid = <unset>,
             vmGroupName = "vm_group",
             affineHostGroupName = "host_group",
             antiAffineHostGroupName = <unset>
          }
       }
    ],
    dpmConfig = (vim.cluster.DpmConfigInfo) null,
    vsanConfig = (vim.vsan.cluster.ConfigInfo) null,
 }
 Arg modify:
 true

The code sometimes works, sometimes returns the above error. Anyone knows what is wrong?

Thanks,

Adriana

"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

c# exportvm lease never gets past initializing.

$
0
0

I am trying to export an ovf utilizing the powershell tools Vmware.Vim.dll and When I try to create a export job the job just stays in the initialize state and never changes to the ready state and the vmlease initializeprogress always stays at 0. does anyone have any ideas on what could be causing this issue. On a side note I am able to export via the vsphere client successfully.

 

***code***

 

VirtualMachine vm = (VirtualMachine)client.FindEntityView(typeof(VirtualMachine), null, filter, null);

          

            if (vm != null)

            {

                HttpNfcLease vmlease = new HttpNfcLease(client, vm.ExportVm());

 

                DateTime StartTime = new DateTime();

                TimeSpan TotalExecutionTime = new TimeSpan();

 

 

                StartTime = DateTime.Now;

                HttpNfcLeaseState state = new HttpNfcLeaseState();

 

 

 

                for (; ; )

                {

                    //used to keep the lease alive

                    vmlease.HttpNfcLeaseProgress(0);

                  

                    //Get lease state

                    state = vmlease.State;

 

 

                    if (state == HttpNfcLeaseState.ready)

                    {

                        Console.WriteLine("Lease is available continue processing export");

                        break;

                    }

                    else if (state == HttpNfcLeaseState.error)

                    {

                        Console.WriteLine("Failed Lease State error: " + vmlease.Error);

                        break;

                    }

                    else

                    {

                        TotalExecutionTime = DateTime.Now - StartTime;

                        Console.WriteLine("LInitialize progress: " + vmlease.InitializeProgress + " Elapsed Time: " + TotalExecutionTime.ToString());

                    }

                    Thread.Sleep(30000);

                }


VB.net CreateImportSpec VMDK File over 2GB.

$
0
0

Hi Everyone,

     When I call this function with an end goal of uploading a .VMDK file to an ESX host, I get an Arithmetic Overflow due to the amount of memory trying to be allocated by .NET frame over 2GB (My VM is approx 8GB) on line CreateImportSpec.

When taking a look at Java examples of this API it seems Java is able to commit to the allocation of the VMDK thus having it succeed. Does anyone know how to translate this over correctly in .NET?

Thanks!

 

[code]

Public Sub ImportToESX(pathToOVF As String, VMName As String, HostIP As String)

        '#Region "Check input"

        If String.IsNullOrEmpty(pathToOVF) Then

            Throw New ArgumentNullException()

        End If

        If String.IsNullOrEmpty(VMName) Then

            Throw New ArgumentNullException()

        End If

        If String.IsNullOrEmpty(HostIP) Then

            Throw New ArgumentNullException()

        End If

        If Not pathToOVF.ToUpper().EndsWith(".OVF") And Not pathToOVF.ToUpper().EndsWith(".VMDK") Then

            Throw New ArgumentException("pathToOVF must contain a .OVF/.VMDK file")

        End If

        '#End Region

 

 

        Dim importSpecParams As New OvfCreateImportSpecParams()

        importSpecParams.DiskProvisioning = OvfCreateImportSpecParamsDiskProvisioningType.thin.ToString()

        importSpecParams.EntityName = VMName

        importSpecParams.HostSystem = _hostSystem.MoRef

        importSpecParams.Locale = "US"

        importSpecParams.DeploymentOption = String.Empty

 

 

        Dim ovfDescriptor As String = read_ovf_content(pathToOVF)

        If String.IsNullOrEmpty(ovfDescriptor) Then

            Throw New ApplicationException("Error loading OVF descriptor")

        End If

 

 

        Dim resourcePool As ResourcePool = DirectCast(_vimClient.FindEntityView(GetType(ResourcePool), Nothing, Nothing, Nothing), ResourcePool)

 

 

        Dim ovfImportResult As OvfCreateImportSpecResult = _ovfManager.CreateImportSpec(ovfDescriptor, resourcePool.MoRef, _hostSystem.Datastore(0), importSpecParams)

 

 

        If ovfImportResult Is Nothing Then

            Throw New ApplicationException("Error creating import spec")

        ElseIf ovfImportResult.[Error] IsNot Nothing Then

            ' this fault means user has earlier version of ESXi

            ' than what OVF was created with.

            If TypeOf ovfImportResult.[Error](0).Fault Is OvfNoSupportedHardwareFamily Then

                Throw New ApplicationException("The ESXi server is not compatable with this OVF")

            End If

 

 

            Throw New ApplicationException(ovfImportResult.[Error](0).LocalizedMessage)

        End If[/code]

powercli 5.8 release 1 get-CI* set-CI*

$
0
0

I'm trying to use this set of commandlets

Get-CIAccessControlRule

Get-CIDatastore

Get-CINetworkAdapter

Get-CIRole

Get-CIUser

Get-CIVApp

Get-CIVAppNetwork

Get-CIVAppStartRule

Get-CIVAppTemplate

Get-CIView

Get-CIVM

Set-CIAccessControlRule

Set-CINetworkAdapter

Set-CIVApp

Set-CIVAppNetwork

Set-CIVAppStartRule

Set-CIVAppTemplate

 

I've downloaded and installed power cli 5.8 release 1

 

when I type "get-help" Get-CI*

nothing gets returned

 

The rest of the commandlets all work as advertised

I'm wondering what I need to do to get all of the Get-CI* commandlets to be available

 

Thank you for any assistance

 

PerformanceManager::queryPerf is returning null for resource pool performance metrics

$
0
0

I'm using PerformanceManager::queryPerf(PerfQuerySpec[]) to query perf.cpu.usagemhz.average and perf.mem.consumed.average for ResourcePool. The same program can get return value for lower version VCs, but get null for VC 6.0. In vSphere, using same account that is used for API call, I can get performance data for the ResourcePool I'm trying to query.

 

Did anyone else used that API for VC 6.0 target? Is it working fine?

 

Thanks!

vsphere Api c# - get infrastructure tree

$
0
0

Hello

Can anybody give me an example how to list all VMs, Clusters, ESX Hosts and Datastores using api in c#?

I want to get a tree like in esx vcenter client 

Need specific event that gets triggered when the host gets destroyed which hosts the vm and there is a HA or cluster case

$
0
0

hi,

       I need the exact event that gets triggered when host that has a VM attached gets destroyed but it has a HA host which becomes active .

Marianne

How to get virtual mac address of a physical nic?

$
0
0
I have a requirement to get virtual mac address of a physical nic using sdk.
This is used to identify the physical switch to which it is connected.
PhysicalNic.getMac() returns physical mac address of the nic, so it is not useful.
Is there any other API to get virtual mac?
Following is the output of esxcfg-info command:
--------------------------------------------------------------------------------------
\==+Physical Nic :
            |----Name...............................................vmnic3
            |----PCI Bus............................................15
            |----PCI Slot...........................................4
            |----PCI function.......................................1
            |----MAC Address........................................00:e0:ed:04:e8:4b
            |----Virtual MAC Address................................00:50:56:54:e8:4b
            |----Driver.............................................e1000
            |----Network Hint.......................................1 0.0.0.0/0.0.0.0
.
.
----------------------------------------------------------------------------------------
Thanks in Advance.

LicenseAssignmentManager.QueryAssignedLicenses replacement

$
0
0

Hi all,

 

I was wondering if someone could tell me how I should replace LicenseAssignmentManager.QueryAssignedLicenses calls in 6.0 version of the vSphere Web Services SDK, please?

 

VMware documentation simply says "As of vSphere API 6.0 use cis.license.management.SystemManagementService", implying that everybody knows what that means, so does anybody know?

 

Thanks a bunch in advance.

 

Dmitri Fedorov

BridgeWays

 

P.S. The quoted documentation: http://pubs.vmware.com/vsphere-60/topic/com.vmware.wssdk.apiref.doc/vim.LicenseAssignmentManager.html#queryAssignedLicenses


Retrieving SAS HBA Identifier using SDK

$
0
0

Hello,

I'm facing some issues in retrieving the SAS identifier (SAS Address) for a SAS HBA using API.

However I'm able to list the SAS Address using the esx cli command " esxcli storage san sas list".

Are there any API available for the same ? Thanks. 

can's run web service SDK samples

$
0
0

hello all,

 

I have download and compile the vsphere web service SDK and samples. but when I try to launch a simple test, it fails:

➜  vsphere-ws  ./run.sh com.vmware.general.Connect --basic-connection --url https://10.112.113.154:/sdk --username root --password password

-- VMware samples in Java --

 

    ERROR: com.vmware.connection.Connection

 

java.lang.InstantiationException: com.vmware.connection.Connection

    at java.lang.Class.newInstance(Class.java:427)

    at com.vmware.common.samples.parameters.Parameters.inject(Parameters.java:216)

    at com.vmware.common.samples.registry.SampleReference.run(SampleReference.java:87)

    at com.vmware.common.Main.run(Main.java:282)

    at com.vmware.common.Main.sampleSwitching(Main.java:254)

    at com.vmware.common.Main.registeredSample(Main.java:169)

    at com.vmware.common.Main.main(Main.java:121)

Caused by: java.lang.NoSuchMethodException: com.vmware.connection.Connection.<init>()

    at java.lang.Class.getConstructor0(Class.java:3082)

    at java.lang.Class.newInstance(Class.java:412)

    ... 6 more

 

Any clue?

 

thanks a lot!

Get connection closed error when trying to extract data from vCenter Server using C# application

$
0
0

I get the below error while extracting data from vCenter 5.5 Server using C# vSphere 5.5 SDK (The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.)

 

 

ERROR The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.

System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)

   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

   --- End of inner exception stack trace ---

   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

   at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)

   at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)

   at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)

   at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)

   at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size)

   at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)

   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)

   --- End of inner exception stack trace ---

   at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)

   at Microsoft.Web.Services3.WebServicesClientProtocol.GetResponse(WebRequest request, IAsyncResult result)

   at Microsoft.Web.Services3.WebServicesClientProtocol.GetWebResponse(WebRequest request)

   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

   at Vim25Api.VimService.RetrieveProperties(ManagedObjectReference _this, PropertyFilterSpec[] specSet)

   at vCenterTestConnect.vCenterESXHostInfo.getvCenterHostAdvancedInfo()

   at vCenterTestConnect.vCenterESXHostInfo.startExtraction()

 

Yje application works fine in test environment in our lab (with 2 hosts and 22 VM) but gives the above error when used in prod environment. Any help would be appreciated.

How to forcefully delete an entire folder ? vifs.pl does not support this feature

$
0
0

I'm trying to delete an entire directory and I was hoping to use RCLI vifs.pl command, but unfortunately even though there is a --force flag in conjunction with --rmdir, it does not allow you to delete a directory if it contain files. I also see that the vifs.pl command does not support listing of files without having to go to dsbrowser.pl (which I'm hoping I don't have to use).

 

What is the preferred method of removing an entire directory when passing a parameter of the following "\[datastore\] vm". I wanted to preserve as much of the original default commands within VMware VIMA as possibly without having to include a patch fix or side script

 

I was thinking of searching the specified directory and looking at the files and remoing it using vifs.pl ? Though I'm not getting any files being printed out and also how might I handle recursive deletes if the directory contains multiple directories with .vmdk under it?

my $eBrowser = Vim::get_view (mo_ref => $vm_view->environmentBrowser);
my $browser = Vim::get_view (mo_ref => $eBrowser->datastoreBrowser);
my $ds_path = "$TMP_DIR";
my $file_query = FileQueryFlags->new(fileSize => 0,fileType => 0,modification => 0);
my $searchSpec = HostDatastoreBrowserSearchSpec->new(details => $file_query,matchPattern => \["*.vmx", "*.vmdk"\]);
my $search_res = $browser->SearchDatastoreSubFolders(datastorePath => $ds_path,searchSpec => $searchSpec);

if ($search_res) {
        foreach my $result (@$search_res) {                my $files = $result->file;                        if ($files) {                                foreach my $file (@$files) {                                        #call vifs.pl to remove each file??                                        print $file,"\n";                                }                        }        }
}

 

 

 

 

 

 

 

 

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

--William

VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

Retrieve user information (name, email, ...) for a given login name / principal

$
0
0

I use a vCenter with LDAP connection and the vSphere management SDK 5.5.

I found UserSearchResult, but it just provides "fullname", "group" and "principal".

Is it possible to:

1. at least retrieve the user's email address (no matter from which source: LDAP or if vCenter has an internal storage that is also fine)?

2. or even better to retrieve arbitrary user information via LDAP?

Viewing all 1860 articles
Browse latest View live


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