Ejemplo n.º 1
0
 def filter_create_port_attributes(cls, port, context):
     """Filter out port attributes not required for a create."""
     cls.add_security_groups(port, context)
     # TODO(kmestery): Converting to uppercase due to ODL bug
     # https://bugs.opendaylight.org/show_bug.cgi?id=477
     port['mac_address'] = port['mac_address'].upper()
     odl_utils.try_del(port, ['status'])
Ejemplo n.º 2
0
 def filter_create_port_attributes(cls, port, context):
     """Filter out port attributes not required for a create."""
     cls.add_security_groups(port, context)
     # TODO(kmestery): Converting to uppercase due to ODL bug
     # https://bugs.opendaylight.org/show_bug.cgi?id=477
     port['mac_address'] = port['mac_address'].upper()
     odl_utils.try_del(port, ['status'])
Ejemplo n.º 3
0
 def filter_update_attributes(cls, port, context):
     """Filter out port attributes for an update operation."""
     cls._add_security_groups(port, context)
     cls._fixup_mac_address(port)
     cls._fixup_allowed_ipaddress_pairs(port[addr_pair.ADDRESS_PAIRS])
     odl_utils.try_del(port, ['network_id', 'id', 'status', 'mac_address',
                       'tenant_id', 'fixed_ips'])
Ejemplo n.º 4
0
 def filter_create_attributes(cls, port):
     """Filter out port attributes not required for a create."""
     # TODO(kmestery): Converting to uppercase due to ODL bug
     # https://bugs.opendaylight.org/show_bug.cgi?id=477
     port['mac_address'] = port['mac_address'].upper()
     cls._filter_unmapped_null(port)
     odl_utils.try_del(port, ['status'])
Ejemplo n.º 5
0
 def _filter_unmapped_null(port):
     # NOTE(yamahata): bug work around
     # https://bugs.eclipse.org/bugs/show_bug.cgi?id=475475
     #   Null-value for an unmapped element causes next mapped
     #   collection to contain a null value
     #   JSON: { "unmappedField": null, "mappedCollection": [ "a" ] }
     #
     #   Java Object:
     #   class Root {
     #     Collection<String> mappedCollection = new ArrayList<String>;
     #   }
     #
     #   Result:
     #   Field B contains one element; null
     #
     # TODO(yamahata): update along side with neutron and ODL
     #   add when neutron adds more extensions
     #   delete when ODL neutron northbound supports it
     # TODO(yamahata): do same thing for other resources
     unmapped_keys = [
         'dns_name', 'port_security_enabled', 'binding:profile'
     ]
     keys_to_del = [key for key in unmapped_keys if port.get(key) is None]
     if keys_to_del:
         odl_utils.try_del(port, keys_to_del)
Ejemplo n.º 6
0
 def filter_update_attributes(cls, subnet, context):
     """Filter out subnet attributes for an update operation."""
     odl_utils.try_del(subnet, [
         'id', 'network_id', 'ip_version', 'cidr', 'allocation_pools',
         'tenant_id'
     ])
     cls._filter_unmapped_null(subnet, cls._UNMAPPED_KEYS)
Ejemplo n.º 7
0
 def filter_update_port_attributes(cls, port, context):
     """Filter out port attributes for an update operation."""
     cls.add_security_groups(port, context)
     odl_utils.try_del(port, [
         'network_id', 'id', 'status', 'mac_address', 'tenant_id',
         'fixed_ips'
     ])
Ejemplo n.º 8
0
 def filter_update_attributes(cls, port, context):
     """Filter out port attributes for an update operation."""
     cls._add_security_groups(port, context)
     cls._fixup_mac_address(port)
     cls._fixup_allowed_ipaddress_pairs(port[addr_pair.ADDRESS_PAIRS])
     odl_utils.try_del(port, [
         'network_id', 'id', 'status', 'mac_address', 'tenant_id',
         'fixed_ips'
     ])
