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    
Size: Mime:
ó
±EYc@s;ddlZddlZddlZddlmZddlmZddlmZ	ddl
mZddl
mZddl
ZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZejjZe	jeƒZdZ d„Z!d„Z"d„Z#dd„Z%e&d„Z'dd„Z(e)dd„Z*de&dde)d„Z+dd„Z,d„Z-d„Z.d„Z/d„Z0d„Z1d„Z2d„Z3d„Z4d „Z5d!„Z6d"„Z7d#„Z8d$„Z9d%„Z:e&d&„Z;dd'„Z<d(„Z=dd)„Z>d*„Z?dS(+iÿÿÿÿN(tetree(tprocessutils(tlog(tarch(tvm_mode(t_(t_LI(tutils(timages(tconfig(tremotefs(tvolumeutilssnova-resizecOstj||ŽS(N(Rtexecute(targstkwargs((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyR.scCs
tjƒS(N(Rtget_iscsi_initiator(((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyR2scCstddd|||ƒdS(s5Create a disk image

    :param disk_format: Disk image format (as known by qemu-img)
    :param path: Desired location of the disk image
    :param size: Desired size of disk image. May be given as an int or
                 a string. If given as an int, it will be interpreted
                 as bytes. If it's a string, it should consist of a number
                 with an optional suffix ('K' for Kibibytes,
                 M for Mebibytes, 'G' for Gibibytes, 'T' for Tebibytes).
                 If no suffix is given, it will be interpreted as bytes.
    sqemu-imgtcreates-fN(R(tdisk_formattpathtsize((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytcreate_image6scCsÖddddg}g}|rA|d|g7}tj|ƒ}nd
}|rs|jd
k	rs|d|jg7}n|d
k	r“|d|g7}n|r·dj|ƒ}d	|g}n|||g}t|Œd
S(sÅCreate COW image

    Creates a COW image with the given backing file

    :param backing_file: Existing image on which to base the COW image
    :param path: Desired location of the COW image
    sqemu-imgRs-ftqcow2sbacking_file=%sscluster_size=%sssize=%st,s-oN(Rt
qemu_img_infotNonetcluster_sizetjoinR(tbacking_fileRRtbase_cmdtcow_optstbase_detailstcsv_optstcmd((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytcreate_cow_imageEscCs]tjjdkr?|rdS|dkr¥ytdddtdtƒWq¥tk
r€}|jtjkrztj	dƒd	S‚q¥t
jk
r¡tj	d
ƒd	SXnyXtdddtƒ\}}|d
kræ|dkrßdSdSntj
tdƒ|ƒWn8tk
r7}|jtjkr1tj	dƒq8‚nXdSntjjdkrUd	SdSdS(smPick the libvirt primary backend driver name

    If the hypervisor supports multiple backend drivers we have to tell libvirt
    which one should be used.

    Xen supports the following drivers: "tap", "tap2", "phy", "file", or
    "qemu", being "qemu" the preferred one. Qemu only supports "qemu".

    :param is_block_dev:
    :returns: driver_name or None
    txentphyiÐ=txendtstatustrun_as_roottcheck_exit_codesxend is not foundtqemusxend is not startedstap-ctltchecksok
i	=ttap2ttapstap-ctl check: %sstap-ctl tool is not installedtfiletkvmN(skvmsqemu(tCONFtlibvirtt	virt_typeRtTruetOSErrorterrnotENOENTtLOGtdebugRtProcessExecutionErrortFalsetinfoRR(thypervisor_versiontis_block_devtexctoutterr((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytpick_disk_driver_namees<

cCstj||ƒj}t|ƒS(sðGet the (virtual) size of a disk image

    :param path: Path to the disk image
    :param format: the on-disk format of path
    :returns: Size (in bytes) of the given disk image as it would be seen
              by a virtual machine.
    (RRtvirtual_sizetint(RtformatR((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyt
get_disk_sizescCs:tj||ƒj}|r6|r6tjj|ƒ}n|S(s„Get the backing file of a disk image

    :param path: Path to the disk image
    :returns: a path to the image's backing store
    (RRRtosRtbasename(RRERBR((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytget_disk_backing_file©sc	Cs‰|stdd||ƒni|r>dtj|ƒ|f}ndtj|ƒ|f}tjƒ}|j||d|d|d|ƒdS(s¼Copy a disk image to an existing directory

    :param src: Source image
    :param dest: Destination path
    :param host: Remote host
    :param receive: Reverse the rsync direction
    :param on_execute: Callback method to store pid of process in cache
    :param on_completion: Callback method to remove pid of process from cache
    :param compression: Allows to use rsync operation with or without
                        compression
    tcps-rs%s:%st
on_executet
on_completiontcompressionN(RRtsafe_ip_formatR
tRemoteFilesystemt	copy_file(tsrctdestthosttreceiveRHRIRJtremote_filesystem_driver((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyt
copy_image¶scCs_|rtj|ƒ}nz)t|dƒ}|j|ƒWdQXWd|rZtj|ƒnXdS(sÃWrite the given contents to a file

    :param path: Destination file
    :param contents: Desired contents of the file
    :param umask: Umask to set when creating this file (will be reset)
    twN(RDtumasktopentwrite(RtcontentsRUtsaved_umasktf((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyt
write_to_fileØscCstd||dtƒdS(s§Change ownership of file or directory

    :param path: File or directory whose ownership to change
    :param owner: Desired new owner (given as uid or username)
    tchownR&N(RR1(Rtowner((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyR\êscCstdd|dtƒdS(sSTouch a file without being the owner.

    :param path: File bump the mtime on
    ttouchs-cR&N(RR1(R((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytupdate_mtimeóscCsd|j|j|jfS(Ns%s:%s:%s(tstartttargettcount(tid_map((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyt_id_map_to_configûsc
Csšdjg|D]$}t|tjƒr
t|ƒ^q
ƒ}djg|D]$}t|tjƒrGt|ƒ^qGƒ}tddd|d||dtƒdS(sÂChange ownership of file or directory for an id mapped
    environment

    :param path: File or directory whose ownership to change
    :param id_maps: List of type LibvirtConfigGuestIDMap
    Rsnova-idmapshifts-is-us-gR&N(Rt
isinstancetvconfigtLibvirtConfigGuestUIDMapRdtLibvirtConfigGuestGIDMapRR1(Rtid_mapsRctuid_maps_strtgid_maps_str((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytchown_for_id_mapsÿs!!cCs…|dkrd}n|dkr*d}nddd|d|f}tjjrg|d	krg|d7}n|||f7}t|ŒdS(
s×Extract a snapshot from a disk image.
    Note that nobody should write to the disk image during this operation.

    :param disk_path: Path to disk image
    :param out_path: Desired path of extracted snapshot
    tisotrawtploopt	parallelssqemu-imgtconverts-fs-ORs-cN(s-c(R.R/tsnapshot_compressionR(t	disk_patht
source_fmttout_pathtdest_fmttqemu_img_cmd((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytextract_snapshots		
cCs&t|dƒ}|jƒSWdQXdS(s9Read contents of file

    :param path: File to read
    trN(RVtread(Rtfp((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyt	load_file'scOs
t||ŽS(søOpen file

    see built-in open() documentation for more details

    Note: The reason this is kept in a separate module is to easily
          be able to provide a stub module that doesn't alter system
          state at all (for unit tests)
    (RV(R
R((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyt	file_open0s	cCs
tj|ƒS(sËDelete (unlink) file

    Note: The reason this is kept in a separate module is to easily
          be able to provide a stub module that doesn't alter system
          state at all (for unit tests)
    (RDtunlink(R((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytfile_delete<scCstjj|ƒS(sÍReturns if path exists

    Note: The reason this is kept in a separate module is to easily
          be able to provide a stub module that doesn't alter system
          state at all (for unit tests)
    (RDRtexists(R((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytpath_existsFsc
Csù|jdƒ}tj|ƒ}|jdƒj}d}tjjdkr²|jdƒ}|jdƒ}|jdƒ}|j	dƒ}|d|j
dƒ!}tjj
|d	ƒ}nétjjd
kr|tjkr|jdƒ}|jdƒ}|jdƒ}|j	dƒ}n‰|jdƒ}|jdƒ}|jdƒ}|j	dƒpZ|j	d
ƒ}|r›tjjdkr›|j	dƒ}|r›d|}q›n|s¶ttdƒƒ‚n|dk	ré|j	dƒ}	|	dkrïd}	qïnd}	||	fS(sBFind root device path for instance

    May be file or device
    isos/typetlxcsdevices/filesystemtdrivertsourcetdirtrootfstdiskRpR,sdevices/disktdevtrbdtnamesrbd:sCCan't retrieve root device path from instance libvirt configurationttypetaioRnN(tXMLDescRt
fromstringtfindttextRR.R/R0tgettrfindRDRRRtEXEtimages_typetRuntimeErrorR(
tvirt_domtxml_desctdomaintos_typeRƒt
filesystemR„RsR‡RB((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyt	find_diskPs@!cCsa|jdƒrdS|jdƒr&dStjj|ƒr]tjjtjj|dƒƒr]dSdS(s;Retrieve disk type (raw, qcow2, lvm, ploop) for given file.s/devtlvmsrbd:R‰sDiskDescriptor.xmlRoN(t
startswithRDRtisdirR€RR(R((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytget_disk_type_from_paths!cCs_tj|ƒ}|j|j}|j|j}|j|j|j}i|d6|d6|d6S(s+Get free/used/total space info for a filesystem

    :param path: Any dirent on the filesystem
    :returns: A dict containing:

             :free: How much space is free (in bytes)
             :used: How much space is used (in bytes)
             :total: How big the filesystem is (in bytes)
    ttotaltfreetused(RDtstatvfstf_frsizetf_blockstf_bavailtf_bfree(RthddinfoR R¡R¢((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytget_fs_infos

cCstj|||ƒdS(sGrab image.N(Rtfetch_to_raw(tcontextRatimage_id((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytfetch_image¢scCstj|||ƒdS(sˆGrab initrd or kernel image.

    This function does not attempt raw conversion, as these images will
    already be in raw format.
    N(Rtfetch(R«RaR¬((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytfetch_raw_image§scCs&|r
|jStjjtj|jƒS(s0Determine the correct path for instance storage.

    This method determines the directory name for instance storage.

    :param instance: the instance we want a path for
    :param relative: if True, just the relative path is returned

    :returns: a path to store information about that instance
    (tuuidRDRRR.tinstances_path(tinstancetrelative((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytget_instance_path°s
cCsId}|r|j}n|r9tjjtj|ƒ}nt|ƒ}|S(sÖGet the instance path on destination node while live migration.

    This method determines the directory name for instance storage on
    destination node, while live migration.

    :param instance: the instance we want a path for
    :param migrate_data: if not None, it is a dict which holds data
                         required for live migration without shared
                         storage.

    :returns: a path to store information about that instance
    N(Rtinstance_relative_pathRDRRR.R±R´(R²tmigrate_dataRµtinstance_dir((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyt get_instance_path_at_destination¿s
cCs5|r+|jjdƒ}|dk	r+|SntjƒS(s´Determine the architecture of the guest (or host).

    This method determines the CPU architecture that must be supported by
    the hypervisor. It gets the (guest) arch info from image_meta properties,
    and it will fallback to the nova-compute (host) arch if no architecture
    info is provided in image_meta.

    :param image_meta: the metadata associated with the instance image

    :returns: guest (or host) architecture
    thw_architectureN(t
propertiesR‘RRt	from_host(t
image_metat
image_arch((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytget_archÚs
cCs—y@dd|g}|r.|jd|gƒntj|ŒtSWnPtjk
rWtStk
r’}|jtj	krŽt
jtdƒƒntSXdS(s@Check if the given source is mounted at given destination point.tfindmnts--targets--sourcesfindmnt tool is not installedN(
textendRRR1RR7R8R2R3R4R5R9R(t
mount_pathR„t	check_cmdR<((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyt
is_mountedîs
cCstjd|ƒS(Ns^[\w\-\.:]+$(tretmatch(thostname((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pytis_valid_hostnames(@R3RDRÄtlxmlRtoslo_concurrencyRtoslo_logRtloggingtnova.computeRRt	nova.conftnovat	nova.i18nRRRt	nova.virtRtnova.virt.libvirtR	Rftnova.virt.libvirt.volumeR
RtconfR.t	getLoggert__name__R5tRESIZE_SNAPSHOT_NAMERRRRR!R8R?RCR1RFRSR[R\R_RdRlRxR|R}RRR›RŸR©R­R¯R´R¸R¾RÃRÇ(((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/libvirt/utils.pyt<module>s`			 8
 										
	
	1