Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Merge 3a57c37 into 8cd6c38
Browse files Browse the repository at this point in the history
  • Loading branch information
slinksoft committed Oct 16, 2020
2 parents 8cd6c38 + 3a57c37 commit cad1072
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
3 changes: 3 additions & 0 deletions kytos/core/config.py
Expand Up @@ -176,6 +176,9 @@ def _parse_options(self, argv):
napps = options.napps_pre_installed
options.napps_pre_installed = json.loads(napps)

if isinstance(options.vlan_pool, str):
options.vlan_pool = json.loads(options.vlan_pool)

return options


Expand Down
9 changes: 3 additions & 6 deletions kytos/core/controller.py
Expand Up @@ -628,12 +628,9 @@ def set_switch_options(self, dpid):
return

vlan_pool = {}
try:
vlan_pool = json.loads(self.options.vlan_pool)
if not vlan_pool:
return
except (TypeError, json.JSONDecodeError) as err:
self.log.error("Invalid vlan_pool settings: %s", err)
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)
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_core/test_switch.py
Expand Up @@ -68,15 +68,15 @@ def tearDown(self):

def test_switch_vlan_pool_default(self):
"""Test default vlan_pool value."""
self.assertEqual(self.options.vlan_pool, '{}')
self.assertEqual(self.options.vlan_pool, {})

def test_switch_vlan_pool_options(self):
"""Test switch with the example from kytos.conf."""
dpid = "00:00:00:00:00:00:00:01"
vlan_pool_json = '{"00:00:00:00:00:00:00:01": ' \
+ '{"1": [[1, 2], [5, 10]], "4": [[3, 4]]}}'
vlan_pool = {"00:00:00:00:00:00:00:01":
{"1": [[1, 2], [5, 10]], "4": [[3, 4]]}}
self.controller.switches[dpid] = self.switch
self.options.vlan_pool = vlan_pool_json
self.options.vlan_pool = vlan_pool
self.controller.get_switch_or_create(dpid, self.switch.connection)

port_id = 1
Expand Down

0 comments on commit cad1072

Please sign in to comment.