modify_ansible_hosts_file(cluster_name_suffix_id, action='join_slaves') except Exception, e: msg = '{0}. Scale action failed. Cluster rolled back'.format(str(e.args[0])) set_cluster_state(token, cluster_id, msg) rollback_scale_cluster(list_of_new_slaves, cyclades, cluster_to_scale, pre_scale_size,ansible=True) set_cluster_state(token, cluster_id, state=msg, status=status_map[previous_cluster_status], error=msg) raise RuntimeError(msg) finally: subprocess.call('rm -rf /tmp/{0}'.format(user_id),shell=True) # Restart hadoop cluster for changes to take effect state = "Restarting %s for the changes to take effect" % (cluster_to_scale.cluster_name) set_cluster_state(token, cluster_id, state) try: if REVERSE_HADOOP_STATUS[previous_hadoop_status] == 'stop': ansible_manage_cluster(cluster_id, 'start') elif REVERSE_HADOOP_STATUS[previous_hadoop_status] == 'start': ansible_manage_cluster(cluster_id, 'stop') ansible_manage_cluster(cluster_id, 'start') except Exception, e: msg = 'Restarting %s failed with %s. Try to restart it manually.'%(cluster_to_scale.cluster_name,str(e.args[0])) set_cluster_state(token, cluster_id, state=msg, status=status_map[previous_cluster_status], error=msg) raise RuntimeError(msg) state = 'Scaled cluster %s and new cluster size is %d' %(cluster_to_scale.cluster_name, cluster_to_scale.cluster_size) set_cluster_state(token, cluster_id, state, status=status_map[previous_cluster_status]) return cluster_to_scale.cluster_name
def hadoop_cluster_action_async(cluster_id, action): """ Asynchronous start, stop or format Hadoop cluster task. """ result = ansible_manage_cluster(cluster_id, action) return result