09-16-2016 11:07 AM - edited 03-01-2019 06:43 AM
Task Name | Tenant / Profile resulting EPG and Node name |
Description | |
Prerequisites |
|
Category | Workflow |
Components | vSphere 5.x |
User Inputs | |
Output |
Instructions for Regular Workflow Use:
A big thank you goes to Tejeswar Sahu for the contribution.
The workflow:
Where some of the input parameters come from within the APIC controller:
Execution of workflow:
The Cloupia/Java Script:
logger.addInfo("Script starts here");
importPackage(com.cloupia.feature.apic.util);
importPackage(com.cloupia.fw.objstore);
importPackage(com.cloupia.lib.cIaaS.apic.command.model);
importPackage(java.lang);
importPackage(java.util);
var apicTenant = ApicPersistenceUtil.getTenantByIdentity("APIC@zmn81");
var accountName = apicTenant.getAccountName();
var tenantName = apicTenant.getName();
var appProfileName = "zmn81_AP";
function getAllEPGByAccountNameTenantNameAndAppProfileName(accountName, tenantName, appProfileName) {
try {
var store = ObjStoreHelper.getStore(new TenantEPG().getClass());
var epgList = store.query("accountName == '" + accountName + "' && tenantName == '" + tenantName + "' && approfName == '" + appProfileName + "'");
if ((epgList == null) || (epgList.size() == 0)) {
return null;
} else {
return epgList;
}
} catch (e) {
logger.addError("Exception occurred while querying EPG list :" + e);
}
}
function getAllStaticNodeAssociatedToTenantEPG(epgName) {
try {
var store = ObjStoreHelper.getStore(new StaticNodeToEPG().getClass());
var nodeList = store.query("epgName == '" + epgName + "'");
if ((nodeList == null) || (nodeList.size() == 0)) {
return null;
} else {
return nodeList;
}
} catch (e) {
logger.addError("Exception occurred while querying Node list :" + e);
}
}
var epgList = getAllEPGByAccountNameTenantNameAndAppProfileName(accountName, tenantName, appProfileName);
if (epgList != null) {
for (var count = 0; count < epgList.size(); count++) {
epgName = epgList.get(count).getName();
logger.addInfo("list item EPG NAME: " + epgName);
var nodeList = getAllStaticNodeAssociatedToTenantEPG(epgName);
if (nodeList != null) {
for (var count1 = 0; count1 < nodeList.size(); count1++) {
staticNode = nodeList.get(count1).gettDn();
logger.addInfo("Static Node Name: " + staticNode);
}
}
}
}
logger.addInfo("Here comes the end of script");
Hi
Tried it but i failed what is the differrent settings that need to be Put in to make it work
Sep 20, 2016 13:08:23 UTC Task: Test_cloupia_script (ExecuteCloupiaScript) failed with error - TypeError: null has no such function 'getAccountName' in <eval> at line number 9, selectedContext=<None>
so in my case the full account name turned out to be this
APIC@zmn81
which is the APIC cloud name = APIC and the actual account name zmn81.
I got the same error before as well when I only used zmn81
Hi
Hmm so there should be something else i suppose, what is the script asking for what is the account name defintion the ACI POD name and the account for the admin account in the APIC or UCSD?
Sep 20, 2016 14:02:28 UTC Task: Test_cloupia_script (ExecuteCloupiaScript) failed with error - <eval>:9:61 Expected , but found error var accountName = apicTenant.getAccountName(APIC-POD1-XXX-LAB@admin); ^ in <eval> at line number 9 at column number 61, selectedContext=<None>
above I have a picture on my account name
APIC && .....
that display you get when you hit the little gear on the right side of the screen and add the ID column to the display.
Un less you called your APIC Icon in the converged view APIC-POD1-xxx-LAB
Hi
:-) Got it the account name is APIC-POD1-xxx-LAB and the network icon is also the same , okay and then the
APIC-POD1-xxx-LAB@YYY in your case is the user name ( YYY) for what ? login into the APIC to get access to the ACI system or ?
in this below you are only using var apic tenant and var acconunt is empty is that who is should be `?
var apicTenant = ApicPersistenceUtil.getTenantByIdentity("APIC@zmn81");
var accountName = apicTenant.getAccountName();
I
zmn81 is the tenant name. There is a screen shot on the top of this post.
apicTenant. gets filled by the above line var apicTenant = ApicPersistenceUtil.getTenantByIdentity("APIC@zmn81");
from the object it is getting the account name...
accountName = apicTenant.getAccountName();
Hi
Nice it works
Where will the result get shown ? the EPG list ?
Currently just in the SR log
logger.addInfo("Static Node Name: " + staticNode);
but would be easy to create out put variables and pass them back to the workflow.
Take a look at my latest posting UCSD - Case Sensitive / Insensitive VM Name Search Example
2 different ways to get from a function and a global var with in the java script the output back to the workflow.
Hi
Ok thanks where is the SR log who can I find it ?
As admin please goto
Organizations -> Service Requests
Select a SR ID - Double click on it and you get this window:
When you select the log tab and hit refresh you get the whole log
or hit refresh while it is executing many times and you see the workflow as it is running putting messages in here.
Yes
Thanks
I see that, where can I find the EPG –list I tried to lock in the log and so on but no luck yet ☺
/Ola
I see the EPG's from the converged view - Select APIC controller
Finde tenant and double click:
There is an EPG TAB:
In the code it is dumped into the log
epgName = epgList.get(count).getName();
logger.addInfo("list item EPG NAME: " + epgName);
Hi
thanks , got it after choosing tenants health and the "customize table Columns" "Report _Id" it showed up, in deep tech steps here :-)
/Ola
oh yes - but the cool thing you can write very custom items in UCSD. When you do few of these it becomes second nature.
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: