Author: tmckay
Date: 2013-02-12 15:11:33 +0000 (Tue, 12 Feb 2013)
New Revision: 5684
Removed:
branches/tmckay/basil/
branches/tmckay/cumin/python/cumin/messaging/
branches/tmckay/cumin/python/cumin/session.py
branches/tmckay/mace/
branches/tmckay/mint/python/mint/session.py
branches/tmckay/sage/python/sage/qmf/
Modified:
branches/tmckay/cumin/bin/cumin-data
branches/tmckay/cumin/bin/cumin-web
branches/tmckay/cumin/model/access/persona.xml
branches/tmckay/cumin/python/cumin/config.py
branches/tmckay/cumin/python/cumin/main.py
branches/tmckay/cumin/python/cumin/model.py
branches/tmckay/mint/python/mint/main.py
branches/tmckay/mint/python/mint/util.py
Log:
Remove unnecessary code
Modified: branches/tmckay/cumin/bin/cumin-data
===================================================================
--- branches/tmckay/cumin/bin/cumin-data 2013-02-11 21:53:18 UTC (rev 5683)
+++ branches/tmckay/cumin/bin/cumin-data 2013-02-12 15:11:33 UTC (rev 5684)
@@ -6,7 +6,7 @@
home = os.environ.get("CUMIN_HOME",
os.path.normpath("/usr/share/cumin"))
sys.path.append(os.path.join(home, "python"))
-from cumin.config import BrokeredOptionParser, CuminDataConfig
+from cumin.config import CuminOptionParser, CuminDataConfig
from mint import data_app
def make_ctrl_c(sig, frame):
@@ -20,7 +20,7 @@
super(DataTemplate, self).__init__()
def get_parser(self):
- return BrokeredOptionParser()
+ return CuminOptionParser()
def get_config(self, section):
# --section controls which section is read from the config file
@@ -31,16 +31,10 @@
def get_app(self, home, values, opts):
from mint.main import Mint
- broker_uris = [x.strip() for x in opts.brokers.split(",")]
-
mint = Mint(home,
- ("model", "model/admin"),
- broker_uris,
+ ("model", "model/admin"),
opts.database)
- if type(values.sasl_mech_list) == str:
- mint.sasl_mech_list = values.sasl_mech_list.upper()
-
mint.aviary_query_servers = values.aviary_query_servers
mint.aviary_collector_servers = values.aviary_collector_servers
mint.aviary_locator = values.aviary_locator
Modified: branches/tmckay/cumin/bin/cumin-web
===================================================================
--- branches/tmckay/cumin/bin/cumin-web 2013-02-11 21:53:18 UTC (rev 5683)
+++ branches/tmckay/cumin/bin/cumin-web 2013-02-12 15:11:33 UTC (rev 5684)
@@ -33,7 +33,7 @@
# Defautl is True. Undocumented.
cumin.aviary_prefer_condor = values.aviary_prefer_condor
-def set_wallaby_configs(cumin, values, brokers):
+def set_wallaby_configs(cumin, values):
if values.wallaby_broker == "None":
values.wallaby_broker = None
@@ -162,7 +162,7 @@
setup_initial_logging()
- parser = BrokeredOptionParser()
+ parser = CuminOptionParser()
# Add additional parameters for web
parser.add_option("--host")
@@ -199,22 +199,15 @@
log.error("Extra arguments:" + "".join([" "+arg
for arg in args]))
raise ArgError
- broker_uris = [x.strip() for x in opts.brokers.split(",")]
authmech = [x.strip() for x in values.auth.split(";") if x !=
""]
- cumin = Cumin(config.get_home(), broker_uris, opts.database,
+ cumin = Cumin(config.get_home(), opts.database,
opts.host, opts.port,
opts.server_cert, opts.server_key,
values.force_secure_cookies,
values.persona, authmech)
- # If the mech_list was set explicitly, honor it.
- # Otherwise Cumin will default based on whether or not
- # a broker URL contains credentials.
- if type(values.sasl_mech_list) == str:
- cumin.sasl_mech_list = values.sasl_mech_list.upper()
-
set_aviary_configs(cumin, values)
- set_wallaby_configs(cumin, values, broker_uris)
+ set_wallaby_configs(cumin, values)
set_ldap_configs(cumin, values)
set_kerberos_configs(cumin, values)
Modified: branches/tmckay/cumin/model/access/persona.xml
===================================================================
--- branches/tmckay/cumin/model/access/persona.xml 2013-02-11 21:53:18 UTC (rev 5683)
+++ branches/tmckay/cumin/model/access/persona.xml 2013-02-12 15:11:33 UTC (rev 5684)
@@ -1,28 +1,4 @@
<PersonaMap>
- <Persona name="default" auth="True">
- <Module name="account"/>
- <Module name="configuration"/>
- <Module name="messaging"/>
- <Module name="grid"/>
- <Module name="inventory"/>
- <Module name="usergrid"/>
-
- <GroupAccess name="nogroup">
- <MainPage name="login.html"/>
- </GroupAccess>
-
- <GroupAccess name="user">
- <MainPage name="usergrid.html"/>
- <ModuleAccess name="account"/>
- <ModuleAccess name="usergrid"/>
- </GroupAccess>
-
- <GroupAccess name="admin">
- <MainPage name="index.html"/>
- <ModuleAccess name="*"/>
- </GroupAccess>
- </Persona>
-
<Persona name="grid" auth="True">
<Module name="account"/>
<Module name="configuration"/>
@@ -45,10 +21,4 @@
<ModuleAccess name="*"/>
</GroupAccess>
</Persona>
-
- <Persona name="messaging" auth="False">
- <Module name="account"/>
- <Module name="messaging"/>
- <Module name="inventory"/>
- </Persona>
</PersonaMap>
Modified: branches/tmckay/cumin/python/cumin/config.py
===================================================================
--- branches/tmckay/cumin/python/cumin/config.py 2013-02-11 21:53:18 UTC (rev 5683)
+++ branches/tmckay/cumin/python/cumin/config.py 2013-02-12 15:11:33 UTC (rev 5684)
@@ -167,13 +167,6 @@
super(BrokeredConfigSection, self).__init__(config, name,
strict_section)
- param = ConfigParameter(self, "brokers", str)
- param.default = "amqp://localhost"
-
- # Leave default set to None, which is equivalent to
- # previous behavior
- param = ConfigParameter(self, "sasl-mech-list", str)
-
param = ConfigParameter(self, "aviary-query-servers", str)
param.default = "http://localhost:9091"
@@ -315,14 +308,6 @@
self.add_option("--log-file")
self.add_option("--log-level")
-class BrokeredOptionParser(CuminOptionParser):
- def __init__(self):
- CuminOptionParser.__init__(self)
-
- # Defaults for these come later from the config
- # section named in --section, via apply_defaults()
- self.add_option("--brokers")
-
class PlumageOptionParser(CuminOptionParser):
def __init__(self):
CuminOptionParser.__init__(self)
Modified: branches/tmckay/cumin/python/cumin/main.py
===================================================================
--- branches/tmckay/cumin/python/cumin/main.py 2013-02-11 21:53:18 UTC (rev 5683)
+++ branches/tmckay/cumin/python/cumin/main.py 2013-02-12 15:11:33 UTC (rev 5684)
@@ -15,7 +15,6 @@
from objectselector import *
from objecttask import *
from server import *
-from session import *
from sqladapter import *
from user import *
from util import *
@@ -23,16 +22,14 @@
from authenticator import *
from persona import CuminAuthorizator
from sage.catalog import Catalog
-from sage.qmf.qmfoperations import QmfOperations
from sage.wallaby.wallabyoperations import WallabyOperations
-from wooly import Session
from cumin.widgets import AboutPage
strings = StringCatalog(__file__)
log = logging.getLogger("cumin")
class Cumin(Application):
- def __init__(self, home, broker_uris, database_dsn,
+ def __init__(self, home, database_dsn,
host="localhost", port=45672,
server_cert="", server_key="",
force_secure_cookies=False,
@@ -54,7 +51,6 @@
model_dir = [os.path.join(self.home, x) for x in ("model/admin",
"model", "model/plumage")]
self.model = CuminModel(self, model_dir)
- self.session = CuminSession(self, broker_uris)
self.database = CuminDatabase(self, database_dsn)
self.server = CuminServer(self, host, port, server_cert, server_key)
@@ -96,10 +92,6 @@
self.model.sql_logging_enabled = True
- # Space separated list of sasl authentication
- # mechanisms, according to the sasl documentation
- self.sasl_mech_list = None
-
# Aviary interface. If server values are "",
# Aviary operations for that server type will not be used.
self.aviary_job_servers = ""
@@ -134,13 +126,7 @@
def _init_persona(self, modules):
# Determine the view based on which modules are enabled
- if "messaging" in modules:
- if "grid" in modules:
- view = MainView(self, "main")
- else:
- view = MessagingMainView(self, "main")
- else:
- view = GridMainView(self, "main")
+ view = GridMainView(self, "main")
self.main_page = MainPage(self, "index.html", view)
self.add_page(self.main_page, add_to_link_set=True)
@@ -199,7 +185,7 @@
# service in the list takes precedence for any
# given op...
self.remote = Catalog()
- ops = [QmfOperations("qmf", self.session)]
+ ops = []
imports_ok = True
if self.aviary_locator or \
@@ -255,7 +241,6 @@
self.wallaby_refresh)
self.model.init()
- self.session.init()
self.database.init(schema_version_check)
self.server.init()
@@ -274,7 +259,6 @@
def start(self):
log.info("Starting %s", self)
- self.session.start()
self.server.start()
if self.wallaby is not None:
self.wallaby.start()
@@ -292,10 +276,6 @@
log.debug("Exception stopping update threads")
self.server.stop()
- try:
- self.session.stop()
- except:
- pass
def set_form_defaults(self,
request_memory,
@@ -336,20 +316,6 @@
def __init__(self, app, name):
super(GridMainView, self).__init__(app, name)
-class MessagingMainView(CuminMainView):
- def __init__(self, app, name):
- super(MessagingMainView, self).__init__(app, name)
-
- self.overview = MessagingOverviewFrame(app, "overview")
- self.add_tab(self.overview)
-
-class MainView(CuminMainView):
- def __init__(self, app, name):
- super(MainView, self).__init__(app, name)
-
- self.overview = OverviewFrame(app, "overview")
- self.add_tab(self.overview)
-
class MainPage(CuminPage, ModeSet):
def __init__(self, app, name, main_view):
super(MainPage, self).__init__(app, name)
@@ -357,7 +323,7 @@
self.main = main_view
self.add_mode(self.main)
self.set_default_frame(self.main)
- self.cumin_module = ["messaging", "grid"]
+ self.cumin_module = ["grid"]
self.page_html_class = "Cumin"
@@ -367,8 +333,6 @@
def get_title(self, session):
return "Administrator"
-# XXX Add qmf tab
-
class OverviewFrame(CuminFrame):
def __init__(self, app, name):
super(OverviewFrame, self).__init__(app, name)
@@ -376,22 +340,9 @@
self.view = self.get_overview_view(app)
self.add_mode(self.view)
- self.notice = ConfigurationNotice(app, "notice")
- self.add_mode(self.notice)
-
def get_overview_view(self, app):
return OverviewView(app, "view")
- def do_process(self, session):
- super(OverviewFrame, self).do_process(session)
-
- configured_count = len([x for x in self.app.session.qmf_brokers if x.host !=
"localhost"])
- connected_count = len([x for x in self.app.session.qmf_brokers if x.connected])
-
- # there were no user defined entries in cumin.conf and localhost isn't
connected
- if (configured_count == 0) and (connected_count == 0):
- self.mode.set(session, self.notice)
-
def render_title(self, session):
return "Overview"
@@ -399,9 +350,6 @@
def __init__(self, app, name):
super(OverviewView, self).__init__(app, name)
- queues = TopQueueTable(app, "queues")
- self.add_child(queues)
-
systems = TopSystemTable(app, "systems")
self.add_child(systems)
systems.cumin_module = "inventory"
@@ -410,137 +358,9 @@
self.add_child(submissions)
submissions.cumin_module = "grid"
-class MessagingOverviewFrame(OverviewFrame):
- def __init__(self, app, name):
- super(MessagingOverviewFrame, self).__init__(app, name)
-
- def get_overview_view(self, app):
- return MessagingOverviewView(app, "view")
-
-class MessagingOverviewView(Widget):
- def __init__(self, app, name):
- super(MessagingOverviewView, self).__init__(app, name)
-
- queues = TopQueueTable(app, "queues")
- self.add_child(queues)
-
- systems = TopSystemTable(app, "systems")
- self.add_child(systems)
-
class ConfigurationNotice(Widget):
pass
-class TopQueueAdapter(SqlAdapter):
- def __init__(self, app, cls):
- super(TopQueueAdapter, self).__init__(app, cls.sql_table)
- self.cls = cls
-
- def init(self):
- super(TopQueueAdapter, self).init()
-
- name_col = self.table._columns_by_name["name"]
- avg_over_last_60_seconds_col =
"""((sum("Queue"."msgTotalEnqueues") -
- sum(s."msgTotalEnqueues")) / (count(1)-1)) / 300 as
avg_60"""
- queue_id_col = self.table._columns_by_name["_id"]
- vhostRef_col = self.table._columns_by_name["_vhostRef_id"]
- vhost_table = self.app.model.org_apache_qpid_broker.Vhost.sql_table
- vhost_id_col = vhost_table._columns_by_name["_id"]
- vhost_brokerRef_col = vhost_table._columns_by_name["_brokerRef_id"]
-
- self.columns.append(name_col)
- self.columns.append(avg_over_last_60_seconds_col)
- self.columns.append(vhost_brokerRef_col)
- self.columns.append(queue_id_col)
-
- sub_query = "(%s) as s" % self.get_sub_query_text()
- SqlInnerJoin(self.query, sub_query,
- queue_id_col, "s._parent_id")
-
- SqlInnerJoin(self.query, vhost_table,
- vhostRef_col, vhost_id_col)
-
- def get_sub_query_text(self):
- samples_table = self.cls.sql_samples_table
- subquery = SqlQuery(samples_table)
- parent_col = samples_table._columns_by_name["_parent_id"]
- updated_col = samples_table._columns_by_name["_qmf_update_time"]
- enqueues_col = samples_table._columns_by_name["msgTotalEnqueues"]
-
- when = "now() - interval '600 seconds'"
- filter = SqlComparisonFilter(updated_col, when, ">=")
- subquery.add_filter(filter)
-
- columns = list()
- columns.append(parent_col)
- columns.append(enqueues_col)
-
- return subquery.emit(columns)
-
- def get_data(self, values, options):
- options.sort_column = "avg_60"
- options.sort_ascending = False
-
- options.group_column = "%s, %s, %s" %
("\"Queue\".name", "\"Queue\"._id",
"\"Vhost\".\"_brokerRef_id\"")
- having = SqlComparisonFilter("count(1)", "1",
">")
- options.group_having.append(having)
-
- try:
- data = super(TopQueueAdapter, self).get_data(values, options)
- except:
- data = []
- return data
-
- def get_sql_options(self, options):
- return options
-
-class TopQueueTable(TopTable):
- def __init__(self, app, name):
- cls = app.model.org_apache_qpid_broker.Queue
- super(TopQueueTable, self).__init__(app, name, cls)
-
- frame = "main.messaging.broker.queue"
- col = self.NameColumn(app, "name", cls.name, cls._id, frame)
- self.add_column(col)
-
- col = self.add_attribute_column(cls.msgDepth)
- self.set_default_sort_column(col)
-
- def init(self):
- super(TopQueueTable, self).init()
-
- self.adapter.vhost_id_field = ObjectSqlField \
- (self.adapter, self.cls.vhostRef)
-
- filter = SqlComparisonFilter(self.cls.msgDepth.sql_column,
- "null",
- "is not")
- self.adapter.query.add_filter(filter)
-
- def render_rows(self, session):
- data = self.data.get(session)
-
- writer = Writer()
-
- for record in data:
- # if there is no broker id, don't render the row
- if record[self.adapter.vhost_id_field.index]:
- writer.write(self.row.render(session, record))
-
- return writer.to_string()
-
- class NameColumn(ObjectLinkColumn):
- def render_cell_href(self, session, record):
- branch = session.branch()
-
- frame = self.page.main.messaging.broker
- adapter = self.table.adapter
-
- frame.id.set(branch, record[adapter.vhost_id_field.index])
- frame.queue.id.set(branch, record[adapter.id_field.index])
- frame.queue.view.show(branch)
-
- return branch.marshal()
-
class TopSystemTable(TopTable):
def __init__(self, app, name):
cls = app.model.com_redhat_sesame.Sysimage
Modified: branches/tmckay/cumin/python/cumin/model.py
===================================================================
--- branches/tmckay/cumin/python/cumin/model.py 2013-02-11 21:53:18 UTC (rev 5683)
+++ branches/tmckay/cumin/python/cumin/model.py 2013-02-12 15:11:33 UTC (rev 5684)
@@ -100,13 +100,6 @@
def show_main(self, session):
return self.app.main_page.main.show(session)
- def get_session_by_object(self, obj):
- agent = self.app.session.get_agent(obj._qmf_agent_id)
- broker = agent.getBroker()
- session = broker.getAmqpSession()
-
- return session
-
def get_negotiator_group_names(self, negotiator):
if not negotiator:
store = NegotiatorGroupNamesStore(self, None)
Deleted: branches/tmckay/cumin/python/cumin/session.py
===================================================================
--- branches/tmckay/cumin/python/cumin/session.py 2013-02-11 21:53:18 UTC (rev 5683)
+++ branches/tmckay/cumin/python/cumin/session.py 2013-02-12 15:11:33 UTC (rev 5684)
@@ -1,201 +0,0 @@
-from model import *
-from util import *
-from mint.util import make_agent_id
-
-from qmf.console import Console, Session, ObjectId
-from rosemary.model import RosemaryObject
-from sage.util import get_sasl_mechanisms
-
-log = logging.getLogger("cumin.session")
-
-class CuminSession(object):
- def __init__(self, app, broker_uris):
- self.app = app
- self.broker_uris = broker_uris
-
- self.qmf_session = None
- self.qmf_brokers = list()
- self.qmf_agents = dict()
-
- # int seq => callable
- self.outstanding_method_calls = dict()
-
- self.lock = Lock()
-
- def add_broker(self, uri):
- mechs = get_sasl_mechanisms(uri, self.app.sasl_mech_list)
- uri_without_password = uri[uri.rfind("@") + 1:]
- log.info("Adding QMF broker at %s with mech_list %s",
uri_without_password, mechs)
-
- assert self.qmf_session
-
- qmf_broker = self.qmf_session.addBroker(uri,mechanisms=mechs)
-
- self.qmf_brokers.append(qmf_broker)
-
- def check(self):
- log.info("Checking %s", self)
-
- def init(self):
- uris_without_password = [x[x.rfind("@")+1:] for x in
self.broker_uris]
- log.info("Initializing %s", uris_without_password)
-
- def start(self):
- log.info("Starting %s", self)
-
- assert self.qmf_session is None
-
- self.qmf_session = Session(CuminConsole(self),
- manageConnections=True,
- rcvObjects=False,
- rcvEvents=False,
- rcvHeartbeats=False)
-
- for uri in self.broker_uris:
- self.add_broker(uri)
-
- def stop(self):
- log.info("Stopping %s", self)
-
- for qmf_broker in self.qmf_brokers:
- self.qmf_session.delBroker(qmf_broker)
-
- def get_agent(self, agent_id):
- self.lock.acquire()
- try:
- return self.qmf_agents.get(agent_id)
- finally:
- self.lock.release()
-
- def call_method(self, callback, obj, name, args):
- assert isinstance(obj, RosemaryObject)
-
- for i in range(10):
- agent = self.get_agent(obj._qmf_agent_id)
-
- if agent:
- break
-
- sleep(1)
-
- if not agent:
- raise Exception("Agent '%s' is unknown" %
obj._qmf_agent_id)
-
- if obj._qmf_object_id.isdigit():
- # Translate v1 object ids
- object_id = self.gen_object_id(obj)
- else:
- object_id = obj._qmf_object_id
-
- oid = ObjectId({"_agent_name": obj._qmf_agent_id,
- "_object_name": object_id})
-
- qmf_objs = agent.getObjects(_objectId=oid)
-
- try:
- qmf_obj = qmf_objs[0]
- except IndexError:
- raise Exception("Object '%s' is unknown" % object_id)
-
- self.lock.acquire()
- try:
- seq = qmf_obj._invoke(name, args, {"_async": True})
-
- assert seq is not None
-
- self.outstanding_method_calls[seq] = callback
-
- return seq
- finally:
- self.lock.release()
-
- def gen_object_id(self, obj):
- # special case objects are queue, link , and bridge
- if obj._class in (self.app.model.org_apache_qpid_broker.Queue,
- self.app.model.org_apache_qpid_broker.Link,
- self.app.model.org_apache_qpid_broker.Bridge):
- if obj._class is self.app.model.org_apache_qpid_broker.Queue:
- key = obj.name
- else:
- if obj._class is self.app.model.org_apache_qpid_broker.Bridge:
- # bridges need the link object_id as well as their own object_id
- cls = self.app.model.org_apache_qpid_broker.Link
- cursor = self.app.database.get_read_cursor()
- link = cls.get_object(cursor, _id=obj._linkRef_id)
- if not link:
- raise Exception("Object '%s' is not a valid
bridge" % obj._id)
- else:
- link = obj
- key = "qpid.%s:%s:%d" % (link.transport, link.host, link.port)
-
- if obj._class is self.app.model.org_apache_qpid_broker.Bridge:
-
#org.apache.qpid.broker:bridge:org.apache.qpid.broker:link:qpid.tcp:localhost:5671,qpid.tcp:localhost:5671!amq.direct!amq.direct!r-key
- key = "%s:%s:%s,%s!%s!%s!%s" % (link._class._package._name,
link._class._name.lower(),
- key, key, obj.src, obj.dest,
obj.key)
- else:
- # other objects use the schema index fields
- key_args = [str(getattr(obj, x.name))
- for x in obj._class._attributes
- if x.index and not x.references]
- key = ",".join(key_args)
-
- id_args = (obj._class._package._name, obj._class._name.lower(), key)
- object_id = ":".join(id_args)
- return object_id
-
- def __repr__(self):
- uris_without_password = [x[x.rfind("@")+1:] for x in
self.broker_uris]
- return "%s(%s)" % (self.__class__.__name__, uris_without_password)
-
-class CuminConsole(Console):
- def __init__(self, session):
- self.session = session
-
- def brokerConnected(self, broker):
- log.info("Broker connected %s:%s", broker.host, broker.port)
-
- def brokerConnectionFailed(self, broker):
- log.info("Broker connection failed %s:%s", broker.host, broker.port)
-
- def brokerDisconnected(self, broker):
- log.info("Broker disconnected %s:%s", broker.host, broker.port)
-
- def newPackage(self, name):
- log.debug("New package %s", name)
-
- def newClass(self, kind, classKey):
- log.debug("New class %s", classKey)
-
- def newAgent(self, qmf_agent):
- log.debug("New agent %s", qmf_agent)
-
- agent_id = make_agent_id(qmf_agent)
-
- self.session.lock.acquire()
- try:
- self.session.qmf_agents[agent_id] = qmf_agent
- finally:
- self.session.lock.release()
-
- def delAgent(self, qmf_agent):
- log.debug("Deleting agent %s", qmf_agent)
-
- agent_id = make_agent_id(qmf_agent)
-
- self.session.lock.acquire()
- try:
- del self.session.qmf_agents[agent_id]
- finally:
- self.session.lock.release()
-
- def methodResponse(self, broker, seq, response):
- log.debug("Method response for request %i received from %s",
- seq, broker)
- log.debug("Response: %s", response)
-
- self.session.lock.acquire()
- try:
- callback = self.session.outstanding_method_calls.pop(seq)
- callback(response.text, response.outArgs)
- finally:
- self.session.lock.release()
Modified: branches/tmckay/mint/python/mint/main.py
===================================================================
--- branches/tmckay/mint/python/mint/main.py 2013-02-11 21:53:18 UTC (rev 5683)
+++ branches/tmckay/mint/python/mint/main.py 2013-02-12 15:11:33 UTC (rev 5684)
@@ -1,7 +1,6 @@
from database import MintDatabase
from expire import ExpireThread
from model import MintModel
-from session import MintSession
from aviary.session import MintAviarySession
from update import UpdateThread
from vacuum import VacuumThread
@@ -11,18 +10,16 @@
log = logging.getLogger("mint.main")
class Mint(object):
- def __init__(self, home, model_paths, broker_uris, database_dsn):
+ def __init__(self, home, model_paths, database_dsn):
self.home = home
model_dir = [os.path.join(self.home, x) for x in model_paths]
self.model = MintModel(self, model_dir)
self.model.sql_logging_enabled = True
- self.broker_uris = broker_uris
self.database = MintDatabase(self, database_dsn)
self.admin = CuminAdmin(self)
self.update_thread = UpdateThread(self)
- self.session = None
self.aviary_session = None
self.expire_enabled = True
@@ -33,10 +30,6 @@
self.print_event_level = 0
- # Space separated list of sasl authentication
- # mechanisms, according to the sasl documentation
- self.sasl_mech_list = None
-
# List of classes to bind in QMF. Referenced by session and update thread.
self._qmf_classes = set()
@@ -187,7 +180,6 @@
# (someday it will be ALL classes)
self._init_aviary()
- self.session = MintSession(self, self.broker_uris, self._qmf_classes)
self.database.init()
self.update_thread.init()
@@ -199,7 +191,6 @@
self.update_thread.start()
- self.session.start()
if self.aviary_session:
self.aviary_session.start()
@@ -220,7 +211,6 @@
if self.vacuum_enabled and not skip_vacuum:
self.vacuum_thread.stop()
- self.session.stop()
if self.aviary_session:
self.aviary_session.stop()
log.info("Session stopped")
Deleted: branches/tmckay/mint/python/mint/session.py
===================================================================
--- branches/tmckay/mint/python/mint/session.py 2013-02-11 21:53:18 UTC (rev 5683)
+++ branches/tmckay/mint/python/mint/session.py 2013-02-12 15:11:33 UTC (rev 5684)
@@ -1,125 +0,0 @@
-from update import *
-from util import *
-
-from qmf.console import Console, Session
-from sage.util import get_sasl_mechanisms
-
-log = logging.getLogger("mint.session")
-
-class MintSession(object):
- def __init__(self, app, broker_uris, qmf_classes):
- self.app = app
- self.broker_uris = broker_uris
-
- self.qmf_classes = qmf_classes
- self.qmf_session = None
- self.qmf_brokers = list()
-
- def add_broker(self, uri):
- mechs = get_sasl_mechanisms(uri, self.app.sasl_mech_list)
- uri_without_password = uri[uri.rfind("@") + 1:]
- log.info("Adding QMF broker at %s with mech_list %s",
uri_without_password, mechs)
-
- assert self.qmf_session
-
- qmf_broker = self.qmf_session.addBroker(uri, mechanisms=mechs)
- self.qmf_brokers.append(qmf_broker)
-
- def start(self):
- log.info("Starting %s", self)
-
- assert self.qmf_session is None
-
- self.qmf_session = Session(MintConsole(self.app.model),
- manageConnections=True,
- rcvObjects=True,
- rcvEvents=False,
- rcvHeartbeats=False,
- userBindings=True)
-
- self.qmf_session.bindAgent("*")
- log.info("Binding all agents")
-
- for cls in self.qmf_classes:
- pname = cls._package._name
- cname = cls._name
- self.qmf_session.bindClass(pname.lower(), cname.lower())
- log.info("Binding QMF class %s.%s" % (pname, cname))
-
- for uri in self.broker_uris:
- self.add_broker(uri)
-
- def stop(self):
- log.info("Stopping %s", self)
-
- for qmf_broker in self.qmf_brokers:
- self.qmf_session.delBroker(qmf_broker)
-
- def __repr__(self):
- uris_without_password = [x[x.rfind("@")+1:] for x in
self.broker_uris]
- return "%s(%s)" % (self.__class__.__name__, uris_without_password)
-
-class MintConsole(Console):
- def __init__(self, model):
- self.model = model
-
- def brokerConnected(self, qmf_broker):
- message = "Broker %s:%i is connected"
- self.model.print_event(1, message, qmf_broker.host, qmf_broker.port)
-
- def brokerInfo(self, qmf_broker):
- message = "Broker info from %s:%i"
- self.model.print_event(1, message, qmf_broker.host, qmf_broker.port)
-
- def brokerDisconnected(self, qmf_broker):
- message = "Broker %s:%i is disconnected"
- self.model.print_event(1, message, qmf_broker.host, qmf_broker.port)
-
- def newAgent(self, qmf_agent):
- self.model.print_event(3, "Creating %s", qmf_agent)
-
- up = AgentUpdate(self.model, qmf_agent)
- self.model.app.update_thread.enqueue(up)
-
- def delAgent(self, qmf_agent):
- self.model.print_event(3, "Deleting %s", qmf_agent)
-
- up = AgentDelete(self.model, qmf_agent)
- self.model.app.update_thread.enqueue(up)
-
- def heartbeat(self, qmf_agent, timestamp):
- message = "Heartbeat from %s at %s"
- self.model.print_event(5, message, qmf_agent, timestamp)
-
- up = AgentUpdate(self.model, qmf_agent)
- self.model.app.update_thread.enqueue(up)
-
- def newPackage(self, name):
- self.model.print_event(2, "New package %s", name)
-
- def newClass(self, kind, classKey):
- self.model.print_event(2, "New class %s", classKey)
-
- def objectProps(self, broker, qmf_object):
- up = ObjectUpdate(self.model, qmf_object)
- self.model.app.update_thread.enqueue(up)
-
- def objectStats(self, broker, qmf_object):
- up = ObjectUpdate(self.model, qmf_object)
- self.model.app.update_thread.enqueue(up)
-
- def event(self, broker, event):
- self.model.print_event(4, "New event %s from %s", broker, event)
-
- def methodResponse(self, broker, seq, response):
- message = "Method response for request %i received from %s"
- self.model.print_event(3, message, seq, broker)
-
- log.debug("Response: %s", response)
-
- self.model.lock.acquire()
- try:
- callback = self.model.outstanding_method_calls.pop(seq)
- callback(response.text, response.outArgs)
- finally:
- self.model.lock.release()
Modified: branches/tmckay/mint/python/mint/util.py
===================================================================
--- branches/tmckay/mint/python/mint/util.py 2013-02-11 21:53:18 UTC (rev 5683)
+++ branches/tmckay/mint/python/mint/util.py 2013-02-12 15:11:33 UTC (rev 5684)
@@ -9,7 +9,6 @@
from datetime import datetime, timedelta
from pprint import pprint
from getpass import getpass
-from qmf.console import ObjectId
from random import sample
from tempfile import mkstemp
from threading import Thread, Lock, RLock, Condition
@@ -114,131 +113,6 @@
return password
-def make_agent_id(agent):
- broker = agent.getBroker()
-
- if not agent.isV2 or agent is broker.getBrokerAgent():
- return "!!%s:%i!!%s" % (broker.host, broker.port,
agent.getAgentBank())
-
- return agent.agentBank
-
-class QmfAgentId(object):
- def __init__(self, brokerId, brokerBank, agentBank):
- assert brokerId
-
- self.brokerId = brokerId
- self.brokerBank = brokerBank
- self.agentBank = agentBank
-
- def fromObject(cls, object):
- broker = object.getBroker()
-
- brokerId = broker.getBrokerId()
- brokerBank = broker.getBrokerBank()
- agentBank = object.getObjectId().getAgentBank()
-
- return cls(brokerId, brokerBank, agentBank)
-
- def fromAgent(cls, agent):
- return agent.getAgentBank()
-
- broker = agent.getBroker()
-
- brokerId = broker.getBrokerId()
- brokerBank = broker.getBrokerBank()
- agentBank = agent.getAgentBank()
-
- print "XXX", brokerId, brokerBank, agentBank
-
- return cls(brokerId, brokerBank, agentBank)
-
- def fromString(cls, string):
- brokerId, brokerBank, agentBank = string.split(".")
-
- brokerBank = int(brokerBank)
- agentBank = int(agentBank)
-
- return cls(brokerId, brokerBank, agentBank)
-
- fromObject = classmethod(fromObject)
- fromAgent = classmethod(fromAgent)
- fromString = classmethod(fromString)
-
- def __str__(self):
- return self.agentBank
-
-class QmfObjectId(object):
- def __init__(self, id):
- self.id = id
-
- def fromObject(cls, object):
- oid = object.getObjectId()
-
- print "XXX", oid
-
- for k, v in oid.__dict__.items():
- print " ", k, v
-
- return cls(oid.first, oid.second)
-
- def fromString(cls, string):
- first, second = string.split(".")
-
- first = int(first)
- second = int(second)
-
- return cls(first, second)
-
- fromObject = classmethod(fromObject)
- fromString = classmethod(fromString)
-
- def toObjectId(self):
- return ObjectId(None, self.first, self.second)
-
- def __str__(self):
- return "%i.%i" % (self.first, self.second)
-
-class UpdateQueue(ConcurrentQueue):
- def __init__(self, maxsize=0, slotCount=1):
- self.slotCount = slotCount
- ConcurrentQueue.__init__(self, maxsize)
-
- def _init(self, maxsize):
- self.maxsize = maxsize
- self.slots = []
-
- for i in range(self.slotCount):
- self.slots.append(deque())
-
- def _qsize(self):
- size = 0
-
- for i in range(self.slotCount):
- size += len(self.slots[i])
-
- return size
-
- def _empty(self):
- return self._qsize() == 0
-
- def _full(self):
- return self.maxsize > 0 and self._qsize() == self.maxsize
-
- def _put(self, update):
- slot = update.priority
-
- if slot in range(self.slotCount):
- self.slots[slot].append(update)
- else:
- raise ValueError("Invalid priority slot")
-
- def _get(self):
- for slot in range(self.slotCount):
- if len(self.slots[slot]) > 0:
- return self.slots[slot].popleft()
-
- return None
-
password_chars =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
def crypt_password(password, salt=None):