第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在Amazon EC2的boto3圖像中使用wait_until_exists()

在Amazon EC2的boto3圖像中使用wait_until_exists()

不負相思意 2021-05-30 18:02:08
我正在嘗試在Amazon EC2中啟動實例(初始狀態(tài)為stop),然后等待實例狀態(tài)從初始化變?yōu)楦鶕?jù)此處給出的文檔運行https://docs.aws.amazon.com/AWSEC2/latest/ UserGuide / ec2-instance-lifecycle.html這是相同的程序import sysimport boto3instance_id = "i-03e7f6391a0f523ee"action = 'ON'ec2 = boto3.client('ec2')if action == 'ON':   response = ec2.start_instances(InstanceIds=[instance_id], DryRun=False)else:    response = ec2.stop_instances(InstanceIds=[instance_id], DryRun=False)print(response)#resp2=ec2.describe_instances()#foo = response['Reservations'][0]['Instances'][0]['NetworkInterfaces'][0]['Association']['PublicDnsName']#filter=[{'Name':'Association','Values':['PublicDnsName']}]#print (foo)#instance = ec2.resource('ec2').instance(instance_id)#while instance.state['Name'] not in ('running', 'stopped'):#        sleep(5)#        print("the instance is initializing")x2=boto3.resource('ec2')image=x2.Image('instance_id')foo=image.wait_until_exists('self',Filters=[{'Name':'state','Values':'avaialable'}])print(foo)resp=ec2.describe_network_interfaces();print ("printing pub dns name")print(resp['NetworkInterfaces'][0]['Association']['PublicDnsName'])print ("going inside function to demonstrate usage of response returned from describe_instances() method")def get_name(inst):    client = boto3.client('ec2')    response = client.describe_instances(InstanceIds = [instance_id])    foo = response['Reservations'][0]['Instances'][0]['NetworkInterfaces'][0]['Association']['PublicDnsName']    return foofoo = get_name(instance_id)print (foo)我遇到的問題是在這一行foo=image.wait_until_exists('self',Filters=[{'Name':'state','Values':'avaialable'}])有很多代碼我已經(jīng)注釋掉了,但這就是我試圖解決這個錯誤的原因,但事情沒有奏效。請查看代碼并讓我知道我應(yīng)該更改什么以使其按預(yù)期工作。我想在ec2資源正在等待啟動的同時在idel shell窗口上打印一些東西,即它的狀態(tài)從停止變?yōu)檫\行。這是我在這里無法實現(xiàn)的。
查看完整描述

1 回答

?
嚕嚕噠

TA貢獻1784條經(jīng)驗 獲得超7個贊

異常明確指出該Values值必須是列表/元組。有問題的代碼行應(yīng)該更改為使用如下列表。我也修復(fù)了錯字,盡管這不是您眼前問題的根源。


foo=image.wait_until_exists('self',Filters=[{'Name':'state','Values':['available']}])


查看完整回答
反對 回復(fù) 2021-06-01
  • 1 回答
  • 0 關(guān)注
  • 149 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號