Wednesday, December 28, 2011

vCO - Auto Deploy Plug-in

I used the holidays to test around with the new vCenter Orchestrator Plug-in for VMware Auto Deploy. The main value is that there is no need to use Microsoft Powershell which isn´t really often available in pure linux environments :)

First you have to configure the vCenter Server Appliance to act as a TFTP or DHCP server if this one isn´t already in place. This page describes the DHCP/TFTP configuration:

http://jreypo.wordpress.com/tag/vsphere-auto-deploy/

Once the services are configured you have to download the ESXi depot file from our download area and place it on a webserver. After that you can download the Plug-in for the vCenter Orchestrator and install it with the vCenter Orchestrator configuration interface.




Now you can add the vCenter Server Appliance as a VMware Auto Deploy host:














After adding the host you need to add a depot too. Please note that you have to extract the ESXi depot .zip file downloaded in the beginning cause you have to point to the "index.xml" file in the package.












With the host and depot you can now create a deploy rule and activate it with the included workflows.













You can check the activation really fast by clicking the "Inventory" tab and taking a look into the Auto Deploy tree.













If everything looking as expected you can now check to start a host system (I tested it with some virtual machines) and see if it boots into an ESXi image.














This is just a small quick start, there are some more possibilities (answer files etc.) but it shows how to get your feet on the street. See you next year!

P.S.: The TFTP/DHCP service isn´t a supported scenario. Thanks William for the hint.


Tuesday, December 13, 2011

vCO - How to add a second SCSI controller


Sometimes you will miss some OOTB workflows in your vCenter Orchestrator library. The last time I searched for a workflow the customer task was:

"Add a second disk with a different controller type and and a new bus ID (1)."

