Skip to content

Commit

Permalink
Merge pull request #428 from kytos-ng/epic/vlan_range
Browse files Browse the repository at this point in the history
feature: Added support to `list[list[int]]` input
  • Loading branch information
viniarck authored Nov 22, 2023
2 parents 83bc371 + e722f77 commit b4cfefc
Show file tree
Hide file tree
Showing 7 changed files with 703 additions and 256 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ Added
=====
- Added ``Interface.tag_ranges`` as ``dict[str, list[list[int]]]`` as replacement for ``vlan_pool`` settings.
- Added ``kytos/core.interface_tags`` event publication to notify any modification of ``Interface.tag_ranges`` or ``Interface.available_tags``.
- Added ``TAGRange`` class which is used when a ``UNI`` has a tag as a list of ranges.
- Added ``KytosTagError`` exception that cover other exceptions ``KytosTagtypeNotSupported``, ``KytosInvalidTagRanges``, ``KytosSetTagRangeError``, ``KytosTagsNotInTagRanges`` and ``KytosTagsAreNotAvailable`` all of which are related to TAGs.

Changed
=======
- Parametrized default ``maxTimeMS`` when creating an index via ``Mongo.boostrap_index`` via environment variable ``MONGO_IDX_TIMEOUTMS=30000``. The retries parameters reuse the same environment variables ``MONGO_AUTO_RETRY_STOP_AFTER_ATTEMPT=3``, ``MONGO_AUTO_RETRY_WAIT_RANDOM_MIN=0.1``, ``MONGO_AUTO_RETRY_WAIT_RANDOM_MAX=1`` that NApps controllers have been using.
- ``kytosd`` process will exit if a NApp raises an exception during its ``setup()`` execution.
- Change format for ``Interface.available_tags`` to ``dict[str, list[list[int]]]``. Storing ``tag_types`` as keys and a list of ranges for ``available_tags`` as values.
- ``Interface.use_tags`` and ``Interface.make_tags_available`` are compatible with list of ranges.

Fixed
=====
Expand Down
46 changes: 41 additions & 5 deletions kytos/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,52 @@ def __str__(self):
return msg


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


class KytosTagError(Exception):
"""Exception to catch an error when setting tag type or value."""
def __init__(self, msg: str) -> None:
self.msg = msg

def __str__(self) -> str:
return f"{self.msg}"

def __repr__(self) -> str:
return f"{self.msg}"


class KytosTagtypeNotSupported(KytosTagError):
"""Exception thrown when a not supported tag type is not supported"""
def __init__(self, msg: str) -> None:
super().__init__(f"KytosTagtypeNotSupported, {msg}")


class KytosInvalidTagRanges(KytosTagError):
"""Exception thrown when a list of ranges is invalid."""
def __init__(self, msg: str) -> None:
super().__init__(f"KytosInvalidTagRanges, {msg}")


class KytosSetTagRangeError(KytosTagError):
"""Exception raised when available_tag cannot be resized"""
def __init__(self, msg: str) -> None:
super().__init__(f"KytosSetTagRangeError, {msg}")


class KytosLinkCreationError(Exception):
"""Exception thrown when the link has an empty endpoint."""
class KytosTagsNotInTagRanges(KytosTagError):
"""Exception thrown when a tag is outside of tag ranges"""
def __init__(self, conflict: list[list[int]], intf_id: str) -> None:
msg = f"The tags {conflict} are outside tag_ranges in {intf_id}"
super().__init__(f"KytosSetTagRangeError, {msg}")


class KytosTagtypeNotSupported(Exception):
"""Exception thronw when a not supported tag type is not supported"""
class KytosTagsAreNotAvailable(KytosTagError):
"""Exception thrown when a tag is not available."""
def __init__(self, conflict: list[list[int]], intf_id: str) -> None:
msg = f"The tags {conflict} are not available in {intf_id}"
super().__init__(f"KytosSetTagRangeError, {msg}")


# Exceptions related to NApps
Expand Down
Loading

0 comments on commit b4cfefc

Please sign in to comment.