Ejemplo n.º 9
0
    def filter_create_attributes(cls, port, context):
        """Filter out port attributes not required for a create."""
        cls._add_security_groups(port, context)
        cls._fixup_mac_address(port)
        cls._fixup_allowed_ipaddress_pairs(port[addr_pair.ADDRESS_PAIRS])
        odl_utils.try_del(port, ['status'])

        # NOTE(yamahata): work around for port creation for router
        # tenant_id=''(empty string) is passed when port is created
        # by l3 plugin internally for router.
        # On the other hand, ODL doesn't accept empty string for tenant_id.
        # In that case, deduce tenant_id from network_id for now.
        # Right fix: modify Neutron so that don't allow empty string
        # for tenant_id even for port for internal use.
        # TODO(yamahata): eliminate this work around when neutron side
        # is fixed
        # assert port['tenant_id'] != ''
        if port['tenant_id'] == '':
            LOG.debug('empty string was passed for tenant_id: %s(port)', port)
            port['tenant_id'] = context._network_context._network['tenant_id']
Ejemplo n.º 10
0
    def filter_create_attributes(cls, port, context):
        """Filter out port attributes not required for a create."""
        cls._add_security_groups(port, context)
        cls._fixup_allowed_ipaddress_pairs(port[addr_pair.ADDRESS_PAIRS])
        cls._filter_unmapped_null(port, cls._UNMAPPED_KEYS)
        odl_utils.try_del(port, ['status'])

        # NOTE(yamahata): work around for port creation for router
        # tenant_id=''(empty string) is passed when port is created
        # by l3 plugin internally for router.
        # On the other hand, ODL doesn't accept empty string for tenant_id.
        # In that case, deduce tenant_id from network_id for now.
        # Right fix: modify Neutron so that don't allow empty string
        # for tenant_id even for port for internal use.
        # TODO(yamahata): eliminate this work around when neutron side
        # is fixed
        # assert port['tenant_id'] != ''
        if port['tenant_id'] == '':
            LOG.debug('empty string was passed for tenant_id: %s(port)', port)
            port['tenant_id'] = context._network_context._network['tenant_id']
Ejemplo n.º 11
0
    def filter_create_port_attributes(cls, port, context):
        """Filter out port attributes not required for a create."""
        cls.add_security_groups(port, context)
        # TODO(kmestery): Converting to uppercase due to ODL bug
        # https://bugs.opendaylight.org/show_bug.cgi?id=477
        port['mac_address'] = port['mac_address'].upper()
        odl_utils.try_del(port, ['status'])

        # NOTE(yamahata): work around for port creation for router
        # tenant_id=''(empty string) is passed when port is created
        # by l3 plugin internally for router.
        # On the other hand, ODL doesn't accept empty string for tenant_id.
        # In that case, deduce tenant_id from network_id for now.
        # Right fix: modify Neutron so that don't allow empty string
        # for tenant_id even for port for internal use.
        # TODO(yamahata): eliminate this work around when neutron side
        # is fixed
        # assert port['tenant_id'] != ''
        if port['tenant_id'] == '':
            LOG.debug('empty string was passed for tenant_id: %s(port)', port)
            port['tenant_id'] = context._network_context._network['tenant_id']
Ejemplo n.º 12
0
    def filter_create_port_attributes(cls, port, context):
        """Filter out port attributes not required for a create."""
        cls.add_security_groups(port, context)
        # TODO(kmestery): Converting to uppercase due to ODL bug
        # https://bugs.opendaylight.org/show_bug.cgi?id=477
        port['mac_address'] = port['mac_address'].upper()
        odl_utils.try_del(port, ['status'])

        # NOTE(yamahata): work around for port creation for router
        # tenant_id=''(empty string) is passed when port is created
        # by l3 plugin internally for router.
        # On the other hand, ODL doesn't accept empty string for tenant_id.
        # In that case, deduce tenant_id from network_id for now.
        # Right fix: modify Neutron so that don't allow empty string
        # for tenant_id even for port for internal use.
        # TODO(yamahata): eliminate this work around when neutron side
        # is fixed
        # assert port['tenant_id'] != ''
        if port['tenant_id'] == '':
            LOG.debug('empty string was passed for tenant_id: %s(port)', port)
            port['tenant_id'] = context._network_context._network['tenant_id']
