Quantcast
Channel: VMware Communities : Discussion List - vSphere Management SDK
Viewing all 1375 articles
Browse latest View live

Device Performance Monitor- can we get DQLEN, QUED, %USD and LOAD from Vmware vSphere Web Service SDK

$
0
0

Can we get device DQLEN, QUED, %USD and LOAD from Vmware Web Service SDK, similar to what we have through esxtop?


Cannot find the declaration of element RetrieveServiceContent.

$
0
0

Has anyone seen this error?  It occurs on this line of code:

_sic = _service.RetrieveServiceContent(_svcRef);

VimException Timeout, Session no longer exist

$
0
0

Hi Everyone,

      I am writing VIMAPI via vb.net and after the application launches and calls to connect to my VCenter server via Client.Connect and SSPIHelper. Approximately 60 minutes of runtime and a call to a VIMAPI function a VIMException occurs for Unauthorized use. This is due to the current session time for the VIMAPI. Is there a function I can call to check to see if the current session is alive and well and call to reauthorize if needed?

[code]

   Try

                sc = Client.Connect("https://virtualcenter/sdk")

            Catch ex As Exception

                MsgBox(ex.Message)

                Return False

            End Try

 

            SessMgr = Client.GetView(Client.ServiceContent.SessionManager, Nothing)

 

            If Not LoginToVirtualCenter(Username, Password) Then

                Return False

            End If

 

