本文整理汇总了Python中cm_api.api_client.ApiResource.delete_cluster方法的典型用法代码示例。如果您正苦于以下问题:Python ApiResource.delete_cluster方法的具体用法?Python ApiResource.delete_cluster怎么用?Python ApiResource.delete_cluster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cm_api.api_client.ApiResource
的用法示例。
在下文中一共展示了ApiResource.delete_cluster方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import delete_cluster [as 别名]
#.........这里部分代码省略.........
for role in yarn.get_all_roles():
cmd = yarn.deploy_client_config(role.name)
if not cmd.wait(CMD_TIMEOUT).success:
raise Exception("Failed to deploy client config. Role: " + role.name)
#SUCCESS!
print "Cluster succesfully deployed."
#Add new nodes
elif(opts.action == "add"):
print "Adding hosts..."
cluster = api.get_cluster(CLUSTER_NAME);
cluster.add_hosts(HOSTNAMES);
print "Configurng HDFS Roles..."
hdfs = cluster.get_service("hdfs")
for i in range(len(HOSTNAMES)):
datanode = hdfs.create_role("hdfs-DATANODE-" + ROLEHASH[i], "DATANODE", HOSTNAMES[i])
datanode.update_config(DATANODE_CONF);
cmds = hdfs.start_roles("hdfs-DATANODE-" + ROLEHASH[i])
for cmd in cmds:
if not cmd.wait(CMD_TIMEOUT).success:
raise Exception(cmd.name)
cmd = hdfs.deploy_client_config("hdfs-DATANODE-" + ROLEHASH[i])
if not cmd.wait(CMD_TIMEOUT).success:
raise Exception("Failed to deploy client config hdfs-DATANODE-" + ROLEHASH[i])
print "Configuring YARN roles..."
yarn = cluster.get_service("yarn")
for i in range(len(HOSTNAMES)):
nodeman = yarn.create_role("yarn-NODEMANAGER-" + ROLEHASH[i], "NODEMANAGER", HOSTNAMES[i])
nodeman.update_config(NODEMAN_CONF)
cmds = yarn.start_roles("yarn-NODEMANAGER-" + ROLEHASH[i])
for cmd in cmds:
if not cmd.wait(CMD_TIMEOUT).success:
raise Exception(cmd.name)
cmd = yarn.deploy_client_config("yarn-NODEMANAGER-" + ROLEHASH[i])
if not cmd.wait(CMD_TIMEOUT).success:
raise Exception("Failed to deploy client config yarn-NODEMANAGER-" + ROLEHASH[i])
#print "Restarting HDFS service..."
#cmd = hdfs.restart()
#if not cmd.wait(CMD_TIMEOUT).success:
# raise Exception("Failed to restart HDFS")
#print "Restarting YARN service..."
#cmd = yarn.restart()
#if not cmd.wait(CMD_TIMEOUT).success:
# raise Exception("Failed to restart YARN")
#SUCCESS!
print "Nodes successfully added"
#Remove nodes
elif(opts.action == "remove"):
cluster = api.get_cluster(CLUSTER_NAME);
hdfs = cluster.get_service("hdfs")
yarn = cluster.get_service("yarn")
print "Decommissioning Roles..."
for role in ROLEHASH:
cmd = yarn.decommission("yarn-NODEMANAGER-" + role)
if not cmd.wait(CMD_TIMEOUT).success:
raise Exception("Failed to decommission role yarn-NODEMANAGER" + role)
cmd = hdfs.decommission("hdfs-DATANODE-" + role)
if not cmd.wait(CMD_TIMEOUT).success:
raise Exception("Failed to decommission role hdfs-DATANODE-" + role)
print "Deleting Nodes..."
for role in ROLEHASH:
hdfs.delete_role("hdfs-DATANODE-" + role)
yarn.delete_role("yarn-NODEMANAGER-" + role)
for hostname in HOSTNAMES:
cluster.remove_host(hostname);
#SUCCESS
print "Nodes successfull removed."
#Delete Cluster
elif(opts.action == "delete"):
cluster = api.get_cluster(CLUSTER_NAME);
hdfs = cluster.get_service("hdfs")
yarn = cluster.get_service("yarn")
print "Stopping YARN..."
cmd = yarn.stop()
if not cmd.wait(CMD_TIMEOUT).success:
raise Exception("Failed to stop YARN")
print "Stopping HDFS..."
cmd = hdfs.stop()
if not cmd.wait(CMD_TIMEOUT).success:
raise Exception("Failed to stop HDFS")
print "Deleting Cluster..."
api.delete_cluster(CLUSTER_NAME)
#SUCCESS
print "Cluster successfully deleted."
else:
print "PLEASE SELECT A CORRECT OPTION"
parser.print_help()