Esempio n. 1
0
    def __init__(self, *args, **kwargs):
        super(MEController, self).__init__(*args, **kwargs)
        self.init_db()
        self.cpt = 0
        self.datapaths = {}
        self.bdy = []

        CONF = cfg.CONF
        CONF.register_opts([
            cfg.IntOpt('IDLE_TIMEOUT'),
            cfg.IntOpt('HARD_TIMEOUT'),
            cfg.StrOpt('MAC_GW'),
            cfg.StrOpt('MAC_MEC'),
            cfg.IntOpt('PORT_GW'),
            cfg.IntOpt('PORT_ENB'),
            cfg.IntOpt('PORT_MEC'),
            cfg.IntOpt('table_0'),
            cfg.IntOpt('table_1')
        ])

        self.IDLE_TIMEOUT = CONF.IDLE_TIMEOUT
        self.HARD_TIMEOUT = CONF.HARD_TIMEOUT
        self.MAC_GW = CONF.MAC_GW
        self.MAC_MEC = CONF.MAC_MEC
        self.PORT_GW = CONF.PORT_GW
        self.PORT_ENB = CONF.PORT_ENB
        self.PORT_MEC = CONF.PORT_MEC
        self.table_0 = CONF.table_0
        self.table_1 = CONF.table_1
Esempio n. 2
0
 def __init__(self, *args, **kwargs):
     super(SimpleSwitchIGMP13, self).__init__(*args, **kwargs)
     #self._snoop = kwargs['igmplib']
     #self.mac_to_port = {}
     #self._to_hosts = {}
     #self.serv_to_clt = {'1': '5', '2': '5', '3': '6', '4': '6'}
     #self.serv_ip_to_port = {'10.100.0.21': '5', '10.100.0.22': '6'}
     #self.tupla = {'10.100.0.21': ('None', '224.0.122.5', '10.100.0.21')}
     CONF = cfg.CONF
     CONF.register_opts([
         cfg.StrOpt('mac_to_port',
                    default='Not configured',
                    help=('A string')),
         cfg.StrOpt('to_hosts', default='Not configured',
                    help=('A string')),
         cfg.StrOpt('server_ip_to_port',
                    default='Not configured',
                    help=('A string')),
         cfg.StrOpt('server_to_client',
                    default='Not configured',
                    help=('A string'))
     ])
     #cfg.StrOpt('tupla', default='Not configured', help = ('A list'))])
     mac_to_port = CONF.mac_to_port
     to_hosts = CONF.to_hosts
     server_ip_to_port = CONF.server_ip_to_port
     server_to_client = CONF.server_to_client
     #tupla = CONF.tupla
     self.serv_to_clt = json.loads(
         server_to_client)  #Convert from str to dict
     self.mac_to_port = json.loads(mac_to_port)
     self._to_hosts = json.loads(to_hosts)
     self.serv_ip_to_port = json.loads(server_ip_to_port)
Esempio n. 3
0
    def __init__(self, *args, **kwargs):
        super(SimpleSwitchIGMP13, self).__init__(*args, **kwargs)
        #self._snoop = kwargs['igmplib']

        CONF = cfg.CONF
        CONF.register_opts([
            cfg.StrOpt('mac_to_port',
                       default='Not configured',
                       help=('A string')),
            cfg.StrOpt('to_hosts', default='Not configured',
                       help=('A string')),
            cfg.StrOpt('server_ip_to_port',
                       default='Not configured',
                       help=('A string')),
            cfg.StrOpt('server_to_client',
                       default='Not configured',
                       help=('A string'))
        ])
        mac_to_port = CONF.mac_to_port
        to_hosts = CONF.to_hosts
        server_ip_to_port = CONF.server_ip_to_port
        server_to_client = CONF.server_to_client

        self.serv_to_clt = json.loads(
            server_to_client)  #Convert from str to dict
        self.mac_to_port = json.loads(mac_to_port)
        self._to_hosts = json.loads(to_hosts)
        self.serv_ip_to_port = json.loads(server_ip_to_port)
