Add usages for step_type field
Before this patch step_type of provision step was useless, now we can use this field to describe step better. partially implements bp: event-log Change-Id: Id50aa16c8f383c573cc41d503716157eea9f9fc8
This commit is contained in:
parent
b5d9f71c90
commit
5caebca4ee
@ -274,16 +274,23 @@ def sleep(seconds=0):
|
||||
|
||||
class InstanceInfo(object):
|
||||
def __init__(self, cluster_id=None, instance_id=None, instance_name=None,
|
||||
node_group_id=None):
|
||||
node_group_id=None, step_type=None):
|
||||
self.cluster_id = cluster_id
|
||||
self.instance_id = instance_id
|
||||
self.instance_name = instance_name
|
||||
self.node_group_id = node_group_id
|
||||
self.step_type = step_type
|
||||
|
||||
|
||||
def set_step_type(step_type):
|
||||
current().current_instance_info.step_type = step_type
|
||||
|
||||
|
||||
class InstanceInfoManager(object):
|
||||
def __init__(self, instance_info):
|
||||
self.prev_instance_info = current().current_instance_info
|
||||
if not instance_info.step_type:
|
||||
instance_info.step_type = self.prev_instance_info.step_type
|
||||
current().current_instance_info = instance_info
|
||||
|
||||
def __enter__(self):
|
||||
|
@ -206,6 +206,7 @@ def ops_error_handler(description):
|
||||
|
||||
|
||||
def _rollback_cluster(cluster, reason):
|
||||
context.set_step_type(_("Engine: rollback cluster"))
|
||||
return INFRA.rollback_cluster(cluster, reason)
|
||||
|
||||
|
||||
@ -250,14 +251,17 @@ def _provision_cluster(cluster_id):
|
||||
|
||||
# creating instances and configuring them
|
||||
cluster = conductor.cluster_get(ctx, cluster_id)
|
||||
context.set_step_type(_("Engine: create cluster"))
|
||||
INFRA.create_cluster(cluster)
|
||||
|
||||
# configure cluster
|
||||
cluster = g.change_cluster_status(cluster, "Configuring")
|
||||
context.set_step_type(_("Plugin: configure cluster"))
|
||||
plugin.configure_cluster(cluster)
|
||||
|
||||
# starting prepared and configured cluster
|
||||
cluster = g.change_cluster_status(cluster, "Starting")
|
||||
context.set_step_type(_("Plugin: start cluster"))
|
||||
plugin.start_cluster(cluster)
|
||||
|
||||
# cluster is now up and ready
|
||||
@ -285,17 +289,19 @@ def _provision_scaled_cluster(cluster_id, node_group_id_map):
|
||||
node_group.count]
|
||||
|
||||
if instances_to_delete:
|
||||
context.set_step_type(_("Plugin: decommission cluster"))
|
||||
plugin.decommission_nodes(cluster, instances_to_delete)
|
||||
|
||||
# Scaling infrastructure
|
||||
cluster = g.change_cluster_status(cluster, "Scaling")
|
||||
|
||||
context.set_step_type(_("Engine: scale cluster"))
|
||||
instance_ids = INFRA.scale_cluster(cluster, node_group_id_map)
|
||||
|
||||
# Setting up new nodes with the plugin
|
||||
if instance_ids:
|
||||
cluster = g.change_cluster_status(cluster, "Configuring")
|
||||
instances = g.get_instances(cluster, instance_ids)
|
||||
context.set_step_type(_("Plugin: scale cluster"))
|
||||
plugin.scale_cluster(cluster, instances)
|
||||
|
||||
g.change_cluster_status(cluster, "Active")
|
||||
@ -308,8 +314,10 @@ def terminate_cluster(cluster_id):
|
||||
cluster = conductor.cluster_get(ctx, cluster_id)
|
||||
plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name)
|
||||
|
||||
context.set_step_type(_("Plugin: shutdown cluster"))
|
||||
plugin.on_terminate_cluster(cluster)
|
||||
|
||||
context.set_step_type(_("Engine: shutdown cluster"))
|
||||
INFRA.shutdown_cluster(cluster)
|
||||
|
||||
if CONF.use_identity_api_v3:
|
||||
|
@ -73,12 +73,15 @@ def add_provisioning_step(cluster_id, step_name, total):
|
||||
return
|
||||
|
||||
update_provisioning_steps(cluster_id)
|
||||
return conductor.cluster_provision_step_add(context.ctx(), cluster_id, {
|
||||
'step_name': step_name,
|
||||
'completed': 0,
|
||||
'total': total,
|
||||
'started_at': timeutils.utcnow(),
|
||||
})
|
||||
step_type = context.ctx().current_instance_info.step_type
|
||||
return conductor.cluster_provision_step_add(
|
||||
context.ctx(), cluster_id, {
|
||||
'step_name': step_name,
|
||||
'step_type': step_type,
|
||||
'completed': 0,
|
||||
'total': total,
|
||||
'started_at': timeutils.utcnow(),
|
||||
})
|
||||
|
||||
|
||||
def get_current_provisioning_step(cluster_id):
|
||||
|
Loading…
Reference in New Issue
Block a user