As technology advances and we, as developers, have so many technologies to choose from when developing a system (SilverLight, Touch based interfaces, MVC, AJAX, SharePoint,etc), enterprises still face an application delivery problem, even with technologies like Citrix or VMWare, users have too many places to go to get their applications! It should be simpler!!
It is with that that I put together this article along with some downloadable content so that you can add the web part to your SharePoint environment and use the application provisioning tool for provisioning applications. This will be the first of a few articles talking about this solution.
We need a single place to get to all of our applications and in addition, a tool that will allow us to provision applications into our new utopia UI
.
So how do we get to a single place for all of our applications you say? Well, lets make a couple of assumptions. The first one is that a corporate portal will be used as the single interface in which all users will go to (They should be going to it already right?
), and since I’m a SharePoint guy, that will of course be SharePoint
. Second, this new utopia UI will house multiple application types.
What do I mean by multiple application types? In general we can categorize applications into about 4 different buckets.
1) Locally installed applications. These are applications that get pushed out to the users local computer via some distro mechanism, such as SMS or like product. These are traditionally launched from a users start menu or desktop
2) Citrix published applications. These are applications that a hosted on a citrix presentation farm (or now called xenapp).
3) Web based applications. These are typically launched by providing link to the app somewhere on a intranet or like system.
4) Virtualized Desktop (VDI type of systems). This is a new type of applications that is creeping into large organizations, we dont really touch on this too much in this article but it is still a valid application type.
So, now with the application categories out of the way
, lets talk about where the problem lies when it come to user trying to launch applications.
The main problem when having these different categories of applications is each one typically has a different type of launching mechanism. For example, local applications will be launched from the start menu, citrix applications can either be launched through PN Agent/Program Neighborhood or through WI, virtual machines are either launched from an RDP file or from VMWare Infrastructure Client, etc. To many choices, shouldn’t they all go to the same place for their applications, it shouldn’t matter the type of application right? So now the user has something like the following to launch their apps.
| Start Menu Delivered Applications | Web Based Application Delivery
(Citrix) |
Now, being a awesome architect for your company you already have a SharePoint rig installed in your organization.:) You have a good building block to start and address the single application interface issue.
To tackle the Citrix problem, you install Citrix WISP (Web Interface for SharePoint). This gets your Citrix applications in your SharePoint rig, but they are still isolated, especially if you would like to show different applications on different SharePoint pages, but again a good start.
To tackle the web based applications, lets say you add static HTML links on your SharePoint pages, maybe a page for all application links, or maybe you put relevant links on sub category pages, for example, HR application links on the HR department page, Training application on the Training department page, etc.
To tackle the local applications…. Well, there isn’t really a good solution to add these links to the site.
So even with the above modifications you can see that we still haven’t provided our users a seamless process to users launching their applications. They should be able to launch any application from the same place, no matter what the application type is right? If you want a local application go to the start menu, if its a Citrix or web application link go the internal portal/web site.
Enter the solution!
What if we could give the user user a simpler interface that we could stick on a main portal site someplace, that would give them access to all of their applications (Citrix,Local,Web,etc), and allow for some personalization of that system as well? Maybe a custom web part to help with the application delivery and launching. Something like the following.
So this, is pretty cool, the users can get to all of their application in a single place. Nice clean UI. As a user i don’t have to go to to any other place in the site for applications, they will always be in the same place.
Notice that there is no distinction of the type of application that the user see’s or launches. For example, lets take the following screen shot (lets neglect the image quality for the moment.)
From the above UI, you have no idea what the application type is when you click on it (which is a good thing). If i click on the HEAT link (which is a Citrix application), then the ICA client fires up and all is good. If i click on the Development IDE application under the (which is a locally installed application) then that application launches and again, all is good. My point here, is that why do we force the users to understand what type of application they are trying to launch, it shouldn’t matter, it should just work!.
So, from the utopia UI, I think we are getting there. We have a good single, simple UI, with folder categorization and application listing (regardless of the application type).
So, the next question is, how do we get applications into this new utopia UI. Well, why not have a separate provisioning application that is able to provision applications into the new utopia UI.
Enter the provisioning application.
We will need a way to get applications and folders into the front end UI So, a little background on this provisioning application. the purpose of this application is to provide a single application distributable to admins to allow them to publish/provision applications into the UI for consumption by the end users. There where the provisioning tool comes in.
Let me give a little background on this application. When designing it I wanted to initially be able to provision 3 types of applications, Local, Citrix and Web based applications along with ability to categorize those applications into folders. Along with this each application should have a permission set selector so as not to show all applications to every person. Lets break down the application a little with the following screen shots
As you can see, the screen consists of several panes. Below is a general description of each one of the panes from the above screenshot.
| Application Folder Pane: | Property Pane: |
| Provisioned Applications Pane: | Provisioning Actions Pane |
Now that we have described the basic layout of the application lets start to talk about how we provision applications into the new UI web part talked about above.
Remember we said that the provisioning application has the ability to provision 3 types of applications, Local, Citrix and Web.
Lets talk about provisioning a locally installed application into the UI. I think instead of typing all of the instructions out on how to publish a local applications, lets just check out a video.
Publishing Folder Overview: This video goes over how you would using the provision tool to publish a new folder into the application list web part and make it available to the user base.
Publishing Local Application Overview: This video goes over using the provisioning tool to publish a locally installed application into the application list web part.
Publishing Citrix Application Overview: This short video shows how we can use the provisioning tool to publish a citrix based application into our application listing web part.
So, with that I am going to call this Part 1 of this multi part blog post done. I will be posting an a few more articles focusing on the following areas
1) Launching the applications from the web part
2) Defining execution scripts for applications Both global scripts as well as application specific scripts.
3) Setting permissions on the provisioned applications.
4) Deep dive into the Citrix Web Interface SDK integration into the application list web part.
5) ICA override settings per Citrix Application.
5) Deep dive into the MFCOM integration to show how the communication to the Citrix farms/applications happens.
6) Provisioning Application configuration The provisioning application has a deep configuration model where you can define Citrix settings, permission providers etc.
Stay tuned for the upcoming videos and articles. Feel free to comment or contact me through twitter, facebook or my email at john@citrixstuff.com
PS. I am working on cleaning up the code so i can post the binaries up here so you can download and try on your sites.
IF you have ESX Servers somewhere in your environment you are probably going to want you ESX systems to send out SNMP traps of its state. Well, by default SNMP if turned off in the ESX install, so you will have to do some manual configuration to get it up and running.
No worries though, below I have listed to steps to get a simple SNMP service up and running on the ESX box.
The first step, is you want to log into you ESX device as root. I use putty but you can use your favorite tool here.
Next, you will need to modify the snmpd configuration file (which is located in the /etc/snmp directory. you can using the following command
vi /etc/snmp/snmpd.conf
Once you have the file opened in VI, you are going to have to add a line to it, something like
rocommunity yourpublichstring
Here, the “yourpublicstring” should be replaced with your organization’s public SNMP community string.
Finally save the file and exit out of vi.
Next, you will need to start the SNMP service on the ESX box. You can issue the following command to do this
/etc/init.d/snmpd restart
That should get you up and running with SNMP on your ESX device.
There might be a time in which you need to strongly name the VimServer.dll that gets created from the WSDL within the SDK. If you need help with that, check out a previous post here
I wont re-hash the previous article but will just focus on making the DLL strongly named.
The first step is to create a private/public key pair. You can do this by using the .NET SDK utility sn.exe. This will create a signing file for you, that you can now use for signing. Now, if you are going to use this is production, I would probably invest in a public cert, but for the purposes of this post, that’s not necessary
So lets get to creating a signing cert.
Open up a command prompt, navigate to the .NET SDK directory.
Execute the following command.
sn.exe /k c:\testcert.snk
Once you have created you signing key, you will need to add it to the VimService.cs file that was generated from the WSDL. The basic steps here are to recompile the cs into a library (dll) and add the signing key to that compilation step. That can be done with the following command
From here to create the strongly named dll we can execute the following command.
csc /t:library /keyfile:c:\testcert.snk
This will output a new dll with a strong name, that you can now use in your apps that need a strongly named assembly. As you can see from the screen all is good.
Hope this helps.
Tags: .NET, C#, VMWare SDK
“I finally was able to get the VseWSS 1.3 CTP that supports 64bit windows installed. Installation went pretty uneventful.
So I fire up VS 2008 and create a new WebPart project. All is going swimmingly so far.
Go to deploy the project KerPlunk!!! Get the “The communication object…..” error message. Shown below.
I seem to remember, some time ago that this message was related to WCF not being registered correctly. So after some research i came across running the following command
“ServiceModelReg.exe –r” from your .NET installed directory. Mine is on 64 bit so the location was in the following location.
“C:\Windows\Microsoft.NET\Framework64\v3.0\Windows Communication Foundation
After running you should see the following screen and you should now be able to deploy a solution from VS.
Hope this helps
Tags: 64 Bit, Visual Studio, VseWSS
If you are writing .NET code using the VMWare SDK, you already know that the ESX host its self has the set of web services installed on it that we use in order to interact with the VMWare system.
One thing you might not know, is that if you have Virtual Center installed in your environment, that device also has the ESX Web Services installed on it. Now, what is the difference? Well, in fact there are really no differences in the web services themselves, just what actions are available to each system using the web services.
For example, if you connect to Virtual Center WEb Services, you have he ability to create folders, where as, in the ESX host folders are not supported.
So, how do we know, what type of system we are connected to? Well, its actually pretty simple.
There are two ways we can accomplish this. The fist creating an instance of the ServiceContent. Once you have that, you can then check a property called “multiHostSupported”.
This property till tell you if the host you are connected to, supports multi hosts. And only Virtual Center support multi hosts.
The second approach is to get the AboutInfo collection of the service object, and check the property of “apiType”. If this returns VirtualCenter then you are in fact connected to a VC box.
Once you have this you can then perform logic to make different API calls based on the type of system your are connect to.
Here is some sample code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | this._vmService = new VimService(); vmService.Url = @"https://<yourserver>/sdk"; _vmService.CookieContainer = new System.Net.CookieContainer(); System.Net.ServicePointManager.CertificatePolicy = new TrustAllCerts(); ManagedObjectReference _object = new ManagedObjectReference(); _object.type = "ServiceInstance"; _object.Value = "ServiceInstance"; this._vmServiceContent = this._vmService.RetrieveServiceContent(_object); this._vmLoginSession = _vmService.Login(_vmServiceContent.sessionManager, "<username>", "<password>", null); AboutInfo _apiAboutInfo = this._vmServiceContent.about; if ( _apiAboutInfo.apiType.ToLower() == "virtualcenter" ) { Console.WritLine(“Connected to a VC API”); } |
Hope this helps.
Tags: C#, VMWare SDK, Webs Services
This post is going to be about using simple object collectors to get a list of virtual machines on a given host. Now, there are a couple of ways to do this, namely using traversal objects, but for this post, we are going to keep it simple. We will get to the TraversalSpec object in some later posts, so we will revamp this code at that time. For now, I am going to focus on creating simple collector objects so we can us them as building blocks.
Disclaimer: I know there are some flaws in the code below, mainly traversing multiple folders, etc. Please remember this is base code to help get an understanding of the VMWare SDK and its methods not a comprehensive programming example
So the first thing to understand about the ESX infrastructure is the hierarchy. Lets check out the picture below.
As you can see, the ESX Server structure is as follows
rootFolder (Everything is a child of this object)
—— Datacenter
———— Folder
——————— VirtualMachine
Given the following structure and the previous comment about making “simple” collectors, we will create three methods each returning a ManagedReferenceObject (this is a VMWare object that you can learn about more in the SDK).
The first method will return the Datacenter object, by passing into the method the main rootFolder.
The second method will return a vmFolder by passing into the method a Datacenter object.
The third method will return a array of virtual machines by passing into the method a vmFolder object.
We also have a helper method that will return some specific properties given a virtual machine object.
So, with that lets get started.
Here is the first method. This method returned the root datacenter object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | public ManagedObjectReference GetVMRootDataCenter( ManagedObjectReference RootFolder ) { ManagedObjectReference _returnObject = null; PropertySpec[] _ps = new PropertySpec[] { new PropertySpec() }; _ps[0].type = "Folder"; _ps[0].pathSet = new string[] { "childEntity" }; ObjectSpec[] _os = new ObjectSpec[] { new ObjectSpec() }; _os[0].obj = RootFolder; _os[0].skip = false; PropertyFilterSpec[] _pfs = new PropertyFilterSpec[] { new PropertyFilterSpec() }; _pfs[0].propSet = _ps; _pfs[0].objectSet = _os; ObjectContent[] _rootFoldersObjectContent = this._vmService.RetrieveProperties(this._vmServiceContent.propertyCollector, _pfs); foreach (ObjectContent _rootFolder in _rootFoldersObjectContent) { Array _objectsReturned = (Array)_rootFolder.propSet[0].val; _returnObject = (ManagedObjectReference)_objectsReturned.GetValue(0); } return _returnObject; } |
Here is the second method. This method returns a vmFolder given a Datacenter object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | public ManagedObjectReference GetVMFolder( ManagedObjectReference ParentObject ) { ManagedObjectReference _returnedObject = null; PropertySpec[] _dataCenterPropertySpec = new PropertySpec[] { new PropertySpec() }; _dataCenterPropertySpec[0].type = "Datacenter"; _dataCenterPropertySpec[0].pathSet = new string[] { "vmFolder" }; //Return the vmFolder objects ObjectSpec[] _dataCenterObjectSpec = new ObjectSpec[] { new ObjectSpec() }; _dataCenterObjectSpec[0].obj = ParentObject; _dataCenterObjectSpec[0].skip = false; PropertyFilterSpec[] _dataCenterToFolderPFS = new PropertyFilterSpec[] { new PropertyFilterSpec() }; _dataCenterToFolderPFS[0].propSet = _dataCenterPropertySpec; _dataCenterToFolderPFS[0].objectSet = _dataCenterObjectSpec; ObjectContent[] _vmFoldersObjectContent = this._vmService.RetrieveProperties(this._vmServiceContent.propertyCollector, _dataCenterToFolderPFS); foreach (ObjectContent _vmFolder in _vmFoldersObjectContent) { _returnedObject = (ManagedObjectReference)_vmFolder.propSet[0].val; } return _returnedObject; } |
Here is the third method. This method returns a array of virtual machines given a vmFolder object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | public ManagedObjectReference[] GetVMChildEntities(ManagedObjectReference ParentFolder) { ManagedObjectReference[] _a = null ; PropertySpec[] _dataCenterPropertySpec = new PropertySpec[] { new PropertySpec() }; _dataCenterPropertySpec[0].type = "Folder"; _dataCenterPropertySpec[0].pathSet = new string[] { "childEntity","name" }; //Return the vmFolder objects ObjectSpec[] _dataCenterObjectSpec = new ObjectSpec[] { new ObjectSpec() }; _dataCenterObjectSpec[0].obj = ParentFolder; _dataCenterObjectSpec[0].skip = false; PropertyFilterSpec[] _dataCenterToFolderPFS = new PropertyFilterSpec[] { new PropertyFilterSpec() }; _dataCenterToFolderPFS[0].propSet = _dataCenterPropertySpec; _dataCenterToFolderPFS[0].objectSet = _dataCenterObjectSpec; ObjectContent[] _vmFoldersObjectContent = this._vmService.RetrieveProperties(this._vmServiceContent.propertyCollector, _dataCenterToFolderPFS); foreach (ObjectContent _vmFolder in _vmFoldersObjectContent) { Array _childEntities = (Array)_vmFolder.propSet[0].val; _a = new ManagedObjectReference[_childEntities.Length]; for (int i = 0; i < _childEntities.Length; i++) { _a[i] = (ManagedObjectReference)_childEntities.GetValue(i); } } return _a; } |
So, from those method we will be able to traverse the folder structure and return a list of virtual machines configured on a given ESX Server.
The last method we need is a help method, that will return some properties on a given virtual machine. That is list below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | public System.Collections.Hashtable GetVMWareVirtualMachineProperties( ManagedObjectReference ObjectToRetrieve ) { PropertySpec[] _childEntitySpecs = new PropertySpec[] { new PropertySpec() }; _childEntitySpecs[0].type = "VirtualMachine"; _childEntitySpecs[0].pathSet = new string[] { "name","runtime.powerState" }; ObjectSpec[] _childEntityObjects = new ObjectSpec[] { new ObjectSpec() }; _childEntityObjects[0].obj = ObjectToRetrieve; _childEntityObjects[0].skip = false; PropertyFilterSpec[] _pfs = new PropertyFilterSpec[] { new PropertyFilterSpec() }; _pfs[0].objectSet = _childEntityObjects; _pfs[0].propSet = _childEntitySpecs; ObjectContent[] _childEntityProps = this._vmService.RetrieveProperties(this._vmServiceContent.propertyCollector, _pfs); System.Collections.Hashtable _allProps = new System.Collections.Hashtable(); foreach (DynamicProperty _prop in _childEntityProps[0].propSet) { _allProps.Add(_prop.name, _prop.val); } return _allProps; } |
So now we have all the required methods for traversing the folder structure. Lets put it together by logging into the ESX server and calling the methods we have defined about
Before going on, lets add the following as global vars in our project.
1 2 3 | private VimService _vmService = null; private ServiceContent _vmServiceContent = null; UserSession _vmLoginSession = null; |
And here is the login code. You can also view the article on logging into the web service by clicking here.
1 2 3 4 5 6 7 8 9 10 11 12 13 | this._vmService = new VimService(); _vmService.Url = @"https://<yourserver>/sdk"; _vmService.CookieContainer = new System.Net.CookieContainer(); System.Net.ServicePointManager.CertificatePolicy = new TrustAllCerts(); ManagedObjectReference _object = new ManagedObjectReference(); _object.type = "ServiceInstance"; _object.Value = "ServiceInstance"; this._vmServiceContent = this._vmService.RetrieveServiceContent(_object); this._vmLoginSession = _vmService.Login(_vmServiceContent.sessionManager, "<username>", "<password>", null); |
Once this is done, we can add the code to actually call our method and return the requested information
1 2 3 4 5 6 7 8 9 | ManagedObjectReference _rootDataCenter = this.GetVMRootDataCenter(this._vmServiceContent.rootFolder); ManagedObjectReference _vmFolder = this.GetVMFolder(_rootDataCenter); foreach (ManagedObjectReference _vm in this.GetVMChildEntities(_vmFolder)) { System.Collections.Hashtable _props = this.GetVMWareVirtualMachineProperties(_vm); Console.WriteLine("{0}:{1},_props["name"].ToString(), _props["runtime.powerState"].ToString()); } |
Ok, thats it, if you run the code you should see a list of your virtual machines along with the power status of each one of them.
Look for more howto’s soon. Hopes this help.
Tags: .NET, C#, Code, ESX, Web Service
Why doesn’t Apple allow developers easy access to their platform? Well, that is what this post will be about. As Apple releases more hardware it seems as though they are becoming more and more closed when it comes to opening up their API to developers, or at least giving developers some choice in how they develop their applications).
As a point of full disclosure, in my day job I am a software engineer/Systems Architect, mostly on the Windows Platform. I am not prejudice on any platform, in fact I have both Windows and Linux running, as well as deal with ESX, Citrix,Mobile,etc platforms. I don’t really care about the platform as long as I can get or write the application that the user needs.
Now, I am not saying here that you cant write any applications for the MAC, I absolutely know that you can (The iPhone is a different story, but more on that later). What my point here is that the initial cost of writing those applications is pretty substantial compared to other platforms, like BlackBerry/Windows Mobile/Android and that Apple needs to open up more and embrace the developer community, we are not all evil
.
For example, If I want to write a native application for the MAC, lets say in Objective C and test it. I will need the following.
1 Mac device (A decent MacBook or iMAC). Approximate cost 1200.00 –1300.00. Now I already have some Windows devices and some Linux devices, why cant i use one of those hardware devices?
Now, if I wanted to say, write that application in Java, I certainly could, but i would still have no way to integrate with the native API’s on the MAC platform and certainly no way to test it, since I would not have a MAC device. Once again I would have to go out and buy one.
As a developer, I already have multiple Linux and Windows devices, so why in fact would I need to purchase and additional hardware device in order to develop applications for the MAC?
Lets talk about the iPhone/iPod Touch. Awesome devices and the SDK does come with an emulator but that only runs on MAC, and in order to write an application for them, you will need to write the code in XCode, since the language for iPhone development is Objective C. Once again sounds like a MacBook or iMac will need to be purchased in order to do any dev for this device. Cha-Ching…
Lets compare that with three other mobile platforms, Windows Mobile, BlackBerry and Google’s Android. All three of these platforms offer SDK’s and IDE’s that run on the windows platform with BlackBerry and Android offering a Linux distribution of their SDK’s and IDE’s. So now as a developer I can write applications for the Windows Mobile platform, Android platform and BlackBerry platform all from the same device. No need to have a separate hardware device just for writing code for that specific device. And if I was a diehard Linux fan, i could use a virtualization technology like VirtualBox to standup a Linux VM and away I go. No such luck with Apple though, still need a physical device.
By the way, both Google Android and BlackBerry use the Eclipse IDE as their IDE for developing applications for their platform, where Microsoft use its Visual Studio product for developing applications for windows mobile. Eclipse is an open source IDE and Microsoft has free version of their VS product called Visual Studio Express.
Soapbox: One of the other issues I have seen specifically when it comes to Apple’s iPhone/Touch is the amount of control that Apple wants to impose on the applications that can get installed on your iPhone/Touch. This is eerily like the big brother syndrome and as a user/developer I don’t want a company deciding which applications are good for me. I purchased the device as well as the service, I should be able to decide what applications I want on my device. This is why other platforms, like is one of the reasons why android, blackberry and Windows Mobile are more developer friendly, because *you* can decide what applications are important to you. Look, I understand that Apple doesn’t want some rogue applications out there, but don’t we, as consumers, have the obligation to do the do diligence of researching an application before installing on our device? Why should Apple be the big brother?
A little more on Apple being more closed than it is open. One example of this is in the mobile space, all of the mobile platform vendors i have mentioned above offer access to all the hardware on the phone, things like the dialer, camera, accelerator, etc. Good for the developer. But the iPhone has certain restrictions when it comes to the dialer and other features, plus if you use any undocumented features, you know like the ones that apple can use, you are in violation of your agreement. Not very conducive to developing cutting edge applications, at least not for the Apple line of products.
So, In order to write any applications for the Apple line of products, developers will have to shell out at least 1200.00 bucks to just get started. Not chump change when it comes to this economy and certainly not very embracing of Apple (although I’m sure the stockholder like this mechanism
)
How can Apple help address this high price entry point for developers and embrace more people developing for their platform? Well, I say that Apple should offer a developers license of their OS platform (Citrix does this, as well as VMWare). Lets say for $79.00. But that is only half the battle. That still doesn’t address the hardware issue. I believe that Apple, in this developer’s license should allow their OS X to be able to be run from x86 based hardware, and really should be allowed to be run in a virtualized environment. This would open up a huge amount of developers to the MAC platform and I’m sure would produce so awesome applications that everyone would benefit from.
In addition to this, I also believe that Apple should offer some type of solution to let users install whatever application they want on their phone. There is a reason why so many people are jail breaking their phones.
Anyways, that’s my .02.
Please tell me what you think, you can comment from my blog of follow me on twitter. twitter.com/johnmcbride
While writing some VMWare SDK/Web Services howto posts as well as some production code in C# I recently ran into an issue where the vimService object was taking upwards for 3 minutes to instantiate.
I figured that I might have messed up on adding the web service reference, so I re-added the web service reference to the project by select “Add Web Reference”, then when it asked for the WSDL location put in our ESX server location. ie. /sdk/vimService?wsdl">/sdk/vimService?wsdl">https://<server>/sdk/vimService?wsdl. Everything should be be good with this right? Wrong… Just by doing this the vimService takes forever to load.
After some researching it turns out that this is somewhat of a known issue, and has to do with the XmlSerialization object in .NET 2.0 and above (Apparently this works fine with .NET 1.1, but that doesn’t really help me out to much
In order to use this web service successfully and have acceptable load times, you are going to have to create the proxy DLL manually, and do some modification of the class that gets gen’d from the wsdl.exe. Since I am putting together some howto posts using the VMWare SDK/Web Services I thought I would put together this post, to document the steps to create a workable proxy DLL that can be used in any .NET projects (c# or VB.net)
Here are a couple of video’s to show the response time. I didn’t edit the first video so there is a lot of dead air
Accessing the VIMService object (SLOW…..)
codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0″
WIDTH=”500″ HEIGHT=”500″ id=”slowVMService”>
Accessing the VIMService object with the modified proxy object. Pretty snappy….
codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0″
WIDTH=”400″ HEIGHT=”330″ id=”slowVMService”>
Step 1. Download and install the VMWare SDK from the following location http://www.vmware.com/download/sdk/. You want to get the SDK titled “VMware Infrastructure SDK Packages”
Step 2. We are going to want to generate a source file from the WSDL files that come included with the SDK. Remember from my earlier comment that you cannot add this as a web reference from Visual Studio or you will suffer from the slow load time). With that being said, we need to navigate to the location of the wsdl files. These should be located in c:\<SDKInstalledFolder>\sdk\wsdl\vim25 folder. NOTE: I am assuming here that you are using ESX 2.5 or above. If you are using a lower version be sure to use the wsdl files in the vim folder instead.
To generate the source file issue the following command
wsdl.exe vim.wsdl vimService.wsdl
By default this will create a VimService.cs file in the same directory.
Step 3. After we have generated the source file we need to compile that into a library so that the proxy can be used in visual studio. To compile the source file issue the following command.
csc.exe /t:library /out:VimService.dll VimService.cs
Step 4. Here is where is gets a little unusual. After we have created the DLL we are going to need to run a .NET utility called sgen on it.
SideBar: sgen.ee is a tool that comes with the .NET SDK. Running this tool on a specific assembly will create a XML serialization assembly for the the types in the given assembly. This helps improve load performance of said assembly.
To run sgen on the newly created dll, issue the following command.
sgen.exe /p VimService.dll
Note: This process make take a few minutes
Step 5. The next step in the process is to modify the actual source file that got created from the WSDL.exe command. Using you favorite text editor open up the vimService.cs file and comment out all lines that start with [System.Xml.Serialization.
You can do a search and replace and search for [System.Xml.Serialization.XmlIncludeAttribute
and replace with
//[System.Xml.Serialization.XmlIncludeAttribute
In the end, you should end up with something like this (Note there are about 3,162 occurrences)
Step 6. After commenting out the System.Xml.Serialization we are going to need to add an additional attribute on the VimService class in the source file. Open the vimService.cs in your favorite text editor, find the following line
public partial class VimService : System.Web.Services.Protocols.SoapHttpClientProtocol {
and right before it add this
[System.Xml.Serialization.XmlSerializerAssemblyAttribute(AssemblyName = "VimService.XmlSerializers")]
It should resemble the following![]()
This will make your source file ready for compilation again.
Step 7. The last step in this process is to recompile the source file once again and create a new library for use within Visual Studio.
Run the following command
csc.exe /t:library /out:VimService.dll VimService.cs
And you should a shiny new dll ready for use within your .NET projects and without the unbearable load times of the vimService object.
And with that, I’m OUT!
Tags: .NET, C#, VI SDK, VMWare, Web Services
So I am trying to put together some short tutorials about using VMWare ESX Web Service together with .NET. These tutorials are meant to be specific and pointed for a single item.
So, on with the first posting for the ESX web Service API.
Before you dig into the the code below, this code references a Web Service proxy object called VMWareWS. You can create this by adding a web reference to your visual studio project with the following url “http://<your esx server>/sdk/vimService?wsdl”, then naming it VMWareWS.
1 2 3 4 5 6 7 8 9 10 11 12 | VMWareWS.VimService _service = new VMWareTesting.VMWareWS.VimService(); _service.Url = @"https://your esx server/sdk"; System.Net.ServicePointManager.CertificatePolicy = new TrustAllCerts(); VMWareWS.ManagedObjectReference _object = new VMWareTesting.VMWareWS.ManagedObjectReference(); _object.type = "ServiceInstance"; _object.Value = "ServiceInstance"; VMWareWS.ServiceContent _serviceContent = _service.RetrieveServiceContent(_object); _service.Login(_serviceContent.sessionManager, "root", "yourpassword", null); |
Now, one thing i need to mention here is the following line
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCerts();
This line references a custom class that allows all certificates from the esx server to be trusted. If you omit this line you will receive a certificate exception. Below is the reference class that you will need to create in your project as well. You can call it whatever you want just change the line above to reference your class name.
1 2 3 4 5 6 7 | class TrustAllCerts : System.Net.ICertificatePolicy { public bool CheckValidationResult(System.Net.ServicePoint SP, System.Security.Cryptography.X509Certificates.X509Certificate X509Cert, System.Net.WebRequest WR, int Value) { return true; } } |
Tags: C#, ESX Server, VMWare, Web Service
I am prototyping some ESX integration and needed to add a reference to the ESX web service, but couldnt remember what the URL was.
So…. if you need to access the ESX from a Visual Studio project, You will need to add a Web Service Reference, and point the URL to the following link
https://<your host>/sdk/vimService?wsdl
That will give you aproxy object that you can now work with.
Watch for more ESX/.NET posts here shortly.
Tags: VMWare ESX, Web Service
