Merge "Shorten the data of task_state field"

This commit is contained in:
Zuul 2018-03-12 10:36:57 +00:00 committed by Gerrit Code Review
commit c8028f9aae
4 changed files with 11 additions and 13 deletions

View File

@ -29,15 +29,14 @@ TASK_STATES = (
IMAGE_PULLING, CONTAINER_CREATING, SANDBOX_CREATING,
CONTAINER_STARTING, CONTAINER_DELETING, SANDBOX_DELETING,
CONTAINER_STOPPING, CONTAINER_REBOOTING, CONTAINER_PAUSING,
CONTAINER_UNPAUSING, CONTAINER_KILLING, CONTAINER_ADDING_SG,
CONTAINER_REMOVING_SG, NETWORK_ATTACHING,
NETWORK_DETACHING
CONTAINER_UNPAUSING, CONTAINER_KILLING, SG_ADDING,
SG_REMOVING, NETWORK_ATTACHING, NETWORK_DETACHING
) = (
'image_pulling', 'container_creating', 'sandbox_creating',
'container_starting', 'container_deleting', 'sandbox_deleting',
'container_stopping', 'container_rebooting', 'container_pausing',
'container_unpausing', 'container_killing', 'container_adding_sg',
'container_removing_sg', 'network_attaching', 'network_detaching'
'container_unpausing', 'container_killing', 'sg_adding',
'sg_removing', 'network_attaching', 'network_detaching'
)
RESOURCE_CLASSES = (

View File

@ -153,11 +153,11 @@ class Manager(periodic_task.PeriodicTasks):
self.network_detach(context, container)
return
if container.task_state == consts.CONTAINER_ADDING_SG:
if container.task_state == consts.SG_ADDING:
self.add_security_group(context, container)
return
if container.task_state == consts.CONTAINER_REMOVING_SG:
if container.task_state == consts.SG_REMOVING:
self.remove_security_group(context, container)
return
@ -467,8 +467,7 @@ class Manager(periodic_task.PeriodicTasks):
@wrap_container_event(prefix='compute')
def _add_security_group(self, context, container, security_group):
LOG.debug('Adding security_group to container: %s', container.uuid)
self._update_task_state(context, container,
consts.CONTAINER_ADDING_SG)
self._update_task_state(context, container, consts.SG_ADDING)
self.driver.add_security_group(context, container, security_group)
self._update_task_state(context, container, None)
container.security_groups += [security_group]
@ -485,8 +484,7 @@ class Manager(periodic_task.PeriodicTasks):
@wrap_container_event(prefix='compute')
def _remove_security_group(self, context, container, security_group):
LOG.debug('Removing security_group from container: %s', container.uuid)
self._update_task_state(context, container,
consts.CONTAINER_REMOVING_SG)
self._update_task_state(context, container, consts.SG_REMOVING)
self.driver.remove_security_group(context, container,
security_group)
self._update_task_state(context, container, None)

View File

@ -53,7 +53,8 @@ class Container(base.ZunPersistentObject, base.ZunObject):
# Version 1.22: Add 'Deleting' to ContainerStatus
# Version 1.23: Add the missing 'pci_devices' attribute
# Version 1.24: Add the storage_opt attribute
VERSION = '1.24'
# Version 1.25: Change TaskStateField definition
VERSION = '1.25'
fields = {
'id': fields.IntegerField(),

View File

@ -344,7 +344,7 @@ class TestObject(test_base.TestCase, _TestObject):
# For more information on object version testing, read
# https://docs.openstack.org/zun/latest/
object_data = {
'Container': '1.24-e9230fe84ef146c80f996d55febc5b4d',
'Container': '1.25-365ee331fee68989272a8e462c0d9999',
'VolumeMapping': '1.1-50df6202f7846a136a91444c38eba841',
'Image': '1.0-0b976be24f4f6ee0d526e5c981ce0633',
'MyObj': '1.0-34c4b1aadefd177b13f9a2f894cc23cd',