def __init__(self, name, broker_url, heartbeat): Thread.__init__(self) self.schema_count = _SCHEMAS_PER_AGENT self.obj_count = _OBJS_PER_AGENT self.notifier = _testNotifier() self.broker_url = broker_url self.agent = Agent(name, _notifier=self.notifier, heartbeat_interval=heartbeat, max_msg_size=_MAX_OBJS_PER_MSG) # Dynamically construct a management database for i in range(self.schema_count): _schema = SchemaObjectClass( _classId=SchemaClassId("MyPackage", "MyClass-" + str(i)), _desc="A test data schema", _object_id_names=["index1", "index2"] ) # add properties _schema.add_property( "index1", SchemaProperty(qmfTypes.TYPE_UINT8)) _schema.add_property( "index2", SchemaProperty(qmfTypes.TYPE_LSTR)) # these two properties are statistics _schema.add_property( "query_count", SchemaProperty(qmfTypes.TYPE_UINT32)) _schema.add_property( "method_call_count", SchemaProperty(qmfTypes.TYPE_UINT32)) # These two properties can be set via the method call _schema.add_property( "set_string", SchemaProperty(qmfTypes.TYPE_LSTR)) _schema.add_property( "set_int", SchemaProperty(qmfTypes.TYPE_UINT32)) # add method _meth = SchemaMethod( _desc="Method to set string and int in object." ) _meth.add_argument( "arg_int", SchemaProperty(qmfTypes.TYPE_UINT32) ) _meth.add_argument( "arg_str", SchemaProperty(qmfTypes.TYPE_LSTR) ) _schema.add_method( "set_meth", _meth ) # Add schema to Agent self.agent.register_object_class(_schema) # instantiate managed data objects matching the schema for j in range(self.obj_count): self.agent.add_object( QmfAgentData( self.agent, _schema=_schema, _values={"index1":j, "index2": "name-" + str(j), "set_string": "UNSET", "set_int": 0, "query_count": 0, "method_call_count": 0} )) self.running = False self.ready = Event()
def __init__(self, name, broker_url, heartbeat): Thread.__init__(self) self.notifier = _testNotifier() self.broker_url = broker_url self.agent = Agent(name, _notifier=self.notifier, heartbeat_interval=heartbeat) # Dynamically construct a management database _schema = SchemaObjectClass( _classId=SchemaClassId("MyPackage", "MyClass"), _desc="A test data schema", _object_id_names=["index1", "index2"] ) # add properties _schema.add_property( "index1", SchemaProperty(qmfTypes.TYPE_UINT8)) _schema.add_property( "index2", SchemaProperty(qmfTypes.TYPE_LSTR)) # these two properties are statistics _schema.add_property( "query_count", SchemaProperty(qmfTypes.TYPE_UINT32)) _schema.add_property( "method_call_count", SchemaProperty(qmfTypes.TYPE_UINT32)) # These two properties can be set via the method call _schema.add_property( "set_string", SchemaProperty(qmfTypes.TYPE_LSTR)) _schema.add_property( "set_int", SchemaProperty(qmfTypes.TYPE_UINT32)) # add method _meth = SchemaMethod( _desc="Method to set string and int in object." ) _meth.add_argument( "arg_int", SchemaProperty(qmfTypes.TYPE_UINT32) ) _meth.add_argument( "arg_str", SchemaProperty(qmfTypes.TYPE_LSTR) ) _schema.add_method( "set_meth", _meth ) # Add schema to Agent self.agent.register_object_class(_schema) # instantiate managed data objects matching the schema _obj1 = QmfAgentData( self.agent, _schema=_schema, _values={"index1":100, "index2":"a name"}) _obj1.set_value("set_string", "UNSET") _obj1.set_value("set_int", 0) _obj1.set_value("query_count", 0) _obj1.set_value("method_call_count", 0) self.agent.add_object( _obj1 ) self.agent.add_object( QmfAgentData( self.agent, _schema=_schema, _values={"index1":99, "index2": "another name", "set_string": "UNSET", "set_int": 0, "query_count": 0, "method_call_count": 0} )) self.agent.add_object( QmfAgentData( self.agent, _schema=_schema, _values={"index1":50, "index2": "my name", "set_string": "SET", "set_int": 0, "query_count": 0, "method_call_count": 0} )) # add an "unstructured" object to the Agent _obj2 = QmfAgentData(self.agent, _object_id="01545") _obj2.set_value("field1", "a value") _obj2.set_value("field2", 2) _obj2.set_value("field3", {"a":1, "map":2, "value":3}) _obj2.set_value("field4", ["a", "list", "value"]) _obj2.set_value("index1", 50) self.agent.add_object(_obj2) _obj2 = QmfAgentData(self.agent, _object_id="01546") _obj2.set_value("field1", "a value") _obj2.set_value("field2", 3) _obj2.set_value("field3", {"a":1, "map":2, "value":3}) _obj2.set_value("field4", ["a", "list", "value"]) _obj2.set_value("index1", 51) self.agent.add_object(_obj2) _obj2 = QmfAgentData(self.agent, _object_id="01544") _obj2.set_value("field1", "a value") _obj2.set_value("field2", 4) _obj2.set_value("field3", {"a":1, "map":2, "value":3}) _obj2.set_value("field4", ["a", "list", "value"]) _obj2.set_value("index1", 49) self.agent.add_object(_obj2) _obj2 = QmfAgentData(self.agent, _object_id="01543") _obj2.set_value("field1", "a value") _obj2.set_value("field2", 4) _obj2.set_value("field3", {"a":1, "map":2, "value":3}) _obj2.set_value("field4", ["a", "list", "value"]) _obj2.set_value("index1", 48) self.agent.add_object(_obj2) self.running = False self.ready = Event()
def __init__(self, name, broker_url, heartbeat): Thread.__init__(self) self.notifier = _testNotifier() self.broker_url = broker_url self.agent = Agent(name, _notifier=self.notifier, heartbeat_interval=heartbeat) # Dynamically construct a management database _schema = SchemaObjectClass(_classId=SchemaClassId( "MyPackage", "MyClass"), _desc="A test data schema", _object_id_names=["index1", "index2"]) # add properties _schema.add_property("index1", SchemaProperty(qmfTypes.TYPE_UINT8)) _schema.add_property("index2", SchemaProperty(qmfTypes.TYPE_LSTR)) # these two properties are statistics _schema.add_property("query_count", SchemaProperty(qmfTypes.TYPE_UINT32)) _schema.add_property("method_call_count", SchemaProperty(qmfTypes.TYPE_UINT32)) # These two properties can be set via the method call _schema.add_property("set_string", SchemaProperty(qmfTypes.TYPE_LSTR)) _schema.add_property("set_int", SchemaProperty(qmfTypes.TYPE_UINT32)) # add method _meth = SchemaMethod(_desc="Method to set string and int in object.") _meth.add_argument("arg_int", SchemaProperty(qmfTypes.TYPE_UINT32)) _meth.add_argument("arg_str", SchemaProperty(qmfTypes.TYPE_LSTR)) _schema.add_method("set_meth", _meth) # Add schema to Agent self.agent.register_object_class(_schema) # instantiate managed data objects matching the schema _obj1 = QmfAgentData(self.agent, _schema=_schema, _values={ "index1": 100, "index2": "a name" }) _obj1.set_value("set_string", "UNSET") _obj1.set_value("set_int", 0) _obj1.set_value("query_count", 0) _obj1.set_value("method_call_count", 0) self.agent.add_object(_obj1) self.agent.add_object( QmfAgentData(self.agent, _schema=_schema, _values={ "index1": 99, "index2": "another name", "set_string": "UNSET", "set_int": 0, "query_count": 0, "method_call_count": 0 })) self.agent.add_object( QmfAgentData(self.agent, _schema=_schema, _values={ "index1": 50, "index2": "my name", "set_string": "SET", "set_int": 0, "query_count": 0, "method_call_count": 0 })) # add an "unstructured" object to the Agent _obj2 = QmfAgentData(self.agent, _object_id="01545") _obj2.set_value("field1", "a value") _obj2.set_value("field2", 2) _obj2.set_value("field3", {"a": 1, "map": 2, "value": 3}) _obj2.set_value("field4", ["a", "list", "value"]) _obj2.set_value("index1", 50) self.agent.add_object(_obj2) _obj2 = QmfAgentData(self.agent, _object_id="01546") _obj2.set_value("field1", "a value") _obj2.set_value("field2", 3) _obj2.set_value("field3", {"a": 1, "map": 2, "value": 3}) _obj2.set_value("field4", ["a", "list", "value"]) _obj2.set_value("index1", 51) self.agent.add_object(_obj2) _obj2 = QmfAgentData(self.agent, _object_id="01544") _obj2.set_value("field1", "a value") _obj2.set_value("field2", 4) _obj2.set_value("field3", {"a": 1, "map": 2, "value": 3}) _obj2.set_value("field4", ["a", "list", "value"]) _obj2.set_value("index1", 49) self.agent.add_object(_obj2) _obj2 = QmfAgentData(self.agent, _object_id="01543") _obj2.set_value("field1", "a value") _obj2.set_value("field2", 4) _obj2.set_value("field3", {"a": 1, "map": 2, "value": 3}) _obj2.set_value("field4", ["a", "list", "value"]) _obj2.set_value("index1", 48) self.agent.add_object(_obj2) self.running = False self.ready = Event()
_object_id_names=["index1", "index2"] ) # add properties _schema.add_property( "index1", SchemaProperty(qmfTypes.TYPE_UINT8)) _schema.add_property( "index2", SchemaProperty(qmfTypes.TYPE_LSTR)) # these two properties are statistics _schema.add_property( "query_count", SchemaProperty(qmfTypes.TYPE_UINT32)) _schema.add_property( "method_call_count", SchemaProperty(qmfTypes.TYPE_UINT32)) # These two properties can be set via the method call _schema.add_property( "set_string", SchemaProperty(qmfTypes.TYPE_LSTR)) _schema.add_property( "set_int", SchemaProperty(qmfTypes.TYPE_UINT32)) # add method _meth = SchemaMethod( _desc="Method to set string and int in object." ) _meth.add_argument( "arg_int", SchemaProperty(qmfTypes.TYPE_UINT32) ) _meth.add_argument( "arg_str", SchemaProperty(qmfTypes.TYPE_LSTR) ) _schema.add_method( "set_meth", _meth ) # Add schema to Agent _agent.register_object_class(_schema) # instantiate managed data objects matching the schema _obj1 = QmfAgentData( _agent, _schema=_schema ) _obj1.set_value("index1", 100) _obj1.set_value("index2", "a name" ) _obj1.set_value("set_string", "UNSET") _obj1.set_value("set_int", 0)
_object_id_names=["index1", "index2"]) # add properties _schema.add_property("index1", SchemaProperty(qmfTypes.TYPE_UINT8)) _schema.add_property("index2", SchemaProperty(qmfTypes.TYPE_LSTR)) # these two properties are statistics _schema.add_property("query_count", SchemaProperty(qmfTypes.TYPE_UINT32)) _schema.add_property("method_call_count", SchemaProperty(qmfTypes.TYPE_UINT32)) # These two properties can be set via the method call _schema.add_property("set_string", SchemaProperty(qmfTypes.TYPE_LSTR)) _schema.add_property("set_int", SchemaProperty(qmfTypes.TYPE_UINT32)) # add method _meth = SchemaMethod(_desc="Method to set string and int in object.") _meth.add_argument("arg_int", SchemaProperty(qmfTypes.TYPE_UINT32)) _meth.add_argument("arg_str", SchemaProperty(qmfTypes.TYPE_LSTR)) _schema.add_method("set_meth", _meth) # Add schema to Agent _agent.register_object_class(_schema) # instantiate managed data objects matching the schema _obj1 = QmfAgentData(_agent, _schema=_schema) _obj1.set_value("index1", 100) _obj1.set_value("index2", "a name") _obj1.set_value("set_string", "UNSET") _obj1.set_value("set_int", 0)
def __init__(self, name, broker_url, heartbeat): Thread.__init__(self) self.schema_count = _SCHEMAS_PER_AGENT self.obj_count = _OBJS_PER_AGENT self.notifier = _testNotifier() self.broker_url = broker_url self.agent = Agent(name, _notifier=self.notifier, heartbeat_interval=heartbeat, max_msg_size=_MAX_OBJS_PER_MSG) # Dynamically construct a management database for i in range(self.schema_count): _schema = SchemaObjectClass(_classId=SchemaClassId( "MyPackage", "MyClass-" + str(i)), _desc="A test data schema", _object_id_names=["index1", "index2"]) # add properties _schema.add_property("index1", SchemaProperty(qmfTypes.TYPE_UINT8)) _schema.add_property("index2", SchemaProperty(qmfTypes.TYPE_LSTR)) # these two properties are statistics _schema.add_property("query_count", SchemaProperty(qmfTypes.TYPE_UINT32)) _schema.add_property("method_call_count", SchemaProperty(qmfTypes.TYPE_UINT32)) # These two properties can be set via the method call _schema.add_property("set_string", SchemaProperty(qmfTypes.TYPE_LSTR)) _schema.add_property("set_int", SchemaProperty(qmfTypes.TYPE_UINT32)) # add method _meth = SchemaMethod( _desc="Method to set string and int in object.") _meth.add_argument("arg_int", SchemaProperty(qmfTypes.TYPE_UINT32)) _meth.add_argument("arg_str", SchemaProperty(qmfTypes.TYPE_LSTR)) _schema.add_method("set_meth", _meth) # Add schema to Agent self.agent.register_object_class(_schema) # instantiate managed data objects matching the schema for j in range(self.obj_count): self.agent.add_object( QmfAgentData(self.agent, _schema=_schema, _values={ "index1": j, "index2": "name-" + str(j), "set_string": "UNSET", "set_int": 0, "query_count": 0, "method_call_count": 0 })) self.running = False self.ready = Event()