Examples

0

LittleCMDB (An Orchestrator and WaveMaker project) – Part 5

Table of Content

In Part1 we start with the SQL DB Plugin and create the required database for our need.

In Part2 we start with the development of our Workflow. We will start with a few elements.

In Part3 we  finish the  collection of the VM information.

In Part4 we insert our data into the database and test our created workflow

In Part5 we create our webview to get a look on our Data in the SQL Database

In Part6 we will make our Workflow smarter to update the DB with actual VM information

In Part7 problems with vAPP located virtual machines are fixed

Part5

After we have finished our Workflow, it is time to start with WaveMaker.

WaveMaker is Part of VMware. WaveMaker is a WYSIWYG Editor based on JavaScript & open source Web 2.0 standards

With WaveMaker, we will create a Website for a view of our database data. In this post, we will keep it simple and only generate the view. In a later post we will integrate the Website with the Orchestrator so that changes, which will be done, are played back to the Orchestrator and the vCenter Server. To start with WaveMaker, you need the WaveMaker Software. First of all, we have to get WaveMaker. You become WaveMaker on their Website http://www.wavemaker.com there you can click on “Download”

There you can get the install package for your OS.

I use the Windows Version. The installation is easy. Just start the installation and the rest will done with the wizard.

After we are finished with the installation (don’t forget to install additional packages WaveMaker request!). We can start it.

For this view, you can start a new project, or start with the project I created here: http://www.vcoportal.de/2012/05/howto-setup-ldap-authentication-for-wavemaker-part-1/

I will use my created project…you are free to do so or to start from scratch…..to use my project you have to download the package and unzip in in your WaveMaker “Project Folder” in My case that is C:\WaveMaker\projects Just insert the vCO_WM_LDAP folder and start WaveMaker. Then you are able to start from this point by clicking on “Open Project”.

When you have installed the newest WaveMaker Software you become an Upgrade Message for the package. That’s okay the project was created with an earlier version of WaveMaker….so go on…..

To save the download package I will clone and rename the project. For that go to “File” and “Copy current project”

Enter the new project name, in my case “LittleCMDB” and confirm the copy.

When the clone is ready close the current project.

And open the “LittleCMDB” project.

Before we can start with the development of our website, we have to create a “View” in our db. It is also possible to create the view in WaveMaker, but them we are not able to export the view back into the db. Here is a link witch explains how to create a LiveView in WaveMaker: http://dev.wavemaker.com/wiki/bin/wmdoc_6.4/Database#HViewsInWaveMaker

I will create my LiveView in my database. For that, I will start my Management Studio.

After the authentication, I drill down to my DB and there to the Views Folder.

With a “right click” there I can create a New View with fits my need.

In the opening windows select all tables you created in our DB. In my case that are “VM_Datastore”, “VM_Host”, “VM_Info” and “VM_Network”.

Know we have our Tables in the created view. Till know, there are no values chosen.

We will do so, by clicking the values we want integrated in our view.

I choose:

  • VMName
  • CPUConfig
  • MemConfig
  • Cluster
  • Host
  • ResourcePool
  • Folder
  • DiskSize
  • Datastore
  • Network
  • IPAddress

After we have chosen the values, you can save the view

Give a Name for the view, I chose “MyView” as name.

After that, we are finished with the SQL DB.

Now we can start with the development of our website. First, we want to change the name for the Headline. Just click on the Headline and then change the text in the caption field to the right.

I change the name to Little CMDB. Then we go to the Model Tab and click on it.

The Menu on the right site changes and you see the structure of the project. This project has different layers. I will not explain here, how to setup the AD Authentication. For that, and if you want to know more about the different layers, go to my LDAP/vCO/WaveMaker post:
http://www.vcoportal.de/2012/05/howto-setup-ldap-authentication-for-wavemaker-part-1/

We want to work in the “vCO_Tasks” Layer, so just click on that and you are there.

Here we start with the integration of the database. For the database connection you need some Information. You need:

  • The database system (in my case SQL Server)
  • The host name or IPAddress
  • The Username
  • The Password
  • And the Database (in my case Little_CMDB)
  • Optional the Instance

