'Add or remove IPs from the port. IPAM version'

def _update_ips_for_port(self, context, port, host, original_ips, new_ips, mac):

    added = []
    removed = []
    changes = self._get_changed_ips_for_port(context, original_ips, new_ips, port['device_owner'])
    try:
        subnets = self._ipam_get_subnets(context, network_id=port['network_id'], host=host, service_type=port.get('device_owner'))
    except ipam_exc.DeferIpam:
        subnets = []
    to_add = self._test_fixed_ips_for_port(context, port['network_id'], changes.add, port['device_owner'], subnets)
    if (port['device_owner'] not in constants.ROUTER_INTERFACE_OWNERS):
        to_add += self._update_ips_for_pd_subnet(context, subnets, changes.add, mac)
    ipam_driver = driver.Pool.get_instance(None, context)
    if changes.remove:
        removed = self._ipam_deallocate_ips(context, ipam_driver, port, changes.remove)
    v6_stateless = self._classify_subnets(context, subnets)[2]
    handled_subnet_ids = [ip['subnet_id'] for ip in ((to_add + changes.original) + changes.remove)]
    to_add.extend(self._get_auto_address_ips(v6_stateless, port, handled_subnet_ids))
    if to_add:
        added = self._ipam_allocate_ips(context, ipam_driver, port, to_add)
    return self.Changes(add=added, original=changes.original, remove=removed)
