Merge "Update code base to be hacking compatible"
This commit is contained in:
@@ -2,3 +2,4 @@ pbr>=0.6,!=0.7,<1.0
|
|||||||
Babel>=1.3
|
Babel>=1.3
|
||||||
PyYAML>=3.1.0
|
PyYAML>=3.1.0
|
||||||
python_dateutil>=2.4.0
|
python_dateutil>=2.4.0
|
||||||
|
six>=1.9.0
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
hacking>=0.5.6,<0.8
|
hacking>=0.10.0,<0.11
|
||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
discover
|
discover
|
||||||
fixtures>=0.3.14
|
fixtures>=0.3.14
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class MemoryUnit(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def convert_unit_size_to_num(size, unit=None):
|
def convert_unit_size_to_num(size, unit=None):
|
||||||
"""Convert given size to a number representing given unit.
|
"""Convert given size to a number representing given unit.
|
||||||
If unit is None, convert to a number representing UNIT_SIZE_DEFAULT
|
|
||||||
|
|
||||||
|
If unit is None, convert to a number representing UNIT_SIZE_DEFAULT
|
||||||
:param size: unit size e.g. 1 TB
|
:param size: unit size e.g. 1 TB
|
||||||
:param unit: unit to be converted to e.g GB
|
:param unit: unit to be converted to e.g GB
|
||||||
:return: converted number e.g. 1000 for 1 TB size and unit GB
|
:return: converted number e.g. 1000 for 1 TB size and unit GB
|
||||||
@@ -69,12 +69,12 @@ class CompareUtils(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def compare_dicts(dict1, dict2):
|
def compare_dicts(dict1, dict2):
|
||||||
'''Returns False if not equal or any input parameter is empty.
|
"""Return False if not equal, True if both are equal."""
|
||||||
Returns True if both are equal.
|
|
||||||
'''
|
|
||||||
if not dict1 or not dict2:
|
if not dict1 or not dict2:
|
||||||
return False
|
return False
|
||||||
#compare generated and expected hot templates
|
|
||||||
|
# compare generated and expected hot templates
|
||||||
both_equal = True
|
both_equal = True
|
||||||
for generated_item, expected_item in zip(dict1.items(), dict2.items()):
|
for generated_item, expected_item in zip(dict1.items(), dict2.items()):
|
||||||
if generated_item != expected_item:
|
if generated_item != expected_item:
|
||||||
@@ -94,7 +94,7 @@ class CompareUtils(object):
|
|||||||
|
|
||||||
|
|
||||||
def str_to_num(value):
|
def str_to_num(value):
|
||||||
'''Convert a string representation of a number into a numeric type.'''
|
"""Convert a string representation of a number into a numeric type."""
|
||||||
if isinstance(value, numbers.Number):
|
if isinstance(value, numbers.Number):
|
||||||
return value
|
return value
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class ToscaBlockStorageAttachment(HotResource):
|
|||||||
else:
|
else:
|
||||||
tosca_props[prop.name] = prop.value
|
tosca_props[prop.name] = prop.value
|
||||||
self.properties = tosca_props
|
self.properties = tosca_props
|
||||||
#instance_uuid and volume_id for Cinder volume attachment
|
# instance_uuid and volume_id for Cinder volume attachment
|
||||||
self.properties['instance_uuid'] = self.instace_uuid
|
self.properties['instance_uuid'] = self.instace_uuid
|
||||||
self.properties['volume_id'] = self.volume_id
|
self.properties['volume_id'] = self.volume_id
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class ToscaNetworkPort(HotResource):
|
|||||||
port_props['fixed_ips'] = [fixed_ip]
|
port_props['fixed_ips'] = [fixed_ip]
|
||||||
elif key == 'order':
|
elif key == 'order':
|
||||||
self.order = value
|
self.order = value
|
||||||
#TODO(sdmonov). Need to implement the properties below
|
# TODO(sdmonov): Need to implement the properties below
|
||||||
elif key == 'is_default':
|
elif key == 'is_default':
|
||||||
pass
|
pass
|
||||||
elif key == 'ip_range_start':
|
elif key == 'ip_range_start':
|
||||||
@@ -105,7 +105,7 @@ class ToscaNetworkPort(HotResource):
|
|||||||
if compute_resource:
|
if compute_resource:
|
||||||
port_resources = compute_resource.assoc_port_resources
|
port_resources = compute_resource.assoc_port_resources
|
||||||
self._insert_sorted_resource(port_resources, self)
|
self._insert_sorted_resource(port_resources, self)
|
||||||
#TODO(sdmonov). Using generate networks every time we add a
|
# TODO(sdmonov): Using generate networks every time we add a
|
||||||
# network is not the fastest way to do the things. We should
|
# network is not the fastest way to do the things. We should
|
||||||
# do this only once at the end.
|
# do this only once at the end.
|
||||||
networks = self._generate_networks_for_compute(port_resources)
|
networks = self._generate_networks_for_compute(port_resources)
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ class ToscaObjectStorage(HotResource):
|
|||||||
if key == "store_name":
|
if key == "store_name":
|
||||||
objectstore_props["name"] = value
|
objectstore_props["name"] = value
|
||||||
elif key == "store_size" or key == "store_maxsize":
|
elif key == "store_size" or key == "store_maxsize":
|
||||||
#currently heat is not supporting dynamically increase
|
# currently heat is not supporting dynamically increase
|
||||||
#the container quota-size.
|
# the container quota-size.
|
||||||
#if both defined in tosca template, consider store_maxsize.
|
# if both defined in tosca template, consider store_maxsize.
|
||||||
if skip_check:
|
if skip_check:
|
||||||
continue
|
continue
|
||||||
quota_size = None
|
quota_size = None
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ TOSCA_TO_HOT_INPUT_TYPES = {'string': 'string',
|
|||||||
'null': 'string'}
|
'null': 'string'}
|
||||||
|
|
||||||
|
|
||||||
class TranslateInputs():
|
class TranslateInputs(object):
|
||||||
'''Translate TOSCA Inputs to Heat Parameters.'''
|
'''Translate TOSCA Inputs to Heat Parameters.'''
|
||||||
|
|
||||||
def __init__(self, inputs, parsed_params):
|
def __init__(self, inputs, parsed_params):
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ TOSCA_TO_HOT_REQUIRES = {'container': 'server', 'host': 'server',
|
|||||||
TOSCA_TO_HOT_PROPERTIES = {'properties': 'input'}
|
TOSCA_TO_HOT_PROPERTIES = {'properties': 'input'}
|
||||||
|
|
||||||
|
|
||||||
class TranslateNodeTemplates():
|
class TranslateNodeTemplates(object):
|
||||||
'''Translate TOSCA NodeTemplates to Heat Resources.'''
|
'''Translate TOSCA NodeTemplates to Heat Resources.'''
|
||||||
|
|
||||||
def __init__(self, tosca, hot_template):
|
def __init__(self, tosca, hot_template):
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
from translator.hot.syntax.hot_output import HotOutput
|
from translator.hot.syntax.hot_output import HotOutput
|
||||||
|
|
||||||
|
|
||||||
class TranslateOutputs():
|
class TranslateOutputs(object):
|
||||||
'''Translate TOSCA Outputs to Heat Outputs.'''
|
'''Translate TOSCA Outputs to Heat Outputs.'''
|
||||||
|
|
||||||
def __init__(self, outputs, node_translator):
|
def __init__(self, outputs, node_translator):
|
||||||
|
|||||||
@@ -95,12 +95,15 @@ class ToscaNetworkTest(TestCase):
|
|||||||
'properties':
|
'properties':
|
||||||
{'cidr': {'get_param': 'network_cidr'},
|
{'cidr': {'get_param': 'network_cidr'},
|
||||||
'ip_version': 4,
|
'ip_version': 4,
|
||||||
'allocation_pools': [{'start': {'get_param':
|
'network': {'get_resource': 'my_network'},
|
||||||
'network_start_ip'},
|
'allocation_pools': [{'start':
|
||||||
'end': {'get_param':
|
{'get_param':
|
||||||
'network_end_ip'
|
'network_start_ip'},
|
||||||
}}],
|
'end':
|
||||||
'network': {'get_resource': 'my_network'}
|
{'get_param':
|
||||||
|
'network_end_ip'
|
||||||
|
}}
|
||||||
|
]
|
||||||
}}
|
}}
|
||||||
|
|
||||||
expected_resource_3 = {'type': 'OS::Neutron::Port',
|
expected_resource_3 = {'type': 'OS::Neutron::Port',
|
||||||
@@ -197,21 +200,20 @@ class ToscaNetworkTest(TestCase):
|
|||||||
|
|
||||||
expected_resource_net = {'type': 'OS::Neutron::Net',
|
expected_resource_net = {'type': 'OS::Neutron::Net',
|
||||||
'properties':
|
'properties':
|
||||||
{'name': 'net%d' % (net_num)
|
{'name': 'net%d' % (net_num)}}
|
||||||
}}
|
|
||||||
|
|
||||||
expected_resource_subnet = {'type': 'OS::Neutron::Subnet',
|
expected_resource_subnet = {'type': 'OS::Neutron::Subnet',
|
||||||
'properties':
|
'properties':
|
||||||
{'cidr': '192.168.%d.0/24' % (net_num),
|
{'cidr': '192.168.%d.0/24' % (net_num),
|
||||||
'ip_version': 4,
|
'ip_version': 4,
|
||||||
'network': {'get_resource': net_name}
|
'network': {'get_resource': net_name}}
|
||||||
}}
|
}
|
||||||
|
|
||||||
expected_resource_port = {'type': 'OS::Neutron::Port',
|
expected_resource_port = {'type': 'OS::Neutron::Port',
|
||||||
'depends_on': [net_name],
|
'depends_on': [net_name],
|
||||||
'properties':
|
'properties':
|
||||||
{'network': {'get_resource': net_name}
|
{'network': {'get_resource': net_name}}}
|
||||||
}}
|
|
||||||
self.assertIn(net_name, resources.keys())
|
self.assertIn(net_name, resources.keys())
|
||||||
self.assertIn(subnet_name, resources.keys())
|
self.assertIn(subnet_name, resources.keys())
|
||||||
self.assertIn(port_name, resources.keys())
|
self.assertIn(port_name, resources.keys())
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class ToscaObjectStoreTemplateTest(TestCase):
|
|||||||
translate = TOSCATranslator(tosca, parsed_params)
|
translate = TOSCATranslator(tosca, parsed_params)
|
||||||
hot_translated_output = translate.translate()
|
hot_translated_output = translate.translate()
|
||||||
|
|
||||||
#load expected hot yaml file
|
# load expected hot yaml file
|
||||||
hot_yaml_file = "../toscalib/tests/data/hot_output/" + \
|
hot_yaml_file = "../toscalib/tests/data/hot_output/" + \
|
||||||
"hot_single_object_store.yaml"
|
"hot_single_object_store.yaml"
|
||||||
hot_tpl = os.path.join(
|
hot_tpl = os.path.join(
|
||||||
@@ -40,7 +40,7 @@ class ToscaObjectStoreTemplateTest(TestCase):
|
|||||||
with open(hot_tpl) as f:
|
with open(hot_tpl) as f:
|
||||||
hot_expected_output = f.read()
|
hot_expected_output = f.read()
|
||||||
|
|
||||||
#compare generated and expected hot templates
|
# compare generated and expected hot templates
|
||||||
status = CompareUtils.compare_hot_yamls(hot_translated_output,
|
status = CompareUtils.compare_hot_yamls(hot_translated_output,
|
||||||
hot_expected_output)
|
hot_expected_output)
|
||||||
self.assertEqual(status, True)
|
self.assertEqual(status, True)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class ToscaTemplateOutputOrderTest(TestCase):
|
|||||||
translate = TOSCATranslator(tosca, parsed_params)
|
translate = TOSCATranslator(tosca, parsed_params)
|
||||||
hot_translated_output = translate.translate()
|
hot_translated_output = translate.translate()
|
||||||
|
|
||||||
#load expected hot yaml file
|
# load expected hot yaml file
|
||||||
hot_yaml_file = "data/hot_output/hot_single_server.yaml"
|
hot_yaml_file = "data/hot_output/hot_single_server.yaml"
|
||||||
hot_tpl = os.path.join(
|
hot_tpl = os.path.join(
|
||||||
os.path.dirname(os.path.abspath(__file__)),
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
@@ -38,7 +38,7 @@ class ToscaTemplateOutputOrderTest(TestCase):
|
|||||||
with open(hot_tpl) as f:
|
with open(hot_tpl) as f:
|
||||||
hot_expected_output = f.read()
|
hot_expected_output = f.read()
|
||||||
|
|
||||||
#compare generated and expected hot templates
|
# compare generated and expected hot templates
|
||||||
status = CompareUtils.compare_hot_yamls(hot_translated_output,
|
status = CompareUtils.compare_hot_yamls(hot_translated_output,
|
||||||
hot_expected_output)
|
hot_expected_output)
|
||||||
self.assertEqual(status, True)
|
self.assertEqual(status, True)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class CommonUtilsTest(TestCase):
|
|||||||
str_to_convert = '55063.000000'
|
str_to_convert = '55063.000000'
|
||||||
expected_output = 55063.0
|
expected_output = 55063.0
|
||||||
output = translator.common.utils.str_to_num(str_to_convert)
|
output = translator.common.utils.str_to_num(str_to_convert)
|
||||||
self.assertEquals(output, expected_output)
|
self.assertEqual(output, expected_output)
|
||||||
|
|
||||||
def test_compare_dicts_unequal(self):
|
def test_compare_dicts_unequal(self):
|
||||||
dict1 = {'allowed_values': [1, 2, 4, 8],
|
dict1 = {'allowed_values': [1, 2, 4, 8],
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
from translator.toscalib.common.exception import MissingRequiredFieldError
|
from translator.toscalib.common.exception import MissingRequiredFieldError
|
||||||
from translator.toscalib.common.exception import TypeMismatchError
|
from translator.toscalib.common.exception import TypeMismatchError
|
||||||
from translator.toscalib.common.exception import UnknownFieldError
|
from translator.toscalib.common.exception import UnknownFieldError
|
||||||
|
from translator.toscalib.elements.constraints import Constraint
|
||||||
|
from translator.toscalib.elements.constraints import Schema
|
||||||
from translator.toscalib.elements.datatype import DataType
|
from translator.toscalib.elements.datatype import DataType
|
||||||
from translator.toscalib.elements.constraints import Constraint, Schema
|
|
||||||
|
|
||||||
|
|
||||||
class DataEntity(object):
|
class DataEntity(object):
|
||||||
@@ -29,8 +30,8 @@ class DataEntity(object):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
'''Validate the value by the definition of the datatype.'''
|
'''Validate the value by the definition of the datatype.'''
|
||||||
|
|
||||||
#A datatype can not have both 'type' and 'properties' definitions.
|
# A datatype can not have both 'type' and 'properties' definitions.
|
||||||
#If the datatype has 'type' definition
|
# If the datatype has 'type' definition
|
||||||
if self.datatype.value_type:
|
if self.datatype.value_type:
|
||||||
DataEntity.validate_datatype(self.datatype.value_type, self.value,
|
DataEntity.validate_datatype(self.datatype.value_type, self.value,
|
||||||
None, self.custom_def)
|
None, self.custom_def)
|
||||||
|
|||||||
@@ -36,9 +36,7 @@ class DataType(StatefulEntityType):
|
|||||||
return self.entity_value(self.defs, 'type')
|
return self.entity_value(self.defs, 'type')
|
||||||
|
|
||||||
def get_all_properties_objects(self):
|
def get_all_properties_objects(self):
|
||||||
'''Return all properties objects defined in this type
|
'''Return all properties objects defined in type and parent type.'''
|
||||||
and its parent type.
|
|
||||||
'''
|
|
||||||
props_def = self.get_properties_def_objects()
|
props_def = self.get_properties_def_objects()
|
||||||
ptype = self.parent_type
|
ptype = self.parent_type
|
||||||
while ptype:
|
while ptype:
|
||||||
@@ -47,9 +45,7 @@ class DataType(StatefulEntityType):
|
|||||||
return props_def
|
return props_def
|
||||||
|
|
||||||
def get_all_properties(self):
|
def get_all_properties(self):
|
||||||
'''Return a dictionary of all property definition
|
'''Return a dictionary of all property definition name-object pairs.'''
|
||||||
name-object pairs.
|
|
||||||
'''
|
|
||||||
return {prop.name: prop
|
return {prop.name: prop
|
||||||
for prop in self.get_all_properties_objects()}
|
for prop in self.get_all_properties_objects()}
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ class EntityType(object):
|
|||||||
RELATIONSHIP_PREFIX = 'tosca.relationships.'
|
RELATIONSHIP_PREFIX = 'tosca.relationships.'
|
||||||
CAPABILITY_PREFIX = 'tosca.capabilities.'
|
CAPABILITY_PREFIX = 'tosca.capabilities.'
|
||||||
INTERFACE_PREFIX = 'tosca.interfaces.'
|
INTERFACE_PREFIX = 'tosca.interfaces.'
|
||||||
#currently the data types are defined only for network
|
# currently the data types are defined only for network
|
||||||
#but may have changes in the future.
|
# but may have changes in the future.
|
||||||
DATATYPE_PREFIX = 'tosca.datatypes.network.'
|
DATATYPE_PREFIX = 'tosca.datatypes.network.'
|
||||||
TOSCA = 'tosca'
|
TOSCA = 'tosca'
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ class EntityType(object):
|
|||||||
if parent and not value:
|
if parent and not value:
|
||||||
p = self.parent_type
|
p = self.parent_type
|
||||||
while value is None:
|
while value is None:
|
||||||
#check parent node
|
# check parent node
|
||||||
if not p:
|
if not p:
|
||||||
break
|
break
|
||||||
if p and p.type == 'tosca.nodes.Root':
|
if p and p.type == 'tosca.nodes.Root':
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class NodeType(StatefulEntityType):
|
|||||||
keyword = None
|
keyword = None
|
||||||
node_type = None
|
node_type = None
|
||||||
for req in requires:
|
for req in requires:
|
||||||
#get all keys in requirement
|
# get all keys in requirement
|
||||||
if 'relationship' in req:
|
if 'relationship' in req:
|
||||||
keys = req.keys()
|
keys = req.keys()
|
||||||
for k in keys:
|
for k in keys:
|
||||||
|
|||||||
@@ -124,11 +124,11 @@ class EntityTemplate(object):
|
|||||||
self._common_validate_properties(capabilitydef,
|
self._common_validate_properties(capabilitydef,
|
||||||
props[self.PROPERTIES])
|
props[self.PROPERTIES])
|
||||||
|
|
||||||
#validating capability properties values
|
# validating capability properties values
|
||||||
for prop in self.get_capability(cap).get_properties_objects():
|
for prop in self.get_capability(cap).get_properties_objects():
|
||||||
prop.validate()
|
prop.validate()
|
||||||
|
|
||||||
#TODO(srinivas_tadepalli): temporary work around to validate
|
# TODO(srinivas_tadepalli): temporary work around to validate
|
||||||
# default_instances until standardized in specification
|
# default_instances until standardized in specification
|
||||||
if cap == "scalable" and prop.name == "default_instances":
|
if cap == "scalable" and prop.name == "default_instances":
|
||||||
prop_dict = props[self.PROPERTIES]
|
prop_dict = props[self.PROPERTIES]
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
import six
|
||||||
|
|
||||||
from translator.toscalib.common.exception import UnknownInputError
|
from translator.toscalib.common.exception import UnknownInputError
|
||||||
from translator.toscalib.utils.gettextutils import _
|
from translator.toscalib.utils.gettextutils import _
|
||||||
@@ -28,11 +29,10 @@ HOST = 'HOST'
|
|||||||
HOSTED_ON = 'tosca.relationships.HostedOn'
|
HOSTED_ON = 'tosca.relationships.HostedOn'
|
||||||
|
|
||||||
|
|
||||||
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
class Function(object):
|
class Function(object):
|
||||||
"""An abstract type for representing a Tosca template function."""
|
"""An abstract type for representing a Tosca template function."""
|
||||||
|
|
||||||
__metaclass__ = abc.ABCMeta
|
|
||||||
|
|
||||||
def __init__(self, tosca_tpl, context, name, args):
|
def __init__(self, tosca_tpl, context, name, args):
|
||||||
self.tosca_tpl = tosca_tpl
|
self.tosca_tpl = tosca_tpl
|
||||||
self.context = context
|
self.context = context
|
||||||
@@ -59,8 +59,7 @@ class Function(object):
|
|||||||
|
|
||||||
|
|
||||||
class GetInput(Function):
|
class GetInput(Function):
|
||||||
"""Get a property value declared within the inputs section of the service
|
"""Get a property value declared within the input of the service template.
|
||||||
template.
|
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ import logging
|
|||||||
|
|
||||||
from translator.toscalib.common.exception import TypeMismatchError
|
from translator.toscalib.common.exception import TypeMismatchError
|
||||||
from translator.toscalib.common.exception import UnknownFieldError
|
from translator.toscalib.common.exception import UnknownFieldError
|
||||||
|
from translator.toscalib.elements.interfaces import CONFIGURE
|
||||||
from translator.toscalib.elements.interfaces import InterfacesDef
|
from translator.toscalib.elements.interfaces import InterfacesDef
|
||||||
from translator.toscalib.elements.interfaces import LIFECYCLE, CONFIGURE
|
from translator.toscalib.elements.interfaces import LIFECYCLE
|
||||||
from translator.toscalib.elements.relationshiptype import RelationshipType
|
from translator.toscalib.elements.relationshiptype import RelationshipType
|
||||||
from translator.toscalib.entity_template import EntityTemplate
|
from translator.toscalib.entity_template import EntityTemplate
|
||||||
from translator.toscalib.relationship_template import RelationshipTemplate
|
from translator.toscalib.relationship_template import RelationshipTemplate
|
||||||
@@ -75,8 +76,8 @@ class NodeTemplate(EntityTemplate):
|
|||||||
explicit_relation = {}
|
explicit_relation = {}
|
||||||
node = value.get('node')
|
node = value.get('node')
|
||||||
if node:
|
if node:
|
||||||
#TODO(spzala) implement look up once Glance meta data is available
|
# TODO(spzala) implement look up once Glance meta data is available
|
||||||
#to find a matching TOSCA node using the TOSCA types
|
# to find a matching TOSCA node using the TOSCA types
|
||||||
msg = _('Lookup by TOSCA types are not supported. '
|
msg = _('Lookup by TOSCA types are not supported. '
|
||||||
'Requirement for %s can not be full-filled.') % self.name
|
'Requirement for %s can not be full-filled.') % self.name
|
||||||
if (node in list(self.type_definition.TOSCA_DEF.keys())
|
if (node in list(self.type_definition.TOSCA_DEF.keys())
|
||||||
@@ -86,14 +87,14 @@ class NodeTemplate(EntityTemplate):
|
|||||||
relationship = value.get('relationship')
|
relationship = value.get('relationship')
|
||||||
if relationship:
|
if relationship:
|
||||||
found_relationship_tpl = False
|
found_relationship_tpl = False
|
||||||
#apply available relationship templates if found
|
# apply available relationship templates if found
|
||||||
for tpl in self.available_rel_tpls:
|
for tpl in self.available_rel_tpls:
|
||||||
if tpl.name == relationship:
|
if tpl.name == relationship:
|
||||||
rtype = RelationshipType(tpl.type)
|
rtype = RelationshipType(tpl.type)
|
||||||
explicit_relation[rtype] = related_tpl
|
explicit_relation[rtype] = related_tpl
|
||||||
self.relationship_tpl.append(tpl)
|
self.relationship_tpl.append(tpl)
|
||||||
found_relationship_tpl = True
|
found_relationship_tpl = True
|
||||||
#create relationship template object.
|
# create relationship template object.
|
||||||
if not found_relationship_tpl:
|
if not found_relationship_tpl:
|
||||||
if isinstance(relationship, dict):
|
if isinstance(relationship, dict):
|
||||||
relationship = relationship.get('type')
|
relationship = relationship.get('type')
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|||||||
@@ -142,13 +142,13 @@ class PropertyTest(TestCase):
|
|||||||
|
|
||||||
def test_timestamp(self):
|
def test_timestamp(self):
|
||||||
test_property_schema = {'type': 'timestamp'}
|
test_property_schema = {'type': 'timestamp'}
|
||||||
#canonical timestamp
|
# canonical timestamp
|
||||||
propertyInstance = Property('test_property', '2015-04-01T02:59:43.1Z',
|
propertyInstance = Property('test_property', '2015-04-01T02:59:43.1Z',
|
||||||
test_property_schema)
|
test_property_schema)
|
||||||
self.assertIsNone(propertyInstance.validate())
|
self.assertIsNone(propertyInstance.validate())
|
||||||
self.assertEqual("2015-04-01T02:59:43.1Z", propertyInstance.value)
|
self.assertEqual("2015-04-01T02:59:43.1Z", propertyInstance.value)
|
||||||
|
|
||||||
#iso8601 timestamp
|
# iso8601 timestamp
|
||||||
propertyInstance = Property('test_property',
|
propertyInstance = Property('test_property',
|
||||||
'2015-04-01t21:59:43.10-05:00',
|
'2015-04-01t21:59:43.10-05:00',
|
||||||
test_property_schema)
|
test_property_schema)
|
||||||
@@ -156,20 +156,20 @@ class PropertyTest(TestCase):
|
|||||||
self.assertEqual("2015-04-01t21:59:43.10-05:00",
|
self.assertEqual("2015-04-01t21:59:43.10-05:00",
|
||||||
propertyInstance.value)
|
propertyInstance.value)
|
||||||
|
|
||||||
#space separated timestamp
|
# space separated timestamp
|
||||||
propertyInstance = Property('test_property',
|
propertyInstance = Property('test_property',
|
||||||
'2015-04-01 21:59:43.10 -5',
|
'2015-04-01 21:59:43.10 -5',
|
||||||
test_property_schema)
|
test_property_schema)
|
||||||
self.assertIsNone(propertyInstance.validate())
|
self.assertIsNone(propertyInstance.validate())
|
||||||
self.assertEqual("2015-04-01 21:59:43.10 -5", propertyInstance.value)
|
self.assertEqual("2015-04-01 21:59:43.10 -5", propertyInstance.value)
|
||||||
|
|
||||||
#no time zone timestamp
|
# no time zone timestamp
|
||||||
propertyInstance = Property('test_property', '2015-04-01 21:59:43.10',
|
propertyInstance = Property('test_property', '2015-04-01 21:59:43.10',
|
||||||
test_property_schema)
|
test_property_schema)
|
||||||
self.assertIsNone(propertyInstance.validate())
|
self.assertIsNone(propertyInstance.validate())
|
||||||
self.assertEqual("2015-04-01 21:59:43.10", propertyInstance.value)
|
self.assertEqual("2015-04-01 21:59:43.10", propertyInstance.value)
|
||||||
|
|
||||||
#date (00:00:00Z)
|
# date (00:00:00Z)
|
||||||
propertyInstance = Property('test_property', '2015-04-01',
|
propertyInstance = Property('test_property', '2015-04-01',
|
||||||
test_property_schema)
|
test_property_schema)
|
||||||
self.assertIsNone(propertyInstance.validate())
|
self.assertIsNone(propertyInstance.validate())
|
||||||
@@ -177,7 +177,7 @@ class PropertyTest(TestCase):
|
|||||||
|
|
||||||
def test_timestamp_invalid(self):
|
def test_timestamp_invalid(self):
|
||||||
test_property_schema = {'type': 'timestamp'}
|
test_property_schema = {'type': 'timestamp'}
|
||||||
#invalid timestamp - day out of range
|
# invalid timestamp - day out of range
|
||||||
propertyInstance = Property('test_property', '2015-04-115T02:59:43.1Z',
|
propertyInstance = Property('test_property', '2015-04-115T02:59:43.1Z',
|
||||||
test_property_schema)
|
test_property_schema)
|
||||||
error = self.assertRaises(ValueError, propertyInstance.validate)
|
error = self.assertRaises(ValueError, propertyInstance.validate)
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ class ToscaTemplateTest(TestCase):
|
|||||||
'Unexpected interface: {0}'.format(interface.name))
|
'Unexpected interface: {0}'.format(interface.name))
|
||||||
|
|
||||||
def test_normative_type_by_short_name(self):
|
def test_normative_type_by_short_name(self):
|
||||||
#test template with a short name Compute
|
# test template with a short name Compute
|
||||||
template = os.path.join(
|
template = os.path.join(
|
||||||
os.path.dirname(os.path.abspath(__file__)),
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
"data/test_tosca_normative_type_by_shortname.yaml")
|
"data/test_tosca_normative_type_by_shortname.yaml")
|
||||||
@@ -258,8 +258,8 @@ class ToscaTemplateTest(TestCase):
|
|||||||
node in node_tpl.relationships.items()])
|
node in node_tpl.relationships.items()])
|
||||||
|
|
||||||
def test_template_requirements_not_implemented(self):
|
def test_template_requirements_not_implemented(self):
|
||||||
#TODO(spzala) replace this test with new one once TOSCA types look up
|
# TODO(spzala): replace this test with new one once TOSCA types look up
|
||||||
#support is implemented.
|
# support is implemented.
|
||||||
"""Requirements that yet need to be implemented
|
"""Requirements that yet need to be implemented
|
||||||
|
|
||||||
The following requirement formats are not yet implemented,
|
The following requirement formats are not yet implemented,
|
||||||
@@ -333,7 +333,7 @@ class ToscaTemplateTest(TestCase):
|
|||||||
properties:
|
properties:
|
||||||
test: 1
|
test: 1
|
||||||
'''
|
'''
|
||||||
#custom definition with capability type definition
|
# custom definition with capability type definition
|
||||||
custom_def = '''
|
custom_def = '''
|
||||||
tosca.nodes.WebApplication.TestApp:
|
tosca.nodes.WebApplication.TestApp:
|
||||||
derived_from: tosca.nodes.WebApplication
|
derived_from: tosca.nodes.WebApplication
|
||||||
@@ -358,7 +358,7 @@ class ToscaTemplateTest(TestCase):
|
|||||||
expected_capabilities,
|
expected_capabilities,
|
||||||
sorted(tpl.get_capabilities().keys()))
|
sorted(tpl.get_capabilities().keys()))
|
||||||
|
|
||||||
#custom definition without capability type definition
|
# custom definition without capability type definition
|
||||||
custom_def = '''
|
custom_def = '''
|
||||||
tosca.nodes.WebApplication.TestApp:
|
tosca.nodes.WebApplication.TestApp:
|
||||||
derived_from: tosca.nodes.WebApplication
|
derived_from: tosca.nodes.WebApplication
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import six
|
|||||||
|
|
||||||
from translator.toscalib.common import exception
|
from translator.toscalib.common import exception
|
||||||
from translator.toscalib.nodetemplate import NodeTemplate
|
from translator.toscalib.nodetemplate import NodeTemplate
|
||||||
from translator.toscalib.parameters import Input, Output
|
from translator.toscalib.parameters import Input
|
||||||
|
from translator.toscalib.parameters import Output
|
||||||
from translator.toscalib.relationship_template import RelationshipTemplate
|
from translator.toscalib.relationship_template import RelationshipTemplate
|
||||||
from translator.toscalib.tests.base import TestCase
|
from translator.toscalib.tests.base import TestCase
|
||||||
from translator.toscalib.tosca_template import ToscaTemplate
|
from translator.toscalib.tosca_template import ToscaTemplate
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ from translator.toscalib.common.exception import MissingRequiredFieldError
|
|||||||
from translator.toscalib.common.exception import UnknownFieldError
|
from translator.toscalib.common.exception import UnknownFieldError
|
||||||
from translator.toscalib import functions
|
from translator.toscalib import functions
|
||||||
from translator.toscalib.nodetemplate import NodeTemplate
|
from translator.toscalib.nodetemplate import NodeTemplate
|
||||||
from translator.toscalib.parameters import Input, Output
|
from translator.toscalib.parameters import Input
|
||||||
|
from translator.toscalib.parameters import Output
|
||||||
from translator.toscalib.relationship_template import RelationshipTemplate
|
from translator.toscalib.relationship_template import RelationshipTemplate
|
||||||
from translator.toscalib.tpl_relationship_graph import ToscaGraph
|
from translator.toscalib.tpl_relationship_graph import ToscaGraph
|
||||||
|
|
||||||
import translator.toscalib.utils.yamlparser
|
import translator.toscalib.utils.yamlparser
|
||||||
|
|
||||||
|
|
||||||
#TOSCA template key names
|
# TOSCA template key names
|
||||||
SECTIONS = (DEFINITION_VERSION, DEFAULT_NAMESPACE, TEMPLATE_NAME,
|
SECTIONS = (DEFINITION_VERSION, DEFAULT_NAMESPACE, TEMPLATE_NAME,
|
||||||
TEMPLATE_AUTHOR, TEMPLATE_VERSION, DESCRIPTION, IMPORTS,
|
TEMPLATE_AUTHOR, TEMPLATE_VERSION, DESCRIPTION, IMPORTS,
|
||||||
DSL_DEFINITIONS, INPUTS, NODE_TEMPLATES, RELATIONSHIP_TEMPLATES,
|
DSL_DEFINITIONS, INPUTS, NODE_TEMPLATES, RELATIONSHIP_TEMPLATES,
|
||||||
|
|||||||
Reference in New Issue
Block a user