Esempio n. 4
0
    def __init__(self, *args, **kwargs):
        super(SR_controller, self).__init__(args, kwargs)

        # These parameters can be changed in the 'normal' Ryu way, by using a config file
        # https://stackoverflow.com/questions/46415069
        args = cfg.CONF
        args.register_opts([
            cfg.StrOpt(
                "net_json",
                default=DEFAULT_NETJSON_FILE,
                help="Path to NetJSON file to parse for the initial topology"),
            cfg.StrOpt(
                "ovs_regex",
                default=r'^ovs.*',
                help=
                "Regex applied to node labels to determine which are slaves to this controller"
            ),
        ])

        self.dpset = kwargs['dpset']
        self.wsgi = kwargs['wsgi']
        self.graph = self.fetch_parameters_from_file(filename=args.net_json)
        self.dpid_to_datapath = {}
        LOG.debug("Fetched information from file: %s" % args.net_json)
        LOG.info("Controller started!")

        try:
            SR_rest_api(dpset=self.dpset, wsgi=self.wsgi)
            SR_flows_mgmt.set_dpid_to_datapath(self.dpid_to_datapath)
        except Exception as e:
            LOG.error("Error when start the NB API: %s" % e)
            raise
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     super(NetFaSwitch, self).__init__(*args, **kwargs)
     self.switch = {}
     self.vsctl = ovs_vsctl.VSCtl(
         'unix:/usr/local/var/run/openvswitch/db.sock')
     wsgi = kwargs['wsgi']
     wsgi.register(NetFaApi, {net_fa_api_instance_name: self})
     self.CONF.register_opts([
         cfg.StrOpt('my_site', default=None),
         cfg.StrOpt('fa_br_name', default=None),
         cfg.StrOpt('fa_tun_name', default=None)
     ], 'netfa')
    def __init__(self, *args, **kwargs):
        global _app
        assert _app is None

        _app = self
        super(FaSdnController, self).__init__(*args, **kwargs)
        global controllerName
        controllerName = self.get_module_name()
        self.CONF.register_opts([
            cfg.StrOpt('fa_br_name', default=None),
            cfg.StrOpt('controller_br_name', default=None)
            ], 'netfa')
Esempio n. 7
0
 def __init__(self, *args, **kwargs):
     super(SwitchIGMPv3Priorities, self).__init__(*args, **kwargs)
     CONF = cfg.CONF
     CONF.register_opts([
         cfg.StrOpt('mac_to_port',
                    default='Not configured',
                    help=('A string')),
         cfg.StrOpt('to_hosts', default='Not configured', help=('A string'))
     ])
     mac_to_port = CONF.mac_to_port
     to_hosts = CONF.to_hosts
     self.mac_to_port = json.loads(mac_to_port)
     self._to_hosts = json.loads(to_hosts)
Esempio n. 8
0
    def __init__(self, *args, **kwargs):
        super(OSIRISApp, self).__init__(*args, **kwargs) 
        self.mac_to_port = {}
        self.datapaths = {}
        self.CONF.register_opts([
            cfg.StrOpt('unis_domain', default=''),
            cfg.StrOpt('unis_server', default='http://localhost:8888'),
            cfg.StrOpt('unis_update_interval', default='5'),
            cfg.StrOpt('unis_host', default='http://localhost:8888'),
            cfg.StrOpt('ovsdb_addr', default='"tcp:127.0.0.1:6650"')
        ], group="osiris")
         
        
        self.domain_name = self.CONF.osiris.unis_domain
        unis_server = self.CONF.osiris.unis_server
        self.ovsdb_addr = self.CONF.osiris.ovsdb_addr
        self.unis_server = self.CONF.osiris.unis_server
        self.unis_host = self.CONF.osiris.unis_host
        self.interval_secs = int(self.CONF.osiris.unis_update_interval)
        self.logger.info("----- UPDATE INTERVAL IS %d -------" % self.interval_secs)
        self.logger.info("Connecting to UNIS Server at "+unis_server)
        self.logger.info("Connecting to Domain: "+self.domain_name)

        ## UnisRT debug lines
        #trace.setLevel(lace.logging.DEBUG) 
        self.logger.info("UNIS SERVER: " + str( self.CONF.osiris.unis_server))
        self.rt = Runtime([unis_server], proxy={ 'subscribe':True,'defer_update':True} , name="main_rt")

        print(self.rt.settings['proxy'])
       
        
        self.update_time_secs = calendar.timegm(time.gmtime())
        # Transient dict of LLDP-discovered Nodes, Ports and Links which are reset every cycle
        self.alive_dict = dict()
        # Persistent dict of Switch Nodes, Ports which are not reset every cycle, modified only on OF events
        self.switches_dict = dict()
        # checks for topologies, if none, create a local topology. TODO: if domain_obj has changed, push a topology that references the new guy.
       
        self.logger.info("Checked domain")
        self.create_domain()
        self.logger.info("Making Topology...")
        self.instantiate_local_topology()
        self.logger.info("Attemping to Update Host Topology")
        self.check_update_host_topology()
        self.logger.info('UPDATED HOST TOPOLOGY')
        
        self.logger.info("Created initial RT instance")
        
        
        self.nodelist = {}
