diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-11-04 10:38:22 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-11-04 10:38:22 +0000 |
commit | 1919f56c9f8dc26b84dec08eeb76214fddbc07a9 (patch) | |
tree | 0731e8cea0a41308fbcf023e8cda3a67881ecc1a | |
parent | f01832e4223b3f25c242ee05fccfbbf1c0d93d43 (diff) | |
parent | 30d7d7d79e41fae268e49e4e9aa1bdd78cee6ef6 (diff) | |
download | python-saharaclient-1919f56c9f8dc26b84dec08eeb76214fddbc07a9.tar.gz |
Merge "Fixing updates for CLI"
-rw-r--r-- | saharaclient/osc/v1/clusters.py | 1 | ||||
-rw-r--r-- | saharaclient/osc/v1/job_templates.py | 1 | ||||
-rw-r--r-- | saharaclient/osc/v1/node_group_templates.py | 18 | ||||
-rw-r--r-- | saharaclient/tests/unit/osc/v1/test_cluster_templates.py | 29 | ||||
-rw-r--r-- | saharaclient/tests/unit/osc/v1/test_clusters.py | 14 | ||||
-rw-r--r-- | saharaclient/tests/unit/osc/v1/test_data_sources.py | 12 | ||||
-rw-r--r-- | saharaclient/tests/unit/osc/v1/test_job_templates.py | 25 | ||||
-rw-r--r-- | saharaclient/tests/unit/osc/v1/test_node_group_templates.py | 48 |
8 files changed, 134 insertions, 14 deletions
diff --git a/saharaclient/osc/v1/clusters.py b/saharaclient/osc/v1/clusters.py index 5f819c1..76250a4 100644 --- a/saharaclient/osc/v1/clusters.py +++ b/saharaclient/osc/v1/clusters.py @@ -399,6 +399,7 @@ class UpdateCluster(show.ShowOne): help='Make the cluster unprotected', dest='is_protected' ) + parser.set_defaults(is_public=None, is_protected=None) return parser diff --git a/saharaclient/osc/v1/job_templates.py b/saharaclient/osc/v1/job_templates.py index 27eaec1..2ab21d6 100644 --- a/saharaclient/osc/v1/job_templates.py +++ b/saharaclient/osc/v1/job_templates.py @@ -298,6 +298,7 @@ class UpdateJobTemplate(show.ShowOne): help='Make the job template unprotected', dest='is_protected' ) + parser.set_defaults(is_public=None, is_protected=None) return parser diff --git a/saharaclient/osc/v1/node_group_templates.py b/saharaclient/osc/v1/node_group_templates.py index 0d8c85d..bf8fa7e 100644 --- a/saharaclient/osc/v1/node_group_templates.py +++ b/saharaclient/osc/v1/node_group_templates.py @@ -76,6 +76,11 @@ class CreateNodeGroupTemplate(show.ShowOne): "instance [REQUIRED if JSON is not provided]" ) parser.add_argument( + '--flavor', + metavar="<flavor-id>", + help="ID of the flavor [REQUIRED if JSON is not provided]" + ) + parser.add_argument( '--security-groups', metavar="<security-groups>", nargs="+", @@ -96,11 +101,6 @@ class CreateNodeGroupTemplate(show.ShowOne): "will be created" ) parser.add_argument( - '--flavor', - metavar="<flavor-id>", - help="ID of the flavor" - ) - parser.add_argument( '--floating-ip-pool', metavar="<floating-ip-pool>", help="ID of the floating IP pool" @@ -214,12 +214,12 @@ class CreateNodeGroupTemplate(show.ShowOne): data = client.node_group_templates.create(**template).to_dict() else: if (not parsed_args.name or not parsed_args.plugin or - not parsed_args.version or not parsed_args or + not parsed_args.version or not parsed_args.flavor or not parsed_args.processes): raise exceptions.CommandError( - 'At least --name, --plugin, --version, --processes ' - 'arguments should be specified or json template should ' - 'be provided with --json argument') + 'At least --name, --plugin, --version, --processes, ' + '--flavor arguments should be specified or json template ' + 'should be provided with --json argument') configs = None if parsed_args.configs: diff --git a/saharaclient/tests/unit/osc/v1/test_cluster_templates.py b/saharaclient/tests/unit/osc/v1/test_cluster_templates.py index c5c2632..1580dce 100644 --- a/saharaclient/tests/unit/osc/v1/test_cluster_templates.py +++ b/saharaclient/tests/unit/osc/v1/test_cluster_templates.py @@ -264,6 +264,20 @@ class TestUpdateClusterTemplate(TestClusterTemplates): self.assertRaises(osc_utils.ParserException, self.check_parser, self.cmd, arglist, verifylist) + def test_ct_update_nothing_updated(self): + arglist = ['template'] + verifylist = [('cluster_template', 'template')] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + self.ct_mock.update.assert_called_once_with( + '0647061f-ab98-4c89-84e0-30738ea55750', cluster_configs=None, + description=None, hadoop_version=None, is_protected=None, + is_public=None, name=None, node_groups=None, plugin_name=None, + shares=None, use_autoconfig=None) + def test_ct_update_all_options(self): arglist = ['template', '--name', 'template', '--node-groups', 'fakeng:2', '--anti-affinity', 'datanode', @@ -302,3 +316,18 @@ class TestUpdateClusterTemplate(TestClusterTemplates): '0647061f-ab98-4c89-84e0-30738ea55750', False, False, False, 'template', 'fakeng:2', 'fake', True, '0.1') self.assertEqual(expected_data, data) + + def test_ct_update_private_unprotected(self): + arglist = ['template', '--private', '--unprotected'] + verifylist = [('cluster_template', 'template'), + ('is_protected', False), ('is_public', False)] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + self.ct_mock.update.assert_called_once_with( + '0647061f-ab98-4c89-84e0-30738ea55750', cluster_configs=None, + description=None, hadoop_version=None, is_protected=False, + is_public=False, name=None, node_groups=None, plugin_name=None, + shares=None, use_autoconfig=None) diff --git a/saharaclient/tests/unit/osc/v1/test_clusters.py b/saharaclient/tests/unit/osc/v1/test_clusters.py index 24b931e..687fa74 100644 --- a/saharaclient/tests/unit/osc/v1/test_clusters.py +++ b/saharaclient/tests/unit/osc/v1/test_clusters.py @@ -321,6 +321,20 @@ class TestUpdateCluster(TestClusters): self.assertRaises(osc_utils.ParserException, self.check_parser, self.cmd, arglist, verifylist) + def test_cluster_update_nothing_updated(self): + arglist = ['fake'] + + verifylist = [('cluster', 'fake')] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + # Check that correct arguments were passed + self.cl_mock.update.assert_called_once_with( + 'cluster_id', description=None, is_protected=None, is_public=None, + name=None) + def test_cluster_update_all_options(self): arglist = ['fake', '--name', 'fake', '--description', 'descr', '--public', '--protected'] diff --git a/saharaclient/tests/unit/osc/v1/test_data_sources.py b/saharaclient/tests/unit/osc/v1/test_data_sources.py index fe3f07a..98a25c8 100644 --- a/saharaclient/tests/unit/osc/v1/test_data_sources.py +++ b/saharaclient/tests/unit/osc/v1/test_data_sources.py @@ -229,6 +229,16 @@ class TestUpdateDataSource(TestDataSources): self.assertRaises(osc_utils.ParserException, self.check_parser, self.cmd, arglist, verifylist) + def test_data_sources_update_nothing_updated(self): + arglist = ['source'] + verifylist = [('data_source', 'source')] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + self.ds_mock.update.assert_called_once_with('id', {}) + def test_data_sources_update_required_options(self): arglist = ['source'] verifylist = [('data_source', 'source')] @@ -284,7 +294,7 @@ class TestUpdateDataSource(TestDataSources): 'swift', 'swift://container.sahara/object') self.assertEqual(expected_data, data) - def test_data_sources_update_privat_unprotected(self): + def test_data_sources_update_private_unprotected(self): arglist = ['source', '--private', '--unprotected'] verifylist = [('data_source', 'source'), ('is_public', False), ('is_protected', False)] diff --git a/saharaclient/tests/unit/osc/v1/test_job_templates.py b/saharaclient/tests/unit/osc/v1/test_job_templates.py index 5e716d0..69f83cb 100644 --- a/saharaclient/tests/unit/osc/v1/test_job_templates.py +++ b/saharaclient/tests/unit/osc/v1/test_job_templates.py @@ -15,6 +15,8 @@ import mock +from openstackclient.tests import utils as osc_utils + from saharaclient.api import jobs as api_j from saharaclient.osc.v1 import job_templates as osc_j from saharaclient.tests.unit.osc.v1 import fakes @@ -227,6 +229,27 @@ class TestUpdateJobTemplate(TestJobTemplates): # Command to test self.cmd = osc_j.UpdateJobTemplate(self.app, None) + def test_job_template_update_no_options(self): + arglist = [] + verifylist = [] + + self.assertRaises(osc_utils.ParserException, self.check_parser, + self.cmd, arglist, verifylist) + + def test_job_template_update_nothing_updated(self): + arglist = ['pig-job'] + + verifylist = [('job_template', 'pig-job')] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + # Check that correct arguments were passed + self.job_mock.update.assert_called_once_with( + 'job_id', description=None, is_protected=None, is_public=None, + name=None) + def test_job_template_update_all_options(self): arglist = ['pig-job', '--name', 'pig-job', '--description', 'descr', '--public', '--protected'] @@ -262,7 +285,7 @@ class TestUpdateJobTemplate(TestJobTemplates): parsed_args = self.check_parser(self.cmd, arglist, verifylist) - columns, data = self.cmd.take_action(parsed_args) + self.cmd.take_action(parsed_args) # Check that correct arguments were passed self.job_mock.update.assert_called_once_with( diff --git a/saharaclient/tests/unit/osc/v1/test_node_group_templates.py b/saharaclient/tests/unit/osc/v1/test_node_group_templates.py index 92548f3..3864f34 100644 --- a/saharaclient/tests/unit/osc/v1/test_node_group_templates.py +++ b/saharaclient/tests/unit/osc/v1/test_node_group_templates.py @@ -72,9 +72,10 @@ class TestCreateNodeGroupTemplate(TestNodeGroupTemplates): def test_ngt_create_minimum_options(self): arglist = ['--name', 'template', '--plugin', 'fake', '--version', - '0.1', '--processes', 'namenode', 'tasktracker'] + '0.1', '--processes', 'namenode', 'tasktracker', + '--flavor', 'flavor'] verifylist = [('name', 'template'), ('plugin', 'fake'), - ('version', '0.1'), + ('version', '0.1'), ('flavor', 'flavor'), ('processes', ['namenode', 'tasktracker'])] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -84,7 +85,7 @@ class TestCreateNodeGroupTemplate(TestNodeGroupTemplates): # Check that correct arguments were passed self.ngt_mock.create.assert_called_once_with( auto_security_group=False, availability_zone=None, - description=None, flavor_id=None, floating_ip_pool=None, + description=None, flavor_id='flavor', floating_ip_pool=None, hadoop_version='0.1', is_protected=False, is_proxy_gateway=False, is_public=False, name='template', node_processes=['namenode', 'tasktracker'], plugin_name='fake', @@ -303,6 +304,26 @@ class TestUpdateNodeGroupTemplate(TestNodeGroupTemplates): self.assertRaises(osc_utils.ParserException, self.check_parser, self.cmd, arglist, verifylist) + def test_ngt_update_nothing_updated(self): + arglist = ['template'] + verifylist = [('node_group_template', 'template')] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + # Check that correct arguments were passed + self.ngt_mock.update.assert_called_once_with( + 'ea3c8624-a1f0-49cf-83c4-f5a6634699ca', auto_security_group=None, + availability_zone=None, description=None, flavor_id=None, + floating_ip_pool=None, hadoop_version=None, is_protected=None, + is_proxy_gateway=None, is_public=None, name=None, + node_configs=None, node_processes=None, plugin_name=None, + security_groups=None, shares=None, use_autoconfig=None, + volume_local_to_instance=None, volume_type=None, + volumes_availability_zone=None, volumes_per_node=None, + volumes_size=None) + def test_ngt_update_all_options(self): arglist = ['template', '--name', 'template', '--plugin', 'fake', '--version', '0.1', '--processes', 'namenode', @@ -369,3 +390,24 @@ class TestUpdateNodeGroupTemplate(TestNodeGroupTemplates): True, 'template', 'namenode, tasktracker', 'fake', None, True, '0.1', False, '/volumes/disk', None, None, 2, 2) self.assertEqual(expected_data, data) + + def test_ngt_update_private_unprotected(self): + arglist = ['template', '--private', '--unprotected'] + verifylist = [('node_group_template', 'template'), + ('is_public', False), ('is_protected', False)] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + # Check that correct arguments were passed + self.ngt_mock.update.assert_called_once_with( + 'ea3c8624-a1f0-49cf-83c4-f5a6634699ca', auto_security_group=None, + availability_zone=None, description=None, flavor_id=None, + floating_ip_pool=None, hadoop_version=None, is_protected=False, + is_proxy_gateway=None, is_public=False, name=None, + node_configs=None, node_processes=None, plugin_name=None, + security_groups=None, shares=None, use_autoconfig=None, + volume_local_to_instance=None, volume_type=None, + volumes_availability_zone=None, volumes_per_node=None, + volumes_size=None) |