Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]
python-version: ["3.9"]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down Expand Up @@ -56,10 +56,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install pip -U
Expand All @@ -74,10 +74,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install pip -U
Expand Down Expand Up @@ -107,10 +107,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install pip -U
Expand All @@ -134,10 +134,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install pip -U
Expand Down Expand Up @@ -170,10 +170,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install pip -U
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@ target/
.ipynb_checkpoints
.pypirc

.idea/
.idea/
# virtualenvs
.venv*/
17 changes: 7 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
language_version: python3.7
exclude: '/mibs'
- repo: https://github.com/python/black
rev: 20.8b1
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
language_version: python3.7
exclude: '/mibs'
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: [
Expand All @@ -22,5 +20,4 @@ repos:
flake8-print,
flake8-eradicate,
]
language_version: python3.7
exclude: '/mibs'
exclude: '/mibs'
47 changes: 2 additions & 45 deletions cloudshell/huawei/autoload/huawei_generic_snmp_autoload.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

from cloudshell.snmp.autoload.generic_snmp_autoload import (
GeneralAutoloadError,
GenericSNMPAutoload,
log_autoload_details,
)
from cloudshell.snmp.autoload.generic_snmp_autoload import GenericSNMPAutoload


class HuaweiGenericSNMPAutoload(GenericSNMPAutoload):
def __init__(self, snmp_handler, logger):
super(HuaweiGenericSNMPAutoload, self).__init__(snmp_handler, logger)

def discover(
self, supported_os, resource_model, validate_module_id_by_port_name=False
):
"""General entry point for autoload.

Read device structure and attributes: chassis, modules, submodules, ports,
port-channels and power supplies
:type resource_model: cloudshell.shell.standards.autoload_generic_models.GenericResourceModel # noqa: E501
:param str supported_os:
:param bool validate_module_id_by_port_name:
:return: AutoLoadDetails object
"""
self.entity_table_service.validate_module_id_by_port_name = (
validate_module_id_by_port_name
)
if not resource_model:
return
self._resource_model = resource_model
if not self.system_info_service.is_valid_device_os(supported_os):
raise GeneralAutoloadError("Unsupported device OS")

self.logger.info("*" * 70)
self.logger.info("Start SNMP discovery process .....")
self.system_info_service.fill_attributes(resource_model)

entity_chassis_tree_dict = self.entity_table_service.chassis_structure_dict

if entity_chassis_tree_dict:
self._build_structure(entity_chassis_tree_dict.values(), resource_model)
self._get_port_channels(resource_model)

autoload_details = resource_model.build(
filter_empty_modules=True, use_new_unique_id=True
)

log_autoload_details(self.logger, autoload_details)
return autoload_details
"""Huawei SNMP autoload based on the generic implementation."""
6 changes: 3 additions & 3 deletions cloudshell/huawei/command_actions/add_remove_vlan_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_vlan_range(self, start_vlan, end_vlan):
).execute_command(start_vlan=start_vlan, end_vlan=end_vlan)

def set_vlan_to_interface(self, vlan, port_mode, qnq):
""" """
""" """

if qnq:
CommandTemplateExecutor(
Expand All @@ -52,7 +52,7 @@ def set_vlan_to_interface(self, vlan, port_mode, qnq):
).execute_command(vlan=vlan)

def set_vlan_range_to_interface(self, start_vlan, end_vlan, port_mode):
""" """
""" """

if port_mode == "trunk":
CommandTemplateExecutor(
Expand All @@ -72,7 +72,7 @@ def activate_port(self):
).execute_command()

def activate_port_mode(self):
""" """
""" """

CommandTemplateExecutor(
self._cli_service, add_remove_vlan.START_PORT_MODE
Expand Down
12 changes: 7 additions & 5 deletions cloudshell/huawei/flows/huawei_autoload_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class HuaweiSnmpAutoloadFlow(AbstractAutoloadFlow):
MIBS_FOLDER = os.path.join(os.path.dirname(__file__), os.pardir, "mibs")

def __init__(self, logger, snmp_handler):
super(HuaweiSnmpAutoloadFlow, self).__init__(logger)
super().__init__(logger)
self._snmp_handler = snmp_handler

def _autoload_flow(self, supported_os, resource_model):
Expand All @@ -26,8 +26,10 @@ def _autoload_flow(self, supported_os, resource_model):
"HUAWEI-TC-MIB",
]
)
snmp_autoload = HuaweiGenericSNMPAutoload(snmp_service, self._logger)

return snmp_autoload.discover(
supported_os, resource_model, validate_module_id_by_port_name=False
snmp_autoload = HuaweiGenericSNMPAutoload(
snmp_handler=snmp_service,
logger=self._logger,
resource_model=resource_model,
)

return snmp_autoload.discover(supported_os)
Loading
Loading