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

Querying / configuring RAID-controlled drives using VIJava

$
0
0

I wonder if knowledgeable people can direct me to a write-up or a sample code which configures datasets on top of RAID controllers, and / or probes such datasets to enumerate the physical drives controlled by the RAID.  A related question: which  org.sblim packages should I download for them to be compatible with VIJava 5.5? (org.sblim.* packages are not included in the VIJava sample code which I've downloaded)

 

TIA


Error in SSOConnect method - 'Vim25Api.VimService' does not contain a definition for 'SetPolicy'

$
0
0

Downloaded the latest build VMware-vSphere-SDK-5.5.0-1284541.zip from here

 

Made sure vCenter server version is 5.5 and local vSphere Client 5.5 is connecting to host with no issues.

 

Followed the instructions to create the following using Visual Studio 2008 command prompt

a. STSService.cs and dll

b. Vim25Service and VimService

 

The samples does not compile with the following error in the SSO Connect method in SvcConnection.cs in AppUtil project.

Error message:

'Vim25Api.VimService' does not contain a definition for 'SetPolicy' and no extension method 'SetPolicy' accepting a first argument of type 'Vim25Api.VimService' could be found (are you missing a using directive or an assembly reference?)   

File C:\Temp\VMware-vSphere-SDK-5.5.0-1284541\SDK\vsphere-ws\dotnet\cs\samples\AppUtil\SvcConnection.cs   

Line 263    Column 22    Project AppUtil

 

Here is method that

     public void SSOConnect(XmlElement token, string url)

        {

            if (_service != null)

            {

                Disconnect();

            }

 

            _service = new VimService();

            _service.Url = url;

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

            _service.CookieContainer = new System.Net.CookieContainer();

          .

          .

          .

            //Setting up the security policy for the request

            Policy policySAML = new Policy();

            policySAML.Assertions.Add(customSecurityAssertion);

 

            // Setting policy of the service

           _service.SetPolicy(policySAML);

 

            _sic = _service.RetrieveServiceContent(_svcRef);

          .

          .

          .

     }


Appreciate any help in resolving this issue.

vSphere Plugin Service

$
0
0

Hi,

 

I have developed a vcenter Service plugin which calls the REST service running on some other server. I have developed a UI plugin in vsphere web client wherein the user will enter the login credentials that are required for basic authentiaction on REST calls. I want these credentials to be saved in VMWare database so that everytime a call is made, the credentials are picked up from the database and are inserted as authentication header in REST call.

 

My question is,

1. Is it possible to add an entry in database tables of VMWare

2. If yes, what tables store the user details. I dont want this user to be used in SSO service as this user won't be used to login to Web Client

3. What API should I refer to achieve this programatically using Java ?

Vcenter Licence

About "View" role

$
0
0



What does the "View" role used for?


id=-3, name=View, info=View:Visibility access (cannot be granted), privilege=[System.Anonymous, System.View]


from description, it can't be granted, but from one of my environment I use a account to retrieve properties of management objects, it can "see" all datacenter properties I want to get except "permission" and all "datastore" under the datacenter, when I check the role on this datacenter, the account I use have "View" role.


My questions are:


1. From the description the role can't be granted, why it appear on my datacenter object


2. What are the differents between System.View and System.Read(ReadOnly role have System.Read privilege and can be granted)

Cannot execute sampes for C# SDK 5.5

$
0
0

Hello Guys,

 

I'm trying to execute SimpleClient or RealTime program but I get bunch of exeptions. For example when I run SimpleClient with this command:

SimpleClient --url Https://192.168.xxx.xxx/sdk --username administrator@vsphere.local --password somepassword --disablesso

I get following  exceptions:

 

[ 2014-09-11 20:17:09 ] Begin Log.

Started

Caught Exception :  Name : WebException Message : Połączenie podstawowe zostało zakończone: Nie można ustanowić relacji

zaufania dla bezpiecznego kanału SSL/TLS. Trace :    w System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(We

bRequest request)

   w System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)

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

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

   w Vim25Api.VimService.RetrieveServiceContent(ManagedObjectReference _this)

   w AppUtil.SvcConnection.Connect(String url, String username, String password) w c:\WS\SDK\vsphere-ws\dotnet\cs\sample

s\AppUtil\SvcConnection.cs:wiersz 88

   w AppUtil.ServiceUtil.ClientConnectDeprecated() w c:\WS\SDK\vsphere-ws\dotnet\cs\samples\AppUtil\ServiceUtil.cs:wiers

