Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / nova / virt / libvirt / migration.pyc
Size: Mime:
ó
±EYc@sdZddlmZddlmZddlmZddlm	Z	ddl
mZddl
mZej
eƒZdZd„Zd	„Zd
„Zd„Zd„Zd
„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z dS(s,Utility methods to manage guests migration

iÿÿÿÿ(tdeque(tetree(tlog(tpower_state(t_LI(t_LWcCs‰d}|jdƒs$|jdƒr;idd6dd6}n|jdƒr`t|jƒ|d<n|jdƒr…t|jƒ|d<n|S(sCReturns listen addresses of vnc/spice from a LibvirtLiveMigrateDatatgraphics_listen_addr_vnctgraphics_listen_addr_spicetvnctspiceN(tNonetobj_attr_is_settstrRR(tmigrate_datatlisten_addrs((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pytgraphics_listen_addrs$scCs+d}|jdƒr't|jƒ}n|S(s;Returns listen address serial from a LibvirtLiveMigrateDatatserial_listen_addrN(R
RRR(R
tlisten_addr((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pyR2scCsgtj|jdtƒƒ}t||ƒ}t||ƒ}t|||ƒ}t||ƒ}tj|ƒS(Ntdump_migratable(	Rt
fromstringtget_xml_desctTruet_update_graphics_xmlt_update_serial_xmlt_update_volume_xmlt_update_perf_events_xmlttostring(tguestR
tget_volume_configtxml_doc((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pytget_updated_guest_xml:scCs¦t|ƒ}x“|jdƒD]‚}|jdƒ}|jdƒ}|dkr|dk	ro|jd||ƒn|jdƒdk	rž|jd||ƒqžqqW|S(Ns./devices/graphicsttypetlistenRR	taddress(svncsspice(RtfindalltgettfindR
tset(RR
Rtdevtgr_typet
listen_tag((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pyRCscCs”t|ƒ}x?|jdƒD].}|jdƒdk	r|jd|ƒqqWx?|jdƒD].}|jdƒdk	r^|jd|ƒq^q^W|S(Ns$./devices/serial[@type='tcp']/sourcethosts%./devices/console[@type='tcp']/source(RR"R#R
R%(RR
RR&((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pyRRsc
Csª|j}tjdtƒ}|jdƒ}d„|Dƒ}xit|ƒD][\}}|jdƒ}	|j|	ƒ}
|	dksG|
sG|
j	sG|	|kr qGn||
j	|
j
ƒƒ}tj|jƒ|ƒ}|jdƒ}
|
rG|	|
krGt
jdi|d6|	d6ƒx]t|ƒD]O\}}x@|j|jƒD],}|j|ƒd|_|j||ƒq;WqWx0t|ƒD]}d|_|j||ƒq|WqGqGW|S(	s8Update XML using device information of destination host.tremove_blank_texts./devices/diskcSsi|]}||j“qS((tserial(t.0tx((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pys
<dictcomp>es	R+s4Find same serial number: pos=%(pos)s, serial=%(num)stpostnumN(tbdmsRt	XMLParserRR"t	enumeratetfindtextR#R
tconnection_infotas_disk_infotXMLtto_xmltLOGtdebugttagtremovettailtinserttlist(RR
Rtmigrate_bdm_infotparsert
disk_nodestbdm_info_by_serialR.tdisk_devt
serial_sourcetbdm_infotconftxml_doc2tserial_desttcnttitem_srctitem_dst((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pyR]s6		
		c	Csâg}t}d|kr$|j}n|jdƒ}|sQtjdƒ}t}n4|d}x't|ƒD]\}}|j|ƒqhW|s|Sx6|D].}tjdddd|ƒ}|j|ƒq–W|sÞ|j|ƒn|S(	s7Update XML by the supported events of destination host.tsupported_perf_eventss./perftperfiteventtenabledtyestname(	RRLR"RtElementtFalseR2R;tappend(	RR
RLtold_xml_has_perftperf_eventst_RNtet	new_event((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pyRˆs&	

cCs×yD|jƒr)tjdd|ƒtjStjdd|ƒtjSWnŒtjk
rÒ}tjdi|d6d|ƒ|jƒtjkr¥tjdd|ƒtjStj	t
dƒi|d6d|ƒtjSnXdS(	s¿Determine the (likely) current migration job type

    :param guest: a nova.virt.libvirt.guest.Guest
    :param instance: a nova.objects.Instance

    Annoyingly when job type == NONE and migration is
    no longer running, we don't know whether we stopped
    because of failure or completion. We can distinguish
    these cases by seeing if the VM still exists & is
    running on the current host

    :returns: a libvirt job type constant
    s#VM running on src, migration failedtinstances!VM is shutoff, migration finisheds#Error checking domain status %(ex)stexs!VM is missing, migration finishedsError %(ex)s, migration failedN(t	is_activeR8R9tlibvirttVIR_DOMAIN_JOB_FAILEDtVIR_DOMAIN_JOB_COMPLETEDtlibvirtErrortget_error_codetVIR_ERR_NO_DOMAINtinfoR(RRZR[((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pyt
find_job_typeªs$	cCsŒ|dkrtS|dkrP|||krPtjtdƒ||d|ƒtS|dkrˆ||krˆtjtdƒ|d|ƒtStS(sñDetermine if the migration should be aborted

    :param instance: a nova.objects.Instance
    :param now: current time in secs since epoch
    :param progress_time: when progress was last made in secs since epoch
    :param progress_timeout: time in secs to allow for progress
    :param elapsed: total elapsed time of migration in secs
    :param completion_timeout: time in secs to allow for completion
    :param migration_status: current status of the migration

    Check the progress and completion timeouts to determine if either
    of them have been hit, and should thus cause migration to be aborted

    Avoid migration to be aborted if it is running in post-copy mode

    :returns: True if migration should be aborted, False otherwise
    srunning (post-copy)isLive migration stuck for %d secRZs)Live migration not completed after %d sec(RSR8twarningRR(RZtnowt
progress_timetprogress_timeouttelapsedtcompletion_timeouttmigration_status((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pytshould_abortÎs	
cCsW|dks|dkrtS|dkrSt||d|ƒ}|dkrStSntS(svDetermine if the migration should be switched to postcopy mode

    :param memory_iteration: Number of memory iterations during the migration
    :param current_data_remaining: amount of memory to be transferred
    :param previous_data_remaining: previous memory to be transferred
    :param migration_status: current status of the migration

    Check the progress after the first memory iteration to determine if the
    migration should be switched to post-copy mode

    Avoid post-copy switch if already running in post-copy mode

    :returns: True if migration should be switched to postcopy mode,
    False otherwise
    srunning (post-copy)iiidi
(RStroundR(tmemory_iterationtcurrent_data_remainingtprevious_data_remainingRktprogress_percentage((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pytshould_switch_to_postcopyöscCs;tjdi|d6|d6|d6d|ƒd}x'|D]}||dkr8|}q8q8W|dkr~tjdd|ƒ|S|d|kr¥tjd	d|ƒ|Stjtd
ƒi|dd6|dd6d|ƒy|j|dƒWnDtjk
r2}tjt	d
ƒi|dd6|d6d|ƒnX|dS(sUpdate max downtime if needed

    :param guest: a nova.virt.libvirt.guest.Guest to set downtime for
    :param instance: a nova.objects.Instance
    :param olddowntime: current set downtime, or None
    :param downtime_steps: list of downtime steps
    :param elapsed: total time of migration in secs

    Determine if the maximum downtime needs to be increased
    based on the downtime steps. Each element in the downtime
    steps list should be a 2 element tuple. The first element
    contains a time marker and the second element contains
    the downtime value to set when the marker is hit.

    The guest object will be used to change the current
    downtime value on the instance.

    Any errors hit when updating downtime will be ignored

    :returns: the new downtime value
    s2Current %(dt)s elapsed %(elapsed)d steps %(steps)stdtRitstepsRZisNo current stepis Downtime does not need to changesJIncreasing downtime to %(downtime)d ms after %(waittime)d sec elapsed timetdowntimetwaittimes4Unable to increase max downtime to %(time)dms: %(e)sttimeRXN(
R8R9R
RcRtmigrate_configure_max_downtimeR]R`ReR(RRZtolddowntimetdowntime_stepsRitthissteptstepRX((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pytupdate_downtimes0	

#cCsm|j|_|j|_|j|_|j|_|j|_|j|_|jƒd||_|jƒdS(sRSave migration stats to the database

    :param instance: a nova.objects.Instance
    :param migration: a nova.objects.Migration
    :param info: a nova.virt.libvirt.guest.JobInfo
    :param remaining: percentage data remaining to transfer

    Update the migration and instance objects with
    the latest available migration stats
    idN(tmemory_totaltmemory_processedtmemory_remainingt
disk_totaltdisk_processedtdisk_remainingtsavetprogress(RZt	migrationRct	remaining((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pyt
save_statsOs


cCssy|jƒWn2tjk
rB}tjtdƒ|d|ƒn-Xtjtdƒd|ƒd|_|j	ƒdS(Ns0Failed to switch to post-copy live migration: %sRZs%Switching to post-copy migration modesrunning (post-copy)(
tmigrate_start_postcopyR]R`R8ReRRcRtstatusR„(RRZR†RX((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pyttrigger_postcopy_switchis	c	Csø|j|jtƒƒ}xÙ|ró|jƒ}|dkrÍ|jdkrdtjtdƒd|ƒqð|r}t|||ƒqðy|j	ƒ|j
dƒWqðtk
rÉ}tjtdƒ|d|ƒqðXqtjtdƒi|d6d|ƒqWd	S(
sŸRun any pending migration tasks

    :param guest: a nova.virt.libvirt.guest.Guest
    :param instance: a nova.objects.Instance
    :param active_migrations: dict of active migrations
    :param on_migration_failure: queue of recovery tasks
    :param migration: a nova.objects.Migration
    :param is_post_copy_enabled: True if post-copy can be used

    Run any pending migration tasks queued against the
    provided instance object. The active migrations dict
    should use instance UUIDs for keys and a queue of
    tasks as the values.

    Currently the valid tasks that can be requested
    are "pause" and "force-complete". Other tasks will
    be ignored.
    sforce-completesrunning (post-copy)s5Live-migration %s already switched to post-copy mode.RZtunpauses1Failed to pause instance during live-migration %ss!Unknown migration task '%(task)s'ttaskN(R#tuuidRtpopleftRŠR8ReRR‹tpauseRTt	Exception(	RRZtactive_migrationston_migration_failureR†tis_post_copy_enabledttasksRRX((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pyt	run_taskszs"	

cCs°x©|r«|jƒ}|dkr…y/|j|ƒ}|tjkrO|jƒnWq¨tk
r}tjtdƒ|d|ƒq¨Xqtjtdƒi|d6d|ƒqWdS(s¨Run any pending migration recovery tasks

    :param host: a nova.virt.libvirt.host.Host
    :param guest: a nova.virt.libvirt.guest.Guest
    :param instance: a nova.objects.Instance
    :param on_migration_failure: queue of recovery tasks

    Run any recovery tasks provided in the on_migration_failure
    queue.

    Currently the only valid task that can be requested
    is "unpause". Other tasks will be ignored
    RŒsBFailed to resume paused instance before live-migration rollback %sRZs!Unknown migration task '%(task)s'RN(	Rtget_power_stateRtPAUSEDtresumeR‘R8ReR(R)RRZR“RtstateRX((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pytrun_recover_tasks¦s	N(!t__doc__tcollectionsRtlxmlRtoslo_logRtloggingtnova.computeRt	nova.i18nRRt	getLoggert__name__R8R
R]RRRRRRRRdRlRrR}RˆR‹R–R›(((sP/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/migration.pyt<module>s.							+	"	$	(	!	8			,