summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Santoro <francesco.santoro@6wind.com>2016-10-31 17:07:09 +0100
committerFrancesco Santoro <francesco.santoro@6wind.com>2016-12-23 17:06:09 +0100
commitaa764eaafef41fd0ce28d3d8dbfd4283582d1671 (patch)
tree1d435284048c5c1bcf3d344efe8eaeb4a42babcb
parent5d3c079558e124a9ff721f77d7b3f6b075d289f3 (diff)
agent: use neutron compliant fastpath agent
This patch replaces the local rpc client/server approach used by mechanism drivers for fastpath information retrieval with a more 'neutron like' one. In particular we now add a fastpath agent to be launched on compute nodes togheter with ovs/lb agents. See example output here: http://paste.openstack.org/show/592187/ Signed-off-by: Francesco Santoro <francesco.santoro@6wind.com> Change-Id: Iebb1d3ea0baf490358e2861903aa083b3aa6a241
Notes
Notes (review): Code-Review+2: Vincent Jardin <vincent.jardin@6wind.com> Workflow+1: Vincent Jardin <vincent.jardin@6wind.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 23 Dec 2016 16:30:36 +0000 Reviewed-on: https://review.openstack.org/409137 Project: openstack/networking-6wind Branch: refs/heads/master
-rw-r--r--devstack/README.rst12
-rw-r--r--devstack/libs/fast-path8
-rw-r--r--devstack/plugin.sh5
-rw-r--r--networking_6wind/agent/__init__.py (renamed from networking_6wind/rpc_server/__init__.py)0
-rw-r--r--networking_6wind/agent/fp_agent.py35
-rw-r--r--networking_6wind/agent/server.py144
-rw-r--r--networking_6wind/common/config.py23
-rw-r--r--networking_6wind/common/constants.py3
-rw-r--r--networking_6wind/ml2_drivers/linuxbridge/mech_driver/mech_lb_fp.py32
-rw-r--r--networking_6wind/ml2_drivers/openvswitch/mech_driver/mech_ovs_fp.py32
-rw-r--r--networking_6wind/rpc_server/rpc_server.py105
-rw-r--r--setup.cfg2
12 files changed, 222 insertions, 179 deletions
diff --git a/devstack/README.rst b/devstack/README.rst
index 767b670..59b6a96 100644
--- a/devstack/README.rst
+++ b/devstack/README.rst
@@ -8,13 +8,21 @@ Enabling in Devstack
8 cd devstack 8 cd devstack
9 9
102. Contact support@6wind.com to get Virtual Accelerator binary evaluation. 102. Contact support@6wind.com to get Virtual Accelerator binary evaluation.
11 And copy this ones into /opt/stack/fp-delivery 11 And copy this ones into /opt/stack/fp-delivery/software
12 12
133. Add this repo as an external repository:: 133. Add this repo as an external repository::
14 14
15 > cat local.conf 15 > cat local.conf
16 [[local|localrc]] 16 [[local|localrc]]
17 enable_plugin networking-6wind http://git.openstack.org/openstack/networking-6wind 17 enable_plugin networking-6wind http://git.openstack.org/openstack/networking-6wind
18
194. Enable 6WIND neutron plugin and mechanism drivers (ovs-fp/lb-fp) in local.conf::
20
18 enable_service net-6wind 21 enable_service net-6wind
22 Q_ML2_PLUGIN_MECHANISM_DRIVERS=ovs-fp
23
245. Enable 6WIND neutron fastpath agent in local.conf::
25
26 enable_service net-6wind-agt
19 27
204. Run ``stack.sh``. 286. Run ``stack.sh``.
diff --git a/devstack/libs/fast-path b/devstack/libs/fast-path
index 04d075d..d425cbd 100644
--- a/devstack/libs/fast-path
+++ b/devstack/libs/fast-path
@@ -132,11 +132,3 @@ function start_va {
132function stop_va { 132function stop_va {
133 sudo service virtual-accelerator stop 133 sudo service virtual-accelerator stop
134} 134}
135
136function start_rpc_fp_server {
137 /usr/local/bin/rpc-fp-server &
138}
139
140function stop_rpc_fp_server {
141 killall rpc-fp-server
142}
diff --git a/devstack/plugin.sh b/devstack/plugin.sh
index 00b4e2e..cfcf397 100644
--- a/devstack/plugin.sh
+++ b/devstack/plugin.sh
@@ -25,6 +25,7 @@ XTRACE=$(set +o | grep xtrace)
25set +o xtrace 25set +o xtrace
26 26
27NET_6WIND_DIR=$DEST/networking-6wind 27NET_6WIND_DIR=$DEST/networking-6wind
28NET_6WIND_AGT_BIN_DIR=$(get_python_exec_prefix)
28NOVA_ROOTWRAP=$(get_rootwrap_location nova) 29NOVA_ROOTWRAP=$(get_rootwrap_location nova)
29 30
30function create_nova_rootwrap { 31function create_nova_rootwrap {
@@ -93,13 +94,13 @@ if is_service_enabled net-6wind; then
93 fi 94 fi
94 95
95 if is_service_enabled n-cpu; then 96 if is_service_enabled n-cpu; then
96 start_rpc_fp_server 97 run_process net-6wind-agt "$NET_6WIND_AGT_BIN_DIR/neutron-fastpath-agent"
97 fi 98 fi
98 fi 99 fi
99 100
100 if [[ "$1" == "unstack" ]]; then 101 if [[ "$1" == "unstack" ]]; then
101 if is_service_enabled n-cpu; then 102 if is_service_enabled n-cpu; then
102 stop_rpc_fp_server 103 stop_process net-6wind-agt
103 stop_va 104 stop_va
104 fi 105 fi
105 fi 106 fi
diff --git a/networking_6wind/rpc_server/__init__.py b/networking_6wind/agent/__init__.py
index e69de29..e69de29 100644
--- a/networking_6wind/rpc_server/__init__.py
+++ b/networking_6wind/agent/__init__.py
diff --git a/networking_6wind/agent/fp_agent.py b/networking_6wind/agent/fp_agent.py
new file mode 100644
index 0000000..8c2cd1d
--- /dev/null
+++ b/networking_6wind/agent/fp_agent.py
@@ -0,0 +1,35 @@
1# Copyright 2016 6WIND SA
2#
3# All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17import sys
18
19from oslo_config import cfg
20from oslo_service import service
21
22from neutron.agent.common import config
23from neutron.common import config as common_config
24from neutron import service as neutron_service
25
26
27def main():
28 common_config.init(sys.argv[1:])
29 config.setup_logging()
30 server = neutron_service.Service.create(
31 binary='neutron-fastpath-agent',
32 topic="FP_AGENT",
33 report_interval=30,
34 manager='networking_6wind.agent.server.NeutronFastPathAgent')
35 service.launch(cfg.CONF, server).wait()
diff --git a/networking_6wind/agent/server.py b/networking_6wind/agent/server.py
new file mode 100644
index 0000000..8ab86c9
--- /dev/null
+++ b/networking_6wind/agent/server.py
@@ -0,0 +1,144 @@
1# Copyright 2016 6WIND S.A.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import datetime
16import os
17
18from networking_6wind.common import constants
19
20from neutron._i18n import _LE
21from neutron.agent import rpc as agent_rpc
22from neutron.common import topics
23
24from neutron import context
25from neutron import manager
26
27from neutron_lib import constants as n_constants
28
29from oslo_config import cfg
30from oslo_log import log as logging
31from oslo_service import loopingcall
32
33from pkg_resources import parse_version as V
34
35cfg.CONF.import_group('vhostuser', 'networking_6wind.common.config')
36
37LOG = logging.getLogger(__name__)
38
39
40class NeutronFastPathAgent(manager.Manager):
41
42 def __init__(self, host, conf=None):
43 self.conf = conf or cfg.CONF
44
45 self.fp_info = {
46 'timestamp': '',
47 'product': 'unknown',
48 'product_version': 'unknown',
49 'active': False,
50 'vhostuser_socket_dir': self.conf.vhostuser.socket_dir,
51 'vhostuser_socket_prefix': self.conf.vhostuser.socket_prefix,
52 'vhostuser_socket_mode': self.conf.vhostuser.mode,
53 'supported_plugs': [],
54 }
55 self.agent_state = {
56 'binary': 'neutron-fastpath-agent',
57 'host': cfg.CONF.host,
58 'topic': n_constants.L2_AGENT_TOPIC,
59 'configurations': self.fp_info,
60 'start_flag': True,
61 'agent_type': constants.FP_AGENT_TYPE,
62 }
63 self.ctx = context.get_admin_context_without_session()
64 self._setup_rpc()
65 self.init_host()
66
67 def init_host(self):
68 self._init_fp_info()
69
70 def _update_fp_status(self, fp_info_dict):
71 timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
72 fp_info_dict['timestamp'] = timestamp
73
74 try:
75 status = os.system('pidof fp-rte')
76 if status == 0:
77 fp_info_dict['active'] = True
78 else:
79 fp_info_dict['active'] = False
80 except Exception:
81 fp_info_dict['active'] = False
82
83 def _init_fp_info(self):
84 with open('/usr/local/etc/6WIND_product') as f:
85 self.fp_info['product'] = f.read(2048).rstrip()
86 with open('/usr/local/etc/6WIND_product_version') as f:
87 self.fp_info['product_version'] = f.read(2048).rstrip()
88
89 self._update_fp_status(self.fp_info)
90
91 fp_product_version = self.fp_info['product_version']
92 if self.fp_info['product'] == 'virtual-accelerator':
93 self.fp_info['supported_plugs'] = ['ovs', 'bridge']
94 try:
95 if V(fp_product_version) >= V('1.4.0'):
96 self.fp_info['supported_plugs'].append('tap')
97 except Exception:
98 pass
99 elif self.fp_info['product'] == '6windgate':
100 self.fp_info['supported_plugs'] = ['ovs', 'bridge']
101 try:
102 if V(fp_product_version) >= V('4.13.0'):
103 self.fp_info['supported_plugs'].append('tap')
104 except Exception:
105 pass
106
107 def _report_state(self):
108 self._update_fp_status(self.fp_info)
109 try:
110 self.state_rpc.report_state(self.ctx, self.agent_state, True)
111 self.agent_state.pop('start_flag', None)
112 except AttributeError:
113 # This means the server does not support report_state
114 LOG.warning("Neutron server does not support state report. "
115 "State report for this agent will be disabled.")
116 self.heartbeat.stop()
117 return
118 except Exception:
119 LOG.exception(_LE("Failed reporting state!"))
120
121 def get_fp_info(self):
122 # check if fp is running and fill agent configurations
123 fp_info_copy = self.agent_state['configurations'].copy()
124 self._update_fp_status(fp_info_copy)
125 return fp_info_copy
126
127 def _setup_rpc(self):
128 self.topic = "FP_AGENT"
129 self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
130 # RPC network init
131 # Handle updates from service
132 self.endpoints = [self]
133 # Define the listening consumers for the agent
134 consumers = [["info", "update"]]
135 self.connection = agent_rpc.create_consumers(self.endpoints,
136 self.topic,
137 consumers,
138 start_listening=False)
139
140 report_interval = 30
141 if report_interval:
142 self.heartbeat = loopingcall.FixedIntervalLoopingCall(
143 self._report_state)
144 self.heartbeat.start(interval=report_interval)
diff --git a/networking_6wind/common/config.py b/networking_6wind/common/config.py
index b07557a..b444ee1 100644
--- a/networking_6wind/common/config.py
+++ b/networking_6wind/common/config.py
@@ -11,30 +11,18 @@
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations 12# License for the specific language governing permissions and limitations
13# under the License. 13# under the License.
14
14from oslo_config import cfg 15from oslo_config import cfg
15from oslo_config import types 16from oslo_config import types
16 17
17 18
18CONF = cfg.CONF 19CONF = cfg.CONF
19 20
20PortType = types.Integer(1, 65535)
21
22rpc_server_group = cfg.OptGroup(name='rpc_fp_server',
23 title='RPC FP server options')
24vhostuser_group = cfg.OptGroup(name='vhostuser', 21vhostuser_group = cfg.OptGroup(name='vhostuser',
25 title='Vhostuser sockets options') 22 title='Vhostuser sockets options')
26mech_driver_group = cfg.OptGroup(name='ml2_fp', 23mech_driver_group = cfg.OptGroup(name='ml2_fp',
27 title='ML2 FP plugin options') 24 title='ML2 FP plugin options')
28 25
29rpc_server_opts = [
30 cfg.StrOpt('bind_host',
31 default='0.0.0.0',
32 help='IP address to listen on.'),
33 cfg.Opt('bind_port',
34 type=PortType,
35 default=8000,
36 help='Port number to listen on.'),
37]
38 26
39vhostuser_opts = [ 27vhostuser_opts = [
40 cfg.StrOpt('socket_dir', 28 cfg.StrOpt('socket_dir',
@@ -43,13 +31,12 @@ vhostuser_opts = [
43 cfg.StrOpt('socket_prefix', 31 cfg.StrOpt('socket_prefix',
44 default='vhost-socket-', 32 default='vhost-socket-',
45 help='Prefix for socket filename'), 33 help='Prefix for socket filename'),
34 cfg.StrOpt('mode',
35 default='client',
36 help='Socket mode'),
46] 37]
47 38
48mech_driver_opts = [ 39mech_driver_opts = [
49 cfg.Opt('rpc_endpoint_port',
50 type=PortType,
51 default=8000,
52 help='Port number to where RPC endpoint is listening.'),
53 cfg.Opt('fp_info_max_age', 40 cfg.Opt('fp_info_max_age',
54 type=types.Integer(1, 300), 41 type=types.Integer(1, 300),
55 default=60, 42 default=60,
@@ -57,10 +44,8 @@ mech_driver_opts = [
57 'update'), 44 'update'),
58] 45]
59 46
60CONF.register_group(rpc_server_group)
61CONF.register_group(vhostuser_group) 47CONF.register_group(vhostuser_group)
62CONF.register_group(mech_driver_group) 48CONF.register_group(mech_driver_group)
63 49
64CONF.register_opts(rpc_server_opts, group=rpc_server_group)
65CONF.register_opts(vhostuser_opts, group=vhostuser_group) 50CONF.register_opts(vhostuser_opts, group=vhostuser_group)
66CONF.register_opts(mech_driver_opts, group=mech_driver_group) 51CONF.register_opts(mech_driver_opts, group=mech_driver_group)
diff --git a/networking_6wind/common/constants.py b/networking_6wind/common/constants.py
index a4958be..8d58100 100644
--- a/networking_6wind/common/constants.py
+++ b/networking_6wind/common/constants.py
@@ -26,3 +26,6 @@ BASE_TIMESTAMP = '1970-01-01 00:00:00'
26 26
27# linuxbridge name prefix 27# linuxbridge name prefix
28BRIDGE_PREFIX = 'brq' 28BRIDGE_PREFIX = 'brq'
29
30# fp agent type
31FP_AGENT_TYPE = '6WIND Fast Path agent'
diff --git a/networking_6wind/ml2_drivers/linuxbridge/mech_driver/mech_lb_fp.py b/networking_6wind/ml2_drivers/linuxbridge/mech_driver/mech_lb_fp.py
index b7aff6b..552848e 100644
--- a/networking_6wind/ml2_drivers/linuxbridge/mech_driver/mech_lb_fp.py
+++ b/networking_6wind/ml2_drivers/linuxbridge/mech_driver/mech_lb_fp.py
@@ -24,7 +24,6 @@ from neutron.plugins.ml2 import driver_api
24from neutron.plugins.ml2.drivers.linuxbridge.mech_driver import ( 24from neutron.plugins.ml2.drivers.linuxbridge.mech_driver import (
25 mech_linuxbridge) 25 mech_linuxbridge)
26 26
27import xmlrpclib
28 27
29LOG = log.getLogger(__name__) 28LOG = log.getLogger(__name__)
30cfg.CONF.import_group('ml2_fp', 'networking_6wind.common.config') 29cfg.CONF.import_group('ml2_fp', 'networking_6wind.common.config')
@@ -43,8 +42,6 @@ class LBFPMechanismDriver(mech_linuxbridge.LinuxbridgeMechanismDriver):
43 super(LBFPMechanismDriver, self).__init__() 42 super(LBFPMechanismDriver, self).__init__()
44 43
45 self.conf = cfg.CONF.ml2_fp 44 self.conf = cfg.CONF.ml2_fp
46 self.agent_ip = None
47 self.port = self.conf.rpc_endpoint_port
48 self.fp_info_max_age = self.conf.fp_info_max_age 45 self.fp_info_max_age = self.conf.fp_info_max_age
49 self.fp_info = { 46 self.fp_info = {
50 'timestamp': constants.BASE_TIMESTAMP, 47 'timestamp': constants.BASE_TIMESTAMP,
@@ -59,23 +56,18 @@ class LBFPMechanismDriver(mech_linuxbridge.LinuxbridgeMechanismDriver):
59 self.is_first_update = True 56 self.is_first_update = True
60 self.needs_update = True 57 self.needs_update = True
61 58
62 def _update_fp_info(self): 59 def _update_fp_info(self, context):
63 LOG.debug('Trying to retrieve fp_info from agent...') 60 LOG.debug('Trying to retrieve fp_info from agent...')
64 if self.agent_ip: 61 for fp_agent in context.host_agents(constants.FP_AGENT_TYPE):
65 try: 62 LOG.debug("Checking agent: %s", fp_agent)
66 rpc_conn = xmlrpclib.ServerProxy('http://%s:%s' % 63 self.fp_info = fp_agent['configurations']
67 (self.agent_ip, self.port)) 64 LOG.debug('Correctly retrieved fp_info from agent: %s' %
68 self.fp_info = rpc_conn.get_fp_info() 65 self.fp_info)
69 LOG.debug('Correctly retrieved fp_info from agent: %s' % 66 return
70 self.fp_info)
71 return
72 except Exception:
73 LOG.debug('Unable to retrieve fp_info from agent')
74 pass
75 67
76 self.fp_info = None 68 self.fp_info = None
77 69
78 def _get_fp_info(self): 70 def _get_fp_info(self, context):
79 if self.fp_info is None: 71 if self.fp_info is None:
80 return 72 return
81 73
@@ -90,17 +82,15 @@ class LBFPMechanismDriver(mech_linuxbridge.LinuxbridgeMechanismDriver):
90 age = tdelta.total_seconds() 82 age = tdelta.total_seconds()
91 83
92 if age >= self.fp_info_max_age: 84 if age >= self.fp_info_max_age:
93 self._update_fp_info() 85 self._update_fp_info(context)
94 86
95 def try_to_bind_segment_for_agent(self, context, segment, agent): 87 def try_to_bind_segment_for_agent(self, context, segment, agent):
96 self.agent_ip = agent['host']
97
98 if self.needs_update: 88 if self.needs_update:
99 if self.is_first_update: 89 if self.is_first_update:
100 self._update_fp_info() 90 self._update_fp_info(context)
101 self.is_first_update = False 91 self.is_first_update = False
102 else: 92 else:
103 self._get_fp_info() 93 self._get_fp_info(context)
104 94
105 if self.check_segment_for_agent(segment, agent): 95 if self.check_segment_for_agent(segment, agent):
106 context.set_binding(segment[driver_api.ID], 96 context.set_binding(segment[driver_api.ID],
diff --git a/networking_6wind/ml2_drivers/openvswitch/mech_driver/mech_ovs_fp.py b/networking_6wind/ml2_drivers/openvswitch/mech_driver/mech_ovs_fp.py
index 685a357..3daefdd 100644
--- a/networking_6wind/ml2_drivers/openvswitch/mech_driver/mech_ovs_fp.py
+++ b/networking_6wind/ml2_drivers/openvswitch/mech_driver/mech_ovs_fp.py
@@ -24,7 +24,6 @@ from neutron.plugins.ml2 import driver_api
24from neutron.plugins.ml2.drivers.openvswitch.mech_driver import ( 24from neutron.plugins.ml2.drivers.openvswitch.mech_driver import (
25 mech_openvswitch) 25 mech_openvswitch)
26 26
27import xmlrpclib
28 27
29LOG = log.getLogger(__name__) 28LOG = log.getLogger(__name__)
30cfg.CONF.import_group('ml2_fp', 'networking_6wind.common.config') 29cfg.CONF.import_group('ml2_fp', 'networking_6wind.common.config')
@@ -43,8 +42,6 @@ class OVSFPMechanismDriver(mech_openvswitch.OpenvswitchMechanismDriver):
43 super(OVSFPMechanismDriver, self).__init__() 42 super(OVSFPMechanismDriver, self).__init__()
44 43
45 self.conf = cfg.CONF.ml2_fp 44 self.conf = cfg.CONF.ml2_fp
46 self.agent_ip = None
47 self.port = self.conf.rpc_endpoint_port
48 self.fp_info_max_age = self.conf.fp_info_max_age 45 self.fp_info_max_age = self.conf.fp_info_max_age
49 self.fp_info = { 46 self.fp_info = {
50 'timestamp': constants.BASE_TIMESTAMP, 47 'timestamp': constants.BASE_TIMESTAMP,
@@ -59,23 +56,18 @@ class OVSFPMechanismDriver(mech_openvswitch.OpenvswitchMechanismDriver):
59 self.is_first_update = True 56 self.is_first_update = True
60 self.needs_update = True 57 self.needs_update = True
61 58
62 def _update_fp_info(self): 59 def _update_fp_info(self, context):
63 LOG.debug('Trying to retrieve fp_info from agent...') 60 LOG.debug('Trying to retrieve fp_info from agent...')
64 if self.agent_ip: 61 for fp_agent in context.host_agents(constants.FP_AGENT_TYPE):
65 try: 62 LOG.debug("Checking agent: %s", fp_agent)
66 rpc_conn = xmlrpclib.ServerProxy('http://%s:%s' % 63 self.fp_info = fp_agent['configurations']
67 (self.agent_ip, self.port)) 64 LOG.debug('Correctly retrieved fp_info from agent: %s' %
68 self.fp_info = rpc_conn.get_fp_info() 65 self.fp_info)
69 LOG.debug('Correctly retrieved fp_info from agent: %s' % 66 return
70 self.fp_info)
71 return
72 except Exception:
73 LOG.debug('Unable to retrieve fp_info from agent')
74 pass
75 67
76 self.fp_info = None 68 self.fp_info = None
77 69
78 def _get_fp_info(self): 70 def _get_fp_info(self, context):
79 if self.fp_info is None: 71 if self.fp_info is None:
80 return 72 return
81 73
@@ -90,17 +82,15 @@ class OVSFPMechanismDriver(mech_openvswitch.OpenvswitchMechanismDriver):
90 age = tdelta.total_seconds() 82 age = tdelta.total_seconds()
91 83
92 if age >= self.fp_info_max_age: 84 if age >= self.fp_info_max_age:
93 self._update_fp_info() 85 self._update_fp_info(context)
94 86
95 def try_to_bind_segment_for_agent(self, context, segment, agent): 87 def try_to_bind_segment_for_agent(self, context, segment, agent):
96 self.agent_ip = agent['host']
97
98 if self.needs_update: 88 if self.needs_update:
99 if self.is_first_update: 89 if self.is_first_update:
100 self._update_fp_info() 90 self._update_fp_info(context)
101 self.is_first_update = False 91 self.is_first_update = False
102 else: 92 else:
103 self._get_fp_info() 93 self._get_fp_info(context)
104 94
105 if self.check_segment_for_agent(segment, agent): 95 if self.check_segment_for_agent(segment, agent):
106 context.set_binding(segment[driver_api.ID], 96 context.set_binding(segment[driver_api.ID],
diff --git a/networking_6wind/rpc_server/rpc_server.py b/networking_6wind/rpc_server/rpc_server.py
deleted file mode 100644
index cd90c8f..0000000
--- a/networking_6wind/rpc_server/rpc_server.py
+++ /dev/null
@@ -1,105 +0,0 @@
1# Copyright 2016 6WIND S.A.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14import os
15
16import datetime
17
18from oslo_config import cfg
19
20from pkg_resources import parse_version as V
21
22import SimpleXMLRPCServer
23
24cfg.CONF.import_group('rpc_fp_server', 'networking_6wind.common.config')
25cfg.CONF.import_group('vhostuser', 'networking_6wind.common.config')
26
27
28# Restrict to a particular path.
29class RequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
30 rpc_paths = ('/RPC2',)
31
32
33class RpcFPServer(object):
34 def __init__(self):
35 self.conf_rpc = cfg.CONF.rpc_fp_server
36 self.conf_vhostuser = cfg.CONF.vhostuser
37
38 self.server = SimpleXMLRPCServer.SimpleXMLRPCServer(
39 (self.conf_rpc.bind_host,
40 self.conf_rpc.bind_port),
41 requestHandler=RequestHandler)
42 self.fp_info = {
43 'timestamp': '',
44 'product': 'unknown',
45 'product_version': 'unknown',
46 'active': False,
47 'vhostuser_socket_dir': self.conf_vhostuser.socket_dir,
48 'vhostuser_socket_prefix': self.conf_vhostuser.socket_prefix,
49 'vhostuser_socket_mode': 'client',
50 'supported_plugs': ['ovs', 'bridge'],
51 }
52
53 def run(self):
54 self.server.register_introspection_functions()
55 self.server.register_function(self.get_fp_info)
56
57 # Run the server's main loop
58 self.server.serve_forever()
59
60 def get_fp_info(self):
61 fp_info_copy = self.fp_info.copy()
62
63 timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
64 fp_info_copy['timestamp'] = timestamp
65
66 try:
67 with open('/usr/local/etc/6WIND_product') as f:
68 fp_info_copy['product'] = f.read(2048).rstrip()
69 with open('/usr/local/etc/6WIND_product_version') as f:
70 fp_info_copy['product_version'] = f.read(2048).rstrip()
71 except IOError:
72 fp_info_copy['product'] = ''
73 fp_info_copy['product_version'] = ''
74
75 try:
76 status = os.system('pidof fp-rte')
77 if status == 0:
78 fp_info_copy['active'] = True
79 else:
80 fp_info_copy['active'] = False
81 except Exception:
82 fp_info_copy['active'] = False
83
84 fp_product_version = fp_info_copy['product_version']
85 if fp_info_copy['product'] == 'virtual-accelerator':
86 try:
87 if V(fp_product_version) >= V('1.4.0'):
88 fp_info_copy['supported_plugs'].append('tap')
89 except Exception:
90 pass
91 elif fp_info_copy['product'] == '6windgate':
92 try:
93 if V(fp_product_version) >= V('4.13.0'):
94 fp_info_copy['supported_plugs'].append('tap')
95 except Exception:
96 pass
97
98 return fp_info_copy
99
100
101def main():
102 # Create server
103 rpc_fp_server = RpcFPServer()
104 # Launch server
105 rpc_fp_server.run()
diff --git a/setup.cfg b/setup.cfg
index 3ea6f91..467c54d 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -53,4 +53,4 @@ neutron.ml2.mechanism_drivers =
53 ovs-fp = networking_6wind.ml2_drivers.openvswitch.mech_driver.mech_ovs_fp:OVSFPMechanismDriver 53 ovs-fp = networking_6wind.ml2_drivers.openvswitch.mech_driver.mech_ovs_fp:OVSFPMechanismDriver
54 lb-fp = networking_6wind.ml2_drivers.linuxbridge.mech_driver.mech_lb_fp:LBFPMechanismDriver 54 lb-fp = networking_6wind.ml2_drivers.linuxbridge.mech_driver.mech_lb_fp:LBFPMechanismDriver
55console_scripts = 55console_scripts =
56 rpc-fp-server = networking_6wind.rpc_server.rpc_server:main 56 neutron-fastpath-agent = networking_6wind.agent.fp_agent:main