Call Workflows from outside

0

LittleCMDB (An Orchestrator and WaveMaker project) – Part 6

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

Part6

Let’s have a look on our LittleCMDB. We can capture virtual machines, we insert the captured data into a SQL DB and we have a Website to get a look on our data. Till now, that okay but we have some “problems” with our CMDB. What’s with virtual Machines were the configuration is changed after the first capture? At the moment will we not get this configuration changes. Why we don’t get the changes? In our decision “VM in DB” we have the condition “when the VM is in our DB we go back to NumberofVMs”. We don’t look for configuration changes.

That’s not smart 🙂 ……… This means our DB could be outdated with one week if enough configuration changes were made…

So let’s start and make our LittleCMDB more “production” ready.

First we remove the red dotted line from “VM in DB” to “NumberofVMs”.

First we insert from Bottom to top a Scriptable Task and a Decision. We do this four times. When we are finished your schema should look like mine.

Then we will insert the next Workflows. Here we are on a decision we must made…… We can choose the SQL “Update” workflows or generate Scriptable Task with our own code. I will use scriptable task for the update of the datasets. Why that? When you use the “Update” Workflows, error correction and data search is sometimes a problem. You can only insert “one” value (the value to update the dataset). In the data search, this leads to problems. So I will use scriptable task in which I can insert all needed parameter and my required error correction.

So insert four scriptable workflows on the left of the other workflows.

At the End your schema must look like this:

Don’t worry about the sum of Workflow……it will be very easy 😉

Know we start with the Scriptable Task at the bottom. First we give a name and description. I will call it “GetVMfromVM_Info”. As description you can insert “We read the information from the VM_Info Table split it and comparing it with the actual data.”

Here are the required Variables for the Element:

Local Parameter Variable Name Module Direction Type
VMName VMName GetVMInfofromVM_Info in String
VMInfo_Table VMInfo_Table GetVMInfofromVM_Info in SQL:Table
VMUUID VMUUID GetVMInfofromVM_Info in String
VMInfofromDB VMInfofromDB GetVMInfofromVM_Info in SQL:ActiveRecord
datastoreName datastoreName GetVMInfofromVM_Info in Array/string
cpuCount cpuCount GetVMInfofromVM_Info in number
memoryMB memoryMB GetVMInfofromVM_Info in number
CPUNumberfromDB CPUNumberfromDB GetVMInfofromVM_Info out number
MemNumberfromDB MemNumberfromDB GetVMInfofromVM_Info out number
VM_Info_Change VM_info_Change GetVMInfofromVM_Info out Boolean
V_ID V_ID GetVMInfofromVM_Info Out String

Don’t forget to map the VMInfo_table variable to the VM_Info table.

Here is the required Script for the Task:

// -------------------------------------------------------------
// we search for the Data of the virtual Machine with the Name and the UUID. First we define the search columns
var columns = {
 VMUUID : VMUUID,
 VMName : VMName,

};

// Get the Data from the Table and put them in a SQL Active Record
VMInfofromDB = VMInfo_table.readRecords(columns);
// The data from the SQL Record is a "String" with is separated with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
var SplitConfigArraytoStringMem = VMInfofromDB.toString();
// In the Array, we search for the Keyword "MemConfig" under which our Memory configuration is stored
var MemSearch = SplitConfigArraytoStringMem.search("MemConfig");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 10 after the Start Position (MemConfig + = is about 10 positions)
var MemStart = MemSearch + 10;
// Here we split at the beginning of the Value with the rest of the string
var MemStringTemp = SplitConfigArraytoStringMem.slice(MemStart);
// We split on the first "," found. That's our value End
var MemStringEnd = MemStringTemp.search(",");
// Here we take the start and the end we figured out before and save the value into the Variable
MemNumberfromDB = MemStringTemp.slice(0, MemStringEnd);

