diff options
Diffstat (limited to 'resources/libraries')
57 files changed, 563 insertions, 542 deletions
diff --git a/resources/libraries/python/Classify.py b/resources/libraries/python/Classify.py index a66994906b..2510da0b77 100644 --- a/resources/libraries/python/Classify.py +++ b/resources/libraries/python/Classify.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -32,10 +32,10 @@ class Classify(object): :type node: dict :type ip_version: str :type direction: str - :returns (table_index, skip_n, match_n) - table_index: Classify table index. - skip_n: Number of skip vectors. - match_n: Number of match vectors. + :returns: (table_index, skip_n, match_n) + table_index: Classify table index. + skip_n: Number of skip vectors. + match_n: Number of match vectors. :rtype: tuple(int, int, int) :raises RuntimeError: If VPP can't create table. """ @@ -64,10 +64,10 @@ class Classify(object): :param direction: Direction of traffic - src/dst. :type node: dict :type direction: str - :returns (table_index, skip_n, match_n) - table_index: Classify table index. - skip_n: Number of skip vectors. - match_n: Number of match vectors. + :returns: (table_index, skip_n, match_n) + table_index: Classify table index. + skip_n: Number of skip vectors. + match_n: Number of match vectors. :rtype: tuple(int, int, int) :raises RuntimeError: If VPP can't create table. """ @@ -95,10 +95,10 @@ class Classify(object): :param hex_mask: Classify hex mask. :type node: dict :type hex_mask: str - :returns (table_index, skip_n, match_n) - table_index: Classify table index. - skip_n: Number of skip vectors. - match_n: Number of match vectors. + :returns: (table_index, skip_n, match_n) + table_index: Classify table index. + skip_n: Number of skip vectors. + match_n: Number of match vectors. :rtype: tuple(int, int, int) :raises RuntimeError: If VPP can't create table. """ @@ -216,14 +216,14 @@ class Classify(object): :param node: VPP node to setup classify session. :param session_type: Session type - hit-next, l2-hit-next, acl-hit-next - or policer-hit-next, and their respective parameters. + or policer-hit-next, and their respective parameters. :param table_index: Classify table index. :param skip_n: Number of skip vectors based on mask. :param match_n: Number of match vectors based on mask. :param match: Match value - l2, l3, l4 or hex, and their - respective parameters. + respective parameters. :param match2: Additional match values, to avoid using overly long - variables in RobotFramework. + variables in RobotFramework. :type node: dict :type session_type: str :type table_index: int @@ -256,7 +256,7 @@ class Classify(object): :type protocol: str :type direction: str :returns: Classify hex mask. - :rtype : str + :rtype: str :raises ValueError: If protocol is not TCP or UDP. :raises ValueError: If direction is not source or destination or source + destination. @@ -310,7 +310,7 @@ class Classify(object): :param ip_version: Version of IP protocol. :type ip_version: str - :return: Base hex mask. + :returns: Base hex mask. :rtype: str """ if ip_version == 'ip4': diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py index 4b891048fd..9dabc73173 100644 --- a/resources/libraries/python/ContainerUtils.py +++ b/resources/libraries/python/ContainerUtils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -281,9 +281,9 @@ class ContainerEngine(object): def install_vpp(self, install_dkms=False): """Install VPP inside a container. - :param install_dkms: If install dkms package. This will impact install - time. Dkms is required for installation of vpp-dpdk-dkms. Default is - false. + :param install_dkms: If install dkms package. This will impact + install time. Dkms is required for installation of vpp-dpdk-dkms. + Default is false. :type install_dkms: bool """ self.execute('ln -s /dev/null /etc/sysctl.d/80-vpp.conf') @@ -418,10 +418,10 @@ class LXC(ContainerEngine): """Acquire a privileged system object where configuration is stored. :param force: If a container exists, destroy it and create a new - container. + container. :type force: bool :raises RuntimeError: If creating the container or writing the container - config fails. + config fails. """ if self.is_container_present(): if force: diff --git a/resources/libraries/python/CpuUtils.py b/resources/libraries/python/CpuUtils.py index 3cb4454e6c..5d8b8a64a3 100644 --- a/resources/libraries/python/CpuUtils.py +++ b/resources/libraries/python/CpuUtils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -114,8 +114,8 @@ class CpuUtils(object): :type smt_used: bool :returns: List of cpu numbers related to numa from argument. :rtype: list of int - :raises RuntimeError: If node cpuinfo is not available or if SMT is not - enabled. + :raises RuntimeError: If node cpuinfo is not available + or if SMT is not enabled. """ cpu_node = int(cpu_node) diff --git a/resources/libraries/python/DPDK/L3fwdTest.py b/resources/libraries/python/DPDK/L3fwdTest.py index 773c125b92..d7e9305391 100644 --- a/resources/libraries/python/DPDK/L3fwdTest.py +++ b/resources/libraries/python/DPDK/L3fwdTest.py @@ -44,7 +44,7 @@ class L3fwdTest(object): :type lcores_list: str :type queue_nums: str :type jumbo_frames: str - :return: none + :returns: none """ if dut_node['type'] == NodeType.DUT: adj_mac0, adj_mac1 = L3fwdTest.get_adj_mac(nodes_info, dut_node, diff --git a/resources/libraries/python/DUTSetup.py b/resources/libraries/python/DUTSetup.py index ae42637f52..9c78cfe6aa 100644 --- a/resources/libraries/python/DUTSetup.py +++ b/resources/libraries/python/DUTSetup.py @@ -190,7 +190,7 @@ class DUTSetup(object): :type node: dict :returns: PID :rtype: int - :raises RuntimeError if it is not possible to get the PID. + :raises RuntimeError: If it is not possible to get the PID. """ ssh = SSH() @@ -510,7 +510,7 @@ class DUTSetup(object): :type vpp_pkg_dir: str :type vpp_rpm_pkgs: list :type vpp_deb_pkgs: list - :raises: RuntimeError if failed to remove or install VPP + :raises RuntimeError: If failed to remove or install VPP. """ logger.debug("Installing VPP") @@ -592,8 +592,8 @@ class DUTSetup(object): :param node: DUT node. :type node: dict - :raises: RuntimeError if failed to restart VPP, get VPP version or - get VPP interfaces + :raises RuntimeError: If failed to restart VPP, get VPP version + or get VPP interfaces. """ logger.debug("Verify VPP on node {0}".format(node['host'])) diff --git a/resources/libraries/python/DpdkUtil.py b/resources/libraries/python/DpdkUtil.py index b8c1d15a9f..541ec9b151 100644 --- a/resources/libraries/python/DpdkUtil.py +++ b/resources/libraries/python/DpdkUtil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -128,7 +128,7 @@ class DpdkUtil(object): :param args: List of testpmd parameters. :type node: dict :type args: dict - :return: nothing + :returns: nothing """ eal_options = DpdkUtil.get_eal_options(**args) pmd_options = DpdkUtil.get_pmd_options(**args) @@ -145,7 +145,7 @@ class DpdkUtil(object): :param node: Node to stop testpmd on. :type node: dict - :return: nothing + :returns: nothing """ ssh = SSH() ssh.connect(node) diff --git a/resources/libraries/python/DropRateSearch.py b/resources/libraries/python/DropRateSearch.py index 2de8e3c174..912d2e9f53 100644 --- a/resources/libraries/python/DropRateSearch.py +++ b/resources/libraries/python/DropRateSearch.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -125,7 +125,7 @@ class DropRateSearch(object): :type traffic_type: str :type traffic_type: bool :returns: Drop threshold exceeded? (True/False) - :rtype bool + :rtype: bool """ pass @@ -137,7 +137,7 @@ class DropRateSearch(object): :type max_rate: float :type min_rate: float :returns: nothing - :raises: ValueError if min rate is lower than 0 and higher than max rate + :raises ValueError: If min rate is lower than 0 or higher than max rate. """ if float(min_rate) <= 0: raise ValueError("min_rate must be higher than 0") @@ -153,7 +153,7 @@ class DropRateSearch(object): :param loss_acceptance: Loss acceptance treshold for PDR search. :type loss_acceptance: str :returns: nothing - :raises: ValueError if loss acceptance is lower than zero + :raises ValueError: If loss acceptance is lower than zero. """ if float(loss_acceptance) < 0: raise ValueError("Loss acceptance must be higher or equal 0") @@ -227,7 +227,7 @@ class DropRateSearch(object): :param rate_type: Type of rate to set. :type rate_type: RateType :returns: nothing - :raises: Exception if rate type is unknown + :raises Exception: If rate type is unknown. """ if rate_type not in RateType: raise Exception("rate_type unknown: {}".format(rate_type)) @@ -282,7 +282,7 @@ class DropRateSearch(object): :returns: String representation of rate type. :rtype: str - :raises: ValueError if rate type is unknown + :raises ValueError: If rate type is unknown. """ if self._rate_type == RateType.PERCENTAGE: return "%" @@ -299,7 +299,7 @@ class DropRateSearch(object): :param max_attempts: Number of traffic runs. :type max_attempts: int :returns: nothing - :raises: ValueError if max attempts is lower than zero + :raises ValueError: If max attempts is lower than zero. """ if int(max_attempts) > 0: self._max_attempts = int(max_attempts) @@ -334,7 +334,7 @@ class DropRateSearch(object): :param search_type: Type of search result evaluation to set. :type search_type: SearchResultType :returns: nothing - :raises: ValueError if search type is unknown + :raises ValueError: If search type is unknown. """ if search_type not in SearchResultType: raise ValueError("search_type unknown: {}".format(search_type)) @@ -372,7 +372,7 @@ class DropRateSearch(object): :type res_list: list :returns: Boolean based on search result type. :rtype: boolean - :raises: ValueError if search result type is unknown + :raises ValueError: If search result type is unknown. """ if self._search_result_type == SearchResultType.BEST_OF_N: return self._get_best_of_n(res_list) @@ -389,7 +389,7 @@ class DropRateSearch(object): :type start_rate: float :type traffic_type: str :returns: nothing - :raises: ValueError if start rate is not in range + :raises ValueError: If start rate is not in range. """ if not self._rate_min <= float(start_rate) <= self._rate_max: @@ -473,7 +473,7 @@ class DropRateSearch(object): :returns: Result rate and latency stats. :rtype: tuple - :raises: Exception if search failed + :raises Exception: If search failed. """ if self._search_result == SearchResults.FAILURE: raise Exception('Search FAILED') @@ -496,7 +496,7 @@ class DropRateSearch(object): :type skip_max_rate: bool :type skip_warmup: bool :returns: nothing - :raises: ValueError if input values are not valid + :raises ValueError: If input values are not valid. """ if not self._rate_min <= float(b_min) <= self._rate_max: @@ -546,7 +546,7 @@ class DropRateSearch(object): :type start_rate: float :type traffic_type: str :returns: nothing - :raises: RuntimeError if linear search failed + :raises RuntimeError: If linear search failed. """ self.linear_search(start_rate, traffic_type) @@ -596,7 +596,7 @@ class DropRateSearch(object): :returns: Returns True if num_a is close in value to num_b or equal. False otherwise. :rtype: boolean - :raises: ValueError if input values are not valid + :raises ValueError: If input values are not valid. """ if num_a == num_b: diff --git a/resources/libraries/python/HTTPRequest.py b/resources/libraries/python/HTTPRequest.py index c4e73c25f2..a64513b9ba 100644 --- a/resources/libraries/python/HTTPRequest.py +++ b/resources/libraries/python/HTTPRequest.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -48,10 +48,12 @@ class HTTPRequestError(Exception): When raising this exception, put this information to the message in this order: - - short description of the encountered problem, - - relevant messages if there are any collected, e.g., from caught - exception, - - relevant data if there are any collected. + + - short description of the encountered problem, + - relevant messages if there are any collected, e.g., from caught + exception, + - relevant data if there are any collected. + The logging is performed on two levels: 1. error - short description of the problem; 2. debug - detailed information. """ @@ -65,7 +67,7 @@ class HTTPRequestError(Exception): :param msg: Message to be displayed and logged. :param enable_logging: When True, logging is enabled, otherwise - logging is disabled. + logging is disabled. :type msg: str :type enable_logging: bool """ @@ -113,7 +115,7 @@ class HTTPRequest(object): :type ip_addr: str :type port: str or int :type path: str - :return: Full url. + :returns: Full url. :rtype: str """ @@ -168,7 +170,7 @@ class HTTPRequest(object): :type path: str :type enable_logging: bool :type kwargs: dict - :return: Status code and content of response. + :returns: Status code and content of response. :rtype: tuple :raises HTTPRequestError: If 1. it is not possible to connect, @@ -238,16 +240,16 @@ class HTTPRequest(object): :param path: URL path, e.g. /index.html. :param headers: Dictionary of HTTP Headers to send with the Request. :param timeout: How long to wait for the server to send data before - giving up, as a float, or a (connect timeout, read timeout) tuple. + giving up, as a float, or a (connect timeout, read timeout) tuple. :param enable_logging: Used to suppress errors when checking Honeycomb - state during suite setup and teardown. When True, logging is enabled, - otherwise logging is disabled. + state during suite setup and teardown. When True, + logging is enabled, otherwise logging is disabled. :type node: dict :type path: str :type headers: dict :type timeout: float or tuple :type enable_logging: bool - :return: Status code and content of response. + :returns: Status code and content of response. :rtype: tuple """ @@ -264,17 +266,17 @@ class HTTPRequest(object): :param path: URL path, e.g. /index.html. :param headers: Dictionary of HTTP Headers to send with the Request. :param payload: Dictionary, bytes, or file-like object to send in - the body of the Request. + the body of the Request. :param json: JSON formatted string to send in the body of the Request. :param timeout: How long to wait for the server to send data before - giving up, as a float, or a (connect timeout, read timeout) tuple. + giving up, as a float, or a (connect timeout, read timeout) tuple. :type node: dict :type path: str :type headers: dict :type payload: dict, bytes, or file-like object :type json: str :type timeout: float or tuple - :return: Status code and content of response. + :returns: Status code and content of response. :rtype: tuple """ return HTTPRequest._http_request('PUT', node, path, headers=headers, @@ -291,13 +293,13 @@ class HTTPRequest(object): :param path: URL path, e.g. /index.html. :param headers: Dictionary of HTTP Headers to send with the Request. :param payload: Dictionary, bytes, or file-like object to send in - the body of the Request. + the body of the Request. :param json: JSON formatted string to send in the body of the Request. :param timeout: How long to wait for the server to send data before - giving up, as a float, or a (connect timeout, read timeout) tuple. + giving up, as a float, or a (connect timeout, read timeout) tuple. :param enable_logging: Used to suppress errors when checking ODL - state during suite setup and teardown. When True, logging is enabled, - otherwise logging is disabled. + state during suite setup and teardown. When True, + logging is enabled, otherwise logging is disabled. :type node: dict :type path: str :type headers: dict @@ -305,7 +307,7 @@ class HTTPRequest(object): :type json: str :type timeout: float or tuple :type enable_logging: bool - :return: Status code and content of response. + :returns: Status code and content of response. :rtype: tuple """ return HTTPRequest._http_request('POST', node, path, @@ -321,11 +323,11 @@ class HTTPRequest(object): :param node: Honeycomb node. :param path: URL path, e.g. /index.html. :param timeout: How long to wait for the server to send data before - giving up, as a float, or a (connect timeout, read timeout) tuple. + giving up, as a float, or a (connect timeout, read timeout) tuple. :type node: dict :type path: str :type timeout: float or tuple - :return: Status code and content of response. + :returns: Status code and content of response. :rtype: tuple """ return HTTPRequest._http_request('DELETE', node, path, timeout=timeout) diff --git a/resources/libraries/python/IPsecUtil.py b/resources/libraries/python/IPsecUtil.py index 85ffe3a503..a4b8412e7c 100644 --- a/resources/libraries/python/IPsecUtil.py +++ b/resources/libraries/python/IPsecUtil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -229,9 +229,9 @@ class IPsecUtil(object): :param integ_alg: The integrity algorithm name. :param integ_key: The integrity key string. :param tunnel_src: Tunnel header source IPv4 or IPv6 address. If not - specified ESP transport mode is used. + specified ESP transport mode is used. :param tunnel_dst: Tunnel header destination IPv4 or IPv6 address. If - not specified ESP transport mode is used. + not specified ESP transport mode is used. :type node: dict :type sad_id: int :type spi: int @@ -266,17 +266,17 @@ class IPsecUtil(object): :param node: VPP node to add SAD entry on. :param n_entries: Number of SAD entries to be created. :param sad_id: First SAD entry ID. All subsequent SAD entries will have - id incremented by 1. + id incremented by 1. :param spi: Security Parameter Index of first SAD entry. All subsequent - SAD entries will have spi incremented by 1. + SAD entries will have spi incremented by 1. :param crypto_alg: The encryption algorithm name. :param crypto_key: The encryption key string. :param integ_alg: The integrity algorithm name. :param integ_key: The integrity key string. :param tunnel_src: Tunnel header source IPv4 or IPv6 address. If not - specified ESP transport mode is used. + specified ESP transport mode is used. :param tunnel_dst: Tunnel header destination IPv4 or IPv6 address. If - not specified ESP transport mode is used. + not specified ESP transport mode is used. :type node: dict :type n_entries: int :type sad_id: int @@ -381,19 +381,19 @@ class IPsecUtil(object): :param priority: SPD entry priority, higher number = higher priority. :param action: Policy action. :param inbound: If True policy is for inbound traffic, otherwise - outbound. + outbound. :param sa_id: SAD entry ID for protect action. :param laddr_range: Policy selector local IPv4 or IPv6 address range in - format IP/prefix or IP/mask. If no mask is provided, it's considered - to be /32. + format IP/prefix or IP/mask. If no mask is provided, + it's considered to be /32. :param raddr_range: Policy selector remote IPv4 or IPv6 address range in - format IP/prefix or IP/mask. If no mask is provided, it's considered - to be /32. + format IP/prefix or IP/mask. If no mask is provided, + it's considered to be /32. :param proto: Policy selector next layer protocol number. :param lport_range: Policy selector local TCP/UDP port range in format - <port_start>-<port_end>. + <port_start>-<port_end>. :param rport_range: Policy selector remote TCP/UDP port range in format - <port_start>-<port_end>. + <port_start>-<port_end>. :type node: dict :type spd_id: int :type priority: int @@ -450,15 +450,15 @@ class IPsecUtil(object): :param spd_id: SPD ID to add entries on. :param priority: SPD entries priority, higher number = higher priority. :param inbound: If True policy is for inbound traffic, otherwise - outbound. + outbound. :param sa_id: SAD entry ID for first entry. Each subsequent entry will - SAD entry ID incremented by 1. + SAD entry ID incremented by 1. :param raddr_ip: Policy selector remote IPv4 start address for the first - entry. Remote IPv4 end address will be calculated depending on - raddr_range parameter. Each subsequent entry will have start address - next after IPv4 end address of previous entry. + entry. Remote IPv4 end address will be calculated depending on + raddr_range parameter. Each subsequent entry will have start address + next after IPv4 end address of previous entry. :param raddr_range: Mask specifying range of Policy selector Remote IPv4 - addresses. Valid values are from 1 to 32. + addresses. Valid values are from 1 to 32. :type node: dict :type n_entries: int :type spd_id: int @@ -507,11 +507,11 @@ class IPsecUtil(object): :param integ_alg: The integrity algorithm name. :param integ_key: The integrity key string. :param raddr_ip1: Policy selector remote IPv4 start address for the - first tunnel in direction node1->node2. + first tunnel in direction node1->node2. :param raddr_ip2: Policy selector remote IPv4 start address for the - first tunnel in direction node2->node1. + first tunnel in direction node2->node1. :param raddr_range: Mask specifying range of Policy selector Remote IPv4 - addresses. Valid values are from 1 to 32. + addresses. Valid values are from 1 to 32. :type node1: dict :type node2: dict :type if1_ip_addr: str @@ -640,11 +640,11 @@ class IPsecUtil(object): :param tunnel_ip1: Tunnel node1 IPv4 address. :param tunnel_ip2: Tunnel node2 IPv4 address. :param raddr_ip1: Policy selector remote IPv4 start address for the - first tunnel in direction node1->node2. + first tunnel in direction node1->node2. :param raddr_ip2: Policy selector remote IPv4 start address for the - first tunnel in direction node2->node1. + first tunnel in direction node2->node1. :param raddr_range: Mask specifying range of Policy selector Remote IPv4 - addresses. Valid values are from 1 to 32. + addresses. Valid values are from 1 to 32. :type node1: dict :type node2: dict :type interface1: str or int diff --git a/resources/libraries/python/IPv4NodeAddress.py b/resources/libraries/python/IPv4NodeAddress.py index 617377d35a..27d55b7bb6 100644 --- a/resources/libraries/python/IPv4NodeAddress.py +++ b/resources/libraries/python/IPv4NodeAddress.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -42,8 +42,8 @@ class IPv4NetworkGenerator(object): def next_network(self): """ - :return: Next network in form (IPv4Network, subnet). - :raises: StopIteration if there are no more elements. + :returns: Next network in form (IPv4Network, subnet). + :raises StopIteration: If there are no more elements. """ if len(self._networks): return self._networks.pop() diff --git a/resources/libraries/python/IPv4Setup.py b/resources/libraries/python/IPv4Setup.py index 36dc6050a1..f9b067d0d8 100644 --- a/resources/libraries/python/IPv4Setup.py +++ b/resources/libraries/python/IPv4Setup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -99,7 +99,7 @@ class IPv4Node(object): :param interface: Interface name. :type interface: str - :return: nothing + :returns: nothing """ pass @@ -331,7 +331,7 @@ class IPv4Setup(object): interfaces from topology and use them to setup ARP entries. :param nodes_info: Dictionary containing information on all nodes - in topology. + in topology. :param nodes_addr: Nodes IPv4 addresses. :type nodes_info: dict :type nodes_addr: dict diff --git a/resources/libraries/python/IPv4Util.py b/resources/libraries/python/IPv4Util.py index 96572f5e1d..fa9d0fe6a9 100644 --- a/resources/libraries/python/IPv4Util.py +++ b/resources/libraries/python/IPv4Util.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -94,7 +94,7 @@ class IPv4Util(object): :type node: dict :type port: str :type nodes_addr: dict - :return: IPv4 prefix length. + :returns: IPv4 prefix length. :rtype: int """ for net in nodes_addr.values(): @@ -117,7 +117,7 @@ class IPv4Util(object): :type node: dict :type port: int :type nodes_addr: dict - :return: IPv4 subnet. + :returns: IPv4 subnet. :rtype: str """ for net in nodes_addr.values(): @@ -133,9 +133,9 @@ class IPv4Util(object): def flush_ip_addresses(port, node): """See IPv4Node.flush_ip_addresses for more information. - :param port: - :param node: - :return: + :param port: FIXME + :param node: FIXME + :returns: FIXME """ get_node(node).flush_ip_addresses(port) @@ -147,7 +147,7 @@ class IPv4Util(object): :param nodes_addr: Available nodes IPv4 addresses. :type link: str :type nodes_addr: dict - :return: Link IPv4 address. + :returns: Link IPv4 address. :rtype: str """ net = nodes_addr.get(link) @@ -163,7 +163,7 @@ class IPv4Util(object): :param nodes_addr: Available nodes IPv4 addresses. :type link: str :type nodes_addr: dict - :return: Link IPv4 address prefix. + :returns: Link IPv4 address prefix. :rtype: int """ net = nodes_addr.get(link) diff --git a/resources/libraries/python/IPv6Setup.py b/resources/libraries/python/IPv6Setup.py index 60e10a34e4..94c95e552f 100644 --- a/resources/libraries/python/IPv6Setup.py +++ b/resources/libraries/python/IPv6Setup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -40,9 +40,9 @@ class IPv6Networks(object): def next_network(self): """Get the next element of the iterator. - :return: IPv6 network. + :returns: IPv6 network. :rtype: IPv6Network object - :raises: StopIteration if there is no more elements. + :raises StopIteration: If there is no more elements. """ if len(self._networks): return self._networks.pop() diff --git a/resources/libraries/python/IPv6Util.py b/resources/libraries/python/IPv6Util.py index 1aab1816f2..f89d17169b 100644 --- a/resources/libraries/python/IPv6Util.py +++ b/resources/libraries/python/IPv6Util.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -37,7 +37,7 @@ class IPv6Util(object): :type count: int :type data_size: int :type timeout: int - :return: Number of lost packets. + :returns: Number of lost packets. :rtype: int """ ssh = SSH() @@ -74,7 +74,7 @@ class IPv6Util(object): :type cnt: int :type size: int :type timeout: int - :return: Number of lost packets. + :returns: Number of lost packets. :rtype: int """ dst_ip = IPv6Util.get_node_port_ipv6_address(dst_node, port, nodes_ip) @@ -90,7 +90,7 @@ class IPv6Util(object): :type node: dict :type iface_key: str :type nodes_addr: dict - :return: IPv6 address string. + :returns: IPv6 address string. :rtype: str """ interface = Topology.get_interface_name(node, iface_key) diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py index 503715c6dd..c0a8957935 100644 --- a/resources/libraries/python/InterfaceUtil.py +++ b/resources/libraries/python/InterfaceUtil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -130,7 +130,7 @@ class InterfaceUtil(object): :type node: dict :type timeout: int :returns: Nothing. - :raises: RuntimeError if the timeout period value has elapsed. + :raises RuntimeError: If the timeout period value has elapsed. """ if_ready = False not_ready = [] @@ -196,10 +196,10 @@ class InterfaceUtil(object): :type node: dict :type interface: int or str :returns: List of dictionaries containing data for each interface, or a - single dictionary for the specified interface. + single dictionary for the specified interface. :rtype: list or dict :raises TypeError: if the data type of interface is neither basestring - nor int. + nor int. """ with VatTerminal(node) as vat: response = vat.vat_terminal_exec_cmd_from_template( @@ -279,8 +279,8 @@ class InterfaceUtil(object): :type interface: str :type ip_version: str :returns: List of dictionaries, each containing IP address, subnet - prefix length and also the subnet mask for ipv4 addresses. - Note: A single interface may have multiple IP addresses assigned. + prefix length and also the subnet mask for ipv4 addresses. + Note: A single interface may have multiple IP addresses assigned. :rtype: list """ @@ -355,7 +355,7 @@ class InterfaceUtil(object): :returns: Interface driver or None if not found. :rtype: str :raises RuntimeError: If it is not possible to get the interface driver - information from the node. + information from the node. .. note:: # lspci -vmmks 0000:00:05.0 @@ -517,10 +517,6 @@ class InterfaceUtil(object): def update_tg_interface_data_on_node(node): """Update interface name for TG/linux node in DICT__nodes. - :param node: Node selected from DICT__nodes. - :type node: dict - :raises RuntimeError: If getting of interface name and MAC fails. - .. note:: # for dev in `ls /sys/class/net/`; > do echo "\"`cat /sys/class/net/$dev/address`\": \"$dev\""; done @@ -529,7 +525,11 @@ class InterfaceUtil(object): "52:54:00:e1:8a:0f": "eth2" "00:00:00:00:00:00": "lo" - .. todo:: parse lshw -json instead + .. note:: TODO: parse lshw -json instead + + :param node: Node selected from DICT__nodes. + :type node: dict + :raises RuntimeError: If getting of interface name and MAC fails. """ # First setup interface driver specified in yaml file InterfaceUtil.tg_set_interfaces_default_driver(node) @@ -646,7 +646,7 @@ class InterfaceUtil(object): :returns: Name and index of created subinterface. :rtype: tuple :raises RuntimeError: if it is unable to create VLAN subinterface on the - node. + node. """ iface_key = Topology.get_interface_by_name(node, interface) sw_if_index = Topology.get_interface_sw_index(node, iface_key) @@ -690,7 +690,7 @@ class InterfaceUtil(object): :returns: SW IF INDEX of created interface. :rtype: int :raises RuntimeError: if it is unable to create VxLAN interface on the - node. + node. """ output = VatExecutor.cmd_from_template(node, "vxlan_create.vat", src=source_ip, @@ -715,14 +715,14 @@ class InterfaceUtil(object): :param node: VPP node to get interface data from. :param interface: Numeric index or name string of a specific interface. - If None, information about all VxLAN interfaces is returned. + If None, information about all VxLAN interfaces is returned. :type node: dict :type interface: int or str :returns: Dictionary containing data for the given VxLAN interface or if - interface=None, the list of dictionaries with all VxLAN interfaces. + interface=None, the list of dictionaries with all VxLAN interfaces. :rtype: dict or list :raises TypeError: if the data type of interface is neither basestring - nor int. + nor int. """ param = "sw_if_index" if interface is None: @@ -771,7 +771,7 @@ class InterfaceUtil(object): :type node: dict :type name: str :returns: Dictionary of information about a specific TAP interface, or - a List of dictionaries containing all TAP data for the given node. + a List of dictionaries containing all TAP data for the given node. :rtype: dict or list """ with VatTerminal(node) as vat: @@ -797,7 +797,8 @@ class InterfaceUtil(object): :param outer_vlan_id: Optional outer VLAN ID. :param inner_vlan_id: Optional inner VLAN ID. :param type_subif: Optional type of sub-interface. Values supported by - VPP: [no_tags] [one_tag] [two_tags] [dot1ad] [exact_match] [default_sub] + VPP: [no_tags] [one_tag] [two_tags] [dot1ad] [exact_match] + [default_sub] :type node: dict :type interface: str or int :type sub_id: int @@ -895,7 +896,7 @@ class InterfaceUtil(object): :returns: SW interface index. :rtype: int :raises RuntimeError: If it is not possible to create loopback on the - node. + node. """ out = VatExecutor.cmd_from_template(node, "create_loopback.vat") if out[0].get('retval') == 0: @@ -1006,12 +1007,12 @@ class InterfaceUtil(object): :param node: VPP node to get interface data from. :param interface_name: Name of the specific interface. If None, - information about all VxLAN GPE interfaces is returned. + information about all VxLAN GPE interfaces is returned. :type node: dict :type interface_name: str :returns: Dictionary containing data for the given VxLAN GPE interface - or if interface=None, the list of dictionaries with all VxLAN GPE - interfaces. + or if interface=None, the list of dictionaries with all VxLAN GPE + interfaces. :rtype: dict or list """ diff --git a/resources/libraries/python/KubernetesUtils.py b/resources/libraries/python/KubernetesUtils.py index efeda69c92..3e45d3a60f 100644 --- a/resources/libraries/python/KubernetesUtils.py +++ b/resources/libraries/python/KubernetesUtils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -206,7 +206,7 @@ class KubernetesUtils(object): :type rtype: str :type name: str :raises RuntimeError: If retrieving or deleting Kubernetes resource - failed. + failed. """ ssh = SSH() ssh.connect(node) diff --git a/resources/libraries/python/L2Util.py b/resources/libraries/python/L2Util.py index 6b8bc042e3..7954193b60 100644 --- a/resources/libraries/python/L2Util.py +++ b/resources/libraries/python/L2Util.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -92,7 +92,7 @@ class L2Util(object): :type uu_flood: bool :type forward: bool :type learn: bool - :type arp_term:bool + :type arp_term: bool """ VatExecutor.cmd_from_template(node, "l2_bd_create.vat", bd_id=bd_id, flood=flood, @@ -132,7 +132,7 @@ class L2Util(object): :type sw_if_index: int :type bd_id: int :type shg: int - :return: + :returns: None """ VatExecutor.cmd_from_template(node, "l2_bd_add_sw_if_index.vat", bd_id=bd_id, sw_if_index=sw_if_index, @@ -151,12 +151,12 @@ class L2Util(object): :param node: Node data dictionary. :param link_names: List of names of links the bridge domain should be - connecting. + connecting. :param bd_id: Bridge domain index number. :type node: dict :type link_names: list - :return: Dictionary used to generate l2 bridge domain VAT configuration - from template file. + :returns: Dictionary used to generate l2 bridge domain VAT configuration + from template file. :rtype: dict """ bd_dict = Topology().get_interfaces_by_link_names(node, link_names) @@ -226,7 +226,7 @@ class L2Util(object): :param if_1: First interface to be added to the bridge. :param if_2: Second interface to be added to the bridge. :param set_up: Change bridge interface state to up after create bridge. - Optional. Default: True. + Optional. Default: True. :type node: dict :type br_name: str :type if_1: str @@ -247,15 +247,16 @@ class L2Util(object): def linux_del_bridge(node, br_name, set_down=True): """Delete bridge from linux node. + ..note:: The network interface corresponding to the bridge must be + down before it can be deleted! + :param node: Node to delete bridge from. :param br_name: Bridge name. :param set_down: Change bridge interface state to down before delbr - command. Optional. Default: True. + command. Optional. Default: True. :type node: str :type br_name: str :type set_down: bool - ..note:: The network interface corresponding to the bridge must be - down before it can be deleted! """ if set_down: cmd = 'ip link set dev {0} down'.format(br_name) @@ -272,8 +273,8 @@ class L2Util(object): :param bd_id: Numeric ID of a specific bridge domain. :type node: dict :type bd_id: int - :return: List of dictionaries containing data for each bridge domain, or - a single dictionary for the specified bridge domain. + :returns: List of dictionaries containing data for each bridge domain, + or a single dictionary for the specified bridge domain. :rtype: list or dict """ with VatTerminal(node) as vat: @@ -298,7 +299,7 @@ class L2Util(object): :param interface: Interface on which rewrite tags. :param tag_rewrite_method: Method of tag rewrite. :param push_dot1q: Optional parameter to disable to push dot1q tag - instead of dot1ad. + instead of dot1ad. :param tag1_id: Optional tag1 ID for VLAN. :param tag2_id: Optional tag2 ID for VLAN. :type node: dict @@ -367,7 +368,7 @@ class L2Util(object): :param bd_index: Index of the bridge domain. :type node: dict :type bd_index: int - :return: L2 FIB table. + :returns: L2 FIB table. :rtype: list """ @@ -393,7 +394,7 @@ class L2Util(object): :type node: dict :type bd_index: int :type mac: str - :return: L2 FIB entry + :returns: L2 FIB entry :rtype: dict """ diff --git a/resources/libraries/python/LispUtil.py b/resources/libraries/python/LispUtil.py index 89f12bb2f2..786dac4b44 100644 --- a/resources/libraries/python/LispUtil.py +++ b/resources/libraries/python/LispUtil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -45,7 +45,7 @@ class LispUtil(object): :param node: VPP node. :param items_filter: Filter which specifies which items should be - retrieved - local, remote, empty string = both. + retrieved - local, remote, empty string = both. :type node: dict :type items_filter: str :returns: Lisp locator_set data as python list. @@ -220,7 +220,7 @@ class LispUtil(object): :type node: dict :type locator_set_number: str :returns: list of lisp locator_set, list of lisp locator_set expected - from VAT. + from VAT. :rtype: tuple """ @@ -266,7 +266,7 @@ class LispUtil(object): :type node: dict :type locator_set_number: str :returns: list of lisp locator_set, list of lisp locator_set expected - from VAT. + from VAT. :rtype: tuple """ diff --git a/resources/libraries/python/MacSwap.py b/resources/libraries/python/MacSwap.py index 30281ba5a3..1ec6a5d216 100644 --- a/resources/libraries/python/MacSwap.py +++ b/resources/libraries/python/MacSwap.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -29,7 +29,7 @@ class MacSwap(object): :param interface: Interface id. :type node: dict :type interface: str or int - :return: nothing + :returns: nothing """ if node['type'] == NodeType.DUT: sw_if_index = Topology.get_interface_sw_index(node, interface) @@ -50,7 +50,7 @@ class MacSwap(object): :param interface_name: Interface name. :type node: dict :type interface_name: str or int - :return: nothing + :returns: nothing """ if node['type'] == NodeType.DUT: diff --git a/resources/libraries/python/Map.py b/resources/libraries/python/Map.py index 7e4d219bdd..ec1d22cec8 100644 --- a/resources/libraries/python/Map.py +++ b/resources/libraries/python/Map.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -35,7 +35,7 @@ class Map(object): :param psid_offset: Port Set Identifier (PSID) offset. :param psid_len: Port Set Identifier (PSID) length. :param map_t: Mapping using translation instead of encapsulation. - Default False. + Default False. :type vpp_node: dict :type ip4_pfx: str :type ip6_pfx: str @@ -108,7 +108,8 @@ class Map(object): @staticmethod def get_psid_from_port(port, psid_len, psid_offset): - """Return PSID from port. + """Return PSID from port.:: + 0 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +-----------+-----------+-------+ @@ -181,7 +182,7 @@ class Map(object): :type ea_bit_len: int :type psid: int :returns: Number representing interface id field of destination IPv6 - address. + address. :rtype: int """ if rule_net.prefixlen + ea_bit_len < 32: @@ -207,14 +208,13 @@ class Map(object): psid_offset, psid_len, ipv4_dst, dst_port): """Compute IPv6 destination address from IPv4 address for MAP algorithm. - (RFC 7597) - - | n bits | o bits | s bits | 128-n-o-s bits | - +--------------------+-----------+---------+-----------------------+ - | Rule IPv6 prefix | EA bits |subnet ID| interface ID | - +--------------------+-----------+---------+-----------------------+ - |<--- End-user IPv6 prefix --->| + (RFC 7597):: + | n bits | o bits | s bits | 128-n-o-s bits | + +--------------------+-----------+---------+-----------------------+ + | Rule IPv6 prefix | EA bits |subnet ID| interface ID | + +--------------------+-----------+---------+-----------------------+ + |<--- End-user IPv6 prefix --->| :param ipv4_pfx: Domain IPv4 preffix. :param ipv6_pfx: Domain IPv6 preffix. diff --git a/resources/libraries/python/NATUtil.py b/resources/libraries/python/NATUtil.py index ea13c9411f..ab97e05dcc 100644 --- a/resources/libraries/python/NATUtil.py +++ b/resources/libraries/python/NATUtil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -35,7 +35,7 @@ class NATUtil(object): :returns: Response of the command. :rtype: str :raises RuntimeError: If setting of inside and outside interfaces for - NAT44 fails. + NAT44 fails. """ try: @@ -65,7 +65,7 @@ class NATUtil(object): :returns: Response of the command. :rtype: str :raises RuntimeError: If setting of deterministic behaviour of NAT44 - fails. + fails. """ try: @@ -84,8 +84,8 @@ class NATUtil(object): """Set NAT workers. :param node: DUT node. - :param lcores: list of cores, format: range e.g. 1-5 or list of ranges - e.g.: 1-5,18-22. + :param lcores: List of cores, format: range e.g. 1-5 or list of ranges + e.g.: 1-5,18-22. :type node: dict :type lcores: str :returns: Response of the command. @@ -131,7 +131,7 @@ class NATUtil(object): :returns: Response of the command. :rtype: str :raises RuntimeError: If command 'exec snat deterministic forward' - fails. + fails. """ try: @@ -156,7 +156,7 @@ class NATUtil(object): :returns: Response of the command. :rtype: str :raises RuntimeError: If command 'exec snat deterministic reverse' - fails. + fails. """ try: diff --git a/resources/libraries/python/NodePath.py b/resources/libraries/python/NodePath.py index 8ee29b234d..f41103046f 100644 --- a/resources/libraries/python/NodePath.py +++ b/resources/libraries/python/NodePath.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -93,12 +93,13 @@ class NodePath(object): def compute_path(self, always_same_link=True): """Compute path for added nodes. + .. note:: First add at least two nodes to the topology. + :param always_same_link: If True use always same link between two nodes - in path. If False use different link (if available) between two - nodes if one link was used before. + in path. If False use different link (if available) + between two nodes if one link was used before. :type always_same_link: bool - - .. note:: First add at least two nodes to the topology. + :raises RuntimeError: If not enough nodes for path. """ nodes = self._nodes if len(nodes) < 2: diff --git a/resources/libraries/python/PacketVerifier.py b/resources/libraries/python/PacketVerifier.py index 9306f486ba..d1e7bbd229 100644 --- a/resources/libraries/python/PacketVerifier.py +++ b/resources/libraries/python/PacketVerifier.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -13,53 +13,55 @@ """PacketVerifier module. - :Example: - - >>> from scapy.all import * - >>> from PacketVerifier import * - >>> rxq = RxQueue('eth1') - >>> txq = TxQueue('eth1') - >>> src_mac = "AA:BB:CC:DD:EE:FF" - >>> dst_mac = "52:54:00:ca:5d:0b" - >>> src_ip = "11.11.11.10" - >>> dst_ip = "11.11.11.11" - >>> sent_packets = [] - >>> pkt_send = Ether(src=src_mac, dst=dst_mac) / - ... IP(src=src_ip, dst=dst_ip) / - ... ICMP() - >>> sent_packets.append(pkt_send) - >>> txq.send(pkt_send) - >>> pkt_send = Ether(src=src_mac, dst=dst_mac) / - ... ARP(hwsrc=src_mac, psrc=src_ip, hwdst=dst_mac, pdst=dst_ip, op=2) - >>> sent_packets.append(pkt_send) - >>> txq.send(pkt_send) - >>> rxq.recv(100, sent_packets).show() - ###[ Ethernet ]### - dst = aa:bb:cc:dd:ee:ff - src = 52:54:00:ca:5d:0b - type = 0x800 - ###[ IP ]### - version = 4L - ihl = 5L - tos = 0x0 - len = 28 - id = 43183 - flags = - frag = 0L - ttl = 64 - proto = icmp - chksum = 0xa607 - src = 11.11.11.11 - dst = 11.11.11.10 - options - ###[ ICMP ]### - type = echo-reply - code = 0 - chksum = 0xffff - id = 0x0 - seq = 0x0 - ###[ Padding ]### - load = 'RT\x00\xca]\x0b\xaa\xbb\xcc\xdd\xee\xff\x08\x06\x00\x01\x08\x00' + Example. :: + + | >>> from scapy.all import * + | >>> from PacketVerifier import * + | >>> rxq = RxQueue('eth1') + | >>> txq = TxQueue('eth1') + | >>> src_mac = "AA:BB:CC:DD:EE:FF" + | >>> dst_mac = "52:54:00:ca:5d:0b" + | >>> src_ip = "11.11.11.10" + | >>> dst_ip = "11.11.11.11" + | >>> sent_packets = [] + | >>> pkt_send = Ether(src=src_mac, dst=dst_mac) / + | ... IP(src=src_ip, dst=dst_ip) / + | ... ICMP() + | >>> sent_packets.append(pkt_send) + | >>> txq.send(pkt_send) + | >>> pkt_send = Ether(src=src_mac, dst=dst_mac) / + | ... ARP(hwsrc=src_mac, psrc=src_ip, hwdst=dst_mac, pdst=dst_ip, op=2) + | >>> sent_packets.append(pkt_send) + | >>> txq.send(pkt_send) + | >>> rxq.recv(100, sent_packets).show() + | ###[ Ethernet ]### + | dst = aa:bb:cc:dd:ee:ff + | src = 52:54:00:ca:5d:0b + | type = 0x800 + | ###[ IP ]### + | version = 4L + | ihl = 5L + | tos = 0x0 + | len = 28 + | id = 43183 + | flags = + | frag = 0L + | ttl = 64 + | proto = icmp + | chksum = 0xa607 + | src = 11.11.11.11 + | dst = 11.11.11.10 + | options + | ###[ ICMP ]### + | type = echo-reply + | code = 0 + | chksum = 0xffff + | id = 0x0 + | seq = 0x0 + | ###[ Padding ]### + | load = 'RT\x00\xca]\x0b\xaa\xbb\xcc\xdd\xee\xff\x08\x06\x00\x01\x08\x00' + + Example end. """ import os diff --git a/resources/libraries/python/Policer.py b/resources/libraries/python/Policer.py index b95fd739fc..c72212914b 100644 --- a/resources/libraries/python/Policer.py +++ b/resources/libraries/python/Policer.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -412,9 +412,10 @@ class Policer(object): def policer_classify_set_interface(self, interface): """Set policer classify interface. + .. note:: First set node with policer_set_node. + :param interface: Interface name or sw_if_index. :type interface: str or int - .. note:: First set node with policer_set_node. """ if isinstance(interface, basestring): self._sw_if_index = Topology.get_interface_sw_index(self._node, @@ -437,7 +438,7 @@ class Policer(object): def dscp_cs0(): """Return DSCP CS0. - :return: DSCP enum CS0 object. + :returns: DSCP enum CS0 object. :rtype: DSCP """ return DSCP.CS0 @@ -446,7 +447,7 @@ class Policer(object): def dscp_cs1(): """Return DSCP CS1. - :return: DSCP enum CS1 object. + :returns: DSCP enum CS1 object. :rtype: DSCP """ return DSCP.CS1 @@ -455,7 +456,7 @@ class Policer(object): def dscp_cs2(): """Return DSCP CS2. - :return: DSCP enum CS2 object. + :returns: DSCP enum CS2 object. :rtype: DSCP """ return DSCP.CS2 @@ -464,7 +465,7 @@ class Policer(object): def dscp_cs3(): """Return DSCP CS3. - :return: DSCP enum CS3 object. + :returns: DSCP enum CS3 object. :rtype: DSCP """ return DSCP.CS3 @@ -473,7 +474,7 @@ class Policer(object): def dscp_cs4(): """Return DSCP CS4. - :return: DSCP enum CS4 object. + :returns: DSCP enum CS4 object. :rtype: DSCP """ return DSCP.CS4 @@ -482,7 +483,7 @@ class Policer(object): def dscp_cs5(): """Return DSCP CS5. - :return: DSCP enum CS5 object. + :returns: DSCP enum CS5 object. :rtype: DSCP """ return DSCP.CS5 @@ -491,7 +492,7 @@ class Policer(object): def dscp_cs6(): """Return DSCP CS6. - :return: DSCP enum CS6 object. + :returns: DSCP enum CS6 object. :rtype: DSCP """ return DSCP.CS6 @@ -500,7 +501,7 @@ class Policer(object): def dscp_cs7(): """Return DSCP CS7. - :return: DSCP enum CS7 object. + :returns: DSCP enum CS7 object. :rtype: DSCP """ return DSCP.CS7 @@ -509,7 +510,7 @@ class Policer(object): def dscp_ef(): """Return DSCP EF. - :return: DSCP enum EF object. + :returns: DSCP enum EF object. :rtype: DSCP """ return DSCP.EF @@ -518,7 +519,7 @@ class Policer(object): def dscp_af11(): """Return DSCP AF11. - :return: DSCP enum AF11 object. + :returns: DSCP enum AF11 object. :rtype: DSCP """ return DSCP.AF11 @@ -527,7 +528,7 @@ class Policer(object): def dscp_af12(): """Return DSCP AF12. - :return: DSCP enum AF12 object. + :returns: DSCP enum AF12 object. :rtype: DSCP """ return DSCP.AF12 @@ -536,7 +537,7 @@ class Policer(object): def dscp_af13(): """Return DSCP AF13. - :return: DSCP enum AF13 object. + :returns: DSCP enum AF13 object. :rtype: DSCP """ return DSCP.AF13 @@ -545,7 +546,7 @@ class Policer(object): def dscp_af21(): """Return DSCP AF21. - :return: DSCP enum AF21 object. + :returns: DSCP enum AF21 object. :rtype: DSCP """ return DSCP.AF21 @@ -554,7 +555,7 @@ class Policer(object): def dscp_af22(): """Return DSCP AF22. - :return: DSCP enum AF22 object. + :returns: DSCP enum AF22 object. :rtype: DSCP """ return DSCP.AF22 @@ -563,7 +564,7 @@ class Policer(object): def dscp_af23(): """Return DSCP AF23. - :return: DSCP enum AF23 object. + :returns: DSCP enum AF23 object. :rtype: DSCP """ return DSCP.AF23 @@ -572,7 +573,7 @@ class Policer(object): def dscp_af31(): """Return DSCP AF31. - :return: DSCP enum AF31 object. + :returns: DSCP enum AF31 object. :rtype: DSCP """ return DSCP.AF31 @@ -581,7 +582,7 @@ class Policer(object): def dscp_af32(): """Return DSCP AF32. - :return: DSCP enum AF32 object. + :returns: DSCP enum AF32 object. :rtype: DSCP """ return DSCP.AF32 @@ -590,7 +591,7 @@ class Policer(object): def dscp_af33(): """Return DSCP AF33. - :return: DSCP enum AF33 object. + :returns: DSCP enum AF33 object. :rtype: DSCP """ return DSCP.AF33 @@ -601,7 +602,7 @@ class Policer(object): :param dscp: DSCP enum object. :type dscp: DSCP - :return: DSCP numeric value. + :returns: DSCP numeric value. :rtype: int """ return dscp.num diff --git a/resources/libraries/python/QemuUtils.py b/resources/libraries/python/QemuUtils.py index 42ccb8c9dd..99fb7f4b8d 100644 --- a/resources/libraries/python/QemuUtils.py +++ b/resources/libraries/python/QemuUtils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -166,7 +166,7 @@ class QemuUtils(object): """Set scheduler policy to SCHED_RR with priority 1 for all Qemu CPU processes. - :raises RuntimeError: Set scheduler policy failed. + :raises RuntimeError: Set scheduler policy failed. """ qemu_cpus = self._qemu_qmp_exec('query-cpus')['return'] @@ -199,7 +199,7 @@ class QemuUtils(object): :param socket: Path of the unix socket. :param server: If True the socket shall be a listening socket. :param mac: Vhost-user interface MAC address (optional, otherwise is - used auto-generated MAC 52:54:00:00:xx:yy). + used auto-generated MAC 52:54:00:00:xx:yy). :param jumbo_frames: Set True if jumbo frames are used in the test. :type socket: str :type server: bool @@ -247,7 +247,7 @@ class QemuUtils(object): :param cmd: QMP command to execute. :type cmd: str - :return: Command output in python representation of JSON format. The + :returns: Command output in python representation of JSON format. The { "return": {} } response is QMP's success response. An error response will contain the "error" keyword instead of "return". """ @@ -449,7 +449,7 @@ class QemuUtils(object): :returns: Default size of free huge pages in system. :rtype: int - :raises: RuntimeError if reading failed for three times. + :raises RuntimeError: If reading failed for three times. """ # TODO: remove to dedicated library cmd_huge_size = "grep Hugepagesize /proc/meminfo | awk '{ print $2 }'" @@ -473,7 +473,7 @@ class QemuUtils(object): :type huge_size: int :returns: Number of free huge pages in system. :rtype: int - :raises: RuntimeError if reading failed for three times. + :raises RuntimeError: If reading failed for three times. """ # TODO: add numa aware option # TODO: remove to dedicated library @@ -499,7 +499,7 @@ class QemuUtils(object): :type huge_size: int :returns: Total number of huge pages in system. :rtype: int - :raises: RuntimeError if reading failed for three times. + :raises RuntimeError: If reading failed for three times. """ # TODO: add numa aware option # TODO: remove to dedicated library @@ -521,10 +521,11 @@ class QemuUtils(object): def qemu_start(self): """Start QEMU and wait until VM boot. - :return: VM node info. - :rtype: dict .. note:: First set at least node to run QEMU on. .. warning:: Starts only one VM on the node. + + :returns: VM node info. + :rtype: dict """ # Qemu binary path bin_path = '{0}{1}'.format(self._qemu_path, self._qemu_bin) @@ -659,7 +660,7 @@ class QemuUtils(object): - watchdog: watchdog action has been triggered - guest-panicked: panicked as a result of guest OS panic - :return: VM status. + :returns: VM status. :rtype: str """ out = self._qemu_qmp_exec('query-status') @@ -682,7 +683,7 @@ class QemuUtils(object): :type node: dict :type force_install: bool :type apply_patch: bool - :raises: RuntimeError if building QEMU failed. + :raises RuntimeError: If building QEMU failed. """ ssh = SSH() ssh.connect(node) diff --git a/resources/libraries/python/Routing.py b/resources/libraries/python/Routing.py index b4771d6224..e6485ba3bc 100644 --- a/resources/libraries/python/Routing.py +++ b/resources/libraries/python/Routing.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -38,7 +38,7 @@ class Routing(object): :param resolve_attempts: Resolve attempts IP route add parameter. :param count: number of IP addresses to add starting from network IP :param local: The route is local - with same prefix (increment is 1). If None, then is not used. + with same prefix (increment is 1). If None, then is not used. :param lookup_vrf: VRF table ID for lookup. :param multipath: Enable multipath routing. :param weight: Weight value for unequal cost multipath routing. diff --git a/resources/libraries/python/SFC/SetupSFCTest.py b/resources/libraries/python/SFC/SetupSFCTest.py index a1d99c5cc6..0ba197115d 100644 --- a/resources/libraries/python/SFC/SetupSFCTest.py +++ b/resources/libraries/python/SFC/SetupSFCTest.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -38,7 +38,7 @@ def pack_framework_dir(): :returns: the temporary package file name. :rtype: str - :raises: If execute the tar command failed. + :raises RuntimeError: If execute the tar command failed. """ tmpfile = NamedTemporaryFile(suffix=".tgz", prefix="SFC-testing-") @@ -86,7 +86,7 @@ def extract_tarball_at_node(tarball, node): :type tarball: str :type node: dict :returns: nothing - :raises: If unpack the file failed. + :raises RuntimeError: If unpack the file failed. """ logger.console('Extracting tarball to {0} on {1}'.format( con.REMOTE_FW_DIR, node['host'])) diff --git a/resources/libraries/python/TLDK/SetupTLDKTest.py b/resources/libraries/python/TLDK/SetupTLDKTest.py index 7692902b7c..e4d7120022 100644 --- a/resources/libraries/python/TLDK/SetupTLDKTest.py +++ b/resources/libraries/python/TLDK/SetupTLDKTest.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -97,7 +97,7 @@ def extract_tarball_at_node(tarball, node): :param node: Dictionary created from topology. :type tarball: str :type node: dict - :return: nothing + :returns: nothing :raises RuntimeError: If extract tarball failed. """ logger.console('Extracting tarball to {0} on {1}'.format( diff --git a/resources/libraries/python/Tap.py b/resources/libraries/python/Tap.py index cf0ae215ed..ffcd00cdaf 100644 --- a/resources/libraries/python/Tap.py +++ b/resources/libraries/python/Tap.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -67,7 +67,7 @@ class Tap(object): :type if_index: int :type tap_name: str :type mac: str - :return: Returns a interface index. + :returns: Returns a interface index. :rtype: int """ command = 'modify' diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index b7c8d6ef4e..4da1c8766f 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -50,8 +50,8 @@ class TGDropRateSearchImpl(DropRateSearch): :type skip_warmup: bool :returns: Drop threshold exceeded? (True/False) :rtype: bool - :raises: NotImplementedError if TG is not supported. - :raises: RuntimeError if TG is not specified. + :raises NotImplementedError: If TG is not supported. + :raises RuntimeError: If TG is not specified. """ # we need instance of TrafficGenerator instantiated by Robot Framework # to be able to use trex_stl-*() @@ -182,7 +182,7 @@ class TrafficGenerator(object): :type tg_if1_dst_mac: str :type tg_if2_dst_mac: str :returns: nothing - :raises: RuntimeError in case of issue during initialization. + :raises RuntimeError: In case of issue during initialization. """ if tg_node['type'] != NodeType.TG: raise RuntimeError('Node type is not a TG') @@ -323,7 +323,7 @@ class TrafficGenerator(object): :type node: dict :returns: True if TRex is running otherwise False. :rtype: bool - :raises: RuntimeError if node type is not a TG. + :raises RuntimeError: If node type is not a TG. """ if node['type'] != NodeType.TG: raise RuntimeError('Node type is not a TG') @@ -340,8 +340,8 @@ class TrafficGenerator(object): :param node: Traffic generator node. :type node: dict :returns: nothing - :raises: RuntimeError if TRex teardown failed. - :raises: RuntimeError if node type is not a TG. + :raises RuntimeError: If node type is not a TG, + or if TRex teardown fails. """ if node['type'] != NodeType.TG: raise RuntimeError('Node type is not a TG') @@ -360,7 +360,7 @@ class TrafficGenerator(object): :param node: TRex generator node. :type node: dict :returns: Nothing - :raises: RuntimeError if stop traffic script fails. + :raises RuntimeError: If stop traffic script fails. """ ssh = SSH() ssh.connect(node) @@ -392,7 +392,7 @@ class TrafficGenerator(object): :type latency: bool :type warmup_time: int :returns: Nothing - :raises: RuntimeError in case of TG driver issue. + :raises RuntimeError: In case of TG driver issue. """ ssh = SSH() ssh.connect(self._node) @@ -447,7 +447,7 @@ class TrafficGenerator(object): """Stop all traffic on TG. :returns: Nothing - :raises: RuntimeError if TG is not set. + :raises RuntimeError: If TG is not set. """ if self._node is None: raise RuntimeError("TG is not set") @@ -475,9 +475,9 @@ class TrafficGenerator(object): :type latency: bool :returns: TG output. :rtype: str - :raises: RuntimeError if TG is not set. - :raises: RuntimeError if node is not TG or subtype is not specified. - :raises: NotImplementedError if TG is not supported. + :raises RuntimeError: If TG is not set, or if node is not TG, + or if subtype is not specified. + :raises NotImplementedError: If TG is not supported. """ node = self._node @@ -502,7 +502,7 @@ class TrafficGenerator(object): """Fail if loss occurred in traffic run. :returns: nothing - :raises: Exception if loss occured. + :raises Exception: If loss occured. """ if self._loss is None: raise Exception('The traffic generation has not been issued') @@ -518,7 +518,7 @@ class TrafficGenerator(object): :type loss_acceptance: float :type loss_acceptance_type: LossAcceptanceType :returns: nothing - :raises: Exception if loss is above acceptance criteria. + :raises Exception: If loss is above acceptance criteria. """ if self._loss is None: raise Exception('The traffic generation has not been issued') diff --git a/resources/libraries/python/TrafficScriptArg.py b/resources/libraries/python/TrafficScriptArg.py index dc655d2e8c..64d0747b27 100644 --- a/resources/libraries/python/TrafficScriptArg.py +++ b/resources/libraries/python/TrafficScriptArg.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -58,7 +58,7 @@ class TrafficScriptArg(object): :param arg_name: Argument name. :type arg_name: str - :return: Argument value. + :returns: Argument value. :rtype: str """ arg_val = self._args.get(arg_name) diff --git a/resources/libraries/python/TrafficScriptExecutor.py b/resources/libraries/python/TrafficScriptExecutor.py index 13696dee8d..db5e434b42 100644 --- a/resources/libraries/python/TrafficScriptExecutor.py +++ b/resources/libraries/python/TrafficScriptExecutor.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -28,7 +28,7 @@ class TrafficScriptExecutor(object): :param string: String to escape. :type string: str - :return: Escaped string. + :returns: Escaped string. :rtype: str """ return string.replace('"', '\\"').replace("$", "\\$") @@ -97,7 +97,7 @@ class TrafficScriptExecutor(object): :type dst_mac: str :type src_ip: str :type dst_ip: str - :return: Traffic script arguments string. + :returns: Traffic script arguments string. :rtype: str """ args = ('--rx_if {0} --tx_if {1} --src_mac {2} --dst_mac {3} --src_ip' diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py index 5881d18966..3a0148a481 100644 --- a/resources/libraries/python/VPPUtil.py +++ b/resources/libraries/python/VPPUtil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -26,7 +26,7 @@ class VPPUtil(object): :param node: VPP node. :param additional_cmds: Additional commands that the vpp should print - settings for. + settings for. :type node: dict :type additional_cmds: tuple """ diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py index 7d03fcd4a6..41e97e3901 100644 --- a/resources/libraries/python/VatExecutor.py +++ b/resources/libraries/python/VatExecutor.py @@ -56,7 +56,7 @@ def get_vpp_pid(node): :param node: DUT node. :type node: dict :returns: PID of VPP process / List of PIDs if more VPP processes are - running on the DUT node. + running on the DUT node. :rtype: int or list """ import resources.libraries.python.DUTSetup as PidLib @@ -79,18 +79,21 @@ class VatExecutor(object): Path is defined automatically. :param vat_name: Name of the vat script file. Only the file name of - the script is required, the resources path is prepended automatically. + the script is required, the resources path is prepended + automatically. :param node: Node to execute the VAT script on. :param timeout: Seconds to allow the script to run. :param json_out: Require JSON output. :param copy_on_execute: If true, copy the file from local host to remote - before executing. + before executing. :type vat_name: str :type node: dict :type timeout: int :type json_out: bool :type copy_on_execute: bool - :raises RuntimeError: If VAT script execution failed. + :raises SSHException: If cannot open connection for VAT. + :raises SSHTimeout: If VAT execution is timed out. + :raises RuntimeError: If VAT script execution fails. """ ssh = SSH() try: @@ -131,8 +134,9 @@ class VatExecutor(object): """Pass all arguments to 'execute_script' method, then cleanup returned json output. - :param vat_name: Name of the vat script file. Only the file name of - the script is required, the resources path is prepended automatically. + :param vat_name: Name of the vat script file. Only the file name of + the script is required, the resources path is prepended + automatically. :param node: Node to execute the VAT script on. :param timeout: Seconds to allow the script to run. :type vat_name: str @@ -178,7 +182,7 @@ class VatExecutor(object): :param node: Node in topology on witch the script is executed. :param vat_template_file: Template file of VAT script. :param vat_args: Arguments to the template file. - :return: List of JSON objects returned by VAT. + :returns: List of JSON objects returned by VAT. """ with VatTerminal(node) as vat: return vat.vat_terminal_exec_cmd_from_template(vat_template_file, @@ -190,7 +194,7 @@ class VatTerminal(object): :param node: Node to open VAT terminal on. :param json_param: Defines if outputs from VAT are in JSON format. - Default is True. + Default is True. :type node: dict :type json_param: bool @@ -250,8 +254,8 @@ class VatTerminal(object): :param cmd: Command to be executed. - :return: Command output in python representation of JSON format or - None if not in JSON mode. + :returns: Command output in python representation of JSON format or + None if not in JSON mode. """ VatHistory.add_to_vat_history(self._node, cmd) logger.debug("Executing command in VAT terminal: {0}".format(cmd)) @@ -331,7 +335,7 @@ class VatTerminal(object): :param vat_template_file: Template file name of a VAT script. :param args: Dictionary of parameters for VAT script. - :return: List of JSON objects returned by VAT. + :returns: List of JSON objects returned by VAT. """ file_path = '{}/{}'.format(Constants.RESOURCES_TPL_VAT, vat_template_file) diff --git a/resources/libraries/python/VatJsonUtil.py b/resources/libraries/python/VatJsonUtil.py index 6445d8c387..4db4eb641a 100644 --- a/resources/libraries/python/VatJsonUtil.py +++ b/resources/libraries/python/VatJsonUtil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -30,7 +30,7 @@ class VatJsonUtil(object): :param mac_address: MAC address. :type mac_address: str - :return: List representation of MAC address. + :returns: List representation of MAC address. :rtype: list """ list_mac = [] @@ -49,7 +49,7 @@ class VatJsonUtil(object): :param mac_address: MAC address of interface we are looking for. :type interfaces_list: dict :type mac_address: str - :return: Interface from JSON. + :returns: Interface from JSON. :rtype: dict """ interface_dict = {} @@ -85,7 +85,7 @@ class VatJsonUtil(object): :param node: Node dictionary. :param interface_dump_json: JSON output from dump_interface_list VAT - command. + command. :type node: dict :type interface_dump_json: str """ @@ -107,11 +107,11 @@ class VatJsonUtil(object): """Get sw_if_index from given JSON output by interface name. :param interface_dump_json: JSON output from dump_interface_list VAT - command. + command. :param interface_name: Interface name. :type interface_dump_json: str :type interface_name: str - :return: SW interface index. + :returns: SW interface index. :rtype: int :raises ValueError: If interface not found in interface_dump_json. """ @@ -134,11 +134,11 @@ class VatJsonUtil(object): """Get interface name from given JSON output by sw_if_index. :param interface_dump_json: JSON output from dump_interface_list VAT - command. + command. :param sw_if_index: SW interface index. :type interface_dump_json: str :type sw_if_index: int - :return: Interface name. + :returns: Interface name. :rtype: str :raises ValueError: If interface not found in interface_dump_json. """ diff --git a/resources/libraries/python/honeycomb/BGP.py b/resources/libraries/python/honeycomb/BGP.py index 75dce762ff..fa51b8727b 100644 --- a/resources/libraries/python/honeycomb/BGP.py +++ b/resources/libraries/python/honeycomb/BGP.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -44,7 +44,7 @@ class BGPKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response to PUT is not - 200 = OK or 201 = ACCEPTED. + 200 = OK or 201 = ACCEPTED. """ if data is None: @@ -72,7 +72,7 @@ class BGPKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response to PUT is not - 200 = OK or 201 = ACCEPTED. + 200 = OK or 201 = ACCEPTED. """ if data is None: @@ -115,7 +115,7 @@ class BGPKeywords(object): :param datastore: Get data from config or operational datastore. :type node: dict :type address: str - :type datastore; str + :type datastore: str :returns: BGP peer configuration data. :rtype: dict :raises HoneycombError: If the status code in response is not 200 = OK. @@ -382,7 +382,8 @@ class BGPKeywords(object): :param ref: Reference data to compare against. :type data: dict :type ref: dict - :raises HoneycombError: If the tables do not match.""" + :raises HoneycombError: If the tables do not match. + """ # Remove runtime attributes from data for item in data: diff --git a/resources/libraries/python/honeycomb/DHCP.py b/resources/libraries/python/honeycomb/DHCP.py index 3c03b1405f..13cc4a77cc 100644 --- a/resources/libraries/python/honeycomb/DHCP.py +++ b/resources/libraries/python/honeycomb/DHCP.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -37,7 +37,7 @@ class DHCPRelayKeywords(object): :type node: dict :type path: str :type data: dict - :return: Content of response. + :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response is not 200 = OK or 201 = ACCEPTED. diff --git a/resources/libraries/python/honeycomb/HcAPIKwACL.py b/resources/libraries/python/honeycomb/HcAPIKwACL.py index 556c39644f..49fc351b01 100644 --- a/resources/libraries/python/honeycomb/HcAPIKwACL.py +++ b/resources/libraries/python/honeycomb/HcAPIKwACL.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -50,7 +50,7 @@ class ACLKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response to PUT is not - 200 = OK. + 200 = OK. """ if data: @@ -266,7 +266,6 @@ class ACLKeywords(object): :type list_name: str :type data: dict :type macip: bool - :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the operation fails. @@ -296,14 +295,13 @@ class ACLKeywords(object): :param interface: Name of an interface on the node. :param acl_name: Name of an ACL chain configured through ACL-plugin. :param direction: Classify incoming or outgiong packets. - Valid options are: ingress, egress + Valid options are: ingress, egress :param macip: Use simple MAC+IP classifier. Optional. :type node: dict :type interface: str or int :type acl_name: str :type direction: str :type macip: bool - :returns: Content of response. :rtype: bytearray :raises ValueError: If the direction argument is incorrect. diff --git a/resources/libraries/python/honeycomb/HcAPIKwBridgeDomain.py b/resources/libraries/python/honeycomb/HcAPIKwBridgeDomain.py index 3c629c96e4..576124794c 100644 --- a/resources/libraries/python/honeycomb/HcAPIKwBridgeDomain.py +++ b/resources/libraries/python/honeycomb/HcAPIKwBridgeDomain.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -52,10 +52,10 @@ class BridgeDomainKeywords(object): :type bd_name: str :type data: dict :type data_representation: DataRepresentation - :return: Content of response. + :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response on PUT is not - 200 = OK. + 200 = OK. """ status_code, resp = HcUtil.\ @@ -78,12 +78,12 @@ class BridgeDomainKeywords(object): :param bd_name: The name of bridge domain. :param path: Path to data we want to change, create or remove. :param new_value: The new value to be set. If None, the item will be - removed. + removed. :type node: dict :type bd_name: str :type path: tuple :type new_value: str, dict or list - :return: Content of response. + :returns: Content of response. :rtype: bytearray :raises HoneycombError: If it is not possible to get or set the data. """ @@ -109,10 +109,10 @@ class BridgeDomainKeywords(object): :param bd_name: Bridge domain name. :param kwargs: Parameters and their values. The accepted parameters are - defined in BridgeDomainKeywords.PARAMS. + defined in BridgeDomainKeywords.PARAMS. :type bd_name: str :type kwargs: dict - :return: Bridge domain data structure. + :returns: Bridge domain data structure. :rtype: dict """ @@ -132,7 +132,7 @@ class BridgeDomainKeywords(object): :param node: Honeycomb node. :type node: dict - :return: Configuration data about all bridge domains from Honeycomb. + :returns: Configuration data about all bridge domains from Honeycomb. :rtype: list :raises HoneycombError: If it is not possible to get configuration data. """ @@ -157,8 +157,8 @@ class BridgeDomainKeywords(object): :param bd_name: The name of bridge domain. :type node: dict :type bd_name: str - :return: Configuration data about the given bridge domain from - Honeycomb. + :returns: Configuration data about the given bridge domain from + Honeycomb. :rtype: dict """ @@ -174,7 +174,7 @@ class BridgeDomainKeywords(object): :param node: Honeycomb node. :type node: dict - :return: Operational data about all bridge domains from Honeycomb. + :returns: Operational data about all bridge domains from Honeycomb. :rtype: list :raises HoneycombError: If it is not possible to get operational data. """ @@ -199,7 +199,7 @@ class BridgeDomainKeywords(object): :param bd_name: The name of bridge domain. :type node: dict :type bd_name: str - :return: Operational data about the given bridge domain from Honeycomb. + :returns: Operational data about the given bridge domain from Honeycomb. :rtype: dict """ @@ -218,11 +218,11 @@ class BridgeDomainKeywords(object): :param node: Honeycomb node. :param bd_name: Bridge domain name. :param kwargs: Parameters and their values. The accepted parameters are - defined in BridgeDomainKeywords.PARAMS + defined in BridgeDomainKeywords.PARAMS :type node: dict :type bd_name: str :type kwargs: dict - :return: Bridge domain data structure. + :returns: Bridge domain data structure. :rtype: dict """ @@ -237,11 +237,11 @@ class BridgeDomainKeywords(object): :param node: Honeycomb node. :param bd_name: Bridge domain name. :param kwargs: Parameters and their values. The accepted parameters are - defined in BridgeDomainKeywords.PARAMS + defined in BridgeDomainKeywords.PARAMS :type node: dict :type bd_name: str :type kwargs: dict - :return: Bridge domain data structure. + :returns: Bridge domain data structure. :rtype: dict """ @@ -257,10 +257,10 @@ class BridgeDomainKeywords(object): :param node: Honeycomb node. :type node: dict - :return: Content of response. + :returns: Content of response. :rtype: bytearray :raises HoneycombError: If it is not possible to remove all bridge - domains. + domains. """ data = {"bridge-domains": {"bridge-domain": []}} @@ -281,10 +281,10 @@ class BridgeDomainKeywords(object): :param bd_name: The name of bridge domain to be removed. :type node: dict :type bd_name: str - :return: Content of response. + :returns: Content of response. :rtype: bytearray - :raises HoneycombError:If it is not possible to remove the bridge - domain. + :raises HoneycombError: If it is not possible to remove the bridge + domain. """ path = ("bridge-domains", ("bridge-domain", "name", bd_name)) @@ -312,14 +312,14 @@ class BridgeDomainKeywords(object): :param node: Honeycomb node. :param bd_name: Bridge domain name. :param param: Parameter to set, change or remove. The accepted - parameters are defined in BridgeDomainKeywords.PARAMS + parameters are defined in BridgeDomainKeywords.PARAMS :param value: The new value to be set, change or remove. If None, the - item will be removed. + item will be removed. :type node: dict :type bd_name: str :type param: str :type value: str - :return: Content of response. + :returns: Content of response. :rtype: bytearray """ @@ -340,7 +340,7 @@ class BridgeDomainKeywords(object): :type node: dict :type bd_name: str :type l2_fib_entry: dict - :return: Content of response. + :returns: Content of response. :rtype: bytearray """ @@ -368,7 +368,7 @@ class BridgeDomainKeywords(object): :type mac: str :type param: str :type value: str or int - :return: Content of response. + :returns: Content of response. :rtype: bytearray """ @@ -392,10 +392,10 @@ class BridgeDomainKeywords(object): :type node: dict :type bd_name: str :type mac: str - :return: Content of response. + :returns: Content of response. :rtype: bytearray :raises HoneycombError: If it is not possible to remove the specified - entry. + entry. """ path = ("bridge-domains", @@ -429,7 +429,7 @@ class BridgeDomainKeywords(object): :param bd_name: Bridge domain's name. :type node: dict :type bd_name: str - :return: Content of response. + :returns: Content of response. :rtype: bytearray """ @@ -448,8 +448,8 @@ class BridgeDomainKeywords(object): :param bd_name: Bridge domain's name. :type node: dict :type bd_name: str - :return: Bridge domain's L2 FIB table or empty list if the table does - not exist or it is empty. + :returns: Bridge domain's L2 FIB table or empty list if the table does + not exist or it is empty. :rtype: list """ @@ -470,8 +470,8 @@ class BridgeDomainKeywords(object): :type node: dict :type bd_name: str :type mac: str - :return: The requested entry from bridge domain's L2 FIB table or empty - dictionary if it does not exist in the L2 FIB table. + :returns: The requested entry from bridge domain's L2 FIB table or empty + dictionary if it does not exist in the L2 FIB table. :rtype: dict """ diff --git a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py index 09c9ae9a3b..a7aebbba25 100644 --- a/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py +++ b/resources/libraries/python/honeycomb/HcAPIKwInterfaces.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -86,7 +86,7 @@ class InterfaceKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response on PUT is not - 200 = OK. + 200 = OK. """ status_code, resp = HcUtil.\ @@ -228,7 +228,7 @@ class InterfaceKeywords(object): :param interface: The name of interface. :param path: Path to data we want to change / create / remove. :param new_value: The new value to be set. If None, the item will be - removed. + removed. :type node: dict :type interface: str :type path: tuple @@ -261,7 +261,7 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param interface: Interface name, key, link name or sw_if_index. :param state: The requested state, only "up" and "down" are valid - values. + values. :type node: dict :type interface: str :type state: str @@ -370,7 +370,6 @@ class InterfaceKeywords(object): :param interface: Interface name, key, link name or sw_if_index. :type node: dict :type interface: str or int - :raises HoneycombError: If the operation fails. """ @@ -402,7 +401,7 @@ class InterfaceKeywords(object): :type node: dict :type interface: str :returns: Operational data about bridge domain settings in the - interface. + interface. :rtype: dict """ @@ -423,7 +422,7 @@ class InterfaceKeywords(object): :param interface: The name of interface. :param param: Parameter to configure (set, change, remove) :param value: The value of parameter. If None, the parameter will be - removed. + removed. :type node: dict :type interface: str :type param: str @@ -448,7 +447,7 @@ class InterfaceKeywords(object): :param interface: The name of interface. :param param: Parameter to configure (set, change, remove) :param value: The value of parameter. If None, the parameter will be - removed. + removed. :type node: dict :type interface: str :type param: str @@ -617,7 +616,7 @@ class InterfaceKeywords(object): :param interface: The name of interface. :param param: Parameter to configure (set, change, remove) :param value: The value of parameter. If None, the parameter will be - removed. + removed. :type node: dict :type interface: str :type param: str @@ -763,7 +762,7 @@ class InterfaceKeywords(object): :param interface: The name of interface. :param param: Parameter to configure (set, change, remove) :param value: The value of parameter. If None, the parameter will be - removed. + removed. :type node: dict :type interface: str :type param: str @@ -788,7 +787,7 @@ class InterfaceKeywords(object): :param interface: The name of interface. :param param: Parameter to configure (set, change, remove) :param value: The value of parameter. If None, the parameter will be - removed. + removed. :type node: dict :type interface: str :type param: str @@ -816,7 +815,7 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param interface: The name of interface. :param kwargs: Parameters and their values. The accepted parameters are - defined in InterfaceKeywords.VXLAN_PARAMS. + defined in InterfaceKeywords.VXLAN_PARAMS. :type node: dict :type interface: str :type kwargs: dict @@ -852,7 +851,7 @@ class InterfaceKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If it is not possible to get information about - interfaces or it is not possible to delete the interface. + interfaces or it is not possible to delete the interface. """ path = ("interfaces", ("interface", "name", interface)) @@ -887,7 +886,7 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param interface: The name of interface. :param kwargs: Parameters and their values. The accepted parameters are - defined in InterfaceKeywords.VXLAN_PARAMS. + defined in InterfaceKeywords.VXLAN_PARAMS. :type node: dict :type interface: str :type kwargs: dict @@ -915,7 +914,7 @@ class InterfaceKeywords(object): :param interface: The name of interface. :param param: Parameter to configure (set, change, remove) :param value: The value of parameter. If None, the parameter will be - removed. + removed. :type node: dict :type interface: str :type param: str @@ -939,7 +938,7 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param interface: The name of interface. :param kwargs: Parameters and their values. The accepted parameters are - defined in InterfaceKeywords.TAP_PARAMS. + defined in InterfaceKeywords.TAP_PARAMS. :type node: dict :type interface: str :type kwargs: dict @@ -978,7 +977,7 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param interface: The name of interface. :param kwargs: Parameters and their values. The accepted parameters are - defined in InterfaceKeywords.TAP_PARAMS. + defined in InterfaceKeywords.TAP_PARAMS. :type node: dict :type interface: str :type kwargs: dict @@ -1012,7 +1011,7 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param interface: The name of interface. :param kwargs: Parameters and their values. The accepted parameters are - defined in InterfaceKeywords.VHOST_USER_PARAMS. + defined in InterfaceKeywords.VHOST_USER_PARAMS. :type node: dict :type interface: str :type kwargs: dict @@ -1040,7 +1039,7 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param interface: The name of interface. :param kwargs: Parameters and their values. The accepted parameters are - defined in InterfaceKeywords.VHOST_USER_PARAMS. + defined in InterfaceKeywords.VHOST_USER_PARAMS. :type node: dict :type interface: str :type kwargs: dict @@ -1073,10 +1072,10 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param super_interface: Super interface. :param match: Match type. The valid values are defined in - InterfaceKeywords.SUB_IF_MATCH. + InterfaceKeywords.SUB_IF_MATCH. :param tags: List of tags. :param kwargs: Parameters and their values. The accepted parameters are - defined in InterfaceKeywords.SUB_IF_PARAMS. + defined in InterfaceKeywords.SUB_IF_PARAMS. :type node: dict :type super_interface: str :type match: str @@ -1380,13 +1379,13 @@ class InterfaceKeywords(object): :param data: Data to be checked. :param ref: Referential data used for comparison. :param _path: Used in recursive calls, stores the path taken down - the JSON tree. + the JSON tree. :type data: dict :type ref: dict :type _path: str :raises HoneycombError: If the data structures do not match in some way, - or if they are not in deserialized JSON format. + or if they are not in deserialized JSON format. """ if data == ref: @@ -1474,7 +1473,7 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param interface: The name of interface to be created. :param kwargs: Parameters and their values. The accepted parameters are - defined in InterfaceKeywords.VXLAN_GPE_PARAMS. + defined in InterfaceKeywords.VXLAN_GPE_PARAMS. :type node: dict :type interface: str :type kwargs: dict @@ -1514,7 +1513,7 @@ class InterfaceKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the configuration of interface is not - successful. + successful. """ interface = interface.replace("/", "%2F") @@ -1555,7 +1554,7 @@ class InterfaceKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the configuration of interface is not - successful. + successful. """ interface = Topology.convert_interface_reference( node, interface, "name") @@ -1588,7 +1587,7 @@ class InterfaceKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the configuration of interface is not - successful. + successful. """ interface = Topology.convert_interface_reference( node, interface, "name") @@ -1614,7 +1613,7 @@ class InterfaceKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the configuration of interface is not - successful. + successful. """ interface = interface.replace("/", "%2F") @@ -1638,14 +1637,14 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param intf: The interface where PBB sub-interface will be configured. :param params: Configuration parameters of the sub-interface to be - created. + created. :type node: dict :type intf: str :type params: dict :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the configuration of sub-interface is not - successful. + successful. """ interface = intf.replace("/", "%2F") @@ -1670,7 +1669,7 @@ class InterfaceKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the removal of sub-interface is not - successful. + successful. """ interface = intf.replace("/", "%2F") @@ -1697,7 +1696,7 @@ class InterfaceKeywords(object): :returns: PBB sub-interface operational data. :rtype: dict :raises HoneycombError: If the removal of sub-interface is not - successful. + successful. """ raise NotImplementedError @@ -1714,8 +1713,8 @@ class InterfaceKeywords(object): :returns: True if the interface exists in disabled interfaces. :rtype: bool :raises HoneycombError: If the interface is not present - in retrieved list of disabled interfaces. - """ + in retrieved list of disabled interfaces. + """ data = InterfaceKeywords.get_disabled_interfaces_oper_data(node) # decrement by one = conversion from HC if-index to VPP sw_if_index interface -= 1 @@ -1780,7 +1779,7 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param super_interface: Name, link name or sw_if_index - of the destination interface's super-interface. + of the destination interface's super-interface. :param dst_interface_index: Index of sub-interface to mirror packets to. :param src_interfaces: List of interfaces to mirror packets from. :type node: dict @@ -1880,7 +1879,7 @@ class InterfaceKeywords(object): :param node: Honeycomb node. :param interface: Name, link name or sw_if_index of an interface, - name of a custom interface or name of a sub-interface. + name of a custom interface or name of a sub-interface. :type node: Honeycomb node. :type interface: str or int :returns: Name of interface that can be used in Honeycomb requests. diff --git a/resources/libraries/python/honeycomb/HcAPIKwNSH.py b/resources/libraries/python/honeycomb/HcAPIKwNSH.py index ce60628d83..e042fdd423 100644 --- a/resources/libraries/python/honeycomb/HcAPIKwNSH.py +++ b/resources/libraries/python/honeycomb/HcAPIKwNSH.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -43,10 +43,10 @@ class NSHKeywords(object): :type node: dict :type path: str :type data: dict - :return: Content of response. + :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response to PUT is not - OK or ACCEPTED. + OK or ACCEPTED. """ if data: @@ -74,7 +74,7 @@ class NSHKeywords(object): :type node: dict :type name: str :type data: dict - :return: Content of response. + :returns: Content of response. :rtype: bytearray """ @@ -93,7 +93,7 @@ class NSHKeywords(object): :type node: dict :type name: str :type data: dict - :return: Content of response. + :returns: Content of response. :rtype: bytearray """ path = "/nsh-maps/nsh-map/{0}".format(name) @@ -107,7 +107,7 @@ class NSHKeywords(object): :param name: Name of the NSH entry. :type node: dict :type name: str - :return: Content of response. + :returns: Content of response. :rtype: bytearray """ @@ -121,7 +121,7 @@ class NSHKeywords(object): :param name: Name of the NSH map. :type node: dict :type name: str - :return: Content of response. + :returns: Content of response. :rtype: bytearray """ @@ -136,11 +136,11 @@ class NSHKeywords(object): :param node: Honeycomb node. :param entry_name: Name of a specific NSH entry. Optional. :param map_name: Name of a specific NSH map. Optional. Do not use - together with entry_name. + together with entry_name. :type node: dict :type entry_name: str :type map_name: str - :return: List of classify tables. + :returns: List of classify tables. :rtype: list """ if entry_name: @@ -166,7 +166,7 @@ class NSHKeywords(object): :param node: Honeycomb node. :type node: dict - :return: Content of response. + :returns: Content of response. :rtype: bytearray """ diff --git a/resources/libraries/python/honeycomb/HcPersistence.py b/resources/libraries/python/honeycomb/HcPersistence.py index e1b827f9c9..ffa850fc9e 100644 --- a/resources/libraries/python/honeycomb/HcPersistence.py +++ b/resources/libraries/python/honeycomb/HcPersistence.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -70,7 +70,7 @@ class HcPersistence(object): :type find: string :type replace: string :raises HoneycombError: If persistent configuration couldn't be - modified. + modified. """ argument = "\"s/{0}/{1}/g\"".format(find, replace) diff --git a/resources/libraries/python/honeycomb/HoneycombSetup.py b/resources/libraries/python/honeycomb/HoneycombSetup.py index a8a4f0e292..8ca34033b0 100644 --- a/resources/libraries/python/honeycomb/HoneycombSetup.py +++ b/resources/libraries/python/honeycomb/HoneycombSetup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -54,6 +54,7 @@ class HoneycombSetup(object): Honeycomb is up and running. Honeycomb must be installed in "/opt" directory, otherwise the start will fail. + :param nodes: List of nodes to start Honeycomb on. :type nodes: list :raises HoneycombError: If Honeycomb fails to start. @@ -86,6 +87,7 @@ class HoneycombSetup(object): stops the Honeycomb and does not check its shutdown state. Use the keyword "Check Honeycomb Shutdown State" to check if Honeycomb has stopped. + :param nodes: List of nodes to stop Honeycomb on. :type nodes: list :raises HoneycombError: If Honeycomb failed to stop. @@ -155,7 +157,8 @@ class HoneycombSetup(object): :type retries: int :type interval: int :raises HoneycombError: If the Honeycomb process IP cannot be found, - or if timeout or number of retries is exceeded.""" + or if timeout or number of retries is exceeded. + """ ssh = SSH() ssh.connect(node) @@ -207,8 +210,8 @@ class HoneycombSetup(object): :param node: List of DUT nodes stopping Honeycomb. :type node: dict - :return: True if all GETs fail to connect. - :rtype bool + :returns: True if all GETs fail to connect. + :rtype: bool """ cmd = "pgrep honeycomb" @@ -229,10 +232,10 @@ class HoneycombSetup(object): """Configure Honeycomb to accept restconf requests from all IP addresses. IP version is determined by node data. - :param node: Information about a DUT node. - :type node: dict - :raises HoneycombError: If the configuration could not be changed. - """ + :param node: Information about a DUT node. + :type node: dict + :raises HoneycombError: If the configuration could not be changed. + """ find = "restconf-binding-address" try: @@ -257,12 +260,12 @@ class HoneycombSetup(object): def configure_jvpp_timeout(node, timeout=10): """Configure timeout value for Java API commands Honeycomb sends to VPP. - :param node: Information about a DUT node. - :param timeout: Timeout value in seconds. - :type node: dict - :type timeout: int - :raises HoneycombError: If the configuration could not be changed. - """ + :param node: Information about a DUT node. + :param timeout: Timeout value in seconds. + :type node: dict + :type timeout: int + :raises HoneycombError: If the configuration could not be changed. + """ find = "jvpp-request-timeout" replace = '\\"jvpp-request-timeout\\": {0}'.format(timeout) @@ -367,7 +370,7 @@ class HoneycombSetup(object): :type feature: string :type disable: bool :raises HoneycombError: If the configuration could not be changed. - """ + """ disabled_features = { "NSH": ["io.fd.hc2vpp.vppnsh.impl.VppNshModule"], @@ -477,6 +480,7 @@ class HoneycombSetup(object): Karaf should be located in the provided path, and VPP and Honeycomb should already be running, otherwise the start will fail. + :param node: Node to start ODL client on. :param path: Path to ODL client on node. :type node: dict @@ -716,11 +720,11 @@ class HoneycombStartupConfig(object): def apply_config(self, node): """Generate configuration file /opt/honeycomb/honeycomb on the specified - node. + node. - :param node: Honeycomb node. - :type node: dict - """ + :param node: Honeycomb node. + :type node: dict + """ self.ssh.connect(node) _, filename, _ = self.ssh.exec_command("ls /opt/honeycomb | grep .jar") @@ -785,7 +789,7 @@ class HoneycombStartupConfig(object): :param mem_min: Minimum amount of memory (MB). :param mem_max: Maximum amount of memory (MB). Default is 4 times - minimum value. + minimum value. :type mem_min: int :type mem_max: int """ @@ -798,7 +802,7 @@ class HoneycombStartupConfig(object): :param mem_min: Minimum metaspace size (MB). :param mem_max: Maximum metaspace size (MB). Defailt is 4 times - minimum value. + minimum value. :type mem_min: int :type mem_max: int """ diff --git a/resources/libraries/python/honeycomb/HoneycombUtil.py b/resources/libraries/python/honeycomb/HoneycombUtil.py index 76bb5b3878..74e0294055 100644 --- a/resources/libraries/python/honeycomb/HoneycombUtil.py +++ b/resources/libraries/python/honeycomb/HoneycombUtil.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -62,12 +62,14 @@ class HoneycombError(Exception): When raising this exception, put this information to the message in this order: + - short description of the encountered problem (parameter msg), - relevant messages if there are any collected, e.g., from caught exception (optional parameter details), - relevant data if there are any collected (optional parameter details). - The logging is performed on two levels: 1. error - short description of the - problem; 2. debug - detailed information. + + The logging is performed on two levels: 1. error - short description of the + problem; 2. debug - detailed information. """ def __init__(self, msg, details='', enable_logging=True): @@ -79,7 +81,7 @@ class HoneycombError(Exception): :param msg: Message to be displayed and logged. :param enable_logging: When True, logging is enabled, otherwise - logging is disabled. + logging is disabled. :type msg: str :type enable_logging: bool """ @@ -109,10 +111,11 @@ class HoneycombUtil(object): structure. There are also two supportive methods implemented: - - read_path_from_url_file which reads URL file and returns a path (see - docs/honeycomb_url_files.rst). - - parse_json_response which parses data from response in JSON representation - according to given path. + + - read_path_from_url_file which reads URL file and returns a path (see + docs/honeycomb_url_files.rst). + - parse_json_response which parses data from response in JSON + representation according to given path. """ def __init__(self): @@ -120,11 +123,12 @@ class HoneycombUtil(object): @staticmethod def read_path_from_url_file(url_file): - """Read path from *.url file. + """Read path from .url file. + + For more information about .url file see docs/honeycomb_url_files.rst - For more information about *.url file see docs/honeycomb_url_files.rst :param url_file: URL file. The argument contains only the name of file - without extension, not the full path. + without extension, not the full path. :type url_file: str :returns: Requested path. :rtype: str @@ -143,36 +147,39 @@ class HoneycombUtil(object): Path format: The path is a tuple with items navigating to requested data. The items can be strings or tuples: - - string item represents a dictionary key in data, - - tuple item represents list item in data. - - Example: - data = \ - { - "interfaces": { - "interface": [ - { - "name": "GigabitEthernet0/8/0", - "enabled": "true", - "type": "iana-if-type:ethernetCsmacd", - }, - { - "name": "local0", - "enabled": "false", - "type": "iana-if-type:ethernetCsmacd", - } - ] - } - } + + - string item represents a dictionary key in data, + - tuple item represents list item in data. + + Example:: + + data = \ + { + "interfaces": { + "interface": [ + { + "name": "GigabitEthernet0/8/0", + "enabled": "true", + "type": "iana-if-type:ethernetCsmacd", + }, + { + "name": "local0", + "enabled": "false", + "type": "iana-if-type:ethernetCsmacd", + } + ] + } + } path = ("interfaces", ("interface", "name", "local0"), "enabled") This path points to "false". - The tuple ("interface", "name", "local0") consists of: - index 0 - dictionary key pointing to a list, - index 1 - key which identifies an item in the list, it is also marked as - the key in corresponding yang file. - index 2 - key value. + The tuple ("interface", "name", "local0") consists of:: + + index 0 - dictionary key pointing to a list, + index 1 - key which identifies an item in the list, it is also marked + as the key in corresponding yang file. + index 2 - key value. :param data: Data received from Honeycomb REST API. :param path: Path to data we want to find. @@ -290,13 +297,13 @@ class HoneycombUtil(object): :param node: Honeycomb node. :param url_file: URL file. The argument contains only the name of file - without extension, not the full path. + without extension, not the full path. :param path: Path which is added to the base path to identify the data. :type node: dict :type url_file: str :type path: str :returns: Status code and content of response. - :rtype tuple + :rtype: tuple """ base_path = HoneycombUtil.read_path_from_url_file(url_file) @@ -319,7 +326,7 @@ class HoneycombUtil(object): :param node: Honeycomb node. :param url_file: URL file. The argument contains only the name of file - without extension, not the full path. + without extension, not the full path. :param data: Configuration data to be sent to Honeycomb. :param path: Path which is added to the base path to identify the data. :param data_representation: How the data is represented. @@ -331,7 +338,7 @@ class HoneycombUtil(object): :returns: Status code and content of response. :rtype: tuple :raises HoneycombError: If the given data representation is not defined - in HEADERS. + in HEADERS. """ try: @@ -358,11 +365,11 @@ class HoneycombUtil(object): :param node: Honeycomb node. :param url_file: URL file. The argument contains only the name of file - without extension, not the full path. + without extension, not the full path. :param data: Configuration data to be sent to Honeycomb. :param data_representation: How the data is represented. :param timeout: How long to wait for the server to send data before - giving up. + giving up. :type node: dict :type url_file: str :type data: dict, str @@ -371,7 +378,7 @@ class HoneycombUtil(object): :returns: Status code and content of response. :rtype: tuple :raises HoneycombError: If the given data representation is not defined - in HEADERS. + in HEADERS. """ try: @@ -392,13 +399,13 @@ class HoneycombUtil(object): :param node: Honeycomb node. :param url_file: URL file. The argument contains only the name of file - without extension, not the full path. + without extension, not the full path. :param path: Path which is added to the base path to identify the data. :type node: dict :type url_file: str :type path: str :returns: Status code and content of response. - :rtype tuple + :rtype: tuple """ base_path = HoneycombUtil.read_path_from_url_file(url_file) @@ -411,7 +418,7 @@ class HoneycombUtil(object): :param node: Honeycomb node. :param suite_name: Name of the current test suite. ${SUITE_NAME} - variable in robotframework. + variable in robotframework. :type node: dict :type suite_name: str """ @@ -433,7 +440,8 @@ class HoneycombUtil(object): """Delete the Honeycomb log file for the current test suite. :param node: Honeycomb node. - :type node: dict""" + :type node: dict + """ ssh = SSH() ssh.connect(node) diff --git a/resources/libraries/python/honeycomb/Lisp.py b/resources/libraries/python/honeycomb/Lisp.py index f2fe24caf1..6ff6f834cc 100644 --- a/resources/libraries/python/honeycomb/Lisp.py +++ b/resources/libraries/python/honeycomb/Lisp.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -50,7 +50,7 @@ class LispKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response to PUT is not - 200 = OK or 201 = ACCEPTED. + 200 = OK or 201 = ACCEPTED. """ if data: @@ -142,7 +142,7 @@ class LispKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the return code is not 200:OK - or 404:NOT FOUND. + or 404:NOT FOUND. """ ret_code, data = HcUtil.get_honeycomb_data(node, "config_lisp") @@ -186,7 +186,7 @@ class LispKeywords(object): :param interface: An interface on the node. :param locator_set: Name for the new locator set. :param priority: Priority parameter for the locator. - :param weight. Weight parameter for the locator. + :param weight: Weight parameter for the locator. :type node: dict :type interface: str :type locator_set: str @@ -491,7 +491,7 @@ class LispGPEKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response to PUT is not - 200 = OK or 201 = ACCEPTED. + 200 = OK or 201 = ACCEPTED. """ if data: @@ -518,7 +518,7 @@ class LispGPEKeywords(object): :returns: LISP GPE operational data. :rtype: bytearray :raises HoneycombError: If the status code in response to GET is not - 200 = OK. + 200 = OK. """ status_code, resp = HcUtil.get_honeycomb_data(node, "oper_lisp_gpe") @@ -540,7 +540,7 @@ class LispGPEKeywords(object): :returns: LISP GPE mapping. :rtype: dict :raises HoneycombError: If the mapping is not present in operational - data. + data. """ data = LispGPEKeywords.get_lispgpe_operational_data(node) @@ -568,7 +568,7 @@ class LispGPEKeywords(object): :returns: LISP GPE config data. :rtype: bytearray :raises HoneycombError: If the status code in response to GET is not - 200 = OK. + 200 = OK. """ status_code, resp = HcUtil.get_honeycomb_data(node, "config_lisp_gpe") @@ -590,7 +590,7 @@ class LispGPEKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the return code is not 200:OK - or 404:NOT FOUND. + or 404:NOT FOUND. """ ret_code, data = HcUtil.get_honeycomb_data(node, "config_lisp_gpe") diff --git a/resources/libraries/python/honeycomb/NAT.py b/resources/libraries/python/honeycomb/NAT.py index 1fb066d10c..6ad9881333 100644 --- a/resources/libraries/python/honeycomb/NAT.py +++ b/resources/libraries/python/honeycomb/NAT.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -41,7 +41,7 @@ class NATKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response to PUT is not - OK or ACCEPTED. + OK or ACCEPTED. """ if data: @@ -67,7 +67,7 @@ class NATKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the operation fails or the response - is not as expected. + is not as expected. """ status_code, resp = HcUtil.get_honeycomb_data(node, "oper_nat") diff --git a/resources/libraries/python/honeycomb/Netconf.py b/resources/libraries/python/honeycomb/Netconf.py index 770af95afa..742948c6e7 100644 --- a/resources/libraries/python/honeycomb/Netconf.py +++ b/resources/libraries/python/honeycomb/Netconf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -98,9 +98,9 @@ class Netconf(object): :param size: Maximum number of bytes to read in one iteration. :param time_out: Timeout value for getting the complete response. :param err: Error message to provide when timeout is reached. - :type size:int - :type time_out:int - :type err:str + :type size: int + :type time_out: int + :type err: str :returns: Content of response. :rtype: str :raises HoneycombError: If the read process times out. @@ -133,12 +133,12 @@ class Netconf(object): def get_all_responses(self, size=4096, time_out=3): """Read responses from the receive buffer and catenate together - until a read operation times out. + until a read operation times out. :param size: Maximum number of bytes to read in one iteration. :param time_out: Timeout value for getting the complete response. - :type size:int - :type time_out:int + :type size: int + :type time_out: int :returns: Content of response. :rtype: str """ diff --git a/resources/libraries/python/honeycomb/Notifications.py b/resources/libraries/python/honeycomb/Notifications.py index 512a6cbb08..58d835eca0 100644 --- a/resources/libraries/python/honeycomb/Notifications.py +++ b/resources/libraries/python/honeycomb/Notifications.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -57,7 +57,7 @@ class Notifications(Netconf): :param time_out: Timeout value for the read operation in seconds. :type time_out: int - :return: Data received from buffer. + :returns: Data received from buffer. :rtype: str """ diff --git a/resources/libraries/python/honeycomb/Performance.py b/resources/libraries/python/honeycomb/Performance.py index 8fbbbf6a28..391607ff04 100644 --- a/resources/libraries/python/honeycomb/Performance.py +++ b/resources/libraries/python/honeycomb/Performance.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -60,7 +60,7 @@ class Performance(object): :param script: Name of the script to execute. :param cores: Number of processor cores to use. :param reserved: Number of cores reserved for other tasks. Default is 2, - one for system tasks and one for VPP main thread. + one for system tasks and one for VPP main thread. :param args: Sequential arguments for the script. :param kwargs: Named arguments for the script. :type node: dict diff --git a/resources/libraries/python/honeycomb/ProxyARP.py b/resources/libraries/python/honeycomb/ProxyARP.py index 9696bf4238..adc525d279 100644 --- a/resources/libraries/python/honeycomb/ProxyARP.py +++ b/resources/libraries/python/honeycomb/ProxyARP.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -44,7 +44,7 @@ class ProxyARPKeywords(object): :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response to PUT is not - 200 = OK or 201 = ACCEPTED. + 200 = OK or 201 = ACCEPTED. """ data = { @@ -112,7 +112,7 @@ class ProxyARPKeywords(object): :type state: str :raises ValueError: If the state argument is incorrect. :raises HoneycombError: If the status code in response is not - 200 = OK or 201 = ACCEPTED. + 200 = OK or 201 = ACCEPTED. """ interface = Topology.convert_interface_reference( @@ -166,7 +166,7 @@ class IPv6NDProxyKeywords(object): :param node: Honeycomb node. :param interface: Name of an interface on the node. :param addresses: IPv6 addresses to configure ND proxy with. If no - address is provided, ND proxy configuration will be removed. + address is provided, ND proxy configuration will be removed. :type node: dict :type interface: str :type addresses: list diff --git a/resources/libraries/python/honeycomb/Routing.py b/resources/libraries/python/honeycomb/Routing.py index 4c6a3f205b..520f53e676 100644 --- a/resources/libraries/python/honeycomb/Routing.py +++ b/resources/libraries/python/honeycomb/Routing.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -46,7 +46,7 @@ class RoutingKeywords(object): :type node: dict :type path: str :type data: dict - :return: Content of response. + :returns: Content of response. :rtype: bytearray :raises HoneycombError: If the status code in response is not 200 = OK. diff --git a/resources/libraries/python/parsers/JsonParser.py b/resources/libraries/python/parsers/JsonParser.py index 0e78679ecc..2c8e62ffe3 100644 --- a/resources/libraries/python/parsers/JsonParser.py +++ b/resources/libraries/python/parsers/JsonParser.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -30,7 +30,7 @@ class JsonParser(object): :param json_data: Data in JSON format. :type json_data: str - :return: JSON data parsed as python list. + :returns: JSON data parsed as python list. :rtype: list """ if "4.2.0-42-generic" in uname(): @@ -62,7 +62,7 @@ class JsonParser(object): :param json_file: File with JSON type data. :type json_file: str - :return: JSON data parsed as python list. + :returns: JSON data parsed as python list. :rtype: list """ input_data = open(json_file).read() diff --git a/resources/libraries/python/ssh.py b/resources/libraries/python/ssh.py index 469d77ffc2..8c064e2729 100644 --- a/resources/libraries/python/ssh.py +++ b/resources/libraries/python/ssh.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -50,7 +50,7 @@ class SSH(object): :param node: Node in topology. :type node: dict - :return: IP address and port for the specified node. + :returns: IP address and port for the specified node. :rtype: int """ @@ -192,7 +192,7 @@ class SSH(object): :param cmd: Command to be executed. :param cmd_input: Input redirected to the command. :param timeout: Timeout. - :return: return_code, stdout, stderr + :returns: return_code, stdout, stderr :Example: @@ -224,7 +224,7 @@ class SSH(object): :type lxc_params: str :type sudo: bool :type timeout: int - :return: return_code, stdout, stderr + :returns: return_code, stdout, stderr """ command = "lxc-attach {p} --name {n} -- /bin/sh -c '{c}'"\ .format(p=lxc_params, n=lxc_name, c=lxc_cmd) @@ -237,7 +237,7 @@ class SSH(object): """Open interactive terminal on a new channel on the connected Node. :param time_out: Timeout in seconds. - :return: SSH channel with opened terminal. + :returns: SSH channel with opened terminal. .. warning:: Interruptingcow is used here, and it uses signal(SIGALRM) to let the operating system interrupt program @@ -276,7 +276,7 @@ class SSH(object): :param cmd: Command to be executed. :param prompt: Command prompt, sequence of characters used to indicate readiness to accept commands. - :return: Command output. + :returns: Command output. .. warning:: Interruptingcow is used here, and it uses signal(SIGALRM) to let the operating system interrupt program diff --git a/resources/libraries/python/tcp.py b/resources/libraries/python/tcp.py index ecd6210f69..e013a65539 100644 --- a/resources/libraries/python/tcp.py +++ b/resources/libraries/python/tcp.py @@ -65,7 +65,7 @@ class TCPUtils(object): :param node: Node to start HTTP server on. :param prealloc_fifos: Max number of connections you expect to handle at - one time. + one time. :param fifo_size: FIFO size in kB. :param private_segment_size: Private segment size. Number + unit. :type node: dict diff --git a/resources/libraries/python/telemetry/IPFIXSetup.py b/resources/libraries/python/telemetry/IPFIXSetup.py index f0f35f3bc6..db703c8a7e 100644 --- a/resources/libraries/python/telemetry/IPFIXSetup.py +++ b/resources/libraries/python/telemetry/IPFIXSetup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -95,7 +95,7 @@ class IPFIXSetup(object): :param node: DUT node. :param domain: Desired index number of exporting domain. :param src_port: Source port to use when sending IPFIX packets. Default - is the standard IPFIX port 4739. + is the standard IPFIX port 4739. :type node: dict :type domain: int :type src_port: int @@ -112,15 +112,15 @@ class IPFIXSetup(object): @staticmethod def assign_classify_table_to_exporter(node, table_id, ip_version='ip4'): """Assign a classify table to an IPFIX exporter. Classified packets will - be included in the IPFIX flow report. - - :param node: DUT node. - :param table_id: ID of a classify table. - :param ip_version: Version of IP protocol. Valid options are ip4, ip6. - :type node: dict - :type table_id: int - :type ip_version: str - """ + be included in the IPFIX flow report. + + :param node: DUT node. + :param table_id: ID of a classify table. + :param ip_version: Version of IP protocol. Valid options are ip4, ip6. + :type node: dict + :type table_id: int + :type ip_version: str + """ with VatTerminal(node, json_param=False) as vat: vat.vat_terminal_exec_cmd_from_template("ipfix_table_add.vat", diff --git a/resources/libraries/python/telemetry/SPAN.py b/resources/libraries/python/telemetry/SPAN.py index 41ff7d34f1..048e89ba67 100644 --- a/resources/libraries/python/telemetry/SPAN.py +++ b/resources/libraries/python/telemetry/SPAN.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # 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: @@ -51,7 +51,7 @@ class SPAN(object): :param node: DUT node. :type node: dict :returns: Full SPAN configuration as list. One list entry for every - source/destination interface pair. + source/destination interface pair. :rtype: list of dict """ @@ -72,7 +72,7 @@ class SPAN(object): :type dst_interface: str or int :type ret_format: string :returns: List of SPAN source interfaces for the provided destination - interface. + interface. :rtype: list """ diff --git a/resources/libraries/python/topology.py b/resources/libraries/python/topology.py index 13dbdddb07..2f4fd023ba 100644 --- a/resources/libraries/python/topology.py +++ b/resources/libraries/python/topology.py @@ -71,6 +71,7 @@ class Topology(object): "Active topology" contains initially data from the topology file and can be extended with additional data from the DUTs like internal interface indexes or names. Additional data which can be filled to the active topology are + - additional internal representation (index, name, ...) - operational data (dynamic ports) @@ -349,11 +350,11 @@ class Topology(object): :param node: The node topology directory. :param link_names: List of names of the link that a interface is - connected to. + connected to. :type node: dict :type link_names: list :returns: Dictionary of interface names that are connected to the given - links. + links. :rtype: dict """ retval = {} @@ -465,8 +466,7 @@ class Topology(object): :param node: Node in topology. :param interface: Name, sw_if_index, link name or key of an interface - on the node. - Valid formats are: sw_if_index, key, name. + on the node. :type node: dict :type interface: str or int @@ -505,16 +505,14 @@ class Topology(object): :param node: Node in topology. :param interface: Name, sw_if_index, link name or key of an interface - on the node. + on the node. :param wanted_format: Format of return value wanted. - Valid options are: sw_if_index, key, name. + Valid options are: sw_if_index, key, name. :type node: dict :type interface: str or int :type wanted_format: str - :returns: Interface name, interface key or sw_if_index. :rtype: str or int - :raises TypeError, ValueError: If provided with invalid arguments. :raises RuntimeError: If the interface does not exist in topology. """ @@ -620,7 +618,7 @@ class Topology(object): on local network. :param nodes_info: Dictionary containing information on all nodes - in topology. + in topology. :param node: Node that contains specified interface. :param iface_key: Interface key from topology file. :type nodes_info: dict @@ -786,7 +784,7 @@ class Topology(object): :type node2: dict :returns: Name of link connecting the two nodes together. :rtype: str - :raises: RuntimeError + :raises RuntimeError: If no links are found. """ connecting_links = self.get_active_connecting_links(node1, node2) if len(connecting_links) == 0: |