05-10-2017 02:29 AM - edited 03-01-2019 03:49 AM
Hello Team,
I have a customer that they have a workflow process to configure some Interfaces with HSRP feature in a couple of routers. According to their process, Engineer Team is responsible to produce all router configuration and send them via .DOC file to the Assurance team that is responsible to apply that config in the routers during the maintenance window.
I have spoken with them to use Cisco NSO to deploy this kind of service however they asked me if it is possible to generate all configuration in the NSO but just save it, and then Assurance Team only apply the config. Would be possible to create this workflow process in the NSO? For sure that this way will help them a lot with time and configuration mistakes.
Solved! Go to Solution.
05-10-2017 04:29 AM
NCS CLI can be used to generate preview of these configs as well. API provides an ability to extract the same preview output that would be obtained from CLI. From Config mode of NCS CLI,
To create/modify services — set services <$serviceName> <$KeyParam1Val> <$dyanamicParam2> <$dyanamicParam2Val> …….
Commit dry-run out format native
To delete services — delete services <$serviceName> <$KeyParam1Val>
Commit dry-run out format native
Example for using the NCS RequestActionTh API for accomplishing the same preview as above:
/**
* Execute NCS Commit Dry run Action
*
* @param params
* - an array of ConfXMLParam, parameters for completing the
* action
* @param output
* - A list of ConfXMLParam, parameters for output
* @param maapi
* -- Maapi, session object
* @param th
* -- int, session index
* @param reviewErrIndexNum
* -- String, Error index Number
* @param reviewErrMsg
* -- String, Error index Message
* @param service
* -- String, Service Name
* @throws ConfException
* @throws IOException
*
*/
private void executeNCSCommitDryRun(ConfXMLParam[] params,
List<ConfXMLParam> output, Maapi maapi, int th,
String reviewErrIndexNum, String reviewErrMsg, String service)
throws ConfException, IOException {
ConfNamespace ncsNS = null;
ConfXMLParam[] diffNative = null;
ConfXMLParam[] diff = null;
String previewDiffSetValue = null;
ncsNS = new Ncs();
diffNative = new ConfXMLParam[]{new ConfXMLParamValue(ncsNS.hash(),
Ncs._outformat, new ConfEnumeration(2))};
diff = maapi.requestActionTh(th, diffNative, "/services/commit-dry-run");
previewDiffSetValue = generatePreviewDiffSetValue(ConfXMLParam
.toXML(diff)) != null
? generatePreviewDiffSetValue(ConfXMLParam.toXML(diff))
: "";
LOGGER.info("Extracted Preview Value: " + previewDiffSetValue);
EnterpriseOnboardUtility.setErrorReturn(output,
Integer.parseInt(reviewErrIndexNum), reviewErrMsg,
previewDiffSetValue);
05-10-2017 04:28 AM
Yes, it is possible to just generate the configuration intended for services to be deployed without actually applying them on the routers. We can leverage the commit–dry run feature through an API invocation to generate the native configs.
maapi.requestActionTh(th, diffNative, "/services/commit-dry-run”);
It may be possible to save the generated configs and then have an external workflow process to either retrieve it at a later time for review or if found acceptable by the operators then provide an option (with Approvals) for those configs to be applied on the device.
05-10-2017 04:28 AM
Is there any way using NCS CLI? Or only via any kind of API?
Also, could you show me how to use this example that you sent.
05-10-2017 04:29 AM
NCS CLI can be used to generate preview of these configs as well. API provides an ability to extract the same preview output that would be obtained from CLI. From Config mode of NCS CLI,
To create/modify services — set services <$serviceName> <$KeyParam1Val> <$dyanamicParam2> <$dyanamicParam2Val> …….
Commit dry-run out format native
To delete services — delete services <$serviceName> <$KeyParam1Val>
Commit dry-run out format native
Example for using the NCS RequestActionTh API for accomplishing the same preview as above:
/**
* Execute NCS Commit Dry run Action
*
* @param params
* - an array of ConfXMLParam, parameters for completing the
* action
* @param output
* - A list of ConfXMLParam, parameters for output
* @param maapi
* -- Maapi, session object
* @param th
* -- int, session index
* @param reviewErrIndexNum
* -- String, Error index Number
* @param reviewErrMsg
* -- String, Error index Message
* @param service
* -- String, Service Name
* @throws ConfException
* @throws IOException
*
*/
private void executeNCSCommitDryRun(ConfXMLParam[] params,
List<ConfXMLParam> output, Maapi maapi, int th,
String reviewErrIndexNum, String reviewErrMsg, String service)
throws ConfException, IOException {
ConfNamespace ncsNS = null;
ConfXMLParam[] diffNative = null;
ConfXMLParam[] diff = null;
String previewDiffSetValue = null;
ncsNS = new Ncs();
diffNative = new ConfXMLParam[]{new ConfXMLParamValue(ncsNS.hash(),
Ncs._outformat, new ConfEnumeration(2))};
diff = maapi.requestActionTh(th, diffNative, "/services/commit-dry-run");
previewDiffSetValue = generatePreviewDiffSetValue(ConfXMLParam
.toXML(diff)) != null
? generatePreviewDiffSetValue(ConfXMLParam.toXML(diff))
: "";
LOGGER.info("Extracted Preview Value: " + previewDiffSetValue);
EnterpriseOnboardUtility.setErrorReturn(output,
Integer.parseInt(reviewErrIndexNum), reviewErrMsg,
previewDiffSetValue);
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide