pages

Monday, February 27, 2012

vCO - want fast success? use python!


As you may know I´m always interested in finding new methods to make vCO available in the most common programming languages. Last week some guys developed their web service client in python using the outstanding PyvCO module: http://labs.vmware.com/flings/pyvco

I see their fast and impressive results which took them just a few days and decided to take a look into python using "native" SOAP clients. After reading thru some available modules I decide to use suds: https://fedorahosted.org/suds/ because it seems to have a simple design.

After installing the module on my MacBook with pip install suds the first test is really simple:

import suds
client = suds.client.Client('http://172.16.0.176:8280/vmware-vmo-webcontrol/webservice?wsdl')
print client

This is the output:














As you can see all methods and types are shown with a simple print :)

Based on this and some indents you can produce some real nice functions like this:
import suds

vCOurl = 'http://172.16.0.176:8280/vmware-vmo-webcontrol/webservice?WSDL'
#username = raw_input('Username: ')
#password = raw_input('Password: ')
username = 'USERNAME'
password = 'PASSWORD'

client = suds.client.Client(vCOurl)
#print client

def getAllWfs():
 allWfs = client.service.getAllWorkflows(username, password)
 return allWfs

def findWfs(name):
 Wfs = client.service.getWorkflowsWithName(name, username, password)
 return Wfs

#allWfs = getAllWfs()
allWfs = findWfs(raw_input('Workflow name: '))

for wf in allWfs:
   print wf.name
   print wf.id
   wfInParas = wf.inParameters
   for iParas in wfInParas[0]:
        print 'inParameter: '
        print (iParas.name, iParas.type)
   wfOutParas = wf.outParameters
   for oParas in wfOutParas[0]:
        print 'outParameter: '
        print (oParas.name, oParas.type)

With this you can search for a workflow and get the IN/OUT parameters. As you can see the success comes really fast!









So feel free to post your implementations!

Friday, February 24, 2012

vCO - How to automate Altiris Deployments

This week I was in Vienna to implement a VM deployment automation based on Altiris. First thing I always ask is: "Why do you use Altiris as deployment mechanism if you have VMware templates?" and in this case the physical deployment was the answer. So Altiris Deployment is used for physical and virtual servers.

What I like when implementing these things is that the customer has the freedom to choose where to deploy. So there are no borders to deploy a VM or vApp in the vCloud Director for example. It´s just a decision field away :)

First thing you need is to have the Altiris SDK installed on your Altiris Deployment Server. You can find the actual version here: http://www.symantec.com/business/support/index?page=content&id=TECH40810

After the installation you will have another IIS website available: /Altiris.ASDK.DS/ which serves the webservice "API". Now we have two options: the SOAP plug-in and native HTTP POST/GET commands. I prefer the HTTP command way cause the SOAP API isn´t available as one WSDL definition.














So the most simple way is to call the Altiris URL for the exact task. In my case I search for the UUID because the system is displayed as VMware-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxx, rename the system into the VMname IN-parameter and schedule the exact job for the system. You can find the JobIDs via web-browser on the Altiris.ASDK.DS path.

 The command for searching a system (HTTP GET) could look like this:


var url = "http://"+AltirisServer+"/Altiris.ASDK.DS/ComputerManagementService.asmx/GetComputerID?computerSearchPhrase=";
url += Servername
url += "&computerSearchType=2";
var MyURL = new URL(url);
MyURL.getContent();
var Result = MyURL.result;


So, now have fun to automate your Altiris Deployment :)
Maybe this also could be used to automate the vApp deployment including Altiris for the vCloud Director...