From d41d9ad7b52573d0394c94dbe80ff3d4ddd4e12a Mon Sep 17 00:00:00 2001 From: Michael Ionkin Date: Thu, 14 Jul 2016 13:14:03 +0300 Subject: [PATCH] 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 --- ...esignate-integration-16c59a6b57dbcfa4.yaml | 4 +++ saharaclient/api/cluster_templates.py | 12 ++++--- saharaclient/osc/v1/cluster_templates.py | 21 +++++++++-- .../unit/osc/v1/test_cluster_templates.py | 35 +++++++++++-------- .../tests/unit/test_cluster_templates.py | 5 ++- 5 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 releasenotes/notes/designate-integration-16c59a6b57dbcfa4.yaml diff --git a/releasenotes/notes/designate-integration-16c59a6b57dbcfa4.yaml b/releasenotes/notes/designate-integration-16c59a6b57dbcfa4.yaml new file mode 100644 index 00000000..3cb06fe0 --- /dev/null +++ b/releasenotes/notes/designate-integration-16c59a6b57dbcfa4.yaml @@ -0,0 +1,4 @@ +--- +features: + - Added integration of Designate for hostname resolution through dns + servers diff --git a/saharaclient/api/cluster_templates.py b/saharaclient/api/cluster_templates.py index 04c25859..02203a7d 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 52c53b81..28c8cf61 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='', help='JSON representation of the cluster template configs' ) + parser.add_argument( + '--domain-name', + metavar='', + 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='', help='JSON representation of the cluster template configs' ) + parser.add_argument( + '--domain-name', + metavar='', + 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 b9e9533f..78e67a3c 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 7f8e4380..d674b6d2 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')