Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code changes to use single nfp.ini file #582

Open
wants to merge 9 commits into
base: mitaka_21st_march_base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
23 changes: 10 additions & 13 deletions devstack/lib/nfp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function namespace_create {
else
echo "New Neutron Port Created on Service management network with ip =$new_ip"
fi
new_ip_cidr+="$new_ip/24"
new_ip_cidr="$new_ip/24"
sleep 2

#get the ip address of new port eg : 11.0.0.6 and asign to namespace
Expand Down Expand Up @@ -410,19 +410,16 @@ function namespace_create {
echo "Fails reaching to $configurator_ip"
fi

sudo ip netns exec nfp-proxy /usr/bin/nfp_proxy --config-file=/etc/nfp_proxy.ini
sudo ip netns exec nfp-proxy /usr/bin/nfp_proxy --config-file=/etc/nfp.ini
}

# copy_nfp_files_and_start_process() - Setup configuration and start processes
function copy_nfp_files_and_start_process {
cd $NFPSERVICE_DIR/gbpservice/nfp
sudo cp -r bin/nfp /usr/bin/
sudo chmod +x /usr/bin/nfp
sudo rm -rf /etc/nfp_*
sudo cp -r bin/nfp_orchestrator.ini /etc/
sudo cp -r bin/nfp_proxy_agent.ini /etc/
[[ $NFP_DEVSTACK_MODE = advanced ]] && sudo cp -r ../contrib/nfp/bin/nfp_config_orch.ini /etc/
sudo cp -r bin/nfp_proxy.ini /etc/nfp_proxy.ini
sudo rm -rf /etc/nfp.ini
sudo cp -r bin/nfp.ini /etc/
sudo cp -r bin/nfp_proxy /usr/bin/

if [[ $NFP_DEVSTACK_MODE = base ]]; then
Expand All @@ -432,19 +429,19 @@ function copy_nfp_files_and_start_process {
configurator_ip=$configurator_ip
configurator_port=8070
fi
echo "Configuring proxy.ini .... with rest_server_address as $configurator_ip:$configurator_port"
sudo sed -i "s/rest_server_address=*.*/rest_server_address=$configurator_ip/g" /etc/nfp_proxy.ini
sudo sed -i "s/rest_server_port= *.*/rest_server_port=$configurator_port/g" /etc/nfp_proxy.ini
echo "Configuring nfp.ini .... with nfp_controller_ip as $configurator_ip:$configurator_port"
sudo sed -i "s/nfp_controller_ip=*.*/nfp_controller_ip=$configurator_ip/g" /etc/nfp.ini
sudo sed -i "s/nfp_controller_port= *.*/nfp_controller_port=$configurator_port/g" /etc/nfp.ini

sed -i 's#source.*#source '$DEVSTACK_DIR'/openrc demo demo#g' $NFPSERVICE_DIR/devstack/exercises/nfp_service/*.sh
source $DEVSTACK_DIR/functions-common

echo "Starting nfp_orchestrator under screen named nfp_orchestrator"
run_process nfp_orchestrator "sudo /usr/bin/nfp --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini --config-file /etc/nfp_orchestrator.ini --log-file $DEST/logs/nfp_orchestrator.log"
run_process nfp_orchestrator "sudo /usr/bin/nfp --module orchestrator --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini --config-file /etc/nfp.ini --log-file $DEST/logs/nfp_orchestrator.log"
sleep 4

echo "Starting nfp_proxy_agent under screen named nfp_proxy_agent"
run_process nfp_proxy_agent "sudo /usr/bin/nfp --config-file /etc/nfp_proxy_agent.ini --log-file $DEST/logs/nfp_proxy_agent.log"
run_process nfp_proxy_agent "sudo /usr/bin/nfp --module proxy_agent --config-file /etc/nfp.ini --log-file $DEST/logs/nfp_proxy_agent.log"
sleep 4

echo "Starting nfp_proxy inside namespace named nfp-proxy, under screen named nfp_proxy"
Expand All @@ -453,7 +450,7 @@ function copy_nfp_files_and_start_process {

if [[ $NFP_DEVSTACK_MODE = advanced ]]; then
echo "Starting nfp_config_orchestrator under screen named nfp_config_orchestrator"
run_process nfp_config_orchestrator "sudo /usr/bin/nfp --config-file /etc/nfp_config_orch.ini --config-file /etc/neutron/neutron.conf --log-file $DEST/logs/nfp_config_orchestrator.log"
run_process nfp_config_orchestrator "sudo /usr/bin/nfp --module config_orchestrator --config-file /etc/nfp.ini --config-file /etc/neutron/neutron.conf --log-file $DEST/logs/nfp_config_orchestrator.log"
else
cd pecan/api
sudo python setup.py develop
Expand Down
58 changes: 58 additions & 0 deletions gbpservice/nfp/bin/nfp.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[ORCHESTRATOR]
# Number of worker process to be spawned.
workers=1
# Path to NFP modules in . format
# NFP core framework will load all .py files
# from this path as nfp modules
nfp_modules_path=gbpservice.nfp.orchestrator.modules
# To invoke OTC Apis
# It could be rpc/REST.
# rpc - where fip access unavaiable for OTC NFP controller
# REST - where fip access is available for OTC NFP controller
backend=rpc

[PROXY_AGENT]
# Number of worker process to be spawned.
workers=1
# Path to NFP modules in . format
# NFP core framework will load all .py files
# from this path as nfp modules
nfp_modules_path=gbpservice.nfp.proxy_agent.modules
# To invoke OTC Apis
# Proxy agent will always use unix_rest backend to
# communicate with proxy component inside namespace
backend=unix_rest

[PROXY]
# Path unix server should bind to
unix_bind_path= /var/run/uds_socket
# Max number of client connections
max_connections=10
# Num of worker threads to handle connections
worker_threads=100
# Timeout for 'connect' operation
connect_max_wait_timeout=120
# Max time an idle channel is allowed to be open
idle_max_wait_timeout=120
# Min time to wait on channel to declare its idle.
idle_min_wait_timeout=0.1
#NFP controllers ip address and port
nfp_controller_ip=172.16.0.3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't hardcode. Leave it empty.

nfp_controller_port=8070
Copy link

@rajendramachani rajendramachani Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test devstack/lib/nfp change
sudo sed -i "s/nfp_controller_port= ./nfp_controller_port=$configurator_port/g" /etc/nfp.ini

the sed line above has space after = and also has .
Will it work ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this comment. I am convinced with the sed line. It should work.


[CONFIG_ORCHESTRATOR]
# Number of worker process to be spawned.
workers=1
# Path to NFP modules in . format
# NFP core framework will load all .py files
# from this path as nfp modules
nfp_modules_path=gbpservice.contrib.nfp.config_orchestrator.modules
# To invoke OTC Apis
# Proxy agent will always use unix_rest backend to
# communicate with proxy component inside namespace
backend=rpc

# Section describing params for backend=rpc
[RPC]
# Topic to send OTC request rpc on.
topic=nfp-proxy-agent-topic
12 changes: 10 additions & 2 deletions gbpservice/nfp/core/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@
default='gbpservice.nfp.core.test',
help='Path for NFP modules.'
'All modules from this path are autloaded by framework'
)
),
oslo_config.StrOpt(
'backend',
default='rpc',
help='Backend Support for communicationg with configurator.'
),
]


es_openstack_opts = [
oslo_config.StrOpt('auth_host',
default='localhost',
Expand Down Expand Up @@ -55,12 +61,14 @@
def init(args, **kwargs):
"""Initialize the configuration. """
oslo_config.CONF.register_opts(NFP_OPTS)
oslo_config.CONF.register_opts(NFP_OPTS, "orchestrator")
oslo_config.CONF.register_opts(NFP_OPTS, "proxy_agent")
oslo_config.CONF.register_opts(NFP_OPTS, "config_orchestrator")
oslo_config.CONF.register_opts(es_openstack_opts, "keystone_authtoken")
oslo_config.CONF.set_override('use_syslog', 'True')
oslo_config.CONF.set_override('syslog_log_facility', 'local1')
oslo_config.CONF(args=args, project='nfp',
version='%%(prog)s %s' % ('version'),
#version.version_info.release_string()),
**kwargs)

return oslo_config.CONF
29 changes: 27 additions & 2 deletions gbpservice/nfp/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def fork_child(self, wrap):

message = ("Forked a new child: %d"
"Parent Pipe: % s, Child Pipe: % s") % (
proc.pid, str(parent_pipe), str(child_pipe))
proc.pid, str(parent_pipe), str(child_pipe))
LOG.info(message)

try:
Expand Down Expand Up @@ -572,8 +572,33 @@ def nfp_modules_post_init(conf, nfp_modules, nfp_controller):
LOG.debug(message)


def _module(args):
try:
index = args.index('--module')
module = args[index + 1]
return module
except ValueError:
print "--module <name> missing from cmd args using default one"
return None


def main():
conf = nfp_cfg.init(sys.argv[1:])
args = sys.argv[1:]
module = _module(args)
if module:
args.remove('--module')
args.remove(module)
conf = nfp_cfg.init(args)
conf.module = module
module_opts = eval('conf.%s.keys' % (module))()
for module_opt in module_opts:
module_cfg_opt = eval("conf.%s._group._opts['%s']['opt']" % (
module, module_opt))
module_cfg_opt_value = eval("conf.%s.%s" % (module, module_opt))
conf.register_opt(module_cfg_opt)
conf.set_override(module_opt, module_cfg_opt_value)
else:
conf = nfp_cfg.init(sys.argv[1:])
nfp_common.init()
nfp_controller = NfpController(conf)
# Load all nfp modules from path configured
Expand Down
9 changes: 0 additions & 9 deletions gbpservice/nfp/lib/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@
default='', help='Topic for rpc connection'),
]

OPTS = [
cfg.StrOpt(
'backend',
default='rpc',
help='Backend Support for communicationg with configurator.'
),
]

oslo_config.CONF.register_opts(OPTS)
oslo_config.CONF.register_opts(rest_opts, "REST")
oslo_config.CONF.register_opts(rpc_opts, "RPC")
n_rpc.init(cfg.CONF)
Expand Down
87 changes: 58 additions & 29 deletions gbpservice/nfp/proxy_agent/proxy/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
import ConfigParser
from gbpservice.nfp.core import log as nfp_logging
import os
from oslo_config import cfg
from oslo_config import cfg as oslo_config
from oslo_log import log as oslo_logging
import socket
import sys
import time


oslo_logging.register_options(cfg.CONF)
oslo_logging.register_options(oslo_config.CONF)

LOG = nfp_logging.getLogger(__name__)

Expand All @@ -50,24 +50,15 @@ class ConnectionIdleTimeOut(Exception):

class Configuration(object):

def __init__(self, filee):
config = ConfigParser.ConfigParser()
config.read(filee)

self.thread_pool_size = config.getint('OPTIONS', 'thread_pool_size')
self.unix_bind_path = config.get('OPTIONS', 'unix_bind_path')
self.max_connections = config.getint('OPTIONS', 'max_connections')
self.worker_threads = config.getint('OPTIONS', 'worker_threads')
self.connect_max_wait_timeout = config.getfloat(
'OPTIONS', 'connect_max_wait_timeout')
self.idle_max_wait_timeout = config.getfloat(
'OPTIONS', 'idle_max_wait_timeout')
self.idle_min_wait_timeout = config.getfloat(
'OPTIONS', 'idle_min_wait_timeout')
self.rest_server_address = config.get(
'NFP_CONTROLLER', 'rest_server_address')
self.rest_server_port = config.getint(
'NFP_CONTROLLER', 'rest_server_port')
def __init__(self, conf):
self.unix_bind_path = conf.proxy.unix_bind_path
self.max_connections = conf.proxy.max_connections
self.worker_threads = conf.proxy.worker_threads
self.connect_max_wait_timeout = conf.proxy.connect_max_wait_timeout
self.idle_max_wait_timeout = conf.proxy.idle_max_wait_timeout
self.idle_min_wait_timeout = conf.proxy.idle_min_wait_timeout
self.rest_server_address = conf.proxy.nfp_controller_ip
self.rest_server_port = conf.proxy.nfp_controller_port


"""
Expand Down Expand Up @@ -319,15 +310,53 @@ def new_client(self, unixsocket, address):
pc = ProxyConnection(self.conf, unixsocket, tcpsocket)
ConnQ.put(pc)

PROXY_OPTS = [
oslo_config.IntOpt(
'max_connections',
default=10,
help='Max num of client connections'
),
oslo_config.IntOpt(
'worker_threads',
default=10,
help='Number of threads to be used.'
),
oslo_config.FloatOpt(
'connect_max_wait_timeout',
default=10,
help='Max time to wait for connect.'
),
oslo_config.FloatOpt(
'idle_max_wait_timeout',
default=10,
help='Max time to keep idle channel open.'
),
oslo_config.FloatOpt(
'idle_min_wait_timeout',
default=10,
help='Minimum time to wait on idle channel.'
),
oslo_config.StrOpt(
'unix_bind_path',
default='/var/run/uds_socket',
help='Path for unix server to bind.'
),
oslo_config.StrOpt(
'nfp_controller_ip',
default='172.16.0.3',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be keep the dafault value as 120.0.0.1 or remove the default value.

help='NFP controllers ip address'
),
oslo_config.IntOpt(
'nfp_controller_port',
default='8070',
help='NFP controllers port num'
)
]


def main(argv):
cfg.CONF(args=sys.argv[1:])
oslo_logging.setup(cfg.CONF, 'nfp')
parser = argparse.ArgumentParser()
parser.add_argument(
'-config-file', "--config-file", action="store", dest='config_file')
parser.add_argument(
'-log-file', "--log-file", action="store", dest='log_file')
args = parser.parse_args(sys.argv[1:])
conf = Configuration(args.config_file)
oslo_config.CONF.register_opts(PROXY_OPTS, 'proxy')
oslo_config.CONF(args=sys.argv[1:])
oslo_logging.setup(oslo_config.CONF, 'nfp')
conf = Configuration(oslo_config.CONF)
Proxy(conf).start()