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
|
'max_rate': self.conf.WANTC.wan_max_rate
|
||||||
}
|
}
|
||||||
self.agent.set_root_queue(tc_dict)
|
self.agent.set_root_queue(tc_dict)
|
||||||
|
context = ctx.get_admin_context()
|
||||||
agent_conf = self.plugin_rpc.get_configuration_from_db(
|
agent_conf = self.plugin_rpc.get_configuration_from_db(
|
||||||
ctx.get_admin_context())
|
context)
|
||||||
class_tree = agent_conf['class_tree']
|
class_tree = agent_conf['class_tree']
|
||||||
if class_tree['id'] == 'root':
|
if class_tree['id'] == 'root':
|
||||||
self.init_child_classes(class_tree['child_list'])
|
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
|
return
|
||||||
raise exceptions.InvalidInput(error_message='Did not get root class')
|
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):
|
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 = {
|
tc_dict = {
|
||||||
'child': wtc_class['class_ext_id'],
|
'child': wtc_class['class_ext_id'],
|
||||||
|
@ -45,6 +45,10 @@ class TcPluginApi(object):
|
|||||||
cctxt = self.client.prepare()
|
cctxt = self.client.prepare()
|
||||||
return cctxt.call(context, 'get_configuration_from_db', host=self.host)
|
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):
|
class TcAgentApi(object):
|
||||||
def __init__(self, host, topic=topics.TC_AGENT):
|
def __init__(self, host, topic=topics.TC_AGENT):
|
||||||
|
@ -306,6 +306,7 @@ class WanTcDb(object):
|
|||||||
return items
|
return items
|
||||||
|
|
||||||
def _has_attribute(self, model, filters):
|
def _has_attribute(self, model, filters):
|
||||||
|
if filters:
|
||||||
for key in filters.keys():
|
for key in filters.keys():
|
||||||
if not hasattr(model, key):
|
if not hasattr(model, key):
|
||||||
return False
|
return False
|
||||||
|
@ -51,11 +51,15 @@ class PluginRpcCallback(object):
|
|||||||
|
|
||||||
def get_configuration_from_db(self, context, host):
|
def get_configuration_from_db(self, context, host):
|
||||||
conf = {
|
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
|
return conf
|
||||||
|
|
||||||
|
def get_class_by_id(self, context, id):
|
||||||
|
return self.plugin.db.get_class_by_id(context, id)
|
||||||
|
|
||||||
|
|
||||||
class WanQosPlugin(wantcfilter.WanTcFilterPluginBase,
|
class WanQosPlugin(wantcfilter.WanTcFilterPluginBase,
|
||||||
wantcdevice.WanTcDevicePluginBase,
|
wantcdevice.WanTcDevicePluginBase,
|
||||||
@ -140,8 +144,8 @@ class WanQosPlugin(wantcfilter.WanTcFilterPluginBase,
|
|||||||
wtc_filter = self.db.create_wan_tc_filter(context,
|
wtc_filter = self.db.create_wan_tc_filter(context,
|
||||||
wan_tc_filter[
|
wan_tc_filter[
|
||||||
'wan_tc_filter'])
|
'wan_tc_filter'])
|
||||||
wtc_class = self.get_wan_tc_class(context, wtc_filter['class_id'])
|
# wtc_class = self.get_wan_tc_class(context, wtc_filter['class_id'])
|
||||||
wtc_filter['class'] = wtc_class
|
# wtc_filter['class'] = wtc_class
|
||||||
self.agent_rpc.create_wtc_filter(context, wtc_filter)
|
self.agent_rpc.create_wtc_filter(context, wtc_filter)
|
||||||
return wtc_filter
|
return wtc_filter
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user