This repository has been archived by the owner on Mar 7, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace list() with [] and dict() with {} I don't like them anymore :( * Various improvements for get_route_to Also fix #109 * Version 0.5.3 * empty inactive_reason rather than None * Consistent expected output as well * Group neighbors without peer-group under the '_' key Painful stuff here. @itdependsnetworks owes me a beer for that :D * Fix previously wrong mock * Remove too generic Exception * Testcase for #119 * Adapted to more general API * Adding napalm-yang to requirements * Renaming file so py.test doesn't try to run it as a test
- Loading branch information
Showing
11 changed files
with
271 additions
and
149 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
napalm_eos/openconfig_mappings.yaml → ...eos/yang_mappings/parsers/interfaces.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from napalm_eos.eos import EOSDriver | ||
|
||
import napalm_yang | ||
|
||
import pprint | ||
|
||
|
||
eos_configuration = { | ||
'hostname': '127.0.0.1', | ||
'username': 'vagrant', | ||
'password': 'vagrant', | ||
'optional_args': {'port': 12443} | ||
} | ||
|
||
|
||
d = EOSDriver(**eos_configuration) | ||
d.open() | ||
|
||
# Get current interfaces configuration | ||
running = d.parse_config("interfaces") | ||
|
||
# Print the exact model as defined by OC | ||
# This is mostly informative, as quick reference | ||
print(running.model_to_text()) | ||
|
||
# We can get a representation of the data in text | ||
print(running.data_to_text()) | ||
|
||
# Or as a dict | ||
pprint.pprint(running.data_to_dict()) | ||
|
||
# We can also translate the object backto native configuration | ||
print(d.translate_model(running, "interfaces")) | ||
|
||
# Let's change some configuration | ||
candidate = d.parse_config("interfaces") | ||
candidate.interfaces.interface["Management1"].config.description("Connected to oob1:et2") | ||
candidate.interfaces.interface["Ethernet2"].config.description("Connected to spine") | ||
candidate.interfaces.interface["Port-Channel1"].config.description("Connected to blah") | ||
candidate.interfaces.interface["Loopback1"].config.enabled(False) | ||
|
||
# Let's create a new loopback interface | ||
candidate.interfaces.interface.new_element("Loopback0") | ||
candidate.interfaces.interface["Loopback0"].name("Loopback0") | ||
candidate.interfaces.interface["Loopback0"].config.name("Loopback0") | ||
candidate.interfaces.interface["Loopback0"].config.description("loopback0") | ||
candidate.interfaces.interface["Loopback0"].config.enabled(True) | ||
candidate.interfaces.interface["Loopback0"].config.mtu(1500) | ||
candidate.interfaces.interface["Loopback0"].hold_time.config.up(0) | ||
candidate.interfaces.interface["Loopback0"].hold_time.config.down(0) | ||
candidate.interfaces.interface["Loopback0"].config.type_(napalm_yang.ianaift.Softwareloopback) | ||
|
||
# Let's see a diff of the running and the candidate configuration | ||
pprint.pprint(running.diff(candidate)) | ||
|
||
# Let's turn this into native configuration | ||
new_config = d.translate_model(candidate, "interfaces") | ||
print(new_config) | ||
|
||
|
||
# Load it into the device | ||
d.load_merge_candidate(config=new_config) | ||
|
||
# See the diff matches our expectations | ||
print(d.compare_config()) | ||
|
||
# Let's commit the configuration now | ||
d.commit_config() | ||
|
||
# if now get a new running and candidate config, let's compare it with out previous candidate | ||
running = d.parse_config("interfaces") | ||
pprint.pprint(running.diff(candidate)) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
napalm_base>=0.19.0 | ||
pyeapi | ||
-e git+https://github.com/napalm-automation/napalm-yang.git@develop#egg=napalm-yang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...ked_data/test_get_bgp_config/iss199_bgp_neighbors_without_peer_group/expected_result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"_": { | ||
"multipath": false, | ||
"multihop_ttl": 0, | ||
"apply_groups": [], | ||
"export_policy": "", | ||
"import_policy": "", | ||
"remove_private_as": false, | ||
"local_as": 13335, | ||
"local_address": "", | ||
"type": "", | ||
"remote_as": 0, | ||
"prefix_limit": {}, | ||
"description": "", | ||
"neighbors": { | ||
"192.168.0.1": { | ||
"route_reflector_client": false, | ||
"nhs": false, | ||
"authentication_key": "", | ||
"export_policy": "export-policy", | ||
"import_policy": "import-policy", | ||
"local_as": 13335, | ||
"local_address": "", | ||
"remote_as": 32934, | ||
"prefix_limit": {}, | ||
"description": "" | ||
}, | ||
"2001:db8::0:1": { | ||
"route_reflector_client": false, | ||
"nhs": false, | ||
"authentication_key": "", | ||
"export_policy": "export-policy", | ||
"import_policy": "import-policy", | ||
"local_as": 13335, | ||
"local_address": "", | ||
"remote_as": 8403, | ||
"prefix_limit": {}, | ||
"description": "" | ||
}, | ||
"172.17.17.1": { | ||
"route_reflector_client": false, | ||
"nhs": false, | ||
"authentication_key": "", | ||
"export_policy": "export-policy", | ||
"import_policy": "import-policy", | ||
"local_as": 13335, | ||
"local_address": "", | ||
"remote_as": 13414, | ||
"prefix_limit": {}, | ||
"description": "" | ||
}, | ||
"2001:db8::0:2": { | ||
"route_reflector_client": false, | ||
"nhs": false, | ||
"authentication_key": "", | ||
"export_policy": "export-policy", | ||
"import_policy": "import-policy", | ||
"local_as": 13335, | ||
"local_address": "", | ||
"remote_as": 54113, | ||
"prefix_limit": {}, | ||
"description": "" | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...fig/iss199_bgp_neighbors_without_peer_group/show_running_config___section_router_bgp.text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
router bgp 13335 | ||
maximum-paths 32 | ||
neighbor 192.168.0.1 remote-as 32934 | ||
neighbor 192.168.0.1 maximum-routes 100 | ||
neighbor 192.168.0.1 route-map import-policy in | ||
neighbor 192.168.0.1 route-map export-policy out | ||
neighbor 172.17.17.1 remote-as 13414 | ||
neighbor 172.17.17.1 maximum-routes 500 | ||
neighbor 172.17.17.1 route-map import-policy in | ||
neighbor 172.17.17.1 route-map export-policy out | ||
neighbor 2001:db8::0:1 remote-as 8403 | ||
neighbor 2001:db8::0:1 maximum-routes 500 | ||
neighbor 2001:db8::0:1 route-map import-policy in | ||
neighbor 2001:db8::0:1 route-map export-policy out | ||
neighbor 2001:db8::0:2 remote-as 54113 | ||
neighbor 2001:db8::0:2 route-map import-policy in | ||
neighbor 2001:db8::0:2 route-map export-policy out | ||
! |
2 changes: 1 addition & 1 deletion
2
test/unit/mocked_data/test_get_bgp_config/normal/expected_result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"IPv6-PEERS-GROUP-NAME": {"neighbors": {"2001:db8::0:2": {"export_policy": "", "prefix_limit": {}, "import_policy": "", "local_as": 0, "route_reflector_client": false, "nhs": false, "local_address": "", "remote_as": 54113, "authentication_key": "", "description": ""}, "2001:db8::0:1": {"export_policy": "", "prefix_limit": {}, "import_policy": "", "local_as": 0, "route_reflector_client": false, "nhs": false, "local_address": "", "remote_as": 8403, "authentication_key": "", "description": ""}}, "export_policy": "reject-all", "multipath": false, "prefix_limit": {}, "import_policy": "reject-all", "local_as": 0, "multihop_ttl": 0, "apply_groups": [], "remote_as": 0, "remove_private_as": true, "local_address": "", "type": "", "description": ""}, "IPv4-PEERS-GROUP-NAME": {"neighbors": {"192.168.0.1": {"export_policy": "", "prefix_limit": {}, "import_policy": "", "local_as": 0, "route_reflector_client": false, "nhs": false, "local_address": "", "remote_as": 32934, "authentication_key": "", "description": ""}, "172.17.17.1": {"export_policy": "", "prefix_limit": {}, "import_policy": "", "local_as": 0, "route_reflector_client": false, "nhs": false, "local_address": "", "remote_as": 13414, "authentication_key": "", "description": ""}}, "export_policy": "4-public-peer-anycast-out", "multipath": false, "prefix_limit": {}, "import_policy": "reject-all", "local_as": 0, "multihop_ttl": 0, "apply_groups": [], "remote_as": 0, "remove_private_as": true, "local_address": "", "type": "", "description": ""}} | ||
{"IPv4-PEERS-GROUP-NAME": {"local_address": "", "description": "", "type": "", "local_as": 13335, "apply_groups": [], "multihop_ttl": 0, "remove_private_as": true, "remote_as": 0, "import_policy": "reject-all", "export_policy": "4-public-peer-anycast-out", "neighbors": {"172.17.17.1": {"local_address": "", "authentication_key": "", "description": "", "nhs": false, "local_as": 13335, "route_reflector_client": false, "remote_as": 13414, "import_policy": "", "export_policy": "", "prefix_limit": {}}, "192.168.0.1": {"local_address": "", "authentication_key": "", "description": "", "nhs": false, "local_as": 13335, "route_reflector_client": false, "remote_as": 32934, "import_policy": "", "export_policy": "", "prefix_limit": {}}}, "prefix_limit": {}, "multipath": false}, "IPv6-PEERS-GROUP-NAME": {"local_address": "", "description": "", "type": "", "local_as": 13335, "apply_groups": [], "multihop_ttl": 0, "remove_private_as": true, "remote_as": 0, "import_policy": "reject-all", "export_policy": "reject-all", "neighbors": {"2001:db8::0:2": {"local_address": "", "authentication_key": "", "description": "", "nhs": false, "local_as": 13335, "route_reflector_client": false, "remote_as": 54113, "import_policy": "", "export_policy": "", "prefix_limit": {}}, "2001:db8::0:1": {"local_address": "", "authentication_key": "", "description": "", "nhs": false, "local_as": 13335, "route_reflector_client": false, "remote_as": 8403, "import_policy": "", "export_policy": "", "prefix_limit": {}}}, "prefix_limit": {}, "multipath": false}} |
2 changes: 1 addition & 1 deletion
2
test/unit/mocked_data/test_get_route_to/normal/expected_result.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"1.0.4.0/24": [{"protocol": "EBGP", "inactive_reason": "", "last_active": true, "age": 0, "routing_table": "default", "next_hop": "192.168.0.1", "outgoing_interface": "", "preference": 200, "current_active": true, "selected_next_hop": true, "protocol_attributes": {"local_preference": 50, "remote_as": 43515, "communities": ["1299:1234", "1299:5678", "1299:91011", "1299:12134"], "preference2": 0, "metric": 0, "local_as": 13335, "as_path": "1299 15169 43515", "remote_address": "192.168.0.1"}}]} | ||
{"1.0.4.0/24": [{"next_hop": "192.168.0.1", "preference": 200, "protocol": "eBGP", "selected_next_hop": true, "current_active": true, "routing_table": "default", "protocol_attributes": {"remote_as": 43515, "as_path": "1299 15169 43515", "local_preference": 50, "remote_address": "192.168.0.1", "preference2": 0, "metric": 0, "communities": ["1299:1234", "1299:5678", "1299:91011", "1299:12134"], "local_as": 13335}, "outgoing_interface": "Port-Channel2", "last_active": true, "inactive_reason": "", "age": 0}]} |