z 95

Exception running : SimpleClient

Caught Exception :  Name : WebException Message : Połączenie podstawowe zostało zakończone: Nie można ustanowić relacji

zaufania dla bezpiecznego kanału SSL/TLS. Trace :    w AppUtil.ServiceUtil.ClientConnectDeprecated() w c:\WS\SDK\vsphere

-ws\dotnet\cs\samples\AppUtil\ServiceUtil.cs:wiersz 107

   w AppUtil.ServiceUtil.ClientConnect() w c:\WS\SDK\vsphere-ws\dotnet\cs\samples\AppUtil\ServiceUtil.cs:wiersz 37

   w AppUtil.AppUtil.connect() w c:\WS\SDK\vsphere-ws\dotnet\cs\samples\AppUtil\AppUtil.cs:wiersz 656

[ 2014-09-11 20:17:14 ] End Log.

 

Caught Exception :  Name : WebException Message : Połączenie podstawowe zostało zakończone: Nie można ustanowić relacji

zaufania dla bezpiecznego kanału SSL/TLS. Trace :    w AppUtil.AppUtil.connect() w c:\WS\SDK\vsphere-ws\dotnet\cs\sample

s\AppUtil\AppUtil.cs:wiersz 665

   w SimpleClient.SimpleClient.Main(String[] args) w c:\WS\SDK\vsphere-ws\dotnet\cs\samples\SimpleClient\SimpleClient.cs

:wiersz 209

 

I've also tried to login with ssourl but still no effect, however stack trace is different.

 

I've got Polish language pack for my visual studio. Please let me know if something is not clear and I have to translate something or provide more information

 

regards,

Xaosthetic

Help with XML Serialization

$
0
0

Guys I need help I have an ArrayList or Object full of managed-objects and I'm struggling to serialize it so I can layer the object into a XML document. I get an error:

 

{"The type VimApi.DynamicProperty was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."}

 

I suspect that its because the VimService.XMLSerializer is not being used in place of the standard .net XML.Serializer

 

Is there any examples of how to use VimService.XMLSerializer for a novice?

 

Thanks in advance.

XmlSerializers doesn't seem to be loading

$
0
0

I'm in a .net  project and have gone through the steps to generate the VimService dll and XmlSerializers but I still get errors like System.InvalidCastException: Unable to cast object of type 'System.Xml.XmlNode[]' to type 'VMWare.vSphere.CustomFieldDef[]' when trying to run api operations.

 

I'm using VS 2010 to compile the initial service with all the serializers uncommented in .net 3.5 framework (stupid requirement of product I'm using these dlls with), generating the XmlSerializers with sgen /p, removing all the references to [System.Xml.Serialization.XmlIncludeAttribute, adding System.Xml.Serialization.XmlSerializerAssemblyAttribute(AssemblyName = "VMWare.vSphere.XmlSerializers")] above the VimService class declaration and recompiling.  I add both dlls as References in my projects and even call Assembly.Load("VMWare.vSphere.XmlSerializers"); in my unit tests to ensure it really can find the dll.

 

Even after all that, I still get the casting issues.   If I add back the specific XmlIncludeAttributes, they cast fine.  I have also done this using all .net 4.0 tools compiling for .net 4.0 and I still get the same issue.  Is there any way to test the XmlSerializerAssemblyAttribute to see if it worked or see what attributes have been precompiled in that dll?

 

Thanks,
Dan


ExtendedFault message, variable substitution

$
0
0

I'm having trouble substituting strings in error messages that I've defined via ExtensionManager.

 

