コード例 #1
0
    def test_delete_structured_data_with_bad_template(self):
        with patch('uniconfig_worker.requests.delete') as mock:
            mock.return_value = MockResponse(
                bytes(json.dumps(bad_request_response), encoding='utf-8'), 404,
                "")
            request = uniconfig_worker.delete_structured_data({
                "inputData": {
                    "device_id":
                    "xr5",
                    "uri":
                    "/frinx-openconfig-interfaces:interfaces/interface=Loopback01",
                }
            })

            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"
            )
            self.assertEqual(
                request["output"]["response_body"]['errors']['error'][0]
                ["error-tag"], "data-missing")
コード例 #2
0
def delete_interface(device):
    url = Template(odl_url_uniconfig_ifc_config).substitute({'ifc': device.interface})
    ifc_response = uniconfig_worker.delete_structured_data({'inputData': {
        'device_id': device.id,
        'uri': url,
    }})
    return ifc_response
コード例 #3
0
def delete_vlan(device):
    url = Template(odl_url_uniconfig_vlan_config).substitute(
        {'vlan': device.vlan})
    vlan_response = uniconfig_worker.delete_structured_data(
        {'inputData': {
            'device_id': device.id,
            'uri': url,
        }})
    return vlan_response
コード例 #4
0
def device_delete_vpls(task):
    return uniconfig_worker.delete_structured_data({
        'inputData': {
            'device_id':
            task['inputData']['id'],
            'uri':
            (Template(odl_url_uniconfig_network_instance_config).substitute(
                {'vpls': (task['inputData']['service_id'])})),
        }
    })
コード例 #5
0
def delete_interface_policy(device):
    if device.in_policy is None and device.out_policy is None:
        return

    url = Template(odl_url_uniconfig_ifc_policy_config).substitute({'ifc': device.interface})
    ifc_response = uniconfig_worker.delete_structured_data({'inputData': {
        'device_id': device.id,
        'uri': url
    }})
    return ifc_response
コード例 #6
0
 def test_delete_structured_data_with_device(self):
     with patch('uniconfig_worker.requests.delete') as mock:
         mock.return_value = MockResponse(
             bytes(json.dumps({}), encoding='utf-8'), 204, "")
         request = uniconfig_worker.delete_structured_data({
             "inputData": {
                 "device_id":
                 "xr5",
                 "uri":
                 "/frinx-openconfig-interfaces:interfaces/interface=Loopback01"
             }
         })
         self.assertEqual(request["status"], "COMPLETED")
         self.assertEqual(request["output"]["response_code"], 204)
         self.assertEqual(request["output"]["response_body"], {})