i'dWc@srdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddlmZmZddlmZmZmZmZmZmZddlmZmZmZmZmZmZmZddl m!Z!dd l"m#Z#dd l$m%Z%m&Z&m'Z'dd l(m)Z)dd l*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1dd l2m3Z3m4Z4m5Z5ddl6m7Z7ddl8m9Z9ddl:m;Z;ddl<m=Z>ddl?m@ZAddlBmCZCddlDmEZEddlFmGZGmHZHmIZImJZJmKZKmLZLddlMmNZNmOZOmPZPmQZQmRZRmSZSddlTmUZUdZVdZWdZXdZYdZZdZ[dZ\dZ]d Z^d!Z_e_e_Z`d"Zad#Zbd$e>fd%YZcd&ecfd'YZdd(ecfd)YZed*eefd+YZfd,eefd-YZgd.eefd/YZhd0eefd1YZidS(2sq boot.py -- Installs and configures boot loader and boot menu onto physical systems and installation images. iN(tgetgrnam(tgetpwnam(tmovetrmtree(t bootconfigt BootmgmtUnsupportedPlatformErrortBootmgmtPropertyWriteErrort BootmgmtUnsupportedPropertyErrort!BootmgmtUnsupportedOperationErrortBootmgmtPropertyReadError(t BootConfigtDiskBootConfigt ODDBootConfigtSolarisDiskBootInstancetSolarisODDBootInstancetChainDiskBootInstancetZvmmODDBootConfig(tSystemFirmware(t BootLoader(tBootPoolt VersaBoottVersaBootRootFactory(tDEBUG(tDC_LABELt DC_PERS_LABELtApplicationDatatCalledProcessErrortPopentSYSTEM_TEMP_DIRtrun(tBootModst BootEntrytBootAdm(tObjectNotFoundError(tDataObjectDict(t InstallEngine(tAbstractCheckpoint(tINSTALL_LOGGER_NAME(t getallifaddrs(tTarget(tbe_listtBEtZpooltBOOT_ENVIRONMENTtBE_NAMEt BE_MOUNTPOINT(tDisktFDISKtIscsit GPTPartitiont PartitiontSlice(tget_image_grub_titlesboot-envtdevss#/usr/lib/grub2/bios/sbin/grub-setups/usr/sbin/bootadms/usr/sbin/dladms/usr/sbin/lofiadms boot/mbr.imgsinstall_grub.logiis ZFS/LocalDisksZFS/iSCSI/IPv4/IPoIBtBootMenucBseZdZejZdZdZdZej dZ ej dZ ej e dZ ej dZe dZd Zej e d Zej d Zej e d Zd ZdZe dZRS(s, Abstract class for BootMenu checkpoint icCstt|j|tj|_t|_d|_ t|_ tj |_ d|_ d|_d|_t|_d|_tjj|_d|_t|_d|_d|_dS(s Constructor for class s/system/volatileN(tsuperR6t__init__tplatformt processortarchtlisttboot_entry_listtNonetbootadmtbootadm_cmd_listtDEFAULT_TIMEOUTt boot_timeoutt boot_modst boot_titlet boot_firmwaretdictt boot_tokenstconfigR#t get_instancetdata_object_cachetdoct img_info_pathtFalset live_installtrel_file_titletwork_dir(tselftname((sboot.pyR8ds             cCsdS(s\ Returns an estimate of the time this checkpoint will take to complete. i((RQ((sboot.pytget_progress_estimateyscCs tdS(s This method is required to be implemented by all subclasses. Standard, pre-defined boot menu entries get created by subclass implementors of this method. N(tNotImplementedError(RQ((sboot.pytbuild_default_entriesscCs tdS(s This method is required to be implemented by all subclasses. Custom entries specified in the boot_mods section of the XML manifest get created by subclass implementors of this method. N(RT(RQ((sboot.pytbuild_custom_entriesscCs tdS(s This method is required to be implemented by all subclasses. Bootadm commands specified in the boot_mods section of the XML manifest get executed by subclass implementors of this method. N(RT(RQtdry_run((sboot.pytset_boot_configurationscCs tdS(s This method is required to be implemented by all subclasses. Returns file system path to the release file. N(RT(RQ((sboot.pyt_get_rel_file_pathscCsT|jjjdt}|r9|j|_|j|_n|j||jdS(s^ Parse data object cache for values required by the checkpoint execution. t class_typeN(RKt persistenttget_first_childRRNRPt_parse_doc_targett_parse_doc_boot_mods(RQRWtapp_data((sboot.pyt parse_docs   cCs!y<|jjdt}t|dkr.dS|d|_Wn)tk rg}tdt|nX|jjrt|jjdkr|j j d|jj|jj|_ n|jj dk r|j j d|jj |jj |_ny|jjdt|_Wn!tk r5|j jdnXyA|jjdtd t}t|dkrv|d|_nWn!tk r|j jd nX|jr|jjr|j jd t|jj|jj|_n|jjdk r|jj|_|j jd |jndS( sg Parses data object cache (DOC) BootMods tree for configuration of the checkpoint. RZiNis(Error retrieving BootMods from the DOC: s3Setting boot title prefix from manifest value: '%s's,Setting boot timeout from manifest value: %ds'No custom boot entries found in the DOCtnot_found_is_errs#No bootadm command found in the DOCs%Setting boot bootadm command list: %ss-Setting boot firmware from manifest value: %s(RKtget_descendantsRtlenRCR!t RuntimeErrortstrttitletloggertinfoRDttimeoutR>RBt get_childrenRR=tdebugR tTrueR?tcmd_listR@tfirmwareRE(RQRCterrR?((sboot.pyR^sH$        cCs tdS(sP This method is required to be implemented by all subclasses. Additional class specific parsing to determine the boot configuration's target paths or devices get performed by subclass implementors this method. Input: None Output: None N(RT(RQRW((sboot.pyR]s cCs tdS(s This method is required to be implemented by all subclasses. Input: None Output: None N(RT(RQ((sboot.pytinit_boot_configs cCs tdS(s This method is required to be implemented by all subclasses. Input: dry_run - If True, the set of files that constitute the boot configuration is written to a temporary directory (and not to the official location(s)) When files are written to a temporary directory, the list and format of the files written is returned (see Output) Output: None N(RT(RQRW((sboot.pytinstall_boot_loaderscCs|jjd|x|D]}t|ts<|g}nxx|D]p}|d}|tjkrr|j|qC|tjtjtj gkr|j ||qCt d|qCWqWdS(s Method that checks returned tuple list from commit_boot_config() and copies over content as appropriate to their targets. s/_handle_boot_config_list: boot_config_list = %sis&Unrecognized boot loader file type: %sN( RgRkt isinstanceR<R tOUTPUT_TYPE_FILEt_handle_file_typetOUTPUT_TYPE_BIOS_ELTORITOtOUTPUT_TYPE_UEFI_ELTORITOtOUTPUT_TYPE_ZVMM_ELTORITOt_handle_iso_boot_image_typeRd(RQtboot_config_listRWt boot_configt config_settftype((sboot.pyt_handle_boot_config_list s      c Cs|\}}}}}}}|d kr6tdn|d krQtdn||j} tjjtjj| tjj} ytjj| s|j j d| tj | n|j j d|| ft || |d krd}n|d krd}n|j j d| ||ftj | t|jt|j|r|j j d| |ftj| |nWn)tk r} tdt| nXd S( sM Method that copies generic file types to their appropriate targets. s#No source path defined for bootfiles(No destination path defined for bootfiles&Creating boot configuration folder: %ss)Moving boot configuration file: %s -> %sis!Setting ownership of %s to: %s:%ss Setting permissions of %s to: %ds4Error copying boot configuration files to target: %sN(R>RdRGtostpathtabspathtjointpardirtexistsRgRktmakedirsRtchownRtpw_uidRtgr_gidtchmodtOSErrorRe( RQRHR|tsrctobjreftdesttuidtgidtmodet real_desttpar_dirRo((sboot.pyRt%s>   '           cCszyI|j||j|j|j|j||j|Wn*tk ru|jjt j nXdS(sF Primary execution method used by the Checkpoint parent class N( R`RpRURVRqRXt ExceptionRgRkt tracebackt format_exc(RQRW((sboot.pytexecuteMs      (t__name__t __module__t__doc__tabctABCMetat __metaclass__RAR8RStabstractmethodRURVRMRXRYR`R^R]RpRqR}RtR(((sboot.pyR6^s(     2    (tSystemBootMenucBseZdZeedZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZedZedZdZdZedZedZRS(s Class for SystemBootMenu checkpoint. Suitable for automatic boot loader and boot menu configuration for install applications that install onto a physical system device such as gui-install, text install and AI cCstt|j|i|_idt6dt6|jtR,R-tBOOT_ENVtDEVSt root_targettboot_pool_diskstimg_info_titlet target_bootfsttarget_bootfs_realnamet _root_poolt _boot_poolttarget_boot_instancetroot_pool_tld_mounttautogentupdate_firmwaret iscsi_doc_objRMtiscsi_ipoe_boot(RQRRRR((sboot.pyR8bs"              c Cstjjg}|jr.|jtjjnt|}|jt}|t dkrt j dt dd|t}|jjd|t|ft|t}|j|dtn|jdk r|jdkrd|jf}q|j|jf}nd}t|d|jjd |jd |t d td td |j d||_|jst|t d|jdddt}|jj|n|jdk rrt |jd|jjd|j!dt}|j"|j}|st#dn|jt$j%|t&|j|} |jj'| g} x0|j(D]%\} } | j|j)| | q7W| |jj*_+ny |jj,j-t.j/|j0Wn.t1k r|jjd|jj,jnXdS(se Instantiates the appropriate bootmgmt.bootConfig subclass object for this class tdirtprefixs be_mount_%s_sMounting BE %s at: %sRWti386tx86trpnamettldpathtzfspathtset_bootfs_on_committvalidate_bootfst rpool_onlyR9tbootfstfstypetzfstdefaulttpoolnamet membershiptcreatesWCould not find any boot devices from the boot pool on which to install the boot loader.sFBoot loader type %s does not support the 'timeout' property. Ignoring.N(2RR t BCF_CREATERtappendt BCF_AUTOGENttupleRRR-R>ttempfiletmkdtempRR,RgRkR)tmountRMRER;R RRRRRlRHR Rtadd_boot_instanceRRRt_get_disk_ctds_from_zpoolRdRtextendRtenable_versabootRt_get_vbroot_instancet versaboottvbrootst boot_loadertsetpropRt PROP_TIMEOUTRBR( RQtbc_flagst target_bet tmp_be_mpttmp_betplatform_tupletsdbit boot_poolt ctds_namesRRtdev_ctdstdisk((sboot.pyRpsh                   cCs+|jrt}n%|jr$t}ntd|jtj|}|}|jj d||j|tkr|j t j j d|jj}t j j|}dt j j|krt j j|}ntdddd|jjg}t|d tj} | jjjd d } | jjjd d } td ddd| g}t|d tj} | jj} d|| | f} |jj d| |jd| |jj d|jj|jd|jjx_tjD]N\}}|j|jjkr|jj d|j|jd|jPqqW|jj |jj}|d.k r|jj d||jd|n|jj d|jj"|jd|jj"|jj#d.k r|jj d|jj#|jd|jj#n|jj dt$t%|jj&|j'j(d|jdt$t%|jj&|j'j(d|jj d|jj&|j'j)|jd |jj&|j'j)|jj*d.k r|jj d!|jj*|jd"|jj*n|j+r-|j,d#kr-|jj d$|jd%d&q|jd'd(}|jj d)t-d*t%||jd%t-d*t%|n|tkr |j.d+kr|j/t j j d,|gd } n|j t j j d,|} |jj d| |jd| ntd-||j0|S(/s Return an instance of the appropriate VersaBootRoot class needed for the given root device ctds name and the Disk object of the disk it lives in. Raises: RuntimeError BootmgmtMissingRequiredPropertyError (from vbroot.validate()) sNRoot disk '%s' cannot be booted by firmware and is not supported by versaboot.s)Device '%s' using versaboot root type: %ss/devthermons show-parts-ps-os pkey,overt check_resultt:iisshow-ibtports%s:port=%s,pkey=%s,protocol=ipsSetting osroot-path to: %ss osroot-pathsSetting osroot-host-ip to: %ssosroot-host-ips!Setting osroot-subnet-mask to: %ssosroot-subnet-masksSetting osroot-router-ip to: %ssosroot-router-ips%Setting osroot-iscsi-target-ip to: %ssosroot-iscsi-target-ips Setting osroot-iscsi-port to: %ssosroot-iscsi-portsSetting osroot-iscsi-lun to: %sisosroot-iscsi-luns'Setting osroot-iscsi-target-name to: %ssosroot-iscsi-target-names(Setting osroot-iscsi-initiator-id to: %ssosroot-iscsi-initiator-idtGPTs&Setting osroot-iscsi-partition to: 'a'sosroot-iscsi-partitiontatsis%Setting osroot-iscsi-partition to: %siatsparcs/dev/dsks(Unsupported VersaBootRoot technology: %sN(1tis_firmware_bootablet!VERSABOOT_ROOT_TYPE_ZFS_LOCALDISKtis_iscsi_over_infinibandt%VERSABOOT_ROOT_TYPE_ZFS_iSCSI_IPv4oIBRdRRRtget_root_technology_by_nameRgRkt_resolve_dev_path_to_deviceR~RRtiscsitlocal_datalink_devicetdirnametbasenametDLADMtlocal_datalink_nameRRtANYtstdouttstriptsplitRtlocal_datalink_ipR&titemstaddresstnetmaskt get_router_ipR>t target_ipt target_portthextintt iscsi_dicttctdtlun_numt target_nametinitiator_namet whole_disktlabeltchrR;t_devfs_to_prom_pathtvalidate(RQRRt tech_namet vbrootclasstvbroottdatalink_device_pathtdevicetcmdtptpkeytoverRt osroot_pathRRRht router_ipt slice_num((sboot.pyRs                            "  cCsatjj|}|jjd|||jdrJ|td}n|jjd||S(s Resolves a dev path name link to its device path, removing the "/devices" portion from the beginning of the device path. sResolved dev path '%s' to '%s's /devices/s/devicess Returning: %s(R~RtrealpathRgRkt startswithRc(RQtdev_patht device_path((sboot.pyRs  cCs'|jdd\}}|jd|S(s@ Replaces the pool name in bootfs with pool's realname. t/i(Rtrealname(RQtzpoolRRttailname((sboot.pyt_make_target_bootfs_realnamescCsd}|jj}|jd}|dk r1|S|jdd}|dkry|jdd}|dkryd}qyn|dks|dkrd}n|S(s Determine X86 console device. Adapted from libict_pymod Returns console device found in bootenv.rc, from devprop command, or default 'text'. s output-devicetpropnametconsoletscreenttexttN(R>Rt boot_varstgetpropt_get_dev_property(RQt osconsoletbootvars((sboot.pyt_get_x86_consoles        cCsd }dd|g}tj|dtjdtjdt}|jdkrgtd||jfn|jj }t |dkr|}|j j d||fn|j j d ||S( s Internal helper method. Retrieves the value of propname reported by devprop(1M) Returns: A string value associated with propname or None s/usr/sbin/devprops-sRtstderrRgis/Error getting device property: %sExit status=%ss(Found device property value for %s: '%s's%No device property value found for %sN( R>Rt check_calltSTOREtILNt returncodeRdR%RRRcRgRk(RQRt propname_valR R tresult((sboot.pyR!s"      cCs|jjj}|jdkr.|j|n|jdkrg|jtD]}tjj d|^qK}|rvdSy|j t j |Wqt k r}|jjdt|qXndS(s Set the boot device in the system firmware on SPARC and UEFI64 This performs no action on BIOS systems, which lack this feature. tobptuefi64s/dev/dskNs+Failed to set UEFI firmware boot device: %s(RHRRntfw_namet_set_sparc_prom_boot_deviceRRR~RRRRtPROP_BOOT_DEVICERRgtwarningRe(RQRWRntdevt boot_devstbpw((sboot.pyt_set_firmware_boot_devices, c Cs1d}tdd>}|dB}d}t}|jjd|t|d}xt|D]\}} |jjd|| | d j|} tjd tj d ||| } t j ||| t tj d || \} } | jd d }|j||jjd | |qaWWdQX|S(s Convert a list of devfs_paths (e.g. /dev/dsk/c0t0d0s0) to prom paths. Returns corresponding list of prom paths. Raises: StandardError (from i/o with prom device) s /dev/openpromtOiiisOpening prom device: %strsDevice path %d: %sttcsI%dsis%s prom device name: %sN(tordR<RgRktopent enumeratetljusttarraytstructtpacktfcntltioctlRltunpackRR(RQt devfs_pathst prom_devicetoioctopromdev2promnamet oprommaxparamt prom_pathstpromtit devfs_pathR2tbuft_tnew_devt prom_name((sboot.pyRs&    cCs|jjd|jr|sy:d}t|dtd|jj}t|dtWqtk r}|jjd|jjt |qXndSg|j t D]}t j jd|^q}t}t}t}d} y@dd g}t|} | jjd d d } | j}Wn9tk rg}|jjd |jjt |nXy%|jjjjtjj}Wn-ttfk r|jjdtjnXy|j|}Wn.tk r} |jjdt | dSX|jdk r?|j g|D]} | |kr| ^qn|j g|D]} | |krL| ^qLdj|} dd| g}|syt|Wqtk r}|jjd|jjt |qXndS(s Set the SPARC boot-device parameter using eeprom. If the root pool is mirrored, sets the boot-device parameter as a sequence of the devices forming the root pool. sSetting openprom boot-devices'/usr/sbin/eeprom boot-device="net disk"tshells*/usr/sbin/eeprom network-boot-arguments=%ss#Failed to set openprom boot-device:Ns/dev/dsks/usr/sbin/eeproms boot-devices boot-device=Ris$Error querying openprom boot-device:s7Firmware does not support the '%s' property. Ignoring.s0Failed to set openprom boot-device parameter: %st sboot-device=%s(!RgRhRRRlRtsparc_obp_boot_stringRR1ReRRR~RRR<R>RtreplaceRRHRRnR RtPROP_BOOT_RECOVERY_LISTRR RkRt StandardErrorRR(RQRWR tcpeR2R3ttboot_prom_boot_devstcur_prom_boot_devstnew_prom_boot_devst prom_arg_strR R+tstdtd((sboot.pyR/Jsh  ,       cCsCt|tjstS|jdk r)tS|j|jkr?tStS(s Returns True if instance is the boot instance we just installed. Otherwise returns False Inputs: - instance: A BootInstance object R(RrRR RMRRRRl(RQtinstance((sboot.pyt_is_target_instancescCs ||_dS(sx Trivial internal convenience method that stores a reference to the target SolarisDiskBootInstance. N(R(RQR^((sboot.pyt_ref_target_instancescCs$|jjd|jt|_dS(s Sets instance as the default boot instance in a boot configuration Inputs: - instance: A BootInstance object s)Marking '%s' as the default boot instanceN(RgRkRfRlR(RQR^((sboot.pyt_set_as_default_instances  c Cstj|jjjkrdS|j||jjd}|j}|dk r||kr|j j d||jj tj|n|dk r |j dr |d}|jj|}|jd|}|dk r ||kr |j j d||f|jj ||q n|jjjdd }|dkr|dk r|j j d |j|jjj tjtjd |_n,|j j d|jjj tjtjdS(s Sets console property for the boot instance in bootenv.rc and kernel boot args. 'console' property is determined from bootenv.rc and devprop(1M) values for 'output-device' and 'console' Ns output-devices*Setting console boot device property to %stttys-modeRs%Setting %s boot device property to %sRRs GUI InstallRtgraphicss-Enabling happy face boot on boot instance: %ss-B console=graphicss&Disabling boot loader graphical splash(stextRc(Rt PROP_CONSOLERHRtSUPPORTED_PROPStinit_from_rootpathRR R$R>RgRkRRR!RKtvolatileR\RftPROP_CONSOLE_GFXtkargstPROP_CONSOLE_TEXT( RQR^t mountpointt curosconsoleR"tosconsole_mode_nametcur_osconsole_mode_valuetosconsole_mode_valuetgui_prof((sboot.pyt_set_instance_bootenvs@                cCs0|jjd|j|jf|j|_dS(s Sets the title of instance to match self.boot_title Inputs: - instance: A BootInstance object s+Setting title of boot instance '%s' to '%s'N(RgRkRfRD(RQR^((sboot.pyt_set_instance_titles cCstjj|jttdS(sC Returns file system path to the release file. s etc/release(R~RRRRR-(RQ((sboot.pyRY scCsg}x|jjD]u}xl|D]d}|d}|jdrU|td}n|dksw|j|jdr#|j|q#q#WqW|S(s& Given a zpool, return a list of vdevs (ctds device names) in that zpool. If disk argument is given, return only the vdevs that belongs to that disk. An empty list is returned if zpool has no vdevs or if none of the vdevs belong to the given disk. is /dev/dsk/RN(tvdevstvaluesRRcR>RR(RQRRRstentrytvdevt vdev_name((sboot.pyRs  "c Cs y2|jjtjtdddddtd}Wntk rQtdnXt}t}xL|jdtD]8}|j r|j |n|j rw|j |qwqwWt |dkrtd nt |dkrtd n|r |d|_ n|d|_|jjdt}|dk rd|j|jtt<|j|jtt|dj|j'_5|j'j6dkr|j'j7| j/j8|j'_6n|j'j9dkr|j'j7| j/j9|j'_9qqqx$|D]}|j1j || fqWqW|j dk r|j- s1|j dkr@|jt2 r@tdnt?j@|jAd}|jB|_C|jC|_D|jEdks|jFrdSytG|jHd|jI|_JWn"tKk r}|s|qnX|jJdk r|jHjLd|jJ|jJ|_DndS(s Parses the target objects in the DOC to determine the installation target device for boot loader installation t max_countit max_depthiRais#No desired target element specifiedRZs'Cannot specify more than one boot Zpools&No desired target root Zpool specifiedsHNo BE specified in Target.Desired tree nor in ApplicationData dictionarys%Target BE '%s' not found in pool '%s's*Mulitple BEs named '%s' found in pool '%s'Rks>Unable to find mountpoint of top level dataset fileystem '%s'!sKExpected mountpoint '%s' of top leveldataset fileystem '%s' does not exist!Rs/dev/dskRs0Cannot find vdev for disk '%s' in root pool '%s's9Found more than one vdev from disk '%s' in root pool '%s'Rs%ss%sias@Could not find any boot devices to install the boot loader onto.RNtimage_info_files*Setting boot title to image info value: %s(MRKRbR'tDESIREDRlR!RdR<R*tis_bootRtis_rootRcRRR\R)R>RRRRR,RkR-R[Rt data_dicttgetR+R(RRRt filesystemsRR~RRR0RRjR.RRtin_zpoolRRRRRRRRt sparc_slicet target_lunRRRR1R3RRRt linecachetgetlineRYRRORDR;RNR4RgRLRRRk(RQRWttargett boot_poolst root_poolstpooltboot_envR_t boot_env_datatbelistt filesystemt iscsi_checkRRtnodestnodet boot_nodestbdevstbdevt title_lineRW((sboot.pyR])s                   " !) #%      cCss|jj|j|j|j|j|j|j|jdkro|jd|jd|j t t ndS(s Method for constructing the default entries list. When installing onto physical target systems, the list of entries is autogenerated based on discovery routines within bootmgmt. The discovered entries should already be present from the invocation of init_boot_config() so the only remaining tasks here are to set the new boot environment as the default boot instance and the console properties on X86. RR^RkN( RHtmodify_boot_instanceR_R`RaRRrR;RqRRR-(RQ((sboot.pyRU:s    cCsD|jr@|jj|jg}t}x|jD]}t|jttddd|j }|j d|j |_ |j rt|_t}||_n t|_|j|_|jdkrd}|jd|nd}|j||jjd|j |jj||q2W|s@|d|_|j|jq@nd S( s Currently only consumed by AI installer app. GUI & Text do not consume a manifest XML file. For AI delete default menu entry if boot_entries are present in manifest XML file. RRRRRtstartiisAdding custom boot entry: '%s'N(R=RHtdelete_boot_instanceR_RMR RRR-RRDt title_suffixRft default_entryRlRRt kernel_argsRit insert_attinsertRRgRhRRa(RQtcustom_instancestis_default_setRuR^twhere((sboot.pyRVQs6           cCsF|js dSd}tjdddt}xB|jD]7}|jjdt||d}|j|q5W|j|j }|jjd||s>t d d |j j d |g}y5t |}|j j}|jjt|Wn<tk r-}|jjd ||jjt|nXtj|n|SdS( sJ Function to execute bootadm command to set up boot configuration NRRs/tmptdeletesAdding bootadm command: %ss s7The file location of boot config bootadm commands is %ss use-batchs-Ps-fs>Failed to set boot configuration using bootadm use-batch -f %s(R@RtNamedTemporaryFileRMRgRkRetwritetcloseRRtBOOTADMRRRRRR1R~tremove(RQRWttemp_file_namet temp_fileR R RRW((sboot.pyRX{s2        c Cs|jtstdng|jtD]}tjjd|^q*}|rtjdddd}|j|j t j <|jt t |j tj<|jjd||jj|d}|j||n-|jt t dkrtd n|jjd t|d}|jd kr;ittj6}nd}zy|jjtrtjj|jt}|jjd |t |d }n|jjd|dtd|d|Wd|dk r|j!nX|j"r|jjd|j#|n|rt$|ndS(sU Install the boot loader and associated boot configuration files sNo boot devices identified!s /dev/rdskRs/tmpRt boot_config_s1Installing boot loader configuration files to: %sRsMBoot checkpoint can not be executed on a live system except with dry run modes%Installing boot loader to devices: %sRsWriting out grub log to %stwt boot_devicestforcet verbose_filetplatdictNs Setting boot devices in firmware(%RRRdR~RRRRRRGR tTOKEN_ZFS_RPOOL_TOP_DATASETRR-R tTOKEN_SYSTEMROOTRgRhRHtcommit_boot_configR>R}RkReR;RlRt PLATOPT_MBRt isEnabledForRRPtGRUB_LOGR;RRR5R( RQRWR2t boot_rdevsttemp_dirRyt platdict_flagt verbose_fstgrub_log((sboot.pyRqsH ,     (RRRRlR8RpRRRR$R!R5RR/R_R`RaRqRrRYR>RRMR]RURVRXRq(((sboot.pyR\s0= `      : Y   ?     * !tISOImageBootMenucBseZdZejZdZdZdZdZ dZ e dZ e dZ e dZe d Ze d Zd Zd ZRS( s9 Abstract base class for ISOImageBootMenu checkpoint cCsMtt|j|d|_t|_t|_d|_d|_ dS(s Constructor for class N( R7RR8R>tba_buildRFtdc_dictt dc_pers_dictt pkg_img_pathttmp_dir(RQRR((sboot.pyR8s     c Cstjjtjjf}t|d|j|_y#|jjjt j ddgWn.t k r|j j d|jjjnX|jjjt j }t|tr|g}n|j jddj|y |jjjt j|jWn.tk r$|j j d|jjjnXt j|jjjkrtjj|jd}t|d }|jj}Wd QXd |}tjj|j|}|j jd |t|d }|jdWd QX|jjjt jd|nd S(se Instantiates the appropriate bootmgmt.bootConfig subclass object for this class t oddimage_roottbiosR-sABoot loader '%s' does not support both BIOS and UEFI64 platforms.s6Creating ISO boot configuration for firmware targets: s, sFBoot loader type %s does not support the 'timeout' property. Ignoring.s .volsetidR7Nt.s&Boot loader unique ident file name: %ssa+s/# This file identifies the image root for GRUB2R( RR Rt BCF_ONESHOTRRRHRRRtPROP_BOOT_TARGSRRgR1RRR RrReRhRRRBRtPROP_IDENT_FILEReR~RRR;treadRR( RQRtfw_targstvpathtvpath_fhtvolsetidt identfilet identpathtidentf((sboot.pyRpsD          cCstjj|jdS(sC Returns file system path to the release file. s etc/release(R~RRR(RQ((sboot.pyRY2scCs5tdtdg}d|_|jj|dS(s= Adds a chainloader entry to the boot configuration. t chaininfoisBoot from Hard DiskN(RRRfRHR(RQR^((sboot.pyt_add_chainloader_entry8s cCsx|jD]}t|j}|jd|j|_|jrKt|_n t |_|j |_ |j dkrxd}nd}|j j||q WdS(s? Add custom defined boot entries from the manifest XML RRRiiN(R=RRRDRRfRRlRRMRRiRRHR(RQRuR^R((sboot.pyRV?s     cCsdS(s Function to execute bootadm command to set up boot configuration Currently only consumed by AI installer app. GUI & Text do not consume a manifest XML file. N((RQRW((sboot.pyRXSscCs&y2|jjjdtdtdtdj|_Wntk rEnX|jj jdt dtdtdj|_ y4|j d|_ |j d|_ |j d|_Wn)tk r}tdt|nXtjj|j d |_tj|jd }|j|_|j|_d S( si Class method for parsing data object cache (DOC) objects for use by the checkpoint. RRRZRaiRRRs'Error retrieving a value from the DOC: s .image_infoiN(RKR[RjRR"RlR~RR!RgRRRRRtKeyErrorRdReR~RRRLRRRYRRORD(RQRWtmsgR((sboot.pyR]Zs, cCsF|jjjdkrdS|jjddt}tjj|j d}t |d%}|j |d|j dWdQX|sBd}d}td |g}zTt|}|jj}|jd d }tj|jj} |jjd |j|jjd |t |jd} t |dt} | j tx.t| tD]} | j | jtqUW| t} | dkr| j | j| nWdQXWdQXtjd}tt}| t}d|||f}|jjd||td||g}t||jjd|tjj|jd}td|d|dd|g}t|tjj|jt }|jjd|t |dL} t |d4} x*ttD]} | j | jtqWWdQXWdQXWd|dk r!td|g}t|nXtj!||jjdndS(sI Creates an embeddable boot image for GRUB2 based USB boot media tGRUB2Ns/Preparing MBR embedded GRUB2 boot image for USBi tmbr_embedded_grub2RiR8s-atlofitrlofisEFI system partition image: %ss)Writing EFI system partition image to: %sR7is EFI Systems%d:0:0:0:0:0:0:0:%d:%dsCreating fdisk table on %s: %ss-AsInstalling GRUB2 on %ssboot/grub/i386-pcs-ds--root-device=(hostdisk/t)s-MsWriting GRUB2 MBR image to: %ss&MBR embedded GRUB2 boot image complete("RHRRRRgRhtMBR~RRRR;tseekRR>tLOFIADMRRRRTtstatt_uefi_image_nametst_sizeRktrangetKBRR2t name_to_numt BLOCKSIZER/Rt GRUB_SETUPt MBR_IMG_RPATHtunlink(RQRWt imagesizet imagenamet imagefiletlofi_devt lofi_rdevR R tuefi_image_sizeRtdstRKttailtesptypet startblocktuefi_image_nblockst fdiskentryt bios_grub_dirtusb_image_name((sboot.pyt_prepare_usb_bootzst        %            *  cCsr|jjdtt|j|y|j|j|Wn*tk rm|jjt j nXdS(sF Primary execution method used by the Checkpoint parent class s.=== Executing Boot Loader Setup Checkpoint ===N( RgRhR7RRtupdate_img_info_pathRRRkRR(RQRW((sboot.pyRs  cCs|r!tjdddd}n |j}|j|jtj<|j|jtj<|jj d||j j |d}|jj d||j |||rt|ndS(sJ Install the boot loader and associated boot configuration files. Rs/tmpRtiso_boot_config_s Writing boot configuration to %ssboot_config_list = %sN(RRRRGR RR tTOKEN_ODD_ROOTRgRkRHRR>R}R(RQRWRRy((sboot.pyRqs c Csp|jjd|jt|jdA}y|jd|jWntk re}t|nXWdQXdS(s6 Method to write out the .img_info_path file. s Updating %ssa+s GRUB_TITLE=N(RgRhRLR;RRDtIOErrorRd(RQtiipR((sboot.pyRs c Csidtj6dtj6dtj6}|d}|d}|d d krQ|}n|d |j}|j|}|d krtd |n |\}} tj j |std ||fn|tjkr||_ n|t kr|j jd |tj|d Stj j|j|jsMtd||jfn||krltj||n|jr|jjjdtn|j|jtjd|j|<|jjjtt|jdt |j jd| |j|fd S(sw Method that copies ISO El Torito and HSFS bootblockimage file types to their appropriate targets. sbios-eltorito-imgtBIOSsuefi-eltorito-imgtUEFIszvmm-eltorito-imgtzvmmiiis+Unrecognised ISO boot loader image type: %ss9Expected boot image type '%s' does not exist at path: %ssDeleting El Torito image: %sNs>El Torito boot image '%s' mislocated outside of image root: %sRRt generate_xmls %s El Torito boot image name: %s(sbios-eltorito-imgR(suefi-eltorito-imgR(szvmm-eltorito-imgR(R RuRvRwR>RGRRdR~RRRRlRgRkRRRRtrenameRRKR[tdelete_childrenRRtseptinsert_childrenR"Rh( RQRHRWt eltorito_dicttimg_typeRRtimg_valtimg_idt firmware_id((sboot.pyRxsH              $   (RRRRRRR8RpRYRRVRMRXR]RRRqRRx(((sboot.pyRs  5     _  tAIISOImageBootMenucBsAeZdZddZddZdZdZdZRS(s~ Class for AIISOImageBootMenu checkpoint. Used by Distro Constructor for creation of Automated Install ISO image. cCsCtt|j|d|_|r5|j|n |jdS(s Constructor for class N(R7RR8R>tinstalladm_entryt_AIISOImageBootMenu__setup(RQRRtarg((sboot.pyR8Ps  s boot imagecCs ||_dS(s: Setup checkpoint with any kwargs in manifest XML N(R(RQR((sboot.pyt__setupZscCshtt|jy |jjjtjtjWn.t k rc|j j d|jjj nXdS(s] Instantiates the appropriate bootmgmt.bootConfig subclass object for AI sEBoot loader type %s does not support the'console' property. Ignoring.N( R7RRpRHRRRRdRjRRgR1RR(RQ((sboot.pyRp_s   cCs|jd|jd|jd|jd|jd|jdg}ddd d d d g}xgt|D]Y\}}t|j}||_|d krt|_n|||_|jj |qgW|j dS(s{ Constructs the default boot entries and inserts them into the bootConfig object's boot_instances list s Automated Install customs Automated Installs Automated Install custom ttyas Automated Install custom ttybs Automated Install ttyas Automated Install ttybs!-B install=true,aimanifest=prompts-B install=trues.-B install=true,aimanifest=prompt,console=ttyas.-B install=true,aimanifest=prompt,console=ttybs-B install=true,console=ttyas-B install=true,console=ttybiN( RDR<RRRfRlRRiRHRR(RQt ai_titlestai_kargsRKRfR^((sboot.pyRUos(          c Cs|jjd|jt|jds}yJ|jd|jd|jd|jd|jd|jWntk r}t|nXWdQXdS( s6 Method to write out the .img_info_path file. s Updating %ssa+s GRUB_TITLE=s sGRUB_MIN_MEM64=0 sGRUB_DO_SAFE_DEFAULT=true sNO_INSTALL_GRUB_TITLE=%s N( RgRhRLR;RRDRRRd(RQRR((sboot.pyRs  N( RRRR>R8RRpRUR(((sboot.pyRKs    tArchiveISOImageBootMenucBs,eZdZddZdZdZRS(s Class for ArchiveISOImageBootMenu checkpoint. Used by archiveadm for creation of Automated Install ISO image with an embedded archive. cCstt|j|dS(s Constructor for class N(R7R R8(RQRRR((sboot.pyR8scCs3tt|j|jjjtjtjdS(s] Instantiates the appropriate bootmgmt.bootConfig subclass object for AI N( R7R RpRHRRRRdRj(RQ((sboot.pyRps cCsddg}ddg}xgt|D]Y\}}t|j}||_|dkrat|_n|||_|jj|q%W|j dS(s{ Constructs the default boot entries and inserts them into the bootConfig object's boot_instances list sAutomated Archive Installations Login Prompts"-B install=true,aimanifest=defaultRiN( R<RRRfRlRRiRHRR(RQR R RKRfR^((sboot.pyRUs      N(RRRR>R8RpRU(((sboot.pyR s  tLiveCDISOImageBootMenucBs)eZdZdZdZdZRS(s Class for LiveCDISOImageBootMenu checkpoint. Used by Distro Constructor for creation of LiveCD ISO image. cCstt|j|dS(s Constructor for class N(R7R R8(RQRR((sboot.pyR8scCshtt|jy |jjjtjtjWn.t k rc|j j d|jjj nXdS(sa Instantiates the appropriate bootmgmt.bootConfig subclass object for LiveCD sEBoot loader type %s does not support the'console' property. Ignoring.N( R7R RpRHRRRRdRhRRgR1RR(RQ((sboot.pyRps   cCs|j|jd|jd|jdg}ddddg}xgt|D]Y\}}t|j}||_|dkrt|_n|||_|j j |qIW|j dS( s{ Constructs the default boot entries and inserts them into the bootConfig object's boot_instances list s VESA drivers text consoles Enable SSHs-B livemode=vesas-B livemode=texts-B livessh=enableiN( RDR>R<RRRfRlRRiRHRR(RQt lcd_titlest lcd_kargsRKRfR^((sboot.pyRUs        (RRRR8RpRU(((sboot.pyR s  tTextISOImageBootMenucBs/eZdZdZdZdZdZRS(s} Class for TextISOImageBootMenu checkpoint. Used by Distro Constructor for creation of Text installer ISO image. icCs&tt|j|tj|_dS(s Constructor for class N(R7RR8RARB(RQRR((sboot.pyR8scCstt|jy|jjjtjtWn!t k rS|j j dnXy |jjjtj tj Wn!t k r|j j dnXdS(sg Instantiates the appropriate bootmgmt.bootConfig subclass object for Text Install s;Bootloader does not support the 'quiet' property. Ignoring.s=Bootloader does not support the 'console' property. Ignoring.N(R7RRpRHRRRt PROP_QUIETRlRRgR1RdRj(RQ((sboot.pyRps   cCs|j|jd|jdg}dddg}xgt|D]Y\}}t|j}||_|dkrxt|_n|||_|j j |q<W|j dS(s{ Constructs the default boot entries and inserts them into the bootConfig object's boot_instances list s ttyas ttybs-B console=ttyas-B console=ttybiN( RDR>R<RRRfRlRRiRHRR(RQt ti_titlestti_kargsRKRfR^((sboot.pyRUs      (RRRRAR8RpRU(((sboot.pyRs   (jRRR>RARR~R9R?RRtgrpRtpwdRtshutilRRtbootmgmtRRRRRR tbootmgmt.bootconfigR R R R RRRtbootmgmt.bootinfoRtbootmgmt.bootloaderRtbootmgmt.versabootRRRtloggingRtsolaris_installRRRRRRRtsolaris_install.boot.boot_specRRR tsolaris_install.data_objectR!t%solaris_install.data_object.data_dictR"tsolaris_install.engineR#t!solaris_install.engine.checkpointR$t Checkpointtsolaris_install.loggerR%R(tsolaris_install.netifR&tsolaris_install.targetR'tsolaris_install.target.logicalR(R)R*R+R,R-tsolaris_install.target.physicalR.R/R0R1R2R3t'solaris_install.transfer.media_transferR4RRRRRRRRRRRRRR6RRRR R R(((sboot.pytsn         .44.. ^P+5