def cluster_update(self, context, cluster, rollback=False):
    LOG.debug('cluster_heat cluster_update')
    osc = clients.OpenStackClients(context)
    allow_update_status = (fields.ClusterStatus.CREATE_COMPLETE, fields.ClusterStatus.UPDATE_COMPLETE, fields.ClusterStatus.RESUME_COMPLETE, fields.ClusterStatus.RESTORE_COMPLETE, fields.ClusterStatus.ROLLBACK_COMPLETE, fields.ClusterStatus.SNAPSHOT_COMPLETE, fields.ClusterStatus.CHECK_COMPLETE, fields.ClusterStatus.ADOPT_COMPLETE)
    if (cluster.status not in allow_update_status):
        conductor_utils.notify_about_cluster_operation(context, taxonomy.ACTION_UPDATE, taxonomy.OUTCOME_FAILURE)
        operation = (_('Updating a cluster when status is "%s"') % cluster.status)
        raise exception.NotSupported(operation=operation)
    delta = cluster.obj_what_changed()
    if (not delta):
        return cluster
    manager = scale_manager.get_scale_manager(context, osc, cluster)
    ct = conductor_utils.retrieve_cluster_template(context, cluster)
    cluster_driver = driver.Driver.get_driver(ct.server_type, ct.cluster_distro, ct.coe)
    try:
        conductor_utils.notify_about_cluster_operation(context, taxonomy.ACTION_UPDATE, taxonomy.OUTCOME_PENDING)
        cluster_driver.update_cluster(context, cluster, manager, rollback)
        cluster.status = fields.ClusterStatus.UPDATE_IN_PROGRESS
        cluster.status_reason = None
    except Exception as e:
        cluster.status = fields.ClusterStatus.UPDATE_FAILED
        cluster.status_reason = six.text_type(e)
        cluster.save()
        conductor_utils.notify_about_cluster_operation(context, taxonomy.ACTION_UPDATE, taxonomy.OUTCOME_FAILURE)
        if isinstance(e, exc.HTTPBadRequest):
            e = exception.InvalidParameterValue(message=six.text_type(e))
            raise e
        raise
    cluster.save()
    return cluster
def cluster_update(self, context, cluster, rollback=False):
    LOG.debug('cluster_heat cluster_update')
    osc = clients.OpenStackClients(context)
    allow_update_status = (fields.ClusterStatus.CREATE_COMPLETE, fields.ClusterStatus.UPDATE_COMPLETE, fields.ClusterStatus.RESUME_COMPLETE, fields.ClusterStatus.RESTORE_COMPLETE, fields.ClusterStatus.ROLLBACK_COMPLETE, fields.ClusterStatus.SNAPSHOT_COMPLETE, fields.ClusterStatus.CHECK_COMPLETE, fields.ClusterStatus.ADOPT_COMPLETE)
    if (cluster.status not in allow_update_status):
        conductor_utils.notify_about_cluster_operation(context, taxonomy.ACTION_UPDATE, taxonomy.OUTCOME_FAILURE)
        operation = (_('Updating a cluster when status is "%s"') % cluster.status)
        raise exception.NotSupported(operation=operation)
    delta = cluster.obj_what_changed()
    if (not delta):
        return cluster
    manager = scale_manager.get_scale_manager(context, osc, cluster)
    ct = conductor_utils.retrieve_cluster_template(context, cluster)
    cluster_driver = driver.Driver.get_driver(ct.server_type, ct.cluster_distro, ct.coe)
    try:
        conductor_utils.notify_about_cluster_operation(context, taxonomy.ACTION_UPDATE, taxonomy.OUTCOME_PENDING)
        cluster_driver.update_cluster(context, cluster, manager, rollback)
        cluster.status = fields.ClusterStatus.UPDATE_IN_PROGRESS
        cluster.status_reason = None
    except Exception as e:
        cluster.status = fields.ClusterStatus.UPDATE_FAILED
        cluster.status_reason = six.text_type(e)
        cluster.save()
        conductor_utils.notify_about_cluster_operation(context, taxonomy.ACTION_UPDATE, taxonomy.OUTCOME_FAILURE)
        if isinstance(e, exc.HTTPBadRequest):
            e = exception.InvalidParameterValue(message=six.text_type(e))
            raise e
        raise
    cluster.save()
    return cluster