Esempio n. 9
0
def get_config():
    """
    Load configuration.
    """
    import sys
    from ryu import cfg

    conf = cfg.CONF
    conf.register_opts([
        cfg.StrOpt("cfg_path", default="/etc/fabricflow/fibc.d"),
        cfg.StrOpt("api_addr", default="127.0.0.1"),
        cfg.IntOpt("api_port", default=50051),
    ])
    conf(sys.argv[1:])
    return conf
Esempio n. 10
0
    def __init__(self,*args,**kwargs):
        super(ForwardingBasic,self).__init__(args,kwargs)
        self.CONF.register_opts([
            cfg.StrOpt("topology",default = None,
                help = "Specified network topology",
                )
            ])
        self.topo = "fattree"
        self.topo = None
        self.name = "Forwarding-Basic"

        self.spanning_tree_done = True
        self.spanning_tree_links = set([])
        self.mac_to_port = {}
        self.mac_to_port.setdefault(0,{})

        self.install_port_events = True
        self.total_links = 0
        self.poll_port_stats = True
        self.link_rate_out_file = open("logs/link_rate.out.%s" %time.strftime("%Y%m%d_%H%M%S") ,'w')

        if self.topo is None:
            self.logger.info("No topology specified.")
        else:
            self.logger.info("Specified topology is %s" %self.topo)
            if self.topo == 'fattree':
                self.expected_links = 64
                self.fat_tree_k = 4
        spawn(self.send_port_req_loop)
Esempio n. 11
0
    def __init__(self, *args, **kwargs):
        super(UmbrellaLINX, self).__init__(*args, **kwargs)

        CONF = cfg.CONF
        CONF.register_opts([
            cfg.StrOpt('topo_file',
                       default='',
                       help=('The specification of the IXP')),
        ])

        self.areas = {}  # Dictionary of Graphs
        self.datapaths = {}
        self.dpid_name = {}
        self.mac_to_port = {}
        self.paths = {}
        self.ports = []
        self.hops_area = {}
        self.borders = {}
        self._topo_from_json(CONF.topo_file)
        for a in self.areas:
            g = self.areas[a]
            self.paths[a] = {}
            paths = nx.all_pairs_shortest_path(g)
            for p in paths:
                self.paths[a][p[0]] = p[1]
Esempio n. 12
0
    def __init__(self, *args, **kwargs):
        super(Ryu, self).__init__(*args, **kwargs)
        #--- register for configuration options
        self.CONF.register_opts([
            cfg.StrOpt('SciPassConfig',
                       default='/etc/SciPass/SciPass.xml',
                       help='where to find the SciPass config file'),
        ])

        self.logger.error("Starting SciPass")
        self.datapaths = {}
        self.isactive = 1
        self.statsInterval = 5
        self.balanceInterval = 15
        self.bal = None
        self.stats = {}
        self.stats_thread = hub.spawn(self._stats_loop)
        self.balance_thread = hub.spawn(self._balance_loop)

        self.ports = defaultdict(dict)
        self.prefix_bytes = defaultdict(lambda: defaultdict(int))
        self.lastStatsTime = None
        self.flowmods = {}

        api = SciPass(logger=self.logger, config_file=self.CONF.SciPassConfig)

        api.registerForwardingStateChangeHandler(
            self.changeSwitchForwardingState)

        self.api = api

        wsgi = kwargs['wsgi']
        wsgi.register(SciPassRest, {'api': self.api})
