def _update_fip_assoc(self, context, fip, floatingip_db, external_port): port_id = internal_ip_address = router_id = None if (('fixed_ip_address' in fip and fip['fixed_ip_address']) and not ('port_id' in fip and fip['port_id'])): msg = _("fixed_ip_address cannot be specified without a port_id") raise q_exc.BadRequest(resource='floatingip', msg=msg) if 'port_id' in fip and fip['port_id']: port_id, internal_ip_address, router_id = self.get_assoc_data( context, fip, floatingip_db['floating_network_id']) fip_qry = context.session.query(FloatingIP) try: fip_qry.filter_by( fixed_port_id=fip['port_id'], floating_network_id=floatingip_db['floating_network_id'], fixed_ip_address=internal_ip_address).one() raise l3.FloatingIPPortAlreadyAssociated( port_id=fip['port_id'], fip_id=floatingip_db['id'], floating_ip_address=floatingip_db['floating_ip_address'], fixed_ip=internal_ip_address, net_id=floatingip_db['floating_network_id']) except exc.NoResultFound: pass floatingip_db.update({ 'fixed_ip_address': internal_ip_address, 'fixed_port_id': port_id, 'router_id': router_id })
def _update_fip_assoc(self, context, fip, floatingip_db, external_port): port_id = internal_ip_address = router_id = None if 'port_id' in fip and fip['port_id']: port_qry = context.session.query(FloatingIP) try: port_qry.filter_by(fixed_port_id=fip['port_id']).one() raise l3.FloatingIPPortAlreadyAssociated( port_id=fip['port_id']) except exc.NoResultFound: pass port_id, internal_ip_address, router_id = self.get_assoc_data( context, fip, floatingip_db['floating_network_id']) floatingip_db.update({ 'fixed_ip_address': internal_ip_address, 'fixed_port_id': port_id, 'router_id': router_id })