Exemple #1
0
def get_rpc_service(service_ident):
    """Get the RPC service from the service uuid or logical name.

    :param service_ident: the UUID or logical name of a service.

    :returns: The RPC Service.
    :raises: InvalidUuidOrName if the name or uuid provided is not valid.
    :raises: ServiceNotFound if the service is not found.
    """
    # Check to see if the service_ident is a valid UUID.  If it is, treat it
    # as a UUID.
    if uuidutils.is_uuid_like(service_ident):
        return objects.Service.get_by_uuid(pecan.request.context,
                                           service_ident)

    # We can refer to services by their name, if the client supports it
    # if allow_service_logical_names():
    #    if utils.is_hostname_safe(service_ident):
    else:
        return objects.Service.get_by_name(pecan.request.context,
                                           service_ident)

    raise exception.InvalidUuidOrName(name=service_ident)

    raise exception.ServiceNotFound(service=service_ident)
Exemple #2
0
    def _do_update_exposed_service(self, service_id, values):
        session = get_session()
        with session.begin():
            query = model_query(models.ExposedService, session=session)
            query = add_identity_filter(query, service_id)
            try:
                ref = query.with_lockmode('update').one()
            except NoResultFound:
                raise exception.ServiceNotFound(uuid=service_id)

            ref.update(values)
        return ref
Exemple #3
0
    def destroy_service(self, service_id):

        session = get_session()
        with session.begin():
            query = model_query(models.Service, session=session)
            query = add_identity_filter(query, service_id)
            try:
                service_ref = query.one()
            except NoResultFound:
                raise exception.ServiceNotFound(service=service_id)

            # Get service ID, if an UUID was supplied. The ID is
            # required for deleting all ports, attached to the service.
            if uuidutils.is_uuid_like(service_id):
                service_id = service_ref['id']

            query.delete()
Exemple #4
0
 def get_service_by_name(self, service_name):
     query = model_query(models.Service).filter_by(name=service_name)
     try:
         return query.one()
     except NoResultFound:
         raise exception.ServiceNotFound(service=service_name)