I define a couple of tasks and faults and added the localization resources. I read documentation indicating that I could do variable substitution in my localized strings (http://communities.vmware.com/# http://pubs.vmware.com/vsphere-55/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvmodl.LocalizableMessage.html).

 

For example, if my localized string is "The IP {ip} is already taken", then I could substitute {ip} with a "127.0.0.1".

 

I expected the vsphere GUI to show me the error message "The IP 127.0.0.1 is already taken" but I only get "The IP is already taken".

 

I explored the error object in the MOB and it appears fine. The key value pair ip/127.0.0.1 is definitely set. Am I using it wrong? I'm using vsphere 5.1.

 

------------------------------------------------

 

My extension defines the following localization resource (type=fault):

 

my_fault.summary = "The IP {ip} is already taken"

 

Data Object Type: ExtendedFault
Parent Managed Object ID: task-1098
Property Path: info.error

Properties

NAMETYPEVALUE
dataKeyValue[]
data["ip"]KeyValue
dynamicPropertyDynamicProperty[]Unset
dynamicTypestringUnset
faultCauseMethodFaultUnset
faultMessageLocalizableMessage[]Unset
faultTypeIdstring"my_fault"

 

Data Object Type: KeyValue
Parent Managed Object ID: task-1099
Property Path: info.error.data["ip"]

Properties

NAMETYPEVALUE
dynamicPropertyDynamicProperty[]Unset
dynamicTypestringUnset
keystring"ip"
valuestring"127.0.0.1"

ListProcessesInGuest & StartProgramInGuest

$
0
0

I am trying to retrieve a list of processes from a Windows guest and also start a program in the guest using C#. I used the Java sample code in "RunProgram.java" in the SDK samples as a guide.

 

The first problem was getting a reference to the GuestProcessManager. The vSphere API reference online says:

 

Managed ObjectProperty Of
GuestProcessManagerGuestOperationsManager
GuestOperationsManagerServiceContent

 

 

However when I access the MOB of my ESXi 4.1 host the ServiceInstance does not contain a GuestOperationsManager. Since I had access to the GuestOperationsManager via the VimService object I getting a MOR to the GuestOperationsManager, but soon realized that I can't really access the children properties of a MOR, I can only retrieve it's type and value and maybe pass it as a parameter in a method invocation.

 

The Java sample helped here as it had the following lines, which I picked up and used in my code as well:

 

ManagedObjectReference processManagerRef = new ManagedObjectReference();         processManagerRef.setType("GuestProcessManager");         processManagerRef.setValue("ha-guest-operations-process-manager");

 

So my first problem is this: If we need to get a MOR to an object which doesn't appear in MOB in the location specified by the API reference, how do we find it? I was lucky to have the sample using the same MOR but if this wasn't so then what?

 

So now my code to list processes in the guest looks like this (C#):

 

 

public void GetGuestProcesses()        {            //ManagedObjectReference guestOpsMgr = _host.ServiceContent.guestOperationsManager;                       ManagedObjectReference processMgr = new ManagedObjectReference();            processMgr.type = "GuestProcessManager";            processMgr.Value = "ha-guest-operations-process-manager";                       NamePasswordAuthentication auth = new NamePasswordAuthentication();            auth.username = "xyz";            auth.password = "abc";            auth.interactiveSession = true;            GuestProcessInfo[] processes;            long[] pids = new long[] { };            try            {                               processes = _host.VimService.ListProcessesInGuest(processMgr, _MOR, auth, pids);                Debug.WriteLine(processes.Length);            }            catch (System.Web.Services.Protocols.SoapException se)            {                Debug.WriteLine(se.Message);                Debug.WriteLine(se.Detail.FirstChild.LocalName);            }            catch (Exception ex)            {                Debug.WriteLine(ex);            }        }

 

The authentication for the guest was also something I picked up from the "RunProgram.java" sample. When I execute this code block my error message is:

A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll
type
InvalidRequestFault

 

For testing starting a program in the Windows guest my code is as follows:

 

 

public void StartInGuest()        {            ManagedObjectReference processMgr = new ManagedObjectReference();            processMgr.type = "GuestProcessManager";            processMgr.Value = "ha-guest-operations-process-manager";            NamePasswordAuthentication auth = new NamePasswordAuthentication();            auth.username = "xyz";            auth.password = "abc";            auth.interactiveSession = true;            GuestProgramSpec progSpec = new GuestProgramSpec();            progSpec.programPath = "C:\\WINDOWS\\NOTEPAD.EXE";            progSpec.arguments = "";                       try            {                long pid = _host.VimService.StartProgramInGuest(processMgr, _MOR, auth, progSpec);                           }            catch (System.Web.Services.Protocols.SoapException se)            {                Debug.WriteLine(se.Message);                Debug.WriteLine(se.Detail.FirstChild.LocalName);            }            catch (Exception ex)            {                Debug.WriteLine(ex);            }        }

 

My error is the same:

 

A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll
type
InvalidRequestFault

 

I did ensure that the capitalization of the program path string was identical as what the host uses. In both cases _MOR holds the MOR to the VM being targeted.

 

I looked up InvalidRequest in the API reference under Fault Types which states :

An InvalidRequest fault is thrown in response to a malformed   request to the server that fails in the transport layer, e.g.,   the SOAP XML request was invalid. Subtypes of this fault,    provides more specific transport errors, such as a using a    reference to an unknown managed object type or method.

So could this be happening because my MOR to the GuestProcessManager was incorrect? Or the authentication code is incorrect? Both were picked up from the Java sample and seemed to make sense to me. I even read up on NamedPasswordAuthentication and it said it could be used for any guest operations call.

 

What could be wrong?

Storage Profile Programming

$
0
0

Hi,

 

I've tried running the samples for policy based storage management provided with vSphere Management SDK but with no success. I've made sure URL's and credentials of vCenter Server are correct.

 

I get an error :com.vmware.spbm.connection.ConnectionException: failed to connect: Unsupported version URI "urn:pbm/1.0" everytime I try and run BasicConnectionTest.java provided with the pbm samples.

 

Can anyone guide me into what is going wrong?

 

Thanks,

 

Sayandip.

PHP nusoap - problems with WSDL and namespace

$
0
0

Hi all,

 

I've finally decided to make an account and ask for help.

 

First off, I am using php and nusoap to make calls to my vCenter to perform operations. I am working on automating clone vm via RecommendDatastores method. I had it working, but I came to a point where I had to specify the xsi:type as an object. When I set the xml type through soapval, soapval just sets the xml type as string. This got me thinking that my soapclient isn't receving the WSDL or not using the right namespace because soapval has no idea of the existence of the complex object types such as CustomizationIdentitySettings or CustomizationFixedIp.

 

Upon doing some digging, I noticed when I create my soapclient I need to pass the url to the WSDL AND set the second paramter (wsdl) to true, i.e., new soapclient(https://hostIP/sdk/vimService.wsdl", true). When I set the second parameter to true, it broke my whole class.

 

I get a soapclient error that says the type is invalid, e.g., "soapclient: got wsdl error: ServiceInstance (ServiceInstance) is not a supported type." or "soapclient: got wsdl error: SessionManager (SessionManager) is not a supported type.".


Here is my code:

 

[code]

 

$this->vsConnection = new soapclient(https://hostIP/sdk/vimService.wsdl", true)

$soapmsg['_this'] = new soapval('_this','ServiceInstance','ServiceInstance');

$result = $this->vsConnection->call('RetrieveServiceContent',$soapmsg,$this->namespace); //namespace = "urn:vim25"

 

[/code]

 

If instead I decide to change the parameters from ('_this','ServiceInstance','ServiceInstance') to ('_this', false,'ServiceInstance'), I get "soapclient: got wsdl error: phpType is struct, but value is not an array: see debug output for details".

 

Any help would be much appreciated.

is there an easy way to schedule when to power on my virtual machine

$
0
0

Hi,

I'm using vSphere 5.1 and ESXi 5.1 from what I gather. What's the easiest way to schedule power on/off a virtual machine? The goal here is to turn on once a week and get OS updates and then shut down again.

 

Please advise.

 

-Rod

How to import an ova image using VISDK

$
0
0

I understand that ova is an archive format of the ovf image. Basically it's a tarball of the files in the ovf image. Is there any API in VISDK to take an ova file directly from a remote server? An ova file can be really huge. Assuming the ova file is located on an FTP server. It'd become really inefficient if it requires download the huge ova file before import.

 

 

Thanks!

managementServerIP returns null for vCenter

$
0
0

Hello, I am trying to retrieve the FQDN of VC name (eg. vCenter.companyName.com) and I got managermentServerIp from HostListSummary class. Then I used InetAddress class from Java API to convert the managementServerIp of vCenter into FQDN. It was working fine and now all of a sudden I am getting null for managementServerIp String. I tried to retrieve other properties from HostListSummary class such as currentEVCModeKey, maxEVCModeKey and everything is returned as null. HostListSummary is not returned as null though. Is there a certain privilege that a user need to obtain before he/she can get the managermentServerIp and other properties from HostListSummary class?

 

Thank you

Sushant Dhakal


Why managementServerIp returns an empty value for a given host?

$
0
0

 

Hello,

 

 

I have 2 hosts on 2 different datacenters.

 

 

I have a function called getHosts and I fetchs the HostListSummary from the host.

 

 

For one host I can get its name, UUID and IP address through managementServerIp.

 

 

For the second host I can get everything except the IP address.

 

 

I wonder if there is any configuration on the physiscal host that is not enabling it.

 

 

Any thoughts?

 

 

Thanks.

 

 

Virtual Machine "Provisioned Space" and "Used Space"

$
0
0

I am trying to get the "Provisioned Space" and "Used Space" for a Virtual Machine, as reported by the vSphere Web Client in the following screenshot:

 

Screen Shot 2014-09-29 at 11.22.44 AM.png

 

I am using the VirtualMachineStorageSummary data object (vSphere Documentation Center)

 

I am collecting the committed and uncommitted properties, and then doing this:

 

spaceProvisioned = committed + uncommitted

spaceUsed = committed

 

However, I see differences in the numbers reported by the API vs the numbers vSphere web client shows.  Most of the virtual machines numbers reported by the API match the vSphere web client, but some are a few % off?

 

e.g. for the machine JK-IMPACT, I get spaceProvisioned = 44.11GB, spaceUsed = 38.83 from the API

but, in the vSphere UI (as shown below) it is: 44.11GB and 35.2GB !

 

Screen Shot 2014-09-29 at 11.36.33 AM.png

 

So the question is, am I pulling the wrong properties from the API, or is there something else I am missing in the way that the vSphere web client uses to calculate/display Provisioned and Used space.

 

Cheers,

Ian

'managementServerIp' property in MOB returns 'Unset' for ESXi hosts managed by vCenter

$
0
0

Both vCenter and ESXi servers are 5.5 and it shows 'Unset' for 'managementServerIp' property in MOB. I believe it's something in the configuration, but not sure what to check, please advise where I can see 'managementServerIp' property equivalent in vSphere Client so I can confirm this issue.


Could it be license related? vCenter has 'vCenter Server 5 Essentials' license, and ESXi servers are in evaluation mode.


Thanks,

Ymnick


Update: It does work when connection is established against ESXi server with ESXi server user 'root', but not when connection is via vCenter with domain user having administrator role assigned for vCenter and ESXi hosts it manages. I still need to make it work via vCenter.

 

Message was edited by: ymnick

Vim25Api.VimService' does not contain a definition for 'SetPolicy

$
0
0



Hello.


I'm trying to build samples from vsphere Management sdk but 'm stopped by this error.


I checked [https://communities.vmware.com/message/2419363 | https://communities.vmware.com/message/2419363] answer suggesting adding "/type:webClient" to the build.bat


but as I checked this file I found that it already is in bat:


:build_stubs 



echo Generating Stubs...



"%WSE_HOME%"\Tools\WseWsdl3.exe /out:%_STUBDIR% /type:webClient %_WSDLFILES%



echo Compiling Stubs...



csc /target:library /out:%_DLLDIR%\STSService.dll %_STUBDIR%\STSService.cs /reference:"%WSE_HOME%\Microsoft.Web.Services3.dll"



del %_STUBDIR%\STSService.cs


     the vim25api.ddl was build by my using this manual: https://vdc-repo.vmware.com/vmwb-repository/dcr/3d076a12-29a2-4d17-9269-cb8150b5a37f/8b5969e2-1a66-4425-af17-feff6d6f705d/doc/sdk_c_sharp_development.5.4.html


Can You show me what else should I change in code to make it work?


Does ESXi 5.5 support Web Services SDK, or does it need to be installed

$
0
0

I am trying to learn/use the Web Services SDK, but have quite a learning curve ahead of me.  I want to use this for ESXi configuration for developing automaton to test our adapters.

 

Anyway, while I have found a lot of documentation, none of it is answering a basic question (at least for me).  Where do I install the SDK?  It appears that I need it on the workstation that will run the automation tests.  However, does it also need to be installed on the ESXi5.5 host?  Are the web service APIs already on the ESXi host?   The documentation uses example like this

https://your_host_ip/sdk , but that does not exist.  Hence my question as to whether or not I need to install it on the host, or is it built-in to ESXi 5.5?.  If so then where is it?

 

 

For example, the manual states in Chapter 2:  (I am referring to this manual. vSphere Web Services SDK Programming Guide vSphere Web Services SDK 5.5)

"The vSphere API is a language‐neutral Web service that runs on ESX/ESXi and vCenter Server systems."

 

So, does 'Web service' above mean it is already installed on ESXi 5.5?  Or does it need to be installed before using the SDK to develop client applications?

 

Also, the quote above starts with "The vSphere API is a language‐neutral", yet then the documentation goes off and makes it sound like only Java or C# works with the SDK.  I plan on using Python, but my design, not pysphere, or other flavors.

 

So, in summary, do I need to install anything on either ESXi or a vCenter server in order to use the web-services SDK?

 

Thanks for any help.

Viewing all 1860 articles
Browse latest View live


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