-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from QualiSystems/dev
Dev
- Loading branch information
Showing
21 changed files
with
307 additions
and
1,178 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,20 +1,27 @@ | ||
from threading import Lock | ||
|
||
from raritan.rpc import pdumodel | ||
from cloudshell.power.pdu.device.outlet import Outlet | ||
|
||
|
||
POWERED_ON = pdumodel.Outlet.PowerState.PS_ON | ||
POWERED_OFF = pdumodel.Outlet.PowerState.PS_OFF | ||
|
||
|
||
class RPCAPIOutlet(Outlet): | ||
def __init__(self, outlet_handler): | ||
self._handler = outlet_handler | ||
self.lock = Lock() | ||
|
||
def power_on(self): | ||
self._handler.setPowerState(POWERED_ON) | ||
if self._handler.getState().powerState != POWERED_ON: | ||
Exception('Ports were not powered on') | ||
with self.lock: | ||
self._handler.setPowerState(POWERED_ON) | ||
if self._handler.getState().powerState != POWERED_ON: | ||
Exception('Ports were not powered on') | ||
|
||
def power_off(self): | ||
self._handler.setPowerState(POWERED_OFF) | ||
if self._handler.getState().powerState != POWERED_OFF: | ||
Exception('Ports were not powered off') | ||
with self.lock: | ||
self._handler.setPowerState(POWERED_OFF) | ||
if self._handler.getState().powerState != POWERED_OFF: | ||
Exception('Ports were not powered off') | ||
|
||
POWERED_ON = pdumodel.Outlet.PowerState.PS_ON | ||
POWERED_OFF = pdumodel.Outlet.PowerState.PS_OFF |
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
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
File renamed without changes.
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.