Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Minor cleanups: make naming consistent with PEP-8 Python standard.

...

No Format
class QmfData:
      <constructor>( _values=map of "name"=<AMQP Type> pairs, 
                     _subtypes=optional map of "name"=<AMQP String> pairs for subtype information,
                     _tag=optional, application-specific tag applied to this QmfData instance
                     _object_id=optional AMQP string that uniquely identifies this QmfData instance.
                     _schema=optional <class SchemaClass> reference
                     _const=False )
      <constructor>( _map=map representation of QmfData, as generated by mapEncode() method, 
                     _schema=optional <class SchemaClass> reference
                     _const=False)
      .isManagedis_managed(): returns True if object identifier string assigned, else False.
      .isDescribedis_described(): returns True if schema is associated with this instance
      .getTagget_tag(): return this object's tag if present, else None
      .getValueget_value(name): return the value of the named data item, returns None if named property is not present.
      .hasValuehas_value(name): returns True if the named data item is present in the map, else False.
      .setValueset_value(name, value, subType=None): set the value of the named data item. Creates a new item if the named data does not exist. Raises an exception if _const is True. 
      .getSubTypeget_subtype(name): returns the sub type description string, else None if not present. 
      .setSubTypeset_subtype(name, subType): set or modify the subtype associated with name.
      .get_object_id(): returns the object id string associated with the object instance, or None if no id assigned.
      .get_schema_class_id: returns the identifier of the Schema that describes the structure of the data, or None if no schema.
      .mapEncodemap_encode(): returns a map representation of the QmfData instance, suitable for use by the constructor.

...

No Format
class SchemaClassId:
      <constructor>( package=<package-name-str>, 
                     class=<class-name-str>,
                     type=<SchemaTypeData|SchemaTypeEvent>)
                     hash=<hash-str, format="%08x-%08x-%08x-%08x">, 
      .getPackageNameget_package_name(): returns <package-name-str>
      .getClassNameget_class_name(): returns <class-name-str>
      .getHashStringget_hash_string(): returns <hash-str, "%08x-%08x-%08x-%08x">
      .getTypeget_type(): returns SchemaTypeObject or SchemaTypeEvent
      .mapEncodemap_encode(): returns a map encoding of the instance.

...

No Format
class SchemaProperty:
      <constructor>( name=<name-value>, 
                     type=<type-value>,
                     ...)
      .getTypeget_type(): AMQP typecode for encoding/decoding the property data
      .getAccessget_access(): "RC"=read/create, "RW"=read/write, "RO"=read only (default)
      .isOptionalis_optional(): True if this property is optional
      .getUnitget_unit(): string describing units (optional)
      .getMinget_min(): minimum value (optional)
      .getMaxget_max(): maximum value (optional)
      .getMaxLenget_max_len(): maximum length for string values (optional)
      .getDescget_desc(): optional string description of this Property
      .getDirectionget_direction(): "I"=input, "O"=output, or "IO"=input/output (required for method arguments, otherwise optional)
      .getSubtypeget_subtype(): string indicating the formal application type for the data, example: "URL", "Telephone number", etc.
      .isPolledis_polled(): True if changes to the data cannot be practically monitored by an Agent.  Such a data item can only
          be queried or polled - not published on change.
      .getReferenceget_reference(): if type==objId, name (str) of referenced class (optional) 
      .isParentRefis_parent_ref(): True if this property references an object in which this object is in a child-parent relationship.
      .getAttributeget_attribute("name"): get the value of the attribute named "name". This method can be used to retrieve
          application-specific attributes.  "name" should start with the prefix "x-"
      .mapEncodemap_encode(): returns a map encoding of the instance.

...

No Format
class SchemaMethod:
      <constructor>( [args=<map of "name":<SchemaProperty> entries>],
                     desc="description of the method")
      .getDescget_desc(): return human-readable description of the method.
      .getArgumentCountget_argument_count(): return the number of arguments
      .getArgumentsget_arguments(): returns a copy of the map of "name":<SchemaProperty>
      .getArgumentget_argument("name"): return the SchemaProperty for the parameter "name"

      .addArgumentadd_argument("name", SchemaProperty): adds an additional argument to the parameter list.
      .map_encode(): returns a map encoding of the SchemaMethod instance

...

No Format
class SchemaClass(QmfData):
      <constructor>( classId=<class SchemaClassId>, 
                     _desc=optional AMQP string containing a human-readable description for this schema)
      .getClassIdget_class_id(): return the SchemaClassId that identifies this Schema instance.
      .generateHashgenerate_hash(): generate a hash over the body of the schema, and return a string representation of the hash in format  "%08x-%08x-%08x-%08x"

