Add bay uuid to Service Objects
Change-Id: Ia8b757d5bbe477c2de09b65f35409847fd1623c3
This commit is contained in:
parent
5405375608
commit
71458fb8ea
|
@ -83,6 +83,7 @@ def upgrade():
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('uuid', sa.String(length=36), nullable=True),
|
sa.Column('uuid', sa.String(length=36), nullable=True),
|
||||||
|
sa.Column('bay_uuid', sa.String(length=36), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
mysql_ENGINE='InnoDB',
|
mysql_ENGINE='InnoDB',
|
||||||
mysql_DEFAULT_CHARSET='UTF8'
|
mysql_DEFAULT_CHARSET='UTF8'
|
||||||
|
|
|
@ -934,6 +934,13 @@ class Connection(api.Connection):
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
raise exception.ServiceNotFound(service=service_uuid)
|
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):
|
def get_service_by_instance(self, instance):
|
||||||
if not utils.is_uuid_like(instance):
|
if not utils.is_uuid_like(instance):
|
||||||
raise exception.InvalidUUID(uuid=instance)
|
raise exception.InvalidUUID(uuid=instance)
|
||||||
|
|
|
@ -170,7 +170,7 @@ class Pod(Base):
|
||||||
bay_uuid = Column(String(36))
|
bay_uuid = Column(String(36))
|
||||||
|
|
||||||
|
|
||||||
class AbrviceObject(Base):
|
class ServiceObject(Base):
|
||||||
"""Represents a software service."""
|
"""Represents a software service."""
|
||||||
|
|
||||||
__tablename__ = 'service'
|
__tablename__ = 'service'
|
||||||
|
@ -180,3 +180,4 @@ class AbrviceObject(Base):
|
||||||
)
|
)
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
uuid = Column(String(36))
|
uuid = Column(String(36))
|
||||||
|
bay_uuid = Column(String(36))
|
||||||
|
|
|
@ -34,6 +34,7 @@ class Service(base.MagnumObject):
|
||||||
fields = {
|
fields = {
|
||||||
'id': int,
|
'id': int,
|
||||||
'uuid': obj_utils.str_or_none,
|
'uuid': obj_utils.str_or_none,
|
||||||
|
'bay_uuid': obj_utils.str_or_none,
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -88,6 +89,17 @@ class Service(base.MagnumObject):
|
||||||
service = Service._from_db_object(cls(context), db_service)
|
service = Service._from_db_object(cls(context), db_service)
|
||||||
return 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
|
@base.remotable_classmethod
|
||||||
def list(cls, context, limit=None, marker=None,
|
def list(cls, context, limit=None, marker=None,
|
||||||
sort_key=None, sort_dir=None):
|
sort_key=None, sort_dir=None):
|
||||||
|
|
Loading…
Reference in New Issue