in libcloud/compute/drivers/azure_arm.py [0:0]
def _to_node(self, data, fetch_nic=True, fetch_power_state=True):
private_ips = []
public_ips = []
nics = data["properties"]["networkProfile"]["networkInterfaces"]
if fetch_nic:
for nic in nics:
try:
n = self.ex_get_nic(nic["id"])
priv = n.extra["ipConfigurations"][0]["properties"].get("privateIPAddress")
if priv:
private_ips.append(priv)
pub = n.extra["ipConfigurations"][0]["properties"].get("publicIPAddress")
if pub:
pub_addr = self.ex_get_public_ip(pub["id"])
addr = pub_addr.extra.get("ipAddress")
if addr:
public_ips.append(addr)
except BaseHTTPError:
pass
state = NodeState.UNKNOWN
if fetch_power_state:
state = self._fetch_power_state(data)
else:
ps = data["properties"]["provisioningState"].lower()
if ps == "creating":
state = NodeState.PENDING
elif ps == "deleting":
state = NodeState.TERMINATED
elif ps == "failed":
state = NodeState.ERROR
elif ps == "updating":
state = NodeState.UPDATING
elif ps == "succeeded":
state = NodeState.RUNNING
node = Node(
data["id"],
data["name"],
state,
public_ips,
private_ips,
driver=self.connection.driver,
extra=data,
)
return node