// The data from the SQL Record is a "String" with is sepearted with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
var SplitConfigArraytoStringCPU = VMInfofromDB.toString();
// In the Array, we search for the Keyword "CPUConfig" under which our Memory configuration is stored
var CPUSearch = SplitConfigArraytoStringCPU.search("CPUConfig");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 10 after the Start Position (CPUConfig + = is about 10 positions)
var CPUStart = CPUSearch + 10;
// Here we split at the beginning of the Value with the rest of the string
var CPUStringTemp = SplitConfigArraytoStringCPU.slice(CPUStart);
// We split on the first "}" found. That's our value End
var CPUStringEnd = CPUStringTemp.search("}");
// Here we take the start and the end we figured out before and save the value into the Variable
CPUNumberfromDB = CPUStringTemp.slice(0, CPUStringEnd);
// The data from the SQL Record is a "String" with is sepearted with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
// The V_ID Field is required to update the SQL DB when there is a change
var SplitConfigArraytoStringVID = VMInfofromDB.toString();
// In the Array, we search for the Keyword "V_ID" under which our V_ID is stored
var VIDSearch = SplitConfigArraytoStringVID.search("VMID");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 5 after the Start Position (VMID + = is about 5 positions)
var VIDStart = VIDSearch + 5;
// Here we split at the beginning of the Value with the rest of the string
var VIDStringTemp = SplitConfigArraytoStringVID.slice(VIDStart);
// We split on the first "," found. That's our value End
var VIDStringEnd = VIDStringTemp.search(",");
// Here we take the start and the end we figured out before and save the value into the Variable
V_ID = VIDStringTemp.slice(0, VIDStringEnd);

//-----------------------------------------------------------------------------------------------------------------
// After we have our "configuration" Values, we have to check if there is a difference between the VM Data and
// the data stored in the DB.

if ((CPUNumberfromDB != cpuCount) || (MemNumberfromDB != memoryMB)){
// When there is a difference, we set the Variable to true
VM_Info_Change = true;}
else {
// When there is no difference, we set the Variable to false
VM_Info_Change = false;}

I made a lot comments in the scripting element so I hope everybody understand the Idea to split the array and get on the DB data.

Next we go to our decision up to the scripting element. We give it a name. I chose “VM_Info_change”. As variable for this decision we need the following:

Local Parameter Variable Name Module Direction Type
VM_Info_Change VM_Info_Change VM_Info_Change in boolean

In the Decision field we set the Value to “is true”

At least, we are going to work with the “Scriptable task” to the left. I call it  “Update active record for ‘VM_Info’” Element.  For that, we need the following In- and Outputs

Local Parameter Variable Name Module Direction Type
VMName VMName Update Active Record for ‘VM_Info’ in String
V_ID V_ID Update Active Record for ‘VM_Info’ in String
VMUUID VMUUID Update Active Record for ‘VM_Info’ in String
cpuCount cpuCount Update Active Record for ‘VM_Info’ in Number
memoryMB memoryMB Update Active Record for ‘VM_Info’ in Number
MemNumberfromDB MemNumberfromDB Update Active Record for ‘VM_Info’ in Number
CPUNumberfromDB CPUNumberfromDB Update Active Record for ‘VM_Info’ in Number
VMInfo_table VMInfo_table Update Active Record for ‘VM_Info’ in SQL:Table
VMInfoRead_result VMInfoRead_result Update Active Record for ‘VM_Info’ in SQL:ActiveRecord
UpdateResult_VM_Info UpdateResult_VM_Info Update Active Record for ‘VM_Info’ out Number

Here is the script we insert into the Scripting field:

// we need the original values to load the record from the DB
var NewArray = new Array(V_ID,VMUUID,VMName,CPUNumberfromDB,MemNumberfromDB)

// we search for the record in the DB with the data from there
VMInfoRead_result = System.getModule("com.vmware.library.sql").findUniqueRecord(VMInfo_table,NewArray);

var columns = {
 VMID : V_ID,
 VMUUID : VMUUID,
 VMName : VMName,
 CPUConfig : cpuCount,
 MemConfig : memoryMB
};
UpdateResult_VM_Info = VMInfo_table.updateRecord(VMInfoRead_result, columns);
System.log("Update DB with new virtual machine information")

Now we are going to connect the first Elements. We start with the “VM_in_DB” Element and connect it with the “red” line to the “GetVMfromVM_Info” Element. The “GetVMfromVM_Info” will be connected to the “VM_Info_Change” element. From this element we connect the “true” (the green line) to “Update active record for ‘VM_Info” and the “false” (the red line) to the “Scriptable Task above. As last connection we draw the line from “Update active record for ‘VM_Info” to the Scriptable Task above. When you are ready your connections must look like my.

