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

C# CloneVM_Task Network Not Connected

$
0
0

Ok, so I would like to be able to clone a vm and have it's network come up already connected, and I feel I'm missing something incredibly simple.

 

https://github.com/jeffpatton1971/mod-vmware/blob/master/VMware/functions.cs#L402

 

That is where my clone code starts up, at line 539 I create my virtual network card. I loop through the devices in the source vm (one i'm cloning from) until I get to the network card that is attached to it. Yes, I know there could be multiple, in our environment we clone from specific machines and they only ever have one nic. I assign that device to my newly created network card. I create my devicespec and set it to edit and assing my network card to the device (I've recently updated this code a little, I now instantiate a virtualvmxnet3 object instead of virtualdevice object). I continue on my merry way assigning a new ip address, connecting it up to the proper vlan on the proper switch.

 

At line 600 I create a new connectinfo object, and set the device to be connected at startup, guest controlled and connected.

 

the clone happens just fine, I browse over to the vm and the network interface shows as not connected.

 

How can I programmatically connect this device to the network?

 

Thanks for checking this out!


snmpSystem On vcenter

$
0
0

Hi

i am trying to reconfigure SNMP VIA vsphere api but the  ManagedObjectReference HostSnmpSystem  value is UNSET AND I AM HAVING NULL ERROR excpetion.

Vcenter 5.1 update 1

 

 

snmp.PNG
Thx

Java API for Network Status of VSAN Cluster

$
0
0

There is a field called Network Status for a VSAN Cluster.

The possible values which appear for this field seem to be "Normal" or "Misconfiguration detected" or "No hosts in this cluster"

 

I need to retrieve the value of Network Status for a VSAN cluster using a java api.

 

Can you please let me know which is the vsphere api I should be invoking to get this value?

Tracking guest os event?

$
0
0

Hello,

 

I hope you all are well. My question this time is about tracking installed guest os. In a particular, is there any way to track when the OS is "completely ready". I know that the "powen on" is the way for tracking vm but it does not contain any information if the guest os is already complete with the loading all the stuff. Every help will be appreciated deeply.

 

Regards,

Stefan

How to cast the (FileInfo) type to (VmDiskFileInfo) type objects? VI SDK Java

$
0
0

I am trying to get virtual disk size and type from datastore. After getting result, to get the size and type, I have to cast  (FileInfo) type to (VmDiskFileInfo) type objects but I got a casting error. It is VI SDK Java.

 

1) Do you know how to cast  (FileInfo) type to (VmDiskFileInfo)?

2) If it is not working, how to get vdisk size and type on a datastore. I need to get all vdisks including free vdisks which are not asssigned to any vms.

 

Thanks -- Sung

How to copy files in web client server to NFS Datastore

$
0
0

Hi, All

 

For some reason, I need to copy some files in web client server to NFS Datastore(PDFS file system), Is there any vSphere API or method can help me ?

 

Thank you

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

Setting vCenter Server Managed IP via Powershell

$
0
0

Does anyone know to set the vCenter Server Managed IP address using Powershell?

 

To set this manually with the vSphere client the option is under Administration | vCenter Server Settings | Runtime Settings | Managed IP Address

 

Thanks in advance


How can I determine the type of a Port Group via C# API

$
0
0

I need to determine the type (ex "Virtual Machine Port Group" vs "VMKernel Port" vs ... as shown in vSphere Client) via the published C# (Web Service facade) API.   It s obvious this type is available as the vSphere client can show it but I do not see a way to get it via the API or Managed Object Browser.

 

 

Perhaps this is the result of my inexperience with the API but I looked at it well and did Google searches and found nothing.   I would expect this value to be part of some Managed Object (MO; e.g, HostPortGroup) or some data object obtained through a MO.  I do not see any such value.

Getting Moref using VM Name

$
0
0

Is there is any fastest way to get the moref of a VM using its name?Instead of traversing each VM and comparing its name.

Can we specify propertyfilter in any manner to achieve this?

vSphere WS interface for Node.JS

$
0
0

Hey all,

 

I've begun to create a vSphere WS interface for Node.js that uses the node-soap and soap-cookie npm packages to connect to a vCenter or ESXi WSDL service instance.

 

I'd like some feedback on what I should try to create next... Right now I'm beginning to reimplement some basic functions such as VM power controls, querying VM status, and changing various VM settings.

 

reedog117/node-vsphere-soap · GitHub

 

I could definitely use some help building this thing, so if you'd like to help, definitely reach out to me!

InstantClone APi ??

Harvest all ESX + VM's at Scale?

$
0
0

