Hello,
I want my user can choose different Template from Datacenter. I have a first custom properties linked with action to show DataCenter Location and now I would like create another action vro linked from input parameter (Datacenter) to give possibility to choose Template
I modify the script with if and else condition but when I choose my first custom properties DataCenter the information is not sent in the condition if and goes directly to the "else"
var sdkConnection;
var vcFolderId;
if(Datacenter){
switch(Datacenter){
case "TOULOUSE":
var sdkConnection = "aixmqvcenter01.aixmq.local"
var vcFolderId = "group-v265";
case "CANNES":
var sdkConnection = "aixmqvcenter01.aixmq.local"
var vcFolderId = "group-v262";
}
}
else {
return["Please select a Datacenter"];
};
var sdk = Server.findForType("VC:SdkConnection",sdkConnection);
// Search for vcfolder with the id of vcFolderId
var vcfolder = sdk.getAllVmFolders(null,"xpath:id='"+vcFolderId+"'");
// vcfolder contains an array of folders. The first element of this array will be stored in theVmFolder as a VcVmFolder object
var theVmFolder = vcfolder[0];
// Stores the vm name
var vmsInFolder = theVmFolder.vm;
// Array to store the vms with the status template from a vcfolder
var templatesInFolder = [];
// Temporary variable to find out if one of the vms in the vcfolder has the status of a template
var vmsAvailable = 0;
// Checks if the vcfolder is empty
if (theVmFolder.vm == 0 && vmsAvailable == 0){
System.log("NO VMs in Folder at all");
templatesInFolder.push("NO TEMPLATES");
}
else {
// Loops through all vms in the vcfolder and stores only vms with the status template in an array of strings
if (vmsInFolder[0].config.template != null){
for (i = 0; i < vmsInFolder.length; i++) {
if (vmsInFolder[i].config.template == true) {
System.log("VM : "+vmsInFolder[i].name+" Is a template");
templatesInFolder.push(vmsInFolder[i].name);
}
else {
System.log("VM : "+vmsInFolder[i].name+" Is not a template");
vmsAvailable = 1;
}
}
}
// Check if none of the available vms in the vcfolder have the status template
if (templatesInFolder[0] == null && vmsAvailable == 1)
{
System.log("No Templates in Folder");
templatesInFolder.push("NO TEMPLATES");
}
}
// Resturns and Array of strings with includes all vms in the vcfolder with the status template
return templatesInFolder;
var sdkConnection;
var vcFolderId;
if(Datacenter){
switch(Datacenter){
case "TOULOUSE":
var sdkConnection = "aixmqvcenter01.aixmq.local"
var vcFolderId = "group-v265";
case "CANNES":
var sdkConnection = "aixmqvcenter01.aixmq.local"
var vcFolderId = "group-v262";
}
}
else {
return["Please select a Datacenter"];
};
var sdk = Server.findForType("VC:SdkConnection",sdkConnection);
// Search for vcfolder with the id of vcFolderId
var vcfolder = sdk.getAllVmFolders(null,"xpath:id='"+vcFolderId+"'");
// vcfolder contains an array of folders. The first element of this array will be stored in theVmFolder as a VcVmFolder object
var theVmFolder = vcfolder[0];
// Stores the vm name
var vmsInFolder = theVmFolder.vm;
// Array to store the vms with the status template from a vcfolder
var templatesInFolder = [];
// Temporary variable to find out if one of the vms in the vcfolder has the status of a template
var vmsAvailable = 0;
// Checks if the vcfolder is empty
if (theVmFolder.vm == 0 && vmsAvailable == 0){
System.log("NO VMs in Folder at all");
templatesInFolder.push("NO TEMPLATES");
}
else {
// Loops through all vms in the vcfolder and stores only vms with the status template in an array of strings
if (vmsInFolder[0].config.template != null){
for (i = 0; i < vmsInFolder.length; i++) {
if (vmsInFolder[i].config.template == true) {
System.log("VM : "+vmsInFolder[i].name+" Is a template");
templatesInFolder.push(vmsInFolder[i].name);
}
else {
System.log("VM : "+vmsInFolder[i].name+" Is not a template");
vmsAvailable = 1;
}
}
}
// Check if none of the available vms in the vcfolder have the status template
if (templatesInFolder[0] == null && vmsAvailable == 1)
{
System.log("No Templates in Folder");
templatesInFolder.push("NO TEMPLATES");
}
}
// Resturns and Array of strings with includes all vms in the vcfolder with the status template
return templatesInFolder;