Merge "Define and assign capsule status"

This commit is contained in:
Zuul 2018-02-27 11:36:49 +00:00 committed by Gerrit Code Review
commit 80cbb24bd8
6 changed files with 24 additions and 3 deletions

View File

@ -141,6 +141,7 @@ class CapsuleController(base.Controller):
new_capsule = objects.Capsule(context, **capsule_dict)
new_capsule.project_id = context.project_id
new_capsule.user_id = context.user_id
new_capsule.status = consts.PENDING
new_capsule.create(context)
new_capsule.containers = []
new_capsule.containers_uuids = []

View File

@ -19,6 +19,12 @@ CONTAINER_STATUSES = (
'Deleted', 'Deleting'
)
CAPSULE_STATUSES = (
PENDING, RUNNING, SUCCEEDED, FAILED, UNKNOWN
) = (
'Pending', 'Running', 'Succeeded', 'Failed', 'Unknown'
)
TASK_STATES = (
IMAGE_PULLING, CONTAINER_CREATING, SANDBOX_CREATING,
CONTAINER_STARTING, CONTAINER_DELETING, SANDBOX_DELETING,

View File

@ -990,6 +990,7 @@ class Manager(periodic_task.PeriodicTasks):
container_list = [container_uuid]
capsule.volumes_info[volume_id] = container_list
capsule.status = consts.RUNNING
capsule.save(context)
def capsule_delete(self, context, capsule):

View File

@ -27,7 +27,8 @@ class Capsule(base.ZunPersistentObject, base.ZunObject):
# Version 1.3: Add 'Deleting' to ContainerStatus
# Version 1.4: Add addresses and volumes_info
# Version 1.5: Change the properties of restort_policy
VERSION = '1.5'
# Version 1.6: Change the type of status
VERSION = '1.6'
fields = {
'capsule_version': fields.StringField(nullable=True),
@ -39,7 +40,7 @@ class Capsule(base.ZunPersistentObject, base.ZunObject):
'project_id': fields.StringField(nullable=True),
'user_id': fields.StringField(nullable=True),
'status': z_fields.ContainerStatusField(nullable=True),
'status': z_fields.CapsuleStatusField(nullable=True),
'status_reason': fields.StringField(nullable=True),
'cpu': fields.FloatField(nullable=True),
'memory': fields.StringField(nullable=True),

View File

@ -37,6 +37,18 @@ class ContainerStatusField(fields.BaseEnumField):
AUTO_TYPE = ContainerStatus()
class CapsuleStatus(fields.Enum):
ALL = consts.CAPSULE_STATUSES
def __init__(self):
super(CapsuleStatus, self).__init__(
valid_values=CapsuleStatus.ALL)
class CapsuleStatusField(fields.BaseEnumField):
AUTO_TYPE = CapsuleStatus()
class TaskState(fields.Enum):
ALL = consts.TASK_STATES

View File

@ -353,7 +353,7 @@ object_data = {
'ResourceClass': '1.1-d661c7675b3cd5b8c3618b68ba64324e',
'ResourceProvider': '1.0-92b427359d5a4cf9ec6c72cbe630ee24',
'ZunService': '1.2-deff2a74a9ce23baa231ae12f39a6189',
'Capsule': '1.5-cbdaffa78fa68c26cf4a61d8f75dd32d',
'Capsule': '1.6-7238a80b4ef34e219c135fa72d0adc06',
'PciDevice': '1.1-6e3f0851ad1cf12583e6af4df1883979',
'ComputeNode': '1.9-e8536102d3b28cb3378e9e26f508cd72',
'PciDevicePool': '1.0-3f5ddc3ff7bfa14da7f6c7e9904cc000',