...

No Format
class SchemaObjectClass(SchemaClass):
      <constructor>( classId=<class SchemaClassId>, 
                     _desc=optional AMQP string containing a human-readable description for this schema,
                     _props=map of "name"=<SchemaProperty> instances,
                     _meths=map of "name"=<SchemaMethod> instances,
                     _id_names=(optional) ordered list of "name"s used to identify the properties whose values are used to construct the object identifier)

      .get_id_names(): return an ordered list of names of the values that are used to construct the key for identifying 
          unique instances of this class.  Returns None if no list defined.
      .getPropertyCountget_property_count(): return the count of SchemaProperty's in this instance.
      .getPropertiesget_properties(): return a map of "name":<SchemaProperty> entries for each value in the object.
      .getPropertyget_property("name"): return the SchemaProperty associated with "name", else None if "name" value does not exist.

      .getMethodCountget_method_count(): return the count SchemaMethod's in this instance.
      .getMethodsget_methods(): return a map of "name":<SchemaMethod> entries for each method associated with the object.
      .getMethodget_method("name"): return the SchemaMethod associated with the "name", else None if "name" does not exist or is not a method.

      .addPropertyadd_property("name", SchemaProperty): add a new property.
      .addMethodadd_method("name", SchemaMethod): add a new method.
      .set_id_names([name-list]): set the value of the order list of names to use when constructing the object identifier.

...

No Format
class SchemaEventClass(SchemaClass):
      <constructor>( classId=<class SchemaClassId>,
                     _desc=optional AMQP string containing a human-readable description for this event,
                     _props=map of "name":SchemaProperty instances)
      .getPropertyCountget_property_count(): return the number of properties.
      .getPropertiesget_properties(): return a map of "name":<SchemaProperty> entries for each property in the event.
      .getPropertyget_property("name"): return the SchemaProperty associated with "name".

      .addPropertyadd_property("name", SchemaProperty): add a new property.

...

