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:


ì]E6ã&@s»dZddlZyddlZWn!ek
rEddljZYnXyddlmZWn"ek
r~ddl	mZYnXyddl
ZWn"ek
r³ddlmZYnXyddl
mZWn"ek
rìddlmZYnXddlmZddlmZddlmZddlmZd	gZejeƒZejZejd
ddd
dƒgZejeƒejdd
dƒZ ej!e dƒGdd„dej"ƒZ#dS)z7Handles all requests relating to Contego functionality.éN)Úlog)Ú	messaging)Úcfg)Úbase)Úinstance)Úrpcz
live-snapshotÚ
contego_topicÚdefaultZ	contego_1Úhelpz!the topic Contego nodes listen onÚcontegoz7Set a version cap for messages sent to contego servicesÚcontego_upgrade_levelsc
sreZdZdZddddddddddiZd‡fd	d
†Zdd„Zd
d„Zdd„Zddd„Z	didddd„Z
dd„Zdd„Zdd„Z
dd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„Z‡S);ÚAPIz`Client side of the contego RPC API

    API version history:

    * 1.0 - Initial version.

    Zgrizzlyz1.0ZhavanaZicehouseZjunoZkiloNcs‰tt|ƒj|t|_tjdtjddƒ}|jj	tj
jtj
jƒ}tj
ƒ}tj|d|d|ƒ|_dS)NZtopicÚversionz1.0Úversion_capÚ
serializer)Úsuperr
Ú__init__ÚCAPABILITIESrZTargetÚCONFrÚVERSION_ALIASESÚgetrrÚobjects_baseZNovaObjectSerializerrZ
get_clientÚclient)ÚselfZ
image_serviceÚkwargsÚtargetrr)Ú	__class__©ú2/usr/lib/python3/dist-packages/contego/nova/api.pyrEs			zAPI.__init__cKs.|jjd|ddƒ}|j|||ƒS)NÚserverrz1.0)rÚprepareÚcall)rÚcontextÚmethodÚhostrÚcctxtrrrr!QszAPI.callcKs.|jjd|ddƒ}|j|||ƒS)Nrrz1.0)rr Úcast)rr"r#r$rr%rrrr&UszAPI.castcCs
d|jiS)NZcapabilities)r)rrrrÚget_infoYszAPI.get_infoFcCsJ|rtjj||ƒ}|S|jj||ƒ}tt|jƒƒƒS)z3Get a single instance with the given instance_uuid.)Úinstance_objZInstanceZget_by_uuidZdbZinstance_get_by_uuidÚdictÚiterÚitems)rr"Ú
instance_uuidZwant_objectrÚrvrrrr\s	zAPI.getipc		Cs©|s|d}|jjd|ddd|ƒ}|dkrS|j||d|ƒS|r|j||d|d	d
|d|ƒS|j||d|d	d
|d|ƒSdS)aGeneric handler for RPC casts/calls to contego topic.
           This only blocks for a response with is_call=True.

        :param params: Optional dictionary of arguments to be passed to the
                       contego worker

        :returns: None
        r$rrz1.0ÚtimeoutNÚparamsr,ÚuuidZinstance_ref)rr r!r&)	rr#r"rr$r/Úis_callr.r%rrrÚ_send_contego_messagefs

	
zAPI._send_contego_messagec
CsO|j||ƒ}tjdtƒƒ|jd||d|dd|ddƒS)z.
        Prepare to VAST the instance
        zprepare to vast the instanceÚvast_preparer$r/r1T)rÚLOGÚdebugÚlocalsr2)rr"r,r/rrrrr3€s

zAPI.vast_preparec
CsO|j||ƒ}tjdtƒƒ|jd||d|dd|ddƒS)z%
        Freeze the instance
        zfreeze the instanceÚvast_freezer$r/r1T)rr4r5r6r2)rr"r,r/rrrrr7Šs

zAPI.vast_freezec
CsO|j||ƒ}tjdtƒƒ|jd||d|dd|ddƒS)z#
        Thaw the instance
        zthaw the instanceÚ	vast_thawr$r/r1T)rr4r5r6r2)rr"r,r/rrrrr8”s

z
API.vast_thawcCsU|j||ƒ}tjdtƒƒ|jd||d|dd|ddddƒS)	z#
        VAST the instance
        zvast the instanceÚ
vast_instancer$r/r1Tr.ip)rr4r5r6r2)rr"r,r/rrrrr9žszAPI.vast_instancec
CsO|j||ƒ}tjdtƒƒ|jd||d|dd|ddƒS)z6
        Get details of a VASTed the instance
        zget details of vasted instanceÚ
vast_get_infor$r/r1T)rr4r5r6r2)rr"r,r/rrrrr:©s

zAPI.vast_get_infoc
CsO|j||ƒ}tjdtƒƒ|jd||d|dd|ddƒS)z2
        Get URL for the vast data server
        z$Get the URL for the vast data serverÚ
vast_data_urlr$r/r1T)rr4r5r6r2)rr"r,r/rrrrr;³s

zAPI.vast_data_urlcCsU|j||ƒ}tjdtƒƒ|jd||d|dd|ddddƒS)	z'
        Initiate data tranfer
        zinitiate data tranferÚvast_data_transferr$r/r1Tr.ip)rr4r5r6r2)rr"r,r/rrrrr<½szAPI.vast_data_transfercCsU|j||ƒ}tjdtƒƒ|jd||d|dd|ddddƒS)	z;
        Verify the existence of previous snapshot
        zVerifying previous snapshotÚvast_check_prev_snapshotr$r/r1Tr.ip)rr4r5r6r2)rr"r,r/rrrrr=ÈszAPI.vast_check_prev_snapshotcCsˆd|dkr-|dd}d|i}n|j||ƒ}|d}tjdtƒƒ|jd||d|d|ddd	d
ƒS)zB
        Get data transfer job status for the given token
        r$Úmetadatar0z0Get data transfer job status for the given tokenÚvast_async_task_statusr/r1Tr.ip)rr4r5r6r2)rr"r,r/r$rrrrr?Ós
			zAPI.vast_async_task_statuscCsU|j||ƒ}tjdtƒƒ|jd||d|dd|ddddƒS)	z
        Finalize VAST
        z"finalize the vast for the instanceÚ
vast_finalizer$r/r1Tr.ip)rr4r5r6r2)rr"r,r/rrrrr@äs
zAPI.vast_finalizec
Cs[|j|jddƒ|ƒ}tjdtƒƒ|jd||d|dd|ddƒS)	zS
        Reset the instance so other openstack operations can be unblocked
        Zread_deletedÚyeszvast reset the instanceÚ
vast_resetr$r/r1T)rZelevatedr4r5r6r2)rr"r,r/rrrrrBîs	zAPI.vast_resetc
CsO|j||ƒ}tjdtƒƒ|jd||d|dd|ddƒS)z'
        Commit snapshot image
        zCommiting snapshot imageÚvast_commit_imager$r/r1T)rr4r5r6r2)rr"r,r/rrrrrCùs
zAPI.vast_commit_imagecCsU|j||ƒ}tjdtƒƒ|jd||d|dd|ddddƒS)	zY
        Map snapshot files to file manager instance identified by instance_uuid
        zmap snapshot files to instanceÚmap_snapshot_filesr$r/r1Tr.ip)rr4r5r6r2)rr"r,r/rrrrrDszAPI.map_snapshot_filescCsU|j||ƒ}tjdtƒƒ|jd||d|dd|ddddƒS)	z-
        Copy backup image to volume
        z:Copy backup image to volume that is mapped to the instanceÚcopy_backup_image_to_volumer$r/r1Tr.ip)rr4r5r6r2)rr"r,r/rrrrrEs			zAPI.copy_backup_image_to_volumecCs5|d}|jd|dd|d|ddddƒS)	zC
        Backup OpenStack configuration for given services
        r$Úvast_config_backupNr/r1Tr.ip)r2)rr"Z	backup_idr/r$rrrrFs
zAPI.vast_config_backupcCsR|d}|j|ƒ}|d|d<|jd|dd|d|dddd	ƒS)
z7
        Validate trusted user and private key
        r$Úcontroller_nodesÚvalidate_trusted_user_and_keyNr/r1Tr.ip)Úget_controller_nodesr2)rr"r/r$rGrrrrH(s
z!API.validate_trusted_user_and_keycsdd„‰dd„}y¸g}tjd}ttdƒrnttdƒdkrn|tjƒ}|j|ƒd	d
„|Dƒ}tt|ƒƒ}d|kr¬|jdƒ‡fdd
†|Dƒ}d
|iSWn<t	k
r}zt
j|ƒd
giSWYdd}~XnXdS)z=
        Return list of RabbitMQ hosts known to Nova
        cSsEytj|ƒdSWn)tk
r@}z	|SWYdd}~XnXdS)Nr)ÚsocketÚ
gethostbyaddrÚ	Exception)ÚaddressÚexrrrÚ
_get_hostname<sz/API.get_controller_nodes.<locals>._get_hostnamecSsVg}tj|ƒ}|jjdƒ}x(|D] }|j|jdƒdƒq.W|S)Nú,ú@é)ÚurlparseÚnetlocÚsplitÚappend)ÚurlÚhostsÚ
parsed_urlZparsed_hostsr$rrrÚ_get_hosts_from_transport_urlBs
z?API.get_controller_nodes.<locals>._get_hosts_from_transport_urlZrabbit_hostsÚ
transport_urlÚNcSs#g|]}|jdƒd‘qS)ú:r)rU)Ú.0r$rrrú
<listcomp>Ws	z,API.get_controller_nodes.<locals>.<listcomp>Z	localhostcsg|]}ˆ|ƒ‘qSrr)r^r$)rOrrr_[s	rG)r\N)rZoslo_messaging_rabbitÚhasattrÚgetattrr[ÚextendÚlistÚsetÚremoverLr4Ú	exception)rr"rZrXZtransport_hostsrNr)rOrrI8s0
	


zAPI.get_controller_nodescCs5|d}|jd|dd|d|ddddƒS)	z6
        Validate given database credentials.
        r$Úvalidate_database_credsNr/r1Tr.ip)r2)rr"r/r$rrrrgas
	zAPI.validate_database_creds)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rrr!r&r'rr2r3r7r8r9r:r;r<r=r?r@rBrCrDrErFrHrIrgrr)rrr
3s>







)r
)$rkrJrSÚImportErrorÚurllib.parseÚparseZoslo_logrÚloggingZnova.openstack.commonZoslo_messagingrZosloZoslo_configrZoslo.configZnova.dbrZnova.objectsrr(ÚnovarrrÚ	getLoggerrhr4rZStrOptZcontego_api_optsZ
register_optsZrpcapi_cap_optZregister_optÚBaser
rrrrÚ<module>s@