Treat OS version as an optional property

TOSCA Compute capability OS has version as an optional property, treat it
accordinly.

Change-Id: Id78964fe12a9fba814d74695f7e05257112f5990
Closes-Bug: #1545870
This commit is contained in:
Sahdev Zala 2016-02-15 14:59:00 -08:00
parent 8ec241a54d
commit 18763928c2
4 changed files with 54 additions and 2 deletions

View File

@ -17,7 +17,6 @@ import os
import requests
from toscaparser.utils.gettextutils import _
from toscaparser.utils.validateutils import TOSCAVersionProperty
import translator.common.utils
from translator.hot.syntax.hot_resource import HotResource
@ -236,7 +235,6 @@ class ToscaCompute(HotResource):
'distribution',
distribution)
version = properties.get('version')
version = TOSCAVersionProperty(version).get_version()
match_version = self._match_images(match_distribution, IMAGES,
'version', version)

View File

@ -0,0 +1,18 @@
heat_template_version: 2013-05-23
description: >
TOSCA simple profile that just defines a single compute instance and selects a
flavor and host Operating System for the Compute node. Note, this is just a test
template showing Compute without optional 'version' property of OS capability.
In general, you should have version to narrow down your image selection.
parameters: {}
resources:
my_server:
type: OS::Nova::Server
properties:
flavor: m1.medium
image: rhel-6.5-test-image
key_name: userkey
user_data_format: SOFTWARE_CONFIG
outputs: {}

View File

@ -0,0 +1,24 @@
tosca_definitions_version: tosca_simple_yaml_1_0
description: >
TOSCA simple profile that just defines a single compute instance and selects a
flavor and host Operating System for the Compute node. Note, this is just a test
template showing Compute without optional 'version' property of OS capability. In
general, you should have version to narrow down your image selection.
topology_template:
node_templates:
my_server:
type: Compute
capabilities:
host:
properties:
disk_size: 40 GB
num_cpus: 2
mem_size: 4 MB
os:
properties:
architecture: x86_64
type: Linux
distribution: RHEL

View File

@ -544,3 +544,15 @@ class ToscaHotTranslationTest(TestCase):
params)
self.assertEqual({}, diff, '<difference> : ' +
json.dumps(diff, indent=4, separators=(', ', ': ')))
def test_hot_translate_without_tosca_os_version(self):
tosca_file = '../tests/data/' \
'test_single_server_without_optional_version_prop.yaml'
hot_file = '../tests/data/hot_output/' \
'hot_single_server_without_tosca_os_version.yaml'
params = {}
diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
hot_file,
params)
self.assertEqual({}, diff, '<difference> : ' +
json.dumps(diff, indent=4, separators=(', ', ': ')))