C#Wc@sdZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZmZmZmZmZmZmZddlmZmZmZdd lmZmZdd lmZdd lmZdd l m!Z!m"Z"e#a$d Z%dZ&dZ'dZ(dZ)dZ*dZ+ej,dZ-dZ.dZ/defdYZ0defdYZ1defdYZ2defdYZ3dZ4dS(s Set support credential values iN(t InstallEngine(tINSTALL_LOGGER_NAME(t support_auth(tSystemConfiguration(t_tDIRECTtHUBtNOSVCtNOCFGNETtPROXYtSCI_HELP(t BaseScreent SkipExceptiont UIMessage(t EditFieldt PasswordField(tListItem(t WindowArea(tfit_text_truncatet textwidthcCs|s dSt|S(N(tNonetstr(tstrg((s support.pyt9scCs|s dSt|S(Nt(R(R((s support.pyR:si(iiis^\**$cCs)|s tStj|o(t||kS(s. Returns True if a string contains only stars.(tFalset_STARStmatchtlen(Rtlength((s support.pyt _is_fillerFscCsd|S(s'Returns a filler string of given lengtht*((R((s support.pyt _set_fillerMstSupportMOSScreencBseZdZedZedZedZedZedZedZ edZ e ded fZ d Z eZeZeZd ed Zd ZedZedZdZdZdZdZRS(s>Main Support screen. Prompts user for MOS email and password.sSupport - RegistrationsProvide your My Oracle Support credentials to be informed of security issues, initiate Oracle Configuration Manager, and enable Oracle Auto Service Requests.s:See http://www.oracle.com/goto/solarisautoreg for details.sEmail:sHEasier for you if you use your My Oracle Support email address/username.sYPlease enter your password if you wish to receive security updates via My Oracle Support.sMy Oracle Support password:s/%s/support_main.txttSupportis sPress F2 again to save anyway.c Cs#tdkr"tjtdantt|j||j|j \}|_ |_ |_ |_ t|_tddd|d|jddd|_t|_i|jtj6|jtj6|jtj6|_tjj|_|jjd td td|_ t!j"|j d tdS( Ns .sysconfigtlinesitcolumnsty_locitx_locit class_typetnot_found_is_errtset_unauth_mos_email(#tLOGGERRtloggingt getLoggerRtsuperR!t__init__t calc_sizest win_size_xtemail_label_widthtpassword_label_widthtemail_edit_widthtpassword_edit_widthRt window_areat win_size_yt error_areaRterror_overridet on_arrow_keytcursestKEY_UPtKEY_DOWNt KEY_ENTERtadd_keysRt get_instancetdoctget_descendantsRtTruetscRtinit_support_fields(tselftmain_wintfull_field_width((s support.pyR.ks -   cCse|tjtj}ttjd}ttjd}||}|||}|||||fS(sReturn sizes of MOS cred field params used in this and other screens Args: win_size_x: width of the window Returns: full_field_width: width of the window available for fields email_label_width: width of the email label (to left of email field) password_label_width: width of the password label email_edit_width: width of email field password_edit_width: width of password field i(R!t ITEM_OFFSETt RIGHT_MARGINRt EMAIL_LABELtPASSWORD_LABEL(R0RGR1R2R3R4((s support.pyR/s    cCs@tj|\}}}} } t} || _|| _d| _|| _t| d|dtj} | j|7_| | _t | t | _ t | d|d|} |d7}|| _|| _d| _|| _t| d|dtj }| j|7_| | _t | t | _ t| d|d|}| || fS(sOFunction to show MOS credential fields in other screens. Provides a convenient way for other screens to append MOS email and password fields for display. As such, labeling and embellishments are minimal. Args: center_win: main window all widgets are attached to. win_size_x: width of window. y_loc: starting Y screen coordinate of where to post creds fields. x_loc: starting X screen coordinate of where to post creds fields. mos_email_text: initial text of email field. mos_password_text: initial text of password field. Returns: mos_email_edit: widget from which email text can be taken. mos_password_edit: widget from which password text can be taken. mos_password_edit_width: width of password field. itwindowttexttfill(R!R/RR%R&R#R$RRJtmaxt_MAX_CRED_WIDTHtscrollable_columnsRRKR(t center_winR0R%R&tmos_email_texttmos_password_fillRGR1R2R3tmos_password_edit_widthR5tmos_email_labeltmos_email_edittmos_password_labeltmos_password_edit((s support.pytshow_abbrev_credss6                 c Csh|jjtkr(tjdtnt|jdrt|jddkrtjdt |j_d|j_ d|j_ d|j_ d|j_ tnd}|jjtjd|dtjd|dd |jd|d 7}|jjtjd|dtjd|dd |jd|d 7}||j_|j|j_d|j_|j|j_t|jd |jd tj|_|j|j}||j_|j|j_t |jt!|j_"t#|jd |jd |jj |_$|d7}|jjtj%d|d|d|dd |jd|d 7}|jjtj&d|d|jd|dd |jd|d 7}||j_||j_d|j_|j'|j_t|jd |jd tj(|_)|jj|j'7_|j*|j_t |j*t!|j_"t+|jd |jd |jj |_,|jj-j.|j/|jj0|j$dS(stDisplay the MOS credential fields. Assumes that network configuration has already been determined. s0Neither OCM nor ASR will be installed on system.t sc_networksRNot enabling OCM and ASR since network will not be configured on installed system.itstart_ytstart_xtmax_yitmax_xiRLRMRNN(1RCt sup_netcfgRR*tinfoR thasattrtgetattrRRt sup_mos_emailtsup_mos_passwordtsc_ocm_passwordtsc_asr_passwordRRt add_paragraphR!tINTRO_1t HEADER_OFFSETR0tINTRO_2R5R%RHR&R#R1R$RRJt email_labelR3RORPRQRt email_edittEMAIL_FOOTER_TEXTtPASSWORD_HEADER_TEXTR2RKtpassword_labelR4Rt password_edittkey_dicttupdateR>tactivate_object(RER%temail_field_start((s support.pyt_shows                                   cCs|jj}|tjkrD||jkrD|jj|jdS|tjksb|tj kr||jkr|jj|jdS|S(sr Have up and down toggle between email and password. Have go from email to password. N( RRtget_active_objectR:R;RqRtRmRR<R=(REt input_keytactive((s support.pyR9HscCsa|jj}|jj}t|jj|j_t|jj|j_|jjrv|jjt|j n |jj ||jjkrd|j_ d|j_ n||jjkp||jjk}|jr| rdSt|_tj|j|j\|_}|r@|jr1|tj7}nt|n|jjtjkr|jj s{|jjr|jj rtj|j_d|j_d|j_d|j_d|j_n|jjr]|jjjdtj|j|jj\}}|jjj |jj sD|jj!sDt"j#j$j% sD|tj&kr|jj s{|jj's{t"j#j$j( s{|tj)krt|j |j_n d|j_|tj*krd|j_ n|tj+krd|j_ n|tj,krt"j#j$j%p|tj-kot"j#j$j(|_tj.||}|r]|jrK|tj7}nt|q]ndS(sError-check and try to authenticate to Oracle Assumes that at least one of OCM or ASR exists. Does not assume a valid network connection exists. If Oracle cannot be contacted, show the user a warning but let the user save them by bypassing validation when this method is called a second time with the same set of credentials. If Oracle can determine that credentials are not valid, do not allow the user to save them. Both OCM and ASR should find the same sets of credentials valid. If the two services disagree, there is some wider problem. Let the user save the credentials; there may be a server problem somewhere which is temporary. Assume that the services will attempt to validate them later. Part of knowing whether the user can "save anyway" without re-authentication, when validation is entered a second time, requires knowing that the credentials have changed. However, the password cannot be saved in the clear. After encrypting the password successfully, the clear MOS password is set to stars. If the user re-enters it, the stars will change to the newly-entered password, indicating a change, and triggering a re-authentication. If the password was blank to begin with and is entered the second time around, also indicates a change triggering re-authentication. NRs-Attempting to contact Oracle. Please wait...(/RCRdRet _CONV_NONERmtget_textRqtset_textR R4t clear_textRRfRgR8RRt check_mosR!tSAVE_ANYWAY_MSGR R`R tsup_proxy_hosttsup_proxy_usertsup_proxy_passwordRtsup_proxy_portRFt error_linet display_errt phone_homet clear_errt sc_ocm_ciphertsolaris_installt sysconfigtutilt OCM_AVAILABLEt OCM_NO_ENCRtsc_asr_privkeyt ASR_AVAILABLEt ASR_NO_ENCRt OCM_SUCCESSt ASR_SUCCESSt OCM_BAD_CREDt ASR_BAD_CREDtphone_home_msg(REt old_mos_emailtold_mos_passwordt creds_changedtmessaget ocm_statust asr_status((s support.pytvalidateXsp      !        !      cCstj|jdS(N(Rtfinalize_support_fieldsRC(RE((s support.pyton_change_screens(t__name__t __module__t__doc__Rt HEADER_TEXTRiRkRJRnRoRKR t HELP_DATAtPASS_SCREEN_LENt_HEADER_OFFSETRjt _ITEM_OFFSETRHt _RIGHT_MARGINRIRR.t staticmethodR/RZRvR9RR(((s support.pyR!Rs*        "? ]  tSupportNetConfigScreencBseZdZeededfeededfeededfgZedZedZ ed Z e d ed fZ e ZeZeZd Zd ZdZRS(sAllow user to select: - No proxy (use system internet connection parameters) - Configure proxy settings - Configure aggregation hubs sNo proxys)Use system Internet connection parameterstProxys*Enter proxy information on the next screensAggregation Hubss)Enter hubs information on the next screensSupport - Network ConfigurationsnTo improve products and services, Oracle Solaris relays configuration data to the Oracle support organization.s1Select an internet access method for OCM and ASR.s/%s/support_net_config.txtR"cCstt|j|t|_t|_d|_xA|jD]6\}}}t |}||jkrA||_qAqAWd|_ t j j|_|jjdtdtd|_dS(NiR'R((R-RR.RR5tdictt choice_dictt max_title_lentCHOICESRRtcurrent_choiceRR?R@RARRBRC(RERFtkeyttitleRMt title_len((s support.pyR.s     c Cs[|jjtksC|jjtksC|jjtkrL|jj rLtn|jjr|jj rtj j j rt j|j_tn|j tjtj}d}|jjtjd|dtjd|dd|j d|d7}|jjtjd|dtjd|dd|j d|d7}|jd kr||jj sd|jjrp|jjrpt|_q|t|_n|j|j_d|j_xtjD]\}}}||j_t ||j!ddd |}t"t#|d||j_$t%|jd |jd |}||_&||j'|<|d7}qW|jj(|j'|jd S( s>Display a menu for selecting the network configuration optionsiR\R]R^iR_itjusttleftRLRMN()RCR`RRRRdR ReRRRRRR0RRHRIRRRhRiRjRkRRRRR R5R&R#RR%RRtminRR$Rtitem_keyRRt(RERGR%RRRMtlinetwidget((s support.pyRvsX                      cCs(|jjj|_|j|j_dS(s?Save current choice, and go to the next screen based on choice.N(RRRwRRRCR`(RE((s support.pyR`s(RRRRRR RRRRiRkR RRRjRRHRRIR.RvR(((s support.pyRs*          DtSupportProxyScreencBseZdZedZedZedZedZedZedZ edZ edZ e d ed fZ eZeZeZd Zd Zd ZdZdZdZRS(s%Allow user to enter proxy informationsSupport - Proxy Configurations}Complete HTTP proxy information if OCM and ASR require a dedicated proxy in order to contact the Oracle support organization.sProxy informations?Enter username and password only if configuring a secure proxy.s Hostname:sPort:s Username:s Password:s/%s/support_net_config.txtR"cCstt|j|t|_t|_t|_i|jt j 6|jt j 6|jt j 6|jt j 6|jt j6|_i|_tjj|_|jjdtdtd|_dS(NR'R(i(R-RR.RR5Rtshow_mos_credentialsR8R9R:R;R<tKEY_LEFTt KEY_RIGHTR=R>t field_dictRR?R@RARRBRC(RERF((s support.pyR.|s       c Cs|jjtjkrtn|jtjtj}|dtj}d}|j j tj d|dtj d|dd|jd|d7}|j j tj d|dtj d|dd|jdtttjttj}tttjttj}|d7}||j_tj|j_d|j_|d|j_t|jd|j d tj|_|jj|jj7_|tj|jjd|j_t|jjt|j_t|jd|j d td |jj d |jj!|_"|j"|j#d <||j_|d|j_t|jd|j d tj|_$|jj|jj7_d |j_|jj|j_t|jd|j d |jj%d |j&d |jj |_'|j'|j#d<|d7}|j j tj(d|dtj d|dd|jd|d7}||j_tj|j_|d|j_t|jd|j d tj|_)|jj|jj7_|tj|jjd|j_t|jjt*|j_t|jd|j d |jj+|_,|j,|j#d<||j_|d|j_t|jd|j d tj|_-|jj|jj7_||jjd|_.|j.|j_t|j.t*|j_t/|jd|j d|jj0|_1|j1|j#d<|j2rd|d7}t3j4|j |j||j|jj5|jj6\|_7|_8|_9|j7|j#d<|j8|j#dDisplay a menu for selecting the network configuration optionsiiR\R]R^R_iRLRMRt error_wins0,0is1,0s0,1RNs1,1s0,2s0,3itmax2tmax3itmax0tmax1N(>RCR`RR R R0RtLEFT_ITEM_OFFSETRIRRRhRiRjRkRORtHOSTNAME_LABELtUSERNAME_LABELt PORT_LABELRKR5R%R&R#R$Rthostname_labelt_MAX_URL_WIDTHRQRtincremental_validate_hostnameRFRRt hostname_editRt port_labelRt port_validt port_edittINTRO_3tusername_labelRPRt username_editRptproxy_password_edit_widthRRRqRR!RZRdReRWRYRURrRsR>Rt(RERGtright_item_offsetR%tleft_label_widthtright_label_width((s support.pyRvs              !                !           !      c Cs|jj}g|jjD]\}}||kr|^q}|djd\}}t|}t|} |jd| } |tjkr|dkr|d8}n|tjkr|| kr|d7}n|tj kr/|dkr|d8}q|dkr(| dkr(| }| d8} q|Snz|tj ksM|tj kr|jd} || krs|d7}q|| kr| | krd}| d7} q|Sn|S|jj |jd|| fdS(s= Implement up, down, left, right arrow keys. it,smax%diR^s%d,%dN(RRRwRtitemstsplittintR:RRR;R<R=RtR( RERxRyRtvaluet active_keytstrxtstrytxtytx_maxty_max((s support.pyR93s:           !c Cs|jj}|jj}|jj}|jj}t|jj|j_t|jj|j_t|j j|j_t|j j|j_|jjr|j j t |j n |j j|jj}|jj}|jrt|jj|j_t|jj|j_|jjrP|jj t |jn |j j||jjkrd|j_d|j_qn||jjkp||jjkp||jjkp||jjkp||jjkp||jjk}|jr | r dSt|_|jjr=d|j_d|j_ntj|j|j\|_}|r|jr}|tj7}nt |n|jj s|jj rt t!dn|jjr|jj s|jjr|jj rt t!dntj"} tj#} |jjr|j$j%j&dtj'|jtj(\} } |j$j%j)|jr|jjs|jj*st+j,j-j. s| tj/kr|jjs|jj0st+j,j-j1 s| tj2krt |j|j_qd|j_n|jj3s*t+j,j-j. s*| tj/kry|jj4sUt+j,j-j1 sU| tj2kry|jjryt |j |j_n d|j_| tj"krd|j_n| tj#krd|j_n| tj5krt+j,j-j.s| tj6kr t+j,j-j1r t7|_qkt7|_nV|jjrk|j$j%j&dtj'|jtj(dt7\} } |j$j%j)ntj8| | }|r|jr|j9j:|j;|j$j<n|jr|tj7}nt |ndS(sLValidate entered data, including contacting Oracle to authenticate. NRsCPlease fill in proxy hostname and proxy port or press F3 to go backs8Non-blank proxy user and password must be given togethers-Attempting to contact Oracle. Please wait...tforce_encrypt_only(=RCRRRRRzRR{RRRqR|R RR}RdReRRWRYRURRfRgR8Rt sc_ocm_hubt sc_asr_hubRR~R!RR RRRRFRRRR RRRRRRRRRRtsc_ocm_proxypasswordtsc_asr_proxypasswordRRRBRRRt make_inactiveRvt do_update( REtold_proxy_hostnametold_proxy_porttold_proxy_passwordtold_proxy_userRRRRRR((s support.pyR[s                 !                      cCsM|j}|jo7dt|ko5dknsItdndS(sValidate port numberiis,Port number must be a number from 0 to 65535N(R{tisdigitRR (REt edit_fieldR((s support.pyRs .cCstj|jdS(N(RRRC(RE((s support.pyRs(RRRRRRiRkRRRRRKR RRRjRRRRIR.RvR9RRR(((s support.pyRfs(          ( tSupportHubScreencBseZdZedZedZedZedZedZe dedfZ e Z e ZeZdZd Zd Zd Zd Zd ZedZRS(s#Allow user to enter hub informationsSupport - Hub ConfigurationsOCM and ASR data can be relayed to the Oracle support organization through local aggregation systems or "hubs" that pool data and forward it.sEnter at least one hub URL.s OCM Hub URL:sASR Manager URL:s/%s/support_net_config.txtR"cCstt|j|t|_t|_t|_i|jt j 6|jt j 6|jt j 6|_ tjj|_|jjdtdtd|_dS(NR'R(i(R-RR.RR5RRR8R9R:R;R<R=R>RR?R@RARRBRC(RERF((s support.pyR.s    c Cs|jjtkrtnt|_|jtjtj }d}|j j tj d|dtj d|dd|jd|d7}|j j tjd|dtj d|dd|jd|d7}tttjttj}tjjjr||j_tj|j_d|j_|d|j_t|jd|j d tj|_|jj|jj7_|tj |jjd|j_t|jjt|j_t |jd|j d |jj!d |j"|_#|jj$|j#|d7}ntjjj%r||j_tj|j_d|j_|d|j_t|jd|j d tj|_&|jj|jj7_|tj |jjd|j_t|jjt|j_t |jd|j d |jj'd |j"|_(|jj$|j(n|j)rt|d7}t*j+|j |j||j|jj,|jj-\|_.|_/|_0|jj1|j.|j/gn|j j2j3|j4|j j5|jd d S( sDisplay a menu for selecting the network configuration options It is assumed that at least one of ocm and asr services will be present. iR\R]R^iR_iRLRMton_exitiN(6RCR`RR tlistt field_arrayR0RRHRIRRRhRiRjRkRORt OCM_HUB_LABELt ASR_HUB_LABELRRRRR5R%R&R#R$Rt ocm_hub_labelRRQRRt url_validt ocm_hub_edittappendRt asr_hub_labelRt asr_hub_editRR!RZRdReRWRYRUtextendRrRsR>Rt(RERGR%thub_label_width((s support.pyRv3s              !        !       !cCs|jj}|tjkr\||jdkr\|jj|j|jj|ddS|tjksz|tj kr||jdkr|jj|j|jj|ddS|S(s0 Implement up, down arrow keys. iiiN( RRRwR:R;RRttindexRR<R=(RERxRy((s support.pyR9s"c Cs~|jj}|jj}tjjjr`t|jj |j_t j |jj|j_ntjjj rt|j j |j_t j |jj|j_n|jj}|jj}|jrdt|jj |j_t|jj |j_|jjr'|jjt|jn |jj||jjkrdd|j_d|j_qdn||jjkp||jjkp||jjkp||jjk}|jr| rdSt|_|jjs|jjrd|j_d|j_d|j_d|j_nt j!|j|j\|_}|rc|jrT|t"j#7}nt$|n|jj r|jj rt$t%dn|jjrz|j&j'j(dt j)|jt*\}}|j&j'j+|jrz|jjs|jj,stjjj s|t j-krk|jjsS|jj.sStjjj sS|t j/krkt|j|j_qzd|j_n|t j0krd|j_n|t j1krd|j_n|t j2krtjjjs|t j3krtjjj rt4|_n t4|_t j5||}|rz|jrO|j6j7|j8|j&j9n|jrh|t"j#7}nt$|qzndS(sLValidate entered data, including contacting Oracle to authenticate. NRs6Please fill in one or more hubs or press F3 to go backs-Attempting to contact Oracle. Please wait...(:RCRRRRRRRzRR{Rtmake_urlRRRdReRRWRYR|R RUR}RRfRgR8RRRRRRR~R!RR RRFRRRRRRRRRRRRRRBRRRRRvR( REt old_ocm_hubt old_asr_hubRRRRRR((s support.pyRs             !              cCstj|jdS(N(RRRC(RE((s support.pyR#scCs |jtj|jdS(s<Transform the edit_field's value into a valid URL if needed.N(R|RRR{(RER((s support.pyR&scCs.|dksd|kr|S|r*d|SdS(s-Transform 'value' into a valid URL if needed.s://shttp://N(R(R((s support.pyR*s(RRRRRRiRkRRR RRRjRRHRRIR.RvR9RRRRR(((s support.pyR s"       c  z  cCsY|j}|stS|jddjdd}|jsUttdndS(sT Check hostname for characters other than alphanumeric, periods, and hypens u-tau.sInvalid CharacterN(R{RBtreplacetisalnumR R(Rthostname((s support.pyR3s   (5RR:R+tretsolaris_install.sysconfig.utilRtsolaris_install.engineRtsolaris_install.loggerRtsolaris_install.sysconfigRt!solaris_install.sysconfig.sc_specRRRRRRR R t&solaris_install.terminalui.base_screenR R R t%solaris_install.terminalui.edit_fieldRRt$solaris_install.terminalui.list_itemRt&solaris_install.terminalui.window_areaRtsolaris_install.terminalui.i18nRRRR*Rzt _CONV_EMPTYRPRRRRtcompileRRR R!RRRR(((s support.pytsB    4    *