Skip to content

Commit

Permalink
Merge pull request #8 from inexio/dev_pbn
Browse files Browse the repository at this point in the history
Dev pbn
  • Loading branch information
Dinker1996 authored Feb 24, 2021
2 parents 2056afb + 2ba8d67 commit 37284ce
Show file tree
Hide file tree
Showing 74 changed files with 1,815 additions and 33 deletions.
64 changes: 64 additions & 0 deletions nesi/bootup/conf/bootstraps/create-vendors-and-models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,68 @@ req='{
"model_id": '$model_id'
}'

version_id=$(create_resource "$req" $ENDPOINT/versions)

# ----------------------------------------------------------------------- PBN ----------------------------------------------------------------------- #

req='{
"name": "PBN"
}'

vendor_id=$(create_resource "$req" $ENDPOINT/vendors)

req='{
"name": "AOCM3608-2x10GE",
"vendor_id": '$vendor_id'
}'

model_id=$(create_resource "$req" $ENDPOINT/models)

req='{
"name": "EPON OLT",
"model_id": '$model_id'
}'

version_id=$(create_resource "$req" $ENDPOINT/versions)

req='{
"name": "AOCM3956",
"vendor_id": '$vendor_id'
}'

model_id=$(create_resource "$req" $ENDPOINT/models)

req='{
"name": "Ethernet Switch",
"model_id": '$model_id'
}'

version_id=$(create_resource "$req" $ENDPOINT/versions)

req='{
"name": "AOCM3924",
"vendor_id": '$vendor_id'
}'

model_id=$(create_resource "$req" $ENDPOINT/models)

req='{
"name": "Ethernet Switch",
"model_id": '$model_id'
}'

version_id=$(create_resource "$req" $ENDPOINT/versions)

req='{
"name": "AOCM3948",
"vendor_id": '$vendor_id'
}'

model_id=$(create_resource "$req" $ENDPOINT/models)

req='{
"name": "Ethernet Switch",
"model_id": '$model_id'
}'

version_id=$(create_resource "$req" $ENDPOINT/versions)
9 changes: 5 additions & 4 deletions nesi/devices/huawei/huawei_resources/huawei_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,15 @@ def get_service_port(self, field, value):

def get_service_port_by_values(self, params=None):
"""Get specific service_port object."""
vlans = huawei_service_port.HuaweiServicePortCollection(

service_ports = huawei_service_port.HuaweiServicePortCollection(
self._conn, base.get_sub_resource_path_by(self, 'service_ports'),
params=params)

# A collection is a non-subscriptable object, therefore we can only get the first object via this way
if len(vlans) > 0:
for vlan in vlans:
return vlan
if len(service_ports) > 0:
for service_port in service_ports:
return service_port
else:
return None

Expand Down
12 changes: 12 additions & 0 deletions nesi/devices/huawei/huawei_resources/huawei_service_port.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 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
from nesi.devices.softbox.base_resources.service_port import ServicePort, ServicePortCollection, logging
from nesi.devices.softbox.base_resources import base

Expand Down
12 changes: 12 additions & 0 deletions nesi/devices/huawei/huawei_resources/huawei_service_vlan.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 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
from nesi.devices.softbox.base_resources.service_vlan import ServiceVlan, ServiceVlanCollection, logging
from nesi.devices.softbox.base_resources import base

Expand Down
Empty file.
17 changes: 17 additions & 0 deletions nesi/devices/pbn/api/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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
21 changes: 21 additions & 0 deletions nesi/devices/pbn/api/schemas/pbn_ont_port_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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

from nesi.devices.softbox.api.schemas.ontport_schemas import *


class PBNOntPortSchema(OntPortSchema):
class Meta:
model = OntPort
fields = OntPortSchema.Meta.fields + ('operational_state', 'admin_state', 'flow_control', 'duplex', 'speed',
'storm_control')
20 changes: 20 additions & 0 deletions nesi/devices/pbn/api/schemas/pbn_ont_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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

from nesi.devices.softbox.api.schemas.ont_schemas import *


class PBNOntSchema(OntSchema):
class Meta:
model = Ont
fields = OntSchema.Meta.fields + ('mac_address',)
26 changes: 26 additions & 0 deletions nesi/devices/pbn/api/schemas/pbn_port_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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

from nesi.devices.softbox.api.schemas.port_schemas import *


class PBNPortSchema(PortSchema):
class Meta:
model = Port
fields = PortSchema.Meta.fields + ('spanning_tree_guard_root', 'switchport_trunk_vlan_allowed',
'switchport_mode_trunk', 'switchport_pvid', 'no_lldp_transmit', 'pbn_speed',
'switchport_block_multicast', 'switchport_rate_limit_egress',
'switchport_rate_limit_ingress', 'no_pdp_enable', 'no_snmp_trap_link_status',
'exclamation_mark', 'switchport_protected')

channels = ma.Nested(CpesSchema.CpeSchema, many=True)
20 changes: 20 additions & 0 deletions nesi/devices/pbn/api/schemas/pbn_user_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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

from nesi.devices.softbox.api.schemas.user_schemas import *


class PBNUserSchema(UserSchema):
class Meta:
model = User
fields = UserSchema.Meta.fields + ('level', 'profile')
20 changes: 20 additions & 0 deletions nesi/devices/pbn/api/schemas/pbn_vlan_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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

from nesi.devices.softbox.api.schemas.vlan_schemas import *


class PBNVlanSchema(VlanSchema):
class Meta:
model = Vlan
fields = VlanSchema.Meta.fields + ('type', 'mac_address')
4 changes: 3 additions & 1 deletion nesi/devices/pbn/pbn_resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__all__ = []
__all__ = ["pbn_subrack", "pbn_card", "pbn_port", "pbn_user", "pbn_vlan", "pbn_service_port",
"pbn_service_vlan", "pbn_ont", "pbn_ont_port"]

Loading

0 comments on commit 37284ce

Please sign in to comment.