- Write a Bash script that prompts the user to enter her favourite animal and favourite cartoon character and displays the entered output in a message on the terminal.
read -p "What's your favourite animal? " favanimal
read -p "What's your cartoon character? " favchar
echo "Your favourite animal is" $favanimal
echo "Your cartoon character is is" $favchar
- Write a Bash script that creates the following directory structure:
tempdir/
├── Exercise1/
│ ├── templates/
│ └── static
└── Exerecise2
├── templates/
└── static
mkdir -p ./tempdir/Exercise{1,2}/{templates,static}
-
File permission.
-
What does the command line
chmod u+rwx,g+rx,o+rx myfile.sh
do?Add read write execute to owner, read execute to group, read execute to other
-
What is the equivalent number format for the command above?
755
-
-
Write command line commands to perform the following Docker operations:
-
Pull the latest version of the “serverx” Docker image from Docker Hub.
docker pull docker.io/library/serverx:latest
-
Run a Docker container named “my-serverx” using the “server” image, mapping host port 1234 to container port 80, and running the container in the background.
docker run -d --name my-serverx -p 1234:80 docker.io/library/serverx
-
List all running Docker containers.
docker ps
-
Stop and remove the "my-serverx" container.
docker stop my-serverx && docker rm my-serverx
-
-
Answer the following questions based on the Ansible playbook execution output.
PLAY [Example Playbook] ***********************************************
TASK [Display Hostname] ***********************************************
changed: [target_host]
TASK [Display System Information] *************************************
changed: [target_host]
PLAY RECAP ************************************************************
target_host : ok=2 changed=2 unreachable=0 failed=0 skipped=0 rescued=0
-
-
What is the name of the playbook?
Example Playbook
-
Which task in the playbook displayed the hostname of the target host?
Display Hostname
-
How many tasks caused changes in the playbook execution?
2
-
What is the total number of tasks executed in the playbook?
2
-
-
Fill in the blanks with appropriate names that explains the tasks and correct commands for the following playbook .
---
- name: Configure IP address on one interface and shutdown on second interface
hosts: CSR1kv
gather_facts: false
tasks:
- name: Configure IP address and bring up interface1
ios_config:
parents: "interface GigabitEthernet1"
lines:
- ip address 192.168.56.101
- no shutdown
- name: Shutdown interface2
ios_config:
parents: "interface GigabitEthernet2"
lines:
- shutdown
- name: Display summary of IP interfaces
ios_command:
commands:
- show ip interface brief
register: output
- Answer the following questions on YANG tree model below.
ietf-interfaces
├── rw interfaces
│ └── rw interface* [name]
│ ├── rw name string
│ ├── rw description? string
│ ├── rw type string
│ └── rw enabled? boolean
└── ro interfaces-state
└── ro interface* [name]
├── ro name string
├── ro type identityref
├── ro admin-status enumeration
├── ro oper-status enumeration
└── ro last-change? yang:date-and-time
-
-
What is the name of the module specified in the YANG model?
ietf-interfaces
-
Which container in the YANG model defines the configuration data for managing the network interfaces?
interfaces
-
What is the data type of the "name" leaf under the "interface" list?
string
-
Which leaf under "interfaces-state/interface" provides the administrative status of an interface?
admin-status
-
-
Based on Part 6 in Lab 8.3.6, modify the given Python code to configure a new VLAN on the network device using NETCONF. Write a necessary code to create a VLAN with the following details:
VLAN ID: 1001
VLAN Name: Management
description: Management VLAN for network devices
from ncclient import manager
import xml.dom.minidom
m = manager.connect(
host="192.168.56.101",
port=830,
username="cisco",
password="cisco123!",
hostkey_verify=False
)
netconf_filter = """
<filter>
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native" />
</filter>
"""
netconf_hostname = """
<config>
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<hostname>CSR1kv</hostname>
</native>
</config>
"""
netconf_vlan = """
<config>
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<vlan>
<Vlan>
<id>1001</id>
<name>Management</name>
<description>Management VLAN for network devices</description>
</Vlan>
</vlan>
</native>
</config>
"""
# netconf_reply = m.get_config(source="running", filter=netconf_filter) # get config
netconf_reply = m.edit_config(target="running", config=netconf_vlan)
print(xml.dom.minidom.parseString(netconf_reply.xml).toprettyxml())
- Find all SIX (6) errors in the NETCONF Python code below.
from ncclient import leader # 1. leader -> manager
m = leader.connect( # 2. leader -> manager
host="192.168.56.101",
port=880, # 3. 880 -> 830
username="cisco",
password="cisco123!",
hostkey_verify=False
)
print("Supported Capabilities:")
for cap in m.server_capabilities:
print(cap)
netconf_reply = m.get_config(source="run")
print(netconf_reply.xml)
netconf_filter = """
<filter>
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native" />
""" # 4. </filter>
netconf_reply = m.get_config(source="run", filter=netconf_filter)
print(netconf_reply.xml)
netconf_hostname = """
<config>
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<hostname>CSR1kv
</native>
</config>
""" # 5. <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native" />
# 6. </hostname>
netconf_reply = m.edit_config(target="running", config=netconf_hostname)
print(netconf_reply.xml)
- The following RESTCONF Python code produces this output.
import requests
api_url = "https://example.com/restconf/data/ietf-interfaces:interfaces"
headers = {
"Accept": "application/yang-data+json",
"Content-Type": "application/yang-data+json"
}
response = requests.get(api_url, headers=headers)
print(response)
print(response.json())
<Response [404]>
{'error': {'code': 404, 'message': 'Resource Not Found'}}
-
-
Which RESTCONF endpoint is being accessed in the code?
interfaces
-
What is the purpose of the 'Accept' header in the code?
Which content types the client is able to understand
-
What is the expected format of the request payload?
application/yang-data+json
-
What does <Response [404]> means?
Server cannot find requested resource
-
What would be the HTTP response code if the RESTCONF operation was successful?
200
-