DevNet Flashcards
What are the three main parts of the yang model?
modular router {
namespace “https://devnet-academy.com/router”;
prefix “router”;
container router { // TODO Create leaf ID and hostname // TODO Create a list interface with leaf name, address, netmask, and description //TODO Make sure to add a key list interface { } } }
Create a leaf list ID and Host name for router.yang
module router {
namespace “https://devnet-academy.com/router”;
prefix “router”;
container router {
leaf id {
type string;
}
leaf hostname {
type string;
}
Create a list interface with leaf name, IP address, netmask, and description for router.yang. Make sure to add a key.
module router {
namespace “https://devnet-academy.com/router”;
prefix “router”;
container router {
// TODO Create leaf id and hostname
leaf id {
type string;
}
leaf hostname {
type string;
}
// TODO Create list interface with leaf name, ip-address, netmask and description
// TODO Make sure to add a key
list interface {
key “name”;
leaf name {
type string;
}
leaf ip-address {
type string;
}
leaf netmask {
type string;
}
leaf description {
type string;
}
}
}
What is the header for the corresponding router.xml?
<?xml version=”1.0” encoding=”UTF-8”?>
<data>
</data>
Start a Vault server in development mode (dev server).
vault server -dev
steps to create vault on Docker
$ docker pull hashicorp/vault
$ docker images
$ docker run –name vault -p 8200:8200 hashicorp/vault:latest
You might have to set these two environment variables. Otherwise yang2dsdl will not work.
$ export PYANG_XSLT_DIR=$HOME/venvs/main/share/yang/xslt
$ export PYANG_RNG_LIBDIR=$HOME/venvs/main/share/yang/schema
Command to convert .yang file to XML format (with annotations)
payang -f sample-xml-skeleton –sample-xml-skeleton-annotaitons router.yang
Yang RFC-#
7950
Providing Privilege Access to Use NETCONF
enable
configure terminal
username name privilege level(must be 15 for NETCONF) password password
aaa new-model
aaa authentication login default local
aaa authorization exec default local
end
Configuring NETCONF-YANG
enable
configure terminal
netconf-yang
netconf-yang feature candidate-datastore
exit
Import the ncclient manager
Import the ncclient manager
from ncclient import manager
using ncclient Connect to the device you want to configure
Connect to the device you want to configure
router = manager.connect(
host=”1.1.1.1”,
username=”developer”,
password=”C1sco12345”,
hostkey_verify=False
)
pyang tree command
pyang -f tree router.yang
validate xml file
yang2dsdl -v router.xml router.yang
steps to create and validate yang model
- validate shema - payng -f tree ——
- convert .yang to xml format
- validate .xml
@api.route(“/network/inventory”)
class NetworkInventory(Resource):
@api.\_\_\_\_(get_inventory_parser) def get(self): args = get_inventory_parser.parse_args() if args.\_\_\_\_\_\_\_: matched_inventory = {} for \_\_\_\_\_\_, \_\_\_\_\_ in \_\_\_\_\_.items(): if \_\_\_.hostname in hostname: matched_inventory[\_\_\_\_\_\_\_] = \_\_\_\_\_\_ return matched_inventory , 200 elif args.\_\_\_: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ = {} for hostname, \_\_\_\_\_\_\_\_\_\_ in inventory.\_\_\_\_(): if \_\_\_\_.type == \_\_\_\_\_\_\_\_: \_\_\_\_\_\_\_\_\_\_\_[hostname] = devicetype return \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ , 200 else: return \_\_\_\_\_\_\_\_\_ , 200
@api.route(“/network/inventory”)
class NetworkInventory(Resource):
@api.expect(get_inventory_parser) def get(self): args = get_inventory_parser.parse_args() if args.hostname: matched_inventory = {} for hostname, devicetype in inventory.items(): if args.hostname in hostname: matched_inventory[hostname] = devicetype return matched_inventory , 200 elif args.type: matched_inventory = {} for hostname, devicetype in inventory.items(): if args.type == devicetype: matched_inventory[hostname] = devicetype return matched_inventory , 200 else: return inventory , 200