Esempio n. 13
0
    def __init__(self, *args, **kwargs):
        super(SurgeMonitor, self).__init__(*args, **kwargs)
        self.switches = {}

        CONF = cfg.CONF
        CONF.register_opts([
            cfg.FloatOpt(
                'POLLING_INTERVAL',
                default=1.0,
                help='The interval at which switch statistics will be fetched'
            ),
            cfg.IntOpt(
                'TRAFFIC_THRESHOLD',
                default=196,
                help=
                'If a switch recieves traffic higher than this, it is classified as a surge'
            ),
            cfg.StrOpt(
                'LOG_PATH',
                default='/home/mininet/surge_monitor/logs/traffic_history/',
                help='Path where log files will be stored')
        ])
        self.conf = CONF

        SwitchStats.polling_interval = CONF.POLLING_INTERVAL
        SwitchStats.surge_threshold = CONF.TRAFFIC_THRESHOLD

        self.monitor_thread = hub.spawn(
            lambda: self._monitor(CONF.POLLING_INTERVAL))
Esempio n. 14
0
def load_switch_measurement_config(configure_file="./switch_controller/switch_measurement/switch_measurement.json"):
    CONF = cfg.CONF
    CONF.register_opts([
        cfg.StrOpt('cluster_configuration', default="./conf/cluster_conf.json"),
        cfg.StrOpt('rule_template_directory', default="./switch_controller/quanta/config/te_test/"),
        cfg.IntOpt('sender', default=36),
        cfg.IntOpt('receiver', default=32),
        cfg.IntOpt('transceiver_speed', default=10),
        cfg.IntOpt('num_reconfig', default=50),
        cfg.IntOpt('reconfig_interval', default=3),
        # cfg.IntOpt('notify_port', default=10033),
        cfg.IntOpt('num_concurrent', default=20),
        cfg.StrOpt('control_output_directory', default='./switch_controller/switch_measurement/switching_record/'),
        cfg.StrOpt('control_output_filename', default='./switching_time'),
        # cfg.StrOpt('testing_switch', default='eps')
    ])
    CONF_file = json.load(open(configure_file))

    for config in CONF_file.keys():
        CONF.__setattr__(config, CONF_file[config])

    return CONF
Esempio n. 15
0
    def set_para(self):
        CONF = cfg.CONF
        CONF.register_opts([
            cfg.StrOpt('method', default="SOR", help=("agent method")),
            cfg.StrOpt('logging_stamp',
                       default="test",
                       help=("logging directory name"))
        ])

        self.method = CONF.method  # OBL, SHR, OR, LB, SOR
        self.server_IP = "192.168.0.134"
        self.server_port = 8888
        self.rule_priority = 4
        self.firewall_priority = 10
        self.max_update_count = 288 * 8 + 40
        self.max_path_num = 4

        # setting experiment setting
        self.logging_stamp = CONF.logging_stamp
        self.update_interval = 12
        # monitoring interval time (second)
        self.monitor_period = 3
        self.rate_start_index = 864
Esempio n. 16
0
 def __init__(self, *args, **kwargs):
     super(OSIRISApp, self).__init__(*args, **kwargs)
     self.mac_to_port = {}
     self.datapaths = {}
     self.CONF.register_opts([
         cfg.StrOpt('unis_domain', default=''),
         cfg.StrOpt('unis_server', default='http://localhost:8888'),
         cfg.StrOpt('unis_update_interval', default='30'),
     ],
                             group="osiris")
     self.domain_name = self.CONF.osiris.unis_domain
     unis_server = self.CONF.osiris.unis_server
     self.interval_secs = int(self.CONF.osiris.unis_update_interval)
     self.logger.info("----- UPDATE INTERVAL IS %d -------" %
                      self.interval_secs)
     self.logger.info("Connecting to UNIS Server at " + unis_server)
     self.logger.info("Connecting to Domain: " + self.domain_name)
     self.rt = Runtime(unis_server, subscribe=False, defer_update=True)
     self.create_domain()
     self.update_time_secs = calendar.timegm(time.gmtime())
     # Transient dict of LLDP-discovered Nodes, Ports and Links which are reset every cycle
     self.alive_dict = dict()
     # Persistent dict of Switch Nodes, Ports which are not reset every cycle, modified only on OF events
     self.switches_dict = dict()
