Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/package/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyc


Tc@sPddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZddl
mZmZddlmZddlmZddlmZmZmZddlmZdd	lmZmZdd
lmZdefdYZd
efdYZ dZ!dZ"dS(iN(tsucceed(turl_to_filenametfetch_to_files(tparse_lsb_releasetLSB_RELEASE_FILENAME(t
gpg_verify(t	read_file(tPackageTaskHandlerConfigurationtPackageTaskHandlertrun_task_handler(t
spawn_process(t	SUCCEEDEDtFAILED(tfind_reporter_commandtReleaseUpgraderConfigurationcBseZdZedZRS(s=Specialized configuration for the Landscape release-upgrader.cCstjj|jdS(sV
        The directory where the upgrade-tool files get stored and extracted.
        supgrade-tool(tostpathtjointpackage_directory(tself((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pytupgrade_tool_directorys(t__name__t
__module__t__doc__tpropertyR(((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyRstReleaseUpgradercBseZdZeZdZeZdZdZ	dZ
dZdZdZ
dZd	Zd
ZdZdZeed
ZdZdZedZdZRS(s|Perform release upgrades.

    @cvar config_factory: The configuration class to use to build configuration
        objects to be passed to our constructor.
    @cvar queue_name: The queue we pick tasks from.
    @cvar lsb_release_filename: The path to the LSB data on the file system.
    @cvar landscape_ppa_url: The URL of the Landscape PPA, if it is present
        in the computer's sources.list it won't be commented out.
    @cvar logs_directory: Path to the directory holding the upgrade-tool logs.
    @cvar logs_limit: When reporting upgrade-tool logs to the server, only the
        last C{logs_limit} lines will be sent.
    srelease-upgraders0http://ppa.launchpad.net/landscape/trunk/ubuntu/s/var/log/dist-upgradeicCs'idd6|d6|d6|d6|d6S(s=Convenience to create messages of type C{"operation-result"}.soperation-resultttypesoperation-idtstatussresult-textsresult-code((Rtoperation_idRttexttcode((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pytmake_operation_result_message7s

cCs*|j}|ddkr&|j|SdS(s.Call the proper handler for the given C{task}.Rsrelease-upgradeN(tdatathandle_release_upgrade(Rttasktmessage((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pythandle_task?s	cs|d|dtj}|dkrojtdd}tjdj|S|d}|d}|jdt|jd	tj	j
}t|d
|t|d
|j||}|j
fd|j
fd|j
fd
|j
fd|j
fd|jj|S(swFetch the upgrade-tool, verify it and run it.

        @param message: A message of type C{"release-upgrade"}.
        s	code-namesoperation-ids!The system is already running %s.isBQueuing message with release upgrade failure to exchange urgently.supgrade-tool-tarball-urlsupgrade-tool-signature-urlsallow-third-partytdebugt	directorycsjS(N(tverify(tx(Rtsignature_filenamettarball_filename(sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyt<lambda>bs	cs
jS(N(textract(R((RR*(sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR+dscs
jS(N(ttweak(R((Rtcurrent_code_name(sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR+escsjddS(Ntallow_third_partyR%(tupgrade(R((ttarget_code_nameR/RRR%(sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR+fs	cs
jS(N(tfinish(R((R(sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR+is(Rtlsb_release_filenameRRtloggingtinfot
_send_messagetgettFalset_configRRtfetchtaddCallbackt
addErrbacktabort(RR#tlsb_release_infottarball_urlt
signature_urlR&tresult((R1R.R*RR)R/R%RsE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR!Es6






				"cCstjj|jjs.tj|jjnt||g|jjdtj}d}d}|j	||j
||S(sFetch the upgrade-tool files.

        @param tarball_url: The upgrade-tool tarball URL.
        @param signature_url: The upgrade-tool signature URL.
        tloggercSstjddS(Ns'Successfully fetched upgrade-tool files(R4R5(tignored((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pytlog_successzscSstjd|S(Ns%Couldn't fetch all upgrade-tool files(R4twarning(tfailure((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pytlog_failure}s
(RRtexistsR9RtmkdirRR4RER;R<(RR?R@RARDRG((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR:ms		

cCs?t||}d}d}|j||j||S(sVerify the upgrade-tool tarball against its signature.

        @param tarball_filename: The filename of the upgrade-tool tarball.
        @param signature_filename: The filename of the tarball signature.
        cSstjddS(Ns*Successfully verified upgrade-tool tarball(R4R5(RC((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyRDscSstjdt|j|S(Ns.Invalid signature for upgrade-tool tarball: %s(R4REtstrtvalue(RF((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyRGs	(RR;R<(RR*R)RARDRG((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR's		

cCsLtj|d}x-|jD]}|j|d|jjqWtdS(svExtract the upgrade-tool tarball.

        @param tarball_filename: The filename of the upgrade-tool tarball.
        sr:gzRN(ttarfiletopent
getmembersR,R9RRtNone(RR*ttftmember((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR,scCsX|jj}tjj|d}t|d}|j|jd|jt	dS(sTweak the files of the extracted tarballs to workaround known bugs.

        @param current_code_name: The code-name of the current release.
        smirrors.cfgtas
N(R9RRRRRMtwritetlandscape_ppa_urltcloseRRO(RR.Rtmirrors_filenametfd((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR-s	
cCstj}xFd|fd|fgD],\}}|r%|jd||fq%q%Wxwttj|jD]]}|jdsqnntjj	|j|}t
||j}|jd||fqnW|jS(sReturn the operation result text to be sent to the server.

        @param out: The standard output of the upgrade-tool process.
        @param err: The standard error of the upgrade-tool process.
        @return: A text aggregating the process output, error and log files.
        toutputterrors=== Standard %s ===

%s

s.logs=== %s ===

%s

(
t	cStringIOtStringIORStsortedRtlistdirtlogs_directorytendswithRRRt
logs_limittgetvalue(Rtoutterrtbuftlabeltcontenttbasenametfilename((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pytmake_operation_result_texts%c
sjj}tjj||}ddg}tjj}|rOd|d<n|rbd|d<nt|d|d|d|d	t}	fd
}
|	j	|
|	S(sSRun the upgrade-tool command and send a report of the results.

        @param code_name: The code-name of the release to upgrade to.
        @param operation_id: The activity id for this task.
        @param allow_third_party: Whether to enable non-official APT repo.
        @param debug: Whether to turn on debug level logging.
        s
--frontendtDistUpgradeViewNonInteractivetTruet!RELEASE_UPRADER_ALLOW_THIRD_PARTYtDEBUG_UPDATE_MANAGERtargstenvRt
wait_pipescsn|\}}}|dkr$t}nt}j||}j|||}tjdj|S(NisBQueuing message with release upgrade results to exchange urgently.(RRRiRR4R5R6(t.0RbRcRRRR#(RR(sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pytsend_operation_results	
(
R9RRRRtenvirontcopyR
R8R;(Rt	code_nameRR/R%Rtupgrade_tool_filenameRnRoRARr((RRsE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR0s	


cCstj|jjtjdkrLtjdj}t	j
dj}nd
}d
}t
}dg}|jjd
k	r|jd|jjnt|d|d|d|dtjd	tjS(sAClean-up the upgrade-tool files and report about package changes.it	landscapes--force-apt-updates--config=%sRntuidtgidRRoN(tshutiltrmtreeR9RRtgetuidtpwdtgetpwnamtpw_uidtgrptgetgrnamtgr_gidROR
tconfigtappendR
tgetcwdRs(RRxRytreporterRn((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR2s		cCs?|j|tdt|jd}tjd|j|S(s3Abort the task reporting details about the failure.s%sisBQueuing message with release upgrade failure to exchange urgently.(RRRJRKR4R5R6(RRFRR#((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR=s
cCstS(N(tfind_release_upgrader_command(((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pytfind_commandscs/j}fd}|j||S(s0Acquire a session ID and send the given message.csjjjtdS(N(t_brokertsend_messaget_session_idRk(t_(RR#(sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pytsends(tget_session_idR;(RR#tdeferredR((RR#sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR6s
(RRRRtconfig_factoryt
queue_nameRR3RTR^R`RR$R!R:R'R,R-RiR8R0R2R=tstaticmethodRR6(((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR"s*			(			
		#		cCs8tjjtjjtjd}tjj|dS(s9Return the path to the landscape-release-upgrader script.islandscape-release-upgrader(RRtdirnametabspathtsystargvR(R((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyR s%cCs2tjtjkr%tjntt|S(N(RtgetpgrptgetpidtsetsidR	R(Rn((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pytmain&s
(#RRRR}RzR4RLRZttwisted.internet.deferRtlandscape.lib.fetchRRtlandscape.lib.lsb_releaseRRtlandscape.lib.gpgRtlandscape.lib.fsRtlandscape.package.taskhandlerRRR	tlandscape.lib.twisted_utilR
tlandscape.manager.managerRRtlandscape.package.reporterR
RRRR(((sE/usr/lib/python2.7/dist-packages/landscape/package/releaseupgrader.pyt<module>s(