After we have finished our connections, we go further with the “Scriptable  Task” Element we have already connected. First we insert a name and description. I use as name “GetVMfromHost_info” and as description “Get the Information from the database regarding the Host information”. Then we have to define our needed variables:

Local Parameter Variable Name Module Direction Type
VMHost_Table VMHost_Table GetVMfromHost_info in SQL:Table
VMUUID VMUUID GetVMfromHost_info in String
V_ID V_ID GetVMfromHost_info in string
VMInfofromDB VMInfofromDB GetVMfromHost_info in SQL:ActiveRecord
runningHostName runningHostName GetVMfromHost_info in String
clusterName clusterName GetVMfromHost_info in String
resourcePoolName resourcePoolName GetVMfromHost_info in String
folderName folderName GetVMfromHost_info in String
HostfromDB HostfromDB GetVMfromHost_info out String
ClusterfromDB ClusterfromDB GetVMfromHost_info out String
RPfromDB RPfromDB GetVMfromHost_info out String
FolderfromDB FolderfromDB GetVMfromHost_info out String
VM_Host_Change VM_Host_Change GetVMfromHost_info out boolean

Also here is it required, to point the Variable “VMHost_table” to the “VM_Host” Table

Then we can start our scripting. In the basic, the following scripting is the same as we already did for the “GetVMInfofromVM_Info” table. Here is the Script:

// -------------------------------------------------------------
// we search for the Data of the virtual Machine with the Name and the UUID. First we define the search columns
var columns = {
 VMID : V_ID,
 VMUUID : VMUUID,
};

// Get the Data from the Table and put them in a SQL Active Record
VMInfofromDB = VMHost_table.readRecords(columns);

// The data from the SQL Record is a "String" with is sepearted with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
var SplitConfigArraytoStringHost = VMInfofromDB.toString();
// In the Array, we search for the Keyword
var HostSearch = SplitConfigArraytoStringHost.search("Host");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 5 after the Start Position
var HostStart = HostSearch + 5;
// Here we split at the beginning of the Value with the rest of the string
var HostStringTemp = SplitConfigArraytoStringHost.slice(HostStart);
// We split on the first "," found. That's our value End
var HostStringEnd = HostStringTemp.search(",");
// Here we take the start and the end we figured out before and save the value into the Variable
HostfromDB = HostStringTemp.slice(0, HostStringEnd);

// The data from the SQL Record is a "String" with is sepearted with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
var SplitConfigArraytoStringCluster = VMInfofromDB.toString();
// In the Array, we search for the Keyword
var ClusterSearch = SplitConfigArraytoStringCluster.search("Cluster");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 8 after the Start Position
var ClusterStart = ClusterSearch + 8;
// Here we split at the beginning of the Value with the rest of the string
var ClusterStringTemp = SplitConfigArraytoStringCluster.slice(ClusterStart);
// We split on the first "}" found. That's our value End
var ClusterStringEnd = ClusterStringTemp.search(",");
// Here we take the start and the end we figured out before and save the value into the Variable
ClusterfromDB = ClusterStringTemp.slice(0, ClusterStringEnd);

// The data from the SQL Record is a "String" with is sepearted with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
var SplitConfigArraytoStringFolder = VMInfofromDB.toString();
// In the Array, we search for the Keyword
var FolderSearch = SplitConfigArraytoStringFolder.search("Folder");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 7 after the Start Position
var FolderStart = FolderSearch + 7;
// Here we split at the beginning of the Value with the rest of the string
var FolderStringTemp = SplitConfigArraytoStringCluster.slice(FolderStart);
// We split on the first "," found. That's our value End
var FolderStringEnd = FolderStringTemp.search(",");
// Here we take the start and the end we figured out before and save the value into the Variable
FolderfromDB = FolderStringTemp.slice(0, FolderStringEnd);