Esempio n. 17
0
class DatabaseModule(app_manager.RyuApp):
    """
    Class for accessing the database json file
    """
    opts = [
        cfg.StrOpt('file',
                   default='./config/database.json',
                   help='Load database file'),
    ]

    def __init__(self, *args, **kwargs):
        super(DatabaseModule, self).__init__(*args, **kwargs)

        CONF.register_opts(self.opts, group='database')
        self.dbFilePath = CONF.database.file

        try:
            with open(self.dbFilePath, 'r') as dbFile:
                self.dbobj = json.loads(dbFile.read())['cdngine']
        except IOError as e:
            self.logger.error('Failed to open file ' + e.message)
        except ValueError as e:
            self.logger.error('Failed to parse json ' + e.message)
        except Exception as e:
            self.logger.error(
                'Unknown error occured while reading database file ' +
                e.message)
        finally:
            self.logger.info('Database file read')

        self.db = DatabaseModel(self.dbobj)

    def getData(self):
        return self.db

    def getTopology(self):
        toporeq = EventTopologyRequest()
        toporeq.dst = 'ForwardingModule'
        toporeq.sync = True
        reply = self.send_request(toporeq)  # type: EventTopologyReply
        return reply.topology

    def getClosestSeToIP(self, ip):
        closesereq = EventClosestSeRequest(ip)
        closesereq.dst = 'CDNModule'
        closesereq.sync = True
        reply = self.send_request(closesereq)  # type: EventClosestSeReply
        return reply.seip
Esempio n. 18
0
    def __init__(self, *args, **kwargs):
        super(TunnelPortUpdater, self).__init__(args, kwargs)
        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.nw = kwargs['network']
        self.tunnels = kwargs['tunnels']
        self.tunnel_dpset = TunnelDPSet()
        self.tunnel_requests = TunnelRequests()

        self.network_api = NetworkAPI(self.nw)
        self.tunnel_api = TunnelAPI(self.tunnels)
        self.network_api.update_network(
            _TUNNEL_TYPE_TO_NW_ID[self.tunnel_type])
Esempio n. 19
0
    def __init__(self, *args, **kwargs):
        super(Monitor2, self).__init__(*args, **kwargs)
        self.mac_to_port = {}
        self.package_count = 0
        self.backend_reached_count = 0

        CONF = cfg.CONF
        CONF.register_opts([
            cfg.IntOpt('front_end_testers', default=4, help=('Number of Front End Testers')),
            cfg.IntOpt('back_end_servers', default=2, help=('Number of Back End Testers')),
            cfg.StrOpt('virtual_ip', default='10.0.0.10', help=('Virtual IP address'))
        ])

        self.front_end_testers = CONF.front_end_testers
        self.back_end_servers = CONF.back_end_servers
        self.virtual_ip = CONF.virtual_ip
        self.next_out = self.front_end_testers
        self.known_routes = {}
Esempio n. 20
0
    def __init__(self, *args, **kwargs):
        super(monitor, self).__init__(*args, **kwargs)
        CONF = cfg.CONF
        print(CONF)
        CONF.register_opts([
            cfg.IntOpt('front_end_testers', default=0, help = ('Number of Front End Machines')),
            cfg.IntOpt('back_end_servers', default=0, help = ('Number of Back End Machines')),
            cfg.StrOpt('virtual_ip', default='default', help = ('Virtual IP'))])

        # Get the values from the config file
        self.num_front_end = CONF.front_end_testers
        self.num_back_end = CONF.back_end_servers
        self.virtual_ip = CONF.virtual_ip
        
        # If num_front_end == 0, assume there was no config file,
        # and set values to the dafault topology
        if (self.num_front_end == 0):
            self.num_front_end = 4
            self.num_back_end = 2
            self.virtual_ip = '10.0.0.10'
        
        # Initiate lists to hold the back end IP addresses, MAC addresses, and ports
        self.back_end_physical_addresses = []
        self.back_end_mac_addresses = []
        self.back_end_ports = []
        
        # Fill the lists with the appropriate information for the back ends
        for i in range(self.num_back_end):
            server_number = i + self.num_front_end + 1
            self.back_end_physical_addresses.append('10.0.0.' + str(server_number))
            if server_number < 16:
                self.back_end_mac_addresses.append('00:00:00:00:00:0' + hex(server_number)[2:])
            else:
                self.back_end_mac_addresses.append('00:00:00:00:00:' + hex(server_number)[2:])
            self.back_end_ports.append(server_number)
                
        # Initiate a list to keep track of Host Mac Addresses
        # that have already been assigned to back end servers
        self.front_end_macs_served = []

        # Keep track of which back end server to assign the host to
        self.next_server_address_index = 0