Reading this the task sounds really simple, but when searching there is only an "Add disk" workflow in the library which always crashes if you set the bus ID to 1, cause there isn´t a second SCSI controller.
Also there is no workflow to add a second SCSI controller and there is no method in the vSphere Client. So I decide to check how the vSphere client handle this event and used Onyx (http://labs.vmware.com/flings/onyx) to look for the used specifications.

So I found out that there is only an "add disk" method in the vSphere Client which automatically adds a second SCSI controller. With this knowledge I build a workflow which adds a second SCSI controller and then a second hard disk on this SCSI controller.

First make a clone of the "createVirtualScsiControllerConfigSpec" action and change the lines:

controller.key = 1;
controller.busNumber = 1;

Now create a new workflow and add a "Scriptable Task" element and the "vim3WaitTaskEnd" action. My IN parameter are: the VM (VC:VirtualMachine), the diskSize (number), the datastore (VC:Datastore) and the thinProvisioned (boolean) switch. The attributes are: task, progress, pollRate.












In the "Scriptable Task" element I added the lines shown in the screenshot. As you can see I use my cloned action to create the second controller. Than just add the second disk and push all into the array and start the reconfigVM task.

Have fun!




Wednesday, November 30, 2011

vSphere 5 - VCSA and syslog with graylog2

As you may know the vCenter Server Appliance can act as a syslog server for the ESX host-systems. The appliance logs all messages into a log partition (/storage/log) what´s not a real feature if you or your customer uses a syslog server. My customer actually uses Graylog2 (http://graylog2.org/) which is a real cool tool.









In the base configuration you aren´t able to insert a remote syslog server, so you have to access the vCenter Server appliance with ssh. Here you go to the /etc/syslog-ng directory.

In this directory there is a config file called: syslog-ng.conf which you have to open with an editor (vim/less for example).

Now search the line:
#
# Enable this and adopt IP to send log messages to a log server.
#
#destination logserver { udp("10.10.10.10" port(514)); };
#log { source(src); destination(logserver); };

end enter your syslog host, port. Please don´t forget to remove the # before the line :) After these settings you can enhance the Global Options to send the fully qualified domain name:

options { long_hostnames(off); sync(0); perm(0640); stats(3600); use_fqdn(yes); };

After the changes restart the syslog deamon with /etc/init.d/syslog restart and check with tcpdump port 514 if the packages are send. 









Happy logging!

Thursday, November 24, 2011

vCO - wavemaker, your cloud webservice (part II)

Based on the first article I will show you how to interact with the workflows and give them parameters and receive results. As you might assume this is more complex than only a short "getAllWorkflows", but with wavemaker and some instructions it is much easier than develop web-clients in higher programming languages.

First thing we will need is the workflowId which was displayed in the first tab. To copy the ID from the workflow "getFreeDvPorts" you have to change the options of the dojoGrid.














So the "selectionMode" has to be "extended" which allows you to copy the ID of the workflow. Next thing you have to do is to change the IN parameter of the "getFreeDvPorts" workflow into "dvSwitchName" as String and "NumPorts" as Number. I also added an "CriticalGroups" as Array/String OUT parameter. So the inputs are the name of the dvSwitch and the minimum of free ports the port-groups must have. The output shows all critical port-groups without enough ports.














In wavemaker, under the tab "getInventory" you can now add 4 textfields:
  • username
  • password
  • dvSwitchName
  • FreePorts
and a button called "Submit". I also add a TokenID field to control if the workflow is started. Next button is called "Result" and the "dataGrid" is used to show the OUT results of the workflow. I entered the username and password fixed which makes it a bit easier. The page should look like this:




















First step is to select the submit button and select a new "Service" for the OnClick event. This service I named "executeWf" and select the reference "vCOlab" and the "executeWorkflow" operation. Now the Submit button is linked with the "executeWorkflow" operation. 




As you can see the "executeWorkflow" operation needs different input parameters. The first two: username and password are easy, cause you only have to bind them to the text fields created in the beginning. The third one is the workflow ID of the "getFreeDvPorts" workflow you can copy from the first "getAllWorkflows" tab (extended editor).

The fourth parameter is very special and William Lam (http://www.virtuallyghetto.com/) and I had some sleepless nights to get the right method. The input parameters "workflowInputs" are set as an expression not as Array/List or something. So you have to insert the following in the expression field:
















As you can see the value is linked to the text .dataValue from "dvSwitchName" and "FreeDvPorts". So the name and the ports are defined with the text fields. For the control field you have to link the dataValue of the TokenID field to the return value "id" of the executeWf operation.














This will show the TokenID also when pressing "Submit" and this indicates that the workflow is executed in vCenter Orchestrator.

The next step is to create a new Service for the "Result" button. This is the "getWorkflowTokenResult" operation which also needs some input parameters: username, password and workflowTokenId. The first and second is bind to the appropriate text field. The third one is linked to the TokenId dataValue:












At last you have to bind the dataGrid to the return value of the "getResult" operation. As you can the the empty dataGrid is changed to a name, type and value separation.

If everything is right the execution should look like:
















So, I hope this more complex scenario helps you to speed up your personal cloud portal with wavemaker and vCO.

Have fun!


Wednesday, November 23, 2011

mighty virtualization - layout change

I decided to change the layout to a more dynamic one (thanks blogspot). I think this one looks better and it´s better to read :)

UPDATE: Had to change it back cause the links where broken and displayed wrong :(

Friday, November 18, 2011

vCO - how to determine free dvSwitch ports

Last week one of my customers ask for a method to report the free ports of all dvSwitch port-groups. First step I try was to look in the API explorer for a "freePorts" parameter, but there wasn´t one. So I developed a litte workflow including some loops (Thanks to Christophe for the bookmarked vCOteam article: Creating workflow loops).

The loops are necessary because of the unknown count of port-groups on the dvSwitch. So the whole workflow looks like this:




















The IN parameters are: DVports(String or number) and DVswitch (VC:DistributedVirtualSwitch). The DVports define the minimum available ports for the port groups and the DVswitch is the Switch to test on.

The first element "getAllPortGroups" gets all port-groups and test if it is a uplink port-group which I don´t want to test. The result is an array filled with all port-groups.

var DVSgroups = new Array();
for(i in DVS.portgroup){
if(DVS.portgroup[i].config.name.match("Uplink")){
System.log("Port-group is uplink port-group.");
}
else{
DVSgroups.push(DVS.portgroup[i]);
}
}


The next element "LoopSetup" sets the number of port-groups for the looping (DVSnb = DVSgroups.length;) and the following decision tests if the DVSnb is greater than 0 which allows you to iterate over every port-group. If the decision is true the counter will be lowered in the next step (counter = counter-1;) and the actual port-group is set in the next task (DVportGroup = DVSgroups[DVSnb];).

Now we have one port-group to test on (screenshot, cause the code raises an error in blogspot):


















As you can see I decided to count the connectees (VM Nics) of the port-groups to ensure that double used ports are counted.

I hope this helps you to find some free ports :)

Wednesday, November 16, 2011

vCO - wavemaker, your cloud webservice (part I)

Many of you noticed that VMware acquired wavemaker (acquisition) in march this year. When searching for a WebView (included in vCenter Orchestrator) alternative I decided to take a look on wavemaker. I was really surprised how easy it was to start with a simple web portal as showcase for my customers. The biggest advantage in my opinion is the simple access to the SOAP based vCenter Orchestrator interface which allows you to build web portals an applications without any knowledge of a higher programming language.

With this series I want to show you three examples:

1. Get all Workflows
2. Get free DVS port-group ports
3. Clone a simple VM

After the installation of wavemaker on my MacBook Pro the Wavemaker GUI is shown in my browser (http://localhost:8094/wavemaker/). At first I have to open a new project and define the basic layout (you can customize the layout later):





















I normally use the "no_theme" option because of it´s slick design. Next step is to create a WebService reference under "Service" in the main menu. Please note that you have to install the wsdl4j.jar library first.













I named my reference "vCOreference" and insert several elements in the main layout box: 2 text boxes (name/caption username and password), one button (name/caption Submit) and a datagrid below those elements. I also named the tabs as the further functionality: getAllWorkflows, getInventory and cloneVM. Please note that you have to select "password" for the password textbox to ensure the hidden input.

















Now I select the "Submit" button an pick the "events" text on the right side of the navigation. Then I choose "New Service" for the "OnClick" event. This means that when the button is clicked the service variable is called.


After the selection is made wavemaker switches to the Services view and I choose the service I want to use with the new variable.

Remember the first use case I choose the "getAllWorkflows" method. After this selection I link the input variables (username/password) to the text boxes designed at the beginning of this article.



Now the variables are linked with the inputs of the SOAP call. As you might imagined I want the data grid to show the result of the "getAllWorkflows" method. This is also really simple: Just click on the data grid and click the bracket beside "data set" in the right navigation pane. In the displayed binding list just choose the first (list) parameter.

With this selection the data grid changes it´s layout into the return parameters (id, name, description) automatically. Now you can save the project and press "Run" on top of the page. After giving the credentials and pressing the "Submit" button all workflows are displayed in the data grid.

As you can see I used only 10-15 clicks to establish a SOAP connection and a small web portal. So my opinion is: "Wavemaker rocks!" This is really an alternative to the included WebViews and allows you to build web services and web portals from the scratch without any knowledge in programming languages!

Wednesday, August 17, 2011

vCO - VMware LabManager migration to vCloud Director (part 1)

Awaiting my new hardware for testing the vLM to vCD migration I decided to give you an theoretical overview how the migration is realized. First thing I had to learn was that a vCD registered host could not act as an vLM host because of a higher agent version on the host (version 5). Unfortunately I forgot to make a screenshot (will repeat that with the new lab).

With this knowledge there is only one option: vLM with vCenter Server 4 and vCD with vCenter Server 5, both registered in the vCenter Orchestrator.





















When migrating to vSphere 5 this could be a one-time scenario. Maybe there are two environments -> the "old" vSphere 4 with vCenter Server 4.x, ESX/ESXi 4.x and VMware LabManager 4.x.x and the "new" one with vCenter 5, ESX 5 and vCD 1.x.

The migration scenario I want to build up is divided into the following steps:

  1. Archiving the vLM VMs into the Library
  2. Export of the archived VMs to a "transfer" NFS datastore
  3. Creation of the "old" configuration as vApp in the vCD
  4. Import of the exported vLM VMs as new vCD VMs
Really simple, or what?

I think I will need several SOAP workflows for the vLM to export the VMs in a consistent state to the "transfer" datastore. Next thing is to create the configuration in the vCD and register the VMs as new vApps or VMs in the vCD. 

Please be patient, in the next 2 weeks I will test it and create a manual for the migration including the vCO packages.

In the meantime... have a look upon the new AMQP Plug-In!

Wednesday, August 10, 2011

vCO - what´s up with VcOptionValue?

Based on my article about the fixed VM boot order and the used VcOptionValue I investigate some time to figure out what else we can do with these parameters. The main statement in my opinion is: "It is the .vmx extension as API data object.".

As described in the API reference: OptionValue we know that there are two properties: key and value, as used in many other objects.

The things which aren´t described are the keys and the values :( The thing I know from the powershell scripts was the "bios.bootDeviceClasses" key in my last article: VM Boot order.

After some investigation I found several other keys and values described by Ulli Hankeln at:

http://sanbarrow.com/vmx/vmx-advanced.html

With the knowledge of these parameters it is really easy to automate your .vmx parameters. Especially the uuid parameters ("I copied this VM"), could make your life easier.

Here is one example to automate the KB196 change (repeated characters in VM console) which comes up very often in Linux-VMs:













Please find the .package file for download at google-docs:

  de.cjohannen.local.KB196.package

If you have use-cases, please let me know how you change the rules :)

Tuesday, July 26, 2011

vExpert 2011 - Christian Johannsen

Over the last two years I tried to become a so called VMware "vExpert". This award is really important to me cause it indicates what I have done for the community in the last years. As blog author, author of several white-paper and virtualization evangelist (virtual automation cult) this is a real honor.



So, thanks folks! :)

Wednesday, July 13, 2011

vCO - OUT-parameter serialization with JSON

Today I stumbled again delivering OUT-parameters with vCO. There is a main thing you have to know: vCO can´t serialize objects. So it isn´t easy to deliver key-paired values to external interfaces, cause if you use "Object" and "Any" as output you`ll get some errors.

Discussing this with some smart guys at the customer site they came up with a JSON description in the "Developers Guide" which is used for WebView. Typically I put all information in a nested Array/string to generate a machine readable output, but JSON could be an alternative.

I started searching with the API Explorer for "JSON" and I found one action:

  •  objectToJson (includes the "serialize" action)
what describes exactly what I want to do.

So here is a little example vm(VC:VirtualMachine) ist IN-Parameter, param(string) is OUT-parameter:

var Specs = new Object();

Specs["vmName"] = vm.name;
Specs["vmId"] = vm.id;
Specs["vmNumCpus"] = vm.summary.config.numCpu;
Specs["vmMemorySize"] = vm.summary.config.memorySizeMB; 
Specs["vmPowerState"] = vm.runtime.PowerState.value;
Specs["vmIpAddress"] = vm.guest.ipAddress;
Specs["vmMacAddress"] = NicObject.macAddress;
Specs["vmGuestHeartbeatStatus"] = vm.summary.quickStats.guestHeartbeatStatus.value;
Specs["vmGuestMemoryUsage"] = vm.summary.quickStats.guestMemoryUsage;
Specs["vmOverallCpuUsage"] = vm.summary.quickStats.overallCpuUsage;
Specs["vmUptime"] = vm.summary.quickStats.uptimeSeconds/3600;
for(i in vm.guest.disk){
if(vm.guest.disk.capacity != undefined){
System.log(vm.guest.disk.capacity);
Specs["vmDiskCapacity"] = vm.guest.disk.capacity;
}
else{
Specs["vmDiskCapacity"] = "undefined";
}
if(vm.guest.disk.freeSpace != undefined){
System.log(vm.guest.disk.freeSpace);
Specs["vmDiskFreeSpace"] = vm.guest.disk.freeSpace;
}
else{
Specs["vmDiskFreeSpace"] = "undefined";
}
}

param = System.getModule("com.vmware.web.webview").objectToJson(Specs) ;














The easiest way to validate the code is JSONlint (http://jsonlint.com). Please keep in mind that the JSON definition does not know "undefined" as type (http://en.wikipedia.org/wiki/JSON). So you need to catch it up and change it into a string or sort it out.

Hope this helps.

Friday, June 24, 2011

vCO - Automate vLM (VMware LabManager)

Today I wrote an article for the vCOteam blog: How to automate the VMware LabManager operations with the new SOAP plug-in!

http://www.vcoteam.info/learn-vco/how-to-automate-labmanager-with-vco.html

Please stay tuned, part two for vCD migration follows :)

Friday, June 17, 2011

vCO - who will live longer?

Today is the day for me: the most powerful plug-ins till dunes was aquired by VMware were released yesterday:

  • the SOAP/REST plug-in
  • the VUM plug-in
With these we are able to automate so much more of our own and 3rd party products. I think that nearly 80% of environments I have seen had applications with WSDL interfaces. Now we can implement them together with the cloud platform and automate daily jobs much better and faster.

Her you will find more information:

http://blogs.vmware.com/orchestrator/2011/06/vcenter-orchestrator-http-rest-and-soap-plug-ins-now-available.html

In the next days we will publish some "real world" examples :)

Have fun!

Friday, June 10, 2011

vCO - change the VM´s boot order

When automating the deployment of virtual machines there comes the time when you need to change the boot order of a virtual machine. 

First there is a bad news: the boot order is part of the virtual machine´s BIOS (.nvram) and there is no easy way to edit this file. The good news is: based on this community discussion and the powershell examples i start to test the VcOptionValue inside the vCO.

After a short period of build and test it works with this simple code:











The inputs are : vm (VC:VirtualMachine) = virtual machine and device(string) = cd, net or hd for the boot device. Please keep in mind that this forces the VM to use only this device.

With this code you are able to change or add other VcOptionValue´s also :) 

Thursday, May 19, 2011

PHP - how to establish a vCO webservice client

Discussing about the vCO webservice clients with Jason Miles at the PSO training I decide to show up how simple it is to build a webservice portal. With this you can easily establish web integration if the customer already has a web portal, for example.

The PHP script has two components (.inc and .php):
  • parameters.inc
  • findWorkflows.php
  • findWorkflowsWithName.php
The first file holds the vCO servername/ip address, the username and the password, the second is the actual script. With "findWorkflowsWithName.php" I want to show how easy the parameter handover from a HTML form is.

At first I create the "parameters.inc" to change the credentials in a central way.



 












After including the right credentials for the vCO connection I create the findWorkflows.php:
















After saving the work the test in the browser shows up all workflows of my vCenter Orchestrator Server.















So the first example is done. The connect works and the first method: "getAllWorkflows" from the vCenter Orchestrator WSDL is running. But in most cases customers want to give data from an external website to the vCenter Orchestrator. I show this with the "getWorflowsWithName" method in another script (findWorkflowsWithName.php).
















With this the user can search for a workflow by name.
















So, get your feet on the street and start building you own web portal :-)

WARNING - when developing this I found out that the input parameter for "getWorkflowsWithName" isn´t only "name", it is "workflowName"! - WARNING









So, sometimes there are some little traps but we try to fix that!

Monday, May 9, 2011

VMworld 2011 - Unveil the vCO secrets and VOTE!

Our fellow Christophe here at VMware has posted the VMworld sessions for the vCenter Orchestrator automation and orchestration sessions:

http://www.vcoteam.info/newsflash/vmworld-2011-help-to-reveal-vmware-best-kept-secret.html

If you want to know more about the exciting capabilities of the vCenter Orchestrator and the automation from infrastructure to the cloud, please vote.

Thanks! Hope to see you at the VMworld 2011!

Monday, May 2, 2011

vCO - convert decimal net mask to decimal octet

I had to calculate the dotted subnet mask from normal formatted network string like:

192.168.12.0/23 --> 255.255.254.0

In vCO pow(x,y) is not available, so I had to build an action which transform the decimal part (here 23) into a dotted format by using a function to calculate pow(2,x).
Because the decimal part was got by .split("/") the input parameter is also string. You an easily rewrite this action for number input usage.


Feel free to leave a comment - Regards, Andreas

Thursday, March 31, 2011

vCO - use and examples of RegExp (regular expression) Update

I just learned a little bit more about RexExP in vCO. The problem and solution track could found at http://communities.vmware.com/thread/308300 (there is no bug in RexExp, only a poor description of the method in vCO). A basic usage was already published in this previous post.

The string.match() is used to find substrings matching a pattern, the RegExp. But when you call this expecting a multiple return, you'll only get the first match.

test = "Cats don't eat catfish. Not my cat";
System.log (test.match("cat"));

will return only one element in array: "cat" - the first match found in catfish.

By expanding the RegExp with modifiers you will receive all results (maybe you know them from JavaScript).


test = "Cats don't eat catfish. Not my cat";
System.log (test.match(new RegEx("cat", "g")));

returns "cat,"cat" for both cat in string.
Using "i" will return "Cat".
And the combination gi "Cat", "cat", "cat"
  • i for case independend search
  • g for global search
  • gi as combination of both

This is the expected behavior mentioned in all tutorials.

Regards, Andreas

Wednesday, March 30, 2011

vCO - from infrastructure to the cloud (Cisco USC Plug-in)

As mentioned in many other blog articles in the past, the development of the vCenter Orchestrator Plug-ins goes straight ahead. A few weeks after the vCloud Plug-in the Cisco UCS Plug-in was released yesterday! This Plug-in shows how many ways there are to design automation and orchestration solutions. In my opinion there are two main strategies to implement a vCO in customer environments:
  • as leading system for automation design and implementation
  • as subordinate system with high integration possibilities
With this in mind there are two other important things to know: the infrastructure and the cloud automation. In every VMware cloud there is also the need to establish an basic vSphere infrastructure (infrastructire as a service) which abstracts the physical resources. So if you have a physical infrastructure you can know design the complete automation from hardware delivery up to cloud integration (application as a service).

Don´t get me wrong, you can integrate your ESX/ESXi host-systems in an automated way also without the Cisco USC Plug-in but if you have Cisco hardware the deployment is much more comfortable because of using the UCS API. Here are some examples from the release notes:

  • Application of a service profile to a UCS blade
  • Cloning a service profile template to a service profile
  • Service profile customization of frequently modified components
  • Import and export of service profiles from and to UCS Manager instances

As you can see the service definition is also available for the cloud infrastructure and allows you to definine service levels and tiers in an automated way.

Based on the HTTP POST method the integration of Cisco UCS Manager looks like:








With this method the Cisco UCS Manager XML API maps the objects with their attributes and functions in the vCenter Orchestrator.

In the Plug-in packages are also several example workflows and actions to automate an existing environment in a fast and comfortable way.















I hope that we now can address a wider audience to automate and orchestrate their cloud infrastructure.

Download Cisco UCS Plug-in: VMware vCenter Orchestrator Plug-in for Cisco UCS 1.0
Release Notes: VMware vCenter Orchestrator Plug-In for Cisco UCS Manager 1.0 Release Notes

Monday, March 28, 2011

vCO - set Jumbo Frames (MTU) for VMkernel

Last week I spoke to some fellows here at VMware and think about a solution to automate the MTU size for a dvPort/PortGroup with vCO automation. In the past there was no automated way than the excellent solution by Scott Lowe. Based on these findings i try to build this in vCO, knowing that the vSphere Client does not support this directly.

At first i had to identify the Port which serves the vmkernel and a few input parameters:









At first I need the host (in my case as string because this is used for an external excitation via SOAP), the name of the dvSwitch, the new IP address of the vmkernel interface and the new subnet mask. So i set the host (VcPlugin.getAllHostSystems) and use the getAllDvSwitches workflow from one of my last publications.
















After that I set the dvSwitch based on the input parameter (dvSwitch) and searching for the right port. The main procedure to identify the right port is: if(Ports[h].connectee.type == "hostVmkVnic") cause this compares to the vmkernel NIC.















At this point I know everything to change the MTU of the vmkernel Port, but... the API shows an cruel description:












So as mentioned when reading the article there is no direct API based way to set the MTU of a dvPort. In my case I solve the problem with using direct ssh commands. The drawback with this is the username/password dependence.














So after identifying the right host, the vmkernel port, the new ip address and subnet mask the ssh commands can run. As you can see I used exact the same commands as the console guys use.

So, hope this helps.

Tuesday, March 8, 2011

vCO - internal methods and authorizations

Today I had a strange problem at one of our larger customers. In fact it could be reduced to one sentence: "When starting a workflow from the GUI everything works, starting this workflow with the same user from a webservice client, all internal methods fail."

In this case internal methods mean things like:

var VMs = VcPlugin.getAllVirtualMachines();

or other actions with embedded methods. As a good Consultant I try to reduce the possibilities which can cause an error like this. At first I test the script of the customer (Perl) in my environment, with success because everything was fine. Then I review the user and his rights in the customers vCO and try my own Win32 test application (will be published soon). Every time I started Clients directly on the vCO all things going straight forward. Every time I test it from the customers PC nothing works or better the array "VMs" was empty.









The bad thing is that I can´t get any error inside the workflows. The vCenter Orchestrator always runs over the workflows and doesn´t display any error message. After several attempts I try to read out the log files in the vCenter Orchestrator. Inside the vCenter Orchestrator configuration there is a log viewer which i use for searching. After a few lines there are several ERROR entries, which look like this:

 2011-03-08 07:35:39.760+0100 ERROR [VimSession] getRootFolder() --> java.lang.Exception: getServiceContent() [vcouser@https://vCenterServerIP/sdk/Main#498028b0] --> Invalid login

I didn´t know that there was a difference between the networks (AD policy) because the user was created in the campus network. Testing it with my Win32 client directly on the vCenter Orchestrator with the same user was successful.

After we changed the rights for the user (AD group) everything works fine and all arrays were filled.

So if you see that internal actions or methods doesn´t work from your webclient, there could be an authorization problem :-)

Sunday, March 6, 2011

NEWS - time to change

Now it is official! Andreas and I joined the VMware PSO team this week. We decide to use mighty-virtualization further as it is known in the past: as virtualization and and automation blog. Between that we'll write at www.vcoteam.info, one of the best blogs for the vCenter Orchestrator automation tool.

Especially the newest vCO plugin for vCloud Director shows up that vCenter Orchestrator allows you to use infrastructure and cloud automation in future. In my opinion vCO is the best automation and orchestration tool for virtual environments on the market and we signed our flags to show you why ;-)

So please stay tuned, there are great things to come!

Thursday, February 3, 2011

vCO - use and examples of RegExp (regular expression)

Regular Expressions are a powerful tool to work with strings and - like awk - a little bit cryptic (for me). So I start to write down some use case and examples I need in vCO for searching or as an input filter, e.g. in vCO WebView.

Links I've used:
Attention: vCO does not use RegExp in format /..../, "/" must be omitted!

Example 1: IP-address format

to restrict a mandatory input only to x.x.x.x up to xxx.xxx.xxx.xxx where x is numeric (0-9) use this RegExp (does not catch range errors, only format will be checked):


How is this build up? IP address is build by 4 groups of pattern, first three with same logic.

First three groups - 1 up to 255 always followed by a dot

A counted repetition is build by {} e.g. {3} = exact 3 times, {1,3} = min. 1 max. 3 times.
So x up to xxx is written as [0-9] <-- represents one character as a digit from 0 to 9, followed by {1,3} <-- repeat this 1 up to 3 times --> [0-9]{1,3}. The dot is a control char and mast be escaped by \. So a complete group is describes as [0-9]{1,3}\.
This group occurs exactly 3 times, so we group this expression by () and repeat it {}

([0-9]{1,3}\.){3}

Last group - 1 up to 255
same as above [0-9]{1,3}. Now combine all groups and you have a RegExp for IP-address format.

([0-9]{1,3}\.){3}[0-9]{1,3}

Example 2: String.search(RegExp)

To search a special character combination String.index ist most used. But if you searching e.g. for VMs containing _TMPL and you want to find also _tmpl and all other combinations, you have to use "ucase" and then .index.
Or you can catch this in one RegExp (VMs is Array/VirtualMachine):

for (i in VMs)
{
  if (VMs[i].name.search("_[tT][mM][pP][lL]") >= 0)
  {
    //do something
  }
}

If the pattern should only be valid at the end of string, add $ to group --> (_[tT][mM][pP][lL])$

Example 3:
match pattern for naming conventions e.g. datastore names

Another often use case is filtering datastores by name.
Assuming a company's naming convention is <CLUSTERNAME>-<TIER><LUN> where clustername has no defined length, tier is F, S, L and LUN 001 to 255. Additional Test LUNs having a suffix and should not match the search. Examples for datastore names:
  • Cluster17-L-123
  • DevCluster02-S-043
  • DevCluster01-L-155_MyTest
If you want find a valid datastore name  in tier class L or M, omitting test datastores you have to define a set of .index clauses or one RegExp:

"(-[LM]-[0-9]{3})$"

This will find all combinations of -L-xxx and -M-xxx only if they are at the end of string.


If you have use case to be solved or other questions, feel free to leave as comment.

Regards, Andreas



Thursday, January 27, 2011

vCO - get all Distributed Virtual Switches

Yesterday i try to get all dvSwitches of a vCenter environment into an array. After several hours of searching and trying there is no easy way in my opinion. So i think this little workaround could help:

var dvPG = VcPlugin.getAllDistributedVirtualPortgroups();
var DVS = new Array(); 

for(i in dvPG){
   DVS.push(dvPG[i].config.distributedVirtualSwitch);
   DVS.sort();
   System.log("DVS vor Schleife: " + DVS);

   for ( i = 0; i < DVS.length; i++)
      {
      if(i != 0){
      while (DVS[i] == DVS[i-1])
      DVS.splice(i,1);
      }
   }
}

If you have other ways please feel free to publish them as a comment. Please note that you need at least one dvPortGroup!

Friday, January 21, 2011

vCO - Unzip Files with VMware Orchestrator workflow

To unzip files with vCO, e.g. patch bundles for ESX, there are some prerequisites.
  • vCO read / write access to source / target location (edit js-io-rights.conf)
  • min. 2 (v)CPU on vCO
  • vCO needs access to java.io.* and java.lang.Object (see post for how to)
This is a first full functional draft. There are some workarounds, because syntax / code is restricted in vCO.

Input parameters
  • ZipFileName - absolute path to ZIP file - e.g. C:/VCO/MyZip.zip
  • OutputPath - path for deflating content - e.g. C:/VCO/deflate/


Finding a solution for the used workarounds, I will update this post.

Feel free to leave comments or drop your questions.

Regards, Andreas

Thursday, January 20, 2011

vCO - Access to Java Classes

By default JavaScript in vCO is limited to class subtree java.util.* . Please read vCenter Orchestrator Administration Guide 4.1 on page 69 before changing default settings.
Why changing default settings? In my case I want to unzip bundles in an offline repository only with vCO, not using 3rd party tools. The ZipFile object is direct accessible, but some methods are derived from classes in java.io.* and java.lang.Object. So I have to loosen the default restrictions, described on Page 69.

Step1:

create a text file e.g MyShutter.txt with following content:

java.io.*
java.util.*
java.lang.Object


Save this file at <VCO-install-folder>\Orchestrator\app-server\bin\MyShutter.txt. This folder already exists.

Step 2:

Stop VCO-Server
Edit vmo.properties (look in ...\app-server\server\vmo\conf) and add following line:

com.vmware.scripting.rhino-class-shutter-file=MyShutter.txt

I've tried to use here an absolute path e.g. C:/VCO/MyShutter.txt (nothing was mentioned in documentation). You will get an error (server.log) like this if doing so:

2011-01-20 16:52:31.540+0100 ERROR [MainScriptingObject] Cannot find rhino js shutter class file at location : C:\Program Files\VMware\Orchestrator\app-server\bin\VCOMyShutter.txt

Step 3:

Start VCO-Server
Run an example using an object from new accessible classes.
Check server.log
If your example fails, check
  • server.log for above error - maybe the shutter file was not found
  • object naming - so you not using import the object must be fully qualified - e.g. ZipFile object qualifies as java.util.zip.ZipFile
Feel free to leave comments or drop your questions.

Regards, Andreas

Thursday, January 13, 2011

vCO - SOAP connect via VB .NET

Last week i try to build a Win32 application, based on the vCenter Orchestrator WSDL interface. In my case i try to develop an administrator interface which allows external administrators (external locations and so on) to start defined workflows with defined input parameters, like a vSphere Client for automation tasks.

After the successful evaluation i wrote the following instruction:

At first I install the newest version of Visual Studio 2010 Express Editions on my notebook and create a new Windows-Forms project. After the creation of an empty project you have to add a webservice reference, cause the vCenter Orchestrator WSDL interface is web-based. This is done by a right mouse click on the root folder of your project (in my case SOAPvCO).












In the sub-menu you will find an option called "Add Service Reference". After clicking the "Advanced" option and the WebService Reference button you can add the local WSDL path of your vCenter Orchestrator and rename it how you want it (in my case vCOref).








After the service reference is created all necessary methods and attributes are available in Visual Studio object browser. Now you can create a simple form in like this:














The basic elements are a textbox (multiline), a connect button (name=ButtonConnect) and an exit button (name=ButtonExit) to close the application. By doing a double click the connect button you will get the code window of the form. As you can see, the sub (ButtonConnect_Click) is created automatically. In this code window you have to create the following code (sorry for the screenshot, but only self-writing teaches!).


















In this simple example the connection parameters are asked with simple input boxes and written into string variables. The most important part is the declaration of "SOAP" as vCOref(our reference).VSOWebControlService(default class for new service) above the sub routines. With this definition above you can now use the "SOAP" constructor for the full form.

When debugging the project, the result should look like:













As you can see, the connection was successful and the number of workflow are shown. With this basic you can start to build up some stuff especially for your needs.

Feel free to ask any questions if you want to know more about the possibilities.