This addresses some flake8 and python typing errors.
Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
self.username: str = kw['username']
self.password: str = kw['password']
# move the following line (class attribute?)
- self.client = RedFishClient(host=self.host, port=self.port, username=self.username, password=self.password)
+ self.client: RedFishClient = RedFishClient(host=self.host, port=self.port, username=self.username, password=self.password)
self.log.logger.info(f"redfish system initialization, host: {self.host}, user: {self.username}")
self.run: bool = False
_data = self._get_path(_path)
return [self._get_path(member['@odata.id']) for member in _data['Members']]
- def get_system(self) -> Dict[str, Dict[str, Dict]]:
+ def get_system(self) -> Dict[str, Any]:
result = {
'host': self.get_host(),
'sn': self.get_sn(),
self.config: Config = kw['config']
self.client: BaseClient
- def get_system(self) -> Dict[str, Dict[str, Dict]]:
+ def get_system(self) -> Dict[str, Any]:
raise NotImplementedError()
def get_status(self) -> Dict[str, Dict[str, Dict]]:
def get_memory(self) -> Dict[str, Dict[str, Dict]]:
raise NotImplementedError()
+ def get_fans(self) -> Dict[str, Dict[str, Dict]]:
+ raise NotImplementedError()
+
def get_power(self) -> Dict[str, Dict[str, Dict]]:
raise NotImplementedError()
from .util import Config, Logger
from typing import Dict, Any, Optional, List
from .basesystem import BaseSystem
-import sys
-import argparse
-import json
import traceback
DEFAULT_CONFIG = {
-import time
-import datetime
import ssl
import json
-from urllib.error import HTTPError, URLError
+from urllib.error import URLError
from urllib.request import urlopen, Request
from .baseclient import BaseClient
from .util import Logger
def __init__(self,
host: str = "",
- port: str = "443",
+ port: int = 443,
username: str = "",
password: str = ""):
super().__init__(host, username, password)
self.log: Logger = Logger(__name__)
self.log.logger.info(f"Initializing redfish client {__name__}")
- self.host: str = f"https://{host}:{port}"
+ self.host: str = f"https://{host}:{str(port)}"
self.token: str = ''
self.location: str = ''
self.log.logger.warning(f"Could not find field: {field} in data: {data[elt]}")
return normalize_dict(result)
-
def get_sn(self) -> str:
return self._sys['SKU']
def get_fans(self) -> Dict[str, Dict[str, Dict]]:
return self._sys['fans']
- def get_led(self) -> Dict[str, Dict[str, Dict]]:
+ def get_led(self) -> Dict[str, Any]:
endpoint = f"/redfish/v1/{self.chassis_endpoint}"
result = self.client.query(method='GET',
endpoint=endpoint,
timeout=10)
response_json = json.loads(result[1])
mapper = {
- 'true': 'on',
- 'false': 'off'
+ 'true': 'on',
+ 'false': 'off'
}
if result[2] == 200:
return {"state": mapper[str(response_json['LocationIndicatorActive']).lower()]}