unit tests, fix returned data
This commit is contained in:
parent
681797fc6d
commit
0518980ab8
|
|
@ -211,21 +211,27 @@ class VyOSDriver(NetworkDriver):
|
|||
|
||||
environment = {
|
||||
"fans": {
|
||||
"status": None
|
||||
"invalid": {
|
||||
"status": False
|
||||
}
|
||||
},
|
||||
"temperature": {
|
||||
"temperature": None,
|
||||
"is_alert" : None,
|
||||
"is_critical": None
|
||||
"invalid" : {
|
||||
"temperature": 0.0,
|
||||
"is_alert" : False,
|
||||
"is_critical": False
|
||||
}
|
||||
},
|
||||
"power": {
|
||||
"status" : None,
|
||||
"capacity": None,
|
||||
"output" : None
|
||||
"invalid" : {
|
||||
"status" : True,
|
||||
"capacity": 0.0,
|
||||
"output" : 0.0
|
||||
}
|
||||
},
|
||||
"cpu": {
|
||||
"0": {
|
||||
"%usage": cpu
|
||||
"%usage": float(cpu)
|
||||
},
|
||||
},
|
||||
"memory": {
|
||||
|
|
@ -273,20 +279,28 @@ class VyOSDriver(NetworkDriver):
|
|||
for iface_name in ifaces_detail:
|
||||
|
||||
description = self._get_value("description", ifaces_detail[iface_name])
|
||||
if description is None:
|
||||
description = ""
|
||||
speed = self._get_value("speed", ifaces_detail[iface_name])
|
||||
if speed is None:
|
||||
speed = 0
|
||||
if speed == "auto":
|
||||
speed = 0
|
||||
hw_id = self._get_value("hw-id", ifaces_detail[iface_name])
|
||||
if hw_id is None:
|
||||
hw_id = "00:00:00:00:00:00"
|
||||
|
||||
is_up = (iface_state[iface_name]["Link"] == "u")
|
||||
is_enabled = (iface_state[iface_name]["State"] == "u")
|
||||
|
||||
iface_dict.update({
|
||||
iface_name: {
|
||||
"is_up" : is_up,
|
||||
"is_enabled" : is_enabled,
|
||||
"description" : description,
|
||||
"last_flapped" : -1,
|
||||
"speed" : speed,
|
||||
"mac_address" : hw_id
|
||||
"is_up" : bool(is_up),
|
||||
"is_enabled" : bool(is_enabled),
|
||||
"description" : unicode(description),
|
||||
"last_flapped" : float(-1),
|
||||
"speed" : int(speed),
|
||||
"mac_address" : unicode(hw_id)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -328,16 +342,18 @@ class VyOSDriver(NetworkDriver):
|
|||
# ["10.129.2.254", "ether", "00:50:56:97:af:b1", "C", "eth0"]
|
||||
# [u'10.0.12.33', u'(incomplete)', u'eth1']
|
||||
if "incomplete" in line[1]:
|
||||
macaddr=None
|
||||
macaddr=unicode("00:00:00:00:00:00")
|
||||
else:
|
||||
macaddr=unicode(line[2])
|
||||
|
||||
arp_table.append({
|
||||
"interface" : unicode(line[-1]),
|
||||
"mac" : macaddr,
|
||||
"ip" : unicode(line[0]),
|
||||
"age" : None
|
||||
})
|
||||
arp_table.append(
|
||||
{
|
||||
'interface': unicode(line[-1]),
|
||||
'mac': macaddr,
|
||||
'ip': unicode(line[0]),
|
||||
'age': 0.0
|
||||
}
|
||||
)
|
||||
|
||||
return arp_table
|
||||
|
||||
|
|
@ -370,10 +386,10 @@ class VyOSDriver(NetworkDriver):
|
|||
ntp_stats.append({
|
||||
"remote" : unicode(ip),
|
||||
"referenceid" : unicode(refid),
|
||||
"synchronized": synchronized,
|
||||
"synchronized": bool(synchronized),
|
||||
"stratum" : int(st),
|
||||
"type" : unicode(t),
|
||||
"when" : int(when),
|
||||
"when" : unicode(when),
|
||||
"hostpoll" : int(hostpoll),
|
||||
"reachability": int(reachability),
|
||||
"delay" : float(delay),
|
||||
|
|
@ -472,20 +488,20 @@ class VyOSDriver(NetworkDriver):
|
|||
|
||||
bgp_neighbor_data["global"]["peers"].setdefault(peer_id, {})
|
||||
peer_dict = {
|
||||
"description": "",
|
||||
"is_enabled" : is_enabled,
|
||||
"local_as" : local_as,
|
||||
"is_up" : is_up,
|
||||
"description": unicode(""),
|
||||
"is_enabled" : bool(is_enabled),
|
||||
"local_as" : int(local_as),
|
||||
"is_up" : bool(is_up),
|
||||
"remote_id" : unicode(remote_rid),
|
||||
"uptime" : self._bgp_time_conversion(up_time),
|
||||
"uptime" : int(self._bgp_time_conversion(up_time)),
|
||||
"remote_as" : int(remote_as)
|
||||
}
|
||||
|
||||
af_dict = dict()
|
||||
af_dict[address_family] = {
|
||||
"sent_prefixes" : None,
|
||||
"sent_prefixes" : int(-1),
|
||||
"accepted_prefixes": int(accepted_prefixes),
|
||||
"received_prefixes": received_prefixes
|
||||
"received_prefixes": int(received_prefixes)
|
||||
}
|
||||
|
||||
peer_dict["address_family"] = af_dict
|
||||
|
|
@ -555,22 +571,22 @@ class VyOSDriver(NetworkDriver):
|
|||
rx_octets = i[0]
|
||||
rx_unicast_packets = i[1]
|
||||
rx_multicast_packets = i[5]
|
||||
rx_broadcast_packets = None
|
||||
rx_broadcast_packets = -1
|
||||
else:
|
||||
counters.update({
|
||||
interfaces[j / 2]: {
|
||||
"tx_errors" : i[2],
|
||||
"tx_discards" : i[3],
|
||||
"tx_octets" : i[0],
|
||||
"tx_unicast_packets" : i[1],
|
||||
"tx_multicast_packets": None,
|
||||
"tx_broadcast_packets": None,
|
||||
"rx_errors" : rx_errors,
|
||||
"rx_discards" : rx_discards,
|
||||
"rx_octets" : rx_octets,
|
||||
"rx_unicast_packets" : rx_unicast_packets,
|
||||
"rx_multicast_packets": rx_multicast_packets,
|
||||
"rx_broadcast_packets": rx_broadcast_packets
|
||||
"tx_errors" : int(i[2]),
|
||||
"tx_discards" : int(i[3]),
|
||||
"tx_octets" : int(i[0]),
|
||||
"tx_unicast_packets" : int(i[1]),
|
||||
"tx_multicast_packets": int(-1),
|
||||
"tx_broadcast_packets": int(-1),
|
||||
"rx_errors" : int(rx_errors),
|
||||
"rx_discards" : int(rx_discards),
|
||||
"rx_octets" : int(rx_octets),
|
||||
"rx_unicast_packets" : int(rx_unicast_packets),
|
||||
"rx_multicast_packets": int(rx_multicast_packets),
|
||||
"rx_broadcast_packets": int(rx_broadcast_packets)
|
||||
}
|
||||
})
|
||||
j += 1
|
||||
|
|
@ -593,14 +609,15 @@ class VyOSDriver(NetworkDriver):
|
|||
for i in config["service"]["snmp"]["community"]:
|
||||
snmp["community"].update({
|
||||
i: {
|
||||
"acl": None,
|
||||
"mode": config["service"]["snmp"]["community"][i]["authorization"]
|
||||
"acl": unicode(""),
|
||||
"mode": unicode(config["service"]["snmp"]["community"][i]["authorization"])
|
||||
}
|
||||
})
|
||||
|
||||
snmp.update({
|
||||
"contact": config["service"]["snmp"]["contact"],
|
||||
"location": config["service"]["snmp"]["location"]
|
||||
"chassis_id": unicode(""),
|
||||
"contact": unicode(config["service"]["snmp"]["contact"]),
|
||||
"location": unicode(config["service"]["snmp"]["location"])
|
||||
})
|
||||
|
||||
return snmp
|
||||
|
|
@ -635,7 +652,7 @@ class VyOSDriver(NetworkDriver):
|
|||
if "domain-name" in config["system"]:
|
||||
fqdn = config["system"]["domain-name"]
|
||||
else:
|
||||
fqdn = None
|
||||
fqdn = ""
|
||||
|
||||
iface_list = list()
|
||||
for iface_type in config["interfaces"]:
|
||||
|
|
@ -644,7 +661,7 @@ class VyOSDriver(NetworkDriver):
|
|||
|
||||
facts = {
|
||||
"uptime" : int(uptime),
|
||||
"vendor" : "VyOS",
|
||||
"vendor" : unicode("VyOS"),
|
||||
"os_version" : unicode(version),
|
||||
"serial_number" : unicode(snumber),
|
||||
"model" : unicode(hwmodel),
|
||||
|
|
@ -701,7 +718,7 @@ class VyOSDriver(NetworkDriver):
|
|||
if ip_ver not in ifaces_ip[iface_name]:
|
||||
ifaces_ip[iface_name][ip_ver] = dict()
|
||||
|
||||
ifaces_ip[iface_name][ip_ver][ip_addr] = { "prefix_length": mask }
|
||||
ifaces_ip[iface_name][ip_ver][ip_addr] = { "prefix_length": int(mask) }
|
||||
|
||||
return ifaces_ip
|
||||
|
||||
|
|
@ -794,23 +811,28 @@ class VyOSDriver(NetworkDriver):
|
|||
# 'rtt_info' example:
|
||||
# ["0.307/0.396/0.480/0.061"]
|
||||
rtt_info = output_ping.split("\n")[-1]
|
||||
match = re.search("([\d\.]+)/([\d\.]+)/([\d\.]+)/[\d\.]+", rtt_info)
|
||||
match = re.search("([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+)", rtt_info)
|
||||
|
||||
if match is not None:
|
||||
rtt_min = float(match.group(1))
|
||||
rtt_avg = float(match.group(2))
|
||||
rtt_max = float(match.group(3))
|
||||
rtt_stddev = float(match.group(4))
|
||||
else:
|
||||
rtt_min = None
|
||||
rtt_avg = None
|
||||
rtt_max = None
|
||||
rtt_stddev = None
|
||||
|
||||
ping_result["success"] = dict()
|
||||
ping_result["success"] = {
|
||||
"probes_sent": sent,
|
||||
"packet_loss": lost,
|
||||
"rtt_min" : rtt_min,
|
||||
"rtt_max" : rtt_max,
|
||||
"rtt_avg" : rtt_avg,
|
||||
"rtt_stdev" : None,
|
||||
"results" : {"ip_address": destination, "rtt": rtt_avg}
|
||||
"rtt_stddev" : rtt_stddev,
|
||||
"results" : [{"ip_address": destination, "rtt": rtt_avg}]
|
||||
}
|
||||
|
||||
return ping_result
|
||||
|
|
|
|||
|
|
@ -1,80 +0,0 @@
|
|||
# Copyright 2016 Dravetech AB. All rights reserved.
|
||||
#
|
||||
# The contents of this file are licensed under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
|
||||
"""Tests."""
|
||||
|
||||
import unittest
|
||||
|
||||
from napalm_skeleton import skeleton
|
||||
from napalm_base.test.base import TestConfigNetworkDriver, TestGettersNetworkDriver
|
||||
import json
|
||||
|
||||
|
||||
class TestConfigDriver(unittest.TestCase, TestConfigNetworkDriver):
|
||||
"""Group of tests that test Configuration related methods."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Run before starting the tests."""
|
||||
hostname = '127.0.0.1'
|
||||
username = 'vagrant'
|
||||
password = 'vagrant'
|
||||
cls.vendor = 'skeleton'
|
||||
|
||||
optional_args = {'port': 12443, }
|
||||
cls.device = skeleton.SkeletonDriver(hostname, username, password, timeout=60,
|
||||
optional_args=optional_args)
|
||||
cls.device.open()
|
||||
|
||||
cls.device.load_replace_candidate(filename='%s/initial.conf' % cls.vendor)
|
||||
cls.device.commit_config()
|
||||
|
||||
|
||||
class TestGetterDriver(unittest.TestCase, TestGettersNetworkDriver):
|
||||
"""Group of tests that test getters."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Run before starting the tests."""
|
||||
cls.mock = True
|
||||
|
||||
hostname = '127.0.0.1'
|
||||
username = 'vagrant'
|
||||
password = 'vagrant'
|
||||
cls.vendor = 'skeleton'
|
||||
|
||||
optional_args = {'port': 12443, }
|
||||
cls.device = skeleton.SkeletonDriver(hostname, username, password, timeout=60,
|
||||
optional_args=optional_args)
|
||||
|
||||
if cls.mock:
|
||||
cls.device.device = FakeDevice()
|
||||
else:
|
||||
cls.device.open()
|
||||
|
||||
|
||||
class FakeDevice:
|
||||
"""Test double."""
|
||||
|
||||
@staticmethod
|
||||
def read_json_file(filename):
|
||||
"""Return the content of a file with content formatted as json."""
|
||||
with open(filename) as data_file:
|
||||
return json.load(data_file)
|
||||
|
||||
@staticmethod
|
||||
def read_txt_file(filename):
|
||||
"""Return the content of a file."""
|
||||
with open(filename) as data_file:
|
||||
return data_file.read()
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
# Copyright 2015 Spotify AB. All rights reserved.
|
||||
#
|
||||
# The contents of this file are licensed under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
|
||||
import unittest
|
||||
|
||||
from napalm_vyos import vyos
|
||||
from napalm_base.test.base import TestConfigNetworkDriver
|
||||
|
||||
|
||||
class TestConfigVyOSDriver(unittest.TestCase, TestConfigNetworkDriver):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
hostname = '127.0.0.1'
|
||||
username = 'vagrant'
|
||||
password = 'vagrant'
|
||||
cls.vendor = 'vyos'
|
||||
cls.port = '2200'
|
||||
|
||||
optional_args = {'port': '2200' }
|
||||
cls.device = vyos.VyOSDriver(hostname, username, password,
|
||||
timeout=60, optional_args=optional_args)
|
||||
cls.device.open()
|
||||
|
||||
cls.device.load_replace_candidate(filename='%s/initial.conf' % cls.vendor)
|
||||
cls.device.commit_config()
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
"""Test fixtures."""
|
||||
from builtins import super
|
||||
|
||||
import pytest
|
||||
from napalm_base.test import conftest as parent_conftest
|
||||
|
||||
from napalm_base.test.double import BaseTestDouble
|
||||
|
||||
from napalm_vyos import vyos
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def set_device_parameters(request):
|
||||
"""Set up the class."""
|
||||
def fin():
|
||||
request.cls.device.close()
|
||||
request.addfinalizer(fin)
|
||||
|
||||
request.cls.driver = vyos.VyOSDriver
|
||||
request.cls.patched_driver = PatchedVyOSDriver
|
||||
request.cls.vendor = 'vyos'
|
||||
parent_conftest.set_device_parameters(request)
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
"""Generate test cases dynamically."""
|
||||
parent_conftest.pytest_generate_tests(metafunc, __file__)
|
||||
|
||||
|
||||
class PatchedVyOSDriver(vyos.VyOSDriver):
|
||||
"""Patched VyOS Driver."""
|
||||
|
||||
def __init__(self, hostname, username, password, timeout=60, optional_args=None):
|
||||
super().__init__(hostname, username, password, timeout, optional_args)
|
||||
|
||||
self.patched_attrs = ['device']
|
||||
self.device = FakeVyOSDevice()
|
||||
|
||||
|
||||
class FakeVyOSDevice(BaseTestDouble):
|
||||
"""VyOS device test double."""
|
||||
|
||||
def run_commands(self, command_list, encoding='json'):
|
||||
"""Fake run_commands."""
|
||||
result = list()
|
||||
|
||||
for command in command_list:
|
||||
filename = '{}.{}'.format(self.sanitize_text(command), encoding)
|
||||
full_path = self.find_file(filename)
|
||||
|
||||
if encoding == 'json':
|
||||
result.append(self.read_json_file(full_path))
|
||||
else:
|
||||
result.append({'output': self.read_txt_file(full_path)})
|
||||
|
||||
return result
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"interface": "eth1", "ip": "10.0.12.33", "mac": "00:00:00:00:00:00", "age": 0.0}, {"interface": "eth1", "ip": "10.0.12.1", "mac": "08:00:27:60:0f:ee", "age": 0.0}, {"interface": "eth0", "ip": "10.0.2.2", "mac": "52:54:00:12:35:02", "age": 0.0}]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Address HWtype HWaddress Flags Mask Iface
|
||||
10.0.12.33 (incomplete) eth1
|
||||
10.0.12.1 ether 08:00:27:60:0f:ee C eth1
|
||||
10.0.2.2 ether 52:54:00:12:35:02 C eth0
|
||||
10.0.2.3 ether 52:54:00:12:35:03 C eth0
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"global": {"router_id": "10.2.2.2", "peers": {"10.0.12.1": {"is_enabled": true, "uptime": 864000, "remote_as": 65001, "description": "", "remote_id": "10.1.1.1", "local_as": 65002, "is_up": true, "address_family": {"ipv4": {"sent_prefixes": -1, "accepted_prefixes": 4, "received_prefixes": 4}}}}}}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
BGP neighbor is 10.0.12.1, remote AS 65001, local AS 65002, external link
|
||||
BGP version 4, remote router ID 10.1.1.1
|
||||
BGP state = Established, up for 01w3d00h
|
||||
Last read 03:39:29, hold time is 90, keepalive interval is 30 seconds
|
||||
Neighbor capabilities:
|
||||
4 Byte AS: advertised and received
|
||||
Route refresh: advertised and received(old & new)
|
||||
Address family IPv4 Unicast: advertised and received
|
||||
Graceful Restart Capabilty: received
|
||||
Remote Restart timer is 120 seconds
|
||||
Address families by peer:
|
||||
none
|
||||
Graceful restart informations:
|
||||
End-of-RIB send: IPv4 Unicast
|
||||
End-of-RIB received:
|
||||
Message statistics:
|
||||
Inq depth is 0
|
||||
Outq depth is 0
|
||||
Sent Rcvd
|
||||
Opens: 2 2
|
||||
Notifications: 1 0
|
||||
Updates: 4 2
|
||||
Keepalives: 33375 36937
|
||||
Route Refresh: 0 0
|
||||
Capability: 0 0
|
||||
Total: 33382 36941
|
||||
Minimum time between advertisement runs is 30 seconds
|
||||
|
||||
For address family: IPv4 Unicast
|
||||
Community attribute sent to this neighbor(both)
|
||||
Outbound path policy configured
|
||||
Route map for outgoing advertisements is *EXPORT-POLICY
|
||||
4 accepted prefixes
|
||||
|
||||
Connections established 2; dropped 1
|
||||
Last reset 01w3d00h, due to User reset
|
||||
Local host: 10.0.12.2, Local port: 33945
|
||||
Foreign host: 10.0.12.1, Foreign port: 179
|
||||
Nexthop: 10.0.12.2
|
||||
Nexthop global: fe80::a00:27ff:fe41:d5f8
|
||||
Nexthop local: ::
|
||||
BGP connection: non shared network
|
||||
Read thread: on Write thread: off
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
BGP router identifier 10.2.2.2, local AS number 65002
|
||||
IPv4 Unicast - max multipaths: ebgp 1 ibgp 1
|
||||
RIB entries 9, using 864 bytes of memory
|
||||
Peers 1, using 4560 bytes of memory
|
||||
|
||||
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
|
||||
10.0.12.1 4 65001 36938 33380 0 0 0 01w3d00h 4
|
||||
|
||||
Total number of neighbors 1
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"fans": {"invalid": {"status": false}}, "memory": {"available_ram": 250112, "used_ram": 228668}, "temperature": {"invalid": {"is_alert": false, "temperature": 0.0, "is_critical": false}}, "power": {"invalid": {"status": true, "output": 0.0, "capacity": 0.0}}, "cpu": {"0": {"%usage": 1.0}}}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
total used free shared buffers cached
|
||||
Mem: 250112 222708 27404 0 45144 93184
|
||||
-/+ buffers/cache: 84380 165732
|
||||
Swap: 0 0 0
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
|
||||
r b swpd free buff cache si so bi bo in cs us sy id wa
|
||||
0 0 0 27460 45136 93184 0 0 0 0 15 24 0 0 99 0
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"os_version": "1.1.7", "uptime": 1043562, "interface_list": ["eth1", "eth0", "lo"], "vendor": "VyOS", "serial_number": "0", "model": "VirtualBox", "hostname": "vyos2", "fqdn": ""}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"lo": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "00:00:00:00:00:00", "speed": 0}, "eth1": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "08:00:27:41:d5:f8", "speed": 0}, "eth0": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "08:00:27:c5:c9:67", "speed": 0}}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
|
||||
Interface IP Address S/L Description
|
||||
--------- ---------- --- -----------
|
||||
eth0 10.0.2.15/24 u/u
|
||||
eth1 10.0.12.2/24 u/u
|
||||
lo 127.0.0.1/8 u/u
|
||||
10.2.2.2/32
|
||||
8.8.8.8/32
|
||||
::1/128
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"eth1": {"tx_discards": 0, "tx_unicast_packets": 1124144, "rx_broadcast_packets": -1, "rx_discards": 0, "tx_multicast_packets": -1, "tx_octets": 128843591, "tx_errors": 0, "rx_octets": 128902602, "rx_errors": 0, "tx_broadcast_packets": -1, "rx_multicast_packets": 0, "rx_unicast_packets": 1123974}, "eth0": {"tx_discards": 0, "tx_unicast_packets": 1228025, "rx_broadcast_packets": -1, "rx_discards": 0, "tx_multicast_packets": -1, "tx_octets": 341284276, "tx_errors": 0, "rx_octets": 136039132, "rx_errors": 0, "tx_broadcast_packets": -1, "rx_multicast_packets": 0, "rx_unicast_packets": 1231464}}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
|
||||
link/ether 08:00:27:c5:c9:67 brd ff:ff:ff:ff:ff:ff
|
||||
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
|
||||
valid_lft forever preferred_lft forever
|
||||
inet6 fe80::a00:27ff:fec5:c967/64 scope link
|
||||
valid_lft forever preferred_lft forever
|
||||
|
||||
RX: bytes packets errors dropped overrun mcast
|
||||
136000952 1231123 0 0 0 0
|
||||
TX: bytes packets errors dropped carrier collisions
|
||||
341194779 1227696 0 0 0 0
|
||||
eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
|
||||
link/ether 08:00:27:41:d5:f8 brd ff:ff:ff:ff:ff:ff
|
||||
inet 10.0.12.2/24 brd 10.0.12.255 scope global eth1
|
||||
valid_lft forever preferred_lft forever
|
||||
inet6 fe80::a00:27ff:fe41:d5f8/64 scope link
|
||||
valid_lft forever preferred_lft forever
|
||||
|
||||
RX: bytes packets errors dropped overrun mcast
|
||||
128872155 1123706 0 0 0 0
|
||||
TX: bytes packets errors dropped carrier collisions
|
||||
128813163 1123876 0 0 0 0
|
||||
lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
|
||||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
||||
inet 127.0.0.1/8 scope host lo
|
||||
valid_lft forever preferred_lft forever
|
||||
inet 10.2.2.2/32 scope global lo
|
||||
valid_lft forever preferred_lft forever
|
||||
inet 8.8.8.8/32 scope global lo
|
||||
valid_lft forever preferred_lft forever
|
||||
inet6 ::1/128 scope host
|
||||
valid_lft forever preferred_lft forever
|
||||
|
||||
RX: bytes packets errors dropped overrun mcast
|
||||
75048164 1249364 0 0 0 0
|
||||
TX: bytes packets errors dropped carrier collisions
|
||||
75048164 1249364 0 0 0 0
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"lo": {"ipv4": {"8.8.8.8": {"prefix_length": 32}, "127.0.0.1": {"prefix_length": 8}, "10.2.2.2": {"prefix_length": 32}}}, "eth1": {"ipv4": {"10.0.12.2": {"prefix_length": 24}}}, "eth0": {"ipv4": {"10.0.2.15": {"prefix_length": 24}}}}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"31.216.56.5": {}, "46.175.224.7": {}, "91.212.242.21": {}}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
remote refid st t when poll reach delay offset jitter
|
||||
==============================================================================
|
||||
31.216.56.5 .INIT. 16 u - 1024 0 0.000 0.000 0.000
|
||||
46.175.224.7 .INIT. 16 u - 1024 0 0.000 0.000 0.000
|
||||
91.212.242.21 .INIT. 16 u - 1024 0 0.000 0.000 0.000
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"jitter": 0.0, "synchronized": false, "offset": 0.0, "referenceid": ".INIT.", "remote": "31.216.56.5", "reachability": 0, "when": "0", "delay": 0.0, "hostpoll": 1024, "stratum": 16, "type": "u"}, {"jitter": 0.0, "synchronized": false, "offset": 0.0, "referenceid": ".INIT.", "remote": "46.175.224.7", "reachability": 0, "when": "0", "delay": 0.0, "hostpoll": 1024, "stratum": 16, "type": "u"}, {"jitter": 0.0, "synchronized": false, "offset": 0.0, "referenceid": ".INIT.", "remote": "91.212.242.21", "reachability": 0, "when": "0", "delay": 0.0, "hostpoll": 1024, "stratum": 16, "type": "u"}]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
remote refid st t when poll reach delay offset jitter
|
||||
==============================================================================
|
||||
31.216.56.5 .INIT. 16 u - 1024 0 0.000 0.000 0.000
|
||||
46.175.224.7 .INIT. 16 u - 1024 0 0.000 0.000 0.000
|
||||
91.212.242.21 .INIT. 16 u - 1024 0 0.000 0.000 0.000
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"contact": "admin@foo.corp", "location": "PL,Krakow", "community": {"commro": {"mode": "ro", "acl": ""}}, "chassis_id": ""}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"vagrant": {"password": "$6$fcHhBu3T$WLmiu6/txlEfWK5uh4mKE8v7qocuftsoAN1oHqPIIoogXAX8zS.SKhB105EExYU6yBy4cKHUD/Q6Mm7CUbVTr.", "sshkeys": ["AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ=="], "level": 15}, "vyos": {"password": "$1$yHIMnG/J$aWDkd3oDYSYps8twB5vpw1", "sshkeys": [], "level": 15}}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"success": {"packet_loss": 0, "rtt_stddev": 0.123, "rtt_min": 0.086, "results": [{"rtt": 0.175, "ip_address": "8.8.8.8"}], "rtt_avg": 0.175, "rtt_max": 0.417, "probes_sent": 5}}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
|
||||
64 bytes from 8.8.8.8: icmp_req=1 ttl=64 time=0.112 ms
|
||||
64 bytes from 8.8.8.8: icmp_req=2 ttl=64 time=0.114 ms
|
||||
64 bytes from 8.8.8.8: icmp_req=3 ttl=64 time=0.136 ms
|
||||
64 bytes from 8.8.8.8: icmp_req=4 ttl=64 time=0.112 ms
|
||||
64 bytes from 8.8.8.8: icmp_req=5 ttl=64 time=0.112 ms
|
||||
|
||||
--- 8.8.8.8 ping statistics ---
|
||||
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
|
||||
rtt min/avg/max/mdev = 0.112/0.117/0.136/0.011 ms
|
||||
|
|
@ -1 +0,0 @@
|
|||
Initial configuration
|
||||
|
|
@ -1 +0,0 @@
|
|||
Some changes that will be merged while testing
|
||||
|
|
@ -1 +0,0 @@
|
|||
The diff when merging `merged_good.conf`
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
Some changes that will be merge while testing. Should contain a typo or something that triggers
|
||||
an error during the load/commmit phase
|
||||
|
|
@ -1 +0,0 @@
|
|||
A full new configuration. It will be used to test the replace operation
|
||||
|
|
@ -1 +0,0 @@
|
|||
A diff between `initial.conf` and `new_good.conf`
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
A full new configuration. However, it should contain a typo or something that triggers an error
|
||||
during commit/load phase.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
"""Tests for getters."""
|
||||
|
||||
from napalm_base.test.getters import BaseTestGetters
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("set_device_parameters")
|
||||
class TestGetter(BaseTestGetters):
|
||||
"""Test get_* methods."""
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
interfaces {
|
||||
ethernet eth0 {
|
||||
address dhcp
|
||||
}
|
||||
ethernet eth1 {
|
||||
address 10.0.12.2/24
|
||||
}
|
||||
loopback lo {
|
||||
address 10.2.2.2/32
|
||||
address 8.8.8.8/32
|
||||
}
|
||||
}
|
||||
policy {
|
||||
prefix-list EXPORT {
|
||||
rule 1 {
|
||||
action permit
|
||||
prefix 172.16.2.0/24
|
||||
}
|
||||
rule 65535 {
|
||||
action permit
|
||||
prefix 10.2.2.2/32
|
||||
}
|
||||
}
|
||||
route-map EXPORT-POLICY {
|
||||
rule 1 {
|
||||
action permit
|
||||
match {
|
||||
ip {
|
||||
address {
|
||||
prefix-list EXPORT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protocols {
|
||||
bgp 65002 {
|
||||
neighbor 10.0.12.1 {
|
||||
remote-as 65001
|
||||
route-map {
|
||||
export EXPORT-POLICY
|
||||
}
|
||||
}
|
||||
redistribute {
|
||||
connected {
|
||||
route-map EXPORT-POLICY
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
service {
|
||||
snmp {
|
||||
community commro {
|
||||
authorization ro
|
||||
}
|
||||
contact admin@foo.corp
|
||||
location PL,Krakow
|
||||
}
|
||||
ssh {
|
||||
disable-host-validation
|
||||
port 22
|
||||
}
|
||||
}
|
||||
system {
|
||||
config-management {
|
||||
commit-revisions 20
|
||||
}
|
||||
host-name vyos2
|
||||
login {
|
||||
banner {
|
||||
pre-login "My banner for all devices"
|
||||
}
|
||||
user vagrant {
|
||||
authentication {
|
||||
encrypted-password $6$fcHhBu3T$WLmiu6/txlEfWK5uh4mKE8v7qocuftsoAN1oHqPIIoogXAX8zS.SKhB105EExYU6yBy4cKHUD/Q6Mm7CUbVTr.
|
||||
plaintext-password ""
|
||||
public-keys vagrant {
|
||||
key AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==
|
||||
type ssh-rsa
|
||||
}
|
||||
}
|
||||
level admin
|
||||
}
|
||||
user vyos {
|
||||
authentication {
|
||||
encrypted-password $1$yHIMnG/J$aWDkd3oDYSYps8twB5vpw1
|
||||
plaintext-password ""
|
||||
}
|
||||
level admin
|
||||
}
|
||||
}
|
||||
ntp {
|
||||
server 0.pool.ntp.org {
|
||||
}
|
||||
server 1.pool.ntp.org {
|
||||
}
|
||||
server 2.pool.ntp.org {
|
||||
}
|
||||
}
|
||||
package {
|
||||
auto-sync 1
|
||||
repository community {
|
||||
components main
|
||||
distribution helium
|
||||
password ""
|
||||
url http://packages.vyos.net/vyos
|
||||
username ""
|
||||
}
|
||||
}
|
||||
syslog {
|
||||
global {
|
||||
facility all {
|
||||
level notice
|
||||
}
|
||||
facility protocols {
|
||||
level debug
|
||||
}
|
||||
}
|
||||
}
|
||||
time-zone UTC
|
||||
}
|
||||
|
||||
|
||||
/* Warning: Do not remove the following line. */
|
||||
/* === vyatta-config-version: "cluster@1:config-management@1:conntrack-sync@1:conntrack@1:cron@1:dhcp-relay@1:dhcp-server@4:firewall@5:ipsec@4:nat@4:qos@1:quagga@2:system@6:vrrp@1:wanloadbalance@3:webgui@1:webproxy@1:zone-policy@1" === */
|
||||
/* Release version: VyOS 1.1.7 */
|
||||
|
|
@ -0,0 +1 @@
|
|||
set system login banner pre-login "aaaa"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[edit system login banner]
|
||||
>pre-login aaaa
|
||||
[edit]
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
set cc system login banner pre-login "aaaa"
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
interfaces {
|
||||
ethernet eth0 {
|
||||
address dhcp
|
||||
}
|
||||
ethernet eth1 {
|
||||
address 10.0.12.2/24
|
||||
}
|
||||
loopback lo {
|
||||
address 10.2.2.2/32
|
||||
address 8.8.8.8/32
|
||||
}
|
||||
}
|
||||
policy {
|
||||
prefix-list EXPORT {
|
||||
rule 1 {
|
||||
action permit
|
||||
prefix 172.16.2.0/24
|
||||
}
|
||||
rule 65535 {
|
||||
action permit
|
||||
prefix 10.2.2.2/32
|
||||
}
|
||||
}
|
||||
route-map EXPORT-POLICY {
|
||||
rule 1 {
|
||||
action permit
|
||||
match {
|
||||
ip {
|
||||
address {
|
||||
prefix-list EXPORT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protocols {
|
||||
bgp 65002 {
|
||||
neighbor 10.0.12.1 {
|
||||
remote-as 65001
|
||||
route-map {
|
||||
export EXPORT-POLICY
|
||||
}
|
||||
}
|
||||
redistribute {
|
||||
connected {
|
||||
route-map EXPORT-POLICY
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
service {
|
||||
snmp {
|
||||
community commro {
|
||||
authorization ro
|
||||
}
|
||||
contact admin@foo.corp
|
||||
location PL,Krakow
|
||||
}
|
||||
ssh {
|
||||
disable-host-validation
|
||||
port 22
|
||||
}
|
||||
}
|
||||
system {
|
||||
config-management {
|
||||
commit-revisions 20
|
||||
}
|
||||
host-name vyos2
|
||||
login {
|
||||
banner {
|
||||
pre-login "My new banner for all devices"
|
||||
}
|
||||
user vagrant {
|
||||
authentication {
|
||||
encrypted-password $6$fcHhBu3T$WLmiu6/txlEfWK5uh4mKE8v7qocuftsoAN1oHqPIIoogXAX8zS.SKhB105EExYU6yBy4cKHUD/Q6Mm7CUbVTr.
|
||||
plaintext-password ""
|
||||
public-keys vagrant {
|
||||
key AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==
|
||||
type ssh-rsa
|
||||
}
|
||||
}
|
||||
level admin
|
||||
}
|
||||
user vyos {
|
||||
authentication {
|
||||
encrypted-password $1$yHIMnG/J$aWDkd3oDYSYps8twB5vpw1
|
||||
plaintext-password ""
|
||||
}
|
||||
level admin
|
||||
}
|
||||
}
|
||||
ntp {
|
||||
server 0.pool.ntp.org {
|
||||
}
|
||||
server 1.pool.ntp.org {
|
||||
}
|
||||
server 2.pool.ntp.org {
|
||||
}
|
||||
}
|
||||
package {
|
||||
auto-sync 1
|
||||
repository community {
|
||||
components main
|
||||
distribution helium
|
||||
password ""
|
||||
url http://packages.vyos.net/vyos
|
||||
username ""
|
||||
}
|
||||
}
|
||||
syslog {
|
||||
global {
|
||||
facility all {
|
||||
level notice
|
||||
}
|
||||
facility protocols {
|
||||
level debug
|
||||
}
|
||||
}
|
||||
}
|
||||
time-zone UTC
|
||||
}
|
||||
|
||||
|
||||
/* Warning: Do not remove the following line. */
|
||||
/* === vyatta-config-version: "cluster@1:config-management@1:conntrack-sync@1:conntrack@1:cron@1:dhcp-relay@1:dhcp-server@4:firewall@5:ipsec@4:nat@4:qos@1:quagga@2:system@6:vrrp@1:wanloadbalance@3:webgui@1:webproxy@1:zone-policy@1" === */
|
||||
/* Release version: VyOS 1.1.7 */
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[edit system login banner]
|
||||
>pre-login "My new banner for all devices"
|
||||
[edit]
|
||||
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
{
|
||||
interfaces {
|
||||
ethernet eth0 {
|
||||
address dhcp
|
||||
}
|
||||
ethernet eth1 {
|
||||
address 10.0.12.2/24
|
||||
}
|
||||
loopback lo {
|
||||
address 10.2.2.2/32
|
||||
address 8.8.8.8/32
|
||||
}
|
||||
}
|
||||
policy {
|
||||
prefix-list EXPORT {
|
||||
rule 1 {
|
||||
action permit
|
||||
prefix 172.16.2.0/24
|
||||
}
|
||||
rule 65535 {
|
||||
action permit
|
||||
prefix 10.2.2.2/32
|
||||
}
|
||||
}
|
||||
route-map EXPORT-POLICY {
|
||||
rule 1 {
|
||||
action permit
|
||||
match {
|
||||
ip {
|
||||
address {
|
||||
prefix-list EXPORT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protocols {
|
||||
bgp 65002 {
|
||||
neighbor 10.0.12.1 {
|
||||
remote-as 65001
|
||||
route-map {
|
||||
export EXPORT-POLICY
|
||||
}
|
||||
}
|
||||
redistribute {
|
||||
connected {
|
||||
route-map EXPORT-POLICY
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
service {
|
||||
snmp {
|
||||
community commro {
|
||||
authorization ro
|
||||
}
|
||||
contact admin@foo.corp
|
||||
location PL,Krakow
|
||||
}
|
||||
ssh {
|
||||
disable-host-validation
|
||||
port 22
|
||||
}
|
||||
}
|
||||
system {
|
||||
config-management {
|
||||
commit-revisions 20
|
||||
}
|
||||
host-name vyos2
|
||||
login {
|
||||
banner {
|
||||
pre-login "My new banner for all devices"
|
||||
}
|
||||
user vagrant {
|
||||
authentication {
|
||||
encrypted-password $6$fcHhBu3T$WLmiu6/txlEfWK5uh4mKE8v7qocuftsoAN1oHqPIIoogXAX8zS.SKhB105EExYU6yBy4cKHUD/Q6Mm7CUbVTr.
|
||||
plaintext-password ""
|
||||
public-keys vagrant {
|
||||
key AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==
|
||||
type ssh-rsa
|
||||
}
|
||||
}
|
||||
level admin
|
||||
}
|
||||
user vyos {
|
||||
authentication {
|
||||
encrypted-password $1$yHIMnG/J$aWDkd3oDYSYps8twB5vpw1
|
||||
plaintext-password ""
|
||||
}
|
||||
level admin
|
||||
}
|
||||
}
|
||||
ntp {
|
||||
server 0.pool.ntp.org {
|
||||
}
|
||||
server 1.pool.ntp.org {
|
||||
}
|
||||
server 2.pool.ntp.org {
|
||||
}
|
||||
}
|
||||
package {
|
||||
auto-sync 1
|
||||
repository community {
|
||||
components main
|
||||
distribution helium
|
||||
password ""
|
||||
url http://packages.vyos.net/vyos
|
||||
username ""
|
||||
}
|
||||
}
|
||||
syslog {
|
||||
global {
|
||||
facility all {
|
||||
level notice
|
||||
}
|
||||
facility protocols {
|
||||
level debug
|
||||
}
|
||||
}
|
||||
}
|
||||
time-zone UTC
|
||||
}
|
||||
|
||||
|
||||
/* Warning: Do not remove the following line. */
|
||||
/* === vyatta-config-version: "cluster@1:config-management@1:conntrack-sync@1:conntrack@1:cron@1:dhcp-relay@1:dhcp-server@4:firewall@5:ipsec@4:nat@4:qos@1:quagga@2:system@6:vrrp@1:wanloadbalance@3:webgui@1:webproxy@1:zone-policy@1" === */
|
||||
/* Release version: VyOS 1.1.7 */
|
||||
Loading…
Reference in New Issue