def __init__(self, *args, **kwargs):
        super(LearningSwitch13, self).__init__(*args, **kwargs)
        CONF = cfg.CONF

        # Import blacklist from configuration file
        CONF.register_opts([
            cfg.ListOpt('blacklist', default='',
                        help=('A list of IPs to block'))
        ])
        self.blacklist = set(CONF.blacklist)
        print('Blacklist IPs: {}'.format(CONF.blacklist))

        # Initialize mac address table
        self.mac_to_port = {}
Ejemplo n.º 2
0
from ryu import cfg

import cmd
import sys
import lxml.etree as ET

from ryu.lib import of_config
from ryu.lib.of_config import capable_switch
from ncclient.operations.rpc import RPCError
import ryu.lib.of_config.classes as ofc


CONF = cfg.CONF
CONF.register_cli_opts([
    cfg.ListOpt('peers', default=[], help='list of peers')
])


class Peer(capable_switch.OFCapableSwitch):
    def __init__(self, name, host, port, username, password):
        self._name = name
        super(Peer, self).__init__(
            host=host, port=port, username=username, password=password,
            unknown_host_cb=lambda host, fingeprint: True)


peers = {}


def add_peer(name, host, port, username, password):
Ejemplo n.º 3
0
from ryu import flags
from ryu import version
from ryu.lib import hub
from ryu.app import wsgi
from ryu.base.app_manager import AppManager
from ryu.controller import controller
from ryu.topology import switches

LOG = logging.getLogger('dragon_knight')
CONF = cfg.CONF

CONF.set_override('observe_links', True)

CONF.register_cli_opts([
    cfg.ListOpt('app-lists', default=[],
                help='application module name to run'),
    cfg.MultiStrOpt('app',
                    positional=True,
                    default=[],
                    help='application module name to run'),
    cfg.StrOpt('pid-file', default=None, help='pid file name'),
    cfg.BoolOpt('enable-debugger',
                default=False,
                help='don\'t overwrite Python standard threading library'
                '(use only for debugging)')
])


