get class by agent
This commit is contained in:
parent
0eaa13b332
commit
9c7a31f780
|
@ -60,11 +60,16 @@ class TcAgentManager(manager.Manager):
|
|||
'max_rate': self.conf.WANTC.wan_max_rate
|
||||
}
|
||||
self.agent.set_root_queue(tc_dict)
|
||||
context = ctx.get_admin_context()
|
||||
agent_conf = self.plugin_rpc.get_configuration_from_db(
|
||||
ctx.get_admin_context())
|
||||
context)
|
||||
class_tree = agent_conf['class_tree']
|
||||
if class_tree['id'] == 'root':
|
||||
self.init_child_classes(class_tree['child_list'])
|
||||
|
||||
if 'filters' in agent_conf:
|
||||
for filter in agent_conf['filters']:
|
||||
self.create_wtc_filter(context, filter)
|
||||
return
|
||||
raise exceptions.InvalidInput(error_message='Did not get root class')
|
||||
|
||||
|
@ -124,7 +129,8 @@ class TcAgentManager(manager.Manager):
|
|||
|
||||
def create_wtc_filter(self, context, wtc_filter):
|
||||
|
||||
wtc_class = wtc_filter['class']
|
||||
wtc_class = self.plugin_rpc.get_class_by_id(context,
|
||||
wtc_filter['class_id'])
|
||||
|
||||
tc_dict = {
|
||||
'child': wtc_class['class_ext_id'],
|
||||
|
|
|
@ -45,6 +45,10 @@ class TcPluginApi(object):
|
|||
cctxt = self.client.prepare()
|
||||
return cctxt.call(context, 'get_configuration_from_db', host=self.host)
|
||||
|
||||
def get_class_by_id(self, context, id):
|
||||
cctxt = self.client.prepare()
|
||||
return cctxt.call(context, 'get_class_by_id', id=id)
|
||||
|
||||
|
||||
class TcAgentApi(object):
|
||||
def __init__(self, host, topic=topics.TC_AGENT):
|
||||
|
|
|
@ -306,9 +306,10 @@ class WanTcDb(object):
|
|||
return items
|
||||
|
||||
def _has_attribute(self, model, filters):
|
||||
for key in filters.keys():
|
||||
if not hasattr(model, key):
|
||||
return False
|
||||
if filters:
|
||||
for key in filters.keys():
|
||||
if not hasattr(model, key):
|
||||
return False
|
||||
return True
|
||||
|
||||
def _get_collection_query(self, context, model, filters=None,
|
||||
|
|
|
@ -51,11 +51,15 @@ class PluginRpcCallback(object):
|
|||
|
||||
def get_configuration_from_db(self, context, host):
|
||||
conf = {
|
||||
'class_tree': self.plugin.db.get_class_tree()
|
||||
'class_tree': self.plugin.db.get_class_tree(),
|
||||
'filters': self.plugin.db.get_wan_tc_filters(context)
|
||||
}
|
||||
|
||||
return conf
|
||||
|
||||
def get_class_by_id(self, context, id):
|
||||
return self.plugin.db.get_class_by_id(context, id)
|
||||
|
||||
|
||||
class WanQosPlugin(wantcfilter.WanTcFilterPluginBase,
|
||||
wantcdevice.WanTcDevicePluginBase,
|
||||
|
@ -140,8 +144,8 @@ class WanQosPlugin(wantcfilter.WanTcFilterPluginBase,
|
|||
wtc_filter = self.db.create_wan_tc_filter(context,
|
||||
wan_tc_filter[
|
||||
'wan_tc_filter'])
|
||||
wtc_class = self.get_wan_tc_class(context, wtc_filter['class_id'])
|
||||
wtc_filter['class'] = wtc_class
|
||||
# wtc_class = self.get_wan_tc_class(context, wtc_filter['class_id'])
|
||||
# wtc_filter['class'] = wtc_class
|
||||
self.agent_rpc.create_wtc_filter(context, wtc_filter)
|
||||
return wtc_filter
|
||||
|
||||
|
|
Loading…
Reference in New Issue