def lsn_port_create(self, context, lsn_id, subnet_info): """Create and return LSN port for associated subnet.""" try: return lsn_api.lsn_port_create(self.cluster, lsn_id, subnet_info) except n_exc.NotFound: raise p_exc.LsnNotFound(entity='', entity_id=lsn_id) except api_exc.NsxApiException: err_msg = _('Unable to create port for LSN %s') % lsn_id raise p_exc.NsxPluginException(err_msg=err_msg)
def lsn_get_for_network(context, network_id, raise_on_err=True): """Retrieve LSN information given its network id.""" query = context.session.query(nsx_models.Lsn) try: return query.filter_by(net_id=network_id).one() except (orm.exc.NoResultFound, d_exc.DBError): msg = _('Unable to find Logical Service Node for network %s') if raise_on_err: LOG.error(msg, network_id) raise p_exc.LsnNotFound(entity='network', entity_id=network_id) else: LOG.warning(msg, network_id)
def lsn_get(self, context, network_id, raise_on_err=True): """Retrieve the LSN id associated to the network.""" try: return lsn_api.lsn_for_network_get(self.cluster, network_id) except (n_exc.NotFound, api_exc.NsxApiException): if raise_on_err: LOG.error( 'Unable to find Logical Service Node for ' 'network %s.', network_id) raise p_exc.LsnNotFound(entity='network', entity_id=network_id) else: LOG.warning( 'Unable to find Logical Service Node for ' 'the requested network %s.', network_id)