diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-02-24 09:23:20 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-02-24 09:23:21 +0000 |
commit | 0458a7691bdf57a569effef9043cdb2853900423 (patch) | |
tree | 812a59eef6bf5a083dc90ad3936937753a207f5b | |
parent | 78ab1e1af843683e3e1c470b7eda054169850311 (diff) | |
parent | 2b253fd8fad1a998d3b6b64f514a56567f77c876 (diff) | |
download | python-saharaclient-0458a7691bdf57a569effef9043cdb2853900423.tar.gz |
Merge "verifications impl for saharaclient"
-rw-r--r-- | saharaclient/api/clusters.py | 5 | ||||
-rw-r--r-- | saharaclient/osc/v1/clusters.py | 69 | ||||
-rw-r--r-- | setup.cfg | 1 |
3 files changed, 73 insertions, 2 deletions
diff --git a/saharaclient/api/clusters.py b/saharaclient/api/clusters.py index f7ae6ba..af1a2a1 100644 --- a/saharaclient/api/clusters.py +++ b/saharaclient/api/clusters.py @@ -128,3 +128,8 @@ class ClusterManager(base.ResourceManager): shares=shares) return self._patch('/clusters/%s' % cluster_id, data) + + def verification_update(self, cluster_id, status): + """Start a verification for a Cluster.""" + data = {'verification': {'status': status}} + return self._patch("/clusters/%s" % cluster_id, data) diff --git a/saharaclient/osc/v1/clusters.py b/saharaclient/osc/v1/clusters.py index 2a887ce..56ebab3 100644 --- a/saharaclient/osc/v1/clusters.py +++ b/saharaclient/osc/v1/clusters.py @@ -44,6 +44,17 @@ def _format_cluster_output(data): data['anti_affinity'] = osc_utils.format_list(data['anti_affinity']) +def _prepare_health_checks(data): + ver = data.get('verification', {}) + additional_fields = ['verification_status'] + data['verification_status'] = ver.get('status', 'UNKNOWN') + for check in ver.get('checks', []): + row_name = "Health check (%s)" % check['name'] + data[row_name] = check['status'] + additional_fields.append(row_name) + return data, additional_fields + + def _get_plugin_version(cluster_template, client): ct = utils.get_resource(client.cluster_templates, cluster_template) return ct.plugin_name, ct.hadoop_version, ct.id @@ -294,7 +305,12 @@ class ShowCluster(show.ShowOne): metavar="<cluster>", help="Name or id of the cluster to display", ) - + parser.add_argument( + '--verification', + action='store_true', + default=False, + help='List additional fields for verifications', + ) return parser def take_action(self, parsed_args): @@ -305,7 +321,11 @@ class ShowCluster(show.ShowOne): client.clusters, parsed_args.cluster).to_dict() _format_cluster_output(data) - data = utils.prepare_data(data, CLUSTER_FIELDS) + fields = [] + if parsed_args.verification: + data, fields = _prepare_health_checks(data) + fields.extend(CLUSTER_FIELDS) + data = utils.prepare_data(data, fields) return self.dict2columns(data) @@ -546,3 +566,48 @@ class ScaleCluster(show.ShowOne): data = utils.prepare_data(data, CLUSTER_FIELDS) return self.dict2columns(data) + + +class VerificationUpdateCluster(show.ShowOne): + """Updates cluster verifications""" + + log = logging.getLogger(__name__ + ".VerificationUpdateCluster") + + def get_parser(self, prog_name): + parser = super(VerificationUpdateCluster, self).get_parser(prog_name) + + parser.add_argument( + 'cluster', + metavar="<cluster>", + help="Name or ID of the cluster", + ) + status = parser.add_mutually_exclusive_group() + status.add_argument( + '--start', + action='store_true', + help='Start the cluster verification', + dest='is_start' + ) + return parser + + def take_action(self, parsed_args): + self.log.debug("take_action(%s)" % parsed_args) + client = self.app.client_manager.data_processing + + cluster_id = utils.get_resource_id( + client.clusters, parsed_args.cluster) + + if parsed_args.is_start: + status = 'START' + else: + raise exceptions.CommandError("--start should be provided") + data = client.clusters.verification_update( + cluster_id, status).cluster + + data, fields = _prepare_health_checks(data) + fields.extend(CLUSTER_FIELDS) + + _format_cluster_output(data) + data = utils.prepare_data(data, fields) + + return self.dict2columns(data) @@ -70,6 +70,7 @@ openstack.data_processing.v1 = dataprocessing_cluster_update = saharaclient.osc.v1.clusters:UpdateCluster dataprocessing_cluster_delete = saharaclient.osc.v1.clusters:DeleteCluster dataprocessing_cluster_scale = saharaclient.osc.v1.clusters:ScaleCluster + dataprocessing_cluster_verification = saharaclient.osc.v1.clusters:VerificationUpdateCluster dataprocessing_job_template_create = saharaclient.osc.v1.job_templates:CreateJobTemplate dataprocessing_job_template_list = saharaclient.osc.v1.job_templates:ListJobTemplates |