Esempio n. 21
0
    def __init__(self, *args, **kwargs):

        super(Intent, self).__init__(*args, **kwargs)

        conf = cfg.CONF
        conf.register_opts([
            cfg.StrOpt('empower_ip',
                       default='127.0.0.1',
                       help=('The Empower Runtime controller ip')),
            cfg.IntOpt('empower_port',
                       default=4444,
                       help=('The Empower Runtime controller port'))
        ])

        self.endpoints = {}
        self.rules = {}
        self.lvnf_info = OrderedDict()
        self.LSwitches = {}
        self.mutex = Lock()
        self._vlan_id = 1000

        self.agent = start_agent(conf.empower_ip, conf.empower_port, 2, self)
Esempio n. 22
0
    def __init__(self, *args, **kwargs):
        '''
        Init method that calls the super init method of U1071673.
        :param args: Init arguments
        :param kwargs: Init KW arguments
        '''
        super(U1071673, self).__init__(*args, **kwargs)
        self.ip_to_port = {}
        self.client_to_server = {}
        self.mac_port_from_ip = {}

        # Number of ARP and ICMP packet protocols received (received packets counter)
        self.pkts_received = 0

        # Inspired by https://stackoverflow.com/questions/17424905/passing-own-arguments-to-ryu-proxy-app
        CONF = cfg.CONF
        CONF.register_opts([
            cfg.IntOpt('front_end_testers',
                       default=4,
                       help=('Number of Front End Testers')),
            cfg.IntOpt('back_end_servers',
                       default=2,
                       help=('Number of Back End Testers')),
            cfg.StrOpt('virtual_ip',
                       default='10.0.0.10',
                       help=('Virtual IP address'))
        ])

        # Using config file variables.
        self.front_end_testers = CONF.front_end_testers
        self.back_end_servers = CONF.back_end_servers
        self.virtual_ip = CONF.virtual_ip
        self.next_out = self.front_end_testers + 1

        self.logger.info(
            "Configured for %s testers and %s servers located at %s virtual ip address.",
            self.front_end_testers, self.back_end_servers, self.virtual_ip)
        self.logger.info("First server located at port %s", self.next_out)
Esempio n. 23
0
    def set_para(self):
        CONF = cfg.CONF
        CONF.register_opts([
            cfg.StrOpt('pathPre', default="./", help=("Path prefix")),
            cfg.StrOpt('topoName', default="Cer", help=("Topology name")),
            cfg.StrOpt('scheme', default="SP", help=("Scheme name")),
            cfg.StrOpt('monitorPeriod', default="2.5",
                       help=("Monitor period")),
            cfg.StrOpt('maxUpdateCount',
                       default="20",
                       help=("Maximum update count")),
            cfg.StrOpt('logging_stamp',
                       default="test",
                       help=("Logging directory name")),
            cfg.IntOpt('failureFlag', default=0, help=("Failure flag"))
        ])

        self.path_pre = CONF.pathPre
        self.topo_name = CONF.topoName
        self.scheme = CONF.scheme
        self.failure_flag = CONF.failureFlag
        print("Topology: ", self.topo_name)
        print("Scheme: ", self.scheme)

        if self.scheme == "SMORE" or self.scheme == "LB" or self.scheme == "DATE":
            self.path_type = "racke"
        elif self.scheme == "SP":
            self.path_type = "sp"
        elif self.scheme == "OR":
            self.path_type = "or"
            self.routing_file = "%sinputs/routing/%s_or_routing.txt" % (
                self.path_pre, self.topo_name)
        else:
            self.path_type = "racke"
        self.rule_priority = 4
        self.monitor_period = float(CONF.monitorPeriod)  # 2.5
        self.scale_ratio = 20.0  # capacity scale para
        self.max_update_count = int(CONF.maxUpdateCount)  # 288*2*2 + 20 # 20
        self.logging_stamp = CONF.logging_stamp  # "Test"
Esempio n. 24
0
    'of-config-cli': 'ryu.cmd.of_config_cli',
    'rpc-cli': 'ryu.cmd.rpc_cli',
}


class RemainderOpt(cfg.MultiStrOpt):
    def _get_argparse_kwargs(self, group, **kwargs):
        kwargs = cfg.MultiStrOpt._get_argparse_kwargs(self, group, **kwargs)
        kwargs['nargs'] = argparse.REMAINDER
        return kwargs


base_conf = cfg.ConfigOpts()
base_conf.register_cli_opt(
    cfg.StrOpt('subcommand',
               positional=True,
               required=True,
               help='[%s]' % '|'.join(subcommands.keys())))
