File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace : scaleway
44name : scaleway
5- version : 2.7.1
5+ version : 2.7.2
66readme : README.md
77authors :
88 - Ansible (https://github.com/ansible)
Original file line number Diff line number Diff line change 55 from scaleway import Client
66 from scaleway .instance .v1 import Server as InstanceServer
77 from scaleway .ipam .v1 import IpamV1API
8- from scaleway .vpc .v2 import VpcV2API
98except ImportError :
109 HAS_SCALEWAY_SDK = False
1110
1211
1312@dataclass
14- class VpcIps :
13+ class VpcIp :
1514 ipv4 : Optional [str ] = None
1615 ipv6 : Optional [str ] = None
1716
1817
1918def get_instance_private_ips (
2019 client : "Client" , servers : list ["InstanceServer" ]
21- ) -> Dict [str , VpcIps ]:
20+ ) -> Dict [str , VpcIp ]:
2221 """
2322 return a mapping of first found vpc IPs with the instance
2423 """
25- vpc_api = VpcV2API (client )
2624 ipam_api = IpamV1API (client )
2725
2826 vpc_ips = {}
2927
3028 for server in servers :
29+ vpc_ip = VpcIp ()
30+ vpc_ips [server .id ] = vpc_ip
3131 for pnic in server .private_nics :
32- server_pn = vpc_api .get_private_network (
33- private_network_id = pnic .private_network_id
34- )
35- vpc_ips [server .id ] = VpcIps
36-
37- for ip in ipam_api .list_i_ps (vpc_id = server_pn .vpc_id ).ips :
32+ for ip in ipam_api .list_i_ps_all (resource_id = pnic .id ):
3833 if ip .is_ipv6 :
39- vpc_ips [ server . id ] .ipv6 = ip .address .split ("/" )[0 ]
34+ vpc_ip .ipv6 = ip .address .split ("/" )[0 ]
4035 else :
41- vpc_ips [ server . id ] .ipv4 = ip .address .split ("/" )[0 ]
36+ vpc_ip .ipv4 = ip .address .split ("/" )[0 ]
4237
4338 return vpc_ips
You can’t perform that action at this time.
0 commit comments