Skip to content

Commit

Permalink
Refactored Interface.available_tags
Browse files Browse the repository at this point in the history
- Added `Interface.tag_ranges`
- Moved `kytos/*.link_available_tags` to  kytos/core/interface.py
  • Loading branch information
Alopalao committed Aug 28, 2023
1 parent 8d154b5 commit 914c99a
Show file tree
Hide file tree
Showing 6 changed files with 348 additions and 120 deletions.
2 changes: 0 additions & 2 deletions kytos/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def parse_args(self):
'enable_entities_by_default': False,
'napps_pre_installed': [],
'authenticate_urls': [],
'vlan_pool': {},
'token_expiration_minutes': 180,
'thread_pool_max_workers': {},
'database': '',
Expand Down Expand Up @@ -206,7 +205,6 @@ def _parse_json(value):

options.logger_decorators = _parse_json(options.logger_decorators)
options.napps_pre_installed = _parse_json(options.napps_pre_installed)
options.vlan_pool = _parse_json(options.vlan_pool)
options.authenticate_urls = _parse_json(options.authenticate_urls)
thread_pool_max_workers = options.thread_pool_max_workers
options.thread_pool_max_workers = _parse_json(thread_pool_max_workers)
Expand Down
34 changes: 0 additions & 34 deletions kytos/core/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from kytos.core.events import KytosEvent
from kytos.core.exceptions import KytosAPMInitException, KytosDBInitException
from kytos.core.helpers import executors, now
from kytos.core.interface import Interface
from kytos.core.logs import LogManager
from kytos.core.napps.base import NApp
from kytos.core.napps.manager import NAppsManager
Expand Down Expand Up @@ -678,8 +677,6 @@ def get_switch_or_create(self, dpid, connection=None):
event_name += 'new'
else:
event_name += 'reconnected'

self.set_switch_options(dpid=dpid)
event = KytosEvent(name=event_name, content={'switch': switch})

if connection:
Expand All @@ -693,37 +690,6 @@ def get_switch_or_create(self, dpid, connection=None):

return switch

def set_switch_options(self, dpid):
"""Update the switch settings based on kytos.conf options.
Args:
dpid (str): dpid used to identify a switch.
"""
switch = self.switches.get(dpid)
if not switch:
return

vlan_pool = {}
vlan_pool = self.options.vlan_pool
if not vlan_pool:
return

if vlan_pool.get(dpid):
self.log.info("Loading vlan_pool configuration for dpid %s", dpid)
for intf_num, port_list in vlan_pool[dpid].items():
if not switch.interfaces.get((intf_num)):
vlan_ids = set()
for vlan_range in port_list:
(vlan_begin, vlan_end) = (vlan_range[0:2])
for vlan_id in range(vlan_begin, vlan_end):
vlan_ids.add(vlan_id)
intf_num = int(intf_num)
intf = Interface(name=intf_num, port_number=intf_num,
switch=switch)
intf.set_available_tags(vlan_ids)
switch.update_interface(intf)

def create_or_update_connection(self, connection):
"""Update a connection.
Expand Down
4 changes: 4 additions & 0 deletions kytos/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def __str__(self):
return msg


class KytosResizingAvailableTagError(Exception):
"""Exception raised when available_tag cannot be resized"""


class KytosLinkCreationError(Exception):
"""Exception thrown when the link has an empty endpoint."""

Expand Down
Loading

0 comments on commit 914c99a

Please sign in to comment.