Ejemplo n.º 13
0
def _filter_unmapped_null(resource_dict, unmapped_keys):
    # NOTE(yamahata): bug work around
    # https://bugs.eclipse.org/bugs/show_bug.cgi?id=475475
    #   Null-value for an unmapped element causes next mapped
    #   collection to contain a null value
    #   JSON: { "unmappedField": null, "mappedCollection": [ "a" ] }
    #
    #   Java Object:
    #   class Root {
    #     Collection<String> mappedCollection = new ArrayList<String>;
    #   }
    #
    #   Result:
    #   Field B contains one element; null
    #
    # TODO(yamahata): update along side with neutron and ODL
    #   add when neutron adds more extensions
    #   delete when ODL neutron northbound supports it
    # TODO(yamahata): do same thing for other resources
    keys_to_del = [key for key in unmapped_keys
                   if resource_dict.get(key) is None]
    if keys_to_del:
        odl_utils.try_del(resource_dict, keys_to_del)
Ejemplo n.º 14
0
def _filter_network_update(network):
    odl_utils.try_del(network, ['id', 'status', 'subnets', 'tenant_id'])
Ejemplo n.º 15
0
 def filter_update_attributes(router):
     """Filter out attributes for an update operation."""
     odl_utils.try_del(router, ['id', 'tenant_id', 'status'])
Ejemplo n.º 16
0
def _filter_port(port, attributes):
    odl_utils.try_del(port, attributes)
    _filter_unmapped_null(port, _PORT_UNMAPPED_KEYS)
    # ODL excpects binding:profile to be a string, not a dict
    _convert_value_to_str(port, key='binding:profile')
Ejemplo n.º 17
0
def _filter_network_update(network):
    odl_utils.try_del(network,
                      ['id', 'status', 'subnets', 'tenant_id', 'project_id'])
    _filter_unmapped_null(network, _NETWORK_UNMAPPED_KEYS)
Ejemplo n.º 18
0
 def filter_create_attributes(cls, network, context):
     """Filter out network attributes not required for a create."""
     odl_utils.try_del(network, ['status', 'subnets'])
     cls._filter_unmapped_null(network, cls._UNMAPPED_KEYS)
Ejemplo n.º 19
0
def _filter_network_update(network):
    odl_utils.try_del(network, ['id', 'status', 'subnets', 'tenant_id'])
Ejemplo n.º 20
0
def _filter_port_create(port):
    """Filter out port attributes not required for a create."""
    odl_utils.try_del(port, ['status'])
    _filter_unmapped_null(port, _PORT_UNMAPPED_KEYS)
Ejemplo n.º 21
0
 def filter_update_attributes(network):
     """Filter out network attributes for an update operation."""
     odl_utils.try_del(network, ['id', 'status', 'subnets', 'tenant_id'])
Ejemplo n.º 22
0
def _filter_port_create(port):
    """Filter out port attributes not required for a create."""
    odl_utils.try_del(port, ['status'])
    _filter_unmapped_null(port, _PORT_UNMAPPED_KEYS)
Ejemplo n.º 23
0
def _filter_port_update(port):
    """Filter out port attributes for an update operation."""
    odl_utils.try_del(port, ['network_id', 'id', 'status', 'mac_address',
                      'tenant_id', 'fixed_ips'])
    _filter_unmapped_null(port, _PORT_UNMAPPED_KEYS)
Ejemplo n.º 24
0
def _filter_subnet_update(subnet):
    odl_utils.try_del(subnet, ['id', 'network_id', 'ip_version', 'cidr',
                      'allocation_pools', 'tenant_id'])
Ejemplo n.º 25
0
def _filter_network_update(network):
    odl_utils.try_del(network, ['id', 'status', 'subnets', 'tenant_id'])
    _filter_unmapped_null(network, _NETWORK_UNMAPPED_KEYS)
Ejemplo n.º 26
0
def _filter_network_create(network):
    odl_utils.try_del(network, ['status', 'subnets'])
    _filter_unmapped_null(network, _NETWORK_UNMAPPED_KEYS)
Ejemplo n.º 27
0
def _filter_subnet_update(subnet):
    odl_utils.try_del(subnet, [
        'id', 'network_id', 'ip_version', 'cidr', 'allocation_pools',
        'tenant_id'
    ])
