Merge "verifications impl for saharaclient"

This commit is contained in:
Jenkins
2016-02-24 09:23:20 +00:00
committed by Gerrit Code Review
3 changed files with 73 additions and 2 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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