Private Function LoginToVirtualCenter(Optional ByVal Username As String = Nothing, Optional ByVal Password As String = Nothing) As Boolean

        If Username Is Nothing And Password Is Nothing Then

            Dim SSPIClient As SspiClients = New SspiClients("", SspiPackageType.NTLM)

            Dim SSPI As New VMware.Vim.SSPIAuthentication

 

            Try

                Dim SH As New SspiHelper("host/MyServer.MyDomain.Com@MyDomain.Com")

                Dim MyToken As Byte()

                Dim MyServerToken As Byte()

                Dim ContinueProcessing As Boolean = True

                SH.InitializeClient(MyToken, MyServerToken, ContinueProcessing)

                UserSess = SessMgr.LoginBySSPI(Convert.ToBase64String(MyToken), "en")

            Catch ex As VimException

                Debug.WriteLine("Exception")

                Dim MySSPIChallange As SSPIChallenge = ex.MethodFault

                Try

                    SSPIClient.Initialize(Convert.FromBase64String(MySSPIChallange.Base64Token))

                    Try

                        UserSess = SessMgr.LoginBySSPI(Convert.ToBase64String(SSPIClient.Token), "en")

                        Return True

                    Catch exab As VimException

                        Debug.WriteLine("NTLM AUTH FAILED TRYING WITH CREDS") ' Not sure why this happens on other machines?

                        Return LoadVirtualCenter(GVSphereUsername, GVSpherePassword)

                    Catch exabc As Exception

                        Console.WriteLine(exabc.Message)

                        Debug.WriteLine("exabc")

                    End Try

                    Return False

                Catch e As Exception

                    MsgBox(e.Message)

                    Return False

                End Try

            End Try

        Else

            UserSess = Client.Login("MyDomain\" & Username, Password)

        End If

 

        Return True

    End Function

[/code]

   Try
                sc = Client.Connect("https://virtualcenter/sdk")
            Catch ex As Exception
                MsgBox(ex.Message)
                Return False
            End Try
 
            SessMgr = Client.GetView(Client.ServiceContent.SessionManager, Nothing)
 
            If Not LoginToVirtualCenter(Username, Password) Then
                Return False
            End If
 
Private Function LoginToVirtualCenter(Optional ByVal Username As String = Nothing, Optional ByVal Password As String = Nothing) As Boolean
        If Username Is Nothing And Password Is Nothing Then
            Dim SSPIClient As SspiClients = New SspiClients("", SspiPackageType.NTLM)
            Dim SSPI As New VMware.Vim.SSPIAuthentication
 
            Try
                Dim SH As New SspiHelper("host/MyServer.MyDomain.Com@MyDomain.Com")
                Dim MyToken As Byte()
                Dim MyServerToken As Byte()
                Dim ContinueProcessing As Boolean = True
                SH.InitializeClient(MyToken, MyServerToken, ContinueProcessing)
                UserSess = SessMgr.LoginBySSPI(Convert.ToBase64String(MyToken), "en")
            Catch ex As VimException
                Debug.WriteLine("Exception")
                Dim MySSPIChallange As SSPIChallenge = ex.MethodFault
                Try
                    SSPIClient.Initialize(Convert.FromBase64String(MySSPIChallange.Base64Token))
                    Try
                        UserSess = SessMgr.LoginBySSPI(Convert.ToBase64String(SSPIClient.Token), "en")
                        Return True
                    Catch exab As VimException
                        Debug.WriteLine("NTLM AUTH FAILED TRYING WITH CREDS") ' Not sure why this happens on other machines?
                        Return LoadVirtualCenter(GVSphereUsername, GVSpherePassword)
                    Catch exabc As Exception
                        Console.WriteLine(exabc.Message)
                        Debug.WriteLine("exabc")
                    End Try
                    Return False
                Catch e As Exception
                    MsgBox(e.Message)
                    Return False
                End Try
            End Try
        Else
            UserSess = Client.Login("MyDomain\" & Username, Password)
        End If
 
        Return True
    End Function

Thumbprint mismatch

$
0
0

The Plugin does not work when we use VMCA to generate the certificate. I have used the certificate manager utility to generate the certificates and followed the link vSphere 6.0 Documentation Center. I have used the the 4th option "install the root certificates and replace all the certificates".

The root cause analysis suggests the following:

The plugin stores a list of valid thumbprints of all the servers present in the Vcenter using the Vcenter Api com.vmware.vise.usersession.ServerInfo.thumbprint. The list of thumbprints are not getting updated even after updating the certificates of the server using VMCA. So when the plugin tries to connect to the VCenter server it returns the updated thumbprint but it is not found in the list of valid thumbprints. The plugin throws the exception that the thumbprint does not match.

Steps tried:

  1. Used the latest Vcenter 6.0 WebClient  vsphere-client-lib.jar to build the java project and deploy in Vcenter.

  2. Restarted all the vmware services using service-control --start --all

  3. Restarted the Vcenter Server.

  4. Cleared the browser cache.

  5. Unregistered and registered the plugin.

  6. Used the certool CLI  to manually create the certificates and vecs-cli to add it to VECS.

 

Clarifications required:

  1. Need to know if there are any post-installation steps which needs to be performed.

  2. The folder C:\ProgramData\VMware\vCenterServer\cfg\sso\keys still contains the old certificates. Is there a way to update them?

  3. Any apis available to refresh the serverInfo?

Create New Folder (CreateFolder method) Web Services SDK C#

$
0
0

 

Hi,

 

 

Have some problems in my code below. Somebody help me, I really am lost, dont know what to do.just a newbie..Here is the error. 

 

 

 

 

 

Thanks thanks

 

 

shim

 

 

__________________________________________

 

 

Stack Trace:

 

 

 

[SoapException]   System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +431678   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204   Vim25Api.VimService.CreateFolder(ManagedObjectReference _this, String name) +123   Nimbus.VirtualCenter.Folder.Create(String url, String usid, String pwd) in D:\projects\nimbus\sourcecode\v1\Nimbus\Nimbus.VirtualCenter\Folder.cs:40   Nimbus.UserPage.Elementpage.TreeView.btnCreateFolder_Click(Object sender, EventArgs e) in D:\projects\nimbus\sourcecode\v1\Nimbus\Nimbus\TreeView.aspx.cs:143   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

 

 

 

 

____________________________________________

 

 

public class Folder

{

static VimService _service;

protected ManagedObjectReference _svcRef;

protected ServiceContent _sic;

private UserSession _session;

 

public void Create(string url, string usid, string pwd)//, string dcName)

{

 

//String datacenterName = dcName; // name of DataCenter

System.Net.ServicePointManager.CertificatePolicy = new CertPolicy();

 

Vim25Api.ManagedObjectReference _svcRef = new ManagedObjectReference();

 

//Gets service contents

_svcRef.type = "ServiceInstance";

_svcRef.Value = "ServiceInstance";

 

_service = new VimService();

_service.Url = url;

_service.CookieContainer = new CookieContainer();

 

Console.WriteLine("Time before call: " + System.DateTime.Now.ToString());

_sic = service.RetrieveServiceContent(svcRef);

Console.WriteLine("Time after call: " + System.DateTime.Now.ToString());

 

 

 

_session = service.Login(sic.sessionManager, usid, pwd, null);

 

service.CreateFolder(svcRef, "sample");

 

 

 

 

 

 

}

}

 

 

getting esxi information from vm

$
0
0

Hi all.

i want to find the host information from vm's info.

right now i have the object id of a VM. i want to find the host's MORef  to do some processing.

i guess there will be some top->down approach will be there but it will be good to have some bottom->up approach where i can directly use vm's data to find host's info(MORef or ObjectID).

any lead in this regard will be helpful.

thanks in advance,

Nishchay

Extract VM Host - Guest relationship through C# Application using VMware vSphere Management SDK

$
0
0

Hi,

I am trying to build a C# application that can extract VM Host - Guest relationship from vCenter Server. I am using VMware vSphere Management SDK for this task. I am new to using API to extract data from vCenter Server. I would greatly appreciate if anyone could throw some inputs on the below questions,

 

1) I don't have access to API Url and credentials. I need to create an application that should accept API URL, Username and Password from user and a Test button should check if the credentials are valid and application is connected to Server. Which API methods should I use to implement this functionality ? I sthere any sample code that I can reuse to implement this feature.

 

2) Next task is to extract VM Host and guest relationship data from vCenter Server. The data needs to written in csv files on clicking the Run button from C# application. Which API methods should I use to extract this data ? Also, is there any sample C# code available to reuse to  extract required data ?