// The data from the SQL Record is a "String" with is sepearted with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
var SplitConfigArraytoStringRP = VMInfofromDB.toString();
// In the Array, we search for the Keyword
var RPSearch = SplitConfigArraytoStringRP.search("ResourcePool");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 13 after the Start Position
var RPStart = RPSearch + 13;
// Here we split at the beginning of the Value with the rest of the string
var RPStringTemp = SplitConfigArraytoStringRP.slice(RPStart);
// We split on the first "}" found. That's our value End
var RPStringEnd = RPStringTemp.search("}");
// Here we take the start and the end we figured out before and save the value into the Variable
RPfromDB = RPStringTemp.slice(0, RPStringEnd);

//-----------------------------------------------------------------------------------------------------------------
// After we have our "configuration" Values, we have to check if there is a difference between the VM Data and
// the data stored in the DB.
if ((HostfromDB != runningHostName) || (ClusterfromDB != clusterName) || (RPfromDB != resourcePoolName) || (FolderfromDB != folderName)){
// When there is a difference, we set the Variable to true
VM_Host_Change = true;}
else {
// When there is no difference, we set the Variable to false
VM_Host_Change = false;}

After we finished our scripting we went to the “Decision”. Here we enter a name; I use “VM_Host_Change” and a description. In the Decision we need the Variable “Vm_Host_Change”

Local Parameter Variable Name Module Direction Type
VM_Host_Change VM_Host_Change VM_Host_Change in boolean

We set the Value in the Decision field to “is true”.

Next we define the In- and Outputs for the “Scriptable Task”. I call the Workflow “Update active record for ‘VM_Host’”. We need the following variables:

Local Parameter Variable Name Module Direction Type
V_ID V_ID Update Active Record for ‘VM_Host’ in String
VMUUID VMUUID Update Active Record for ‘VM_Host’ in String
clusterName clusterName Update Active Record for ‘VM_Host’ in String
runningHostName runningHostName Update Active Record for ‘VM_Host’ in String
resourcePoolName resourcePoolName Update Active Record for ‘VM_Host’ in String
folderName folderName Update Active Record for ‘VM_Host’ in String
ClusterfromDB ClusterfromDB Update Active Record for ‘VM_Host’ in String
HostfromDB HostfromDB Update Active Record for ‘VM_Host’ in String
RPfromDB RPfromDB Update Active Record for ‘VM_Host’ in String
FolderfromDB FolderfromDB Update Active Record for ‘VM_Host’ in String
UpdateResult_VM_Host UpdateResult_VM_Host Update Active Record for ‘VM_Host’ in Number
VMHost_table VMHost_table Update Active Record for ‘VM_Host’ in SQL:Table
VMHost_ReadResult VMHost_ReadResult Update Active Record for ‘VM_Host’ in SQL:ActiveRecord
UpdateResult_VM_Host UpdateResult_VM_Host Update Active Record for ‘VM_Host’ Out Number

Here is the script which we need in this module:

// we need the original values to load the record from the DB
var NewArray = new Array(V_ID,VMUUID,ClusterfromDB,HostfromDB,RPfromDB,FolderfromDB)

// we search for the record in the DB with the data from there
VMHost_ReadResult = System.getModule("com.vmware.library.sql").findUniqueRecord(VMHost_table,NewArray);

var columns = {
 VMID : V_ID,
 VMUUID : VMUUID,
 Cluster : clusterName,
 Host : runningHostName,
 ResourcePool : resourcePoolName,
 Folder : folderName
};

UpdateResult_VM_Host = VMHost_table.updateRecord(VMHost_ReadResult, columns);
System.log("Update DB with new host information")

 

After we have finished our mappings, we can connect the different workflows together. Also here it is the same schema as before. We connect the “GetVMfromHost_Info” to the decision “VM_Host_Change” from there we connect the false path to the “Scriptable Task” above and the true Path to “Update active record from ‘VM_Host”. From there we connect to also to the Scriptable task.

Now, I think everybody has an understanding from the method which is used here, so I will only provide the variables and the scripts for the last elements.

I call the next scriptable task “GetVMfromVM_Network”.  Here are the required in- and outputs and the script:

