pages

Showing posts with label VMware. Show all posts
Showing posts with label VMware. Show all posts

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



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

Wednesday, December 22, 2010

vCO - bug discovered on initializing variables

After examing Deric's question in VMware community for vCO I was a little bit confused of my testing results - could that be? - is it a feature or a bug.
Now we have a first statement, it is definitly a bug. Read more at http://communities.vmware.com/thread/296963.

Regards, Andreas

vCO - cluster AAM compliance check

Normal productive clusters are spread over two or more fire compartments. But only maximum five hosts in a cluster are primary hosts for AAM. What happens if all primary hosts reside in one section and this section fails?!  Check your cluster AAM fire compartment compliance:
The following code is compressed in one task for better viewing. For production use split it up in action & workflow(s), depending on sections. It will check, if minmum 2 host in each cell (fire compartment) is a primary host. Adapt these values for your use.
Parameters:
  • (input) Cluster [VcClusterComputeResource]: the cluster to be checked
  • (input) Cell1, Cell2 [Array/VcHostSystem]: an array containing the hosts in each fire compartment (e.g. use vCO configurations)
  • (output) compliant [boolean]: the cluster compliance
  • (output) Cell1Primary, Cell2Primary [Array/VcHostSystem]: primary hosts found for cell
Depending on compliance state you can use the both arrays in a next step email workflow to inform about the cell compliance.

If you are running vSphere 4.1 you can use DRS groups to get already defined host lists:

<Cluster>.configurationEx.group contains the group listing (array).
Cluster.configurationEx.group[x].host constains the host list of group x (array). You can use this to feed the parameters Cell1 & Cell2 dynamically with values from vSphere.

Regards, Andreas

Monday, December 20, 2010

vCloud Director - installation part I

Based on the actual evolutions in the VMware product environment, I decide to installl the new vCloud Director in my home-lab. There are two things which i had to get before starting:

  • Oracle DB 11g for Windows
  • RHEL 5 64bit
After several register processes and hours of downloads I decide to start with the oracle server based on windows. In the future I think i will run it under RHEL also.

Starting with the Oracle DB server there are several things which need my attention, because after the installation the Enterprise Manager (http://localhost:1521/em) was available to me but the listener only reacts on the 127.0.0.1 address. In my opinion there was no way to change it while installing.

First thing i try was diabling the Windows firewall :-) , but without success. Next thing i try was a special command:

tnsping oracle.cjo.local

which reports an error while connecting. After that i try to get an status of the actual configuration with:

lsnrctl status

which shows several TNS-xxxx errors (for example: TNS-03505: Failed to resolve name). After reading some support statements i stopped all services in the server manager.







Then i go to the dbhome_1 directory and edit the tnsnames.ora and listener.ora (configuration files for the service) and change all localhosts to the right DNS name.

tnsnames.ora














listener.ora



After that i start all stopped services (OracleDBConsoleoracle, OracleMTSRecoveryService, OracleOraDb11g_home1TNSListener and OracleServiceORACLE) and check the status via:

lsnrctl status

which shows the right connection name.














Also i try another

tnsping oracle.cjo.local

which shows the following:


Next part now is to install the vCloud Director and try if the connection works. An update will follow...

Sunday, December 19, 2010

vCO - get ESX SSL thumbprint

To add a new ESX host to virtual center by vCO you need the SSL thumbprint of this host.
The following scriptable task shows a simple solution. To keep the example as simple as possible, most parameters are defined local. For production use declare these parameters (port, userName, ...) as input parameters.


For example, you can modify the VMware workflow 'add host to cluster' as shown below, to add a host with self signed or unknown CA to your cluster:



Feel free to leave comments.

Regards, Andreas

Thursday, November 25, 2010

vCO - get performance data from VM & build graph

Retrieving performance data from an entity is a little bit complex not only because of the nested parameters. To reduce code and make it easier for starters to step in, we just grab the average CPU in MHz from a VM about the last hour and build a graph like this:
For this example the code is placed in one scriptable task. For production purpose it is mor sensible to split it in several actions & workflows.
  • Input Parameter: VM [VcVirtualMachine]
Part I - retrieve performance data

setting interval:
var end = new Date(); // now
var start = new Date();
start.setTime(end.getTime() - 3600000); // 1h before end
System.log (end.toUTCString());
System.log (start.toUTCString());
Look at the logged time stamps. They are in UTC and later on also in graph. If you want to adjust this to client time, you have to recalc the time stamp for CSV using Date.getTimezoneOffset().