def main(args=None, prog=None):
    try:
        CONF(args=args,
Ejemplo n.º 4
0
from __future__ import print_function

import ast
import cmd
import signal
import socket
import sys
import termios

from ryu import cfg
from ryu.lib import rpc

CONF = cfg.CONF
CONF.register_cli_opts([
    cfg.ListOpt('peers',
                default=[],
                help='List of peers, separated by commas. '
                '(e.g., "hoge=localhost:9998,fuga=localhost:9999")'),
    cfg.StrOpt('command',
               short='c',
               default=None,
               help='Command to be executed as single command. '
               'The default is None and opens interactive console.'),
])


class Peer(object):
    def __init__(self, name, addr):
        self._name = name
        self._addr = addr
        self.socket = None
        self.client = None
Ejemplo n.º 5
0
               default=DEFAULT_OFP_HOST,
               help='openflow listen host (default %s)' % DEFAULT_OFP_HOST),
    cfg.IntOpt('ofp-tcp-listen-port',
               default=None,
               help='openflow tcp listen port '
               '(default: %d)' % ofproto_common.OFP_TCP_PORT),
    cfg.IntOpt('ofp-ssl-listen-port',
               default=None,
               help='openflow ssl listen port '
               '(default: %d)' % ofproto_common.OFP_SSL_PORT),
    cfg.StrOpt('ctl-privkey', default=None, help='controller private key'),
    cfg.StrOpt('ctl-cert', default=None, help='controller certificate'),
    cfg.StrOpt('ca-certs', default=None, help='CA certificates'),
    cfg.ListOpt('ofp-switch-address-list',
                item_type=str,
                default=[],
                help='list of IP address and port pairs (default empty). '
                'e.g., "127.0.0.1:6653,[::1]:6653"'),
    cfg.IntOpt('ofp-switch-connect-interval',
               default=DEFAULT_OFP_SW_CON_INTERVAL,
               help='interval in seconds to connect to switches '
               '(default %d)' % DEFAULT_OFP_SW_CON_INTERVAL),
])
CONF.register_opts([
    cfg.FloatOpt(
        'socket-timeout',
        default=5.0,
        help='Time, in seconds, to await completion of socket operations.'),
    cfg.FloatOpt(
        'echo-request-interval',
        default=15.0,
Ejemplo n.º 6
0
from ryu.services.protocols.ovsdb import event
from ryu.controller import handler

opts = (cfg.StrOpt('address', default='0.0.0.0', help='OVSDB address'),
        cfg.IntOpt('port', default=6640, help='OVSDB port'),
        cfg.IntOpt('probe-interval', help='OVSDB reconnect probe interval'),
        cfg.IntOpt('min-backoff',
                   help=('OVSDB reconnect minimum milliseconds between '
                         'connection attemps')),
        cfg.IntOpt('max-backoff',
                   help=('OVSDB reconnect maximum milliseconds between '
                         'connection attemps')),
        cfg.StrOpt('mngr-privkey', default=None, help='manager private key'),
        cfg.StrOpt('mngr-cert', default=None, help='manager certificate'),
        cfg.ListOpt('whitelist',
                    default=[],
                    help='Whitelist of address to allow to connect'),
        cfg.ListOpt('schema-tables',
                    default=[],
                    help='Tables in the OVSDB schema to configure'),
        cfg.ListOpt('schema-exclude-columns',
                    default=[],
                    help='Table columns in the OVSDB schema to filter out.  '
                    'Values should be in the format: <table>.<column>.'
                    'Ex: Bridge.netflow,Interface.statistics'))

cfg.CONF.register_opts(opts, 'ovsdb')


class OVSDB(app_manager.RyuApp):
    _EVENTS = [
Ejemplo n.º 7
0
import ssl
import socket

from ryu import cfg
from ryu.base import app_manager
from ryu.lib import hub
from ryu.services.protocols.ovsdb import client
from ryu.services.protocols.ovsdb import event
from ryu.controller import handler

opts = (cfg.StrOpt('address', default='0.0.0.0', help='OVSDB address'),
        cfg.IntOpt('port', default=6640, help='OVSDB port'),
        cfg.StrOpt('mngr-privkey', default=None, help='manager private key'),
        cfg.StrOpt('mngr-cert', default=None, help='manager certificate'),
        cfg.ListOpt('whitelist',
                    default=[],
                    help='Whitelist of address to allow to connect'))

cfg.CONF.register_opts(opts, 'ovsdb')


class OVSDB(app_manager.RyuApp):
    _EVENTS = [
        event.EventNewOVSDBConnection, event.EventModifyRequest,
        event.EventReadRequest
    ]

    def __init__(self, *args, **kwargs):
        super(OVSDB, self).__init__(*args, **kwargs)
        self._address = self.CONF.ovsdb.address
        self._port = self.CONF.ovsdb.port
Ejemplo n.º 8
0
from ryu import log
log.early_init_log(logging.DEBUG)

from ryu import flags
from ryu import version
from ryu.app import wsgi
from ryu.base.app_manager import AppManager
from ryu.controller import controller
from ryu.topology import switches

#"ryu.app.simple_switch_13_rest"
#"ryu.app.domain_controller"
CONF = cfg.CONF
CONF.register_cli_opts([
    cfg.ListOpt('app-lists',
                default=["ryu.app.domain_controller"],
                help='application module name to run'),
    cfg.MultiStrOpt('app',
                    positional=True,
                    default=[],
                    help='application module name to run'),
    cfg.StrOpt('pid-file', default=None, help='pid file name'),
    cfg.BoolOpt('enable-debugger',
                default=False,
                help='don\'t overwrite Python standard threading library'
                '(use only for debugging)'),
    cfg.IntOpt("domain_id", default=1, help="id of domain controller"),
    cfg.StrOpt("domain_wsgi_ip",
               default="10.108.90.202",
               help="port no of domain\'s wsgi"),
    cfg.IntOpt("domain_port",
Ejemplo n.º 9
0
from ryu import flags
from ryu import version
from ryu.app import wsgi
from ryu.base.app_manager import AppManager
from ryu.controller import controller
from ryu.topology import switches

#ryu.app.super_controller
#ryu.services.protocols.bgp.application
CONF = cfg.CONF
CONF.register_cli_opts([
    #  cfg.ListOpt('app-lists', default=["ryu.app.super_controller"],
    #            help='application module name to run'),
    cfg.ListOpt('app-lists',
                default=["ryu.app.gui_topology.gui_topology"],
                help='application module name to run'),
    cfg.MultiStrOpt('app',
                    positional=True,
                    default=[],
                    help='application module name to run'),
    cfg.StrOpt('pid-file', default=None, help='pid file name'),
    cfg.BoolOpt('enable-debugger',
                default=False,
                help='don\'t overwrite Python standard threading library'
                '(use only for debugging)'),
    # cfg.IntOpt("domain_id", default=2,
    #            help="id of domain controller"),
    cfg.StrOpt("super_wsgi_ip",
               default="10.108.90.202",
               help="port no of super\'s wsgi"),