Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Added support to list[list[int]] input #428

Merged
merged 13 commits into from
Nov 22, 2023
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.

Deprecated
==========
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
Loading