'Update the port IPs
Updates the port\'s IPs based on any new fixed_ips passed in or if
deferred IP allocation is in effect because allocation requires host
binding information that wasn\'t provided until port update.
:param old_port_db: The port database record
:param old_port: A port dict created by calling _make_port_dict.  This
must be called before calling this method in order to
load data from extensions, specifically host binding.
:param new_port: The new port data passed through the API.'

def update_port(self, context, old_port_db, old_port, new_port):

    old_host = old_port.get(portbindings.HOST_ID)
    new_host = new_port.get(portbindings.HOST_ID)
    host = (new_host if validators.is_attr_set(new_host) else old_host)
    changes = self.update_port_with_ips(context, host, old_port_db, new_port, new_port.get('mac_address'))
    fixed_ips_requested = validators.is_attr_set(new_port.get('fixed_ips'))
    old_ips = old_port.get('fixed_ips')
    deferred_ip_allocation = ((old_port.get('ip_allocation') == ipa.IP_ALLOCATION_DEFERRED) and host and (not old_host) and (not old_ips) and (not fixed_ips_requested))
    if (not deferred_ip_allocation):
        new_host_requested = (host and (host != old_host))
        if (old_ips and new_host_requested and (not fixed_ips_requested)):
            valid_subnets = self._ipam_get_subnets(context, old_port['network_id'], host)
            valid_subnet_ids = {s['id'] for s in valid_subnets}
            for fixed_ip in old_ips:
                if (fixed_ip['subnet_id'] not in valid_subnet_ids):
                    raise segment_exc.HostNotCompatibleWithFixedIps(host=host, port_id=old_port['id'])
        return changes
    port_copy = copy.deepcopy(old_port)
    port_copy['fixed_ips'] = const.ATTR_NOT_SPECIFIED
    port_copy.update(new_port)
    context.session.expire(old_port_db, ['fixed_ips'])
    ips = self.allocate_ips_for_port_and_store(context, {'port': port_copy}, port_copy['id'])
    getattr(old_port_db, 'fixed_ips')
    return self.Changes(add=ips, original=[], remove=[])
