Beispiel #1
0
 def lsn_port_get_by_mac(self, context, network_id, mac, raise_on_err=True):
     """Retrieve LSN and LSN port given network and mac address."""
     lsn_id = self.lsn_get(context, network_id, raise_on_err=raise_on_err)
     if lsn_id:
         try:
             lsn_port_id = lsn_api.lsn_port_by_mac_get(
                 self.cluster, lsn_id, mac)
         except (n_exc.NotFound, api_exc.NsxApiException):
             if raise_on_err:
                 LOG.error(_LE('Unable to find Logical Service Node Port '
                               'for LSN %(lsn_id)s and mac address '
                               '%(mac)s'),
                           {'lsn_id': lsn_id, 'mac': mac})
                 raise p_exc.LsnPortNotFound(lsn_id=lsn_id,
                                             entity='MAC',
                                             entity_id=mac)
             else:
                 LOG.warning(_LW('Unable to find Logical Service Node '
                                 'Port for LSN %(lsn_id)s and mac address '
                                 '%(mac)s'),
                             {'lsn_id': lsn_id, 'mac': mac})
             return (lsn_id, None)
         else:
             return (lsn_id, lsn_port_id)
     else:
         return (None, None)
Beispiel #2
0
 def lsn_port_get(self, context, network_id, subnet_id, raise_on_err=True):
     """Retrieve LSN and LSN port for the network and the subnet."""
     lsn_id = self.lsn_get(context, network_id, raise_on_err=raise_on_err)
     if lsn_id:
         try:
             lsn_port_id = lsn_api.lsn_port_by_subnet_get(
                 self.cluster, lsn_id, subnet_id)
         except (n_exc.NotFound, api_exc.NsxApiException):
             if raise_on_err:
                 LOG.error(_LE('Unable to find Logical Service Node Port '
                               'for LSN %(lsn_id)s and subnet '
                               '%(subnet_id)s'),
                           {'lsn_id': lsn_id, 'subnet_id': subnet_id})
                 raise p_exc.LsnPortNotFound(lsn_id=lsn_id,
                                             entity='subnet',
                                             entity_id=subnet_id)
             else:
                 LOG.warning(_LW('Unable to find Logical Service Node Port '
                                 'for LSN %(lsn_id)s and subnet '
                                 '%(subnet_id)s'),
                             {'lsn_id': lsn_id, 'subnet_id': subnet_id})
             return (lsn_id, None)
         else:
             return (lsn_id, lsn_port_id)
     else:
         return (None, None)
Beispiel #3
0
def lsn_port_get_for_mac(context, mac_address, raise_on_err=True):
    """Return Logical Service Node Port information given its mac address."""
    with db_api.CONTEXT_READER.using(context):
        try:
            return (context.session.query(
                nsx_models.LsnPort).filter_by(mac_addr=mac_address).one())
        except (orm.exc.NoResultFound, d_exc.DBError):
            if raise_on_err:
                raise p_exc.LsnPortNotFound(lsn_id=None,
                                            entity='mac',
                                            entity_id=mac_address)
Beispiel #4
0
def lsn_port_get_for_subnet(context, subnet_id, raise_on_err=True):
    """Return Logical Service Node Port information given its subnet id."""
    with db_api.CONTEXT_READER.using(context):
        try:
            return (context.session.query(
                nsx_models.LsnPort).filter_by(sub_id=subnet_id).one())
        except (orm.exc.NoResultFound, d_exc.DBError):
            if raise_on_err:
                raise p_exc.LsnPortNotFound(lsn_id=None,
                                            entity='subnet',
                                            entity_id=subnet_id)