in libcloud/compute/drivers/cloudsigma.py [0:0]
def _to_node(self, data):
id = data["uuid"]
name = data["name"]
state = self.NODE_STATE_MAP.get(data["status"], NodeState.UNKNOWN)
public_ips = []
private_ips = []
extra = {
"cpus": data["cpu"] / 2000,
"memory": data["mem"] / 1024 / 1024,
"nics": data["nics"],
"vnc_password": data["vnc_password"],
"meta": data["meta"],
"runtime": data["runtime"],
"drives": data["drives"],
}
# find image name and boot drive size
image = None
drive_size = 0
for item in extra["drives"]:
if item["boot_order"] == 1:
drive = self.ex_get_drive(item["drive"]["uuid"])
drive_size = drive.size
image = "{} {}".format(
drive.extra.get("distribution", ""), drive.extra.get("version", "")
)
break
# try to find if node size is from example sizes given by CloudSigma
try:
kwargs = SPECS_TO_SIZE[(extra["cpus"], extra["memory"], drive_size)]
size = CloudSigmaNodeSize(**kwargs, driver=self)
except KeyError:
id_to_hash = str(extra["cpus"]) + str(extra["memory"]) + str(drive_size)
size_id = hashlib.md5(id_to_hash.encode("utf-8")).hexdigest() # nosec
size_name = "custom, {} CPUs, {}MB RAM, {}GB disk".format(
extra["cpus"], extra["memory"], drive_size
) # noqa
size = CloudSigmaNodeSize(
id=size_id,
name=size_name,
cpu=extra["cpus"],
ram=extra["memory"],
disk=drive_size,
bandwidth=None,
price=0,
driver=self,
)
for nic in data["nics"]:
_public_ips, _private_ips = self._parse_ips_from_nic(nic=nic)
public_ips.extend(_public_ips)
private_ips.extend(_private_ips)
node = Node(
id=id,
name=name,
state=state,
public_ips=public_ips,
image=image,
private_ips=private_ips,
driver=self,
size=size,
extra=extra,
)
return node