No Format
{"query": {"what": {"object": None},
           "where": ["and" ["eq" "_package_name" ["quote" "aPackage]]
                           ["eq" ["quote" "someClass"] "_class_name"]
                           ["or" ["not" ["re_match" "state" ["quote" "$Error"]]]
                                 ["ne" "owner" ["quote" "Cartman"]]
                           ]
                    ]
          }
}

Subscriptions

TBD
A subscription is a mechanism for monitoring management data for
changes in its state. A Console creates a subscription with an Agent
based on a Query. The Query specifies the set of management data that
is to be monitored. When the Agent detects changes to the selected
set, a notification is sent to the subscribing Console(s). A
Subscription is represented by the SubscriptionId class. A Console
must cancel the subscription when the console no longer needs to
monitor the data.

...

No Format
class Agent:
      .get_name(): returns the identifying name string of the agent.  This name is used to send AMQP messages directly to this agent.
      .isActiveis_active(): returns True if the agent is alive (heartbeats have not timed out)
      .invoke_method(name, inArgs{}, [[reply-handle] | [timeout]]): invoke the named method against the agent.
      .enable_events(): allows reception of events from this agent.
      .disable_events(): prevents reception of events from this agent.
      .destroy(): releases this Agent instance.  Once called, the console application should not reference this instance again.
      ?tbd?

...

No Format
class Console:
      <constructor>(name=<name-str>, 
                    domain=(optional) domain string for console's AMQP address,
                    notifier=<class Notifier>,
                    reply_timeout=<default for all blocking calls>,
                    agent_timeout=<default timeout for agent heartbeat>,
                    subscription_duration=<default lifetime of a subscription>)

      .destroy(timeout=None): Must be called to release Console's resources.

      .addConnectionadd_connection(QPID Connection): Connect the console to the AMQP cloud.

      .removeConnectionremove_connection(conn): Remove the AMQP connection from the console.  Un-does the addConnectionadd_connection() operation, and
          releases any agents associated with the connection.  All blocking methods are unblocked and given a failure status.
          All outstanding asynchronous operations are cancelled without producing WorkItems.

      .getAddressget_address():
          Get the AMQP address this Console is listening to (type str).

      .find_agent( name string, [timeout] ): Query for the presence of a specific agent in the QMF domain. Returns a 
          class Agent if the agent is present.  If the agent is not already known to the console, this call will send 
          a query for the agent and block (with default timeout override) waiting for a response.

      .enable_agent_discovery( [Query] ): Called to enable the asynchronous Agent Discovery process. Once enabled, AGENT_ADDED
          and AGENT_DELETED work items can arrive on the WorkQueue.  If a query is supplied, it will be used to filter agent 
          notifications.

      .disable_agent_discovery(): Called to disable the async Agent Discovery process enabled by calling enableAgentDiscoveryenable_agent_discovery().  

      .getWorkItemCountget_workitem_count(): Returns the count of pending WorkItems that can be retrieved. 

      .getNextWorkItemget_next_workitem([timeout=0]): Obtains the next pending work item, or None if none available. 

      .releaseWorkItemrelease_workitem(wi): Releases a WorkItem instance obtained by getNextWorkItem(). Called when the application has finished
          processing the WorkItem. 

      .getAgentsget_agents(): Returns a list of available agents (class Agent)

      .getAgentget_agent( name string ): Return the class Agent for the named agent, if known. 

      .getPackagesget_packages( [class Agent] ): Returns a list of the names of all known packages.  If an optional Agent is provided, then
          only those packages available from that Agent are returned.

      .getClassesget_classes( [class Agent] ):  Returns a list of SchemaClassIds for all available Schema.  If an optional Agent is provided,
          then the returned SchemaClassIds are limited to those Schema known to the given Agent.

      .getSchemaget_schema( class SchemaClassId [, class Agent]): Return a list of all available class SchemaClass across all known agents.
          If an optional Agent is provided, restrict the returned schema to those supported by that Agent.

      .getObjectsget_objects( _SchemaClassId= | _package=, _class= |
                    _object_identifier=,
                   [timeout=],
                   [list-of-class-Agent] ): perform a blocking query for QmfConsoleObjects.  Returns a list (possibly empty) of matching
           objects. The selector for the query may be either:
           * class SchemaClassId - all objects whose schema match the schema identified by _SchemaClassId parameter.
           * package/class name - all objects whose schema are contained by the named package and class.
           * the object identified by _object_identifier
           This method will block until all known agents reply, or the timeout expires. Once the timeout expires, all
           data retrieved to date is returned. If a list of agents is supplied, then the query is sent to only those agents.  


      .createSubscriptioncreate_subscription( class Query [, duration=<secs> [, list of agents] ): creates a subscription using the given Query.  If a list of agents
          is provided, the Query will apply only to those agents. Otherwise it will apply to all active agents, including
          those discovered during the lifetime of the subscription. The duration argument can be used to override the
          console's default subscription lifetime for this subscription.  Returns a class SubscriptionId.

      .refreshSubscriptionrefresh_subscription( SubscriptionId [, duration=<secs>] ): (re)activates a subscription.  Uses the console default duration
          unless the duration is explicitly specified.

      .cancelSubscriptioncancel_subscription( SubscriptionId ): terminates the given subscription. 

...

No Format
logging.info( "Starting Connection" )
conn = Connection("localhost")
conn.connect()

logging.info( "Starting Console" )
myConsole = Console()
myConsole.addConnectionadd_connection( conn )

logging.info( "Finding Agent" )
myAgent = myConsole.findAgentfind_agent( "com.aCompany.Examples.anAgent", _timeout=5 )

if myAgent:
   logging.info( "Agent Found: %s" % myAgent )
else:
   logging.info( "No Agent Found!")

logging.info( "Removing connection" )
myConsole.removeConnectionremove_connection( conn )

logging.info( "Destroying console:" )
myConsole.destroy( _timeout=10 )

...

No Format
class MyNotifier(Notifier):
    def __init__(self, context):
        self._myContext = context
        self.WorkAvailable = False

    def indication(self):
        print("Indication received! context=%d" % self._myContext)
        self.WorkAvailable = True

noteMe = MyNotifier( 668 )

logging.info( "Starting Connection" )
conn = Connection("localhost")
conn.connect()

myConsole = Console(notifier=noteMe)
myConsole.addConnectionadd_connection( conn )

myConsole.enableAgentDiscoveryenable_agent_discovery()
logging.info("Waiting...")


while not noteMe.WorkAvailable:
    print("No work yet...sleeping!")
    time.sleep(1)


print("Work available = %d items!" % myConsole.getWorkItemCount())
wi = myConsole.getNextWorkitemget_next_workitem(timeout=0)
while wi:
    print("work item %d:%s" % (wi.getType(), str(wi.getParams())))
    wi = myConsole.getNextWorkitemget_next_workitem(timeout=0)


logging.info( "Removing connection" )
myConsole.remove_connection( conn )

logging.info( "Destroying console:" )
myConsole.destroy( 10 )

...

No Format
class QmfAgentData(QmfData):
      .destroy(): mark the object as deleted by setting the deletion timestamp to the current time.
      .setValueset_value(name, value): update the value of the property.
      .incValueinc_value(name, delta): add the delta to the property
      .decValuedec_value(name, delta): subtract the delta from the property
      ?tbd?

...

No Format
class Agent:
      <constructor>( name=<name-string>,
                     domain=(optional) domain string for agent's AMQP address,
                     notifier=class Notifier,
                     heartbeat_interval=30,
                     max_msg_size=0)
      .get_name(): return the name string of the agent.
      .setConnectionset_connection( QPID Connection ): connect the agent to the AMQP cloud.
      .registerObjectClassregister_object_class( class SchemaObjectClass ): Register a
            schema for an object class with the agent.  The agent must
            have a registered schema for an object class before it can
            handle objects of that class.
      .registerEventClassregister_event_class( class SchemaEventClass ) : Register a
            schema for an event class with the agent.  The agent must
            have a registered schema for an event class before it can
            handle events of that class.
      .raise_event( class QmfEvent ): Cause the agent to raise the
            given event.
      .addObjectadd_object( class QmfAgentData ):
            passes a reference to an instance of a managed QMF object
            to the agent. The object's name
 must uniquely identify this
      name must uniquely identify this  object among all objects known to this agent.
      .getWorkItemCountget_workitem_count(): Returns the count of pending WorkItems that
            can be retrieved.
      .getNextWorkItemget_next_workitem([timeout=0]): Obtains the next pending work
            item, or None if none available. 
      .releaseWorkItemrelease_workitem(wi): Releases a WorkItem instance obtained by
            getNextWorkItem get_next_workitem(). Called when the application has finished
            processing the WorkItem. 
      .method_response(name="method name",
                       handle=<handle from WorkItem>,
                       out_args={output argument map}
                       error=<QmfData> ): Indicate to the agent
 that the application has completed processing a method
    that the application has completed processing a method
            request. See the description of the METHOD_CALL WorkItem.

AgentExternal Class

The AgentExternal class must be used by those applications that
implement the external store model. The AgentExternal class extends
the Agent class by adding interfaces that notify the application when
it needs to service a request for management operations from the
agent.

No Format
class AgentExternal(Agent):
      <constructor>(name=<name-string>,
                    domain=(optional) domain string for agent's AMQP address,
                    notifier= class Notifier,
                    heartbeat_interval=30,
                    max_msg_size=65535)
      .allocObjectIdalloc_object_id( name="object name"): indicate to QMF that the named object is available to be managed.  Once this method returns, 
          the agent will service requests from consoles referencing this data.
      .freeObjectIdfree_object_id( name="object name" ): indicate to QMF that the named object is no longer available to be managed.
      .queryResponsequery_response( handle=<handle from WorkItem>,
                      class QmfAgentObject): send a managed object in 
            reply to a received query. Note that ownership of the
 object 
          object instance is returned to the caller on return from
            this call. 
      .queryCompletequery_complete( handle=<handle from WorkItem>, 
                      result=<status code> ):  Indicate to the agent
            that the application has completed processing a query request.
            Zero or more calls to the queryResponse() method should be
            invoked before calling queryCompletequery_complete().  If the query should
            fail - for example, due to authentication error - the result
            should be set to a non-zero error code ?TBD?.
      .subscriptionResponsesubscription_response( handle=<handle from WorkItem>,
                             result=<status code>,
                             subscription_handle=<application context>):
            Indicate the status of a subscription request.  If result
            is zero, the subscription is accepted by the application,
            and an subscription handle is provided.  This handle must
            be passed to the application when the agent unsubscribes.

...

Note Well: In the case of an internal store agent implementation, only the
METHOD_CALL work item is generated. An external store agent must support
all work item types.

METHOD_CALL

...

The QUERY WorkItem describes a query that the application must
service. The application should call the queryResponsequery_response() method for
each object that satisfies the query. When complete, the application
must call the queryCompletequery_complete() method. If a failure occurs, the
application should indicate the error to the agent by calling the
queryCompletequery_complete() method with a description of the error.

...

No Format
  SUBSCRIBE parameters: ( class Query, 
                          user_id=<authenticated id of the user> )

TBD
The SUBSCRIBE WorkItem provides a query that the application should
monitor until the subscription is cancelled. On receipt of this
WorkItem, the application should call the subscriptionResponse() agent
method to acknowledge the response. Whenever the matching objects are
updated, the application should call queryResponse() for each updated
object, followed by a call to queryComplete() when done. The
subscription remains in effect until an UNSUBSCRIBE WorkItem for the
subscription is received.

...

No Format
  UNSUBSCRIBE parameters: ( <handle associated with subscription> )

TBD
Alerts the application that the corresponding subscription has been
cancelled. The application should no longer supply query updates
against the subscribed query.