-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inherit power client and standartize method names
Signed-off-by: Benny Zlotnik <[email protected]>
- Loading branch information
Showing
3 changed files
with
71 additions
and
55 deletions.
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
32 changes: 9 additions & 23 deletions
32
packages/jumpstarter-driver-snmp/jumpstarter_driver_snmp/client.py
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 |
---|---|---|
@@ -1,48 +1,34 @@ | ||
from dataclasses import dataclass | ||
|
||
import asyncclick as click | ||
|
||
from jumpstarter.client import DriverClient | ||
from jumpstarter_driver_power.client import PowerClient | ||
|
||
|
||
@dataclass(kw_only=True) | ||
class SNMPServerClient(DriverClient): | ||
class SNMPServerClient(PowerClient): | ||
"""Client interface for SNMP Power Control""" | ||
|
||
def power_on(self): | ||
def on(self) -> str: | ||
"""Turn power on""" | ||
return self.call("power_on") | ||
return self.call("on") | ||
|
||
def power_off(self): | ||
def off(self) -> str: | ||
"""Turn power off""" | ||
return self.call("power_off") | ||
|
||
def power_cycle(self): | ||
"""Power cycle the device""" | ||
return self.call("power_cycle") | ||
return self.call("off") | ||
|
||
def cli(self): | ||
@click.group() | ||
def snmp(): | ||
"""SNMP power control commands""" | ||
pass | ||
|
||
@snmp.command() | ||
def on(): | ||
"""Turn power on""" | ||
result = self.power_on() | ||
click.echo(result) | ||
|
||
@snmp.command() | ||
def off(): | ||
"""Turn power off""" | ||
result = self.power_off() | ||
click.echo(result) | ||
for cmd in super().cli().commands.values(): | ||
snmp.add_command(cmd) | ||
|
||
@snmp.command() | ||
def cycle(): | ||
"""Power cycle the device""" | ||
result = self.power_cycle() | ||
result = self.cycle() | ||
click.echo(result) | ||
|
||
return snmp |
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