def __init__(self, operation, object_type, context):
     if object_type in [odl_const.ODL_SG, odl_const.ODL_SG_RULE]:
         self._data = context[object_type].copy()
     else:
         self._data = context.current.copy()
     self._object_type = object_type
     filters.filter_for_odl(object_type, operation, self._data)
示例#2
0
    def _json_data(self, row):
        data = copy.deepcopy(row.data)
        filters.filter_for_odl(row.object_type, row.operation, data)
        url_object = row.object_type.replace('_', '-')

        if row.operation == odl_const.ODL_CREATE:
            method = 'post'
            urlpath = url_object + 's'
            to_send = {row.object_type: data}
        elif row.operation == odl_const.ODL_UPDATE:
            method = 'put'
            urlpath = url_object + 's/' + row.object_uuid
            to_send = {row.object_type: data}
        elif row.operation == odl_const.ODL_DELETE:
            method = 'delete'
            urlpath = url_object + 's/' + row.object_uuid
            to_send = None
        elif row.operation == odl_const.ODL_ADD:
            method = 'put'
            urlpath = 'routers/' + data['id'] + '/add_router_interface'
            to_send = data
        elif row.operation == odl_const.ODL_REMOVE:
            method = 'put'
            urlpath = 'routers/' + data['id'] + '/remove_router_interface'
            to_send = data

        return method, urlpath, to_send
 def __init__(self, operation, object_type, context):
     if object_type in [odl_const.ODL_SG, odl_const.ODL_SG_RULE]:
         self._data = context[object_type].copy()
     else:
         self._data = context.current.copy()
     self._object_type = object_type
     filters.filter_for_odl(object_type, operation, self._data)
示例#4
0
 def __init__(self, operation, object_type, context):
     if object_type in [odl_const.ODL_SG, odl_const.ODL_SG_RULE]:
         self._data = copy.deepcopy(context[object_type])
     elif object_type == odl_const.ODL_PORT:
         # NOTE(yamahata): work around for journal._enrich_port()
         self._data = copy.deepcopy(context.current)
         if self._data.get(odl_const.ODL_SGS):
             self._data[odl_const.ODL_SGS] = [
                 {'id': id_} for id_ in self._data[odl_const.ODL_SGS]]
     else:
         self._data = copy.deepcopy(context.current)
     self._object_type = object_type
     filters.filter_for_odl(object_type, operation, self._data)
 def __init__(self, operation, object_type, context):
     if object_type in [odl_const.ODL_SG, odl_const.ODL_SG_RULE]:
         self._data = copy.deepcopy(context[object_type])
     elif object_type == odl_const.ODL_PORT:
         # NOTE(yamahata): work around for journal._enrich_port()
         self._data = copy.deepcopy(context.current)
         if self._data.get(odl_const.ODL_SGS):
             self._data[odl_const.ODL_SGS] = [
                 {'id': id_} for id_ in self._data[odl_const.ODL_SGS]]
     else:
         self._data = copy.deepcopy(context.current)
     self._object_type = object_type
     filters.filter_for_odl(object_type, operation, self._data)
示例#6
0
    def _json_data(row):
        data = copy.deepcopy(row.data)
        filters.filter_for_odl(row.object_type, row.operation, data)

        if row.operation == odl_const.ODL_CREATE:
            method = 'post'
            to_send = {row.object_type: data}
        elif row.operation == odl_const.ODL_UPDATE:
            method = 'put'
            to_send = {row.object_type: data}
        elif row.operation == odl_const.ODL_DELETE:
            method = 'delete'
            to_send = None

        return method, _build_url(row), to_send
示例#7
0
    def _json_data(row):
        data = copy.deepcopy(row.data)
        filters.filter_for_odl(row.object_type, row.operation, data)

        if row.operation == odl_const.ODL_CREATE:
            method = 'post'
            to_send = {row.object_type: data}
        elif row.operation == odl_const.ODL_UPDATE:
            method = 'put'
            to_send = {row.object_type: data}
        elif row.operation == odl_const.ODL_DELETE:
            method = 'delete'
            to_send = None

        return method, _build_url(row), to_send
    def test_update_port_filter(self):
        """Validate the filter code on update port operation"""
        expected_items = ['fixed_ips', 'security_groups', 'device_id',
                          'security_groups', 'admin_state_up']
        subnet = self._get_mock_operation_context(odl_const.ODL_SUBNET).current
        port = self._get_mock_operation_context(odl_const.ODL_PORT).current
        port['fixed_ips'] = [{'subnet_id': subnet['id'],
                              'ip_address': '10.0.0.10'}]
        port['mac_address'] = port['mac_address'].upper()

        orig_port = copy.deepcopy(port)

        with mock.patch.object(segments_db, 'get_network_segments'):
            filters.filter_for_odl(odl_const.ODL_PORT,
                                   odl_const.ODL_UPDATE, port)
            for key, value in orig_port.items():
                if key in expected_items:
                    self.assertEqual(port[key], value)
示例#9
0
    def test_update_port_filter(self):
        """Validate the filter code on update port operation"""
        expected_items = ['fixed_ips', 'security_groups', 'device_id',
                          'security_groups', 'admin_state_up']
        subnet = self._get_mock_operation_context(odl_const.ODL_SUBNET).current
        port = self._get_mock_operation_context(odl_const.ODL_PORT).current
        port['fixed_ips'] = [{'subnet_id': subnet['id'],
                              'ip_address': '10.0.0.10'}]
        port['mac_address'] = port['mac_address'].upper()

        orig_port = copy.deepcopy(port)

        with mock.patch.object(segments_db, 'get_network_segments'):
            filters.filter_for_odl(odl_const.ODL_PORT,
                                   odl_const.ODL_UPDATE, port)
            for key, value in orig_port.items():
                if key in expected_items:
                    self.assertEqual(port[key], value)
示例#10
0
    def _json_data(self, row):
        data = copy.deepcopy(row.data)
        filters.filter_for_odl(row.object_type, row.operation, data)
        url_object = row.object_type.replace('_', '-')

        if row.operation == odl_const.ODL_CREATE:
            method = 'post'
            urlpath = url_object + 's'
            to_send = {row.object_type: data}
        elif row.operation == odl_const.ODL_UPDATE:
            method = 'put'
            urlpath = url_object + 's/' + row.object_uuid
            to_send = {row.object_type: data}
        elif row.operation == odl_const.ODL_DELETE:
            method = 'delete'
            urlpath = url_object + 's/' + row.object_uuid
            to_send = None

        return method, urlpath, to_send
示例#11
0
 def __init__(self, operation, object_type, object_dict):
     self._data = object_dict.copy()
     self._object_type = object_type
     filters.filter_for_odl(object_type, operation, self._data)
示例#12
0
 def __init__(self, operation, object_type, object_dict):
     self._data = object_dict.copy()
     self._object_type = object_type
     filters.filter_for_odl(object_type, operation, self._data)