Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
paull committed Dec 10, 2024
1 parent 344ad7e commit 43ecb77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions lisa/sut_orchestrator/baremetal/ip_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .schema import IPPowerSchema

REQUEST_TIMEOUT = 3
REQUEST_SUCCESS_CODE = 200


class IPPower(subclasses.BaseClassWithRunbookMixin, ContextMixin, InitializableMixin):
Expand Down Expand Up @@ -49,14 +50,19 @@ def type_schema(cls) -> Type[schema.TypedSchema]:

def on(self, port: str) -> None:
request_on = f"{self._request_cmd}{port}=1"
try:
requests.get(request_on, timeout=REQUEST_TIMEOUT)
except requests.Timeout:
raise LisaException(f"Failed to turn off port {port}")
self._set_ip_power(request_on)

def off(self, port: str) -> None:
request_off = f"{self._request_cmd}{port}=0"
self._set_ip_power(request_off)

def _set_ip_power(self, power_cmd: str) -> None:
try:
requests.get(request_off, timeout=REQUEST_TIMEOUT)
except requests.Timeout:
raise LisaException(f"Failed to turn off port {port}")
response = requests.get(power_cmd, timeout=REQUEST_TIMEOUT)
response.raise_for_status()
except requests.HTTPError as http_err:
raise LisaException(f"HTTP error: {http_err} in set_ip_power occurred")
except Exception as err:
raise LisaException(f"Other Error: {err} in set_ip_power occurred")
else:
self._log.debug(f"Command {power_cmd} in set_ip_power done")
2 changes: 1 addition & 1 deletion lisa/sut_orchestrator/baremetal/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class KeyLoaderSchema(schema.TypedSchema, schema.ExtendableSchemaMixin):


@dataclass_json()
@dataclass
@dataclass
class BootConfigSchema(schema.TypedSchema, schema.ExtendableSchemaMixin):
type: str = field(default="boot_config", metadata=field_metadata(required=True))

Expand Down

0 comments on commit 43ecb77

Please sign in to comment.