Skip to content
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
10 changes: 10 additions & 0 deletions .github/workflows/check-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: check version
on:
pull_request:
paths-ignore:
- README.md
branches:
- master
jobs:
check-version:
uses: QualiSystems/.github/.github/workflows/package-check-version.yml@master
11 changes: 11 additions & 0 deletions .github/workflows/deploy-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: deploy package
on:
release:
types: [ published ]
jobs:
tox-ci:
uses: QualiSystems/.github/.github/workflows/package-tox-py-39.yml@master
pypi-deploy:
needs: tox-ci
uses: QualiSystems/.github/.github/workflows/package-deploy-pypi.yml@master
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: github release
on:
push:
paths-ignore:
- README.md
branches:
- master
jobs:
tox-ci:
uses: QualiSystems/.github/.github/workflows/package-tox-py-39.yml@master
pypi-deploy:
needs: tox-ci
uses: QualiSystems/.github/.github/workflows/package-github-release.yml@master
10 changes: 10 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: package CI
on:
push:
paths-ignore:
- README.md
branches-ignore:
- master
jobs:
tox-ci:
uses: QualiSystems/.github/.github/workflows/package-tox-py-39.yml@master
189 changes: 0 additions & 189 deletions .github/workflows/py3-packages-ci.yml

This file was deleted.

21 changes: 12 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@

repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- "--py39-plus"
- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
rev: 5.12.0
hooks:
- id: isort
language_version: python3.7
exclude: '/mibs'
- repo: https://github.com/python/black
rev: 20.8b1
rev: 22.12.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: 5.0.4
hooks:
- id: flake8
additional_dependencies: [
Expand All @@ -22,6 +25,6 @@ repos:
flake8-comprehensions,
flake8-print,
flake8-eradicate,
flake8-requirements,
]
language_version: python3.7
exclude: '/mibs'
exclude: '/mibs'
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include *.txt
global-include *.ini
global-include *.ini
global-include *.json
40 changes: 40 additions & 0 deletions cloudshell/checkpoint/autoload/checkpoint_generic_snmp_autoload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from __future__ import annotations

import logging
import os
from functools import cached_property
from typing import TYPE_CHECKING

from cloudshell.snmp.autoload.generic_snmp_autoload import GenericSNMPAutoload

from cloudshell.checkpoint.autoload.checkpoint_snmp_port_table import (
CheckpointPortsTable,
)
from cloudshell.checkpoint.autoload.checkpoint_snmp_system_info import (
CheckpointSNMPSystemInfo,
)

if TYPE_CHECKING:
from cloudshell.snmp.autoload.services.system_info_table import SnmpSystemInfo

logger = logging.getLogger(__name__)


class CheckpointGenericSNMPAutoload(GenericSNMPAutoload):
def __init__(self, snmp_handler, resource_model):
super().__init__(snmp_handler, logger, resource_model)
self.load_mibs(os.path.abspath(os.path.join(os.path.dirname(__file__), "mibs")))

@cached_property
def system_info_service(self) -> SnmpSystemInfo:
return CheckpointSNMPSystemInfo(self.snmp_handler, logger)

@property
def port_table_service(self) -> CheckpointPortsTable:
if not self._port_table_service:
self._port_table_service = CheckpointPortsTable(
resource_model=self._resource_model,
ports_snmp_table=self.port_snmp_table,
logger=self.logger,
)
return self._port_table_service
8 changes: 8 additions & 0 deletions cloudshell/checkpoint/autoload/checkpoint_snmp_port_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from __future__ import annotations

from cloudshell.snmp.autoload.services.port_table import PortsTable


class CheckpointPortsTable(PortsTable):
PORT_EXCLUDE_LIST = PortsTable.PORT_EXCLUDE_LIST + ["lo", "sync", "loopback"]
PORT_CHANNEL_NAME_LIST = PortsTable.PORT_CHANNEL_NAME_LIST + ["bond"]
47 changes: 47 additions & 0 deletions cloudshell/checkpoint/autoload/checkpoint_snmp_system_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from __future__ import annotations

from cloudshell.snmp.autoload.services.system_info_table import SnmpSystemInfo
from cloudshell.snmp.core.domain.snmp_oid import SnmpMibObject


class CheckpointSNMPSystemInfo(SnmpSystemInfo):
def _get_device_model(self):
"""Get device model from the SNMPv2 mib."""
result = self._get_val(
self._snmp_handler.get_property(
SnmpMibObject("CHECKPOINT-MIB", "svnApplianceProductName", "0")
)
)

return result

def _get_vendor(self):
"""Get device model from the SNMPv2 mib."""
if not self._vendor:
sys_obj_id = self._snmp_v2_obj.get_system_object_id()
sys_obj_id_oid = str(sys_obj_id.raw_value)
oid_match = self.VENDOR_OID_PATTERN.search(sys_obj_id_oid)
if oid_match:
self._vendor = self._snmp_handler.translate_oid(
oid_match.group()
).capitalize()

return self._vendor or "Checkpoint"

def _get_device_os_version(self) -> str:
"""Get device OS Version form snmp SNMPv2 mib."""
result = self._get_val(
self._snmp_handler.get_property(
SnmpMibObject("CHECKPOINT-MIB", "svnVersion", "0")
)
)

return result

def is_valid_device_os(self, supported_os: list[str]) -> bool:
"""Validate device OS using snmp."""
if not SnmpSystemInfo.is_valid_device_os(self, supported_os=supported_os):
# Check is vendor equal Checkpoint
return self._get_vendor().lower() == "checkpoint"

return True
Loading