Ejemplo n.º 28
0
 def filter_create_attributes(cls, port):
     """Filter out port attributes not required for a create."""
     cls._filter_unmapped_null(port)
     odl_utils.try_del(port, ['status'])
Ejemplo n.º 29
0
def _filter_port_create(port):
    """Filter out port attributes not required for a create."""
    _filter_port_unmapped_null(port)
    odl_utils.try_del(port, ['status'])
Ejemplo n.º 30
0
 def filter_create_network_attributes(network, context):
     """Filter out network attributes not required for a create."""
     odl_utils.try_del(network, ['status', 'subnets', 'vlan_transparent',
                       'mtu'])
Ejemplo n.º 31
0
 def filter_update_attributes(cls, network, context):
     """Filter out network attributes for an update operation."""
     odl_utils.try_del(network, ['id', 'status', 'subnets', 'tenant_id'])
     cls._filter_unmapped_null(network, cls._UNMAPPED_KEYS)
Ejemplo n.º 32
0
 def filter_update_network_attributes(network, context):
     """Filter out network attributes for an update operation."""
     odl_utils.try_del(network, ['id', 'status', 'subnets', 'tenant_id',
                       'vlan_transparent', 'mtu'])
Ejemplo n.º 33
0
def _filter_network_create(network):
    odl_utils.try_del(network, ['status', 'subnets'])
Ejemplo n.º 34
0
 def filter_update_attributes(cls, port, context):
     """Filter out port attributes for an update operation."""
     cls._add_security_groups(port, context)
     cls._fixup_allowed_ipaddress_pairs(port[addr_apidef.ADDRESS_PAIRS])
     cls._filter_unmapped_null(port, cls._UNMAPPED_KEYS)
     odl_utils.try_del(port, ['network_id', 'id', 'status', 'tenant_id'])
Ejemplo n.º 35
0
def _filter_network_create(network):
    odl_utils.try_del(network, ['status', 'subnets'])
    _filter_unmapped_null(network, _NETWORK_UNMAPPED_KEYS)
Ejemplo n.º 36
0
def _filter_port_create(port):
    """Filter out port attributes not required for a create."""
    _filter_port_unmapped_null(port)
    odl_utils.try_del(port, ['status'])
Ejemplo n.º 37
0
def _filter_subnet_update(subnet):
    odl_utils.try_del(
        subnet,
        ['id', 'network_id', 'ip_version', 'cidr', 'tenant_id', 'project_id'])
    _filter_unmapped_null(subnet, _SUBNET_UNMAPPED_KEYS)
Ejemplo n.º 38
0
def _filter_network_create(network):
    odl_utils.try_del(network, ['status', 'subnets'])
Ejemplo n.º 39
0
 def filter_create_attributes(network):
     """Filter out network attributes not required for a create."""
     odl_utils.try_del(network, ['status', 'subnets'])
Ejemplo n.º 40
0
def _filter_port_update(port):
    """Filter out port attributes for an update operation."""
    odl_utils.try_del(
        port, ['network_id', 'id', 'status', 'tenant_id', 'project_id'])
    _filter_unmapped_null(port, _PORT_UNMAPPED_KEYS)
Ejemplo n.º 41
0
 def filter_update_attributes(subnet):
     """Filter out subnet attributes for an update operation."""
     odl_utils.try_del(subnet, ['id', 'network_id', 'ip_version', 'cidr',
                       'allocation_pools', 'tenant_id'])
Ejemplo n.º 42
0
 def filter_update_port_attributes(cls, port, context):
     """Filter out port attributes for an update operation."""
     cls.add_security_groups(port, context)
     odl_utils.try_del(port, ['network_id', 'id', 'status', 'mac_address',
                       'tenant_id', 'fixed_ips'])
Ejemplo n.º 43
0
 def filter_update_attributes(cls, port):
     """Filter out port attributes for an update operation."""
     cls._filter_unmapped_null(port)
     odl_utils.try_del(port, ['network_id', 'id', 'status', 'mac_address',
                       'tenant_id', 'fixed_ips'])
Ejemplo n.º 44
0
def _filter_network_create(network):
    odl_utils.try_del(network, ['status', 'subnets'])
    _network_attribute_compatibility(network)
    _filter_unmapped_null(network, _NETWORK_UNMAPPED_KEYS)