/usr/share/netplan/netplan/cli/commands/__pycache__
NameSizeModeActions
apply.cpython-38.pyc91460644editdlrm
generate.cpython-38.pyc20170644editdlrm
get.cpython-38.pyc22130644editdlrm
info.cpython-38.pyc17510644editdlrm
ip.cpython-38.pyc46330644editdlrm
migrate.cpython-38.pyc106360644editdlrm
set.cpython-38.pyc55720644editdlrm
sriov_rebind.cpython-38.pyc17010644editdlrm
try_command.cpython-38.pyc58770644editdlrm
__init__.cpython-38.pyc8160644editdlrm
Edit: /usr/share/netplan/netplan/cli/commands/__pycache__/migrate.cpython-38.pyc (10636B)
U ø)/bóOã@s–dZddlZddlZddlZddlZddlmZzddlZdZWnek rXdZYnXddl m Z ddl Z ddl m mZGdd„dejƒZdS) znetplan migrate command lineéN)ÚglobFT)Ú OrderedDictcsVeZdZ‡fdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z ddd„Z ‡Z S)ÚNetplanMigratecstƒjddddddS)NZmigratez/Migration of /etc/network/interfaces to netplanT)Ú command_idÚ descriptionÚleafÚtesting)ÚsuperÚ__init__©Úself©Ú __class__©ú2/usr/share/netplan/netplan/cli/commands/migrate.pyr %s ýzNetplanMigrate.__init__cCsÐd|krfd|kri|d<d|dkr0g|dd<|d d¡D] }|sHq>|dd|g7<q>|d=d|krÌd|kr~i|d<d|dkr–g|dd<|d d¡D] }|s®q¤|dd|g7<q¤|d=dS)zÂParse dns options (dns-nameservers and dns-search) from if_options (an interface options dict) into the interface configuration if_config Mutates the arguments in place. zdns-nameserversZ nameserversÚ addressesú z dns-searchÚsearchN)Úsplit)r Ú if_optionsÚ if_configÚnsÚdomainrrrÚparse_dns_options+s(    z NetplanMigrate.parse_dns_optionsc CsŽd|krŠzt|dƒ}Wn0tk rHt d||d¡t d¡YnXd|kr||d|ks|t d|||d¡t d¡||d<|d=dS)z”Parse out the MTU. Operates the same way as parse_dns_options iface is the name of the interface, used only to print error messages Úmtuz%s: cannot parse "%s" as an MTUéz0%s: tried to set MTU=%d, but already have MTU=%dN)ÚintÚ ValueErrorÚloggingÚerrorÚsysÚexit)r ÚifacerrrrrrÚ parse_mtuHs zNetplanMigrate.parse_mtucCsXd|krTd|krB|d|dksBt d||d|d¡t d¡|d|d<|d=dS)z°Parse out the manually configured MAC. Operates the same way as parse_dns_options iface is the name of the interface, used only to print error messages Z hwaddressÚ macaddressz0%s: tried to set MAC %s, but already have MAC %srN)rrr r!)r r"rrrrrÚparse_hwaddress[sÿ  zNetplanMigrate.parse_hwaddresscCsV|jjddd|jjdddd|j|_| ¡trJt d¡t  d ¡|  ¡dS) Nz --root-dirzOSearch for and generate configuration files in this root directory instead of /)Úhelpz --dry-runÚ store_truezQPrint converted netplan configuration to stdout instead of writing/changing files)Úactionr&z¥The `yaml` Python package couldn't be imported, and is needed for the migrate command. To install it on Debian or Ubuntu-based system, run `apt install python3-yaml`é) ÚparserÚ add_argumentÚcommand_migrateÚfuncÚ parse_argsÚNO_YAMLrrr r!Ú run_commandr rrrÚrunjsÿ ÿ  zNetplanMigrate.runc Cs i}z| |jpd¡\}}Wn:tk rV}zt t|ƒ¡t d¡W5d}~XYnX| ¡D]Œ\}}| ¡D]x\}}t  d|||¡||krªt d|¡t d¡|ddkrÄt  d|¡qr|ddkrl|  d i¡  d i¡  |i¡} |  |d | ¡|  ||d | ¡|d r@t d |d   |d  ¡¡¡t d¡|dkrTd| d<n|dksbt‚d| d<qr|ddkrÐ|  d i¡  d i¡  |i¡} d| kr¨g| d<|  |d | ¡| ||d | ¡|  ||d | ¡|dkrtdddgƒ} tddddgƒ} t|d  ¡ƒ} | | } | rx|  | ¡D] }t d|||¡t d¡q,| | D] }t d|||¡t d¡qVd|d krœt d|¡t d¡d|d dkrÒ|d d d¡d }|d d}nLd|d kröt d!|¡t d¡|d d}|d dd|d d}zt |¡}Wn@tjk rl}zt d"|||¡t d¡W5d}~XYnXztj|d#d$}Wn@tjk rÀ}zt d%|||¡t d¡W5d}~XYnX| dt|ƒdt|jƒg7<d|d krÎ|d d| d&<qì|dkst‚tdddd'gƒ} tdd(d)d*dd+d,d-gƒ} t|d  ¡ƒ} | | } | r²|  | ¡D] }t d|||¡t d¡qf| | D] }t d|||¡t d¡qd|d krÖt d|¡t d¡d|d dkr |d d d¡d }|d d}nLd|d kr0t d!|¡t d¡|d d}|d dd|d d}zt |¡}Wn@tjk r¦}zt d.|||¡t d¡W5d}~XYnXztj|d#d$}Wn@tjk rú}zt d/|||¡t d¡W5d}~XYnX| dt|ƒdt|jƒg7<d|d kr>|d d| d0<d'|d krì|d d'd1krhd#| d'<nf|d d'd2kr„d| d'<nJ|d d'd3kr®t d4|¡t d¡n t d5||d d'¡t d¡qrt d6||d¡t d¡qrq`tj  |jpdd7¡}|rØd|d d8<t |¡}|j r4t!|ƒn¢tj  |jpDdd9¡}zt "tj #|¡¡Wnt$k rvYnXz$t%|d:ƒ}| &|¡W5QRXWn,t$k rÈt d;|¡t d<¡YnXt 'd=|¡n t 'd>¡|j st 'd?||¡t (||d@¡dS)ANÚrzConverting %s family %s %sz.%s: non-automatic interfaces are not supportedÚmethodÚloopbackzIgnoring loopback interface %sÚdhcpÚnetworkÚ ethernetsÚoptionsz2%s: option(s) %s are not supported for dhcp methodz, ÚinetTZdhcp4Úinet6Zdhcp6ÚstaticrZaddressZnetmaskZgatewayZ broadcastZmetricZ pointopointZscopez%s: unsupported %s option "%s"z%s: unknown %s option "%s"z(%s: no address supplied in static methodú/rzE%s: address does not specify prefix length, and netmask not specifiedz-%s: error parsing "%s" as an IPv4 address: %sF)Ústrictz-%s: error parsing "%s" as an IPv4 network: %sZgateway4Z accept_raZmediaZautoconfZprivextzpreferred-lifetimez dad-attemptsz dad-intervalz-%s: error parsing "%s" as an IPv6 address: %sz-%s: error parsing "%s" as an IPv6 network: %sZgateway6Ú0Ú1Ú2z(%s: netplan does not support accept_ra=2z#%s: unexpected accept_ra value "%s"z%s: method %s is not supportedzetc/network/interfacesÚversionzetc/netplan/10-ifupdown.yamlÚxzC%s already exists; remove it if you want to run the migration againézmigration complete, wrote %sz>ifupdown does not configure any interfaces, nothing to migratez#renaming %s to %s.netplan-convertedz.netplan-converted))Úparse_ifupdownÚroot_dirrrrÚstrr r!ÚitemsÚdebugÚ setdefaultrr%ÚjoinÚkeysÚAssertionErrorr#ÚsetÚ intersectionrÚ ipaddressZ IPv4AddressZAddressValueErrorZ IPv4NetworkZNetmaskValueErrorZ prefixlenZ IPv6AddressZ IPv6NetworkÚosÚpathÚyamlÚdumpÚdry_runÚprintÚmakedirsÚdirnameÚFileExistsErrorÚopenÚwriteÚinfoÚrename)r Znetplan_configÚifacesZ auto_ifacesÚer"Z family_configZfamilyÚconfigÚcZsupported_optsZunsupported_optsÚoptsZbad_optsZ unsupportedÚunknownZ addr_specZnet_specZipaddrÚaZipnetrZ netplan_yamlÚdestÚfrrrr,xs0    ÿ         ÿ  $ ÿ   ÿ  $     ÿ       zNetplanMigrate.command_migratec CsLdd„}g}t|ƒd}zt|d|ƒî}t d|j¡|D]Ô}| ¡}|r@| d¡r\q@| d¡rÄt d¡}||t j   |j¡|ƒ} t   | ¡D]0}|  |¡r|| |t j  | |d …|¡¡7}qq@| d ¡r t||t j   |j¡|ƒƒD]}|| |||d …¡7}qêq@| |¡q@W5QRXWn$tk rFt d ||¡YnX|S) zvReturn normalized lines from ifupdown config This resolves "source" and "source-directory" includes. cSs.| ¡d}| d¡r||S|d|SdS)Nr)r<)rÚ startswith)ÚrootdirÚcurdirÚlineÚargrrrÚexpand_source_argGs  zCNetplanMigrate._ifupdown_lines_from_file..expand_source_argr)r<z reading %sú#zsource-directory z^[a-zA-Z0-9_-]+$Nzsource z%s/%s does not exist, ignoring)ÚlenrYrrHÚnameÚstriprfÚreÚcompilerPrQrWÚlistdirÚmatchÚ_ifupdown_lines_from_filerJrÚappendÚFileNotFoundError) r rgrQrkÚlinesZ rootdir_lenreriZvalid_reÚdrrrrtBs.    & z(NetplanMigrate._ifupdown_lines_from_filer<c Csädddddddœ}| |d¡}tƒ}tƒ}d}d}|D]”}| ¡} z&|| d} t d| | ¡d}d}Wn`tk rÊ|r¶t d||¡|jdd d|||d | d<Yq6ntd | dƒ‚YnXt| ƒ| dkrútd | | dt| ƒdfƒ‚| dd kr|  | d¡q6| ddkr0tdƒ‚q6| ddkr@q6| ddkr¼| ddkrltd| dƒ‚| ddkrŠtd| dƒ‚| d}| d}| didœ|  | dtƒ¡|<q6t d| dƒ‚q6t d||¡||fS)uWParse ifupdown configuration. Return (iface_name → family → {method, options}, auto_ifaces: set) tuple on successful parsing, or a ValueError when encountering an invalid file or ifupdown features which are not supported (such as "mapping"). options is itself a dictionary option_name → value. r)rC)Úautoú allow-autoú allow-hotplugÚmappingú no-scriptsr"z/etc/network/interfacesNrz$line fields %s (expected length: %i)z$in_options %s, parsing as option: %s)Úmaxsplitr8zUnknown stanza type %sz0Expected %i fields for stanza type %s but got %i)ryrzr{r|zmapping stanza is not supportedr}r"r)r9r:zUnknown address family %s)r4r;r5zUnsupported method %s)r3r8z!stanza type %s is not implementedz,final parsed interfaces: %s; auto ifaces: %s) rtrrMrrrHÚKeyErrorrrmÚaddrIÚNotImplementedError) r rgZfieldlenrwr]ryZ in_optionsZ in_familyriÚfieldsZexp_lenrrrrDhsP    $ÿ "zNetplanMigrate.parse_ifupdown)r<) Ú__name__Ú __module__Ú __qualname__r rr#r%r1r,rtrDÚ __classcell__rrr rr$s K&r)Ú__doc__rrPr rprrRr/Ú ImportErrorÚ collectionsrrOÚnetplan.cli.utilsÚcliÚutilsÚNetplanCommandrrrrrÚs