To integrate our database, go to “Services” à “Import Database”:

A wizard is opened and you have to fill in the required field.

After you have filled in our data test the connection and then import the data.

If you get an error during the import there are some possible solutions.

1)      The user has not the permission for the Import

2)      The Schema Filter under the Advanced Options is case sensitive

Here are some links to the WaveMaker Forum to fix Import Problems:

http://dev.wavemaker.com/wiki/bin/Dev/MSSQL#HInstanceName

http://dev.wavemaker.com/forums/?q=node/1827

After you have imported the database, go back to Palette.

Here we drill down to the “Database Widget” and there we take “MyView” DojoGrid and pull it into the Window in the middle.

There you have to choose the View, which you want for your data. I will take the Dialog View. I choose the Dialog View.

When you have made everything right, you will become directly a view on the DB data.

Know we make some facelift for the view. First, you can change the Title name for the DojoGrid. I call it Little CMDB View.

Then I will reduce the columns and change the names to more speaking names (instead of id.vmname and so on). Just right click on the columns and chose “editColumns” to do so.

In my View, I only chose the VM Name for showing. I also change the alignment to center. All other data will be shown in the detail pane. Feel free to change the view to your need.

After that, I change the Names in the Detail Panel. For that, just click on the column and change the name to what you want.

When you are ready save your site and start a test run (when you are lazy, it is enough to start the run, and this will save your project!)

When you made everything right then your data will be loaded after authentication (sometimes it takes a little bit longer, depending on the data in the DB and your environment!)

When everything looks fine, we have to deploy the Website on one of your webservers. You also have the possibility to host the site on your Orchestrator server. Jörg made a Video were it is shown to do so:

http://www.vcoportal.de/2011/11/using-wavemaker-as-web-frontend-for-vco/

The interesting part is at 06:30!
(Note from Jörg:  :mrgreen: Be aware that this is absolutely unsupported!)

The project in this post is  very restricted, cause the circumstance that you must use our own AD- and SQL Server data…..

That’s all for Part5….stay tuned for the next Part……

WaveMaker
WaveMaker
LittleCMDB.zip
16.9 MiB
Details...
0

LittleCMDB (An Orchestrator and WaveMaker project) – Part 4

Table of Content

In Part1 we start with the SQL DB Plugin and create the required database for our need.

In Part2 we start with the development of our Workflow. We will start with a few elements.

In Part3 we  finish the  collection of the VM information.

In Part4 we insert our data into the database and test our created workflow

In Part5 we create our webview to get a look on our Data in the SQL Database

In Part6 we will make our Workflow smarter to update the DB with actual VM information

In Part7 problems with vAPP located virtual machines are fixed


Part4

In Part4 of this LittleCMDB series we will finished the first Version of our vCO Workflow and make a run….

Our “get Information” part of the Workflow is ready, know it is time to put the data into the SQL Database.

For that, we start with the placement of our SQL-Statement Workflow we created earlier. For that, we place the workflows

  • “Create active record for ‘VM_Info’”

  • “Create active record for ‘VM_Host’”

    and two Scriptable Tasks in our schema.

In my Order the workflow on the right site of the “VM in DB” is the VM_Info, followed from VM_Host and then the two scriptable Task

First, we will configure the VM_Info Workflow.

The only thing we have to do is to match the attributes which we have with the needed input parameter of the workflow.

Here is the matching table for the Workflow:

Local Parameter Variable Name Module Direction Type
isUnique isUnique Create Active Record VM_Info in Boolean (true)
VMUUID VMUUID Create Active Record VM_Info in String
VMID V_ID Create Active Record VM_Info in String
CPUConfig cpuCount Create Active Record VM_Info in number
MemConfig MemoryMB Create Active Record VM_Info in number
result VMInfo_result Create Active Record VM_Info out SQL:ActiveRecord

Some extra notes here: Sometimes, the creation of the SQL statements workflows uses wrong “Types” for example string then number. You can change this types in the Workflow. After that, you have to reinsert the Workflow.

When you are ready your binding must look like this:

