x[hddlZddlZddlZddlmZddlmZddlmZmZdddZ eje Z ddZ d Zdd Zd Zdd Zd Zy)N)dmi)net) url_helperutileth0eth1)publicprivatec|s!t|}tjd||s tddj t j ddt j dd} |jj|||jj|tjd|||S#t$rtjtd ||wxYw) zBring up NIC using an address using link-local (ip4LL) IPs. On DigitalOcean, the link-local domain is per-droplet routed, so there is no risk of collisions. However, to be more safe, the ip4LL address is random. z,selected interface '%s' for reading metadatazPunable to find interfaces to access themeta-data server. This droplet is broken.z169.254.{0}.{1}/16rz&brought device '%s' up with address %szRip4LL address assignment of '%s' to '%s' failed. Droplet networking will be broken) get_link_local_nicLOGdebug RuntimeErrorformatrandomrandintnet_opsadd_addrlink_up Exceptionrlogexc)distronicaddrs H/usr/lib/python3/dist-packages/cloudinit/sources/helpers/digitalocean.pyassign_ipv4_link_localrs  ( @#F  8  & &q#q# 6 D T*s# :CF J   1     s ,AB<<'C#ctjDcgc]}|jj|r|!}}|syt |dScc}w)Nc.tj|dS)Nifindex)cloudnetread_sys_net_int)ds rz$get_link_local_nic..@s8#<#| | d<|j| tjd| | 1|r*tjd||jd|dd|dS)a}Convert the DigitalOcean Network description into Cloud-init's netconfig format. Example JSON: {'public': [ {'mac': '04:01:58:27:7f:01', 'ipv4': {'gateway': '45.55.32.1', 'netmask': '255.255.224.0', 'ip_address': '45.55.50.93'}, 'anchor_ipv4': { 'gateway': '10.17.0.1', 'netmask': '255.255.0.0', 'ip_address': '10.17.0.9'}, 'type': 'public', 'ipv6': {'gateway': '....', 'ip_address': '....', 'cidr': 64}} ], 'private': [ {'mac': '04:01:58:27:7f:02', 'ipv4': {'gateway': '10.132.0.1', 'netmask': '255.255.0.0', 'ip_address': '10.132.75.35'}, 'type': 'private'} ] } cdd|jd|jdd}d|jdvr5dj|jd|jd|d <|S|jd |d <|S) Nstaticauto ip_addressgateway)typecontroladdressr8:z{0}/{1}cidrr;netmask)getr)pcfgsubparts r_get_subnet_partz7convert_network_configuration.._get_subnet_partusxx -xx *   $((<( (!*!1!1&(8"GI  "&)!4GI r'znic mapping: %srzconsidering %smacz3Did not find network interface on system with mac 'z'. Cannot apply configuration: r9unknownz6Found %s interface '%s' on '%s', assigned name of '%s'zfFound interface '%s' on '%s', which is not a public or private interface. Using default system naming.physical)r9 mac_addressname)ipv4ipv6 anchor_ipv4 anchor_ipv6Nr anchorr8subnetsznic '%s' configuration: %szadded dns servers: %s nameserver)r9r;r )versionconfig)r#get_interfaces_by_macrrr?rNIC_MAPappend)rP dns_serversrB nic_configs macs_to_nicsnrrF sysfs_namenic_typeif_namemsgncfgrMnetdef raw_subnetsub_parts rconvert_network_configurationr`Xs:"K113LII. 3?Qil "C(ggen l *%  "%%k2 7769-++h 3 j IIH  E  IIc; 3&  D %F.J' 3H8#x6'9Y' NN8 $ %"Y4  .>g3?j );7L[IJK 00r'ctj||||}|jstd|zt j |j jS)N)timeout sec_betweenretrieszunable to read metadata at %s)rreadurlokrjsonloadscontentsdecode)urlrbrcrdresponses r read_metadatarmsU!! W+wH ;;=:S@AA ::h''..0 11r'ctjd}|dk7rytjd}|rtjd|d|fSd}tj |t |)Nzsystem-manufacturer DigitalOcean)FNzsystem-serial-numberz8system identified via SMBIOS as DigitalOcean Droplet: %szsystem identified via SMBIOS as a DigitalOcean Droplet, but did not provide an ID. Please file a support ticket at: https://cloud.digitalocean.com/support/tickets/newT)r read_dmi_datarrcriticalr) vendor_name droplet_idr[s r read_sysinfortsw ##$9:Kn$""#9:J F   *  A S3r')N)ru)rgloggingr cloudinitrrr#rrrR getLogger__name__rrrr2r`rmrtr'rr|sX   %& /g!#LLN*k1\2r'