-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
542 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/bash | ||
# This file is part of the NESi software. | ||
# | ||
# Copyright (c) 2020 | ||
# Original Software Design by Ilya Etingof <https://github.com/etingof>. | ||
# | ||
# Software adapted by inexio <https://github.com/inexio>. | ||
# - Janis Groß <https://github.com/unkn0wn-user> | ||
# - Philip Konrath <https://github.com/Connyko65> | ||
# - Alexander Dincher <https://github.com/Dinker1996> | ||
# - Philipp-Noah Groß <https://github.com/pngross> | ||
# | ||
# License: https://github.com/inexio/NESi/LICENSE.rst | ||
# | ||
# Example NESi REST API server bootstrapping | ||
# | ||
ENDPOINT=http://localhost:5000/nesi/v1 | ||
|
||
path="`dirname \"$0\"`" | ||
|
||
. $path/functions.sh | ||
|
||
# Create a network device (admin operation) | ||
req='{ | ||
"vendor": "Zhone", | ||
"model": "Zhone-Gerät lol", | ||
"version": "2500", | ||
"description": "(Juan-)", | ||
"hostname": "Zhone-Gerät lul", | ||
"network_protocol": "telnet", | ||
"network_address": "127.0.0.1", | ||
"network_port": 9023, | ||
"uuid": "7777", | ||
"software_version": "juan" | ||
}' | ||
|
||
box_id=$(create_resource "$req" $ENDPOINT/boxen) || exit 1 | ||
|
||
# Admin user | ||
req='{ | ||
"name": "Admin" | ||
}' | ||
|
||
admin_id=$(create_resource "$req" $ENDPOINT/boxen/$box_id/users) | ||
|
||
# Admin credentials | ||
req='{ | ||
"username": "admin", | ||
"password": "secret", | ||
"user_id": '$admin_id' | ||
}' | ||
|
||
admin_credential_id=$(create_resource "$req" $ENDPOINT/boxen/$box_id/credentials) | ||
|
||
# create a Subrack | ||
|
||
req='{ | ||
"name": "1", | ||
"description": "Juan Zhone" | ||
}' | ||
|
||
subrack_1=$(create_resource "$req" $ENDPOINT/boxen/$box_id/subracks) | ||
|
||
# create a Card | ||
|
||
req='{ | ||
"subrack_id": '$subrack_1', | ||
"product": "vdsl", | ||
"description": "Karte von Juan" | ||
}' | ||
|
||
card_1=$(create_resource "$req" $ENDPOINT/boxen/$box_id/cards) | ||
|
||
# create a Port | ||
|
||
req='{ | ||
"card_id": '$card_1', | ||
"description": "Network Port 1", | ||
"admin_state": "1", | ||
"operational_state": "1", | ||
"upstream": 4023, | ||
"downstream": 13232, | ||
"upstream_max": 8000, | ||
"downstream_max": 16000 | ||
}' | ||
|
||
port_1=$(create_resource "$req" $ENDPOINT/boxen/$box_id/ports) | ||
|
||
# create a Port | ||
|
||
req='{ | ||
"card_id": '$card_1', | ||
"description": "Network Port 2", | ||
"admin_state": "0", | ||
"operational_state": "0", | ||
"upstream": 4023, | ||
"downstream": 13232, | ||
"upstream_max": 8000, | ||
"downstream_max": 16000 | ||
}' | ||
|
||
port_2=$(create_resource "$req" $ENDPOINT/boxen/$box_id/ports) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,5 @@ class Meta: | |
|
||
_links = ma.Hyperlinks( | ||
{'self': ma.URLFor('show_subracks', box_id='<box_id>')}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Software adapted by inexio <https://github.com/inexio>. | ||
# - Janis Groß <https://github.com/unkn0wn-user> | ||
# - Philip Konrath <https://github.com/Connyko65> | ||
# - Alexander Dincher <https://github.com/Dinker1996> | ||
# - Philipp-Noah Groß <https://github.com/pngross> | ||
# | ||
# License: https://github.com/inexio/NESi/LICENSE.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Software adapted by inexio <https://github.com/inexio>. | ||
# - Janis Groß <https://github.com/unkn0wn-user> | ||
# - Philip Konrath <https://github.com/Connyko65> | ||
# - Alexander Dincher <https://github.com/Dinker1996> | ||
# - Philipp-Noah Groß <https://github.com/pngross> | ||
# | ||
# License: https://github.com/inexio/NESi/LICENSE.rst | ||
|
||
from inspect import isclass | ||
from pkgutil import iter_modules | ||
from pathlib import Path | ||
from importlib import import_module | ||
|
||
# iterate through the modules in the current package | ||
package_dir = Path(__file__).resolve().parent | ||
for (_, module_name, _) in iter_modules([package_dir]): | ||
|
||
# import the module and iterate through its attributes | ||
module = import_module(f"{__name__}.{module_name}") | ||
for attribute_name in dir(module): | ||
attribute = getattr(module, attribute_name) | ||
|
||
if isclass(attribute): | ||
# Add the class to this package's variables | ||
globals()[attribute_name] = attribute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Software adapted by inexio <https://github.com/inexio>. | ||
# - Janis Groß <https://github.com/unkn0wn-user> | ||
# - Philip Konrath <https://github.com/Connyko65> | ||
# - Alexander Dincher <https://github.com/Dinker1996> | ||
# - Philipp-Noah Groß <https://github.com/pngross> | ||
# | ||
# License: https://github.com/inexio/NESi/LICENSE.rst | ||
|
||
from nesi.softbox.api.schemas.box_schemas import * | ||
|
||
class ZhoneBoxSchema(BoxSchema): | ||
class Meta: | ||
model = Box | ||
fields = BoxSchema.Meta.fields # + ('', '', '', '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Software adapted by inexio <https://github.com/inexio>. | ||
# - Janis Groß <https://github.com/unkn0wn-user> | ||
# - Philip Konrath <https://github.com/Connyko65> | ||
# - Alexander Dincher <https://github.com/Dinker1996> | ||
# - Philipp-Noah Groß <https://github.com/pngross> | ||
# | ||
# License: https://github.com/inexio/NESi/LICENSE.rst | ||
|
||
from nesi.softbox.api.schemas.card_schemas import * | ||
|
||
class ZhoneCardSchema(CardSchema): | ||
class Meta: | ||
model = Card | ||
fields = CardSchema.Meta.fields # + ('', '', '', '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Software adapted by inexio <https://github.com/inexio>. | ||
# - Janis Groß <https://github.com/unkn0wn-user> | ||
# - Philip Konrath <https://github.com/Connyko65> | ||
# - Alexander Dincher <https://github.com/Dinker1996> | ||
# - Philipp-Noah Groß <https://github.com/pngross> | ||
# | ||
# License: https://github.com/inexio/NESi/LICENSE.rst | ||
|
||
from nesi.softbox.api.schemas.port_schemas import * | ||
|
||
class ZhonePortSchema(PortSchema): | ||
class Meta: | ||
model = Port | ||
fields = PortSchema.Meta.fields | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Software adapted by inexio <https://github.com/inexio>. | ||
# - Janis Groß <https://github.com/unkn0wn-user> | ||
# - Philip Konrath <https://github.com/Connyko65> | ||
# - Alexander Dincher <https://github.com/Dinker1996> | ||
# - Philipp-Noah Groß <https://github.com/pngross> | ||
# | ||
# License: https://github.com/inexio/NESi/LICENSE.rst | ||
|
||
from nesi.softbox.api.schemas.subrack_schemas import * | ||
|
||
class ZhoneSubrackSchema(SubrackSchema): | ||
class Meta: | ||
model = Subrack | ||
fields = SubrackSchema.Meta.fields # + ('', '', '', '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__all__ = [] | ||
__all__ = ["zhone_port", "zhone_card", "zhone_subrack"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.