When we are ready we go further with the next Workflow “Create Active record ‘VM_Host’.

Here we need the following bindings:

Local Parameter Variable Name Module Direction Type
isUnique isUnique Create Active Record VM_Host in Boolean (true)
VMUUID VMUUID Create Active Record VM_Host in String
Cluster clusterName Create Active Record VM_Host in String
Host runningHostName Create Active Record VM_Host in String
ResourcePool ResourcePoolName Create Active Record VM_Host in String
Folder folderName Create Active Record VM_Host in String
VMID V_ID Create Active Record VM_Host in String
result VMHost_result Create Active Record VM_Host out SQL:ActiveRecord

Now we are on the first Scriptable Task element. We will use this for the VM_network SQL operation. You may ask yourself why will we don’t use the Workflow Element? That’s a good question and here is the answer.

In the Network and Datastore Element we need some scripting to catch errors from gathering the VM data. Also there is a need for changing the Array/string Elements into String Elements for the storing in the database.

So, let’s start with the first Scripting Element. I call it “SQL_VM_Network”. Know let’s insert the needed in- and outputs

Local Parameter Variable Name Module Direction Type
V_ID V_ID SQL_VM_Network in String
isUnique isUnique SQL_VM_Network in Boolean (true)
VMUUID VMUUID SQL_VM_Network in String
networks networks SQL_VM_Network in Array/string
ipAddresses ipAddresses SQL_VM_Network in Array/string
VMNetwork_table VMNetwork_table SQL_VM_Network in SQL:Table
ipAddressesToString ipAddressesToString SQL_VM_Network in String
NetworksToString NetworksToString SQL_VM_Network in String
VMNetwork_result VMNetwork_result SQL_VM_Network out SQL:ActiveRecord

Here is the Script for the Element


// Catch empty Network and IpAdresses and set a placeholder text

if (ipAddresses == null){

IpAddressToString = "No IP adress found"

} else {

IpAddressToString = ipAddresses.toString()

};

if (networks== null){

NetworksToString = "No networks found"

} else {

NetworksToString =networks.toString()

};

// The SQL Operation to store the information into the Db

var columns = {

VMID : V_ID,

VMUUID : VMUUID,

Network : NetworksToString,

IPAddress : IpAddressToString

};

VMNetwork_result = VMNetwork_table.createRecord(columns, isUnique);

System.log("Database table record created successfully");

Know we have to configure the second scriptable Task. This one is for the Datastore config. I call it “SQL_VM_Datastore”.

Here are the required variables

Local Parameter Variable Name Module Direction Type
V_ID V_ID SQL_VM_Datastore in String
isUnique isUnique SQL_VM_Datastore in Boolean (true)
VMUUID VMUUID SQL_VM_Datastore in String
diskSize diskSize SQL_VM_Datastore in Array/string
datastoreName datastoreName SQL_VM_Datastore in Array/string
VMDatastore_table VMNetwork_table SQL_VM_Datastore in SQL:Table
DiskSizeToString DiskSizeToString SQL_VM_Datastore in String
DatastoreNamesToString DatastoreNamesToString SQL_VM_Datastore in String
VMDatastore_result VMNetwork_result SQL_VM_Datastore out SQL:ActiveRecord

Here is the script for the Element:


// Catch empty disksizes and datastoreName and replace with a string

if (diskSizes == null){

DiskSizeToString = "Could not read Disk Size"

} else {

DiskSizeToString = diskSizes.toString();

};

if (datastoresName == null){

DatastoreNamesToString = "Could not read Datastore Name"

} else {

DatastoreNamesToString = datastoresName.toString();

};

// The SQL Operation to store the information into the Db

var columns = {

VMID : V_ID,

VMUUID : VMUUID,

DiskSize : DiskSizeToString,

Datastore : DatastoreNamesToString

};

VMDatastore_result = VMDatastore_table.createRecord(columns, isUnique);

System.log("Database table record created successfully");

Know we have to connect our elements. First, we need a Connection from our “VM in DB” Element to the “Create active record for ‘VM_Info’”. From there we go up and connect the “Create active record for ‘VM_Host’” with the “SQL_VM_Network” and then with the “SQL_VM_Datastore”. From the “SQL_VM_Datastore” we build the connection to “NumberofVMs”.