retrieve datacenter name in vsphere SDK 6.0

$
0
0

we were using 5.5 SDK and retrieving datacenter name .Now,with 6.0 SDK,the dc name code throws null pointer exception.Please suggest

 

 

serverConnection sc = si.getServerConnection();
         
         String dcName = null;
         _logger.info(" Server connection url :  " + sc.getUrl());
         Object dvsObject = MorUtil.createExactManagedEntity(sc, dvsMor);
        
        
        if(dvsObject != null && dvsObject instanceof DistributedVirtualSwitch){
            DistributedVirtualSwitch dvsObj = (DistributedVirtualSwitch)dvsObject;
            
            ManagedEntity me = dvsObj.getParent();
                
            ManagedObjectReference networkMor = me.getMOR();

 

The above line throws null pointer.Please suggest an example to retrieve the dc name from dvs object.

Is there any change in amanged object entity hierarchy and folder hierarchy in 6.0?

Marianne


Code Sample to create a new vmdk?

$
0
0

Hi,

 

Can anyone please give me code sample to create a new vmdk to a vm?

 

Please note that I just want to create a vmdk. Dont want to attach it to any vms...

 

Regards,

Naresh

how to get the uuid of the virtual machine that got deleted from the VM Deleted event

$
0
0

Hi,

 

I have a requirement of getting the removed vm instance uuid when I get com.vmware.vim25.VmRemovedEvent. I tried as follows:

 

case "com.vmware.vim25.VmRemovedEvent":

       VmRemovedEvent vmDelEvent = (VmRemovedEvent) event;

       VirtualMachine vm = (VirtualMachine) MorUtil

                      .createExactManagedEntity(si.getServerConnection(), vmDelEvent.getVm().vm);

       VirtualMachineConfigInfo vmConfigInfo = vm.getConfig()

 

But getting the below exception when I am trying to retrieve configInfo. Is it becasue the vm already removed?

  exception in vmjava.rmi.RemoteException: VI SDK invoke exception:com.vmware.vim25.ManagedObjectNotFound

 

Please suggest me how to find the deleted vm config information.

Error while using build.bat to generate a test certificate and STSService stubs

$
0
0

I am trying to build a C# application using vSphere API that connect to vCenter server and gets a Host-VM relationship.  

To run shared by vmWare, I followed developer guide and set all environment variables. When I am running .\build.bat to generate a test certificate and STSService stubs, I get the below error, 

"Files was unexpected at this time"

I am using Visual Studio 12. I've also set VSINSTALLDIR ="C:\Program Files(x86)\Microsoft Visual Studio 11.0\SDK"

I noticed that bin folder under C:\Program Files(x86)\Microsoft Visual Studio 11.0\SDK is empty. Do I need to make any changes in this path ?

Any inputs to resolve this error would be greatly appreciated. 

Using the 5.5 SDK to perform power operation on VM

$
0
0

Hi all

I'm very new to c# so please excuse my ignorance but I'm trying to create a simple web application written in asp.net and c# in visual studio 2013 that will allow me to perform simple power on and power off operations on a VM.

Using the guide at http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.wssdk.dsg.doc/sdk_c_sharp_development.5.3.html I have downloaded the Web Service 5.5 SDK and performed the setup guide to configure the environmental variables and build the Vim25Service.dll and Vim25Service.XmlSerializers.dll dll's. As stated in the guide I can run the SimpleClient C# application which has worked successfully.

My issue however is that I really have no idea what to do next....

I've created a new web application with an asp.net page containing an asp button. I've added the two .dll's as references to the solution and added using Vim25Api; to the page. I'm trying to follow other example on the net but not having much luck. I'm not sure if just add the dll's is enough or do I need to import the whole Samples2008.sln solution into my new solution? Once added, how do I use them?

I'm by no means an experienced programmer and so at this stage I'm not fussed about setting up custom classes (if that even makes sense). Could anyone provide an example of how I could do this in the C# code behind the button? Any help would be appreciated

Cheers
Brady

need support for VIJAVA .jar for vsphere 6.0

$
0
0

HI,

       We are migrating our plugin to vsphere 6.0 and we see that there is no vijava support for vsphere6.

We have to change all  our wrapper functions to use vim25 jar but its extremely cumbersome.

 

Please suggest a way to get latest vijava jar that supports vsphere 6.0

 

 

Thanks,

Marianne

HOW TO CONNECT VMWARE ESXI 5.5 ON MY VB.NET APPLICATION

$
0
0

Hi any one please help me, for how to conned esxi 5.5 machine on my vb.net application and list out what are the vm are running.

can someone point to the sample code where we retrieve the datacenter object by providing the datacenter name thru vsphere SDk

$
0
0

Please provide sample code to retrieve datacenter object when i have datacenter name using vsphere6.0 sdk.

 

We recently moved to vsphere 6.0 sdk


how to retrieve dvs name from DVS Destroyed event

$
0
0

ManagedObjectReference mordvs = dvsDestroyedEvent.getDvs().dvs;

String mor_type = mordvs.getType();

 

DistributedVirtualSwitch dvs = null;

 

dvs = (DistributedVirtualSwitch) MorUtil.createExactManagedEntity(si.getServerConnection(), mordvs);

String dvsName = dvs.getName();

 

dvs.getName() is throwing exception as

Caught Exception :  Name : java.lang.RuntimeException Message : com.vmware.vim25.ManagedObjectNotFound: VmwareDistributedVirtualSwitch:dvs-122 Trace : 

Using Perl to create a nested resource pool

$
0
0

I've used William Lam's "createResourcepool.pl" script as a guide and am trying to convert it to where it will create a child/nested resource pool.  The group I work for has a Resource Pool assigned to us (IHPS), and I'd like to be able to create child/nested Resource Pools under that to help group project team work.

 

Below is the code I've leveraged and modified:

 

#!/usr/bin/perl -w

# William Lam 11/28/09

# http://engineering.ucsb.edu/~duonglt/vmware

 

use strict;

use warnings;

use VMware::VILib;

use VMware::VIRuntime;

 

my %opts = (

    resourcepool  => {

        type => "=s",

        help => "Name of Resource Pool to create",

    required => 1,

        },

);

 

Opts::add_options(%opts);

Opts::parse();

Opts::validate();

Util::connect();

 

my ($folder, $resourcepool, $parent_pool_view, $parentresourcepool);

 

$resourcepool = Opts::get_option('resourcepool');

 

my $parent_pool = "IHPS";

 

$parent_pool_view = Vim::find_entity_view(view_type => 'ResourcePool', filter => { name => $parent_pool});

 

unless($parent_pool_view) {

        Util::disconnect();

        die "Unable to find parent Resource    Pool: \"$parent_pool\"\n";

}

 

$parentresourcepool = Vim::get_view(mo_ref => $parent_pool_view->resourcePool);

 

eval {

    my $sharesLevel = SharesLevel->new('normal');

    my $cpuShares = SharesInfo->new(shares => 0, level => $sharesLevel);

    my $memShares = SharesInfo->new(shares => 0, level => $sharesLevel);

    my $cpuAllocation = ResourceAllocationInfo->new(expandableReservation => 'true', limit => -1, reservation => 0, shares => $cpuShares);

    my $memoryAllocation = ResourceAllocationInfo->new(expandableReservation => 'true', limit => -1, reservation => 0, shares => $memShares);

    my $rp_spec = ResourceConfigSpec->new(cpuAllocation => $cpuAllocation, memoryAllocation => $memoryAllocation);

    my $newRP = $parentresourcepool->CreateResourcePool(name => $resourcepool, spec => $rp_spec);

 

    if($newRP->type eq 'ResourcePool') {

        print "Successfully created new ResourcePool: \"" . $resourcepool . "\"\n";

    } else {

        print "Error: Unable to create new ResourcePool: \"" . $resourcepool . "\"\n";

    }

};

if($@) { print "Error: " . $@ . "\n"; }

 

Util::disconnect();

 

 

When I run this from (from a Windows Server 2008 R2 system with the 5.1 Perl SDK installed), I get this error:

Can't call method "type" on unblessed reference at C:\Program Files (x86)/VMware/VMware vSphere CLI/Perl/lib/VMware/VICommon.pm line 1501.

 

I'm new enough to Perl that I'm not sure how to resolve this - any ideas/hints?

 

Thanks,
Mike

SPBM - To retrieve capabilities defined in VM storage policy ?

$
0
0

Is there a way to retrieve storage capabilities (thin deduplication, encryption, RAID, IOPS, etc) from the VM storage policy ?

With vVols, the VM is associated to storage policy. From the SPBM SDK, are there any calls to know the capabilities being used by VM (or defined in the storage profile) ?

Thanks.

excuse me , does any friend know why? in ws sdk 6.0, when Building the C# SSO DLL, two fuction (one of them is setPolicy)were not created .

$
0
0

excuse me , does any friend know why?

 

in web service sdk 6.0,

when  Building the C# SSO DLL, two fuctionwere not created .

 

when generating c# .cs file with wsdl file, two warning :

1 : this  Web reference does not  obey WS-I Basic Profile v1.1。

"Policy" is invalied

2,input msg "RequestSecurityTokenMsg" from  namespace http://www.rsa.com/names/2009/12/product/riat/wsdl"

has a net signature http://docs.oasis-open.org/ws-sx/ws-t

rust/200512:RequestSecurityToken”。


one or more extend element of wsdl  are ignored,


 

it was only warning , so sso.dll can be build,

but when build the sdk sample can't build , serveral lines  which calls the two fuction (for example : setPolicy ) failed , I commented them to finish the building .

but when running a simple client , sso failed

DeleteDiskPartition api is not there while UpdateDiskPartition is there

$
0
0

i want to delete a partition using DeleteDiskPartition api . but to my surprise it is not there at all. the same api is available in pysphere but not in vim25.

can anyone help me in this regard.

Viewing all 1375 articles
Browse latest View live