Fix bad image yaml sent to heat
Stein heat accepts different paramaters for glance image v2 template. This refactors the image building yaml in ranger to fix malformed request sent to heat. Change-Id: I5929a57827afdbe9787b04885a70f10bab99a9bf
This commit is contained in:
@@ -18,7 +18,7 @@ def create_full_yaml(title, resources, description, outputs):
|
||||
|
||||
|
||||
def _properties(alldata, region):
|
||||
public = True if alldata['visibility'] == "public" else False
|
||||
public = alldata['visibility']
|
||||
protected = {0: False, 1: True}[alldata['protected']]
|
||||
tenants = [tenant['customer_id'] for tenant in alldata['customers']]
|
||||
properties = dict(
|
||||
@@ -30,24 +30,23 @@ def _properties(alldata, region):
|
||||
id=str(uuid.UUID(alldata['id'])),
|
||||
tags=alldata['tags'],
|
||||
protected=protected,
|
||||
copy_from=alldata["url"],
|
||||
location=alldata["url"],
|
||||
owner=alldata["owner"],
|
||||
is_public=public,
|
||||
tenants=str(tenants)
|
||||
visibility=alldata['visibility']
|
||||
)
|
||||
|
||||
if region['action'] != 'create':
|
||||
properties['deactivate'] = {1: False, 0: True}[alldata['enabled']]
|
||||
|
||||
if alldata['properties']:
|
||||
properties['extra_properties'] = alldata['properties']
|
||||
# if alldata['properties']:
|
||||
# properties['extra_properties'] = alldata['properties']
|
||||
|
||||
return properties
|
||||
|
||||
|
||||
def _glanceimage(alldata, region):
|
||||
return dict(
|
||||
type="OS::Glance::Image2",
|
||||
type="OS::Glance::WebImage",
|
||||
properties=_properties(alldata, region)
|
||||
)
|
||||
|
||||
@@ -61,6 +60,6 @@ def yamlbuilder(alldata, region):
|
||||
description = {'description': 'yaml file for region - %s' % region['name']}
|
||||
resources['resources'] = {"glance_image": _glanceimage(alldata, region)}
|
||||
outputs['outputs'] = {
|
||||
'%s_id' % image_type: {"value": {"get_resource": "%s" % image_type}}}
|
||||
'%s_id' % image_type: {"value": "{get_resource: %s}" % image_type}}
|
||||
full_yaml = create_full_yaml(title, resources, description, outputs)
|
||||
return full_yaml
|
||||
|
||||
@@ -22,11 +22,14 @@ json_input = {
|
||||
'image_internal_id': 1
|
||||
},
|
||||
'protected': 1,
|
||||
'customers': [{
|
||||
'customer_id': 'abcd-efgh-ijkl-4567', 'image_id': 1
|
||||
}, {
|
||||
'customer_id': 'opqr-stuv-wxyz-8901', 'image_id': 1
|
||||
}],
|
||||
'customers': [
|
||||
{
|
||||
'customer_id': 'abcd-efgh-ijkl-4567', 'image_id': 1
|
||||
},
|
||||
{
|
||||
'customer_id': 'opqr-stuv-wxyz-8901', 'image_id': 1
|
||||
}],
|
||||
|
||||
'container_format': 'bare', 'min_disk': 2,
|
||||
'id': '12345678901234567890123456789012'
|
||||
}
|
||||
@@ -40,20 +43,15 @@ yaml_output = {
|
||||
'glance_image': {
|
||||
'properties': {
|
||||
'container_format': 'bare', 'disk_format': 'raw',
|
||||
'is_public': True,
|
||||
'copy_from': 'https://mirrors.it.att.com/images/image-name',
|
||||
'visibility': 'public',
|
||||
'location': 'https://mirrors.it.att.com/images/image-name',
|
||||
'deactivate': False,
|
||||
'min_disk': 2, 'min_ram': 0, 'name': 'Ubuntu', 'owner': 'unknown',
|
||||
'protected': True,
|
||||
'id': '12345678-9012-3456-7890-123456789012',
|
||||
'tenants': ['abcd-efgh-ijkl-4567', 'opqr-stuv-wxyz-8901'],
|
||||
'tags': ['abcd-efgh-ijkl-4567', 'mnop-qrst-uvwx-0987'],
|
||||
'extra_properties': {
|
||||
'key_name': 'Key1', 'key_value': 'Key1.value',
|
||||
'image_internal_id': 1
|
||||
}
|
||||
'tags': ['abcd-efgh-ijkl-4567', 'mnop-qrst-uvwx-0987']
|
||||
},
|
||||
'type': 'OS::Glance::Image2'
|
||||
'type': 'OS::Glance::WebImage'
|
||||
}
|
||||
},
|
||||
'heat_template_version': '2015-1-1',
|
||||
|
||||
Reference in New Issue
Block a user