When you have build the connections, your Schema must look like this:

Before we close our Workflow we validate it

When you made everything right, our workflow must show now errors.

Know it is time to make a first run. Save and close the Workflow and start the Workflow with a right click and the option “Start Workflow…”

If you start your Workflow after the first run a second time, only new virtual machines will be cached. Existing machines are ignored.

That’ was all for Part4. In Part5 we are going to create a Website with WaveMaker and get a look on our data so stay tuned 😉

De Vcoportal Part4
De Vcoportal Part4
de.vcoportal_Part4.package
120.9 KiB
Details...
0

LittleCMDB (An Orchestrator and WaveMaker project) – Part 3

Table of Content

In Part1 we start with the SQL DB Plugin and create the required database for our need.

In Part2 we start with the development of our Workflow. We will start with a few elements.

In Part3 we  finish the  collection of the VM information.

In Part4 we insert our data into the database and test our created workflow

In Part5 we create our webview to get a look on our Data in the SQL Database

In Part6 we will make our Workflow smarter to update the DB with actual VM information

In Part7 problems with vAPP located virtual machines are fixed


Part3

Here we go with the Part3 of our LittleCMDB……

To get forward with out CMDB with need more Elements. We insert the following elements and workflows into the Schema.

  • A scripting element

  • a decision

  • the Workflow element “Extract virtual machine information”

  • a second scripting element

  • a third scripting element

  • a second decision

We can place the elements on the left side of our Schema.

After placement it have to look like this screen shot

 

Next we have to insert values in the different elements. Lets start with the first Scriptable task.

We set the name of the element t o”Countdown VMs” and insert a good description (we want to countdown the “AllVMs” Array…). Next we need the in and output’s for the element. Following variables are required:

Local Parameter Variable Name Module Direction Type
NumberVMs NumberVMs Countdown Vms in Number
allVMs allVMs Countdown Vms in Array/VC:VirtualMachine
SQLVID SQLVID Countdown Vms in String
NumberVMs NumberVMs Countdown Vms out Number
VmtoGet VmtoGet Countdown Vms out VC:VirtualMachine
SkipVM SkipVM Countdown Vms out Boolean
VMName VMName Countdown Vms out String
V_ID V_ID Countdown Vms out String

After we have created the values we start with our scripting. In our Scripting, we have to check different states of the connected virtual machines. Some states could lead to errors in our scripting, so we have to avoid them and skip the VM. In the Scripting Tab we have to insert this commands.


// set Variable SkipVM to false

SkipVM == false;

// We take the last VM in our Array

VmtoGet = allVMs.pop();

// some virtual machines are in the API but not connected. We must exclude them, otherwise we become errors

if (VmtoGet.summary.runtime.connectionState == VcVirtualMachineConnectionState.orphaned) {

SkipVM = true;

System.debug("OrphanedVM: " + VmtoGet);

}

if (VmtoGet.summary.config.template == true) {

SkipVM = true;

System.debug("Template: " + VmtoGet);

}

if (VmtoGet.summary.runtime.connectionState == VcVirtualMachineConnectionState.disconnected) {

SkipVM = true;

System.debug("VM Disconnected: " + VmtoGet);

}

if (VmtoGet.summary.runtime.connectionState == VcVirtualMachineConnectionState.inaccessible) {

SkipVM = true;

System.debug("VM Inaccessible: " + VmtoGet);

}

// Get the virtual machine name

VMName = VmtoGet.summary.config.name;

// create a unique UUID for the database (It is also possible to do so in the SQL DB....here I use the JavaScript )

V_ID = System.nextUUID();

// decrease the Variable NumberVMs

NumberVMs = NumberVMs -1;

Next we go to the decision. Here we have to insert a speaking name and a description. I use “SkipVM” as name. After that, we have to fill in the Decision condition.

 

For that, we click on “Not Set (NULL)” and choose the Skip VM variable

 

Then we have to set the parameter to “is false”

 

Then we are already finished with this module.