Using the pyvmomi bindings to the vSphere SDK I need to harvest all of the ESX servers and VM's in a given vCenter. The vCenter environment will be approaching the 5.5 documented maximums (1000 ESX servers with 15,000 VM's spread across them). I currently don't have a way to build an environment at this scale and am trying to figure out the fastest way to pull all this data out of vCenter. Any idea what I can expect if I try to use a view and property collector to try to pull all the VM's out? Example:

vms = serviceInstance.get_vm_view()

sets = ['name', 'config.uuid', 'runtime.host', 'runtime.device', 'config.hardware.device', 'network', 'config.annotation', 'summary.config.vmPathName']

vmlist = serviceInstance.collect_properties(view_ref=vms, obj_type=pyVmomi.vim.VirtualMachine, path_set=sets)

 

The API documents talk about views/property collectors being the performant way to pull out a lot of data from the inventory, but states your performance may vary:

PropertyCollector Performance

 

Do I have a chance of using a view at this scale? Any ideas for how test at this scale without building a real environment?

 

Using the vCenter Simulator I think I'll be able to get an idea of how much memory I'll need to pull that much information out, but won't be able to get real timing numbers.

CredentialStore getPassword returns unreadable string.

$
0
0

Clarification on “CredentialStore” password management:

 

While retrieving the password stored in the credential store, using the “CredentialStoreAdmin tool”(using --showpw) i'm are getting unreadable/junk/encrypted(??) characters.

 

From the command **Usage**( CredentialStoreAdmin tool) below ; the --showpw option should return clear text.:

 

The CredentialStoreAdmin class is a command-line tool that provides complete access to the credential store backing file on the local machine.

      common        [required]:

      help: Display help for the commands for this tool

      add: Add a user account and password for a specified host to the credential store

      list: List all host names and user accounts contained in the credential store; use with:-

      --showpw: argument to display in cleartext

      -h: argument to list user name and password for the host

      remove: Remove the user account and password from the credential store for the specified account

      clear: Clear all content from the credential store

 

What is being done? The below use case illustrates the requirement.

Use Case:

  1.       Store the vCenter/ESX/ESXi server password locally using credential store.
  2.       Use the password stored in the credential store for automatic logon.
    1. Pass the password stored to open session with vCenter/ESX/ESXi server.

 

Also tried the same using **credstore_admin.pl** (from VMware vSphere SDK for Perl).

Here the password returned with “get” option is readable.

 

VMware WEB SDK Used(JAVA): VMware-vSphere-SDK-5.5.0-1284541

VMware PERL SDK Used VMware-vSphere-Perl-SDK-5.5.0-1384587

 

Let me know if this is the expected behavior if not how to get the password in human readable form.

HTML bridge and the Web Client SDK 5.5.1

$
0
0

Hello All,

 

I do hope you are well. I would like to ask you about any information of the new and the future implementation of the UI HTML plugins. I couldn't find any document or guide as well as example. I would be deeply grateful if you can help me with any video lesson, conference video, document and examples.

 

Regards,

Stephan


Please point me an example or api to programmatically delete distribute portgroups that are created on distributed switches

$
0
0


Please provide this answer to proceed further.For creation of portgroup,I use this:


 


 


DVPortgroupConfigSpec dvpgconfig = new DVPortgroupConfigSpec();


String pgName="_"dvs.getName()strPortGroupName;

 


dvpgconfig.setName(pgName);


dvpgconfig.setNumPorts(128);


dvpgconfig.setType("earlyBinding");


_logger.info("PG Name:"+pgName);


Task task = dvs.createDVPortgroup_Task(dvpgconfig); 

DVPortgroupConfigSpec dvpgconfig = new DVPortgroupConfigSpec();



String pgName="_"dvs.getName()strPortGroupName;

dvpgconfig.setName(pgName);



dvpgconfig.setNumPorts(128);



dvpgconfig.setType("earlyBinding");



_logger.info("PG Name:"+pgName);



Task task = dvs.createDVPortgroup_Task(dvpgconfig); 


How to move a VirtualMachine from one Folder to another?

$
0
0

Hi there,

 

I'm trying to move a Vmware.Vim.VirtualMachine from one Vmware.Vim.Folder to another with the API Provided by the C# Vmware.Vim.dll from the

PowerCLI in a VisualStudio 2010 Project. Please be aware that these Folders are not "normal" Folders, these are the VMware containers...

 

Could someone tell me how to achieve this?

 

I found the vm.Relocate_Task() Method, but I was wondering wether it was for moving the disks in storage or should it be used for this task too?

 

Greetings,

Kjellski

Get Virtual Machines into specific folder using c# or vb.net

$
0
0

Hi, If you want get VirtualMachine into specific folder how?

 

a lot of thanks

FindAllByDnsName ==> general system error occurred: Missing non-optional field

$
0
0

Hello


