Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ def verify_loadbalancer_structure(self, blob_data, resource):
if context['service_info']:
data = context['service_info']
if all(k in data for k in ["pools", "vips", "members",
"health_monitors",
"subnets", "ports"]):
"health_monitors"]):
return True
except AttributeError:
return False
Expand Down
13 changes: 0 additions & 13 deletions gbpservice/nfp/config_orchestrator/modules/config_orch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from gbpservice.nfp.config_orchestrator.handlers.config import (
loadbalancerv2 as lbv2)
from gbpservice.nfp.config_orchestrator.handlers.config import vpn
from gbpservice.nfp.config_orchestrator.handlers.event import (
handler as v_handler)
from gbpservice.nfp.config_orchestrator.handlers.notification import (
handler as notif_handler)

Expand Down Expand Up @@ -107,22 +105,11 @@ def rpc_init(sc, conf):
sc.register_rpc_agents([fwagent, lbagent, lbv2agent, vpnagent, rpcagent])


def events_init(sc, conf):
"""Register event with its handler."""
evs = v_handler.event_init(sc, conf)
sc.register_events(evs)


def nfp_module_init(sc, conf):
rpc_init(sc, conf)
events_init(sc, conf)


def nfp_module_post_init(sc, conf):
ev = sc.new_event(id='SERVICE_OPERATION_POLL_EVENT',
key='SERVICE_OPERATION_POLL_EVENT')
sc.post_event(ev)

uptime = time.strftime("%c")
body = {'eventdata': {'uptime': uptime,
'module': 'config_orchestrator'},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,22 @@ def event_init(sc, conf):
handler=EventsHandler(sc, conf)),
Event(id='SERVICE_CREATE_PENDING',
handler=EventsHandler(sc, conf))]
return evs

sc.register_events(evs)


def nfp_module_init(sc, conf):
event_init(sc, conf)


def nfp_module_post_init(sc, conf):
try:
ev = sc.new_event(id='SERVICE_OPERATION_POLL_EVENT',
key='SERVICE_OPERATION_POLL_EVENT')
sc.post_event(ev)
except Exception as e:
msg = ("%s" % (e))
LOG.error(msg)


"""Periodic Class to service events for visiblity."""
Expand Down
73 changes: 44 additions & 29 deletions gbpservice/nfp/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def post_event_graph(self, event):
"""
event.desc.type = nfp_event.EVENT_GRAPH
event.desc.flag = ''
event.desc.pid = os.getpid()
event.desc.pid = os.getpid()
return event

def post_event(self, event):
Expand Down Expand Up @@ -216,7 +216,8 @@ def decompress(self, event):

def pipe_recv(self, pipe):
event = pipe.recv()
if event: self.decompress(event)
if event:
self.decompress(event)
return event

def pipe_send(self, pipe, event):
Expand Down Expand Up @@ -499,34 +500,48 @@ def load_nfp_modules(conf, controller):
base_module = __import__(conf.nfp_modules_path,
globals(), locals(), ['modules'], -1)
modules_dir = base_module.__path__[0]
try:
files = os.listdir(modules_dir)
for pyfile in set([f for f in files if f.endswith(".py")]):
try:
pymodule = __import__(conf.nfp_modules_path,
globals(), locals(),
[pyfile[:-3]], -1)
pymodule = eval('pymodule.%s' % (pyfile[:-3]))
modules_dir_list = [modules_dir]
while modules_dir_list:
current_path = modules_dir_list.pop(0)
tmp_path = current_path[1:]
tmp_path = tmp_path.replace('/', '.')
index = tmp_path.index('gbpservice.nfp')
nfp_formatted_path = tmp_path[index:]
try:
files = os.listdir(current_path)
for f in files:
test_path = os.path.join(current_path, f)
if os.path.isdir(test_path):
modules_dir_list.append(test_path)
for pyfile in set([f for f in files if f.endswith(".py") and
not f.startswith('__init__')]):
try:
pymodule.nfp_module_init(controller, conf)
pymodules += [pymodule]
LOG.debug("(module - %s) - Initialized" %
(identify(pymodule)))
except AttributeError as e:
import sys
import traceback
exc_type, exc_value, exc_traceback = sys.exc_info()
print traceback.format_exception(exc_type, exc_value,
exc_traceback)
LOG.warn("(module - %s) - "
"does not implement"
"nfp_module_init()" % (identify(pymodule)))
except ImportError:
LOG.error(
"Failed to import module %s" % (pyfile))
except OSError:
LOG.error(
"Failed to read files from %s" % (modules_dir))
pymodule = __import__(nfp_formatted_path,
globals(), locals(),
[pyfile[:-3]], -1)
pymodule = eval('pymodule.%s' % (pyfile[:-3]))
try:
pymodule.nfp_module_init(controller, conf)
pymodules += [pymodule]
LOG.debug("(module - %s) - Initialized" %
(identify(pymodule)))
except AttributeError as e:
import sys
import traceback
exc_type, exc_value, exc_traceback = sys.exc_info()
print traceback.format_exception(exc_type,
exc_value,
exc_traceback)
LOG.warn("(module - %s) - "
"does not implement"
"nfp_module_init()"
% (identify(pymodule)))
except ImportError:
LOG.error(
"Failed to import module %s" % (pyfile))
except OSError:
LOG.error(
"Failed to read files from %s" % (current_path))
except ImportError:
LOG.error(
"Failed to import module from path %s" % (conf.nfp_modules_path))
Expand Down