Now we have to deal with the “Extract virtual machine Information” Workflow. This workflow has one Input and a lot of Output variables.

Local Parameter Variable Name Module Direction Type
vm VmtoGet Extract virtual Machine in VC:VirtualMachine
folderName folderName Extract virtual Machine out String
folderID folderID Extract virtual Machine out String
runningHostName runningHostName Extract virtual Machine out String
runningHostID runningHostID Extract virtual Machine out String
resourcePoolName resourcePoolName Extract virtual Machine out String
rescourcePoolID rescourcePoolID Extract virtual Machine out String
clusterName clusterName Extract virtual Machine out String
clusterID clusterID Extract virtual Machine out String
computeResourceId computeResourceId Extract virtual Machine out String
datastoreName datastoreName Extract virtual Machine out Array/string
datastoreId datastoreId Extract virtual Machine out Array/string
diskSize diskSize Extract virtual Machine out Array/number
cpuCount cpuCount Extract virtual Machine out number
memoryMB memoryMB Extract virtual Machine out number
ipAddresses ipAddresses Extract virtual Machine out Array/string
networks networks Extract virtual Machine out Array/string
folder folder Extract virtual Machine out VC:VmFolder
host host Extract virtual Machine out VC:HostSystem
resourcePool resourcePool Extract virtual Machine out VC:ResourcePool
cluster cluster Extract virtual Machine out VC:ClusterComputeResource
computeResource computeResource Extract virtual Machine out VC:ComputeResource
datastores datastores Extract virtual Machine out Array/VC:Datastore

The output Variables must all be attributes….when your are finished your “Visual Bindings” have a whole bunch of connections…

 

That’s all for the module. Know we have to deal with the second scripting element. When you have a deeper look at the “Extract virtual machine Information” module, you will see that some information about virtual machines are missing. One of these information is the virtual machine UUID. This UUID is always unique for a VM. The name of the VM could be changed but the UUID with not be changed. So to be able to identify a VM we need this UUID. In this scripting element, we want extract this information.

First we give a name and a description for the module. I use the name “GetVMUUID”. Then we need one Input parameter and a output parameter.

Local Parameter Variable Name Module Direction Type
VmtoGet VmtoGet GetVMUUID in VC:VirtualMachine
VMUUID VMUUID GetVMUUID out String

In the scripting tab we insert the following:

VMUUID = VmtoGet.summary.config.uuid;

With this, we get the UUID of the virtual Machine.

Now it is time to configure the third scriptable task. In this module, we will check if the VM is already in our DB. For that, we do some custom SQL scripting. We will not use a “predefined” SQL Statement, which we created earlier because we only need two columns for our decision.

First, lets name the module and insert a description. I name the module “GetVMfromDB”

Let’s see what Input and Output parameter we need:

Local Parameter Variable Name Module Direction Type
isUnique isUnique GetVMfromDB in Boolean (true)
VMUUID VMUUID GetVMfromDB in String
V_ID V_ID GetVMfromDB in String
VMInfo_Table VMInfo GetVMfromDB in SQL:Table
VMInfoRead_Result VMInfoReadResult GetVMfromDB in SQL:ActiveRecord
VMName VMName GetVMfromDB in String
VminDB VminDB GetVMfromDB out Boolean

The VMInfo_Table must be chosen. You can pick the right Table during the configuration of the Variable


The VMInfoRead_result is reading data out of the database and to work with this data.

After we have created all variables, we can start with the Scripting.

The script we need has to read the VM information out of the db (if the VM exist in the database). If the VM exist it generates a log entry and sets the Variables “VMinDB” to true. Otherwise to false. We use the Variable “VMinDB” for the control of our Workflow.


// We check the DB for the VM. The check is based on VMName and UUID

var columns = {
UUID : VMUUID,
VMName : VMName,

};
VMInfoRead_result = VMInfo_Table.readRecords(columns);

// Some local variables here. We have to split the DB Information
var SplitArraytoString = VMInfoRead_result.toString();
var UUIDString = SplitArraytoString.search(VMUUID);
var VMNameString = SplitArraytoString.search(VMName);

