def __init__(self, client, data, complete=True): datacenter = data.get('datacenter') if datacenter is not None: data['datacenter'] = BoundDatacenter(client._client.datacenters, datacenter) volumes = data.get('volumes', []) if volumes: volumes = [BoundVolume(client._client.volumes, {"id": volume}, complete=False) for volume in volumes] data['volumes'] = volumes image = data.get("image", None) if image is not None: data['image'] = BoundImage(client._client.images, image) iso = data.get("iso", None) if iso is not None: data['iso'] = BoundIso(client._client.isos, iso) server_type = data.get("server_type") if server_type is not None: data['server_type'] = BoundServerType(client._client.server_types, server_type) public_net = data.get("public_net") if public_net: ipv4_address = IPv4Address(**public_net['ipv4']) ipv6_network = IPv6Network(**public_net['ipv6']) floating_ips = [BoundFloatingIP(client._client.floating_ips, {"id": floating_ip}, complete=False) for floating_ip in public_net['floating_ips']] data['public_net'] = PublicNetwork(ipv4=ipv4_address, ipv6=ipv6_network, floating_ips=floating_ips) super(BoundServer, self).__init__(client, data, complete)
def __init__(self, client, data, complete=True): datacenter = data.get('datacenter') if datacenter is not None: data['datacenter'] = BoundDatacenter(client._client.datacenters, datacenter) volumes = data.get('volumes', []) if volumes: volumes = [ BoundVolume(client._client.volumes, {"id": volume}, complete=False) for volume in volumes ] data['volumes'] = volumes image = data.get("image", None) if image is not None: data['image'] = BoundImage(client._client.images, image) iso = data.get("iso", None) if iso is not None: data['iso'] = BoundIso(client._client.isos, iso) server_type = data.get("server_type") if server_type is not None: data['server_type'] = BoundServerType(client._client.server_types, server_type) public_net = data.get("public_net") if public_net: ipv4_address = IPv4Address(**public_net['ipv4']) ipv6_network = IPv6Network(**public_net['ipv6']) floating_ips = [ BoundFloatingIP(client._client.floating_ips, {"id": floating_ip}, complete=False) for floating_ip in public_net['floating_ips'] ] firewalls = [ PublicNetworkFirewall(BoundFirewall(client._client.firewalls, {"id": firewall["id"]}, complete=False), status=firewall["status"]) for firewall in public_net.get("firewalls", []) ] data['public_net'] = PublicNetwork(ipv4=ipv4_address, ipv6=ipv6_network, floating_ips=floating_ips, firewalls=firewalls) private_nets = data.get("private_net") if private_nets: private_nets = [ PrivateNet(network=BoundNetwork(client._client.networks, {"id": private_net['network']}, complete=False), ip=private_net['ip'], alias_ips=private_net['alias_ips'], mac_address=private_net['mac_address']) for private_net in private_nets ] data['private_net'] = private_nets super(BoundServer, self).__init__(client, data, complete)