Local Parameter Variable Name Module Direction Type
V_ID V_ID GetVMInfofromVM_Network in string
VMNetwork_table VMNetwork_table GetVMInfofromVM_Network in SQL:Table
VMUUID VMUUID GetVMInfofromVM_Network in String
VMInfofromDB VMInfofromDB GetVMInfofromVM_Network in SQL:ActiveRecord
ipAddresses ipAddresses GetVMInfofromVM_Network in Array/string
networks networks GetVMInfofromVM_Network in Array/string
IPfromDB IPfromDB GetVMInfofromVM_Network out String
NetworksfromDB NetworksfromDB GetVMInfofromVM_Network out String
VM_Network_Change VM_Network_Change GetVMInfofromVM_Network out boolean
IpAddressToString IpAddressToString GetVMInfofromVM_Network out string
NetworksToString NetworksToString GetVMInfofromVM_Network out string
// -------------------------------------------------------------
// we search for the Data of the virtual Machine with the Name and the UUID. First we define the search columns
var columns = {
 VMID : V_ID,
 VMUUID : VMUUID,
};

// Get the Data from the Table and put them in a SQL Active Record
VMInfofromDB = VMNetwork_table.readRecords(columns);

// The data from the SQL Record is a "String" with is sepearted with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
var SplitConfigArraytoStringIP = VMInfofromDB.toString();
// In the Array, we search for the Keyword "IPAddress"
var IPSearch = SplitConfigArraytoStringIP.search("IPAddress");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 10 after the Start Position
var IPStart = IPSearch + 10;
// Here we split at the beginning of the Value with the rest of the string
var IPStringTemp = SplitConfigArraytoStringIP.slice(IPStart);
// We split on the first "," followed from a space. That's our value End. That's different then before because
// the vm can have more than one ip which is separated thru a ","
var IPStringEnd = IPStringTemp.search(/\s?,\s/);
// Here we take the start and the end we figured out before and save the value into the Variable
IPfromDB = IPStringTemp.slice(0, IPStringEnd);

// The data from the SQL Record is a "String" with is sepearted with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
var SplitConfigArraytoStringNet = VMInfofromDB.toString();
// In the Array, we search for the Keyword
var NetSearch = SplitConfigArraytoStringNet.search("Network");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 8 after the Start Position
var NetStart = NetSearch + 8;
// Here we split at the beginning of the Value with the rest of the string
var NetStringTemp = SplitConfigArraytoStringNet.slice(NetStart);
// We split on the first "," folowed from a space. That's our value End. That's different then before because
// the vm can have more than one network which is separated thru a ","
var NetStringEnd = NetStringTemp.search(/\s?,\s/);
// Here we take the start and the end we figured out before and save the value into the Variable
NetworksfromDB = NetStringTemp.slice(0, NetStringEnd);
//-----------------------------------------------------------------------------------------------------------------
// After we have our "configuration" Values, we have to check if there is a difference between the VM Data and
// the data stored in the DB.

// Catch empty Network and IpAddresses and set a placeholder text
if ((ipAddresses == null) || (ipAddresses == "")) {
IpAddressToString = "No IP adress found"
} else {
IpAddressToString = ipAddresses.toString()
};

if ((networks== null) || (networks == "" )){
NetworksToString = "No networks found"
} else {
NetworksToString =networks.toString()
};

if ((IPfromDB != IpAddressToString) || (NetworksfromDB != NetworksToString)){
// When there is a difference, we set the Variable to true
VM_Network_Change = true;}
else {
// When there is no difference, we set the Variable to false
VM_Network_Change = false;}

When you have a deeper look at the script, you will see that there is a change between this script and the two scripts before. Here we have (as by the insert into the DB) to convert our API Network information into a string! You will see the same conversation in the datastore script. Next we work with the Decision above. I call it “VM_Network_Change” and set the Value “VM_network_change” to true. Here is the table with the Variables:

Local Parameter Variable Name Module Direction Type
VM_Network_Change VM_Network_Change VM_Network_Change in boolean

Our last part for this three pair configuration is the “Scriptable task”. I call it “Update active record for ‘VM_Network”. We use the following in- and outputs:

