Author: justi9
Date: 2008-06-25 13:59:00 -0400 (Wed, 25 Jun 2008)
New Revision: 2161
Modified:
mgmt/basil/python/basil/__init__.py
Log:
Update some of the naming in basil
Modified: mgmt/basil/python/basil/__init__.py
===================================================================
--- mgmt/basil/python/basil/__init__.py 2008-06-25 09:10:23 UTC (rev 2160)
+++ mgmt/basil/python/basil/__init__.py 2008-06-25 17:59:00 UTC (rev 2161)
@@ -20,33 +20,33 @@
self.lock = Lock()
- def on_schema(self, context_id, class_info,
+ def on_schema(self, broker_id, class_info,
configs, metrics, methods, events):
self.lock.acquire()
try:
package = self.get_package(class_info)
- package.on_schema(context_id, class_info,
+ package.on_schema(broker_id, class_info,
configs, metrics, methods, events)
finally:
self.lock.release()
- def on_config(self, context_id, class_info, values, timestamps):
+ def on_props(self, broker_id, class_info, values, timestamps):
self.lock.acquire()
try:
package = self.get_package(class_info)
- package.on_config(context_id, class_info, values, timestamps)
+ package.on_props(broker_id, class_info, values, timestamps)
finally:
self.lock.release()
- def on_metric(self, context_id, class_info, values, timestamps):
+ def on_stats(self, broker_id, class_info, values, timestamps):
self.lock.acquire()
try:
package = self.get_package(class_info)
- package.on_metric(context_id, class_info, values, timestamps)
+ package.on_stats(broker_id, class_info, values, timestamps)
finally:
self.lock.release()
- def on_callback(self, context_id, seq, status_code, status_text, args):
+ def on_callback(self, broker_id, seq, status_code, status_text, args):
self.lock.acquire()
try:
object, name, callback, kwargs = self.method_calls.pop(seq)
@@ -77,19 +77,19 @@
self.classes = list()
- def on_schema(self, context_id, class_info,
+ def on_schema(self, broker_id, class_info,
configs, metrics, methods, events):
cls = self.get_class(class_info)
- cls.on_schema(context_id, class_info,
+ cls.on_schema(broker_id, class_info,
configs, metrics, methods, events)
- def on_config(self, context_id, class_info, values, timestamps):
+ def on_props(self, broker_id, class_info, values, timestamps):
cls = self.get_class(class_info)
- cls.on_config(context_id, class_info, values, timestamps)
+ cls.on_props(broker_id, class_info, values, timestamps)
- def on_metric(self, context_id, class_info, values, timestamps):
+ def on_stats(self, broker_id, class_info, values, timestamps):
cls = self.get_class(class_info)
- cls.on_metric(context_id, class_info, values, timestamps)
+ cls.on_stats(broker_id, class_info, values, timestamps)
def get_class(self, class_info):
name = class_info[1]
@@ -120,7 +120,7 @@
attrs["basil_class"] = self
self.python_class = type(str(name), (BasilObject,), attrs)
- def on_schema(self, context_id, class_info,
+ def on_schema(self, broker_id, class_info,
configs, metrics, methods, events):
for spec in configs:
setattr(self.python_class, spec[0], None)
@@ -136,19 +136,19 @@
for spec in events:
pass
- def on_config(self, context_id, class_info, values, timestamps):
- object = self.get_object(class_info, context_id, values)
+ def on_props(self, broker_id, class_info, values, timestamps):
+ object = self.get_object(class_info, broker_id, values)
for name, value in values:
setattr(object, name, value)
- def on_metric(self, context_id, class_info, values, timestamps):
- object = self.get_object(class_info, context_id, values)
+ def on_stats(self, broker_id, class_info, values, timestamps):
+ object = self.get_object(class_info, broker_id, values)
for name, value in values:
setattr(object, name, value)
- def get_object(self, class_info, context_id, values):
+ def get_object(self, class_info, broker_id, values):
for name, value in values:
if name == "id":
id = value
@@ -157,11 +157,11 @@
assert id is not None
try:
- object = self.objects_by_composite_id[(context_id, id)]
+ object = self.objects_by_composite_id[(broker_id, id)]
except KeyError:
- object = self.python_class(class_info, context_id, id)
+ object = self.python_class(class_info, broker_id, id)
self.objects.append(object)
- self.objects_by_composite_id[(context_id, id)] = object
+ self.objects_by_composite_id[(broker_id, id)] = object
return object
@@ -169,9 +169,9 @@
return self.name
class BasilObject(object):
- def __init__(self, class_info, context_id, object_id):
+ def __init__(self, class_info, broker_id, object_id):
self.basil_class_info = class_info
- self.basil_context_id = context_id
+ self.basil_broker_id = broker_id
self.basil_object_id = object_id
def basil_call(self, name, callback, **kwargs):
@@ -183,7 +183,7 @@
finally:
model.lock.release()
- conn = model.connections[self.basil_context_id]
+ conn = model.connections[self.basil_broker_id]
client, chan = conn.mclient, conn.chan
model.method_calls[seq] = (self, name, callback, kwargs)
@@ -192,32 +192,32 @@
name, kwargs)
def __repr__(self):
- return "%r-%r" % (self.basil_context_id, self.basil_object_id)
+ return "%r-%r" % (self.basil_broker_id, self.basil_object_id)
class BasilConnection(object):
def __init__(self, model, host, port):
self.model = model
self.host = host
self.port = port
- self.context_id = "%s:%i" % (self.host, self.port)
+ self.broker_id = "%s:%i" % (self.host, self.port)
self.conn = Connection(connect(host, port), self.model.spec)
self.mclient = managementClient(self.model.spec,
None,
- self.model.on_config,
- self.model.on_metric,
+ self.model.on_props,
+ self.model.on_stats,
self.model.on_callback)
self.mclient.schemaListener(self.model.on_schema)
self.chan = None
- self.model.connections[self.context_id] = self
+ self.model.connections[self.broker_id] = self
def open(self):
self.conn.start()
self.chan = self.mclient.addChannel \
- (self.conn.session(str(uuid4())), self.context_id)
+ (self.conn.session(str(uuid4())), self.broker_id)
def close(self):
self.mclient.removeChannel(self.chan)