Skip to content

Commit

Permalink
try both chassis and high level commands for connect and disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
shmir committed May 2, 2023
1 parent aafbcad commit e30c00f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 31 deletions.
16 changes: 6 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
rev: 5.11.5
hooks:
- id: isort
language_version: python3.9
args: [--line-length=127]
- repo: https://github.com/python/black
rev: 22.8.0
rev: 23.3.0
hooks:
- id: black
language_version: python3.9
args: [--line-length=127]
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
Expand All @@ -27,23 +25,21 @@ repos:
--max-line-length=127,
'--ignore=D105,D200,W503,F401,F811'
]
- repo: local
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v3.0.0a5
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args: [
--max-line-length=127,
--max-public-methods=32,
--max-args=8,
'--disable=logging-fstring-interpolation,logging-not-lazy,unspecified-encoding,too-few-public-methods,too-many-instance-attributes',
'--good-names=ip,rc,eval,vm,ls',
'--load-plugins=pylint_pytest'
]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.971
rev: v1.2.0
hooks:
- id: mypy
verbose: true
Expand Down
23 changes: 16 additions & 7 deletions ixexplorer/ixe_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,29 @@ class IxeChassis(IxeObject, metaclass=ixe_obj_meta):
def __init__(self, parent: "IxeSession", host: str) -> None:
"""Create IxeChassis object with name = url == IP address."""
super().__init__(parent=parent, uri=host, name=host)
self.chassis_id = 0
self.chassis_id = 1

def connect(self) -> None:
"""Connect to chassis and get assigned chassis ID.
Note that sometimes, randomly, ixConnectToChassis fails. However, using chassis.add also fails, so it seems there is
no advantage for using one over the other.
We try both methods to connect to chassis because it is a little unclear which method works with which chassis.
"""
self.api.call_rc(f"ixConnectToChassis {self.uri}")
self.chassis_id = self.id
try:
self.add()
self.id = self.chassis_id
except IxTclHalError:
self.api.call_rc(f"ixConnectToChassis {self.uri}")
self.chassis_id = self.id

def disconnect(self) -> None:
"""Disconnect from chassis."""
self.api.call_rc(f"ixDisconnectFromChassis {self.uri}")
"""Disconnect from chassis.
We try both methods to disconnect from chassis because it is a little unclear which method works with which chassis.
"""
try:
self.ix_command("del")
except IxTclHalError:
self.api.call_rc(f"ixDisconnectFromChassis {self.uri}")

def add_card(self, cid):
"""Add card.
Expand Down
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,22 @@ requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]

[tool.isort]
line_length = 127
profile = "black"

[tool.black]
line-length = 127

[tool.pylint]
max-line-length = 127

[tool.mypy]
ignore_missing_imports = true
allow_untyped_calls = true
allow_untyped_defs = true
allow_incomplete_defs = true
follow_imports = "skip"
no_strict_optional = true
show_error_codes = true
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ tox

# Pipeline
pre-commit
pylint
pylint_pytest

# Packaging
setuptools-scm
Expand Down
12 changes: 0 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,3 @@ exclude =
[options.entry_points]
console_scripts =
tcl_cli = ixexplorer.samples.tcl_cli:main

[isort]
profile=black

[mypy]
ignore_missing_imports = True
allow_untyped_calls = True
allow_untyped_defs = False
allow_incomplete_defs = False
follow_imports = skip
no_strict_optional = True
show_error_codes = True

0 comments on commit e30c00f

Please sign in to comment.