|
|
658b6c |
From 790cbaa66f3927a84739af4a1f0e8bba295cdc36 Mon Sep 17 00:00:00 2001
|
|
|
658b6c |
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
|
|
658b6c |
Date: Mon, 30 Jul 2018 10:43:04 +0200
|
|
|
658b6c |
Subject: [PATCH] fence_aliyun: add logging
|
|
|
658b6c |
|
|
|
658b6c |
---
|
|
|
658b6c |
agents/aliyun/fence_aliyun.py | 16 ++++++++++++----
|
|
|
658b6c |
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
|
658b6c |
|
|
|
658b6c |
diff --git a/agents/aliyun/fence_aliyun.py b/agents/aliyun/fence_aliyun.py
|
|
|
658b6c |
index aa6c0acf..2cda6b7f 100644
|
|
|
658b6c |
--- a/agents/aliyun/fence_aliyun.py
|
|
|
658b6c |
+++ b/agents/aliyun/fence_aliyun.py
|
|
|
658b6c |
@@ -23,9 +23,10 @@ def _send_request(conn, request):
|
|
|
658b6c |
try:
|
|
|
658b6c |
response_str = conn.do_action_with_exception(request)
|
|
|
658b6c |
response_detail = json.loads(response_str)
|
|
|
658b6c |
+ logging.debug("_send_request reponse: %s" % response_detail)
|
|
|
658b6c |
return response_detail
|
|
|
658b6c |
except Exception as e:
|
|
|
658b6c |
- fail_usage("Failed: _send_request failed")
|
|
|
658b6c |
+ fail_usage("Failed: _send_request failed: %s" % e)
|
|
|
658b6c |
|
|
|
658b6c |
def start_instance(conn, instance_id):
|
|
|
658b6c |
request = StartInstanceRequest()
|
|
|
658b6c |
@@ -69,15 +70,22 @@ def get_nodes_list(conn, options):
|
|
|
658b6c |
|
|
|
658b6c |
def get_power_status(conn, options):
|
|
|
658b6c |
state = get_status(conn, options["--plug"])
|
|
|
658b6c |
+
|
|
|
658b6c |
if state == "Running":
|
|
|
658b6c |
- return "on"
|
|
|
658b6c |
+ status = "on"
|
|
|
658b6c |
elif state == "Stopped":
|
|
|
658b6c |
- return "off"
|
|
|
658b6c |
+ status = "off"
|
|
|
658b6c |
else:
|
|
|
658b6c |
- return "unknown"
|
|
|
658b6c |
+ status = "unknown"
|
|
|
658b6c |
+
|
|
|
658b6c |
+ logging.info("get_power_status: %s" % status)
|
|
|
658b6c |
+
|
|
|
658b6c |
+ return status
|
|
|
658b6c |
|
|
|
658b6c |
|
|
|
658b6c |
def set_power_status(conn, options):
|
|
|
658b6c |
+ logging.info("set_power_status: %s" % options["--action"])
|
|
|
658b6c |
+
|
|
|
658b6c |
if (options["--action"]=="off"):
|
|
|
658b6c |
stop_instance(conn, options["--plug"])
|
|
|
658b6c |
elif (options["--action"]=="on"):
|