Calling CloudClient from vRO (vRealize Orchestrator)
VMware’s vRealize CloudClient can be easily called by Orchestrator in order to programmatically interface with the CloudClient supported plugins, ie: vRO/vRA/SRM/Codestream etc.
Steps Required:
1) Create Script to call CloudClient which sets up environment variables in which to authenticate and store a unique session.
Create a script on the local vRO filesystem called “runVraCommand.sh” with the following contents:
while getopts s:t:u:p:i:x: opt; do
case “$opt” in
s)
export vra_server=$OPTARG
;;
t)
export vra_tenant=$OPTARG
;;
u)
export vra_username=$OPTARG
;;
p)
export vra_password=$OPTARG
;;
i)
export vra_iaas_username=$OPTARG
;;
x)
export vra_iaas_password=$OPTARG
;;
\?) usage;;
esac
done
shift $((OPTIND-1))
usage() {
echo “Invalid Arguments:”
echo “-s – CafeServer hostname”
echo “-u – CafeServer username”
echo “-p – CafeServer password”
echo “-i – IaaS username”
echo “-x – IaaS password”
exit
}
if [ “$vra_server” == “” ]; then
usage
fi
if [ “$vra_tenant” == “” ]; then
vra_tenant=”vsphere.local”
fi
export CLOUDCLIENT_SESSION_KEY=”VRAPlugin-$vra_server-$vra_tenant-$vra_username”
pathToCloudClient=”/storage/scripts/cloudclient/bin/”
$pathToCloudClient/cloudclient.sh $@ | grep -v “CloudClient session:” | grep -v “vRA SSO login:” | grep -v “IaaS Model Manager login”
2) Update the vRO Service so that the path to run CloudClient is allowed
3) In vRO create an action called ccRunVraCommand that can generically call CloudClient:
var ccScript = “runVraCommand.sh”
var fullCmd;
if (iaasUser != null && iaasUser != “”){
fullCmd = clmDir + ccScript + ” -s ” + server + ” -u ” + user + ” -p ” + password + ” -t ” + tenant + ” -i ” + iaasUser + ” -x ” + iaasPassword + ” ” + command;
} else {
fullCmd = clmDir + ccScript + ” -s ” + server + ” -u ” + user + ” -p ” + password + ” -t ” + tenant + ” ” + command;
}
var cmd = new Command(fullCmd);
cmd.execute(true);
var cmdOut = cmd.output;
return cmdOut;
4) Sample Scripting Action to invoke
var cmd = “vra catalog detail –id \”Sample Catalog Item\” –format JSON”;
var result = System.getModule(“com.vmware.test.cloudclient”).ccRunVraCmd(“server”,”vsphere.local”, “user1@vmware,com”, “password”, “”,””, cmd);
return result;
Output in JSON for easy vRO parsing:
{
“catalogItem” : {
“callbacks” : null,
“catalogItemTypeRef” : {
“id” : “com.vmware.csp.core.designer.service.serviceblueprint”,
“label” : “Sample Catalog Item”
},
“dateCreated” : “2015-03-23T14:08:05.540+0000”,
“description” : “Sample Catalog Item”,
“forms” : {
“itemDetails” : {
“type” : “external”,
“formId” : “com.vmware.csp.core.designer.service.serviceblueprint_ServiceBlueprint.Details”
},
“requestDetails” : {
“type” : “external”,
“formId” : “com.vmware.csp.core.designer.service.serviceblueprint_Request.Details”
},
“requestPostApproval” : null,
“requestPreApproval” : null,
“requestSubmission” : {
“type” : “external”,
“formId” : “com.vmware.csp.core.designer.service.serviceblueprint_Request.Submit”
},
“catalogRequestInfoHidden” : true,
“requestFormScale” : “BIG”
},
“iconId” : “d4bb8a94-c20c-435f-9421-ec984d1bcf42”,
“id” : “d4bb8a94-c20c-435f-9421-ec984d1bcf42”,
“isNoteworthy” : false,
“lastUpdatedDate” : “2015-03-23T22:34:20.945+0000”,
“name” : “Add DNS A Record”,
“organization” : {
“tenantRef” : “vsphere.local”,
“tenantLabel” : “vsphere.local”,
“subtenantRef” : “d20e6b53-9c65-4a52-94e0-fdf58202c545”,
“subtenantLabel” : “BG1”
},
“outputResourceTypeRef” : null,
“providerBinding” : {
“bindingId” : “0931a10e-7f00-42f0-8de8-12fe12aac242”,
“providerRef” : {
“id” : “cbc03019-968f-4af0-803b-202e2b81f73b”,
“label” : “Advanced Designer Service”
}
},
“serviceRef” : {
“id” : “822ab72c-2f4d-4fe9-b3e6-bfe7b1fad2f0”,
“label” : “Infra”
},
“status” : “PUBLISHED”,
“statusName” : “Published”,
“version” : 4
},
“form” : [ {
“key” : “provider-__ASD_PRESENTATION_INSTANCE”,
“value” : null,
“required” : “false”,
“dataType” : “string”,
“providerProperty” : null
}, {
“key” : “provider-hostname”,
“value” : “Hostname (not FQDN)”,
“required” : “false”,
“dataType” : “string”,
“providerProperty” : null
}, {
“key” : “provider-ip”,
“value” : “IP Address”,
“required” : “false”,
“dataType” : “string”,
“providerProperty” : null
} ]
}
Leave a Reply