summaryrefslogtreecommitdiff
path: root/saharaclient
diff options
context:
space:
mode:
authorMichael Ionkin <mionkin@mirantis.com>2016-07-14 13:14:03 +0300
committerMichael Ionkin <mionkin@mirantis.com>2016-08-02 19:19:20 +0300
commitd41d9ad7b52573d0394c94dbe80ff3d4ddd4e12a (patch)
treeded6904655da153c869d63a8f412e91d0fd02c53 /saharaclient
parentbeff775d5d8ff0392abe9939acb65500b675229f (diff)
downloadpython-saharaclient-d41d9ad7b52573d0394c94dbe80ff3d4ddd4e12a.tar.gz
Designate integration
added 'domain_name' parameter to Cluster Template in API and CLI client. NOTE: in spec we proposed to use two domains: one for internal resolution and another for external. But we decided to use only one domain for both sides so an instance will have one hostname in the domain and two appropriate A records because it's more convenient. partial-bp: designate-integration Change-Id: Ic636d1d9d27f9f96fbfd37b7d29d8f0add44a24f
Diffstat (limited to 'saharaclient')
-rw-r--r--saharaclient/api/cluster_templates.py12
-rw-r--r--saharaclient/osc/v1/cluster_templates.py21
-rw-r--r--saharaclient/tests/unit/osc/v1/test_cluster_templates.py35
-rw-r--r--saharaclient/tests/unit/test_cluster_templates.py5
4 files changed, 51 insertions, 22 deletions
diff --git a/saharaclient/api/cluster_templates.py b/saharaclient/api/cluster_templates.py
index 04c2585..02203a7 100644
--- a/saharaclient/api/cluster_templates.py
+++ b/saharaclient/api/cluster_templates.py
@@ -27,7 +27,8 @@ class ClusterTemplateManager(base.ResourceManager):
def create(self, name, plugin_name, hadoop_version, description=None,
cluster_configs=None, node_groups=None, anti_affinity=None,
net_id=None, default_image_id=None, use_autoconfig=None,
- shares=None, is_public=None, is_protected=None):
+ shares=None, is_public=None, is_protected=None,
+ domain_name=None):
"""Create a Cluster Template."""
data = {
@@ -46,7 +47,8 @@ class ClusterTemplateManager(base.ResourceManager):
use_autoconfig=use_autoconfig,
shares=shares,
is_public=is_public,
- is_protected=is_protected)
+ is_protected=is_protected,
+ domain_name=domain_name)
return self._create('/cluster-templates', data, 'cluster_template')
@@ -56,7 +58,8 @@ class ClusterTemplateManager(base.ResourceManager):
node_groups=NotUpdated, anti_affinity=NotUpdated,
net_id=NotUpdated, default_image_id=NotUpdated,
use_autoconfig=NotUpdated, shares=NotUpdated,
- is_public=NotUpdated, is_protected=NotUpdated):
+ is_public=NotUpdated, is_protected=NotUpdated,
+ domain_name=NotUpdated):
"""Update a Cluster Template."""
data = {}
@@ -72,7 +75,8 @@ class ClusterTemplateManager(base.ResourceManager):
use_autoconfig=use_autoconfig,
shares=shares,
is_public=is_public,
- is_protected=is_protected)
+ is_protected=is_protected,
+ domain_name=domain_name)
return self._update('/cluster-templates/%s' % cluster_template_id,
data, 'cluster_template')
diff --git a/saharaclient/osc/v1/cluster_templates.py b/saharaclient/osc/v1/cluster_templates.py
index 52c53b8..28c8cf6 100644
--- a/saharaclient/osc/v1/cluster_templates.py
+++ b/saharaclient/osc/v1/cluster_templates.py
@@ -25,7 +25,7 @@ from saharaclient.osc.v1 import utils
CT_FIELDS = ['id', 'name', 'plugin_name', 'plugin_version', 'description',
'node_groups', 'anti_affinity', 'use_autoconfig', 'is_default',
- 'is_protected', 'is_public']
+ 'is_protected', 'is_public', 'domain_name']
def _format_node_groups_list(node_groups):
@@ -132,6 +132,12 @@ class CreateClusterTemplate(command.ShowOne):
metavar='<filename>',
help='JSON representation of the cluster template configs'
)
+ parser.add_argument(
+ '--domain-name',
+ metavar='<domain-name>',
+ help='Domain name for instances of this cluster template. This '
+ 'option is available if \'use_designate\' config is True'
+ )
return parser
def take_action(self, parsed_args):
@@ -191,7 +197,8 @@ class CreateClusterTemplate(command.ShowOne):
cluster_configs=configs,
shares=shares,
is_public=parsed_args.public,
- is_protected=parsed_args.protected
+ is_protected=parsed_args.protected,
+ domain_name=parsed_args.domain_name
).to_dict()
_format_ct_output(data)
@@ -424,6 +431,13 @@ class UpdateClusterTemplate(command.ShowOne):
metavar='<filename>',
help='JSON representation of the cluster template configs'
)
+ parser.add_argument(
+ '--domain-name',
+ metavar='<domain-name>',
+ default=None,
+ help='Domain name for instances of this cluster template. This '
+ 'option is available if \'use_designate\' config is True'
+ )
parser.set_defaults(is_public=None, is_protected=None,
use_autoconfig=None)
return parser
@@ -481,7 +495,8 @@ class UpdateClusterTemplate(command.ShowOne):
cluster_configs=configs,
shares=shares,
is_public=parsed_args.is_public,
- is_protected=parsed_args.is_protected
+ is_protected=parsed_args.is_protected,
+ domain_name=parsed_args.domain_name
)
data = client.cluster_templates.update(
diff --git a/saharaclient/tests/unit/osc/v1/test_cluster_templates.py b/saharaclient/tests/unit/osc/v1/test_cluster_templates.py
index b9e9533..78e67a3 100644
--- a/saharaclient/tests/unit/osc/v1/test_cluster_templates.py
+++ b/saharaclient/tests/unit/osc/v1/test_cluster_templates.py
@@ -39,7 +39,8 @@ CT_INFO = {
"id": "0647061f-ab98-4c89-84e0-30738ea55750",
"anti_affinity": [],
"name": "template",
- "is_protected": False
+ "is_protected": False,
+ "domain_name": 'domain.org.'
}
@@ -83,18 +84,20 @@ class TestCreateClusterTemplate(TestClusterTemplates):
'node_group_template_id':
'd29631fc-0fad-434b-80aa-7a3e9526f57c'}],
plugin_name='fake', use_autoconfig=False, shares=None,
- cluster_configs=None)
+ cluster_configs=None, domain_name=None)
def test_ct_create_all_options(self):
arglist = ['--name', 'template', '--node-groups', 'fakeng:2',
'--anti-affinity', 'datanode',
'--description', 'descr',
- '--autoconfig', '--public', '--protected']
+ '--autoconfig', '--public', '--protected',
+ '--domain-name', 'domain.org.']
verifylist = [('name', 'template'),
('node_groups', ['fakeng:2']),
('description', 'descr'), ('autoconfig', True),
- ('public', True), ('protected', True)]
+ ('public', True), ('protected', True),
+ ('domain_name', 'domain.org.')]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -108,16 +111,17 @@ class TestCreateClusterTemplate(TestClusterTemplates):
'node_group_template_id':
'd29631fc-0fad-434b-80aa-7a3e9526f57c'}],
plugin_name='fake', use_autoconfig=True, shares=None,
- cluster_configs=None)
+ cluster_configs=None, domain_name='domain.org.')
# Check that columns are correct
- expected_columns = ('Anti affinity', 'Description', 'Id', 'Is default',
+ expected_columns = ('Anti affinity', 'Description',
+ 'Domain name', 'Id', 'Is default',
'Is protected', 'Is public', 'Name', 'Node groups',
'Plugin name', 'Plugin version', 'Use autoconfig')
self.assertEqual(expected_columns, columns)
# Check that data is correct
- expected_data = ('', 'Cluster template for tests',
+ expected_data = ('', 'Cluster template for tests', 'domain.org.',
'0647061f-ab98-4c89-84e0-30738ea55750', False, False,
False, 'template', 'fakeng:2', 'fake', '0.1', True)
self.assertEqual(expected_data, data)
@@ -209,14 +213,15 @@ class TestShowClusterTemplate(TestClusterTemplates):
self.ct_mock.find_unique.assert_called_once_with(name='template')
# Check that columns are correct
- expected_columns = ('Anti affinity', 'Description', 'Id', 'Is default',
+ expected_columns = ('Anti affinity', 'Description',
+ 'Domain name', 'Id', 'Is default',
'Is protected', 'Is public', 'Name', 'Node groups',
'Plugin name', 'Plugin version', 'Use autoconfig')
self.assertEqual(expected_columns, columns)
# Check that data is correct
expected_data = (
- '', 'Cluster template for tests',
+ '', 'Cluster template for tests', 'domain.org.',
'0647061f-ab98-4c89-84e0-30738ea55750', False, False, False,
'template', 'fakeng:2', 'fake', '0.1', True)
self.assertEqual(expected_data, data)
@@ -280,12 +285,13 @@ class TestUpdateClusterTemplate(TestClusterTemplates):
arglist = ['template', '--name', 'template', '--node-groups',
'fakeng:2', '--anti-affinity', 'datanode',
'--description', 'descr', '--autoconfig-enable',
- '--public', '--protected']
+ '--public', '--protected', '--domain-name', 'domain.org.']
verifylist = [('cluster_template', 'template'), ('name', 'template'),
('node_groups', ['fakeng:2']),
('description', 'descr'), ('use_autoconfig', True),
- ('is_public', True), ('is_protected', True)]
+ ('is_public', True), ('is_protected', True),
+ ('domain_name', 'domain.org.')]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -300,16 +306,17 @@ class TestUpdateClusterTemplate(TestClusterTemplates):
{'count': 2, 'name': 'fakeng',
'node_group_template_id':
'd29631fc-0fad-434b-80aa-7a3e9526f57c'}],
- plugin_name='fake', use_autoconfig=True)
+ plugin_name='fake', use_autoconfig=True, domain_name='domain.org.')
# Check that columns are correct
- expected_columns = ('Anti affinity', 'Description', 'Id', 'Is default',
+ expected_columns = ('Anti affinity', 'Description',
+ 'Domain name', 'Id', 'Is default',
'Is protected', 'Is public', 'Name', 'Node groups',
'Plugin name', 'Plugin version', 'Use autoconfig')
self.assertEqual(expected_columns, columns)
# Check that data is correct
- expected_data = ('', 'Cluster template for tests',
+ expected_data = ('', 'Cluster template for tests', 'domain.org.',
'0647061f-ab98-4c89-84e0-30738ea55750', False, False,
False, 'template', 'fakeng:2', 'fake', '0.1', True)
self.assertEqual(expected_data, data)
diff --git a/saharaclient/tests/unit/test_cluster_templates.py b/saharaclient/tests/unit/test_cluster_templates.py
index 7f8e438..d674b6d 100644
--- a/saharaclient/tests/unit/test_cluster_templates.py
+++ b/saharaclient/tests/unit/test_cluster_templates.py
@@ -31,6 +31,7 @@ class ClusterTemplateTest(base.BaseTestCase):
'count': 1
},
"use_autoconfig": False,
+ "domain_name": 'domain.org.'
}
update_json = {
@@ -46,6 +47,7 @@ class ClusterTemplateTest(base.BaseTestCase):
'count': 1
},
"use_autoconfig": True,
+ "domain_name": 'domain.org.'
}
}
@@ -112,6 +114,7 @@ class ClusterTemplateTest(base.BaseTestCase):
net_id=getattr(resp, "neutron_management_network", None),
default_image_id=getattr(resp, "default_image_id", None),
use_autoconfig=True,
+ domain_name=getattr(resp, "domain_name", None)
)
self.assertIsInstance(updated, ct.ClusterTemplate)
@@ -130,7 +133,7 @@ class ClusterTemplateTest(base.BaseTestCase):
'hadoop_version': None, 'is_protected': None, 'is_public': None,
'name': None, 'net_id': None,
'node_groups': None, 'plugin_name': None, 'shares': None,
- 'use_autoconfig': None}
+ 'use_autoconfig': None, 'domain_name': None}
req_json = unset_json.copy()
req_json['neutron_management_network'] = req_json.pop('net_id')