create querySpec (here for only one VM)
var querySpec = new Array();
querySpec.push(new VcPerfQuerySpec());
querySpec[0].entity = VM.reference;
querySpec[0].startTime = start;
querySpec[0].endTime = end;
querySpec[0].intervalId = 20; //or use 300 for 5 minute stepping
create perfMetricId for one metric (CPU average in MHz) and call perfManager

var PM = new VcPerfMetricId();
PM.counterId = 6; //6 = cpu.usagemhz.average
PM.instance = ""; // no instances
var arrPM = new Array();
arrPM.push(PM);
querySpec[0].metricId = arrPM; //assign PerfMetric to querySpec
querySpec[0].format = "csv";

var CSVs = VM.sdkConnection.perfManager.queryPerf(querySpec);
Now the array CSVs contains one VcPerfEntityMetricCSV object - we only called one - nevertheless i will iterate over CSVs so you can reuse the code

Part II - join data and time stamps in a CSV file
for (i in CSVs)
{
    var CSV = CSVs[i];
    var Temp = CSV.sampleInfoCSV.split(",");
    var Sample = Array();
    for (j in Temp)
    {
        if (j % 2 != 0)
        //only use odd entries, they contain the sample time - even ones contain interval
        {
            Sample.push(Temp[j]);
        }
    }
    var Values = CSV.value[0].value.split(","); // the MHz values
    var BaseName = "C:/Test/" + workflow.id;
    var CSVname = BaseName + ".csv";
    var ControlName = BaseName +  ".control";
    var PNGname = BaseName + ".png";
    var FW = new FileWriter(CSVname);
    FW.open();
    FW.lineEndType = 1;
    for (j in Sample)
    {
           FW.writeLine(Sample[j] + "," + Values[j]);
    }
    FW.close;
Using workflow.id to build the file names makes them individual. So you can call the workflow parallel without having duplicate file names.

Part III - generate graph
To do this there are some requirements:
  • enable local execution for vCO
  • download gnuplot and unzip - in this example it is unzipped to C:\test\gnuplot
First we have to build the control file for gnuplot for manipulate graph rendering. I've changed only some basic parameter - if you are familiar with gnuplot, just add more parameters to get a better look. At the end we just call gnuplot with our control file.
Pay attention on the single quotation marks. We have to mix them up to get the double ones in control file.

    var FW = new FileWriter (ControlName);
    FW.open();
    FW.lineEndType = 1;
    FW.writeLine ('set datafile separator ","');
    FW.writeLine ('unset key');
    FW.writeLine ('set title "performance data ' + VM.id + ' [' + VM.name + ']' + '"');
    FW.writeLine ("set terminal png");
    FW.writeLine ('set output "' + PNGname + '"');
    FW.writeLine ("set xdata time");
    FW.writeLine ('set timefmt "%Y-%m-%dT%H:%M:%SZ"');
    FW.writeLine ('set format x "%H:%M:%S"');
    FW.writeLine ("set xtics rotate");
    FW.writeLine ('set ylabel "MHz"');
    FW.writeLine ('plot "' + CSVname + '" using 1:2 wi li');
    FW.writeLine ("quit");
    FW.close;
    var cmd = "cmd.exe /c C:\\Test\\gnuplot\\binary\\gnuplot.exe " + ControlName;
    System.log (cmd);
    var CMD = new Command(cmd) ;
    var Result = CMD.execute(true);
    System.log ("GNUplot: " + Result);
}

That's all - feel free to leave a comment - regards, Andreas

Tuesday, November 23, 2010

vCO - rights management for WebViews

Yesterday i try to publish a WebView which should be used by only one user group of my Active-Dirctory. After a few attempts i decide to describe the whole process with some pictures. So the goal for todays article is to get only access to the workflow based under "Customer2".

At first you have to define the rights at the root object (Edit access rights....):


Because of the rights heredity you have to enable minimum the "View" right for all objects.













 
In my case a set a view more. After setting the rights for my user group: "Benutzer" which is an Active-Directory group every folder in my hierachy inherits the rights. If you log in to the WebService portal for example, every user in "Benutzer" can view, execute and inspect all folder.











When setting the rigths at the root object is done you have to edit the access rights for the folders you whish to hide. Similar to the steps at the root object you have to select "Edit access rights..." on the folder you want to hide. As you can see the folder has inherited its rights from the parent object (root). Now you have to set the rights, or better the restriction to the folder.














