Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/tutorials/data/ios/config.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
hostname csr1000v-1
!
ip name-server 8.8.8.8
!
ntp server 2610:20:6F96:96::6
ntp server 129.6.15.29
!
ip ssh version 2
ip ssh time-out 60
!
username developer privilege 15 secret 9 $9$fhUXi6Xg438iAE$..VhXRCHiDQy3K2zmZUl9iZLbQJ9wpUtQZwQxSRESc2
username cisco privilege 15 secret 9 $9$COf3Q4xfzT.JxE$L3hvSkDv874Qrh8Hzdv/rPQjLNOjreYG2ocffHG7rls
username root privilege 15 secret 9 $9$FfUDIPBFcs03AE$MyLIWEuiRle8p3yGflAGTcrJA6BUUh/oWtyyfoMQXSI
username newuser80 password 0 Yu76_87AF
!
interface FastEthernet1
description This is Fa1
shutdown
Expand Down
15 changes: 15 additions & 0 deletions docs/tutorials/data/ios/new_config.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
hostname csr1000v-1
!
ip name-server 8.8.8.8
!
ntp server 2610:20:6F96:96::6
ntp server 129.6.15.29
!
ip ssh version 2
ip ssh time-out 60
!
username developer privilege 15 secret 9 $9$fhUXi6Xg438iAE$..VhXRCHiDQy3K2zmZUl9iZLbQJ9wpUtQZwQxSRESc2
username cisco privilege 15 secret 9 $9$COf3Q4xfzT.JxE$L3hvSkDv874Qrh8Hzdv/rPQjLNOjreYG2ocffHG7rls
username root privilege 15 secret 9 $9$FfUDIPBFcs03AE$MyLIWEuiRle8p3yGflAGTcrJA6BUUh/oWtyyfoMQXSI
username newuser80 password 0 Yu76_87AF
!
interface FastEthernet1
description This is Fa1
shutdown
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/ios_merging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
255 changes: 209 additions & 46 deletions docs/tutorials/ios_navigating_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"from ntc_rosetta import get_driver\n",
"\n",
"ios = get_driver(\"ios\", \"openconfig\")\n",
Expand All @@ -39,54 +40,216 @@
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"execution_count": 5,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'openconfig-interfaces:interfaces': {'interface': [{'name': 'FastEthernet1',\n",
" 'config': {'name': 'FastEthernet1',\n",
" 'type': 'iana-if-type:ethernetCsmacd',\n",
" 'description': 'This is Fa1',\n",
" 'enabled': False},\n",
" 'subinterfaces': {'subinterface': [{'index': 1,\n",
" 'config': {'index': 1, 'description': 'This is Fa1.1'}},\n",
" {'index': 2, 'config': {'index': 2, 'description': 'This is Fa1.2'}}]}},\n",
" {'name': 'FastEthernet3',\n",
" 'config': {'name': 'FastEthernet3',\n",
" 'type': 'iana-if-type:ethernetCsmacd',\n",
" 'description': 'This is Fa3',\n",
" 'enabled': True},\n",
" 'openconfig-if-ethernet:ethernet': {'openconfig-vlan:switched-vlan': {'config': {'interface-mode': 'ACCESS',\n",
" 'access-vlan': 10}}}},\n",
" {'name': 'FastEthernet4',\n",
" 'config': {'name': 'FastEthernet4',\n",
" 'type': 'iana-if-type:ethernetCsmacd',\n",
" 'enabled': False},\n",
" 'openconfig-if-ethernet:ethernet': {'openconfig-vlan:switched-vlan': {'config': {'interface-mode': 'TRUNK',\n",
" 'trunk-vlans': [10, 20]}}}}]},\n",
" 'openconfig-network-instance:network-instances': {'network-instance': [{'name': 'default',\n",
" 'config': {'name': 'default'},\n",
" 'vlans': {'vlan': [{'vlan-id': 10,\n",
" 'config': {'vlan-id': 10, 'name': 'prod', 'status': 'ACTIVE'}},\n",
" {'vlan-id': 20,\n",
" 'config': {'vlan-id': 20, 'name': 'dev', 'status': 'SUSPENDED'}}]}}]}}"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"openconfig-interfaces:interfaces\": {\n",
" \"interface\": [\n",
" {\n",
" \"config\": {\n",
" \"description\": \"This is Fa1\",\n",
" \"enabled\": false,\n",
" \"name\": \"FastEthernet1\",\n",
" \"type\": \"iana-if-type:ethernetCsmacd\"\n",
" },\n",
" \"name\": \"FastEthernet1\",\n",
" \"subinterfaces\": {\n",
" \"subinterface\": [\n",
" {\n",
" \"config\": {\n",
" \"description\": \"This is Fa1.1\",\n",
" \"index\": 1\n",
" },\n",
" \"index\": 1\n",
" },\n",
" {\n",
" \"config\": {\n",
" \"description\": \"This is Fa1.2\",\n",
" \"index\": 2\n",
" },\n",
" \"index\": 2\n",
" }\n",
" ]\n",
" }\n",
" },\n",
" {\n",
" \"config\": {\n",
" \"description\": \"This is Fa3\",\n",
" \"enabled\": true,\n",
" \"name\": \"FastEthernet3\",\n",
" \"type\": \"iana-if-type:ethernetCsmacd\"\n",
" },\n",
" \"name\": \"FastEthernet3\",\n",
" \"openconfig-if-ethernet:ethernet\": {\n",
" \"openconfig-vlan:switched-vlan\": {\n",
" \"config\": {\n",
" \"access-vlan\": 10,\n",
" \"interface-mode\": \"ACCESS\"\n",
" }\n",
" }\n",
" }\n",
" },\n",
" {\n",
" \"config\": {\n",
" \"enabled\": false,\n",
" \"name\": \"FastEthernet4\",\n",
" \"type\": \"iana-if-type:ethernetCsmacd\"\n",
" },\n",
" \"name\": \"FastEthernet4\",\n",
" \"openconfig-if-ethernet:ethernet\": {\n",
" \"openconfig-vlan:switched-vlan\": {\n",
" \"config\": {\n",
" \"interface-mode\": \"TRUNK\",\n",
" \"trunk-vlans\": [\n",
" 10,\n",
" 20\n",
" ]\n",
" }\n",
" }\n",
" }\n",
" }\n",
" ]\n",
" },\n",
" \"openconfig-network-instance:network-instances\": {\n",
" \"network-instance\": [\n",
" {\n",
" \"config\": {\n",
" \"name\": \"default\"\n",
" },\n",
" \"name\": \"default\",\n",
" \"vlans\": {\n",
" \"vlan\": [\n",
" {\n",
" \"config\": {\n",
" \"name\": \"prod\",\n",
" \"status\": \"ACTIVE\",\n",
" \"vlan-id\": 10\n",
" },\n",
" \"vlan-id\": 10\n",
" },\n",
" {\n",
" \"config\": {\n",
" \"name\": \"dev\",\n",
" \"status\": \"SUSPENDED\",\n",
" \"vlan-id\": 20\n",
" },\n",
" \"vlan-id\": 20\n",
" }\n",
" ]\n",
" }\n",
" }\n",
" ]\n",
" },\n",
" \"openconfig-system:system\": {\n",
" \"aaa\": {\n",
" \"authentication\": {\n",
" \"users\": {\n",
" \"user\": [\n",
" {\n",
" \"config\": {\n",
" \"password-hashed\": \"$9$fhUXi6Xg438iAE$..VhXRCHiDQy3K2zmZUl9iZLbQJ9wpUtQZwQxSRESc2\",\n",
" \"role\": \"15\",\n",
" \"username\": \"developer\"\n",
" },\n",
" \"username\": \"developer\"\n",
" },\n",
" {\n",
" \"config\": {\n",
" \"password-hashed\": \"$9$COf3Q4xfzT.JxE$L3hvSkDv874Qrh8Hzdv/rPQjLNOjreYG2ocffHG7rls\",\n",
" \"role\": \"15\",\n",
" \"username\": \"cisco\"\n",
" },\n",
" \"username\": \"cisco\"\n",
" },\n",
" {\n",
" \"config\": {\n",
" \"password-hashed\": \"$9$FfUDIPBFcs03AE$MyLIWEuiRle8p3yGflAGTcrJA6BUUh/oWtyyfoMQXSI\",\n",
" \"role\": \"15\",\n",
" \"username\": \"root\"\n",
" },\n",
" \"username\": \"root\"\n",
" },\n",
" {\n",
" \"config\": {\n",
" \"password\": \"Yu76_87AF\",\n",
" \"username\": \"newuser80\"\n",
" },\n",
" \"username\": \"newuser80\"\n",
" }\n",
" ]\n",
" }\n",
" }\n",
" },\n",
" \"config\": {\n",
" \"hostname\": \"csr1000v-1\"\n",
" },\n",
" \"dns\": {\n",
" \"servers\": {\n",
" \"server\": [\n",
" {\n",
" \"address\": \"8.8.8.8\",\n",
" \"config\": {\n",
" \"address\": \"8.8.8.8\",\n",
" \"port\": 53\n",
" }\n",
" }\n",
" ]\n",
" }\n",
" },\n",
" \"ntp\": {\n",
" \"config\": {\n",
" \"enable-ntp-auth\": false,\n",
" \"enabled\": true\n",
" },\n",
" \"servers\": {\n",
" \"server\": [\n",
" {\n",
" \"address\": \"2610:20:6F96:96::6\",\n",
" \"config\": {\n",
" \"address\": \"2610:20:6F96:96::6\"\n",
" }\n",
" },\n",
" {\n",
" \"address\": \"129.6.15.29\",\n",
" \"config\": {\n",
" \"address\": \"129.6.15.29\"\n",
" }\n",
" }\n",
" ]\n",
" }\n",
" },\n",
" \"ssh-server\": {\n",
" \"config\": {\n",
" \"enable\": true,\n",
" \"protocol-version\": \"V2\",\n",
" \"timeout\": 60\n",
" }\n",
" },\n",
" \"telnet-server\": {\n",
" \"config\": {\n",
" \"enable\": true\n",
" }\n",
" }\n",
" }\n",
"}\n"
]
}
],
"source": [
"raw = parsed.raw_value()\n",
"raw"
"print(json.dumps(raw, sort_keys=True, indent=2))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -112,7 +275,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand All @@ -121,7 +284,7 @@
"'This is Fa1'"
]
},
"execution_count": 4,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -132,7 +295,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -141,7 +304,7 @@
"'This is Fa1.1'"
]
},
"execution_count": 5,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -152,7 +315,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand All @@ -161,7 +324,7 @@
"{'config': {'interface-mode': 'ACCESS', 'access-vlan': 10}}"
]
},
"execution_count": 6,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -187,7 +350,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
Loading