reduce direct uses of oslo.config.cfg.CONF
no functional changes are intended. Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
934fc1516f
commit
7b1d0eb9d6
@ -15,7 +15,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
from oslo.config import cfg
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from neutronclient import client as q_client
|
from neutronclient import client as q_client
|
||||||
@ -45,10 +44,7 @@ from ryu.lib.ovs import bridge
|
|||||||
from ryu.lib.quantum_ifaces import QuantumIfaces
|
from ryu.lib.quantum_ifaces import QuantumIfaces
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
def _get_auth_token(CONF, logger):
|
||||||
|
|
||||||
|
|
||||||
def _get_auth_token(logger):
|
|
||||||
httpclient = q_client.HTTPClient(
|
httpclient = q_client.HTTPClient(
|
||||||
username=CONF.neutron_admin_username,
|
username=CONF.neutron_admin_username,
|
||||||
tenant_name=CONF.neutron_admin_tenant_name,
|
tenant_name=CONF.neutron_admin_tenant_name,
|
||||||
@ -65,7 +61,7 @@ def _get_auth_token(logger):
|
|||||||
return httpclient.auth_token
|
return httpclient.auth_token
|
||||||
|
|
||||||
|
|
||||||
def _get_quantum_client(token):
|
def _get_quantum_client(CONF, token):
|
||||||
if token:
|
if token:
|
||||||
my_client = q_clientv2.Client(
|
my_client = q_clientv2.Client(
|
||||||
endpoint_url=CONF.neutron_url,
|
endpoint_url=CONF.neutron_url,
|
||||||
@ -130,14 +126,15 @@ class OVSPort(object):
|
|||||||
|
|
||||||
|
|
||||||
class OVSSwitch(object):
|
class OVSSwitch(object):
|
||||||
def __init__(self, dpid, nw, ifaces, logger):
|
def __init__(self, CONF, dpid, nw, ifaces, logger):
|
||||||
# TODO: clean up
|
# TODO: clean up
|
||||||
|
self.CONF = CONF
|
||||||
self.dpid = dpid
|
self.dpid = dpid
|
||||||
self.network_api = nw
|
self.network_api = nw
|
||||||
self.ifaces = ifaces
|
self.ifaces = ifaces
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
self._q_api = None # lazy initialization
|
self._q_api = None # lazy initialization
|
||||||
self.ctrl_addr = CONF.neutron_controller_addr
|
self.ctrl_addr = self.CONF.neutron_controller_addr
|
||||||
if not self.ctrl_addr:
|
if not self.ctrl_addr:
|
||||||
raise ValueError('option neutron_controler_addr must be speicfied')
|
raise ValueError('option neutron_controler_addr must be speicfied')
|
||||||
|
|
||||||
@ -153,9 +150,9 @@ class OVSSwitch(object):
|
|||||||
def q_api(self):
|
def q_api(self):
|
||||||
if self._q_api is None:
|
if self._q_api is None:
|
||||||
token = None
|
token = None
|
||||||
if CONF.neutron_auth_strategy:
|
if self.CONF.neutron_auth_strategy:
|
||||||
token = _get_auth_token(self.logger)
|
token = _get_auth_token(self.CONF, self.logger)
|
||||||
self._q_api = _get_quantum_client(token)
|
self._q_api = _get_quantum_client(self.CONF, token)
|
||||||
return self._q_api
|
return self._q_api
|
||||||
|
|
||||||
def set_ovsdb_addr(self, dpid, ovsdb_addr):
|
def set_ovsdb_addr(self, dpid, ovsdb_addr):
|
||||||
@ -176,7 +173,7 @@ class OVSSwitch(object):
|
|||||||
self.ovsdb_addr = ovsdb_addr
|
self.ovsdb_addr = ovsdb_addr
|
||||||
if self.ovs_bridge is None:
|
if self.ovs_bridge is None:
|
||||||
self.logger.debug('ovsdb: adding ports %s', self.ports)
|
self.logger.debug('ovsdb: adding ports %s', self.ports)
|
||||||
ovs_bridge = bridge.OVSBridge(dpid, ovsdb_addr)
|
ovs_bridge = bridge.OVSBridge(self.CONF, dpid, ovsdb_addr)
|
||||||
self.ovs_bridge = ovs_bridge
|
self.ovs_bridge = ovs_bridge
|
||||||
ovs_bridge.init()
|
ovs_bridge.init()
|
||||||
# TODO: for multi-controller
|
# TODO: for multi-controller
|
||||||
@ -352,7 +349,8 @@ class QuantumAdapter(app_manager.RyuApp):
|
|||||||
ovs_switch = self.dps.get(dpid)
|
ovs_switch = self.dps.get(dpid)
|
||||||
if not ovs_switch:
|
if not ovs_switch:
|
||||||
if create:
|
if create:
|
||||||
ovs_switch = OVSSwitch(dpid, self.nw, self.ifaces, self.logger)
|
ovs_switch = OVSSwitch(self.CONF, dpid, self.nw, self.ifaces,
|
||||||
|
self.logger)
|
||||||
self.dps[dpid] = ovs_switch
|
self.dps[dpid] = ovs_switch
|
||||||
else:
|
else:
|
||||||
self.logger.debug('ovs switch %s is already known', dpid)
|
self.logger.debug('ovs switch %s is already known', dpid)
|
||||||
|
@ -124,7 +124,7 @@ class SimpleVLAN(app_manager.RyuApp):
|
|||||||
self.logger.debug('ovs_port_update dpid %s port_no %s', dpid, port_no)
|
self.logger.debug('ovs_port_update dpid %s port_no %s', dpid, port_no)
|
||||||
# ovs-vsctl --db=ovsdb_addr --timeout=2
|
# ovs-vsctl --db=ovsdb_addr --timeout=2
|
||||||
# set Port port.name tag=tunnel_key
|
# set Port port.name tag=tunnel_key
|
||||||
ovs_br = bridge.OVSBridge(dpid, ovsdb_addr, 2)
|
ovs_br = bridge.OVSBridge(self.CONF, dpid, ovsdb_addr, 2)
|
||||||
# ofp_phy_port::name is zero-padded
|
# ofp_phy_port::name is zero-padded
|
||||||
port_name = port.name.rstrip('\x00')
|
port_name = port.name.rstrip('\x00')
|
||||||
try:
|
try:
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
# This module updates OVS tunnel ports for OpenStack integration.
|
# This module updates OVS tunnel ports for OpenStack integration.
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
import logging
|
import logging
|
||||||
import netaddr
|
import netaddr
|
||||||
|
|
||||||
@ -34,12 +34,6 @@ from ryu.lib import hub
|
|||||||
from ryu.lib.ovs import bridge as ovs_bridge
|
from ryu.lib.ovs import bridge as ovs_bridge
|
||||||
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
|
||||||
CONF.register_opts([
|
|
||||||
cfg.StrOpt('tunnel-type', default='gre',
|
|
||||||
help='tunnel type for ovs tunnel port')
|
|
||||||
])
|
|
||||||
|
|
||||||
_TUNNEL_TYPE_TO_NW_ID = {
|
_TUNNEL_TYPE_TO_NW_ID = {
|
||||||
'gre': rest_nw_id.NW_ID_VPORT_GRE,
|
'gre': rest_nw_id.NW_ID_VPORT_GRE,
|
||||||
}
|
}
|
||||||
@ -104,15 +98,15 @@ class TunnelPort(object):
|
|||||||
|
|
||||||
|
|
||||||
class TunnelDP(object):
|
class TunnelDP(object):
|
||||||
def __init__(self, dpid, ovsdb_addr, tunnel_ip, tunnel_type, conf_switch_,
|
def __init__(self, CONF, dpid, ovsdb_addr, tunnel_ip, tunnel_type,
|
||||||
network_api, tunnel_api, logger):
|
conf_switch_, network_api, tunnel_api, logger):
|
||||||
super(TunnelDP, self).__init__()
|
super(TunnelDP, self).__init__()
|
||||||
self.dpid = dpid
|
self.dpid = dpid
|
||||||
self.network_api = network_api
|
self.network_api = network_api
|
||||||
self.tunnel_api = tunnel_api
|
self.tunnel_api = tunnel_api
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
|
|
||||||
self.ovs_bridge = ovs_bridge.OVSBridge(dpid, ovsdb_addr)
|
self.ovs_bridge = ovs_bridge.OVSBridge(CONF, dpid, ovsdb_addr)
|
||||||
|
|
||||||
self.tunnel_ip = tunnel_ip
|
self.tunnel_ip = tunnel_ip
|
||||||
self.tunnel_type = tunnel_type
|
self.tunnel_type = tunnel_type
|
||||||
@ -355,7 +349,11 @@ class TunnelPortUpdater(app_manager.RyuApp):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(TunnelPortUpdater, self).__init__(args, kwargs)
|
super(TunnelPortUpdater, self).__init__(args, kwargs)
|
||||||
self.tunnel_type = CONF.tunnel_type
|
self.CONF.register_opts([
|
||||||
|
cfg.StrOpt('tunnel-type', default='gre',
|
||||||
|
help='tunnel type for ovs tunnel port')
|
||||||
|
])
|
||||||
|
self.tunnel_type = self.CONF.tunnel_type
|
||||||
self.cs = kwargs['conf_switch']
|
self.cs = kwargs['conf_switch']
|
||||||
self.nw = kwargs['network']
|
self.nw = kwargs['network']
|
||||||
self.tunnels = kwargs['tunnels']
|
self.tunnels = kwargs['tunnels']
|
||||||
@ -373,7 +371,7 @@ class TunnelPortUpdater(app_manager.RyuApp):
|
|||||||
ovs_tunnel_addr)
|
ovs_tunnel_addr)
|
||||||
if dpid not in self.tunnel_dpset:
|
if dpid not in self.tunnel_dpset:
|
||||||
# TODO:XXX changing ovsdb_addr, ovs_tunnel_addr
|
# TODO:XXX changing ovsdb_addr, ovs_tunnel_addr
|
||||||
tunnel_dp = TunnelDP(dpid, ovsdb_addr, ovs_tunnel_addr,
|
tunnel_dp = TunnelDP(self.CONF, dpid, ovsdb_addr, ovs_tunnel_addr,
|
||||||
self.tunnel_type, self.cs,
|
self.tunnel_type, self.cs,
|
||||||
self.network_api, self.tunnel_api,
|
self.network_api, self.tunnel_api,
|
||||||
self.logger)
|
self.logger)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
import webob.dec
|
import webob.dec
|
||||||
|
|
||||||
from ryu.lib import hub
|
from ryu.lib import hub
|
||||||
|
@ -28,7 +28,7 @@ hub.patch()
|
|||||||
# eg. oslo.config.cfg.
|
# eg. oslo.config.cfg.
|
||||||
import ryu.contrib
|
import ryu.contrib
|
||||||
|
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
import ryu.contrib
|
import ryu.contrib
|
||||||
|
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
|
|
||||||
import cmd
|
import cmd
|
||||||
import sys
|
import sys
|
||||||
|
@ -29,7 +29,7 @@ hub.patch()
|
|||||||
# eg. oslo.config.cfg.
|
# eg. oslo.config.cfg.
|
||||||
import ryu.contrib
|
import ryu.contrib
|
||||||
|
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from neutron.openstack.common import log as os_logging
|
from neutron.openstack.common import log as os_logging
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
import ryu.contrib
|
import ryu.contrib
|
||||||
|
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
|
|
||||||
import cmd
|
import cmd
|
||||||
import signal
|
import signal
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
import logging
|
import logging
|
||||||
from ryu.lib import hub
|
from ryu.lib import hub
|
||||||
from ryu.lib.hub import StreamServer
|
from ryu.lib.hub import StreamServer
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
global flags
|
global flags
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ slimmed down version of OVSBridge in quantum agent
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import ryu.exception as ryu_exc
|
import ryu.exception as ryu_exc
|
||||||
@ -88,7 +88,8 @@ class TunnelPort(object):
|
|||||||
|
|
||||||
|
|
||||||
class OVSBridge(object):
|
class OVSBridge(object):
|
||||||
def __init__(self, datapath_id, ovsdb_addr, timeout=None, exception=None):
|
def __init__(self, CONF, datapath_id, ovsdb_addr, timeout=None,
|
||||||
|
exception=None):
|
||||||
super(OVSBridge, self).__init__()
|
super(OVSBridge, self).__init__()
|
||||||
self.datapath_id = datapath_id
|
self.datapath_id = datapath_id
|
||||||
self.vsctl = ovs_vsctl.VSCtl(ovsdb_addr)
|
self.vsctl = ovs_vsctl.VSCtl(ovsdb_addr)
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
import inspect
|
import inspect
|
||||||
import platform
|
import platform
|
||||||
import logging
|
import logging
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
@ -26,11 +26,6 @@ from ryu.lib import hub
|
|||||||
from ryu.lib import mac
|
from ryu.lib import mac
|
||||||
|
|
||||||
VRRP_RPC_PORT = 50004 # random
|
VRRP_RPC_PORT = 50004 # random
|
||||||
CONF = cfg.CONF
|
|
||||||
|
|
||||||
CONF.register_opts([
|
|
||||||
cfg.IntOpt('vrrp-rpc-port', default=VRRP_RPC_PORT,
|
|
||||||
help='port for vrrp rpc interface')])
|
|
||||||
|
|
||||||
|
|
||||||
class RPCError(Exception):
|
class RPCError(Exception):
|
||||||
@ -49,6 +44,10 @@ class Peer(object):
|
|||||||
class RpcVRRPManager(app_manager.RyuApp):
|
class RpcVRRPManager(app_manager.RyuApp):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(RpcVRRPManager, self).__init__(*args, **kwargs)
|
super(RpcVRRPManager, self).__init__(*args, **kwargs)
|
||||||
|
self.CONF.register_opts([
|
||||||
|
cfg.IntOpt('vrrp-rpc-port', default=VRRP_RPC_PORT,
|
||||||
|
help='port for vrrp rpc interface')])
|
||||||
|
|
||||||
self._args = args
|
self._args = args
|
||||||
self._kwargs = kwargs
|
self._kwargs = kwargs
|
||||||
self._peers = []
|
self._peers = []
|
||||||
@ -90,7 +89,7 @@ class RpcVRRPManager(app_manager.RyuApp):
|
|||||||
hub.spawn(self._peer_loop_thread, peer)
|
hub.spawn(self._peer_loop_thread, peer)
|
||||||
|
|
||||||
def _peer_accept_thread(self):
|
def _peer_accept_thread(self):
|
||||||
server = hub.StreamServer(('', CONF.vrrp_rpc_port),
|
server = hub.StreamServer(('', self.CONF.vrrp_rpc_port),
|
||||||
self.peer_accept_handler)
|
self.peer_accept_handler)
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import signal
|
|||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
|
|
||||||
# import all packet libraries.
|
# import all packet libraries.
|
||||||
PKT_LIB_PATH = 'ryu.lib.packet'
|
PKT_LIB_PATH = 'ryu.lib.packet'
|
||||||
|
@ -17,7 +17,7 @@ import logging
|
|||||||
import struct
|
import struct
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
from oslo.config import cfg
|
from ryu import cfg
|
||||||
|
|
||||||
from ryu.topology import event
|
from ryu.topology import event
|
||||||
from ryu.base import app_manager
|
from ryu.base import app_manager
|
||||||
@ -453,10 +453,10 @@ class Switches(app_manager.RyuApp):
|
|||||||
self.links = LinkState() # Link class -> timestamp
|
self.links = LinkState() # Link class -> timestamp
|
||||||
self.is_active = True
|
self.is_active = True
|
||||||
|
|
||||||
self.link_discovery = CONF.observe_links
|
self.link_discovery = self.CONF.observe_links
|
||||||
if self.link_discovery:
|
if self.link_discovery:
|
||||||
self.install_flow = CONF.install_lldp_flow
|
self.install_flow = self.CONF.install_lldp_flow
|
||||||
self.explicit_drop = CONF.explicit_drop
|
self.explicit_drop = self.CONF.explicit_drop
|
||||||
self.lldp_event = hub.Event()
|
self.lldp_event = hub.Event()
|
||||||
self.link_event = hub.Event()
|
self.link_event = hub.Event()
|
||||||
self.threads.append(hub.spawn(self.lldp_loop))
|
self.threads.append(hub.spawn(self.lldp_loop))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user