base_conf.register_cli_opt(
    RemainderOpt('subcommand_args',
                 default=[],
                 positional=True,
                 help='subcommand specific arguments'))


class SubCommand(object):
    def __init__(self, name, entry):
        self.name = name
        self.entry = entry

    def run(self, args):
        prog = '%s %s' % (
Esempio n. 25
0
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,
             prog=prog,
             project='ryu',
             version='ryu-manager {}'.format(version),
             default_config_files=['/usr/local/etc/ryu/ryu.conf'])
    except cfg.ConfigFilesNotFoundError:
Esempio n. 26
0
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
global flags
"""

from ryu import cfg

CONF = cfg.CONF

CONF.register_cli_opts([
    # app/quantum_adapter
    cfg.StrOpt('neutron-url',
               default='http://localhost:9696',
               help='URL for connecting to neutron',
               deprecated_name='quantum-url'),
    cfg.IntOpt('neutron-url-timeout',
               default=30,
               help='timeout value for connecting to neutron in seconds',
               deprecated_name='quantum-url-timeout'),
    cfg.StrOpt('neutron-admin-username',
               default='neutron',
               help='username for connecting to neutron in admin context',
               deprecated_name='quantum-admin-username'),
    cfg.StrOpt('neutron-admin-password',
               default='service_password',
               help='password for connecting to neutron in admin context',
               deprecated_name='quantum-admin-password'),
    cfg.StrOpt('neutron-admin-tenant-name',
               default='service',
Esempio n. 27
0
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

# This is a collector instance for NetFlow V5. OpenVirtualSwitch doesn't
# support NetFlow V9 for getting MPLS headers from the packets.

from ryu import cfg
from ryu.base import app_manager
from ryu.lib import hub
from ryu.lib.xflow import netflow

opts = [
    cfg.StrOpt('address',
               default='127.0.0.1',
               help='NetFlow Collector bind address'),
    cfg.IntOpt('port', default=3000, help='NetFlow Collector port'),
    cfg.IntOpt('max_udp_msg_size',
               default=1472,
               help='Maximum size of UDP messages')
]

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


class NetFlow(app_manager.RyuApp):
    def __init__(self, *args, **kwargs):
        super(NetFlow, self).__init__(*args, **kwargs)
        self._address = self.CONF.plow.address
        self._port = self.CONF.plow.port
Esempio n. 28
0
from ryu.ofproto import ofproto_common
from ryu.ofproto import ofproto_parser
from ryu.ofproto import ofproto_protocol
from ryu.ofproto import ofproto_v1_0
from ryu.ofproto import nx_match

from ryu.controller import handler
from ryu.controller import ofp_event

from ryu.lib.dpid import dpid_to_str

LOG = logging.getLogger('ryu.controller.controller')

CONF = cfg.CONF
CONF.register_cli_opts([
    cfg.StrOpt('ofp-listen-host', default='', help='openflow listen host'),
    cfg.IntOpt('ofp-tcp-listen-port',
               default=ofproto_common.OFP_TCP_PORT,
               help='openflow tcp listen port'),
    cfg.IntOpt('ofp-ssl-listen-port',
               default=ofproto_common.OFP_SSL_PORT,
               help='openflow ssl listen 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.FloatOpt(
        'socket-timeout',
        default=5.0,
        help='Time, in seconds, to await completion of socket operations.')
])
Esempio n. 29
0
from ryu.controller.handler import MAIN_DISPATCHER, CONFIG_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_0, ofproto_v1_3
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.lib.packet import ipv4
from ryu.lib.packet import ether_types
from ryu.lib.packet import arp
from ryu.lib.ofp_pktinfilter import packet_in_filter, RequiredTypeFilter
from .conf_mgr import SDNIPConfigManager
from .fwd import Fwd

CONF = cfg.CONF
CONF.register_cli_opts([
    cfg.StrOpt('static-arp-table',
               default=None,
               help='location of SDN-IP config file')
])
FAKE_IP = '0.0.0.0'
FAKE_MAC = 'c0:ff:ee:c0:ff:ee'

# integrate with DragonKnight CLI
with_dk = False
try:
    from dragon_knight import dk_plugin
    with_dk = True
except ImportError as e:
    pass


class ArpProxy(app_manager.RyuApp):
Esempio n. 30
0
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
        try:
            self.connect()
        except ConnectionError as e:
            print('Exception when connecting to peer "%s": %s' % (name, e))