Exemplo n.º 1
0
 def test_read_structured_data_with_device(self):
     with patch('uniconfig_worker.requests.get') as mock:
         mock.return_value = MockResponse(
             bytes(json.dumps(interface_response), encoding='utf-8'), 200,
             "")
         request = uniconfig_worker.read_structured_data({
             "inputData": {
                 "device_id": "xr5",
                 "uri": "/frinx-openconfig-interfaces:interfaces"
             }
         })
         self.assertEqual(request["status"], "COMPLETED")
         self.assertEqual(
             request["output"]["url"], odl_url_base +
             "/data/network-topology:network-topology/topology=uniconfig/node=xr5"
             "/frinx-uniconfig-topology:configuration"
             "/frinx-openconfig-interfaces:interfaces")
         self.assertEqual(request["output"]["response_code"], 200)
         self.assertEqual(
             request["output"]["response_body"]
             ["frinx-openconfig-interfaces:interfaces"]["interface"][0]
             ['config']['name'], "GigabitEthernet0/0/0/0")
         self.assertEqual(
             request["output"]["response_body"]
             ["frinx-openconfig-interfaces:interfaces"]["interface"][1]
             ['config']['name'], "GigabitEthernet0/0/0/1")
         self.assertEqual(
             request["output"]["response_body"]
             ["frinx-openconfig-interfaces:interfaces"]["interface"][2]
             ['config']['name'], "GigabitEthernet0/0/0/2")
Exemplo n.º 2
0
def read_interface(device):
    url = Template(odl_url_uniconfig_ifc_config).substitute({'ifc': device.interface})
    ifc_response = uniconfig_worker.read_structured_data({'inputData': {
        'device_id': device.id,
        'uri': url,
    }})
    return ifc_response
Exemplo n.º 3
0
def read_vlan(device):
    url = Template(odl_url_uniconfig_vlan_config).substitute(
        {'vlan': device.vlan})
    vlan_response = uniconfig_worker.read_structured_data(
        {'inputData': {
            'device_id': device.id,
            'uri': url,
        }})
    return vlan_response
Exemplo n.º 4
0
def device_read_vpls(task):
    return uniconfig_worker.read_structured_data({
        'inputData': {
            'device_id':
            task['inputData']['id'],
            'uri':
            (Template(odl_url_uniconfig_network_instance_config).substitute(
                {'vpls': (task['inputData']['service_id'])})),
        }
    })
Exemplo n.º 5
0
 def test_read_structured_data_no_device(self):
     with patch('uniconfig_worker.requests.get') as mock:
         mock.return_value = MockResponse(
             bytes(json.dumps(bad_request_response), encoding='utf-8'), 404,
             "")
         request = uniconfig_worker.read_structured_data({
             "inputData": {
                 "device_id": "",
                 "uri": "/frinx-openconfig-interfaces:interfaces"
             }
         })
         self.assertEqual(request["status"], "FAILED")
         self.assertEqual(request["output"]["response_code"], 404)
         self.assertEqual(
             request["output"]["response_body"]['errors']['error'][0]
             ["error-type"], "protocol")
         self.assertEqual(
             request["output"]["response_body"]['errors']['error'][0]
             ["error-message"],
             "Request could not be completed because the relevant data model content does not exist"
         )