Tips for Formatting Datacenter Automation Output
The "Datacenter Automation Utilities", also known as DCA, PowerPack includes run book automation and action policies that assist with general-purpose activities for other installed Automation PowerPacks. Within this powerpack there are multiple RunBooks that assist you in formatting the output of the data. This includes prettifying the data for the SL1 UI or formatting the data to send to other systems such as ServiceNow. This is already configured for Out-of-the-box automations, but there are a few things to consider when using your own commands. With, the data structure must be in a specific format. The data must be passed as a dictionary, the name of the key must be “command_list_out”, the data must be a list of tuples with the tuple containing three objects. The three objects should be: 1. The name of the automation being performed The output of the command/API call/etc. The word “False” or “None”, meaning no further flags need to be passed The RBA output should look something like this for a single command: command = “df -h” (stdin, stdout, stderr) = client.exec_command(command) Output_of_command = stdout.read() EM7_RESULT = {“command_list_out”: [(‘Running df -h’, Output_of_command, None)]} In the above example: “{}” – symbolizes the data structure is a dictionary “command_list_out” – the key of the dictionary “:” – required to separate key and value pair “[]” - symbolizes the data structure is a list “()” - symbolizes the data structure is a tuple “Running df -h” – this is the description of what is being performed, this can be free text and say whatever you would like “,” – separates each index in the tuple “Output_of_command” – this is the output of the command df -h being ran against the device “None” – a requirement that says nothing else to be passed for the custom flags in the python library. The RBA output should look something like this for a multiple command: command1 = “df -h” command2 = “ping -c 15 -i 2 google.com” (stdin, stdout, stderr) = client.exec_command(command1) Output_of_command1 = stdout.read() (stdin, stdout, stderr) = client.exec_command(command2) Output_of_command2 = stdout.read() EM7_RESULT = {“command_list_out”: [(‘Running df -h’, Output_of_command1, None), (‘Running ping, Output_of_command2, None)]} In the above example: “{}” – symbolizes the data structure is a dictionary “command_list_out” – the key of the dictionary “:” – required to separate key and value pair “[]” - symbolizes the data structure is a list “()” - symbolizes the data structure is a tuple “Running df -h” – this is the description of what is being performed, this can be free text and say whatever you would like “,” – separates each index in the tuple “Output_of_command1” – this is the output of the command df -h being ran against the device “Output_of_command2” – this is the output of the command ping being ran against google.com “None” – a requirement that says nothing else to be passed for the custom flags in the python library. Note: The difference with the multiple commands versus the single commands are the extra tuple. Meaning that after the first parenthesis is closed off a comma can now be passed to start the new tuple with the new output of commands.43Views2likes0Comments