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    
dmapi / usr / lib / python2.7 / dist-packages / dmapi / api / openstack / wsgi.pyc
Size: Mime:
ó
x€cc@sqddlZddlZddlmZddlmZddlmZddlm	Z	ddl
Z
ddlZddlm
ZddlmZddlmZdd	lmZdd
lmZddlmZddlmZejeƒZd
dfZddddgZddgZdZdZdZdZ dZ!d„Z"d„Z#dej$fd„ƒYZ$de%fd„ƒYZ&d e&fd!„ƒYZ'd"e&fd#„ƒYZ(d$„Z)d%e%fd&„ƒYZ*d'„Z+d(e%fd)„ƒYZ,d*ej-fd+„ƒYZ.d,„Z/d-„Z0d.„Z1d/e2fd0„ƒYZ3e
j4e3ƒd1e%fd2„ƒYƒZ5d3ej6j7fd4„ƒYZ8dS(5iÿÿÿÿN(tlog(t	jsonutils(tencodeutils(tstrutils(tapi_version_request(tversioned_method(t	exception(ti18n(t_(tutils(twsgisapplication/jsons&application/vnd.openstack.compute+jsontcreatetdeletetshowtupdatetPOSTtPUTs2.1tversioned_methodssOpenStack-API-VersionsX-OpenStack-Dmapi-API-Versionsopenstack.legacy_v2cCstS(N(t_SUPPORTED_CONTENT_TYPES(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytget_supported_content_types=scCs(t|dƒr||St||ƒSdS(Nt__getitem__(thasattrtgetattr(titemtitem_key((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytitem_getEstRequestcBs³eZdZd„Zdd„Zd„Zd„Zd„Zd„Zd„Z	d	„Z
d
„Zd„Zd„Z
d
„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s@Add some OpenStack API-specific logic to the base webob.Request.cOsNtt|ƒj||Žiid6|_t|dƒsJtjƒ|_ndS(Ntdb_itemsR(tsuperRt__init__t_extension_dataRtapi_versiontAPIVersionRequestR(tselftargstkwargs((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyROstidcCsA|jdj|iƒ}x!|D]}||t||ƒ<q WdS(sAllow API methods to store objects from a DB query to be
        used by API extensions within the same API request.

        An instance of this class only lives for the lifetime of a
        single API request, so there's no need to implement full
        cache management.
        RN(Rt
setdefaultR(R!tkeytitemsRRR((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytcache_db_itemsUs
cCs|jd|S(s Allow an API extension to get previously stored objects within
        the same API request.

        Note that the object data will be slightly stale.
        R(R(R!R&((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytget_db_itemsascCs|j|ƒj|ƒS(s¡Allow an API extension to get a previously stored object
        within the same API request.

        Note that the object data will be slightly stale.
        (R)tget(R!R&R((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytget_db_itemiscCs|jd|dƒdS(Nt	instancestuuid(R((R!R,((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytcache_db_instancesqscCs|jd|gdƒdS(NR,R-(R((R!tinstance((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytcache_db_instancetscCs
|jdƒS(NR,(R)(R!((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytget_db_instanceswscCs|jd|ƒS(NR,(R+(R!t
instance_uuid((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytget_db_instancezscCs|jd|dƒdS(Ntflavorstflavorid(R((R!R4((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytcache_db_flavors}scCs|jd|gdƒdS(NR4R5(R((R!tflavor((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytcache_db_flavor€scCs
|jdƒS(NR4(R)(R!((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytget_db_flavorsƒscCs|jd|ƒS(NR4(R+(R!R5((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt
get_db_flavor†scCs¤d|jkr™d}|jjddƒ}t|ƒdkred|d}|tƒkre|}qen|sƒ|jjtƒƒ}n|pŒd|jd<n|jdS(s.Determine the requested response content-type.sdmapi.best_content_typet.isapplication/sapplication/jsonN(tenvirontNonetpathtrsplittlenRtacceptt
best_match(R!tcontent_typetpartst
possible_type((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytbest_match_content_type‰s	cCs[d|jkrdS|j}|s/|dkr3dS|tƒkrWtjd|ƒ‚n|S(suDetermine content type of the request body.

        Does not do any body introspection, only checks header

        sContent-Types
text/plainRCN(theadersR=RCRRtInvalidContentType(R!RC((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytget_content_typeŸs	cCs#|js
dS|jjtjƒƒS(sÆDetermine the best available language for the request.

        :returns: the best language match or None if the 'Accept-Language'
                  header was not available in the request.
        N(taccept_languageR=RBRtget_available_languages(R!((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytbest_match_languageµs		cCsÜtj|jdddtgƒ}|dkrEtjtjƒ|_n“|dkrctj	ƒ|_nutj|ƒ|_|jj
tjƒtj	ƒƒsØtj
d|jjƒdtjƒjƒdtj	ƒjƒƒ‚ndS(	s@Set API version request based on the request header information.tservice_typetcomputetlegacy_headerstlatesttreq_vertmin_vertmax_verN(tmicroversion_parsetget_versionRGt!LEGACY_API_VERSION_REQUEST_HEADERR=RR tDEFAULT_API_VERSIONRtmax_api_versiontmatchestmin_api_versionRtInvalidGlobalAPIVersiont
get_string(R!t
hdr_string((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytset_api_version_requestÀs"			cCst|jt<dS(N(tTrueR<t
ENV_LEGACY_V2(R!((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt
set_legacy_v2ÛscCs|jjttƒS(N(R<R*R`tFalse(R!((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytis_legacy_v2Þs(t__name__t
__module__t__doc__RR(R)R+R.R0R1R3R6R8R9R:RFRIRLR^RaRc(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRLs&																tActionDispatchercBs eZdZd„Zd„ZRS(s6Maps method name to local methods through action name.cOs:|jddƒ}t|t|ƒ|jƒ}|||ŽS(sFind and call local method.tactiontdefault(tpopRtstrRi(R!R"R#Rht
action_method((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytdispatchåscCs
tƒ‚dS(N(tNotImplementedError(R!tdata((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRiës(RdReRfRmRi(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRgâs	tJSONDeserializercBs&eZd„Zdd„Zd„ZRS(cCsGytj|ƒSWn/tk
rBtdƒ}tjd|ƒ‚nXdS(Nscannot understand JSONtreason(Rtloadst
ValueErrorRRtMalformedRequestBody(R!t
datastringtmsg((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt
_from_jsonñs

RicCs|j|d|ƒS(NRh(Rm(R!RuRh((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytdeserializeøscCsi|j|ƒd6S(Ntbody(Rw(R!Ru((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRiûs(RdReRwRxRi(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRpïs	tJSONDictSerializercBs#eZdZdd„Zd„ZRS(s(Default JSON request body serialization.RicCs|j|d|ƒS(NRh(Rm(R!RoRh((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt	serializescCstjtj|ƒƒS(N(tsixt	text_typeRtdumps(R!Ro((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRis(RdReRfR{Ri(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRzÿscs‡fd†}|S(sÆAttaches response code to a method.

    This decorator associates a response code with a method.  Note
    that the function attributes are directly manipulated; the method
    is not wrapped.
    cs
ˆ|_|S(N(t	wsgi_code(tfunc(tcode(s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt	decorators	((RR‚((Rs</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytresponse	stResponseObjectcBs_eZdZddd„Zd„Zd„Zd„Zd„Ze	d„ƒZ
e	d„ƒZRS(	sìBundles a response object

    Object that app methods may return in order to allow its response
    to be modified by extensions in the code. Its use is optional (and
    should only be used if you really know what you are doing).
    cCs:||_d|_||_|p$i|_tƒ|_dS(sBuilds a response object.iÈN(tobjt
_default_codet_codet_headersRzt
serializer(R!R…RRG((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRs
			cCs|j|jƒS(s'Retrieves a header with the given name.(Rˆtlower(R!R&((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR(scCs||j|jƒ<dS(s5Sets a header with the given name to the given value.N(RˆRŠ(R!R&tvalue((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt__setitem__-scCs|j|jƒ=dS(s'Deletes the header with the given name.N(RˆRŠ(R!R&((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt__delitem__2scCsÙ|j}d}|jdk	r3|j|jƒ}ntjd|ƒ}|jjdƒrwtj	|jdƒ|jd<n|j
|_x9t|j
jƒƒD]"\}}tj	|ƒ|j|<q™Wtj	|ƒ|jd<|S(sSerializes the wrapped object.

        Utility method for serializing the wrapped object.  Returns a
        webob.Response object.
        RysContent-LengthsContent-TypeN(R‰R=R…R{twebobtResponseRGR*R	tutf8Rt
status_inttlistRˆR'(R!trequestRCR‰RyRƒthdrR‹((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR{7s	"cCs|jp|jS(sRetrieve the response status.(R‡R†(R!((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRPscCs
|jjƒS(sRetrieve the headers.(Rˆtcopy(R!((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRGVsN(RdReRfR=RRRŒRR{tpropertyRRG(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR„s					cCsŒytj|ƒ}Wn/tk
rDtdƒ}tjd|ƒ‚nXt|ƒdkrxtdƒ}tjd|ƒ‚nt|jƒƒdS(sqDetermine action to invoke.

    This looks inside the json body and fetches out the action method
    name.
    scannot understand JSONRqistoo many body keysi(	RRrRsRRRtR@R’tkeys(RytdecodedRv((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytaction_peek]s
tResourceExceptionHandlercBs eZdZd„Zd„ZRS(sìContext manager to handle Resource exceptions.

    Used when processing exceptions generated by API implementation
    methods (or their extensions).  Converts most exceptions to Fault
    exceptions, with the appropriate logging.
    cCsdS(N(R=(R!((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt	__enter__{scCs@|s
tSt|tjƒr@ttjjd|jƒƒƒ‚nüt|tj	ƒrX‚nät|tj
ƒr”ttjd|jd|jƒƒƒ‚n¨t|t
ƒrà|||f}tjd|d|ƒttjjƒƒ‚n\t|tƒrtjd|ƒ|‚n4t|tjjƒr<tjd|ƒt|ƒ‚ntS(NtexplanationRsException handling resource: %stexc_infosFault thrown: %ssHTTP exception thrown: %s(R_t
isinstanceRt	ForbiddentFaultRŽtexct
HTTPForbiddentformat_messagetVersionNotFoundForAPIMethodtInvalidtConvertedExceptionRt	TypeErrortLOGterrortHTTPBadRequesttinfot
HTTPExceptionRb(R!tex_typetex_valuetex_tracebackR((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt__exit__~s.		(RdReRfR›R°(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRšss	tResourcecBs§eZdZeZd„Zd„Zd„Zd„Zd„Z	d„Z
d„Zd„Ze
jjd	eƒd
„ƒZd„Zd„Zd
„Zd„Zd„ZRS(s·WSGI app that handles (de)serialization and controller dispatch.

    WSGI app that reads routing information supplied by RoutesMiddleware
    and calls the requested action method upon its controller.  All
    controller action methods must accept a 'req' argument, which is the
    incoming wsgi.Request. If the operation is a PUT or POST, the controller
    method must also accept a 'body' argument (the deserialized request body).
    They may raise a webob.exc exception or return a dict, which will be
    serialized by requested content type.

    Exceptions derived from webob.exc.HTTPException will be automatically
    wrapped in Fault() to provide API friendly error responses.

    cCsP||_tdtƒ|_i|_|r:|j|ƒni|_i|_dS(sm:param controller: object that implement methods created by routes
                              lib
        tjsonN(t
controllertdictRztdefault_serializerstwsgi_actionstregister_actionstwsgi_extensionstwsgi_action_extensions(R!R³((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR¬s			cCsOt|diƒ}x6t|jƒƒD]"\}}t||ƒ|j|<q%WdS(s0Registers controller actions with this resource.R¶N(RR’R'R¶(R!R³tactionsR&tmethod_name((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR·¾scCs«t|dgƒ}x’|D]Š\}}t||ƒ}|rp||jkrYg|j|<n|j|j|ƒq||jkrg|j|<n|j|j|ƒqWdS(s3Registers controller extensions with this resource.R¸N(RR¹tappendR¸(R!R³t
extensionsR»taction_namet	extension((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytregister_extensionsÅscCsšt|jdƒr"|jj|ƒSy|ddjƒ}Wntttfk
rWiSXy|d=Wntk
rvnXy|d=Wntk
r•nX|S(s+Parse dictionary created by routes library.tget_action_argsswsgiorg.routing_argsiR³tformat(RR³RÁR•tKeyErrort
IndexErrortAttributeError(R!trequest_environmentR"((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRÁØs

cCs|jƒ}||jfS(N(RIRy(R!R“RC((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytget_bodyñscCstƒj|ƒS(N(RpRx(R!Ry((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRxöscCsƒx||D]t}d}y,tƒ|d|d||}WdQXWn/tjk
rXqntk
rp}|}nX|r|SqWdS(Ntreqtresp_obj(R=RšRR¤R (R!R½RÉR“taction_argstextRƒtex((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytprocess_extensionsùs


cCs
|jtkS(N(tmethodt_METHODS_WITH_BODY(R!R“((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt_should_have_bodystRequestClassc	Cs|jr€y|jƒWq€tjk
rK}ttjjd|jƒƒƒStj	k
r|}ttjj
d|jƒƒƒSXn|j|jƒ}|j
ddƒ}y%|j|ƒ\}}|jƒ}Wn6tjk
rtdƒ}ttjjd|ƒƒSX|j||||||ƒS(s@WSGI method that controls (de)serialization and method dispatch.RœRhsUnsupported Content-TypeN(tsupport_api_request_versionR^RtInvalidAPIVersionStringR RŽR¡RªR£R[tHTTPNotAcceptableRÁR<RjR=RÇRFRHRtHTTPUnsupportedMediaTypet_process_stack(	R!R“teRÊRhRCRyRARv((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt__call__s&	cCsóy"|j||||ƒ\}}Wn›ttfk
rKttjjƒƒStk
rŠ}	tdƒ|	j	d}
ttjj
d|
ƒƒStjk
r¿tdƒ}
ttjj
d|
ƒƒSX|rtdƒi|d6t
j|dƒd6t|ƒd	6}
tjtj|
ƒƒntjd
it|ƒd	6ƒy|j||ƒ}Wn6tjk
rtdƒ}
ttjj
d|
ƒƒSX|j|ƒ|jddƒ}|jjdƒ}
|
r|r||
jkrtd
ƒi|d6|
jd6}
ttjj
d|
ƒƒSd}y)tƒ|j|||ƒ}WdQXWntk
rR}	|	}nX|sd}t|ƒtks}|dkrŒt|ƒ}nt |tƒr¤|}n|}|rét!|dƒrÎ|j"|_#n|j$||||ƒ}n|r|r|j%||ƒ}qnt!|dƒrïxdt&|j'j(ƒƒD]M\}}t
j)rat*j+|ƒ|j'|<q3t,j-t*j+|ƒƒ|j'|<q3W|j.j/ƒsïd|j.j0ƒ|j't1<|j.j0ƒ|j't2<|j'j3dt1ƒ|j'j3dt2ƒqïn|S(sImplement the processing stack.sThere is no such action: %siRœsMalformed request bodys>Action: '%(action)s', calling method: %(meth)s, body: %(body)sRhsutf-8RytmethsCalling method '%(meth)s't
project_ids
dmapi.contextstMalformed request URL: URL's project_id '%(project_id)s' doesn't match Context's project_id '%(context_project_id)s'tcontext_project_idNRRGscompute tVary(4t
get_methodRÅR§R RŽR¡tHTTPNotFoundRÃRR"RªRRtR|R}RkR¨tdebugRt
mask_passwordt_get_request_contentRRjR=R<R*RÚRšRmttypeR´R„RžRRR†RÍR{R’RGR'tPY2R	RRtsafe_decodeRtis_nullR\tAPI_VERSION_REQUEST_HEADERRVtadd(R!R“RhRÊRCRyRARÙR½RÌRvtcontentsRÚtcontextRƒt
action_resultRÉR”tval((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRÖ9s€	
	
	


	
"	cCsYi}|j|ƒrU|jdks3|jdkrCidd6}qU|j|ƒ}n|S(NiRy(RÐtcontent_lengthR=Rx(R!RyR“Rè((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRášscCs(|j||||ƒ\}}||fS(N(t_get_method(R!R“RhRCRyRÙR½((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRݤs
	cCsÂy1|jst||ƒ}nt|j|ƒ}Wn4tk
rg|js^|tdgkr‚qnX||jj|gƒfS|dkrœt|ƒ}n|}|j||jj|gƒfS(s6Look up the action-specific method and its extensions.Rh(	R³RRÅR¶t_ROUTES_METHODSR¸R*R™R¹(R!R“RhRCRyRÙR¾((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRí«s	



cCs?y|d||SWn$tjk
r:ttjjƒƒSXdS(s.Dispatch a call to the action-specific method.RÈN(RR¤R RŽR¡RÞ(R!RÎR“RÊ((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRmÄs(RdReRfR_RÒRR·RÀRÁRÇRxRÍRÐRŽtdectwsgifyRRØRÖRáRÝRíRm(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR±›s 								%	a	
		cs‡fd†}|S(sÞMark a function as an action.

    The given name will be taken as the action key in the body.

    This is also overloaded to allow extensions to provide
    non-extending definitions of create and delete operations.
    cs
ˆ|_|S(N(twsgi_action(R€(tname(s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR‚Ùs	((RòR‚((Ròs</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRhÐs	cs#‡fd†}|r||ŒS|S(sèIndicate a function extends an operation.

    Can be used as either::

        @extends
        def index(...):
            pass

    or as::

        @extends(action='resize')
        def _action_resize(...):
            pass
    cs|jˆjdƒf|_|S(NRh(RdR*twsgi_extends(R€(R#(s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR‚ïs((R"R#R‚((R#s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytextendsßs
cs‡fd†}|S(sDecorator for v2.1 API methods which specifies expected exceptions.

    Specify which exceptions may occur when an API method is called. If an
    unexpected exception occurs then return a 500 instead and ask the user
    of the API to file a bug report.
    cs%tjˆƒ‡‡fd†ƒ}|S(Ncsùyˆ||ŽSWnátk
rô}t|tjjƒrqtˆtƒrSˆf}nˆ}|j|kr¹‚q¹nHt|tjƒr‰‚n0t|tj	ƒr¡‚nt|tj
ƒr¹‚ntjdƒtdƒt
|ƒ}tjjd|ƒ‚nXdS(Ns"Unexpected exception in API methodsrUnexpected API Error. Please report this at http://support.trilio.io/ and attach the Dmapi API log if possible.
%sRœ(t	ExceptionRžRŽR¡tWSGIHTTPExceptiontintRRRŸtValidationErrortUnauthorizedR¨RRâtHTTPInternalServerError(R"R#R¡tt_errorsRv(terrorstf(s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytwrappeds&	
	
(t	functoolstwraps(RýRþ(Rü(Rýs</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR‚s!%((RüR‚((Rüs</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytexpected_errorsüs(tControllerMetaclasscBseZdZd„ZRS(s…Controller metaclass.

    This metaclass automates the task of assembling a dictionary
    mapping action keys to method names.
    c
Cs>i}g}d}xg|D]_}|jt|diƒƒ|jdkrt|jkrxt|tƒ}t|tƒqxqqWxyt|jƒƒD]e\}}	t	|	ƒs­qnt|	ddƒrÏ|||	j
<qt|	ddƒr|j|	jƒqqW||d<||d<|r||t<nt
t|ƒj||||ƒS(s.Adds the wsgi_actions dictionary to the class.R¶t
ControllerRñRóR¸N(R=RRRdtVER_METHOD_ATTRt__dict__tdelattrR’R'tcallableRñR¼RóRRt__new__(
tmcsRòtbasestcls_dictRºR½RtbaseR&R‹((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR4s,



(RdReRfR(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR-sRcBsYeZdZdZdd„Zd„Zedd„ƒZe	d„ƒZ
e	d„ƒZRS(sDefault controller.cCs:|r||_n$|jr-|jƒ|_n	d|_dS(s3Initialize controller with a view builder instance.N(t
_view_buildert_view_builder_classR=(R!tview_builder((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRbs
	cs~‡‡‡fd†‰ytjˆtƒ}Wntk
rKtjˆˆƒSX|rnˆtjˆtƒkrnˆStjˆˆƒS(Ncs¡t|ƒdkr"|dj}n
|dj}ˆjˆ}xL|D]D}|j|j|jƒrCtjˆ|jƒ|jˆ||ŽSqCWt	j
d|ƒ‚dS(sSLook for the method which matches the name supplied and version
            constraints and calls it with the supplied arguments.

            @return: Returns the result of the method called
            @raises: VersionNotFoundForAPIMethod if there is no method which
                 matches the name and version constraints
            iRÈtversionN(R@RRRYt
start_versiontend_versionRÿtupdate_wrapperR€RR¤(R"R#tvert	func_listR€(R&R!tversion_select(s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRms


(tobjectt__getattribute__RRÅ(R!R&tversion_meth_dict((R&R!Rs</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRks
cs‡‡‡fd†}|S(sMDecorator for versioning api methods.

        Add the decorator to any method which takes a request object
        as the first parameter and belongs to a class which inherits from
        wsgi.Controller.

        @min_ver: string representing minimum version
        @max_ver: optional string representing maximum version
        cs
tjˆƒ}ˆr'tjˆƒ}ntjƒ}|j}tj||||ƒ}tˆtiƒ}|stˆt|ƒn|j|gƒ}|s¤|||<n|j	|ƒt
j|ƒ}|rðtj
d|jd|jd|jƒ‚n|jdd„dtƒ|S(NRòRRRSR&cSs|jS(N(R(Rý((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt<lambda>Æstreverse(RR RdRtVersionedMethodRRtsetattrR*R¼Rtcheck_for_versions_intersectionRtApiVersionsIntersectRòRRtsortR_(Rýtobj_min_vertobj_max_vert	func_nametnew_funct	func_dictRtis_intersect(tclsRSRR(s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR‚¤s.	

				((R'RRRSR‚((R'RSRRs</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR˜s&cCs-|o||kstSd„}|||ƒS(NcSs.y|jdƒtSWntk
r)tSXdS(N(R*R=R_RÅRb(td((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytis_dictÑs


(Rb(Rytentity_nameR)((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt
is_valid_bodyÌs	cCs›g}d}x@|D]8}|j|jd|fƒ|j|jd|fƒqWd„}|jd|ƒx,|D]$}||d7}|dkrotSqoWtS(sDetermines whether function list contains version intervals
        intersections or not. General algorithm:

        https://en.wikipedia.org/wiki/Intersection_algorithm

        :param func_list: list of VersionedMethod objects
        :return: boolean
        iiiÿÿÿÿcSs|dS(Ni((tx((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pytcompareësR&(R¼RRR R_Rb(RtpairstcounterRýR-tp((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRÚs

	
N(RdReRfR=RRRtclassmethodRtstaticmethodR+R(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR\s		-3R cBs‘eZdZidd6dd6dd6dd6d	d
6dd6d
d6dd6d
d6dd6dd6Zd„Zejjdeƒd„ƒZ	d„Z
RS(s>Wrap webob.exc.HTTPException to provide API friendly response.t
badRequestitunauthorizedi‘t	forbiddeni“titemNotFoundi”t	badMethodi•tconflictingRequesti™t	overLimititbadMediaTypeiŸi­tnotImplementediõtserviceUnavailablei÷cCsX||_x<t|jjjƒƒD]"\}}t|ƒ|jj|<q"W|j|_dS(s1Create a Fault for the given webob.exc.exception.N(twrapped_excR’RGR'RkR‘(R!RR&R‹((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR	s	%RÑcCsy|jƒ}|jj}|jj|dƒ}|jj}tjdi|d6|d6ƒtj	||ƒ}ii|d6|d6|6}|dksœ|dkrÎ|jj
jddƒ}|rÎ|||d	<qÎn|jj
ƒsBd
|jjƒ|jj
t<|jjƒ|jj
t<|jj
jdtƒ|jj
jdtƒnd|j_d
|j_tƒj|ƒ|j_|jS(s?Generate a WSGI response based on the exception passed to ctor.tcomputeFaults+Returning %(code)s to user: %(explanation)sRRœtmessageii­sRetry-Aftert
retryAfterscompute RÜsapplication/jsonsUTF-8N(RLR=R‘t_fault_namesR*RœR¨RßRt	translateRGR=RRåR\RæRVRçRCtcharsetRzR{ttext(R!RÈtuser_localeRt
fault_nameRœt
fault_datatretry((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRØs2	
cCs
|jjƒS(N(R=t__str__(R!((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyRI5s(RdReRfRARRŽRïRðRRØRI(((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyR ùs 
	%(9RÿRTtoslo_logRtloggingtoslo_serializationRt
oslo_utilsRRR|RŽtdmapi.api.openstackRRRtdmapiRRt
dmapi.i18nRR	R
t	getLoggerRdR¨RRîRÏRWRRæRVR`RRRRRgRpRzRƒR„R™RštApplicationR±RhRôRRâRt
add_metaclassRR¡R¬R (((s</usr/lib/python2.7/dist-packages/dmapi/api/openstack/wsgi.pyt<module>s^					–

	F	(ÿ6			1/œ