/usr/lib/python2.6/site-packages/openstack
NameSizeModeActions
block_store/-0755rm
cluster/-0755rm
compute/-0755rm
database/-0755rm
identity/-0755rm
image/-0755rm
key_manager/-0755rm
message/-0755rm
metric/-0755rm
network/-0755rm
object_store/-0755rm
orchestration/-0755rm
telemetry/-0755rm
tests/-0755rm
connection.py113370644editdlrm
connection.pyc106290644editdlrm
exceptions.py31140644editdlrm
exceptions.pyc47190644editdlrm
format.py46130644editdlrm
format.pyc41750644editdlrm
module_loader.py9890644editdlrm
module_loader.pyc7290644editdlrm
profile.py70080644editdlrm
profile.pyc79800644editdlrm
proxy.py136030644editdlrm
proxy.pyc129350644editdlrm
proxy2.py144540644editdlrm
proxy2.pyc141080644editdlrm
resource.py391070644editdlrm
resource.pyc382400644editdlrm
resource2.py297640644editdlrm
service_filter.py53330644editdlrm
service_filter.pyc69030644editdlrm
session.py41990644editdlrm
session.pyc42960644editdlrm
utils.py28640644editdlrm
utils.pyc28080644editdlrm
__init__.py6630644editdlrm
__init__.pyc2900644editdlrm
Edit: /usr/lib/python2.6/site-packages/openstack/resource.pyc (38240B)
Ñò 5 Wc@sdZddkZddkZddkZddkZddkZddkZddklZ ddk l Z ddk l Z ddk l Z defd„ƒYZd Zd efd „ƒYZeieiƒd eifd „ƒYƒZd„Zd„ZdS(så The :class:`~openstack.resource.Resource` class is a base class that represent a remote resource. Attributes of the resource are defined by the responses from the server rather than in code so that we don't have to try and keep up with all possible attributes and extensions. This may be changed in the future. The :class:`~openstack.resource.prop` class is a helper for definiting properties in a resource. For update management, :class:`~openstack.resource.Resource` maintains a dirty list so when updating an object only the attributes that have actually been changed are sent to the server. There is also some support here for lazy loading that needs improvement. There are plenty of examples of use of this class in the SDK code. iÿÿÿÿN(tparse(t exceptions(tformat(tutilstpropcBs;eZdZdddd„Zd„Zd„Zd„ZRS(såA helper for defining properties in a resource. A prop defines some known attributes within a resource's values. For example we know a User resource will have a name: >>> class User(Resource): ... name = prop('name') ... >>> u = User() >>> u.name = 'John Doe' >>> print u['name'] John Doe User objects can now be accessed via the User().name attribute. The 'name' value we pass as an attribute is the name of the attribute in the message. This means that you don't need to use the same name for your attribute as will be set within the object. For example: >>> class User(Resource): ... name = prop('userName') ... >>> u = User() >>> u.name = 'John Doe' >>> print u['userName'] John Doe There is limited validation ability in props. You can validate the type of values that are set: >>> class User(Resource): ... name = prop('userName') ... age = prop('age', type=int) ... >>> u = User() >>> u.age = 'thirty' TypeError: Invalid type for attr age By specifying an alias attribute name, that alias will be read when the primary attribute name does not appear within the resource: >>> class User(Resource): ... name = prop('address', alias='location') ... >>> u = User(location='Far Away') >>> print u['address'] Far Away cCs(||_||_||_||_dS(N(tnamettypetaliastdefault(tselfRRRR((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt__init__as   cCs6|djodSy#||i}|djodSWnDtj o8y||i}Wq|ttfj o |iSXnX|io¬t||iƒ o˜t|it ƒoFt|t i ƒo |ih||ii 6ƒ}q.|i|ƒ}q2t|it iƒo|ii|ƒ}q2|i|ƒ}n|S(N(tNoneRtKeyErrorRtAttributeErrorRRt isinstancet issubclasstResourcetsixt string_typest id_attributeRt Formattert deserialize(R tinstancetownertvalue((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt__get__gs(     cCs|ioÂt||iƒ o®||ijožt|itƒoFt|tiƒo |ih||ii6ƒ}qÈ|i|ƒ}qÌt|iti ƒo|ii |ƒ}qÌt |i|ƒƒ}n|i |i jo|i i|i ƒn|||i>> class Container(Resource): ... name = prop("name") ... object_count = header("x-container-object-count") ... >>> c = Container({name='pix'}) >>> c.head(session) >>> print c["headers"]["x-container-object-count"] 4 >>> print c.object_count 4 The first print shows accessing the header value without the property and the second print shows accessing the header with the property helper. cCs,|djodSt|jo |tSdS(N(R tHEADERS(R R((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt _get_headers½s    cCs(|i|ƒ}tt|ƒi||ƒS(N(R&tsuperR$R(R RRR#((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyRÄscCsO|i|ƒ}|djoh}|ited/e d/d-„ƒZ?ed/e@d.„ƒZARS(0tidRtlocationtcCsi|djohn |iƒ|_|o tƒnt|iiƒƒ|_|i|iƒ||_dS(sConstruct a Resource to interact with a service's REST API. The Resource class offers two class methods to construct resource objects, which are preferrable to entering through this initializer. See :meth:`Resource.new` and :meth:`Resource.existing`. :param dict attrs: The attributes to set when constructing this Resource. :param bool loaded: ``True`` if this Resource exists on the server, ``False`` if it does not. N(R tcopyRtsettkeyst_dirtyt update_attrst_loaded(R tattrstloaded((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyR ös #)cCs#d|i|ii|i|ifS(Ns%s.%s(attrs=%s, loaded=%s)(R!t __class__R RR1(R ((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt__repr__s  cCs1|io|iS|io|iS|ƒiiS(N(t resource_namet resource_keyR4R (tcls((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pytget_resource_name s   cKs||dtƒS(sCreate a new instance of this resource. Internally set flags such that it is marked as not present on the server. :param dict kwargs: Each of the named arguments will be set as attributes on the resulting Resource object. R3(tFalse(R8tkwargs((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pytnews cKs||dtƒS(sCreate an instance of an existing remote resource. It is marked as an exact replication of a resource present on a server. :param dict kwargs: Each of the named arguments will be set as attributes on the resulting Resource object. R3(tTrue(R8R;((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pytexisting%s cCsZt||ƒo|St|tiƒo|ih||6Std|i|fƒ‚dS(Nsvalue must be %s instance or %s(RRRR<t ValueErrorR (R8t attributeR((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt _from_attr0s cCs|i|i|ƒS(sšCreate an instance from an ID or return an existing instance. New instances are created with :meth:`~openstack.resource.Resource.new` :param value: If ``value`` is an instance of this Resource type, it is returned. If ``value`` is an ID which an instance of this Resource type can be created with, one is created and returned. :rtype: :class:`~openstack.resource.Resource` or the appropriate subclass. :raises: :exc:`ValueError` if ``value`` is not an instance of this Resource type or a valid ``id``. (RAR(R8R((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pytfrom_id=scCs|i|i|ƒS(sCreate an instance from a name or return an existing instance. New instances are created with :meth:`~openstack.resource.Resource.new` :param value: If ``value`` is an instance of this Resource type, it is returned. If ``value`` is a name which an instance of this Resource type can be created with, one is created and returned. :rtype: :class:`~openstack.resource.Resource` or the appropriate subclass. :raises: :exc:`ValueError` if ``value`` is not an instance of this Resource type or a valid ``name``. (RAtname_attribute(R8R((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt from_namePscCs |i|S(N(R(R R((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt __getitem__gscCsey|i|}Wntj o t}nX||j}|o!||i|<|ii|ƒndS(N(RR R=R/tadd(R RRtorigtchanged((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt __setitem__js   cCs|i|=|ii|ƒdS(N(RR/RF(R R((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt __delitem__vs cCs t|iƒS(N(tlenR(R ((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt__len__zscCs t|iƒS(N(titerR(R ((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt__iter__}scCs|ii|idƒS(s‘The identifier associated with this resource. The true value of the ``id`` property comes from the attribute set as :data:`id_attribute`. For example, a container's name may be the appropirate identifier, so ``id_attribute = "name"`` would be set on the :class:`Resource`, and ``Resource.name`` would be conveniently accessible through ``id``. N(RtgetRR (R ((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyR)„s cCs|i|i=dS(N(RR(R ((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyR)‘scCs|ii|idƒS(s¡The name associated with this resource. The true value of the ``name`` property comes from the attribute set as :data:`name_attribute`. N(RRORCR (R ((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyR•scCs||i|i(R8RvRkRjRTRw((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt get_by_idrs c CsD|i||id|d|d|ƒ}|i||ƒt|_|S(s¹Get the remote resource associated with this instance. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param bool include_headers: ``True`` if header data should be included in the response body, ``False`` if not. :param dict args: A dictionary of query parameters to be appended to the compound URL. :return: This :class:`Resource` instance. :raises: :exc:`~openstack.exceptions.MethodNotSupported` if :data:`Resource.allow_retrieve` is not set to ``True``. RjR^RT(R€R)RVR=R1(R RvRTR^Rw((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyRO‹s   cCsk|ipti|dƒ‚n|i||ƒ}hdd6}|i|d|id|ƒ}h|it6S(s³Get a dictionary representing the headers of a remote resource. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param resource_id: This resource's identifier, if needed by the request. :param dict path_args: A dictionary of arguments to construct a compound URL. See `How path_args are used`_ for details. :return: A ``dict`` containing the headers. :raises: :exc:`~openstack.exceptions.MethodNotSupported` if :data:`Resource.allow_head` is not set to ``True``. theadR+tAcceptRpR#(t allow_headRRrRmR‚RtR#R%(R8RvRkRjRlR#RS((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pythead_data_by_idŸs   cCs%|i||d|ƒ}|i|S(s»Get an object representing the headers of a remote resource. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param resource_id: This resource's identifier, if needed by the request. :param dict path_args: A dictionary of arguments to construct a compound URL. See `How path_args are used`_ for details. :return: A :class:`Resource` representing the headers. :raises: :exc:`~openstack.exceptions.MethodNotSupported` if :data:`Resource.allow_head` is not set to ``True``. Rj(R…R>(R8RvRkRjtdata((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt head_by_id¹scCs8|i||id|ƒ}|ii|ƒt|_|S(sƒGet the remote resource headers associated with this instance. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :return: This :class:`Resource` instance. :raises: :exc:`~openstack.exceptions.MethodNotSupported` if :data:`Resource.allow_head` is not set to ``True``. Rj(R…R)RRRR=R1(R RvR†((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyR‚Ìs  c Csa|ipti|dƒ‚n|i|ƒ}|o|i|jo||i=n|itdƒ}|ioh||i6}n|}|i ||ƒ}h|d6}|o||ts RjRT( RPRZR/R‹R)RRR tAssertionErrorRVR=RQ(R Rvt dirty_attrsRStresp_id((R s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyRR s  cCs_|ipti|dƒ‚n|i||ƒ}hdd6}|i|d|id|ƒdS(s‡Delete a remote resource with the given id. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param resource_id: This resource's identifier, if needed by the request. :param dict path_args: A dictionary of arguments to construct a compound URL. See `How path_args are used`_ for details. :return: ``None`` :raises: :exc:`~openstack.exceptions.MethodNotSupported` if :data:`Resource.allow_delete` is not set to ``True``. tdeleteR+RƒRpR#N(t allow_deleteRRrRmR‘Rt(R8RvRkRjRlR#((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt delete_by_id's   cCs|i||id|ƒdS(shDelete the remote resource associated with this instance. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :return: ``None`` :raises: :exc:`~openstack.exceptions.MethodNotSupported` if :data:`Resource.allow_update` is not set to ``True``. RjN(R“R)(R Rv((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyR‘>s c csR|ipti|dƒ‚nt}|d john|}|i|ƒ}hdd6}xï|oç|i|d|id|d|ƒ}|iƒ}|i o||i }n|p t }nd} d } x5|D]-} |i | } | i } | d7} | VqÕW|pd Sd |jo| |d jod S| |d <| |d R)( R8RvRjt paginatedR•t more_dataRlR#RStyieldedt new_markerR†R((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyR”Js:         c s»‡‡fd†}y%ˆioˆi|ˆd|ƒSWntij onXˆi|d|ƒ}||ˆiˆiƒ}|dj o|S|odStidˆi ˆfƒ‚dS(s½Find a resource by its name or id. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param name_or_id: This resource's identifier, if needed by the request. The default is ``None``. :param dict path_args: A dictionary of arguments to construct a compound URL. See `How path_args are used`_ for details. :param bool ignore_missing: When set to ``False`` :class:`~openstack.exceptions.ResourceNotFound` will be raised when the resource does not exist. When set to ``True``, None will be returned when attempting to find a nonexistent resource. :return: The :class:`Resource` object matching the given name or id or None if nothing matches. :raises: :class:`openstack.exceptions.DuplicateResource` if more than one resource is found for this request. :raises: :class:`openstack.exceptions.ResourceNotFound` if nothing is found and ignore_missing is ``False``. c sÜd}xÏ|D]Ç}ˆi|}d\}}|dj ot||dƒ}n|dj ot||dƒ}n|ˆjp |ˆjoF|djo |}qÔd}|ˆiƒˆf}ti|ƒ‚q q W|S(Ns+More than one %s exists with the name '%s'.(NN(R R>tgetattrR9RtDuplicateResource( tresultstthe_idtthe_namet the_resulttitemt maybe_resulttid_valuet name_valuetmsg(t name_or_idR8(s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyt get_one_match¡s      RjsNo %s found for %sN( R{RRtNotFoundExceptionR”RRCR tResourceNotFoundR (R8RvR©Rjtignore_missingRªR†tresult((R©R8s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pytfindˆs  N(BR R!R R7R6R™RRCR$R*RhRtR:RqR{RˆR’R˜R„R‰R R5t classmethodR9R<R>RARBRDRERIRJRLRNtpropertyR)tdeleterRtsetterRPRQRVR0R`R(Rct staticmethodRdRfRgRmRxRnR€RROR…R‡R‚R‹RRR“R‘R”R=R¯(((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyRÐsŒ                   , % 1  =cCsß|i|jo|Sd}|djo g}nx„||jov|i|ƒ|i|jo|S|i|jo)d|i|if}ti|ƒ‚nti|ƒ||7}q5Wd|i|f}ti|ƒ‚dS(s'Wait for the resource to be in a particular status. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param resource: The resource to wait on to reach the status. The resource must have a status attribute. :type resource: :class:`~openstack.resource.Resource` :param status: Desired status of the resource. :param list failures: Statuses that would indicate the transition failed such as 'ERROR'. :param interval: Number of seconds to wait between checks. :param wait: Maximum number of seconds to wait for transition. :return: Method returns self on success. :raises: :class:`~openstack.exceptions.ResourceTimeout` transition to status failed to occur in wait seconds. :raises: :class:`~openstack.exceptions.ResourceFailure` resource transitioned to one of the failure states. :raises: :class:`~AttributeError` if the resource does not have a status attribute is,Resource %s transitioned to failure state %ss*Timeout waiting for %s to transition to %sN( tstatusR ROR)RtResourceFailurettimetsleeptResourceTimeout(RvtresourceRµtfailurestintervaltwaitt total_sleepR¨((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pytwait_for_statusËs$     cCs}d}xT||joFy|i|ƒWntij o|SXti|ƒ||7}q Wd|i}ti|ƒ‚dS(sFWait for the resource to be deleted. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param resource: The resource to wait on to be deleted. :type resource: :class:`~openstack.resource.Resource` :param interval: Number of seconds to wait between checks. :param wait: Maximum number of seconds to wait for the delete. :return: Method returns self on success. :raises: :class:`~openstack.exceptions.ResourceTimeout` transition to status failed to occur in wait seconds. isTimeout waiting for %s deleteN(RORR«R·R¸R)R¹(RvRºR¼R½R¾R¨((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pytwait_for_deleteös   (R"tabct collectionsR,RXR·Rtsix.moves.urllibRR}t openstackRRRtobjectRR%R$t add_metaclasstABCMetatMutableMappingRR¿RÀ(((s8/tmp/pip-build-wCUybK/openstacksdk/openstack/resource.pyts&      u*ÿÿü +