Local Parameter Variable Name Module Direction Type
V_ID V_ID Update active record for ‘VM_Network in String
VMUUID VMUUID Update active record for ‘VM_Network in String
NetworksToString NetworksToString Update active record for ‘VM_Network in String
IpAddressToString IpAddressToString Update active record for ‘VM_Network in String
IPfromDB IPfromDB Update active record for ‘VM_Network in String
NetworksfromDB NetworksfromDB Update active record for ‘VM_Network in String
VMNetwork_table VMNetwork_table Update active record for ‘VM_Network in SQL:Table
VMNetworkRead_result VMNetworkRead_result Update active record for ‘VM_Network in SQL:ActiceRecord
UpdateResult_VM_Network UpdateResult_VM_Network Update active record for ‘VM_Network Out Number

And here is the script:

// We must catch "null" values and change them to ""
// we do this for IPfromDB and NetworksfromDB
// we need the original values to load the record from the DB
if (IPfromDB == "null"){
IPfromDB = "";}
if (NetworksfromDB == "null"){
NetworksfromDB = "";}

var NewArray = new Array(V_ID,VMUUID,NetworksfromDB,IPfromDB)

// we search for the record in the DB with the data from there
VMNetworkRead_result = System.getModule("com.vmware.library.sql").findUniqueRecord(VMNetwork_table,NewArray);

var columns = {
 VMID : V_ID,
 VMUUID : VMUUID,
 Network : NetworksToString,
 IPAddress : IpAddressToString
};

UpdateResult_VM_Network = VMNetwork_table.updateRecord(VMNetworkRead_result, columns);
System.log("Update DB with new network Information")

 

Now we can make our connections. Just follow the logic witch was used before. It is the same here…

Now let’s configure the last three pair of Workflows. We start with the scriptable task. I name it “GetVMfromVM_Datastore” and here are the used variables:

Local Parameter Variable Name Module Direction Type
V_ID V_ID GetVMInfofromVM_Datastore in string
VMDatastore_table VMDatastore_table GetVMInfofromVM_Datastore in SQL:Table
VMUUID VMUUID GetVMInfofromVM_Datastore in String
VMInfofromDB VMInfofromDB GetVMInfofromVM_Datastore in SQL:ActiveRecord
datastoresName datastoresName GetVMInfofromVM_Datastore in Array/string
diskSizes diskSizes GetVMInfofromVM_Datastore in Array/Number
DatastorefromDB DatastorefromDB GetVMInfofromVM_Datastore out String
DiskfromDB DiskfromDB GetVMInfofromVM_Datastore out String
VM_Datastore_Change VM_Datastore_Change GetVMInfofromVM_Datastore out boolean
DiskSizetoString DiskSizetoString GetVMInfofromVM_Datastore out String
DatastoreNamestoString DatastoreNamestoString GetVMInfofromVM_Datastore out String

And here is the required script:

// -------------------------------------------------------------
// we search for the Data of the virtual Machine with the Name and the UUID. First we define the search columns
var columns = {
 VMID : V_ID,
 VMUUID : VMUUID,

};

// Get the Data from the Table and put them in a SQL Active Record
VMInfofromDB = VMDatastore_table.readRecords(columns);

// The data from the SQL Record is a "String" with is sepearted with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
var SplitConfigArraytoStringDisk = VMInfofromDB.toString();
// In the Array, we search for the Keyword
var DiskSearch = SplitConfigArraytoStringDisk.search("DiskSize");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 9 after the Start Position
var DiskStart = DiskSearch + 9;
// Here we split at the beginning of the Value with the rest of the string
var DiskStringTemp = SplitConfigArraytoStringDisk.slice(DiskStart);
// We split on the first "," folowed from a space. That's our value End. That's different then before because
// the vm can have more than one ip which is separated thru a ","
var DiskStringEnd = DiskStringTemp.search(/\s?,\s/);
// Here we take the start and the end we figured out before and save the value into the Variable
DiskfromDB = DiskStringTemp.slice(0, DiskStringEnd);

