<commit_before># Copyright (c) 2015 OpenStack Foundation.
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    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.


import collections
import struct
import threading

from ryu.base import app_manager
from ryu.controller.handler import CONFIG_DISPATCHER
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.controller import ofp_event
from ryu.ofproto import ether
from ryu.ofproto.ether import ETH_TYPE_8021Q
from ryu.ofproto import ofproto_v1_3

from ryu.lib.packet import ethernet
from ryu.lib.packet import packet

from ryu.lib.mac import haddr_to_bin
from ryu.lib.packet import icmp
from ryu.lib.packet import ipv4
from ryu.lib.packet import tcp
from ryu.lib.packet import udp
from ryu.lib.packet import vlan

from ryu.lib import addrconv

from neutron import context
from neutron import manager

from neutron.common import constants as const
from neutron.i18n import _LE, _LI
from neutron.plugins.common import constants as service_constants
from oslo_log import log

LOG = log.getLogger(__name__)

ETHERNET = ethernet.ethernet.__name__
VLAN = vlan.vlan.__name__
IPV4 = ipv4.ipv4.__name__
ICMP = icmp.icmp.__name__
TCP = tcp.tcp.__name__
UDP = udp.udp.__name__

VLANID_NONE = 0
VLANID_MIN = 2
VLANID_MAX = 4094
COOKIE_SHIFT_VLANID = 32
UINT16_MAX = 0xffff
UINT32_MAX = 0xffffffff
UINT64_MAX = 0xffffffffffffffff
OFPFW_NW_PROTO = 1 << 5

HIGH_PRIOREITY_FLOW = 1000
MEDIUM_PRIOREITY_FLOW = 100
NORMAL_PRIOREITY_FLOW = 10
LOW_PRIOREITY_FLOW = 1
LOWEST_PRIOREITY_FLOW = 0


# A class to represent a  forwarding Elemnt Switch local state
class AgentDatapath(object):

    def __init__(self):
        self.local_vlan_mapping = {}
        self.local_ports = None
        self.datapath = 0
        self.patch_port_num = 0

        # Dictionary used to hold port information received from OVS
        # each port data structure has a link to an entry in this dictionary
        # in 'switch_port_desc'
        self.switch_port_desc_dict = {}


# A class to represent tenat toplogie
class TenantTopo(object):

    def __init__(self):
        self.nodes = set()
        self.edges = collections.defaultdict(list)
        self.routers = {}
        self.distances = {}
        self.mac_to_port_data = collections.defaultdict(set)
        self.subnets = collections.defaultdict(set)
        self.tenant_id = None
        #self.segmentation_id = None

    def add_router(self, router):
        self.routers[router.id] = router<commit_msg>openflow app: Change comments to docstrings<commit_after># Copyright (c) 2015 OpenStack Foundation.
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    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.


import collections
import struct
import threading

from ryu.base import app_manager
from ryu.controller.handler import CONFIG_DISPATCHER
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.controller import ofp_event
from ryu.ofproto import ether
from ryu.ofproto.ether import ETH_TYPE_8021Q
from ryu.ofproto import ofproto_v1_3

from ryu.lib.packet import ethernet
from ryu.lib.packet import packet

from ryu.lib.mac import haddr_to_bin
from ryu.lib.packet import icmp
from ryu.lib.packet import ipv4
from ryu.lib.packet import tcp
from ryu.lib.packet import udp
from ryu.lib.packet import vlan

from ryu.lib import addrconv

from neutron import context
from neutron import manager

from neutron.common import constants as const
from neutron.i18n import _LE, _LI
from neutron.plugins.common import constants as service_constants
from oslo_log import log

LOG = log.getLogger(__name__)

ETHERNET = ethernet.ethernet.__name__
VLAN = vlan.vlan.__name__
IPV4 = ipv4.ipv4.__name__
ICMP = icmp.icmp.__name__
TCP = tcp.tcp.__name__
UDP = udp.udp.__name__

VLANID_NONE = 0
VLANID_MIN = 2
VLANID_MAX = 4094
COOKIE_SHIFT_VLANID = 32
UINT16_MAX = 0xffff
UINT32_MAX = 0xffffffff
UINT64_MAX = 0xffffffffffffffff
OFPFW_NW_PROTO = 1 << 5

HIGH_PRIOREITY_FLOW = 1000
MEDIUM_PRIOREITY_FLOW = 100
NORMAL_PRIOREITY_FLOW = 10
LOW_PRIOREITY_FLOW = 1
LOWEST_PRIOREITY_FLOW = 0


class AgentDatapath(object):
    """Represents a forwarding element switch local state"""

    def __init__(self):
        self.local_vlan_mapping = {}
        self.local_ports = None
        self.datapath = 0
        self.patch_port_num = 0

        # Dictionary used to hold port information received from OVS
        # each port data structure has a link to an entry in this dictionary
        # in 'switch_port_desc'
        self.switch_port_desc_dict = {}


class TenantTopo(object):
    """Represents a tenant topology"""

    def __init__(self):
        self.nodes = set()
        self.edges = collections.defaultdict(list)
        self.routers = {}
        self.distances = {}
        self.mac_to_port_data = collections.defaultdict(set)
        self.subnets = collections.defaultdict(set)
        self.tenant_id = None
        #self.segmentation_id = None

    def add_router(self, router):
        self.routers[router.id] = router
{'fraction_non_alphanumeric': 0.06438333607772107, 'fraction_numerical': 0.017124979417092047, 'mean_word_length': 3.7158385093167703, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '659676', 'n_tokens_mistral': 1992, 'n_tokens_neox': 1885, 'n_words': 611}