UCSD - APIC/ACI Example Given Tenant / Profile resulting EPG and Node name

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