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

Load graphml #274

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dist/*
/autonetkit/tests/output/
/autonetkit/output/
/autonetkit/tutorial/output/
autonetkit.egg-info/
31 changes: 23 additions & 8 deletions autonetkit/entry.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
import sys

from autonetkit.workflow.workflow import BaseWorkflow
import argparse


def main(filename):
def parse_args() -> argparse.Namespace:
"""
Standalone parser for for command arguments
"""
# create an arg parser
parser = argparse.ArgumentParser("autonetkit")
parser.add_argument("-f", type=str, dest="filename")

return parser.parse_args()

@param filename:

def main():
"""
Entry point for autonetkit
"""

args = parse_args()

workflow = BaseWorkflow()
network_model = workflow.load(filename)
network_model = workflow.load(args.filename)
workflow.run(network_model, target_platform="kathara")


if __name__ == '__main__':
filename = sys.argv[1]
main(filename)
if __name__ == "__main__":
"""
entrypoint for running directly
"""

main()
30 changes: 19 additions & 11 deletions autonetkit/load/load_graphml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@

from autonetkit.load.common import add_loopback
from autonetkit.design.utils.graph_utils import normalise_node_locations
from autonetkit.load.model import StructuredNode, StructuredPort, StructuredTopology, StructuredLink
from autonetkit.load.model import (
StructuredNode,
StructuredPort,
StructuredTopology,
StructuredLink,
)
from autonetkit.load.preprocess import process_structured_topology
from autonetkit.network_model.network_model import NetworkModel
from autonetkit.network_model.types import PortType, DeviceType


def import_from_graphml(filename: str, network_model_cls= NetworkModel) -> NetworkModel:
def import_from_graphml(filename: str, network_model_cls=NetworkModel) -> NetworkModel:
"""

@param filename:
Expand Down Expand Up @@ -39,14 +44,15 @@ def import_from_graphml(filename: str, network_model_cls= NetworkModel) -> Netwo
# create loopback zero
device_type = node_data.get("device_type").title()
get = node_data.get("x")
node = StructuredNode(type=device_type,
label=label,
x=get,
y=node_data.get("y"),
asn=node_data.get("asn"),
target=node_data.get("target"),
data = node_metadata
)
node = StructuredNode(
type=device_type,
label=label,
x=get,
y=node_data.get("y"),
asn=node_data.get("asn"),
target=node_data.get("target"),
data=node_metadata,
)

topology.nodes.append(node)
node_map[nx_node_id] = node
Expand Down Expand Up @@ -79,7 +85,9 @@ def import_from_graphml(filename: str, network_model_cls= NetworkModel) -> Netwo
topology.links.append(link)

# TODO: later match this to the YAML physical inventory etc
network_model = process_structured_topology(topology, network_model_cls)
# network_model = process_structured_topology(topology, network_model_cls)
# two arguments are not implemented yet
network_model = process_structured_topology(topology)
t_in = network_model.get_topology("input")

normalise_node_locations(t_in)
Expand Down
36 changes: 14 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,29 @@
setup(
name="autonetkit",
version="0.12.3",
description='Automatic configuration generation',
long_description='Automatic configuration generation',

description="Automatic configuration generation",
long_description="Automatic configuration generation",
entry_points={
'console_scripts': [
'autonetkit = autonetkit.console:main',
'autonetkit_webserver = autonetkit.webserver.webserver:main',
"console_scripts": [
"autonetkit = autonetkit.entry:main",
"autonetkit_webserver = autonetkit.webserver.webserver:main",
],
},

author='Simon Knight',
author="Simon Knight",
author_email="simon.knight@gmail.com",
url="http://www.autonetkit.org",

packages=find_packages(exclude=('tests', 'docs')),

packages=find_packages(exclude=("tests", "docs")),
include_package_data=True, # include data from MANIFEST.in

download_url=("http://pypi.python.org/pypi/autonetkit"),

install_requires=[
'netaddr',
'networkx',
'Jinja2',
'aiohttp',
'aiohttp_jinja2',
'requests',
'pydantic'
"netaddr",
"networkx",
"Jinja2",
"aiohttp",
"aiohttp_jinja2",
"requests",
"pydantic",
],

classifiers=[
"Programming Language :: Python",
"Development Status :: 4 - Beta",
Expand All @@ -47,5 +40,4 @@
"Topic :: System :: Software Distribution",
"Topic :: Scientific/Engineering :: Mathematics",
],

)