Implement activate/deactivate logic for image
Ranger update to pass activate/deactivate status and image tags to heat template. Also made minor tempest updates Change-Id: I56a508636f9b90c4f088513a7b7b56b49648a8b2
This commit is contained in:
parent
26e7ae1462
commit
bbb914d70d
@ -100,11 +100,12 @@ class Image(Base, IMSBaseModel):
|
|||||||
|
|
||||||
def __json__(self):
|
def __json__(self):
|
||||||
properties = {}
|
properties = {}
|
||||||
# don't send tags to rds server
|
tags = []
|
||||||
# tags = {}
|
|
||||||
|
|
||||||
for prop in self.properties:
|
for prop in self.properties:
|
||||||
properties[prop.key_name] = prop.key_value
|
properties[prop.key_name] = prop.key_value
|
||||||
|
for item in self.tags:
|
||||||
|
tags.append(item['tag'])
|
||||||
|
|
||||||
return dict(
|
return dict(
|
||||||
id=self.id,
|
id=self.id,
|
||||||
@ -122,6 +123,7 @@ class Image(Base, IMSBaseModel):
|
|||||||
created_at=self.created_at,
|
created_at=self.created_at,
|
||||||
updated_at=self.updated_at,
|
updated_at=self.updated_at,
|
||||||
properties=properties,
|
properties=properties,
|
||||||
|
tags=tags,
|
||||||
regions=self.get_regions_json(),
|
regions=self.get_regions_json(),
|
||||||
customers=[customer.__json__() for customer in self.customers]
|
customers=[customer.__json__() for customer in self.customers]
|
||||||
)
|
)
|
||||||
|
@ -28,12 +28,17 @@ def _properties(alldata, region):
|
|||||||
disk_format=alldata['disk_format'],
|
disk_format=alldata['disk_format'],
|
||||||
min_disk=alldata['min_disk'],
|
min_disk=alldata['min_disk'],
|
||||||
id=str(uuid.UUID(alldata['id'])),
|
id=str(uuid.UUID(alldata['id'])),
|
||||||
|
tags=alldata['tags'],
|
||||||
protected=protected,
|
protected=protected,
|
||||||
copy_from=alldata["url"],
|
copy_from=alldata["url"],
|
||||||
owner=alldata["owner"],
|
owner=alldata["owner"],
|
||||||
is_public=public,
|
is_public=public,
|
||||||
tenants=str(tenants)
|
tenants=str(tenants)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if region['action'] != 'create':
|
||||||
|
properties['deactivate'] = {1: False, 0: True}[alldata['enabled']]
|
||||||
|
|
||||||
if alldata['properties']:
|
if alldata['properties']:
|
||||||
properties['extra_properties'] = alldata['properties']
|
properties['extra_properties'] = alldata['properties']
|
||||||
|
|
||||||
|
@ -9,11 +9,7 @@ json_input = {
|
|||||||
'url': 'https://mirrors.it.att.com/images/image-name',
|
'url': 'https://mirrors.it.att.com/images/image-name',
|
||||||
'disk_format': 'raw', 'min_ram': 0, 'enabled': 1,
|
'disk_format': 'raw', 'min_ram': 0, 'enabled': 1,
|
||||||
'visibility': 'public', 'owner': 'unknown',
|
'visibility': 'public', 'owner': 'unknown',
|
||||||
'image_tags': [{
|
'tags': ["abcd-efgh-ijkl-4567", "mnop-qrst-uvwx-0987"],
|
||||||
'image_internal_id': 1, 'tag': 'abcd-efgh-ijkl-4567'
|
|
||||||
}, {
|
|
||||||
'image_internal_id': 1, 'tag': 'abcd-efgh-ijkl-4567'
|
|
||||||
}],
|
|
||||||
'regions': [{
|
'regions': [{
|
||||||
'action': 'delete', 'image_internal_id': 1,
|
'action': 'delete', 'image_internal_id': 1,
|
||||||
'type': 'single', 'name': 'North'
|
'type': 'single', 'name': 'North'
|
||||||
@ -29,7 +25,7 @@ json_input = {
|
|||||||
'customers': [{
|
'customers': [{
|
||||||
'customer_id': 'abcd-efgh-ijkl-4567', 'image_id': 1
|
'customer_id': 'abcd-efgh-ijkl-4567', 'image_id': 1
|
||||||
}, {
|
}, {
|
||||||
'customer_id': 'abcd-efgh-ijkl-4567', 'image_id': 1
|
'customer_id': 'opqr-stuv-wxyz-8901', 'image_id': 1
|
||||||
}],
|
}],
|
||||||
'container_format': 'bare', 'min_disk': 2,
|
'container_format': 'bare', 'min_disk': 2,
|
||||||
'id': '12345678901234567890123456789012'
|
'id': '12345678901234567890123456789012'
|
||||||
@ -46,10 +42,12 @@ yaml_output = {
|
|||||||
'container_format': 'bare', 'disk_format': 'raw',
|
'container_format': 'bare', 'disk_format': 'raw',
|
||||||
'is_public': True,
|
'is_public': True,
|
||||||
'copy_from': 'https://mirrors.it.att.com/images/image-name',
|
'copy_from': 'https://mirrors.it.att.com/images/image-name',
|
||||||
|
'deactivate': False,
|
||||||
'min_disk': 2, 'min_ram': 0, 'name': 'Ubuntu', 'owner': 'unknown',
|
'min_disk': 2, 'min_ram': 0, 'name': 'Ubuntu', 'owner': 'unknown',
|
||||||
'protected': True,
|
'protected': True,
|
||||||
'id': '12345678-9012-3456-7890-123456789012',
|
'id': '12345678-9012-3456-7890-123456789012',
|
||||||
'tenants': ['abcd-efgh-ijkl-4567', 'abcd-efgh-ijkl-4567'],
|
'tenants': ['abcd-efgh-ijkl-4567', 'opqr-stuv-wxyz-8901'],
|
||||||
|
'tags': ['abcd-efgh-ijkl-4567', 'mnop-qrst-uvwx-0987'],
|
||||||
'extra_properties': {
|
'extra_properties': {
|
||||||
'key_name': 'Key1', 'key_value': 'Key1.value',
|
'key_name': 'Key1', 'key_value': 'Key1.value',
|
||||||
'image_internal_id': 1
|
'image_internal_id': 1
|
||||||
|
@ -70,6 +70,9 @@ class ImsBaseOrmTest(base.BaseOrmTest):
|
|||||||
post_body["regions"] = [region] if set_region else []
|
post_body["regions"] = [region] if set_region else []
|
||||||
# create image with visibililty = "public" or "private"
|
# create image with visibililty = "public" or "private"
|
||||||
post_body["visibility"] = "private" if set_private else "public"
|
post_body["visibility"] = "private" if set_private else "public"
|
||||||
|
# set image tags
|
||||||
|
post_body["tags"] = ["tag1", "tag2"]
|
||||||
|
|
||||||
# add tenant for the image only if set_private
|
# add tenant for the image only if set_private
|
||||||
if set_private:
|
if set_private:
|
||||||
if single_tenant:
|
if single_tenant:
|
||||||
|
@ -181,7 +181,8 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
|
|||||||
@decorators.idempotent_id('bac99348-6b13-4b30-958b-3c039b27eda3')
|
@decorators.idempotent_id('bac99348-6b13-4b30-958b-3c039b27eda3')
|
||||||
def test_update_image_tenant(self):
|
def test_update_image_tenant(self):
|
||||||
# replace current tenant in self.private_image with alt tenant
|
# replace current tenant in self.private_image with alt tenant
|
||||||
self.client.update_customer(self.private_image['id'], self.alt_tenant_id)
|
self.client.update_customer(self.private_image['id'],
|
||||||
|
self.alt_tenant_id)
|
||||||
self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success')
|
self._wait_for_image_status_on_dcp(self.private_image['id'], 'Success')
|
||||||
|
|
||||||
# check that image tenants array contains only alt tenant
|
# check that image tenants array contains only alt tenant
|
||||||
@ -210,21 +211,22 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
|
|||||||
@decorators.idempotent_id('01160918-e217-401d-a6a0-e7992ab76e41')
|
@decorators.idempotent_id('01160918-e217-401d-a6a0-e7992ab76e41')
|
||||||
def test_update_image(self):
|
def test_update_image(self):
|
||||||
region = {}
|
region = {}
|
||||||
post_body = self._get_image_params(set_region=False,
|
post_body = self._get_image_params(set_region=False)
|
||||||
set_enabled=False)
|
|
||||||
image = self._data_setup(post_body)
|
image = self._data_setup(post_body)
|
||||||
test_image_id = image['id']
|
test_image_id = image['id']
|
||||||
|
|
||||||
# setup region and change 'enabled' and 'customer' properties
|
# setup region and change 'enabled', 'customers' properties
|
||||||
region["name"] = self.region_id
|
region["name"] = self.region_id
|
||||||
region["type"] = "single"
|
region["type"] = "single"
|
||||||
region["checksum"] = "7297321c2fa6424417a548c85edd6e98"
|
region["checksum"] = "7297321c2fa6424417a548c85edd6e98"
|
||||||
region["virtual_size"] = "None"
|
region["virtual_size"] = "None"
|
||||||
region["size"] = "38797312"
|
region["size"] = "38797312"
|
||||||
post_body["regions"] = [region]
|
post_body["regions"] = [region]
|
||||||
|
post_body["enabled"] = False
|
||||||
post_body["enabled"] = True
|
|
||||||
post_body["customers"] = [self.alt_tenant_id]
|
post_body["customers"] = [self.alt_tenant_id]
|
||||||
|
# empty tags list
|
||||||
|
post_body["tags"] = []
|
||||||
|
|
||||||
_, body = self.client.update_image(test_image_id, para=None,
|
_, body = self.client.update_image(test_image_id, para=None,
|
||||||
**post_body)
|
**post_body)
|
||||||
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
|
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
|
||||||
@ -233,7 +235,8 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
|
|||||||
image = body["image"]
|
image = body["image"]
|
||||||
self.assertEqual(image["regions"][0]["name"], CONF.identity.region)
|
self.assertEqual(image["regions"][0]["name"], CONF.identity.region)
|
||||||
self.assertIn(self.alt_tenant_id, image['customers'])
|
self.assertIn(self.alt_tenant_id, image['customers'])
|
||||||
self.assertTrue(image['enabled'])
|
self.assertFalse(image['enabled'])
|
||||||
|
self.assertFalse(image['tags'])
|
||||||
|
|
||||||
@decorators.idempotent_id('23e2e7e2-5b19-4c66-b35c-7c686a986627')
|
@decorators.idempotent_id('23e2e7e2-5b19-4c66-b35c-7c686a986627')
|
||||||
def test_delete_image(self):
|
def test_delete_image(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user