Task Name | Creating a NEXUS Account in UCSD |
Description |
|
Prerequisites | - Tested on 5.3.1
|
Category | Workflow |
Components | vSphere 5.x |
User Inputs | |
Instructions for Regular Workflow Use:
- Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
- Unzip the file on your computer. Should end up with a .WFD file.
- Log in to UCS Director as a user that has "system-admin" privileges.
- Navigate to "Policies-->Orchestration" and click on "Import".
- Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
- Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
- Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
- Click "Submit".
- 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:
The workflow:
The workflow inputs:
The custom workflow inputs:
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();