cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5199
Views
1
Helpful
25
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee
Task Name

Tenant / Profile resulting EPG and Node name

Description

Prerequisites
  1. Tested on 6.0
CategoryWorkflow
ComponentsvSphere 5.x
User Inputs
Output

Instructions for Regular Workflow Use:

  1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
  2. Unzip the file on your computer. Should end up with a .WFD file.
  3. Log in to UCS Director as a user that has "system-admin" privileges.
  4. Navigate to "Policies-->Orchestration" and click on "Import".
  5. Click "Browse" and navigate to the location on your computer where the .WFDX file resides. Choose the .WFDX file and click "Open".
  6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
  7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
  8. Click "Submit".
  9. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment

A big thank you goes to Tejeswar Sahu for the contribution.

The workflow:

Screen Shot 2016-09-16 at 12.50.48 PM.png

Where some of the input parameters come from within the APIC controller:

Screen Shot 2016-09-16 at 12.59.46 PM.png

Screen Shot 2016-09-16 at 1.00.05 PM.png

Screen Shot 2016-09-16 at 1.00.15 PM.png

Execution of workflow:

Screen Shot 2016-09-16 at 1.00.44 PM.png

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");

Comments
odahlqvist
Level 4
Level 4

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>

Orf Gelbrich
Cisco Employee
Cisco Employee

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

odahlqvist
Level 4
Level 4

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>

Orf Gelbrich
Cisco Employee
Cisco Employee

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

odahlqvist
Level 4
Level 4

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

Orf Gelbrich
Cisco Employee
Cisco Employee

zmn81 is the tenant name.  There is a screen shot on the top of this post.

Orf Gelbrich
Cisco Employee
Cisco Employee

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();

odahlqvist
Level 4
Level 4

Hi

Nice it works

Where will the result get shown ? the EPG list ?

Orf Gelbrich
Cisco Employee
Cisco Employee

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.

odahlqvist
Level 4
Level 4

Hi

Ok thanks where is the SR log who can I find it ?

Orf Gelbrich
Cisco Employee
Cisco Employee

As admin please goto

     Organizations -> Service Requests

Screen Shot 2016-09-21 at 7.44.00 AM.png

Select a SR ID - Double click on it and you get this window:

Screen Shot 2016-09-21 at 7.44.10 AM.png

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.

Screen Shot 2016-09-21 at 7.44.20 AM.png

odahlqvist
Level 4
Level 4

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

Orf Gelbrich
Cisco Employee
Cisco Employee

I see the EPG's  from the converged view - Select APIC controller

Screen Shot 2016-09-21 at 8.24.42 AM.png

Finde tenant and double click:

Screen Shot 2016-09-21 at 8.26.02 AM.png

There is an EPG TAB:

Screen Shot 2016-09-21 at 8.26.12 AM.png

In the code it is dumped into the log

       epgName = epgList.get(count).getName();

        logger.addInfo("list item EPG NAME: " + epgName);

odahlqvist
Level 4
Level 4

Hi

thanks , got it after choosing tenants health and the "customize table Columns" "Report _Id"  it showed up, in deep tech steps here :-)

/Ola

Orf Gelbrich
Cisco Employee
Cisco Employee

oh yes - but the cool thing you can write very custom items in UCSD.  When you do few of these it becomes second nature.

Getting Started

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:

Quick Links