Merge "Fix 'Placement' policies not translated"
This commit is contained in:
commit
23c9766205
@ -18,7 +18,7 @@ TARGET_CLASS_NAME = 'ToscaPolicies'
|
|||||||
|
|
||||||
|
|
||||||
class ToscaPolicies(HotResource):
|
class ToscaPolicies(HotResource):
|
||||||
'''Translate TOSCA policy type tosca.poicies.Placement.'''
|
'''Translate TOSCA policy type tosca.policies.Placement.'''
|
||||||
|
|
||||||
toscatype = 'tosca.policies.Placement'
|
toscatype = 'tosca.policies.Placement'
|
||||||
|
|
||||||
@ -29,8 +29,13 @@ class ToscaPolicies(HotResource):
|
|||||||
self.policy = policy
|
self.policy = policy
|
||||||
|
|
||||||
def handle_properties(self, resources):
|
def handle_properties(self, resources):
|
||||||
|
group_policy = "%(soft-prefix)s%(policy)s" % {
|
||||||
|
"soft-prefix": "soft-" if not self.get_tosca_props().get(
|
||||||
|
"strict", True) else "",
|
||||||
|
"policy": self.get_tosca_props().get("policy", "affinity"),
|
||||||
|
}
|
||||||
self.properties["name"] = self.name
|
self.properties["name"] = self.name
|
||||||
self.properties["policies"] = ["affinity"]
|
self.properties["policies"] = [group_policy]
|
||||||
for resource in resources:
|
for resource in resources:
|
||||||
if resource.name in self.policy.targets:
|
if resource.name in self.policy.targets:
|
||||||
resource.properties["scheduler_hints"] = {
|
resource.properties["scheduler_hints"] = {
|
||||||
|
@ -273,6 +273,9 @@ class TranslateNodeTemplates(object):
|
|||||||
if policy.is_derived_from('tosca.policies.Monitoring'):
|
if policy.is_derived_from('tosca.policies.Monitoring'):
|
||||||
TOSCA_TO_HOT_TYPE[policy_type.type] = \
|
TOSCA_TO_HOT_TYPE[policy_type.type] = \
|
||||||
TOSCA_TO_HOT_TYPE['tosca.policies.Monitoring']
|
TOSCA_TO_HOT_TYPE['tosca.policies.Monitoring']
|
||||||
|
if policy.is_derived_from('tosca.policies.Placement'):
|
||||||
|
TOSCA_TO_HOT_TYPE[policy_type.type] = \
|
||||||
|
TOSCA_TO_HOT_TYPE['tosca.policies.Placement']
|
||||||
if not policy.is_derived_from('tosca.policies.Monitoring') and \
|
if not policy.is_derived_from('tosca.policies.Monitoring') and \
|
||||||
not policy.is_derived_from('tosca.policies.Scaling') and \
|
not policy.is_derived_from('tosca.policies.Scaling') and \
|
||||||
policy_type.type not in TOSCA_TO_HOT_TYPE:
|
policy_type.type not in TOSCA_TO_HOT_TYPE:
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
heat_template_version: 2013-05-23
|
||||||
|
|
||||||
|
description: >
|
||||||
|
Template for deploying the nodes based on anti-affinity
|
||||||
|
placement policy.
|
||||||
|
|
||||||
|
parameters: {}
|
||||||
|
|
||||||
|
resources:
|
||||||
|
my_server:
|
||||||
|
type: OS::Nova::Server
|
||||||
|
properties:
|
||||||
|
flavor: m1.medium
|
||||||
|
image: rhel-6.5-test-image
|
||||||
|
scheduler_hints:
|
||||||
|
group:
|
||||||
|
get_resource: my_compute_placement_policy
|
||||||
|
user_data_format: SOFTWARE_CONFIG
|
||||||
|
my_compute_placement_policy:
|
||||||
|
type: OS::Nova::ServerGroup
|
||||||
|
properties:
|
||||||
|
name: my_compute_placement_policy
|
||||||
|
policies:
|
||||||
|
- anti-affinity
|
||||||
|
|
||||||
|
outputs: {}
|
@ -0,0 +1,26 @@
|
|||||||
|
heat_template_version: 2013-05-23
|
||||||
|
|
||||||
|
description: >
|
||||||
|
Template for deploying the nodes based on soft-affinity
|
||||||
|
placement policy.
|
||||||
|
|
||||||
|
parameters: {}
|
||||||
|
|
||||||
|
resources:
|
||||||
|
my_server:
|
||||||
|
type: OS::Nova::Server
|
||||||
|
properties:
|
||||||
|
flavor: m1.medium
|
||||||
|
image: rhel-6.5-test-image
|
||||||
|
scheduler_hints:
|
||||||
|
group:
|
||||||
|
get_resource: my_compute_placement_policy
|
||||||
|
user_data_format: SOFTWARE_CONFIG
|
||||||
|
my_compute_placement_policy:
|
||||||
|
type: OS::Nova::ServerGroup
|
||||||
|
properties:
|
||||||
|
name: my_compute_placement_policy
|
||||||
|
policies:
|
||||||
|
- soft-affinity
|
||||||
|
|
||||||
|
outputs: {}
|
@ -76,7 +76,21 @@ data_types:
|
|||||||
|
|
||||||
policy_types:
|
policy_types:
|
||||||
tosca.policies.tacker.Placement:
|
tosca.policies.tacker.Placement:
|
||||||
derived_from: tosca.policies.Root
|
derived_from: tosca.policies.Placement
|
||||||
|
description: Defines placement policy for VNF's.
|
||||||
|
properties:
|
||||||
|
policy:
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
default: affinity
|
||||||
|
description: Placement policy for target VDU's.
|
||||||
|
strict:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
description: >
|
||||||
|
If the policy is not strict, it is allowed to continue even if the
|
||||||
|
nova-scheduler fails to assign hosts under the policy.
|
||||||
|
|
||||||
tosca.policies.tacker.Failure:
|
tosca.policies.tacker.Failure:
|
||||||
derived_from: tosca.policies.Root
|
derived_from: tosca.policies.Root
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
|
||||||
|
|
||||||
|
description: >
|
||||||
|
Template for deploying the nodes based on given policies.
|
||||||
|
|
||||||
|
imports:
|
||||||
|
- tacker_defs.yaml
|
||||||
|
- tacker_nfv_defs.yaml
|
||||||
|
topology_template:
|
||||||
|
node_templates:
|
||||||
|
my_server:
|
||||||
|
type: tosca.nodes.Compute
|
||||||
|
capabilities:
|
||||||
|
# Host container properties
|
||||||
|
host:
|
||||||
|
properties:
|
||||||
|
num_cpus: 2
|
||||||
|
disk_size: 10 GB
|
||||||
|
mem_size: 512 MB
|
||||||
|
# Guest Operating System properties
|
||||||
|
os:
|
||||||
|
properties:
|
||||||
|
# host Operating System image properties
|
||||||
|
architecture: x86_64
|
||||||
|
type: Linux
|
||||||
|
distribution: RHEL
|
||||||
|
version: 6.5
|
||||||
|
policies:
|
||||||
|
- my_compute_placement_policy:
|
||||||
|
type: tosca.policies.tacker.Placement
|
||||||
|
properties:
|
||||||
|
policy: affinity
|
||||||
|
strict: true
|
||||||
|
description: Apply my placement policy to my application's servers
|
||||||
|
targets: [ my_server ]
|
@ -0,0 +1,36 @@
|
|||||||
|
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
|
||||||
|
|
||||||
|
description: >
|
||||||
|
Template for deploying the nodes based on anti-affinity placement policy.
|
||||||
|
|
||||||
|
imports:
|
||||||
|
- tacker_defs.yaml
|
||||||
|
- tacker_nfv_defs.yaml
|
||||||
|
|
||||||
|
topology_template:
|
||||||
|
node_templates:
|
||||||
|
my_server:
|
||||||
|
type: tosca.nodes.Compute
|
||||||
|
capabilities:
|
||||||
|
# Host container properties
|
||||||
|
host:
|
||||||
|
properties:
|
||||||
|
num_cpus: 2
|
||||||
|
disk_size: 10 GB
|
||||||
|
mem_size: 512 MB
|
||||||
|
# Guest Operating System properties
|
||||||
|
os:
|
||||||
|
properties:
|
||||||
|
# host Operating System image properties
|
||||||
|
architecture: x86_64
|
||||||
|
type: Linux
|
||||||
|
distribution: RHEL
|
||||||
|
version: 6.5
|
||||||
|
policies:
|
||||||
|
- my_compute_placement_policy:
|
||||||
|
type: tosca.policies.tacker.Placement
|
||||||
|
properties:
|
||||||
|
policy: anti-affinity
|
||||||
|
strict: true
|
||||||
|
description: Apply my placement policy to my application’s servers
|
||||||
|
targets: [ my_server ]
|
@ -0,0 +1,35 @@
|
|||||||
|
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
|
||||||
|
|
||||||
|
description: >
|
||||||
|
Template for deploying the nodes based on soft-affinity placement policy.
|
||||||
|
|
||||||
|
imports:
|
||||||
|
- tacker_defs.yaml
|
||||||
|
- tacker_nfv_defs.yaml
|
||||||
|
topology_template:
|
||||||
|
node_templates:
|
||||||
|
my_server:
|
||||||
|
type: tosca.nodes.Compute
|
||||||
|
capabilities:
|
||||||
|
# Host container properties
|
||||||
|
host:
|
||||||
|
properties:
|
||||||
|
num_cpus: 2
|
||||||
|
disk_size: 10 GB
|
||||||
|
mem_size: 512 MB
|
||||||
|
# Guest Operating System properties
|
||||||
|
os:
|
||||||
|
properties:
|
||||||
|
# host Operating System image properties
|
||||||
|
architecture: x86_64
|
||||||
|
type: Linux
|
||||||
|
distribution: RHEL
|
||||||
|
version: 6.5
|
||||||
|
policies:
|
||||||
|
- my_compute_placement_policy:
|
||||||
|
type: tosca.policies.tacker.Placement
|
||||||
|
properties:
|
||||||
|
policy: affinity
|
||||||
|
strict: false
|
||||||
|
description: Apply my placement policy to my application's servers
|
||||||
|
targets: [ my_server ]
|
@ -486,12 +486,35 @@ class ToscaHotTranslationTest(TestCase):
|
|||||||
params = {}
|
params = {}
|
||||||
self._test_successful_translation(tosca_file, hot_file, params)
|
self._test_successful_translation(tosca_file, hot_file, params)
|
||||||
|
|
||||||
def test_hot_translate_policy(self):
|
def test_hot_translate_placement_policy_default_affinity(self):
|
||||||
tosca_file = '../tests/data/policies/tosca_policies.yaml'
|
tosca_file = '../tests/data/policies/tosca_policies.yaml'
|
||||||
hot_file = '../tests/data/hot_output/policies/hot_policies.yaml'
|
hot_file = '../tests/data/hot_output/policies/hot_policies.yaml'
|
||||||
params = {}
|
params = {}
|
||||||
self._test_successful_translation(tosca_file, hot_file, params)
|
self._test_successful_translation(tosca_file, hot_file, params)
|
||||||
|
|
||||||
|
def test_hot_translate_placement_policy_affinity(self):
|
||||||
|
tosca_file = ('../tests/data/nfv/'
|
||||||
|
'tosca_placement_policy_affinity.yaml')
|
||||||
|
hot_file = '../tests/data/hot_output/policies/hot_policies.yaml'
|
||||||
|
params = {}
|
||||||
|
self._test_successful_translation(tosca_file, hot_file, params)
|
||||||
|
|
||||||
|
def test_hot_translate_placement_policy_anti_affinity(self):
|
||||||
|
tosca_file = ('../tests/data/nfv/'
|
||||||
|
'tosca_placement_policy_anti_affinity.yaml')
|
||||||
|
hot_file = ('../tests/data/hot_output/nfv/'
|
||||||
|
'hot_policy_anti_affinity.yaml')
|
||||||
|
params = {}
|
||||||
|
self._test_successful_translation(tosca_file, hot_file, params)
|
||||||
|
|
||||||
|
def test_hot_translate_placement_policy_soft_affinity(self):
|
||||||
|
tosca_file = ('../tests/data/nfv/'
|
||||||
|
'tosca_placement_policy_soft_affinity.yaml')
|
||||||
|
hot_file = ('../tests/data/hot_output/nfv/'
|
||||||
|
'hot_policy_soft_affinity.yaml')
|
||||||
|
params = {}
|
||||||
|
self._test_successful_translation(tosca_file, hot_file, params)
|
||||||
|
|
||||||
def test_hot_script_types(self):
|
def test_hot_script_types(self):
|
||||||
tosca_file = '../tests/data/interfaces/test_tosca_script_types.yaml'
|
tosca_file = '../tests/data/interfaces/test_tosca_script_types.yaml'
|
||||||
hot_file = '../tests/data/hot_output/hot_script_types.yaml'
|
hot_file = '../tests/data/hot_output/hot_script_types.yaml'
|
||||||
|
Loading…
Reference in New Issue
Block a user