// The data from the SQL Record is a "String" with is sepearted with ",". We have to Split the String in Single Files.....
// First, we put the String into a temporally Variable.
var SplitConfigArraytoStringData = VMInfofromDB.toString();
// In the Array, we search for the Keyword
var DataSearch = SplitConfigArraytoStringData.search("Datastore");
// The above defined search give us the Starting Position of our Keyword. We want the blank value, so we have to split
// on Position 10 after the Start Position
var DataStart = DataSearch + 10;
// Here we split at the beginning of the Value with the rest of the string
var DataStringTemp = SplitConfigArraytoStringData.slice(DataStart);
// We split on the first "}". That's our value End
var DataStringEnd = DataStringTemp.search("}");
// Here we take the start and the end we figured out before and save the value into the Variable
DatastorefromDB = DataStringTemp.slice(0, DataStringEnd);
//-----------------------------------------------------------------------------------------------------------------
// After we have our "configuration" Values, we have to check if there is a difference between the VM Data and
// the data stored in the DB.
// Catch empty disksizes and datastoreName and replace with a string
if ((diskSizes == null) || (diskSizes == "")){
DiskSizeToString = "Could not read Disk Size"
} else {
DiskSizeToString = diskSizes.toString();
};

if ((datastoresName == null) || (datastoresName = "")) {
DatastoreNamesToString = "Could not read Datastore Name"
} else {
DatastoreNamesToString = datastoresName.toString();
};

if ((DiskfromDB != DiskSizeToString) || (DatastorefromDB != DatastoreNamesToString)){
// When there is a difference, we set the Variable to true
VM_Datastore_Change = true;}
else {
// When there is no difference, we set the Variable to false
VM_Datastore_Change = false;}

Next we change the name for the decision to “VM_Datastore_Change”. As input we need:

Local Parameter Variable Name Module Direction Type
VM_Datastore_Change VM_Datastore_Change VM_Datastore_Change in boolean

Also here we set the Value VM_Datastore_Change to “true”.

Our last configuration must be done on the “Scriptable task”. I call it “Update active record for ‘VM_Datastore’”. Here we need the in- and outputs:

Local Parameter Variable Name Module Direction Type
V_ID V_ID Update active record for ‘VM_Datastore’ in String
VMUUID VMUUID Update active record for ‘VM_Datastore’ in String
DiskSizetoString DiskSizetoString Update active record for ‘VM_Datastore’ in String
DatastoreNamesToString DatastoreNamesToString Update active record for ‘VM_Datastore’ in String
DiskfromDB DiskfromDB Update active record for ‘VM_Datastore’ in String
DatastorefromDB DatastorefromDB Update active record for ‘VM_Datastore’ in String
VMDatastore_table VMDatastore_table Update active record for ‘VM_Datastore’ in SQL:Table
VMDatastoreRead_result VMDatastoreRead_result Update active record for ‘VM_Datastore’ in SQL:Active Record
UpdateResult_VM_Datastore UpdateResult_VM_Datastore Update active record for ‘VM_Datastore’ out Number

And this script:

// We must catch "null" values and change them to ""
// we do this for DiskfromDB and DatastorefromDB
// we need the original values to load the record from the DB
if (DiskfromDB == "null"){
DiskfromDB = "";}
if (DatastorefromDB == "null"){
DatastorefromDB = "";}

// we search for the record in the DB with the data from there
var NewArray = new Array(V_ID,VMUUID,DiskfromDB,DatastorefromDB)

VMDatastoreRead_result = System.getModule("com.vmware.library.sql").findUniqueRecord(VMDatastore_table,NewArray);

// Now we start to update the record with the new data
var columns = {
 VMID : V_ID,
 VMUUID : VMUUID,
 DiskSize : DiskSizeToString,
 Datastore : DatastoreNamesToString
};
UpdateResult_VM_Datastore = VMDatastore_table.updateRecord(VMDatastoreRead_result, columns);
System.log("Update DB with new Storage Information")

At least we have to make our last connections. We start from “GetVMfromVM_Datastore” and go to the “VM_Datastore_Change”. From there we go with the false (the red) line to “NumberofVMs”. With the true (the green) line we go to “Update active record for ‘VM_Datastore’”. From there we connect to “NumberofVMs”.

After we have finished our configuration, let’s validate the workflow

And start….

If everything is fine, your DB will be updated with the last information and configuration changes of our virtual machines…..

That’s all for Part6…..

De Vcoportal Part6
De Vcoportal Part6
de.vcoportal.package_part6.package
126.0 KiB
Details...
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...