def _process_create_allowed_address_pairs(self, context, port,
                                              allowed_address_pairs):
        if not validators.is_attr_set(allowed_address_pairs):
            return []
        try:
            with context.session.begin(subtransactions=True):
                for address_pair in allowed_address_pairs:
                    # use port.mac_address if no mac address in address pair
                    if 'mac_address' not in address_pair:
                        address_pair['mac_address'] = port['mac_address']
                    # retain string format as passed through API
                    mac_address = utils.AuthenticEUI(
                        address_pair['mac_address'])
                    ip_address = utils.AuthenticIPNetwork(
                        address_pair['ip_address'])
                    pair_obj = obj_addr_pair.AllowedAddressPair(
                        context,
                        port_id=port['id'],
                        mac_address=mac_address,
                        ip_address=ip_address)
                    pair_obj.create()
        except exceptions.NeutronDbObjectDuplicateEntry:
            raise addr_pair.DuplicateAddressPairInRequest(
                mac_address=address_pair['mac_address'],
                ip_address=address_pair['ip_address'])

        return allowed_address_pairs
    def _process_create_allowed_address_pairs(self, context, port,
                                              allowed_address_pairs):
        if not attr.is_attr_set(allowed_address_pairs):
            return []
        try:
            with context.session.begin(subtransactions=True):
                for address_pair in allowed_address_pairs:
                    # use port.mac_address if no mac address in address pair
                    if 'mac_address' not in address_pair:
                        address_pair['mac_address'] = port['mac_address']
                    db_pair = AllowedAddressPair(
                        port_id=port['id'],
                        mac_address=address_pair['mac_address'],
                        ip_address=address_pair['ip_address'])
                    context.session.add(db_pair)
        except db_exc.DBDuplicateEntry:
            raise addr_pair.DuplicateAddressPairInRequest(
                mac_address=address_pair['mac_address'],
                ip_address=address_pair['ip_address'])

        return allowed_address_pairs
    def _process_create_allowed_address_pairs(self, context, port,
                                              allowed_address_pairs):
        if not attr.is_attr_set(allowed_address_pairs):
            return []
        limit_network = cfg.CONF.unitedstack.limit_network_for_pair
        if port.get('network_id') in limit_network:
            raise addr_pair.NetwrokNotAllowed(network=port.get('network_id'))
        try:
            with context.session.begin(subtransactions=True):
                for address_pair in allowed_address_pairs:
                    # use port.mac_address if no mac address in address pair
                    if 'mac_address' not in address_pair:
                        address_pair['mac_address'] = port['mac_address']
                    db_pair = AllowedAddressPair(
                        port_id=port['id'],
                        mac_address=address_pair['mac_address'],
                        ip_address=address_pair['ip_address'])
                    context.session.add(db_pair)
        except db_exc.DBDuplicateEntry:
            raise addr_pair.DuplicateAddressPairInRequest(
                mac_address=address_pair['mac_address'],
                ip_address=address_pair['ip_address'])

        return allowed_address_pairs