-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from napalm-automation/develop
Release
- Loading branch information
Showing
57 changed files
with
512 additions
and
11 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -59,3 +59,5 @@ env | |
|
||
tags | ||
*.swp | ||
|
||
.compiled |
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,25 @@ | ||
language: python | ||
python: | ||
- 2.7 | ||
|
||
env: | ||
- ANSIBLE_VERSION=2.2 | ||
- ANSIBLE_VERSION=2.3 | ||
|
||
install: | ||
- pip install napalm-base | ||
- pip install "ansible>=$ANSIBLE_VERSION.0,<$ANSIBLE_VERSION.99" | ||
|
||
script: | ||
- cd tests | ||
# Test configuration dry-run | ||
- ansible-playbook -i napalm_install_config/hosts -l "*.dry_run.*" napalm_install_config/config.yaml -C | ||
# Test configuration commit | ||
- ansible-playbook -i napalm_install_config/hosts -l "*.commit.*" napalm_install_config/config.yaml | ||
# Test configuration errrors | ||
- ansible-playbook -i napalm_install_config/hosts -l "*.error*" napalm_install_config/config_error.yaml | ||
# Test get_facts | ||
- ansible-playbook -i napalm_get_facts/hosts napalm_get_facts/get_facts_ok.yaml -l multiple_facts.ok | ||
- ansible-playbook -i napalm_get_facts/hosts napalm_get_facts/get_facts_not_implemented.yaml -l multiple_facts.not_implemented -e "ignore_notimplemented=true" | ||
- ansible-playbook -i napalm_get_facts/hosts napalm_get_facts/get_facts_not_implemented.yaml -l multiple_facts.not_implemented -e "ignore_notimplemented=false" | ||
- ansible-playbook -i napalm_get_facts/hosts napalm_get_facts/get_facts_error.yaml -l multiple_facts.error |
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
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
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
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
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,4 @@ | ||
[defaults] | ||
library = ../library/ | ||
|
||
retry_files_enabled = False |
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,32 @@ | ||
--- | ||
- name: Get facts | ||
hosts: all | ||
connection: local # code is run locally | ||
gather_facts: no # don't gather facts | ||
tasks: | ||
- block: | ||
- name: get facts from device | ||
napalm_get_facts: # NAPALM plugin | ||
hostname: "{{ host }}" # start of connection parameters | ||
username: "{{ user }}" | ||
dev_os: "{{ os }}" | ||
password: "{{ password }}" | ||
optional_args: | ||
path: "{{ playbook_dir }}/mocked/{{ inventory_hostname }}" | ||
profile: "{{ profile }}" | ||
filter: ['facts', 'route_to', 'interfaces'] # which NAPALM getters to use | ||
args: | ||
route_to: | ||
protocol: static | ||
destination: 8.8.8.8 | ||
register: napalm_facts # store information here | ||
- assert: | ||
that: | ||
- napalm_facts.ansible_facts.facts.hostname == "localhost" | ||
- napalm_facts.ansible_facts.interfaces.Ethernet1.mac_address == "08:00:27:C6:00:F0" | ||
rescue: | ||
- debug: | ||
var: ansible_failed_result.msg | ||
- assert: | ||
that: | ||
- "{{ ansible_failed_result.msg == \"[interfaces] cannot retrieve device data: u'Key blah is not present'\" }}" |
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,34 @@ | ||
--- | ||
- name: Get facts | ||
hosts: all | ||
connection: local # code is run locally | ||
gather_facts: no # don't gather facts | ||
tasks: | ||
- block: | ||
- name: get facts from device | ||
napalm_get_facts: # NAPALM plugin | ||
hostname: "{{ host }}" # start of connection parameters | ||
username: "{{ user }}" | ||
dev_os: "{{ os }}" | ||
password: "{{ password }}" | ||
optional_args: | ||
path: "{{ playbook_dir }}/mocked/{{ inventory_hostname }}" | ||
profile: "{{ profile }}" | ||
filter: ['facts', 'route_to', 'interfaces'] # which NAPALM getters to use | ||
args: | ||
route_to: | ||
protocol: static | ||
destination: 8.8.8.8 | ||
ignore_notimplemented: "{{ ignore_notimplemented }}" | ||
register: napalm_facts # store information here | ||
- assert: | ||
that: | ||
- napalm_facts.ansible_facts.facts.hostname == "localhost" | ||
- napalm_facts.ansible_facts.interfaces.Ethernet1.mac_address == "08:00:27:C6:00:F0" | ||
rescue: | ||
- fail: | ||
msg: Whe shouldn't be here | ||
when: ignore_notimplemented | ||
- assert: | ||
that: | ||
- ansible_failed_result.msg == "The filter route_to is not supported in napalm-mock [get_route_to()]" |
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,26 @@ | ||
--- | ||
- name: Get facts | ||
hosts: all | ||
connection: local # code is run locally | ||
gather_facts: no # don't gather facts | ||
tasks: | ||
- name: get facts from device | ||
napalm_get_facts: # NAPALM plugin | ||
hostname: "{{ host }}" # start of connection parameters | ||
username: "{{ user }}" | ||
dev_os: "{{ os }}" | ||
password: "{{ password }}" | ||
optional_args: | ||
path: "{{ playbook_dir }}/mocked/{{ inventory_hostname }}" | ||
profile: "{{ profile }}" | ||
filter: ['facts', 'route_to', 'interfaces'] # which NAPALM getters to use | ||
args: | ||
route_to: | ||
protocol: static | ||
destination: 8.8.8.8 | ||
register: napalm_facts # store information here | ||
- assert: | ||
that: | ||
- napalm_facts.ansible_facts.facts.hostname == "localhost" | ||
- "{{ '1.0.4.0/24' in napalm_facts.ansible_facts.route_to }}" | ||
- napalm_facts.ansible_facts.interfaces.Ethernet1.mac_address == "08:00:27:C6:00:F0" |
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,7 @@ | ||
[all] | ||
multiple_facts.ok os=mock host=127.0.0.1 user=vagrant password=vagrant profile=[eos] | ||
multiple_facts.not_implemented os=mock host=127.0.0.1 user=vagrant password=vagrant profile=[eos] | ||
multiple_facts.error os=mock host=127.0.0.1 user=vagrant password=vagrant profile=[eos] | ||
|
||
[all:vars] | ||
ansible_python_interpreter="/usr/bin/env python" |
16 changes: 16 additions & 0 deletions
16
tests/napalm_get_facts/mocked/multiple_facts.error/get_facts.1
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,16 @@ | ||
{ | ||
"fqdn": "localhost", | ||
"hostname": "localhost", | ||
"interface_list": [ | ||
"Ethernet1", | ||
"Ethernet2", | ||
"Ethernet3", | ||
"Ethernet4", | ||
"Management1" | ||
], | ||
"model": "vEOS", | ||
"os_version": "4.15.5M-3054042.4155M", | ||
"serial_number": "", | ||
"uptime": "...", | ||
"vendor": "Arista" | ||
} |
8 changes: 8 additions & 0 deletions
8
tests/napalm_get_facts/mocked/multiple_facts.error/get_interfaces.1
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,8 @@ | ||
{ | ||
"exception": "KeyError", | ||
"args": [ | ||
"Key blah is not present" | ||
], | ||
"kwargs": {} | ||
} | ||
|
2 changes: 2 additions & 0 deletions
2
tests/napalm_get_facts/mocked/multiple_facts.error/get_route_to.1
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,2 @@ | ||
{"1.0.4.0/24": [{"next_hop": "192.168.0.1", "preference": 200, "protocol": "eBGP", "selected_next_hop": true, "current_active": true, "routing_table": "TEST", "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}, {"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}]} | ||
|
16 changes: 16 additions & 0 deletions
16
tests/napalm_get_facts/mocked/multiple_facts.not_implemented/get_facts.1
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,16 @@ | ||
{ | ||
"fqdn": "localhost", | ||
"hostname": "localhost", | ||
"interface_list": [ | ||
"Ethernet1", | ||
"Ethernet2", | ||
"Ethernet3", | ||
"Ethernet4", | ||
"Management1" | ||
], | ||
"model": "vEOS", | ||
"os_version": "4.15.5M-3054042.4155M", | ||
"serial_number": "", | ||
"uptime": "...", | ||
"vendor": "Arista" | ||
} |
42 changes: 42 additions & 0 deletions
42
tests/napalm_get_facts/mocked/multiple_facts.not_implemented/get_interfaces.1
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,42 @@ | ||
{ | ||
"Ethernet2": { | ||
"is_enabled": true, | ||
"description": "", | ||
"last_flapped": 1466586841.4151127, | ||
"is_up": true, | ||
"mac_address": "08:00:27:10:C4:8F", | ||
"speed": 0 | ||
}, | ||
"Management1": { | ||
"is_enabled": true, | ||
"description": "", | ||
"last_flapped": 1466586841.4284112, | ||
"is_up": true, | ||
"mac_address": "08:00:27:20:B9:04", | ||
"speed": 1000 | ||
}, | ||
"Ethernet1": { | ||
"is_enabled": true, | ||
"description": "", | ||
"last_flapped": 1466586841.4148579, | ||
"is_up": true, | ||
"mac_address": "08:00:27:C6:00:F0", | ||
"speed": 0 | ||
}, | ||
"Ethernet4": { | ||
"is_enabled": true, | ||
"description": "", | ||
"last_flapped": 1466586841.415464, | ||
"is_up": true, | ||
"mac_address": "08:00:27:E0:12:D2", | ||
"speed": 0 | ||
}, | ||
"Ethernet3": { | ||
"is_enabled": true, | ||
"description": "", | ||
"last_flapped": 1466586841.4152465, | ||
"is_up": true, | ||
"mac_address": "08:00:27:1F:60:43", | ||
"speed": 0 | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/napalm_get_facts/mocked/multiple_facts.ok/get_facts.1
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,16 @@ | ||
{ | ||
"fqdn": "localhost", | ||
"hostname": "localhost", | ||
"interface_list": [ | ||
"Ethernet1", | ||
"Ethernet2", | ||
"Ethernet3", | ||
"Ethernet4", | ||
"Management1" | ||
], | ||
"model": "vEOS", | ||
"os_version": "4.15.5M-3054042.4155M", | ||
"serial_number": "", | ||
"uptime": "...", | ||
"vendor": "Arista" | ||
} |
42 changes: 42 additions & 0 deletions
42
tests/napalm_get_facts/mocked/multiple_facts.ok/get_interfaces.1
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,42 @@ | ||
{ | ||
"Ethernet2": { | ||
"is_enabled": true, | ||
"description": "", | ||
"last_flapped": 1466586841.4151127, | ||
"is_up": true, | ||
"mac_address": "08:00:27:10:C4:8F", | ||
"speed": 0 | ||
}, | ||
"Management1": { | ||
"is_enabled": true, | ||
"description": "", | ||
"last_flapped": 1466586841.4284112, | ||
"is_up": true, | ||
"mac_address": "08:00:27:20:B9:04", | ||
"speed": 1000 | ||
}, | ||
"Ethernet1": { | ||
"is_enabled": true, | ||
"description": "", | ||
"last_flapped": 1466586841.4148579, | ||
"is_up": true, | ||
"mac_address": "08:00:27:C6:00:F0", | ||
"speed": 0 | ||
}, | ||
"Ethernet4": { | ||
"is_enabled": true, | ||
"description": "", | ||
"last_flapped": 1466586841.415464, | ||
"is_up": true, | ||
"mac_address": "08:00:27:E0:12:D2", | ||
"speed": 0 | ||
}, | ||
"Ethernet3": { | ||
"is_enabled": true, | ||
"description": "", | ||
"last_flapped": 1466586841.4152465, | ||
"is_up": true, | ||
"mac_address": "08:00:27:1F:60:43", | ||
"speed": 0 | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/napalm_get_facts/mocked/multiple_facts.ok/get_route_to.1
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,2 @@ | ||
{"1.0.4.0/24": [{"next_hop": "192.168.0.1", "preference": 200, "protocol": "eBGP", "selected_next_hop": true, "current_active": true, "routing_table": "TEST", "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}, {"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}]} | ||
|
Oops, something went wrong.