Home > Automation Questions 2

Automation Questions 2

March 16th, 2020 in ENCOR 350-401 Go to comments

Question 1

Explanation

The words “try” and “except” are Python keywords and are used to catch exceptions. For example:

try:
 print 1/0
except ZeroDivisionError:
 print "Error! We cannot divide by zero!!!" 

Question 2

Explanation

If we have a JSON string, we can parse it by using the json.loads() method so we don’t need to have a response server to test this question. Therefore, in order to test the result above, you can try this Python code:

import json
json_string = """
{
 "ins_api": { <!!!Please copy the code above and put here. We omitted it to save some space!!!>
 }
}
""" 
response = json.loads(json_string)

print(response['ins_api']['outputs']['output']['body']['kickstart_ver_str'])

And this is the result:

Python_JSON_print.jpg

Note:
+ If you want to run the full code in this question in Python (with a real HTTP JSON response), you must first install “requests” package before “import requests”.
+ The error “NameError: name ‘json’ is not defined” is only shown if we forgot the line “import json” in Python code -> Answer A is not correct.
+ We only see the “KeyError” message if we try to print out an unknown attribute (key). For example:

print(response['ins_api']['outputs']['output']['body']['unknown_attribute'])

Python_error_unknow_attribute.jpg
+ Triple quotes (“””) in Python allows strings to span multiple lines, including verbatim NEWLINEs, TABs, and any other special characters.

Question 3

Explanation

Cisco IOS XE supports the Yet Another Next Generation (YANG) data modeling language. YANG can be used with the Network Configuration Protocol (NETCONF) to provide the desired solution of automated and programmable network operations. NETCONF(RFC6241) is an XML-based protocol that client applications use to request information from and make configuration changes to the device. YANG is primarily used to model the configuration and state data used by NETCONF operations.

Reference: https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst9500/software/release/16-5/configuration_guide/prog/b_165_prog_9500_cg/data_models.pdf

Note: Although NETCONF also uses XML but XML is not a data modeling language.

Question 4

Explanation

The 404 (Not Found) error status code indicates that the REST API can’t map the client’s URI to a resource but may be available in the future. Subsequent requests by the client are permissible.

Reference: https://restfulapi.net/http-status-codes/

Question 5

Explanation

A 401 error response indicates that the client tried to operate on a protected resource without providing the proper authorization. It may have provided the wrong credentials or none at all.

Note: A 4xx code indicates a “client error” while a 5xx code indicates a “server error”.

Reference: https://restfulapi.net/http-status-codes/

Question 6

Question 7

Explanation

The Southbound API is used to communicate with network devices.

Southbound_Northbound_APIs.jpg

Question 8

Explanation

To enable the action of printing data directly to the local tty when an Embedded Event Manager (EEM) applet is triggered, use the action puts command in applet configuration mode.

The following example shows how to print data directly to the local tty:

Router(config-applet)# event manager applet puts
Router(config-applet)# event none
Router(config-applet)# action 1 regexp “(.*) (.*) (.*)” “one two three” _match _sub1
Router(config-applet)# action 2 puts “match is $_match”
Router(config-applet)# action 3 puts “submatch 1 is $_sub1”
Router# event manager run puts
match is one two three
submatch 1 is one
Router#

The action puts command applies to synchronous events. The output of this command for a synchronous applet is directly displayed to the tty, bypassing the syslog.

Reference: https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/eem/command/eem-cr-book/eem-cr-a1.html

Question 9

Explanation

JSON data is written as name/value pairs.
A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value:
“name”:”Mark”

JSON can use arrays. Array values must be of type string, number, object, array, boolean or null. For example:
{
“name”:”John”,
“age”:30,
“alive”:true,
“cars”:[ “Ford”, “BMW”, “Fiat” ]
}

Question 10

Explanation

Agentless tool means that no software or agent needs to be installed on the client machines that are to be managed. Ansible is such an agentless tool. In contrast to agentless tool, agent-based tool requires software or agent to be installed on the client. Therefore the master and slave nodes can communicate directly without the need of high-level language interpreter.