if ((UUIDString >= 0) && (VMNameString >=0))
{
VMinDB = true;
System.log("VM: " + VMName + " already in DB.")
}
else
{
VMinDB = false;
System.log("VM: " + VMName + " not in DB.")
};

At last we have to deal with the next Decision. I use the Name “VM in DB”for that decision. Here we check if the VM is already in the DB.

 

 After we have chosen the Variable, we set the Boolean Value to “false”

 

After we have finished all the Elements, we are starting to connect these. We start with the “Countdown VMs”. We need a connection from “NumberofVMs” to there. And from “Countdown VMs” we will make a connection to “SkipVM”

 

Next we need a connection from “SkipVM” to “Extract virtual machine Information” and a “Error Connection to “NumberofVMs”.

 

All Other Elements will be connected to the following element.

 

From “VM in DB” we connect the error connection to “NumberofVMs”. When the VM is already in our Database, we go further with the next virtual machine.

 

At least for this part, we create a End under “NumberofVMs”. This End will be reached, If the number of VMs is “0”.

 That’s all for Part3. In Part4 we will start to insert the Data into the SQL Server, so stay tuned 😉

De Vcoportal Part3
De Vcoportal Part3
de.vcoportal_Part3.package
119.8 KiB
Details...
0

LittleCMDB (An Orchestrator and WaveMaker project) – Part 2

Table of Content

In Part1 we start with the SQL DB Plugin and create the required database for our need.

In Part2 we start with the development of our Workflow. We will start with a few elements.

In Part3 we  finish the  collection of the VM information.

In Part4 we insert our data into the database and test our created workflow

In Part5 we create our webview to get a look on our Data in the SQL Database

In Part6 we will make our Workflow smarter to update the DB with actual VM information

In Part7 problems with vAPP located virtual machines are fixed

Part2

Here we go with Part2 of the “Little CMDB” Project. Enjoy the Post 😉

After the SQL Database is ready, it is time to start with the Workflow development. As first task, let’s start and create a new workflow. I will name my as GetVMConfig.

Insert a good description for the Workflow, change the Version Number and then lets go to the schema tab.

 The first thing we need, is a action element to get a list of all virtual machines. Just drag the action element into the window.

 

Just insert „getAll“ into the filter field. As second step choose the “getAllVMs” Workflow.

After we have insert the workflow we change to the „General“ Tab and drag a „Scriptable Task“ and a „Custom Decision“ into the Schema

Now we insert a name for the „Scriptable task“, I choose CalculateVMNumber and a Description.

After that, we are changing the name the of the “Decision” to “NumberofVMs” and insert a description.

 

After we have complete this naming and description for the workflows, we have to create some Variables.

There are two ways to create the variables. The first one is, to drag and drop from the workflows and actions over the Visual Binding tab. The second is to create the variables on the general tab. I will use the first choice.

For all other, here is a sheet with the required variables and there value to create them on the General tab:

Local Parameter Variable Name Module Direction Type
actionResult allVMs GetAllVMs out Array/VC:VirtualMachine
allVMs allVMs CalculateVMNumber in Array/VC:VirtualMachine
NumberVMs NumberVMs CalculateVMNumber out Number
NumberVMs NumberVMs NumberofVMs in Number

Lets start with the “getAllVMs” Action

I recommend to give a variables a “speaking” name and a description

When your are finished, your “Out” tab must look like this:

The next thing we have to configure, is the “CalculateVMNumber”. Here we have to insert the “allVMs” variable over the “IN” Tab

You can insert the Variable over the “Plus” symbol.

At the moment we have only one possible value so we choose the “allVMs”.

Next we go to the “Out” tab. Here we have to export the “NumberVMs” Variable. You can insert the variable over the “Plus” Sign. If you don’t have created the Variable jet, you can do so over the link above.

After we have created the variable (don’t forget we need a “number” as type 😉 ) we go to the script tab.

Here we do our first scripting. We wont to get the length of the array. We can to that with this small script:

NumberVMs = allVMs.length;

