-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added ip_power control for BareMetal platform #3550
Open
paulli2017
wants to merge
6
commits into
microsoft:main
Choose a base branch
from
paulli2017:paull/ippower
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7736b83
# This is a combination of 2 commits.
739ba08
Added ip_power control for BareMetal platform
d0e8ed3
Added ip_power control for BareMetal platform
4338632
Added tftp deployment on BareMetal platform (#3422)
paulli2017 a77a26e
Added ip_power control for BareMetal platform
f5a0fe6
test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
from typing import Type | ||
|
||
import requests | ||
|
||
from lisa import schema | ||
from lisa.util import ContextMixin, InitializableMixin, LisaException, subclasses | ||
from lisa.util.logger import get_logger | ||
|
||
from .schema import IPPowerSchema | ||
|
||
REQUEST_TIMEOUT = 3 | ||
REQUEST_SUCCESS_CODE = 200 | ||
|
||
|
||
class IPPower(subclasses.BaseClassWithRunbookMixin, ContextMixin, InitializableMixin): | ||
def __init__(self, runbook: IPPowerSchema) -> None: | ||
super().__init__(runbook=runbook) | ||
self._log = get_logger("cluster", self.__class__.__name__) | ||
|
||
@classmethod | ||
def type_schema(cls) -> Type[schema.TypedSchema]: | ||
return IPPowerSchema | ||
|
||
def on(self, port: str) -> None: | ||
raise NotImplementedError() | ||
|
||
def off(self, port: str) -> None: | ||
raise NotImplementedError() | ||
|
||
|
||
class Ip9285(IPPower): | ||
def __init__(self, runbook: IPPowerSchema) -> None: | ||
super().__init__(runbook) | ||
self._request_cmd = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does the |
||
f"http://{runbook.host}/set.cmd?" | ||
f"user={runbook.username}+pass=" | ||
f"{runbook.password}+cmd=setpower+P6" | ||
) | ||
|
||
@classmethod | ||
def type_name(cls) -> str: | ||
return "Ip9285" | ||
|
||
@classmethod | ||
def type_schema(cls) -> Type[schema.TypedSchema]: | ||
return IPPowerSchema | ||
|
||
def on(self, port: str) -> None: | ||
request_on = f"{self._request_cmd}{port}=1" | ||
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: | ||
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow SerialConsole's design, implement the logic in the feature, and call it in cluster, when it's needed.