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

Fix node mapping and package meta data #2

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

- v0.1.0b3
- fix longest prefix node type mapping
- update package meta data
- added a note regarding configurations when changing node types
- v0.1.0b2
- fix slot calculation for nodes with interface gaps
- increase IOL / IOL-2 maximum interfaces from 16 to 32
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ After modification / adding more or different node type mappings to the exported

Disclaimer: There's certainly things out there which do not properly translate. If you encounter anything then raise an issue in the issue tracker and I'll look into it.

> [!NOTE]
> It is possible to change node types when importing. For example, you might want to change IOSv-L2 instances to IOLL2-XE instances by providing a custom import map. Note, however, that this does **NOT** change the device configuration of the imported nodes. So, if the configuration uses `GigabitEthernet0/4` in the original IOSv-L2 configuration then it is your responsibility to change this to `Ethernet1/0` for the configuration of the imported IOLL2-XE device. This can be easily done via a sed script or using a text editor and global search and replace. However, this might be more involved depending on the original/target device type.

### Usage

```
Expand Down
36 changes: 18 additions & 18 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,41 @@ dependencies = [
requires-python = ">=3.8"
readme = "README.md"
license = {text = "MIT"}
keywords = ["automation", "tools", "simulation", "virtualization", "network-programming"]

classifiers = [
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 4 - Beta",

"Environment :: Console",

# Indicate who your project is intended for
"Intended Audience :: Telecommunications Industry",
# "Topic :: Software Development :: Build Tools",
"Topic :: Internet",

# Pick your license as you wish (see also "license" above)
"License :: OSI Approved :: MIT License",

# Operating system
"Operating System :: OS Independent",

# Specify the Python versions you support here.
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]

[project.urls]
Homepage = "https://developer.cisco.com/modeling-labs"
# Documentation = "https://readthedocs.org"
Repository = "https://github.com/ciscodevnet/eve2cml"
Issues = "https://github.com/ciscodevnet/eve2cml/issues"
Changelog = "https://github.com/ciscodevnet/eve2cml/blob/master/CHANGELOG.md"

[project.scripts]
eve2cml = "eve2cml.main:main"
Expand Down
2 changes: 1 addition & 1 deletion src/eve2cml/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.0b2"
__version__ = "0.1.0b3"
21 changes: 11 additions & 10 deletions src/eve2cml/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@ def node_def(self, obj_type: str, template: str, image: str) -> CMLdef:
found = self.map.get(lookup)
if not found:
# special case for non-template images like IOL or Docker
if image and template == obj_type:
for key, cmldef in self.map.items():
if lookup.startswith(key):
return cmldef
found = self.map.get(f"{obj_type}:{template}")
if not found:
_LOGGER.warning(
"Unmapped node type %s %s %s", obj_type, template, image
)
return CMLdef(self.unknown_type, None, True)
longest_prefix = ""
longest_cmldef = None
for key, cmldef in self.map.items():
if lookup.startswith(key) and len(key) > len(longest_prefix):
longest_prefix = key
longest_cmldef = cmldef
if longest_cmldef:
_LOGGER.info("mapped node type %s", longest_cmldef)
return longest_cmldef
_LOGGER.warning("Unmapped node type %s %s %s", obj_type, template, image)
return CMLdef(self.unknown_type, None, True)
return found

def cml_iface_label(self, slot: int, node_def: str, label: str) -> str:
Expand Down
4 changes: 2 additions & 2 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ mypy-extensions==1.0.0
packaging==23.2
pluggy==1.4.0
pytest==8.1.1
pytest-cov==4.1.0
pytest-cov==5.0.0
pyyaml==6.0.1
ruff==0.3.2
ruff==0.4.1
soupsieve==2.5
tomli==2.0.1; python_version < "3.11"
types-beautifulsoup4==4.12.0.20240229
Expand Down
Loading