You don’t have to literally type the variables. The bound variables for the Workflow are shown on top of the “Scripting” tab. You can simple click on them and there are used in the scripting field.

At last (for the moment) we go to the “NumberofVMs” Decision. There we insert the “NumberVMs” Variable on the in field and insert this script in the scripting tab.

Now, we have to connect the different modules. We can use the connector by clicking on the “connector symbol” and drag-and-drop between the different modules.

After you are finished, just click on the “Validate” button and lets see if we have any error in our workflow.

At the moment we have two errors, which are logical (we don’t have finished our CMDB jet…).

Save the Workflow and then we will in Part3 we will go one with our LittleCMDB so stay tuned 😉

De Vcoportal Part2
De Vcoportal Part2
de.vcoportal_Part2.package
110.7 KiB
Details...
0

LittleCMDB (An Orchestrator and WaveMaker project) – Part 1

Table of Content

In Part1 we start with the SQL DB Plugin and create the required database for our need.

In Part2 we start with the development of our Workflow. We will start with a few elements.

In Part3 we  finish the  collection of the VM information.

In Part4 we insert our data into the database and test our created workflow

In Part5 we create our webview to get a look on our Data in the SQL Database

In Part6 we will make our Workflow smarter to update the DB with actual VM information

In Part7 problems with vAPP located virtual machines are fixed

Part1

Today I want to start with a series of posts for an example how to to create an Orchestrator and Wavemaker project. This project came from a “real-world” situation. The customer wants his VM configuration saved outside the virtual environment into a SQL Database. During the talks with the customer, the idea for a little CMDB was born. The actual customer project is much bigger than the example in this article series, but you will become a good insight view on all relevant topics and themes.

When we think about a CMDB we have to choose which data we want to save in our database. Here are some things I included in my database:

  • Unified Identifier (VMID) (The primary key for the VM)

  • VM UUID (the second key for the VM)

  • VM name

  • CPU Configuration

  • Memory Configuration

  • Cluster

  • Host

  • Folder

  • Resource Pools

  • Network

  • IP Address

  • Datastore(s)

  • Disk Size

Surely there are more things which could be integrated but in this post I will focus these values. These identified values bring us to a database schema. Also there are not so many values; I prefer to save the data in different tables. On every table I choose the Unified Identifier with the name VMID as primary key. As second key I select the VMUUID with should be unique for every virtual machine within a vCenter Server. I also split the different information for the VMs in different tables for maybe future grow.

I create the following tables with these values:

VM_Info

Name

Data Type

IsNull

Comments

VMID

varchar(100)

False

PrimaryKey

VMUUID

varchar(100)

False

VMName

varchar(100)

False

CPUConfig

Numeric(18)

False

MemConfig

Numeric(18)

False

VM_Host

Name

Data Type

Is Null Allowed

Comments

VMID

varchar(100)

False

PrimaryKey

VMUUID

varchar(100)

False

Cluster

varchar(100)

True

Host

varchar(100)

False

ResourcePool

varchar(100)

True

Folder

varchar(100)

True

VM_Network

Name

Data Type

Is Null Allowed

Information

VMID

varchar(100)

False

PrimaryKey

VMUUID

varchar(100)

False

Network

varchar(100)

True

Multiple Values Possible

IPAddress

varchar(500)

true

Multiple Values Possible

VM_Datastore

Name

Data Type

Is Null Allowed

Information

VMID

varchar(100)

False

PrimaryKey

VMUUID

varchar(100)

False

DiskSize

varchar(100)

True

Multiple Values Possible

Datastore

varchar(500)

true

Multiple Values Possible

I am not a database Admin and I cannot say if this is a good DB schema, but it fits my needs and I can grow with additional tables.

As Database a use a MS-SQL Server. My DB is named LittleCMDB. Here is the Script to create the DB on an MS-SQL or MS-SQL Express DB.