An agentless tool uses standard protocols, such as SSH, to push configurations down to a device (and it can be considered a “messaging system”).

Question 11

Explanation

Yet Another Next Generation (YANG) is a language which is only used to describe data models (structure). It is not XML or JSON.

Question 12

Explanation

With Synchronous ( sync yes), the CLI command in question is not executed until the policy exits. Whether or not the command runs depends on the value for the variable _exit_status. If _exit_status is 1, the command runs, if it is 0, the command is skipped.

Comments
  1. Ciscolad
    March 18th, 2020

    Question 10

    Which statement about agent-based versus agentless configuration management tools is true?
    A. Agentless tools require no messaging systems between master and slaves.
    B. Agentless tools use proxy nodes to interface with slave nodes.
    C. Agent-based tools do not require a high-level language interpreter such as Python or Ruby on slave nodes.
    D. Agent-based tools do not require installation of additional software packages on the slave nodes.

    Answer: C (should be A)

    Explanation

    Agentless tool means that no software or agent needs to be installed on the client machines that are to be managed. Ansible is such an agentless tool. In contrast to agentless tool, agent-based tool requires software or agent to be installed on the client. Therefore the master and slave nodes can communicate directly without the need of high-level language interpreter.

  2. @ciscolad
    March 24th, 2020

    According to your explanation,

    -agentless tool:require messaging systems between master and slaves
    -agent-based tool:not require a high-level language interpreter

    right?seems C is correct…

  3. Hamouda
    April 23rd, 2020

    which answer is correct
    Question 10

    Which statement about agent-based versus agentless configuration management tools is true?
    A. Agentless tools require no messaging systems between master and slaves.
    B. Agentless tools use proxy nodes to interface with slave nodes.
    C. Agent-based tools do not require a high-level language interpreter such as Python or Ruby on slave nodes.
    D. Agent-based tools do not require installation of additional software packages on the slave nodes.

  4. Aussie
    April 27th, 2020

    I have seen different answers for Q 10 so not sure if anyone could help
    D
    A
    and offcourse C here
    not sure which is correct

  5. Billy
    May 4th, 2020

    Question 10:
    Agent based tools needs DSL to be installed which is a high level language interpreter
    However, I’m not sure about the meaning of “no messaging system”… does SSH can be classified as messaging system?

  6. Anonymous
    June 21st, 2020

    why i can’t find questions ?1 only answers !!

  7. Jay
    June 21st, 2020

    What is question for #11?

  8. Jay
    June 21st, 2020

    sorry, i mean for #12?

  9. GZ
    July 9th, 2020

    Question 10

    Which statement about agent-based versus agentless configuration management tools is true?
    A. Agentless tools require no messaging systems between master and slaves.
    B. Agentless tools use proxy nodes to interface with slave nodes.
    C. Agent-based tools do not require a high-level language interpreter such as Python or Ruby on slave nodes.
    D. Agent-based tools do not require installation of additional software packages on the slave nodes.
    Correct answer C
    Explanations:
    A. (Incorrect) Agentless tools such as Ansible do need SSH (messaging system) between master and slave otherwise how will they communicate.
    B. (Incorrect) only agent-based tools use proxy agents on the clients.
    C (Correct) Agent-based tools such as Chef, Puppet, SaltStack require instillation of special software (agent) on the client nodes. The server node then talks with the agent directly and there is no need of a high-level language interpreter such as Python or Ruby on slave nodes.
    D. (Incorrect) Agent-based tools such as Chef, Puppet, SaltStack do require installation of additional software packages (agents) on the slave nodes.

  10. I.L.I.
    November 9th, 2020

    Q10:
    – C is wrong, e.g. Puppet and Chef are agent-based tools but they use Ruby.
    – A is better answer, by “messaging system” they probably mean a specialized platform, e.g. 0MQ used by SaltStack. We shouldn’t consider SSH, SNMP etc. as messaging systems.

  1. No trackbacks yet.