I'm trying to use the SearchIndex.FindAllByDnsName method to retrieve a list of vms registered on my host.
However, this methods always send me back a soap fault message : A general system error occurred: Missing non-optional field
Here is my code. i'm using Qt framework, and gSoap (2.8) for web services embedding. The previous calls to other methods (RetrieveServiceContent, Login) works fine.

 


VimBindingProxy l_vim;

 

    vim25__ManagedObjectReference ManagedObjectRef;

    vim25__RetrieveServiceContentRequestType RetrieveServiceContentReq;

    vim25_RetrieveServiceContentResponse RetrieveServiceContentRes;

    vim25__ServiceContent *ServiceContent;

 

    l_vim.soap_endpoint = "https://10.126.28.188/sdk";

 

    soap_ssl_init();

    soap_ssl_client_context(l_vim.soap,SOAP_SSL_NO_AUTHENTICATION,NULL,NULL,NULL,NULL,NULL)

 

    ManagedObjectRef.__item = "ServiceInstance";

    ManagedObjectRef.type = "ServiceInstance";

 

    RetrieveServiceContentReq._USCOREthis = &ManagedObjectRef;

 

    if ( l_vim.RetrieveServiceContent(&RetrieveServiceContentReq, RetrieveServiceContentRes) == SOAP_OK )

    { qDebug() << "RetrieveServiceContent - OK";

    }

 

    ServiceContent = RetrieveServiceContentRes.returnval;

 

    vim25__LoginRequestType LoginReq;

    vim25_LoginResponse LoginRep;

 

    LoginReq._USCOREthis = ServiceContent->sessionManager;

    LoginReq.userName = "root";

    LoginReq.password = "xxxxxx";

 

    if (l_vim.Login(&amp;LoginReq,LoginRep) == SOAP_OK)

    { qDebug() << "Login - OK";

    }

 

    vim25__FindAllByDnsNameRequestType FindAllByDnsNameReq;

    vim25_FindAllByDnsNameResponse FindAllByDnsNameRep;

    FindAllByDnsNameReq._USCOREthis = ServiceContent->searchIndex;

    FindAllByDnsNameReq.dnsName = "xxx"; //==> hostName of my vm

    FindAllByDnsNameReq.vmSearch = true;

 

    qDebug() << "FindAllByDnsName"<< l_vim.FindAllByDnsName(&FindAllByDnsNameReq,FindAllByDnsNameRep);

    qDebug() << l_vim.soap_fault_string();

 

When trying on the direct webservice interface using a soap tool (SoapUI), I get the same exact error.

 

Request :

 


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">
<soapenv:Header/>
<soapenv:Body>
<urn:FindAllByDnsName>
<urn:_this type="SearchIndex">ha-searchindex</urn:_this>
<urn:dnsName>xxx</urn:dnsName>
<urn:vmSearch>true</urn:vmSearch>
</urn:FindAllByDnsName>
</soapenv:Body>
</soapenv:Envelope>

 

 


Response :

 

 


<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>A general system error occurred: Missing non-optional field</faultstring>
        <detail>
            <SystemErrorFault xsi:type="SystemError" xmlns="urn:vim25">
              <reason>Missing non-optional field</reason>
            </SystemErrorFault>
        </detail>
      </soapenv:Fault>
  </soapenv:Body>
</soapenv:Envelope>

 


Any idea ?


thanks


MK

 

Ce message a été modifié par : mankonit

HowTo: Beginners Advice for using the vSphere APIs in C#

$
0
0

To be done: write about general structure and behavior of the API, e.g.: Folders(not "real" Folders, two points of view - ressource and organization)

Hi there,

in this thread I'll just let you know how I struggeled the API for the last two months and, hopefully, make sure you don't have to too. I've been able to accomplish at least the most of what I wanted but it took me days to find solutions to specific problems. While I had to struggle with incomplete documentation or missing answers to years old questions, I hope you can follow the path of "debugging" I tend to walk along nowadays. I used C# and the vSphere PowerCLI Toolkits VMware.Vim.dll, which enables you to use nice high level features as well as get specific things done.

 

First off, how to get started?

I chose the, in my opinion, simplest way to program against the API with the vSpherePowerCLI Toolkit. Once again, VMware, please provide more information about how to choose the API. And also mention that everything is nicely possible with this little VMware.Vim.dll with nice Wrapper types for all objects.

 

Good Part: You don't have to build anything, and you just start right ahead with VisualStudio 2010 and a single reference.

 

Just download the PowerCLI packagehttp://www.vmware.com/support/developer/PowerCLI/index.html and install it. Then just set the reference in your project to the VMware.Vim.dll in your freshly installed folder ( for me, that was: C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\VMware.Vim.dll) on Windows 7. And then you can start coding with "using VMware.Vim;" and there you go!

 

