mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #175 from runyaga/develop
check if vm in running state
This commit is contained in:
commit
ba10895d5a
@ -51,6 +51,7 @@ import logging
|
||||
import socket
|
||||
|
||||
# Import libcloud
|
||||
from libcloud.compute.base import NodeState
|
||||
from libcloud.compute.types import Provider
|
||||
from libcloud.compute.providers import get_driver
|
||||
from libcloud.compute.deployment import MultiStepDeployment, ScriptDeployment, SSHKeyDeployment
|
||||
@ -193,13 +194,14 @@ def create(vm_):
|
||||
return False
|
||||
|
||||
not_ready = True
|
||||
nr_count = 0
|
||||
nr_count = 50
|
||||
log.debug('Looking for IP addresses')
|
||||
while not_ready:
|
||||
nodelist = list_nodes()
|
||||
private = nodelist[vm_['name']]['private_ips']
|
||||
public = nodelist[vm_['name']]['public_ips']
|
||||
if private and not public:
|
||||
running = nodelist[vm_['name']]['state'] == NodeState.RUNNING
|
||||
if running and private and not public:
|
||||
log.warn('Private IPs returned, but not public... checking for misidentified IPs')
|
||||
for private_ip in private:
|
||||
private_ip = preferred_ip(vm_, [private_ip])
|
||||
@ -214,15 +216,15 @@ def create(vm_):
|
||||
if ssh_interface(vm_) == 'private_ips' and data.private_ips:
|
||||
break
|
||||
|
||||
if public:
|
||||
if running and public:
|
||||
data.public_ips = public
|
||||
not_ready = False
|
||||
|
||||
nr_count += 1
|
||||
if nr_count > 50:
|
||||
nr_count -= 1
|
||||
if nr_count == 0:
|
||||
log.warn('Timed out waiting for a public ip, continuing anyway')
|
||||
break
|
||||
time.sleep(1)
|
||||
time.sleep(nr_count)
|
||||
|
||||
if ssh_interface(vm_) == 'private_ips':
|
||||
ip_address = preferred_ip(vm_, data.private_ips)
|
||||
|
@ -29,6 +29,7 @@ import socket
|
||||
import time
|
||||
|
||||
# Import libcloud
|
||||
from libcloud.compute.base import NodeState
|
||||
from libcloud.compute.types import Provider
|
||||
from libcloud.compute.providers import get_driver
|
||||
from libcloud.compute.deployment import MultiStepDeployment, ScriptDeployment, SSHKeyDeployment
|
||||
@ -122,13 +123,15 @@ def create(vm_):
|
||||
return False
|
||||
|
||||
not_ready = True
|
||||
nr_count = 0
|
||||
nr_count = 50
|
||||
log.debug('Looking for IP addresses')
|
||||
while not_ready:
|
||||
nodelist = list_nodes()
|
||||
private = nodelist[vm_['name']]['private_ips']
|
||||
public = nodelist[vm_['name']]['public_ips']
|
||||
if private and not public:
|
||||
running = nodelist[vm_['name']]['state'] == NodeState.RUNNING
|
||||
|
||||
if running and private and not public:
|
||||
log.warn('Private IPs returned, but not public... checking for misidentified IPs')
|
||||
for private_ip in private:
|
||||
private_ip = preferred_ip(vm_, [private_ip])
|
||||
@ -143,15 +146,15 @@ def create(vm_):
|
||||
if ssh_interface(vm_) == 'private_ips' and data.private_ips:
|
||||
break
|
||||
|
||||
if public:
|
||||
if running and public:
|
||||
data.public_ips = public
|
||||
not_ready = False
|
||||
|
||||
nr_count += 1
|
||||
if nr_count > 50:
|
||||
nr_count -= 1
|
||||
if nr_count == 0:
|
||||
log.warn('Timed out waiting for a public ip, continuing anyway')
|
||||
break
|
||||
time.sleep(1)
|
||||
time.sleep(nr_count)
|
||||
|
||||
if ssh_interface(vm_) == 'private_ips':
|
||||
ip_address = preferred_ip(vm_, data.private_ips)
|
||||
|
Loading…
Reference in New Issue
Block a user