Restrictions in child objects are set by deselecting the rights (cruel sentence...). So deselect all rights and choose the same user group "Benutzer" as before.











After that you can verify the settings and press "Save and Close". Now do the same step for alle folders you want to hide.

In my example the "Customer2" folder is an child of "Customer". Regarding this my parent folder "Customer" needs all the rights set in the root object. If you change the rights here it will affect the child folders! Next we hide my "Customer1" folder because my users should only see workflows in "Customer2". You can do this exactly the same way as for the other folders.


  












As done before we "Edit access rights..." and deactivate all rights for the "Customer1" folder.










After that the child object has no rights and prevails to the parent object. On the "Customer2" folder you have nothing to change (if the parent rights in root are the right ones) because it is visible and the workflows can be executed and inspected.











Now you can logon at the WebViews portal with a user from the Active-Directory group you have enabled ("Benutzer").












In my case the user "Raketen RJ. Joe" can now create a simple virtual machine with his user rights in my vCenter Orchestrator WebViews :-) #
I hope this simple instruction helps you to design a rights management for you administration or user team.

Sunday, November 14, 2010

vCO - XML post with pre-authentication

If you want to post XML data to webservices wich need pre-authentication you need a workaround, because vCO does not support this feature.

In my case, I had to post XML data to CA unicenter without activated SOAP interface, only authenticated post was available. So I wrote this little app XMLpost and call it from vCO.

Read more on original post here: http://communities.vmware.com/docs/DOC-14024

Saturday, November 13, 2010

VMware VCAP-DXA exam experience

Today was the day! After travelling the long way to Frankfurt and reading every guide from VMware at the train i arrived at the VUE test center around 1:00 pm. After the normal check-in procedure i take my seat in front of an old DELL client. After 10 questions in the survey the exam begins...

After 3 hours and 30 minutes my eyes were dry and red and my head begans to burn. I think it was one of the hardest exams i had made in the last years. So i try to give you an overview what drives me mad:

1.building performance reports and statistics
I think nearly every question has to do with performance metrics, performance reports, utilization reports and so on. Also there are several questions to build custom reports and performance graphs like: build up an DRS Cluster, put the hosts into it and design a performance chart for all memory operations (average, used etc.). Sometimes the description doesn´t match the really available options...

2.vMA administration
Another strong part were the vMA questions. Several tricky things are asked: delay in the vMA input via vSphere Client console, esxupdate with NIC drivers (did not work in my test environment!), verifying an ks.cfg file (was not available on my hosts, should be available under /tmp on one of them!), esxcli to create an SATP ALUA rule (New Array does not work as name, because of the space between!)

3.PowerCLI
In my case there was only on script to build: Find all VMs with a CDROM attached and write the list into a file.

4.Standard operations
The most things i had to do where standard vSphere operations: build up a vDS with several port groups, change Uplink orders in vDS port groups, build up an vApp and a resource pool with explicit configuration tasks (start order, reservation under 25%, 5VMs start without expandable resources).

In my case there were no question about the vShield Zones, the vCenter Orchestrator or the Linked Mode, but i really missed them because the vMA questions were really hard! I think i will need a second attempt to get the certification :-(

UPDATE: Today the certification@vmware.com mail arrives and what should i say: i passed the exam!!!

Thursday, July 22, 2010

NEW - mcsWebServicePlugin - NEW

Have you ever ask yourself how to integrate own dynamic webservices into the vSphere Client? Not the poorly way with static .xml pages... now we develop a small freeware solution for this: the mcsWebServicePlugin!

With this vSphere Client Plugin you have the power to integrate your webservices based on the clicked object in the inventory tree. With this solution you are able to simply integrate your mangement boards based on the clicked ESX/ESXi Host-System:



But that´s not the only option. You can also integrate web-portals like your service desk, your monitoring solution or an order portal for new virtual machines. We use it for vCenter Orchestrator workflow integration.



The best is the really simple installation and configuration of the plugin. You have to copy the mcsWebServicePlugin.zip into plugins in your vSphere Client folder and extract it to a new folder in the plugins path. After starting the vSphere Client you can configure your webservice and copy the index.php and the info.php into this path.



At the moment this is the freeware version. In the future there will be a commercial release which would be much more dynamic and allows more than one tab and one central link location.

Feel free to ask for features or if you have any questions!

Here you can download the Plugin and the documentation:
mcsWebServicePlugin.zip
documentation_mightycare_webserviceplugin_v0.2.pdf