Support shares in sahara cluster templates

Since 0.10.0 python-saharaclient has ability to specify
shares parameter when creating cluster templates.
This patch adds support for this feature to
OS::Sahara::ClusterTemplate resource in Heat.

Change-Id: I44533f79cc8e95e6c41edf08f54f86370d6fd5e2
This commit is contained in:
Tetiana Lashchova 2015-09-19 21:19:20 +03:00
parent 0f33d2d94f
commit 4d8de287a4
2 changed files with 52 additions and 4 deletions

View File

@ -358,11 +358,13 @@ class SaharaClusterTemplate(resource.Resource):
PROPERTIES = (
NAME, PLUGIN_NAME, HADOOP_VERSION, DESCRIPTION,
ANTI_AFFINITY, MANAGEMENT_NETWORK,
CLUSTER_CONFIGS, NODE_GROUPS, IMAGE_ID, USE_AUTOCONFIG
CLUSTER_CONFIGS, NODE_GROUPS, IMAGE_ID, USE_AUTOCONFIG,
SHARES
) = (
'name', 'plugin_name', 'hadoop_version', 'description',
'anti_affinity', 'neutron_management_network',
'cluster_configs', 'node_groups', 'default_image_id', 'use_autoconfig'
'cluster_configs', 'node_groups', 'default_image_id', 'use_autoconfig',
'shares'
)
_NODE_GROUP_KEYS = (
@ -371,6 +373,12 @@ class SaharaClusterTemplate(resource.Resource):
'name', 'count', 'node_group_template_id',
)
_SHARE_KEYS = (
SHARE_ID, PATH, ACCESS_LEVEL
) = (
'id', 'path', 'access_level'
)
properties_schema = {
NAME: properties.Schema(
properties.Schema.STRING,
@ -463,6 +471,36 @@ class SaharaClusterTemplate(resource.Resource):
properties.Schema.BOOLEAN,
_("Configure most important configs automatically."),
support_status=support.SupportStatus(version='5.0.0')
),
SHARES: properties.Schema(
properties.Schema.LIST,
_("List of manila shares to be mounted."),
schema=properties.Schema(
properties.Schema.MAP,
schema={
SHARE_ID: properties.Schema(
properties.Schema.STRING,
_("Id of the manila share."),
required=True
),
PATH: properties.Schema(
properties.Schema.STRING,
_("Local path on each cluster node on which to mount "
"the share. Defaults to '/mnt/{share_id}'.")
),
ACCESS_LEVEL: properties.Schema(
properties.Schema.STRING,
_("Governs permissions set in manila for the cluster "
"ips."),
constraints=[
constraints.AllowedValues(['rw', 'ro']),
],
default='rw'
)
}
),
support_status=support.SupportStatus(version='6.0.0'),
update_allowed=True
)
}
@ -490,6 +528,7 @@ class SaharaClusterTemplate(resource.Resource):
'net_id': self.properties[self.MANAGEMENT_NETWORK],
'default_image_id': self.properties[self.IMAGE_ID],
'use_autoconfig': self.properties[self.USE_AUTOCONFIG],
'shares': self.properties[self.SHARES]
}
if props['net_id']:
if self.is_using_neutron():

View File

@ -59,6 +59,9 @@ resources:
plugin_name: vanilla
hadoop_version: 2.3.0
neutron_management_network: some_network
shares:
- id: e45eaabf-9300-42e2-b6eb-9ebc92081f46
access_level: ro
"""
cluster_template_without_name = """
@ -334,7 +337,10 @@ class SaharaClusterTemplateTest(common.HeatTestCase):
'anti_affinity': None,
'node_groups': None,
'cluster_configs': None,
'use_autoconfig': None
'use_autoconfig': None,
'shares': [{'id': 'e45eaabf-9300-42e2-b6eb-9ebc92081f46',
'access_level': 'ro',
'path': None}]
}
self.ct_mgr.create.assert_called_once_with(**args)
@ -382,7 +388,10 @@ class SaharaClusterTemplateTest(common.HeatTestCase):
'anti_affinity': None,
'node_groups': None,
'cluster_configs': None,
'use_autoconfig': None
'use_autoconfig': None,
'shares': [{'id': 'e45eaabf-9300-42e2-b6eb-9ebc92081f46',
'access_level': 'ro',
'path': None}]
}
self.ct_mgr.update.assert_called_once_with('some_ct_id', **args)
self.assertEqual((ct.UPDATE, ct.COMPLETE), ct.state)