Add bay uuid to Service Objects
Change-Id: Ia8b757d5bbe477c2de09b65f35409847fd1623c3changes/11/141111/2
parent
5405375608
commit
71458fb8ea
|
@ -83,6 +83,7 @@ def upgrade():
|
|||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('uuid', sa.String(length=36), nullable=True),
|
||||
sa.Column('bay_uuid', sa.String(length=36), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_ENGINE='InnoDB',
|
||||
mysql_DEFAULT_CHARSET='UTF8'
|
||||
|
|
|
@ -934,6 +934,13 @@ class Connection(api.Connection):
|
|||
except NoResultFound:
|
||||
raise exception.ServiceNotFound(service=service_uuid)
|
||||
|
||||
def get_service_by_bay_uuid(self, bay_uuid):
|
||||
query = model_query(models.Service).filter_by(bay_uuid=bay_uuid)
|
||||
try:
|
||||
return query.all()
|
||||
except NoResultFound:
|
||||
raise exception.ServiceNotFound(bay=bay_uuid)
|
||||
|
||||
def get_service_by_instance(self, instance):
|
||||
if not utils.is_uuid_like(instance):
|
||||
raise exception.InvalidUUID(uuid=instance)
|
||||
|
|
|
@ -170,7 +170,7 @@ class Pod(Base):
|
|||
bay_uuid = Column(String(36))
|
||||
|
||||
|
||||
class AbrviceObject(Base):
|
||||
class ServiceObject(Base):
|
||||
"""Represents a software service."""
|
||||
|
||||
__tablename__ = 'service'
|
||||
|
@ -180,3 +180,4 @@ class AbrviceObject(Base):
|
|||
)
|
||||
id = Column(Integer, primary_key=True)
|
||||
uuid = Column(String(36))
|
||||
bay_uuid = Column(String(36))
|
||||
|
|
|
@ -34,6 +34,7 @@ class Service(base.MagnumObject):
|
|||
fields = {
|
||||
'id': int,
|
||||
'uuid': obj_utils.str_or_none,
|
||||
'bay_uuid': obj_utils.str_or_none,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
@ -88,6 +89,17 @@ class Service(base.MagnumObject):
|
|||
service = Service._from_db_object(cls(context), db_service)
|
||||
return service
|
||||
|
||||
@base.remotable_classmethod
|
||||
def get_by_bay_uuid(cls, context, bay_uuid):
|
||||
"""Find a service based on bay uuid and return a :class:`Pod` object.
|
||||
|
||||
:param bay_uuid: the uuid of a bay.
|
||||
:param context: Security context
|
||||
:returns: a list of class:`Service` object.
|
||||
"""
|
||||
db_services = cls.dbapi.get_service_by_bay_uuid(bay_uuid)
|
||||
return Service._from_db_object_list(db_services, cls, context)
|
||||
|
||||
@base.remotable_classmethod
|
||||
def list(cls, context, limit=None, marker=None,
|
||||
sort_key=None, sort_dir=None):
|
||||
|
|
Loading…
Reference in New Issue