Create NEXUS Account in UCSD

Version 4
    Task NameCreating a NEXUS Account in UCSD
    Description
    Prerequisites
    1. Tested on 5.3.1
    CategoryWorkflow
    ComponentsvSphere 5.x
    User Inputs

    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 .WFD file resides. Choose the .WFD 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.

     

    Thank you Tejeswar Sahu for providing this.


    The custom task and task to import:


    Screen Shot 2015-07-01 at 3.35.19 PM.png



    The workflow:


    Screen Shot 2015-07-01 at 3.37.18 PM.png


    The workflow inputs:


    Screen Shot 2015-07-01 at 3.37.47 PM.png


    The custom workflow inputs:


    Screen Shot 2015-07-01 at 3.38.26 PM.png


    The script:


    importPackage(java.lang);

    importPackage(java.util);

    importPackage(com.cloupia.lib.cIaaS.network.model);//DeviceCredential

    importPackage(com.cloupia.feature.networkController.model);//NetworkPersistenceUtil

    importPackage(java.util.regex);

    importPackage(java.net);

    importPackage(com.cloupia.service.cIM.inframgr);//InfrastructureDataUtil

     

     

    var podName = input.pod;

    var deviceIP = input.ip

    var protocol = input.protocol;

    var port = input.port;

    var login = input.login;

    var password = input.password;

    var deviceCreds;

    function addNetworkElementOfCiscoNexusType()

    {

     

     

    logger.addInfo(":"+podName+":"+deviceIP+":"+protocol+":"+port+":"+login+":"+password+":");

    createDeviceCredentialObject();

    validateInputs();

    /*var deviceCreds = new DeviceCredential();

    deviceCreds.setDatacenter(podName);

    //DeviceCategoryLOVProvider.CATEGORY_NXOS_DEVICE_ID = "nxos"

    deviceCreds.setDeviceCategory(DeviceCategoryLOVProvider.CATEGORY_NXOS_DEVICE_ID);

    deviceCreds.setDeviceIp(deviceIP);

    deviceCreds.setProtocol(protocol);

    deviceCreds.setPort(port);

    deviceCreds.setLogin(login);

    deviceCreds.setPassword(password);*/

     

     

    NetworkPersistenceUtil.addDeviceCredential(deviceCreds);

    }

    function validateDeviceIP(){

    var regex = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";

    var pattern = Pattern.compile(regex);

    var matcher =  pattern.matcher(deviceIP);

     

     

       if(matcher.matches() == false) {

     

       logger.addError("Ip Address :" +deviceIP+ ": is of invalid format.Please provide valid Ip address as input.");

       ctxt.setFailed("input DeviceIP validation failed");

       ctxt.exit();

     

     

       } else {

     

     

       logger.addInfo("input Device IP address validation passed for:" + deviceIP);

      }

     

     

    }

    function isDeviceIPAlreadyUsed(){

    var isUsed = NetworkPersistenceUtil.isDeviceIPUsed(deviceIP,podName);

    if(isUsed){

    logger.addError("The IP Address :" + deviceIP + ": is already used in the datacenter :" + podName);

    ctxt.setFailed("The IP Address is already used.");

       ctxt.exit();

    }

    }

    function isDeviceReachable(){

    var ipAddr = InetAddress.getByName(deviceIP);

            var isReachable = ipAddr.isReachable(30000);

            logger.addInfo("isDeviceReachable:"+isReachable);

      if(!isReachable){

      logger.addError("The device IP:"+deviceIP+" is not reachable.");

      ctxt.setFailed("The device IP is not reachable.");

       ctxt.exit();

    }

    }

    function isValidLoginOrPassword(){

    var errMsg = new StringBuffer("");

    var deviceTypeNumeric = DeviceCategoryLOVProvider.DeviceTypeMp.get(DeviceCategoryLOVProvider.CATEGORY_NXOS_DEVICE_ID);

    var validConnection = InfrastructureDataUtil.isValidNetworkDeviceForDC(deviceCreds, deviceTypeNumeric, DeviceCategoryLOVProvider.CATEGORY_NXOS_DEVICE_ID, errMsg, true, true);

    if(!validConnection){

    logger.addError("Invalid login or password:"+errMsg);

    ctxt.setFailed("Invalid login or password");

    ctxt.exit();

    }

    }

    function validateInputs(){

    validateDeviceIP();

    isDeviceReachable();

    createDeviceCredentialObject();

    isValidLoginOrPassword();

    isDeviceIPAlreadyUsed();

    logger.addInfo("Validation got successful.");

    }

    function createDeviceCredentialObject(){

    deviceCreds = new DeviceCredential();

    deviceCreds.setDatacenter(podName);

    //DeviceCategoryLOVProvider.CATEGORY_NXOS_DEVICE_ID = "nxos"

    deviceCreds.setDeviceCategory(DeviceCategoryLOVProvider.CATEGORY_NXOS_DEVICE_ID);

    deviceCreds.setDeviceIp(deviceIP);

    deviceCreds.setProtocol(protocol);

    deviceCreds.setPort(port);

    deviceCreds.setLogin(login);

    deviceCreds.setPassword(password);

    }

     

     

    addNetworkElementOfCiscoNexusType();