Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Python3.6-AutoRecovery/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,12 @@ def main_handler(event, context):
run_command = os.environ.get('run_Command')
run_command_base = base64.b64encode(run_command.encode('utf-8'))

# 判断服务器是否在 RUNNING 状态
status_get = get_cvm_status(timestamp, date, secretid, secretkey, region, insid)
status = json.loads(status_get)["Response"]["InstanceSet"][0]["InstanceState"]
print(status)

loop = 1
while loop <= 6:
# 判断服务器是否在 RUNNING 状态
status_get = get_cvm_status(timestamp, date, secretid, secretkey, region, insid)
status = json.loads(status_get)["Response"]["InstanceSet"][0]["InstanceState"]
print(status)
if status == 'RUNNING':
# 服务器命令执行
time.sleep(10)
Expand All @@ -162,4 +161,4 @@ def main_handler(event, context):
loop += 1
else:
print("机器状态未就绪!")
return ("机器状态未就绪!")
return ("机器状态未就绪!")