Viewing File: /usr/lib/python2.7/site-packages/cloudinit/sources/helpers/digitalocean.pyo

ó
oBú]c@sÄddlZddlZddlmZddlmZddlmZddlmZidd6dd	6Z	ej
eƒZdd
„Zd„Zdd„Zd
„Zdddd„Zd„ZdS(iÿÿÿÿN(tlog(tnet(t
url_helper(tutilteth0tpublicteth1tprivatecCs!|s"tƒ}tjd|ƒn|s7tdƒ‚ndjtjddƒtjddƒƒ}dd	d
|d|g}ddd
d|dg}tjdƒs¯tdƒ‚nyAtj	|ƒtjd||ƒtj	|ƒtjd|ƒWn*t
k
rtjtd||ƒ‚nX|S(síBring 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.
    s,selected interface '%s' for reading metadatasPunable to find interfaces to access themeta-data server. This droplet is broken.s169.254.{0}.{1}/16ii¨iiÿtiptaddrtaddtdevtlinktsettups4No 'ip' command available to configure ip4LL addresss#assigned ip4LL address '%s' to '%s'sbrought device '%s' upsRip4LL address assignment of '%s' to '%s' failed. Droplet networking will be broken(tget_link_local_nictLOGtdebugtRuntimeErrortformattrandomtrandintRtwhichtsubpt	Exceptiontlogexc(tnicR	tip_addr_cmdtip_link_cmd((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/helpers/digitalocean.pytassign_ipv4_link_locals*	



cCsKgtjƒD]}tj|ƒr
|^q
}|s8dSt|dd„ƒS(NtkeycSstj|dƒS(Ntifindex(tcloudnettread_sys_net_int(td((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/helpers/digitalocean.pyt<lambda><s(R tget_devicelisttis_physicaltNonetmin(tftnics((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/helpers/digitalocean.pyR8s.cCsŠ|stjdƒdStjdƒdddd|g}y!tj|ƒtjd|ƒWn)tk
r…}tjtd	||ƒnXdS(
szRemove the ip4LL address. While this is not necessary, the ip4LL
       address is extraneous and confusing to users.
    sLno link_local address interface defined, skipping link local address cleanupNscleaning up ipv4LL addressRR	tflushRsremoved ip4LL addresses from %ss)failed to remove ip4LL address from '%s'.(RRRRRR(RRte((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/helpers/digitalocean.pytdel_ipv4_link_local?s


cCsýd„}g}tjƒ}tjd|ƒx‰|D]}||d}tjd|ƒ|jdƒ}||krŠtd||fƒ‚n|j|ƒ}|jddƒ}	tj|	|ƒ}
|
|kråtjd	|	|||
ƒnd
}tj|||ƒidd6|d6|
d
6}g}
xgdD]_}|j|dƒ}|sJq&n||ƒ}|	dksnd|krx|d=n|
j|ƒq&W|
|d<|j|ƒtjd|
|ƒq2W|rëtjd|ƒ|jidd6|d6ƒnidd6|d6S(sÅ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'}
           ]
        }
    cSs‹idd6dd6|jdƒd6|jdƒd6}d|jdƒkrtd	j|jdƒ|jd
ƒƒ|d<n|jdƒ|d<|S(Ntstaticttypetautotcontrolt
ip_addresstaddresstgatewayt:s{0}/{1}tcidrtnetmask(tgetR(tpcfgtsubpart((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/helpers/digitalocean.pyt_get_subnet_partqs
snic mapping: %sisconsidering %stmacsVDid not find network interface on system with mac '%s'. Cannot apply configuration: %sR.tunknowns6Found %s interface '%s' on '%s', assigned name of '%s'sfFound interface '%s' on '%s', which is not a public or private interface. Using default system naming.tphysicaltmac_addresstnametipv4tipv6tanchor_ipv4tanchor_ipv6RtanchorR3tsubnetssnic '%s' configuration: %ssadded dns servers: %st
nameserverR2itversiontconfig(R@RARBRCN(	R tget_interfaces_by_macRRR7RtNIC_MAPR&tappend(RHtdns_serversR:tnic_configstmacs_to_nicstnRR>t
sysfs_nametnic_typetif_nametmsgtncfgREtnetdeft
raw_subnettsub_part((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/helpers/digitalocean.pytconvert_network_configurationTsL	
	





iicCsVtj|d|d|d|ƒ}|jƒs@td|ƒ‚ntj|jjƒƒS(Nttimeouttsec_betweentretriessunable to read metadata at %s(RtreadurltokRtjsontloadstcontentstdecode(turlRYRZR[tresponse((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/helpers/digitalocean.pyt
read_metadata´s
cCsvtjdƒ}|dkr%tdfStjdƒ}|rMtjd|ƒnd}tj|ƒt|ƒ‚t|fS(Nssystem-manufacturertDigitalOceanssystem-serial-numbers8system identified via SMBIOS as DigitalOcean Droplet: %ss¦system 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/new(	Rt
read_dmi_datatFalseR&RRtcriticalRtTrue(tvendor_namet
droplet_idRS((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/helpers/digitalocean.pytread_sysinfo¼s
	

(R^Rt	cloudinitRtloggingRR RRRJt	getLoggert__name__RR&RRR,RXRdRl(((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/helpers/digitalocean.pyt<module>s&		`
Back to Directory File Manager