|
|
@ -189,19 +189,13 @@ class Droplet(JsonfyMixIn):
|
|
|
|
def is_powered_on(self):
|
|
|
|
def is_powered_on(self):
|
|
|
|
return self.status == 'active'
|
|
|
|
return self.status == 'active'
|
|
|
|
|
|
|
|
|
|
|
|
def update_attr(self, attrs=None, times=5):
|
|
|
|
def update_attr(self, attrs=None):
|
|
|
|
if attrs:
|
|
|
|
if attrs:
|
|
|
|
for k, v in attrs.iteritems():
|
|
|
|
for k, v in attrs.iteritems():
|
|
|
|
setattr(self, k, v)
|
|
|
|
setattr(self, k, v)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
json = self.manager.show_droplet(self.id)
|
|
|
|
json = self.manager.show_droplet(self.id)
|
|
|
|
if not json['ip_address']:
|
|
|
|
if json['ip_address']:
|
|
|
|
if times > 0:
|
|
|
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
|
|
|
self.update_attr(times=times-1)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise TimeoutError('No ip is found.', self.id)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.update_attr(json)
|
|
|
|
self.update_attr(json)
|
|
|
|
|
|
|
|
|
|
|
|
def power_on(self):
|
|
|
|
def power_on(self):
|
|
|
@ -221,6 +215,8 @@ class Droplet(JsonfyMixIn):
|
|
|
|
time.sleep(min(20, end_time-time.time()))
|
|
|
|
time.sleep(min(20, end_time-time.time()))
|
|
|
|
self.update_attr()
|
|
|
|
self.update_attr()
|
|
|
|
if self.is_powered_on():
|
|
|
|
if self.is_powered_on():
|
|
|
|
|
|
|
|
if not self.ip_address:
|
|
|
|
|
|
|
|
raise TimeoutError('No ip is found.', self.id)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
raise TimeoutError('Wait for droplet running timeout', self.id)
|
|
|
|
raise TimeoutError('Wait for droplet running timeout', self.id)
|
|
|
|
|
|
|
|
|
|
|
|