ó £¼1Yc@sØddlZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd l m Z dd lmZejeƒZd ejfd „ƒYZdS(iÿÿÿÿN(tdistros(thelpers(tlog(tutil(tssh_util(tnet_util(t rhel_util(taix_util(t PER_INSTANCE(t HostnameConftDistrocBs×eZdZdZd„Zd„Zed„Zd„Zdd„Z d„Z d„Z d „Z dd „Zd „Zd „Zd „Zd„Zd„Zddd„Zd„Zd„Zd„Zd„Zd„ZRS(s /etc/hostss/etc/resolv.confcCs8tjj||||ƒtj|ƒ|_d|_dS(Ntaix(RR t__init__RtRunnerst_runnertosfamily(tselftnametcfgtpaths((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyR %scCs|jdd|ƒdS(Ntinstalltpkgs(tpackage_command(Rtpkglist((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pytinstall_packages-scCs3|j|ƒ}|r/|j|ƒ|j|ƒStS(N(t_write_networkt_bring_down_interfacest_bring_up_interfacestFalse(Rtsettingstbring_upt dev_names((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyt apply_network0s   cCsctj|ƒ}tj|jƒd||fGHg}g}|jƒ}t}t}t}d} tj ƒtj ƒtj ƒxd|j ƒD]V\} } d} dg} dg}| dkrŸtj | ƒ}| jdƒdkrÿtj|| |ƒt}t}qŸ| jd|gƒ|jd|gƒ| dtkrsid d 6d d 6}d } t}| dkrj|} qsd} n| dtkr idd 6dd 6}d } nxh| j ƒD]Z\}}||kr­|r­t|tƒr­| j|||ƒ|j|||ƒq­q­W| rŸy$tj| d|ƒtjdƒWntk rP}|‚nXd| kr2| ddkrïtjd|ddgdtddd gƒtjdƒtj|ƒ}tjdd|dgdtddd gƒtjdƒntjdd|d| dgdtddd gƒtjdƒn|dkrœ| dtkrjtjd| jdƒƒn| dtkr™tjd| jdƒƒq™qœqŸnd| kr¿|j| dƒnd | kr‰|j| d ƒq‰q‰W|rötjƒn|rtjƒtj| ƒn|r.t|ƒdksF|r_t|ƒdkr_tj|j||ƒn|S(!Ns3Translated ubuntu style network settings %s into %sis/usr/sbin/chdevtlot bootprototdhcps-ltipv6s -anetaddr6=taddresss -aprefixlen=tnetmaskitanytipv4s -anetaddr=s -anetmask=t logstringitmtuiÜs /etc/ifconfigtdowntdetachtcapturetrcss-ajumbo_frames=yess-amtu=ten0tgatewaysdns-nameserverss dns-search( Rttranslate_networkRtremove_resolve_conf_filetresolve_conf_fntkeystTrueRtNonetdisable_dhcpcdtdisable_ndpd_hosttdisable_autoconf6t iteritemsttranslate_devnametgett config_dhcptextendt isinstancet basestringtappendRtsubpttimetsleept Exceptiontlogical_adpt_namet add_routet enable_dhcpcdtenable_ndpd_hosttenable_autoconf6tlentupdate_resolve_conf_file(RRtentriest nameserverst searchserversRtcreate_dhcp_filet run_dhcpcdt run_autoconf6tipv6_interfacetdevtinfotrun_cmdt chdev_cmdt log_chdev_cmdtaix_devt chdev_optstkeytvaltet aix_adapter((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyR9s˜              !  + +3 %    cCs tjddt|ƒgƒdS(Ns/usr/bin/chlangs-M(RRBtstr(Rtlocaletout_fn((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyt apply_locale™scCs`tjdddddt|ƒgƒ|jdƒd}tjdd t|ƒdd !gƒdS( Ns/usr/sbin/chdevs-ltinet0s-as hostname=t.is/usr/bin/unames-Si (RRBR_tsplit(RthostnameRat shortname((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyt_write_hostnameœs&cCs|s |S|S(N((RRftfqdn((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyt_select_hostname¤scCs|j}||j|ƒfS(N(thostname_conf_fnt_read_hostname(Rthost_fn((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyt_read_system_hostname«s cCs0tjdgƒ\}}t|ƒr(|S|SdS(Ns/usr/bin/hostname(RRBRK(Rtfilenametdefaulttoutt_err((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyRl¯s cCs¼|dkrtSddtj|ƒddg}tjd||ƒyLtj|ƒ\}}tjdƒt |ƒrˆtj d||ƒntSWn(tj k r·tj td |ƒt SXdS( NR!s/usr/sbin/chdevs-ls-asstate=ups8Attempting to run bring up interface %s using command %sis(Running %s resulted in stderr output: %ss#Running interface command %s failed(R5RR;tLOGtdebugRRBRCRDRKtwarntProcessExecutionErrortlogexcR(Rt device_nametcmdt_outterr((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyt_bring_up_interface¶s   cCsP|r(d|kr(td|jƒ‚nx!|D]}|j|ƒs/tSq/WtS(Ntalls1Distro %s can not translate the device name "all"(t RuntimeErrorRR|RR5(Rt device_namestd((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyRÆs  cCs÷|dkrtStj|ƒ}tj|dƒdkrHtjdƒtSdd|ddg}tjd ||ƒyXtj |d d dgƒ\}}tjdƒt |ƒrÃtj d ||ƒntSWn(tj k ròtj td |ƒtSXdS(NR!tstateR+is/usr/sbin/chdevs-ls-as state=downs:Attempting to run bring down interface %s using command %sR.is(Running %s resulted in stderr output: %ss#Running interface command %s failed(R5RR;t get_if_attrRCRDRsRtRRBRKRuRvRwR(RRxt interfaceRyRzR{((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyt_bring_down_interfaceÎs"  !  cCso|r(d|kr(td|jƒ‚nd}x*|D]"}|j|ƒs5|d7}q5q5W|dkrktStS(NR}s1Distro %s can not translate the device name "all"ii(R~RR„R5R(RRt am_failedR€((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyRãs  cCsd|g}tj|ƒdS(Ns /usr/bin/chtz(RRB(RttzRy((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyt set_timezoneîs cCsÅ|dkrg}ndg}|jdƒ|jdƒ|r]t|tƒr]|j|ƒn%|r‚t|tƒr‚|j|ƒn|j|ƒtjd|ƒ}|j|ƒtj|dt ƒdS(Ntyums-ts-ys%s-%sR-( R6RAR?R_tlistR>Rtexpand_package_listRBR(RtcommandtargsRRyR((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyRòs       cCs&|jjd|jdgdtƒdS(Nsupdate-sourcest makecachetfreq(RtrunRR(R((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pytupdate_package_sourcessc KsÆtj|ƒr#tjd|ƒtSdg}dg}idd6dd6dd6d d 6d d 6d d6}dg}x’|jƒD]„\}}||kr{|r{t|tƒr{|j|||gƒ||krå|j||dgƒqÿ|j|||gƒq{q{Wd|ksd|kr8|j dƒ|j dƒn|j dƒ|j dƒ|j |ƒ|j |ƒtj d|ƒytj |d|ƒWn,t k rÁ} tj td|ƒ| ‚nXdS(Ns!User %s already exists, skipping.s/usr/sbin/useradds-dthomedirs-ctgecoss-gt primary_groups-Gtgroupss-stshells-et expiredatetpasswdtREDACTEDtno_create_hometsystems-d/nonexistents-msAdding user %sR)sFailed to create user %s(Rtis_userRsRURR:R?R@R>RARtRBRERw( RRtkwargst adduser_cmdtlog_adduser_cmdt adduser_optst redact_optsR[R\R]((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pytadd_users@    !      cKsÁ|j||d|kr=|dr=|j||dƒn|jdtƒr_|j|ƒnd|kr‚|j||dƒnd|kr½t|dƒp¡g}tj||ddƒntS(sÐ Creates users for the system using the GNU passwd tools. This will work on an GNU system. This should be overriden on distros where useradd is not desirable or not available. tplain_text_passwdt lock_passwdtsudotssh_authorized_keystoptionsN( R¡t set_passwdR<R5R£twrite_sudo_rulestsetRtsetup_user_keysR6(RRRœR4((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyt create_userAs  cCsMytjdd|gƒWn,tk rH}tjtd|ƒ|‚nXdS(sL Lock the password of a user, i.e., disable password logins s/usr/bin/chusersaccount_locked=trues&Failed to disable password for user %sN(RRBRERwRs(RRR]((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyR£]s cCs÷d|g}tj|ƒr/tjd|ƒnFy"tj|ƒtjd|ƒWn!tk rttjd|ƒnXt|ƒdkróxi|D]^}tj |ƒs¼tjd||ƒqŽntjdd||gƒtjd ||fƒqŽWndS( Ns/usr/bin/mkgroups(Skipping creation of existing group '%s'sCreated new group %ssFailed to create group %sisCUnable to add group member '%s' to group '%s'; user does not exist.s/usr/sbin/usermods-GsAdded user '%s' to group '%s'( Rtis_groupRsRuRBRURERwRKR›(RRtmemberst group_add_cmdtmember((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyt create_groupjs    N(t__name__t __module__RkR3R RR5R RR6RbRhRjRnRlR|RR„RR‡RRR¡R«R£R°(((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyR !s,   `           /  (RCt cloudinitRRRtloggingRRtcloudinit.distrosRRRtcloudinit.settingsRt"cloudinit.distros.parsers.hostnameR t getLoggerR±RsR (((sB/opt/freeware/lib/python2.7/site-packages/cloudinit/distros/aix.pyts