Saggi Mizrahi has uploaded a new change for review. Change subject: Move fenceNode out of API.py ......................................................................
Move fenceNode out of API.py The actual details of how the response is mangles is part of the bindings so API.py really doesn't serve a purpose. This is the first step in a general trend of moving the logic out of API.py to dedicated modules and move the response mangling to the binding wrappers. Change-Id: Idaba551333a0f289abaff11dc113e09c426d591a Signed-off-by: Saggi Mizrahi <[email protected]> --- M vdsm/API.py M vdsm/BindingXMLRPC.py 2 files changed, 25 insertions(+), 38 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/91/7191/1 diff --git a/vdsm/API.py b/vdsm/API.py index 5826d81..4fdc7e7 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -37,7 +37,6 @@ from vdsm.define import doneCode, errCode, Kbytes, Mbytes import caps from vdsm.config import config -import fenceAgent import supervdsm @@ -972,40 +971,6 @@ APIBase.__init__(self) # General Host functions - def fenceNode(self, addr, port, agent, username, password, action, - secure=False, options=''): - """Send a fencing command to a remote node. - - agent is one of (rsa, ilo, drac5, ipmilan, etc) - action can be one of (status, on, off, reboot).""" - - self.log.debug('fenceNode(addr=%s,port=%s,agent=%s,user=%s,' + - 'passwd=%s,action=%s,secure=%s,options=%s)', addr, port, agent, - username, 'XXXX', action, secure, options) - - secure = utils.tobool(secure) - port = int(port) - - if action == "status": - try: - power = fenceAgent.getFenceStatus(addr, port, agent, username, - password, secure, options) - - return {'status': doneCode, - 'power': power} - - except fenceAgent.FenceStatusCheckError as e: - return {'status': {'code': 1, 'message': str(e)}} - - try: - fenceAgent.fenceNode(addr, port, agent, username, password, secure, - options, self._cif.shutdownEvent) - - return {'status': doneCode} - - except fenceAgent.UnsupportedFencingAgentError: - return errCode['fenceAgent'] - def ping(self): "Ping the server. Useful for tests" return {'status': doneCode} diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py index 48f4723..7eee29e 100644 --- a/vdsm/BindingXMLRPC.py +++ b/vdsm/BindingXMLRPC.py @@ -32,6 +32,8 @@ from vdsm.define import doneCode, errCode import API from vdsm.exception import VdsmException +import fenceAgent + try: from gluster.api import getGlusterMethods _glusterEnabled = True @@ -355,9 +357,29 @@ def fenceNode(self, addr, port, agent, username, password, action, secure=False, options=''): - api = API.Global() - return api.fenceNode(addr, port, agent, username, password, - action, secure, options) + + secure = utils.tobool(secure) + port = int(port) + + if action == "status": + try: + power = fenceAgent.getFenceStatus(addr, port, agent, username, + password, secure, options) + + return {'status': doneCode, + 'power': power} + + except fenceAgent.FenceStatusCheckError as e: + return {'status': {'code': 1, 'message': str(e)}} + + try: + fenceAgent.fenceNode(addr, port, agent, username, password, secure, + options, self.cif.shutdownEvent) + + return {'status': doneCode} + + except fenceAgent.UnsupportedFencingAgentError: + return errCode['fenceAgent'] def setLogLevel(self, level): api = API.Global() -- To view, visit http://gerrit.ovirt.org/7191 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idaba551333a0f289abaff11dc113e09c426d591a Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Saggi Mizrahi <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