VimClient vmc = new VimClient();
vmc.Login(<credentials go here>);

 

Notes: You will always want to keep an instance of the VimClient arround in order to be able to operate on the ManagedObject on the vSphere Server.

 

CAUTION: Sometimes, it seems to be broken when you instantiate an object with the typical:

 

 

// Seems to use the constructor of the class itself and instantiates itself with
// the VimClient to get its data from vCenter...
T t = new T(<vimclient>, <managed object reference>);

 

If so, try using the:

 

// instead of null you could also provide properties, which I never needed.
T t = (T) vimclient.GetView(<managed object reference>, null); 

 

You will run into errors. Then it's time to debug!

Lets DEBUG!

 

I suggest you to do a step by step debug to ensure the source of the error is not misleading your thoughts. First off, go to the website of the ManagedObjectBrowser(MOB), which can be found by browsing to:

 

https://w.x.y.z/mob where w.x.y.z is the IP of your vSphere Server.

 

Then, click on ServiceContent and in the appearing window click Invoke! Now you can look at the vSphere Server from the API perspective. Browse to the Folder or whatever you struggle with. Then take a look at the ManagedObjectReference in order to double check that while you Debug, you see

the same ManagedObjectReference in your code. If you are not sure on how to retrieve this, I am always taking the "secure" way over the ViewBase:

 

// now place the type of object you want to see as T in the line beneath:
T t = (T) vmc.GetView(new ManagedObjectReference(<String from MOB seen reference>, null));

 

While debugging, set a breakpoint to the line above. Then you'll be able to how this worked out.

Also you'll get a feeling on how to use the API when you browse the vSphere Inventory in the MOB.

 

A word on ManagedObjects

If you try to find something you want to gather informations from or you want to modfiy an object, I suggest you follow more than one path.

My approach here is to use three different methods to find things. I have a sort of string concatenation class that does some path concatenation for finding objects by inventory paths. This is extremely useful because you don't rely on Managed Object references that you might not even know.

 

Here is how you can get going:

 

https:/1.1.1.1/mob/?moid=SearchIndex

 

And then you have the following options to reach for objects:

 

ManagedObjectReference:ManagedEntity[]    FindAllByDnsName
ManagedObjectReference:ManagedEntity[]    FindAllByIp
ManagedObjectReference:ManagedEntity[]    FindAllByUuid
ManagedObjectReference:VirtualMachine    FindByDatastorePath
ManagedObjectReference:ManagedEntity    FindByDnsName
ManagedObjectReference:ManagedEntity    FindByInventoryPath
ManagedObjectReference:ManagedEntity    FindByIp
ManagedObjectReference:ManagedEntity    FindByUuid
ManagedObjectReference:ManagedEntity    FindChild

 

It's super useful to check wether you have all paths in the right place and also to look up some of the entities that you don't want

to click through the whole inventory structure.

One example path you could throw in "FindByInventoryPath" for testing purposes:

 

/<Name of Datacenter>/host/<Name of ClusterComputeResource>/Resources

 

This will directly lead you to your Clusters resources MOR from a programs viewpoint.

 

Now the Programatical part; I've just build up a method for this:

 

 


/// <summary>
/// Returns a ManagedObjectReference from an inventory path
/// </summary>
/// <param name="vmc">The client to be used</param>
/// <param name="path">Path of the Entity to be found</param>
/// <returns>the MoRef found by path</returns>
public static ManagedObjectReference findManagedObjectReferenceByPath(VimClient vmc, String path)
{    // Inventory Searching Instance of SearchIndex    SearchIndex searcher = (SearchIndex)vmc.GetView(vmc.ServiceContent.SearchIndex, null); // new SearchIndex(vmc, vmc.ServiceContent.SearchIndex);    ManagedObjectReference result;    try    {        result = searcher.FindByInventoryPath(path);    }    catch (Exception e)    {        throw new MyNamespace.Exceptions.PathNotFoundException("While trying findManagedObjectReferenceByPath( " + path + "), an InnerException occured.", e);    }    if (result != null)    {        return result;    }    else    {        throw new MyNamespace.Exceptions.PathNotFoundException("Couldn't find anything by the path: " + path);    }
}

 

And btw. with this apprach, you can look at the GUI of vCenter ti guess the right paths...

 

Useful Documentation

What I made sticky on my browser while developing the application are the following pages:

 

 

I know I know, this is not complete, but please provide feedback with your first struggles in order to complete this thing.

Nevertheless, I hope this helps, at least a bit!

 

Greetings,

Kjellski

 

P.S.: I hope somebode will make this thread sticky and or suggest feedback for making it richer.

Viewing all 1860 articles
Browse latest View live


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