USE [LittleCMDB]
GO
/****** Object:  Table [dbo].[VM_Network]    Script Date: 07/13/2012 15:33:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VM_Network](
[VMID] [varchar](100) NOT NULL,
[VMUUID] [varchar](100) NOT NULL,
[Network] [varchar](100) NULL,
[IPAddress] [varchar](500) NULL,
CONSTRAINT [PK_VM_Network] PRIMARY KEY CLUSTERED
(
[VMID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[VM_Info]    Script Date: 07/13/2012 15:33:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VM_Info](
[VMID] [varchar](100) NOT NULL,
[VMUUID] [varchar](100) NOT NULL,
[VMName] [varchar](100) NOT NULL,
[CPUConfig] [numeric](18, 0) NOT NULL,
[MemConfig] [numeric](18, 0) NOT NULL,
CONSTRAINT [PK_VM_Info_1] PRIMARY KEY CLUSTERED
(
[VMID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[VM_Host]    Script Date: 07/13/2012 15:33:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VM_Host](
[VMID] [varchar](100) NOT NULL,
[VMUUID] [varchar](100) NOT NULL,
[Cluster] [varchar](100) NULL,
[Host] [varchar](100) NULL,
[ResourcePool] [varchar](100) NULL,
[Folder] [varchar](100) NULL,
CONSTRAINT [PK_VM_Host] PRIMARY KEY CLUSTERED
(
[VMID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[VM_Datastore]    Script Date: 07/13/2012 15:33:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VM_Datastore](
[VMID] [varchar](100) NOT NULL,
[VMUUID] [varchar](100) NOT NULL,
[DiskSize] [varchar](100) NULL,
[Datastore] [varchar](500) NULL,
CONSTRAINT [PK_VM_Datastore] PRIMARY KEY CLUSTERED
(
[VMID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO

For the usage of a DB in Orchestrator, you can use the SQL-Plugin. The Plug in could be get from the VMware Website (https://my.vmware.com/web/vmware/details?downloadGroup=VCO_SQL_PLUGIN_10&productId=229)

The Installation is done over the Orchestrator Configuration site (http://ORCHESTRATOR_IP:8282). I will not describe the installation. If you are not familiar with the plug in installation then RTFM in the official documentation here http://pubs.vmware.com/orchestrator-plugins/index.jsp?topic=/com.vmware.using.sql.plugin.doc_10/GUID-66110FFD-EB0F-484A-937B-8C131C8DFFB2.html

After you finished the installation of the SQL Plug in, it is time to integrate the SQL Server and the required Database tables.

You can add your database with the vCO Client Workflows Library SQL “Add a database”

There you have to define your SQL Connection Details. In my case, that are the required parameter for the SQL connection. In my case that are:

  • A name for the connection

  • The SQL Server IP with Port and database name (for details look in the screen shot..)

  • A username with permissions on the DB

  • And the password for the user

After the database is successfully added, we have to integrate the preconfigured tables. This is done with the workflow “Add tables to a database”

 

After the start of the workflow we first have to choose the database

In the opening window we take our DB (LittleCMDB in my case…)

 

Then we have to integrate our tables

 

You can add tables by clicking in the “Tables” field

 

there you have to insert all fields beginning with VM_*. Add the end the your Array of String has to look like this:

 

After you have „Accept“ your choice you can „Submit“ the Workflow.

 

Before I start to generate the SQL Statements, I create a Folder in which I will place my SQL-Statements. For that I have created a folder “vcoportal.de” there a sub folder “LittleCMDB”. In the “LittleCMDB” Folder a also created a Subfolder with the name “SQL-Statements”.

Feel free to change your names and folders, i prefer this structure.

To generate your SQL-Statements we have to browse to the Workflow “Generate CRUD workflows for a table”

This Workflow must be executed for every table we want to use.

For that, you have to provide the following inputs:

  • The table

  • The destination directory

  • If you want to overwrite existing workflows

  • And the read-only columns

 

Here is a example for one of my tables:

 

When you are ready for your tables, take a look into your destination folder. For every table, there must be a record to “Insert, Update, Read and Delete” values in your tables.

The preparation of the SQL Server statements is done. Know we can start to build up our workflow to feed the SQL Database…..

So, that’s all for Part1. Stay tuned for Part2. Then we will start to create the Workflow…..

SQL Script
SQL Script
LittleCMDB_SQL.zip
622.0 B
Details...