-
-
- @staticmethod
- def add_vpp_to_honeycomb_network_topology(nodes, headers):
- """Add vpp node to Honeycomb network topology.
-
- :param nodes: all nodes in test topology
- :param headers: headers to be used with PUT requests
- :type nodes: dict
- :type headers: dict
- :return: status code and response from PUT requests
- :rtype: tuple
- :raises HoneycombError: if a node was not added to honeycomb topology
-
- Reads HTML path from template file config_topology_node.url
- Path to the node to be added, e.g.:
- ("/restconf/config/network-topology:network-topology"
- "/topology/topology-netconf/node/")
- There must be "/" at the end, as generated node name is added
- at the end.
-
- Reads payload data from template file add_vpp_to_topology.xml
- Information about node as XML structure, e.g.:
- <node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
- <node-id>
- {vpp_host}
- </node-id>
- <host xmlns="urn:opendaylight:netconf-node-topology">
- {vpp_ip}
- </host>
- <port xmlns="urn:opendaylight:netconf-node-topology">
- {vpp_port}
- </port>
- <username xmlns="urn:opendaylight:netconf-node-topology">
- {user}
- </username>
- <password xmlns="urn:opendaylight:netconf-node-topology">
- {passwd}
- </password>
- <tcp-only xmlns="urn:opendaylight:netconf-node-topology">
- false
- </tcp-only>
- <keepalive-delay xmlns="urn:opendaylight:netconf-node-topology">
- 0
- </keepalive-delay>
- </node>
- NOTE: The placeholders:
- {vpp_host}
- {vpp_ip}
- {vpp_port}
- {user}
- {passwd}
- MUST be there as they are replaced by correct values.
- """
-
- with open(os.path.join(C.RESOURCES_TPL_HC, "config_topology_node.url"))\
- as template:
- path = template.readline()
-
- try:
- xml_data = ET.parse(os.path.join(C.RESOURCES_TPL_HC,
- "add_vpp_to_topology.xml"))
- except ET.ParseError as err:
- raise HoneycombError(repr(err))
- data = ET.tostring(xml_data.getroot())
-
- status_codes = []
- responses = []
- for node_name, node in nodes.items():
- if node['type'] == NodeType.DUT:
- try:
- payload = data.format(
- vpp_host=node_name,
- vpp_ip=node["host"],
- vpp_port=node['honeycomb']["netconf_port"],
- user=node['honeycomb']["user"],
- passwd=node['honeycomb']["passwd"])
- status_code, resp = HTTPRequest.put(
- node=node,
- path=path + '/' + node_name,
- headers=headers,
- payload=payload)
- if status_code != HTTP_CODES["OK"]:
- raise HoneycombError(
- "VPP {0} was not added to topology. "
- "Status code: {1}".format(node["host"],
- status_code))
-
- status_codes.append(status_code)
- responses.append(resp)
-
- except HTTPRequestError as err:
- raise HoneycombError("VPP {0} was not added to topology.\n"
- "{1}".format(node["host"], repr(err)))
-
- return status_codes, responses