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

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.

excuse me , does any friend know why a error occurs when the sample VMCreate refers to vim25api , in ws sdk 5.0?

$
0
0

excuse me ,

 

does any friend know why  a error occurs when   the sample  VMCreate refers to vim25api , in ws sdk 5.0?

 

in sdk 5.0 ,the sample  VMCreate refer to vimapi  in defult,

SDK\vsphere-ws\wsdl\vim contains WSDL files for use with ESX Server 3.0.1 and VirtualCenter 2.0.

SDK\vsphere-ws\wsdl\vim25 contains WSDL files for use with ESXi 5.0, ESX/ESXi 4.1, ESX/ESXi 4.0,

vCenter Server 4.1/4.0, ESX 3.5, and VirtualCenter 2.5 systems.

 

to support higher version esxi or vcenter, we have to refer to vim25api,

I did this ,

but, when running vmcreate.exe,

a error happened, error msg: “System.Object[]” can not be casted to type “Vim25Api.ManagedObjectReference”。

 

the line in vmcreate.cs is:

         ManagedObjectReference[] hrmors

            = (ManagedObjectReference[])cb.getServiceUtil().GetDynamicProperty((ManagedObjectReference)crmors[i], "host");

I debugged it, crmors[i] is a reference of compute resource, it looks like a valid object, and should be casted well.

what's more it runs very well when we  refered to vimapi,

 

does any friend know why ?

Retrieving the list of independent virtual disks for a host (managed by a vCenter)

$
0
0

Is there a way to get the list of virtual disks (independent disks i.e. not associated with a virtual machine), when the ESX server is being managed by a vCenter.

Am using VIM API (C# language).

A way to get vDS ports for VMs of a certain Host

$
0
0

Hi,

I am trying to get a list of vDS ports that have VMs connected from a certain Host.

I tried using the vDS.FetchDVPortKeys(criteria) with the scope criteria but besides the fact that this criteria is deprecated in 6.0 it is not returning the desired results as only my uplink ports have the Host set as scope, the VM ports have the scope Unset

Is there a fast way to get the list of vDS ports for this VMs in a setup of 150 Host, 9000 VMs, all connected in 5 vDSs?

Thank you,

Alina

            criteria = vim.dvs.PortCriteria()
            criteria.connected = True
            criteria.uplinkPort = False
            criteria.active = True
            criteria.scope = host
            vm_ports = dvs.FetchDVPortKeys(criteria)

Is there a way to fetch Data Objects properties such as vDS port state in a similar way to the propertyCollector for the Managed Objects

$
0
0

Hi,

I am trying to retrieve vDS ports properties such as the state in the most efficient way, not fetching the entire object but just this property. I know about the propertyCollector that can be used on a Managed object and I am wondering if there is a way to do something similar for the Data Objects. 

I need a very efficient way to do this on a large setup:  vCenter with 150 Hosts, 9000 VMs, all connected in 5 VDSs.

Thank you,

Alina

Viewing all 1860 articles
Browse latest View live


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