Compare commits
No commits in common. "c8" and "c8s" have entirely different histories.
@ -1,62 +0,0 @@
|
|||||||
3297473a9d57e93ff378eab173990c1b64673c01 SOURCES/Jinja2-3.0.2.tar.gz
|
|
||||||
e1b766b2b1601fde67b3b19ed2f13b9746bb1cca SOURCES/MarkupSafe-2.0.1.tar.gz
|
|
||||||
3880207fdf0db1eeadf976092c8fbf80a7335c24 SOURCES/PyJWT-2.4.0.tar.gz
|
|
||||||
a8c40a3ae9d4c159382a58db3153d83e5521c51e SOURCES/PyYAML-6.0.tar.gz
|
|
||||||
0c47ce98be5a519023c16e10027ed1268c489fcc SOURCES/adal-1.2.7.tar.gz
|
|
||||||
0a56f6d9ed2014a363486d33b63eca094379be06 SOURCES/aliyun-python-sdk-core-2.13.1.tar.gz
|
|
||||||
c2a98b9a1562d223a76514f05028488ca000c395 SOURCES/aliyun-python-sdk-ecs-4.9.3.tar.gz
|
|
||||||
f14647a4d37a9a254c4e711b95a7654fc418e41e SOURCES/aliyun-python-sdk-vpc-3.0.2.tar.gz
|
|
||||||
1f493a02d15374027ae2bcb2ea4daf5b907c528b SOURCES/azure-common-1.1.28.zip
|
|
||||||
acfa532a6e6acc7311d697b3835a6190796ab5b4 SOURCES/azure-core-1.24.2.zip
|
|
||||||
46d2d17d958ae305ced32fdd6aa847b0cdf31989 SOURCES/azure-identity-1.10.0.zip
|
|
||||||
2a2e61ec1805165b19c4652b316225ced9b1ca28 SOURCES/azure-mgmt-compute-27.2.0.zip
|
|
||||||
f73acf29dd33e65a37b13dc8048832cbdd9e8306 SOURCES/azure-mgmt-core-1.3.2.zip
|
|
||||||
d4672e130177a9b330cf40c5bded8ed3aa4b1143 SOURCES/azure-mgmt-network-20.0.0.zip
|
|
||||||
2512ff4ef016cad0b916006f6acf2a309f908c4d SOURCES/botocore-1.23.46.tar.gz
|
|
||||||
0d12f48faa727f0979e9ad5c4c80dfa32b73caff SOURCES/cachetools-4.2.4.tar.gz
|
|
||||||
ec7e8dd8ef95edfdb83a1ea040b8b88507b47615 SOURCES/certifi-2023.7.22.tar.gz
|
|
||||||
c42a46cd11f6153f299cf10e9c236e8b2a143c21 SOURCES/cffi-1.15.1.tar.gz
|
|
||||||
2384f6cfba4685d901262e073a4455d4cf76d102 SOURCES/chardet-4.0.0.tar.gz
|
|
||||||
865df92e66e5dc7b940144cbad8115c07dc8784f SOURCES/charset-normalizer-2.0.7.tar.gz
|
|
||||||
eb8be696115458f9368432525e9cae11d0f6bebf SOURCES/cryptography-3.3.2.tar.gz
|
|
||||||
e2561df8e7ff9113dab118a651371dd88dab0142 SOURCES/fence-agents-4.2.1.tar.gz
|
|
||||||
81c165cd2a388d5a6cd415308edaf11ee5bf42cd SOURCES/flit_core-3.10.1.tar.gz
|
|
||||||
f4e578dc0ed68d6667d7b36cdfc2647d55e9858f SOURCES/google-auth-2.3.0.tar.gz
|
|
||||||
74ec77d2e2ef6b2ef8503e6e398faa6f3ba298ae SOURCES/httplib2-0.19.1-py3-none-any.whl
|
|
||||||
08c0449533fc94462f78652dea209099754d9ee4 SOURCES/idna-3.3.tar.gz
|
|
||||||
ea36ce1c780dd44f01225dca7f9995a6685a60cc SOURCES/isodate-0.6.1.tar.gz
|
|
||||||
356c48dfea2214dd9e7e2b222a99dddfe9c0d05c SOURCES/jmespath-0.10.0.tar.gz
|
|
||||||
d06a9547b1a87e9c51b0a7c708189d993f2e3d89 SOURCES/kubernetes-12.0.1.tar.gz
|
|
||||||
373683b6adda29af3b1334a69bf149b85deb7899 SOURCES/msal-1.27.0.tar.gz
|
|
||||||
04e016bd1fa4ed6ddb852095a45d4f8c81a5b54a SOURCES/msal-extensions-1.0.0.tar.gz
|
|
||||||
00c5509205e59ebae09e5d3fe068ab61588e9b4a SOURCES/msrest-0.7.1.zip
|
|
||||||
bcedc87fc73e9738cbc8b0435513c01b6eb0b5c2 SOURCES/msrestazure-0.6.4.tar.gz
|
|
||||||
f6efa66f6106b069b5c0e0cf8cc677e4e96c91ca SOURCES/oauthlib-3.1.1.tar.gz
|
|
||||||
7e2f8f4cebf309ef6aaf740ee9073276d6937802 SOURCES/oauthlib-3.2.2.tar.gz
|
|
||||||
570d69d8c108ebb8aee562389d13b07dfb61ce25 SOURCES/openshift-0.12.1.tar.gz
|
|
||||||
bccbc1bf76a9db46998eb8e1ffa2f2a2baf9237a SOURCES/packaging-21.2-py3-none-any.whl
|
|
||||||
a243525070cf70f22a185447ebd3e1435dabb218 SOURCES/pip-21.3.1.tar.gz
|
|
||||||
67c8e65065f751c87cadf973a0a2d7b2cfad3bfa SOURCES/poetry-core-1.0.8.tar.gz
|
|
||||||
4f099f76d500f4ca500a17a3a647f84b7a796e54 SOURCES/portalocker-2.7.0.tar.gz
|
|
||||||
e0fa19f8fda46a1fa2253477499b116b33f67175 SOURCES/pyasn1-0.4.8.tar.gz
|
|
||||||
43b89feb6864fe359aae89120627165219de313b SOURCES/pyasn1-modules-0.2.8.tar.gz
|
|
||||||
0ae93d89b69fab48af3a407a2f8663bcea270c3d SOURCES/pycparser-2.20.tar.gz
|
|
||||||
c55d177e9484d974c95078d4ae945f89ba2c7251 SOURCES/pycryptodome-3.20.0.tar.gz
|
|
||||||
c8307f47e3b75a2d02af72982a2dfefa3f56e407 SOURCES/pyparsing-2.4.7-py2.py3-none-any.whl
|
|
||||||
c2ba10c775b7a52a4b57cac4d4110a0c0f812a82 SOURCES/python-dateutil-2.8.2.tar.gz
|
|
||||||
1dc2fa004aa6517f1620e55d8a7b8e68a9cf2a47 SOURCES/python-string-utils-1.0.0.tar.gz
|
|
||||||
8c7a89d183d3e9b70bf91ba5b75eccf7111b9d8d SOURCES/requests-2.26.0.tar.gz
|
|
||||||
96c46fc47e75d06fa7ead4d7fb1ae7d58d68989f SOURCES/requests-2.27.1.tar.gz
|
|
||||||
f139aed770519b6a095b8fdc888d03955cbe9d8e SOURCES/requests-oauthlib-1.3.0.tar.gz
|
|
||||||
024bb67bc625557fd15b70e1c8e7d6abf5aa75dd SOURCES/requests-oauthlib-2.0.0.tar.gz
|
|
||||||
e8a53067e03fe1b6682fd99a40a7359396a06daa SOURCES/rsa-4.7.2.tar.gz
|
|
||||||
d1011ff44cd5a045de0460c1b79ec65592e86860 SOURCES/ruamel.yaml-0.17.16.tar.gz
|
|
||||||
27de97227bbbde5a9f571f9fad223578d7bdf7cc SOURCES/ruamel.yaml.clib-0.2.6.tar.gz
|
|
||||||
d5354718cb8c9330d3abc27445467ce8a5ed9d70 SOURCES/setuptools-58.3.0.tar.gz
|
|
||||||
0f34eba670121f9c41939ca8d805687de359f71c SOURCES/setuptools_scm-6.4.2.tar.gz
|
|
||||||
06fa0bb50f2a4e2917fd14c21e9d2d5508ce0163 SOURCES/six-1.16.0.tar.gz
|
|
||||||
2a2b9fb5137976719423b1bb8241b83eb32bb7b0 SOURCES/tomli-1.1.0.tar.gz
|
|
||||||
0fab53e2ff16ae6370cfcf72e3e251535a5ebe74 SOURCES/typing_extensions-4.1.1.tar.gz
|
|
||||||
84e2852d8da1655373f7ce5e7d5d3e256b62b4e4 SOURCES/urllib3-1.26.18.tar.gz
|
|
||||||
540f083782c584989c1a0f69ffd69ba7aae07db6 SOURCES/websocket-client-1.2.1.tar.gz
|
|
||||||
f9f3d980579b88baaacdb6c4a3cc4466b9353030 SOURCES/wheel-0.37.1.tar.gz
|
|
72
.gitignore
vendored
72
.gitignore
vendored
@ -1,62 +1,10 @@
|
|||||||
SOURCES/Jinja2-3.0.2.tar.gz
|
/*.tar.?z*
|
||||||
SOURCES/MarkupSafe-2.0.1.tar.gz
|
/*.rpm
|
||||||
SOURCES/PyJWT-2.4.0.tar.gz
|
/*.txt
|
||||||
SOURCES/PyYAML-6.0.tar.gz
|
/*.whl
|
||||||
SOURCES/adal-1.2.7.tar.gz
|
/*.zip
|
||||||
SOURCES/aliyun-python-sdk-core-2.13.1.tar.gz
|
/.*.swp
|
||||||
SOURCES/aliyun-python-sdk-ecs-4.9.3.tar.gz
|
/.build-*.log
|
||||||
SOURCES/aliyun-python-sdk-vpc-3.0.2.tar.gz
|
/*/
|
||||||
SOURCES/azure-common-1.1.28.zip
|
!/tests/
|
||||||
SOURCES/azure-core-1.24.2.zip
|
/tests/*.retry
|
||||||
SOURCES/azure-identity-1.10.0.zip
|
|
||||||
SOURCES/azure-mgmt-compute-27.2.0.zip
|
|
||||||
SOURCES/azure-mgmt-core-1.3.2.zip
|
|
||||||
SOURCES/azure-mgmt-network-20.0.0.zip
|
|
||||||
SOURCES/botocore-1.23.46.tar.gz
|
|
||||||
SOURCES/cachetools-4.2.4.tar.gz
|
|
||||||
SOURCES/certifi-2023.7.22.tar.gz
|
|
||||||
SOURCES/cffi-1.15.1.tar.gz
|
|
||||||
SOURCES/chardet-4.0.0.tar.gz
|
|
||||||
SOURCES/charset-normalizer-2.0.7.tar.gz
|
|
||||||
SOURCES/cryptography-3.3.2.tar.gz
|
|
||||||
SOURCES/fence-agents-4.2.1.tar.gz
|
|
||||||
SOURCES/flit_core-3.10.1.tar.gz
|
|
||||||
SOURCES/google-auth-2.3.0.tar.gz
|
|
||||||
SOURCES/httplib2-0.19.1-py3-none-any.whl
|
|
||||||
SOURCES/idna-3.3.tar.gz
|
|
||||||
SOURCES/isodate-0.6.1.tar.gz
|
|
||||||
SOURCES/jmespath-0.10.0.tar.gz
|
|
||||||
SOURCES/kubernetes-12.0.1.tar.gz
|
|
||||||
SOURCES/msal-1.27.0.tar.gz
|
|
||||||
SOURCES/msal-extensions-1.0.0.tar.gz
|
|
||||||
SOURCES/msrest-0.7.1.zip
|
|
||||||
SOURCES/msrestazure-0.6.4.tar.gz
|
|
||||||
SOURCES/oauthlib-3.1.1.tar.gz
|
|
||||||
SOURCES/oauthlib-3.2.2.tar.gz
|
|
||||||
SOURCES/openshift-0.12.1.tar.gz
|
|
||||||
SOURCES/packaging-21.2-py3-none-any.whl
|
|
||||||
SOURCES/pip-21.3.1.tar.gz
|
|
||||||
SOURCES/poetry-core-1.0.8.tar.gz
|
|
||||||
SOURCES/portalocker-2.7.0.tar.gz
|
|
||||||
SOURCES/pyasn1-0.4.8.tar.gz
|
|
||||||
SOURCES/pyasn1-modules-0.2.8.tar.gz
|
|
||||||
SOURCES/pycparser-2.20.tar.gz
|
|
||||||
SOURCES/pycryptodome-3.20.0.tar.gz
|
|
||||||
SOURCES/pyparsing-2.4.7-py2.py3-none-any.whl
|
|
||||||
SOURCES/python-dateutil-2.8.2.tar.gz
|
|
||||||
SOURCES/python-string-utils-1.0.0.tar.gz
|
|
||||||
SOURCES/requests-2.26.0.tar.gz
|
|
||||||
SOURCES/requests-2.27.1.tar.gz
|
|
||||||
SOURCES/requests-oauthlib-1.3.0.tar.gz
|
|
||||||
SOURCES/requests-oauthlib-2.0.0.tar.gz
|
|
||||||
SOURCES/rsa-4.7.2.tar.gz
|
|
||||||
SOURCES/ruamel.yaml-0.17.16.tar.gz
|
|
||||||
SOURCES/ruamel.yaml.clib-0.2.6.tar.gz
|
|
||||||
SOURCES/setuptools-58.3.0.tar.gz
|
|
||||||
SOURCES/setuptools_scm-6.4.2.tar.gz
|
|
||||||
SOURCES/six-1.16.0.tar.gz
|
|
||||||
SOURCES/tomli-1.1.0.tar.gz
|
|
||||||
SOURCES/typing_extensions-4.1.1.tar.gz
|
|
||||||
SOURCES/urllib3-1.26.18.tar.gz
|
|
||||||
SOURCES/websocket-client-1.2.1.tar.gz
|
|
||||||
SOURCES/wheel-0.37.1.tar.gz
|
|
||||||
|
84
RHEL-5397-3-fence_scsi-fix-run_cmd.patch
Normal file
84
RHEL-5397-3-fence_scsi-fix-run_cmd.patch
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
--- a/agents/scsi/fence_scsi.py 2024-01-03 14:06:10.155417318 +0100
|
||||||
|
+++ b/agents/scsi/fence_scsi.py 2024-01-03 14:07:40.737369588 +0100
|
||||||
|
@@ -84,14 +84,14 @@
|
||||||
|
# check if host is ready to execute actions
|
||||||
|
def do_action_monitor(options):
|
||||||
|
# Check if required binaries are installed
|
||||||
|
- if bool(run_cmd(options, options["--sg_persist-path"] + " -V")["err"]):
|
||||||
|
+ if bool(run_cmd(options, options["--sg_persist-path"] + " -V")["rc"]):
|
||||||
|
logging.error("Unable to run " + options["--sg_persist-path"])
|
||||||
|
return 1
|
||||||
|
- elif bool(run_cmd(options, options["--sg_turs-path"] + " -V")["err"]):
|
||||||
|
+ elif bool(run_cmd(options, options["--sg_turs-path"] + " -V")["rc"]):
|
||||||
|
logging.error("Unable to run " + options["--sg_turs-path"])
|
||||||
|
return 1
|
||||||
|
elif ("--devices" not in options and
|
||||||
|
- bool(run_cmd(options, options["--vgs-path"] + " --version")["err"])):
|
||||||
|
+ bool(run_cmd(options, options["--vgs-path"] + " --version")["rc"])):
|
||||||
|
logging.error("Unable to run " + options["--vgs-path"])
|
||||||
|
return 1
|
||||||
|
|
||||||
|
@@ -102,11 +102,13 @@
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
-#run command, returns dict, ret["err"] = exit code; ret["out"] = output
|
||||||
|
+# run command, returns dict, ret["rc"] = exit code; ret["out"] = output;
|
||||||
|
+# ret["err"] = error
|
||||||
|
def run_cmd(options, cmd):
|
||||||
|
ret = {}
|
||||||
|
- (ret["err"], ret["out"], _) = run_command(options, cmd)
|
||||||
|
+ (ret["rc"], ret["out"], ret["err"]) = run_command(options, cmd)
|
||||||
|
ret["out"] = "".join([i for i in ret["out"] if i is not None])
|
||||||
|
+ ret["err"] = "".join([i for i in ret["err"] if i is not None])
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
@@ -122,11 +124,11 @@
|
||||||
|
def preempt_abort(options, host, dev):
|
||||||
|
reset_dev(options,dev)
|
||||||
|
cmd = options["--sg_persist-path"] + " -n -o -A -T 5 -K " + host + " -S " + options["--key"] + " -d " + dev
|
||||||
|
- return not bool(run_cmd(options, cmd)["err"])
|
||||||
|
+ return not bool(run_cmd(options, cmd)["rc"])
|
||||||
|
|
||||||
|
|
||||||
|
def reset_dev(options, dev):
|
||||||
|
- return run_cmd(options, options["--sg_turs-path"] + " " + dev)["err"]
|
||||||
|
+ return run_cmd(options, options["--sg_turs-path"] + " " + dev)["rc"]
|
||||||
|
|
||||||
|
|
||||||
|
def register_dev(options, dev, key):
|
||||||
|
@@ -171,13 +173,13 @@
|
||||||
|
reset_dev(options, dev)
|
||||||
|
cmd = options["--sg_persist-path"] + " -n -o -I -S " + key + " -d " + dev
|
||||||
|
cmd += " -Z" if "--aptpl" in options else ""
|
||||||
|
- return not bool(run_cmd(options, cmd)["err"])
|
||||||
|
+ return not bool(run_cmd(options, cmd)["rc"])
|
||||||
|
|
||||||
|
|
||||||
|
def reserve_dev(options, dev):
|
||||||
|
reset_dev(options,dev)
|
||||||
|
cmd = options["--sg_persist-path"] + " -n -o -R -T 5 -K " + options["--key"] + " -d " + dev
|
||||||
|
- return not bool(run_cmd(options, cmd)["err"])
|
||||||
|
+ return not bool(run_cmd(options, cmd)["rc"])
|
||||||
|
|
||||||
|
|
||||||
|
def get_reservation_key(options, dev, fail=True):
|
||||||
|
@@ -201,7 +203,7 @@
|
||||||
|
opts = "-y "
|
||||||
|
cmd = options["--sg_persist-path"] + " -n -i " + opts + "-k -d " + dev
|
||||||
|
out = run_cmd(options, cmd)
|
||||||
|
- if out["err"]:
|
||||||
|
+ if out["rc"]:
|
||||||
|
fail_usage("Cannot get registration keys", fail)
|
||||||
|
if not fail:
|
||||||
|
return []
|
||||||
|
@@ -319,7 +321,7 @@
|
||||||
|
"--options vg_attr,pv_name "+\
|
||||||
|
"--config 'global { locking_type = 0 } devices { preferred_names = [ \"^/dev/dm\" ] }'"
|
||||||
|
out = run_cmd(options, cmd)
|
||||||
|
- if out["err"]:
|
||||||
|
+ if out["rc"]:
|
||||||
|
fail_usage("Failed: Cannot get shared devices")
|
||||||
|
for line in out["out"].splitlines():
|
||||||
|
vg_attr, pv_name = line.strip().split(":")
|
23
RHEL-96179-fence_kubevirt-force-off.patch
Normal file
23
RHEL-96179-fence_kubevirt-force-off.patch
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
From b6e05c57a73e5d9bdde7d133ba7ec43737a7c6b7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
|
||||||
|
Date: Tue, 25 Feb 2025 16:11:32 +0100
|
||||||
|
Subject: [PATCH] fence_kubevirt: set grace_period_seconds=0 to immediately
|
||||||
|
power off the node
|
||||||
|
|
||||||
|
---
|
||||||
|
agents/kubevirt/fence_kubevirt.py | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/agents/kubevirt/fence_kubevirt.py b/agents/kubevirt/fence_kubevirt.py
|
||||||
|
index e3817b0fb..8ba8ce8db 100755
|
||||||
|
--- a/agents/kubevirt/fence_kubevirt.py
|
||||||
|
+++ b/agents/kubevirt/fence_kubevirt.py
|
||||||
|
@@ -108,7 +108,7 @@ def define_new_opts():
|
||||||
|
def virtctl_vm_action(conn, action, namespace, name, apiversion):
|
||||||
|
path = '/apis/subresources.{api_version}/namespaces/{namespace}/virtualmachines/{name}/{action}'
|
||||||
|
path = path.format(api_version=apiversion, namespace=namespace, name=name, action=action)
|
||||||
|
- return conn.request('put', path, header_params={'accept': '*/*'})
|
||||||
|
+ return conn.request('put', path, header_params={'accept': '*/*'}, body={'gracePeriod': 0} if action == 'stop' else None)
|
||||||
|
|
||||||
|
# Main agent method
|
||||||
|
def main():
|
209
RHEL-99338-fence_aliyun-update.patch
Normal file
209
RHEL-99338-fence_aliyun-update.patch
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
--- a/agents/aliyun/fence_aliyun.py 2025-06-23 12:03:30.176181831 +0200
|
||||||
|
+++ b/agents/aliyun/fence_aliyun.py 2025-06-23 12:04:38.243037392 +0200
|
||||||
|
@@ -1,53 +1,67 @@
|
||||||
|
#!@PYTHON@ -tt
|
||||||
|
|
||||||
|
-import sys, re
|
||||||
|
+import sys
|
||||||
|
import logging
|
||||||
|
import atexit
|
||||||
|
import json
|
||||||
|
+
|
||||||
|
sys.path.append("@FENCEAGENTSLIBDIR@")
|
||||||
|
from fencing import *
|
||||||
|
-from fencing import fail, fail_usage, EC_TIMED_OUT, run_delay
|
||||||
|
+from fencing import fail_usage, run_delay
|
||||||
|
+
|
||||||
|
|
||||||
|
try:
|
||||||
|
sys.path.insert(0, '/usr/lib/fence-agents/bundled/aliyun')
|
||||||
|
from aliyunsdkcore import client
|
||||||
|
from aliyunsdkcore.auth.credentials import EcsRamRoleCredential
|
||||||
|
+ from aliyunsdkcore.profile import region_provider
|
||||||
|
+except ImportError as e:
|
||||||
|
+ logging.warning("The 'aliyunsdkcore' module has been not installed or is unavailable, try to execute the command 'pip install aliyun-python-sdk-core --upgrade' to solve. error: %s" % e)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+try:
|
||||||
|
from aliyunsdkecs.request.v20140526.DescribeInstancesRequest import DescribeInstancesRequest
|
||||||
|
from aliyunsdkecs.request.v20140526.StartInstanceRequest import StartInstanceRequest
|
||||||
|
from aliyunsdkecs.request.v20140526.StopInstanceRequest import StopInstanceRequest
|
||||||
|
from aliyunsdkecs.request.v20140526.RebootInstanceRequest import RebootInstanceRequest
|
||||||
|
- from aliyunsdkcore.profile import region_provider
|
||||||
|
-except ImportError:
|
||||||
|
- pass
|
||||||
|
+except ImportError as e:
|
||||||
|
+ logging.warning("The 'aliyunsdkecs' module has been not installed or is unavailable, try to execute the command 'pip install aliyun-python-sdk-ecs --upgrade' to solve. error: %s" % e)
|
||||||
|
+
|
||||||
|
|
||||||
|
def _send_request(conn, request):
|
||||||
|
+ logging.debug("send request action: %s" % request.get_action_name())
|
||||||
|
request.set_accept_format('json')
|
||||||
|
try:
|
||||||
|
response_str = conn.do_action_with_exception(request)
|
||||||
|
- response_detail = json.loads(response_str)
|
||||||
|
- logging.debug("_send_request reponse: %s" % response_detail)
|
||||||
|
- return response_detail
|
||||||
|
except Exception as e:
|
||||||
|
- fail_usage("Failed: _send_request failed: %s" % e)
|
||||||
|
+ fail_usage("Failed: send request failed: Error: %s" % e)
|
||||||
|
+
|
||||||
|
+ response_detail = json.loads(response_str)
|
||||||
|
+ logging.debug("reponse: %s" % response_detail)
|
||||||
|
+ return response_detail
|
||||||
|
|
||||||
|
def start_instance(conn, instance_id):
|
||||||
|
+ logging.debug("start instance %s" % instance_id)
|
||||||
|
request = StartInstanceRequest()
|
||||||
|
request.set_InstanceId(instance_id)
|
||||||
|
_send_request(conn, request)
|
||||||
|
|
||||||
|
def stop_instance(conn, instance_id):
|
||||||
|
+ logging.debug("stop instance %s" % instance_id)
|
||||||
|
request = StopInstanceRequest()
|
||||||
|
request.set_InstanceId(instance_id)
|
||||||
|
request.set_ForceStop('true')
|
||||||
|
_send_request(conn, request)
|
||||||
|
|
||||||
|
def reboot_instance(conn, instance_id):
|
||||||
|
+ logging.debug("reboot instance %s" % instance_id)
|
||||||
|
request = RebootInstanceRequest()
|
||||||
|
request.set_InstanceId(instance_id)
|
||||||
|
request.set_ForceStop('true')
|
||||||
|
_send_request(conn, request)
|
||||||
|
|
||||||
|
def get_status(conn, instance_id):
|
||||||
|
+ logging.debug("get instance %s status" % instance_id)
|
||||||
|
request = DescribeInstancesRequest()
|
||||||
|
request.set_InstanceIds(json.dumps([instance_id]))
|
||||||
|
response = _send_request(conn, request)
|
||||||
|
@@ -59,20 +73,30 @@
|
||||||
|
return instance_status
|
||||||
|
|
||||||
|
def get_nodes_list(conn, options):
|
||||||
|
+ logging.debug("start to get nodes list")
|
||||||
|
result = {}
|
||||||
|
request = DescribeInstancesRequest()
|
||||||
|
request.set_PageSize(100)
|
||||||
|
+
|
||||||
|
+ if "--filter" in options:
|
||||||
|
+ filter_key = options["--filter"].split("=")[0].strip()
|
||||||
|
+ filter_value = options["--filter"].split("=")[1].strip()
|
||||||
|
+ params = request.get_query_params()
|
||||||
|
+ params[filter_key] = filter_value
|
||||||
|
+ request.set_query_params(params)
|
||||||
|
+
|
||||||
|
response = _send_request(conn, request)
|
||||||
|
- instance_status = None
|
||||||
|
if response is not None:
|
||||||
|
instance_list = response.get('Instances').get('Instance')
|
||||||
|
for item in instance_list:
|
||||||
|
instance_id = item.get('InstanceId')
|
||||||
|
instance_name = item.get('InstanceName')
|
||||||
|
result[instance_id] = (instance_name, None)
|
||||||
|
+ logging.debug("get nodes list: %s" % result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def get_power_status(conn, options):
|
||||||
|
+ logging.debug("start to get power(%s) status" % options["--plug"])
|
||||||
|
state = get_status(conn, options["--plug"])
|
||||||
|
|
||||||
|
if state == "Running":
|
||||||
|
@@ -81,14 +105,11 @@
|
||||||
|
status = "off"
|
||||||
|
else:
|
||||||
|
status = "unknown"
|
||||||
|
-
|
||||||
|
- logging.info("get_power_status: %s" % status)
|
||||||
|
-
|
||||||
|
+ logging.debug("the power(%s) status is %s" % (options["--plug"], status))
|
||||||
|
return status
|
||||||
|
|
||||||
|
-
|
||||||
|
def set_power_status(conn, options):
|
||||||
|
- logging.info("set_power_status: %s" % options["--action"])
|
||||||
|
+ logging.info("start to set power(%s) status to %s" % (options["--plug"], options["--action"]))
|
||||||
|
|
||||||
|
if (options["--action"]=="off"):
|
||||||
|
stop_instance(conn, options["--plug"])
|
||||||
|
@@ -97,7 +118,6 @@
|
||||||
|
elif (options["--action"]=="reboot"):
|
||||||
|
reboot_instance(conn, options["--plug"])
|
||||||
|
|
||||||
|
-
|
||||||
|
def define_new_opts():
|
||||||
|
all_opt["region"] = {
|
||||||
|
"getopt" : "r:",
|
||||||
|
@@ -126,17 +146,42 @@
|
||||||
|
all_opt["ram_role"] = {
|
||||||
|
"getopt": ":",
|
||||||
|
"longopt": "ram-role",
|
||||||
|
- "help": "--ram-role=[name] Ram Role",
|
||||||
|
+ "help": "--ram-role=[name] Ram Role",
|
||||||
|
"shortdesc": "Ram Role.",
|
||||||
|
"required": "0",
|
||||||
|
"order": 5
|
||||||
|
}
|
||||||
|
+ all_opt["credentials_file"] = {
|
||||||
|
+ "getopt": ":",
|
||||||
|
+ "longopt": "credentials-file",
|
||||||
|
+ "help": "--credentials-file=[path] Path to aliyun-cli credentials file",
|
||||||
|
+ "shortdesc": "Path to credentials file",
|
||||||
|
+ "required": "0",
|
||||||
|
+ "order": 6
|
||||||
|
+ }
|
||||||
|
+ all_opt["credentials_file_profile"] = {
|
||||||
|
+ "getopt": ":",
|
||||||
|
+ "longopt": "credentials-file-profile",
|
||||||
|
+ "help": "--credentials-file-profile=[profile] Credentials file profile",
|
||||||
|
+ "shortdesc": "Credentials file profile",
|
||||||
|
+ "required": "0",
|
||||||
|
+ "default": "default",
|
||||||
|
+ "order": 7
|
||||||
|
+ }
|
||||||
|
+ all_opt["filter"] = {
|
||||||
|
+ "getopt": ":",
|
||||||
|
+ "longopt": "filter",
|
||||||
|
+ "help": "--filter=[key=value] Filter (e.g. InstanceIds=[\"i-XXYYZZAA1\",\"i-XXYYZZAA2\"]",
|
||||||
|
+ "shortdesc": "Filter for list-action.",
|
||||||
|
+ "required": "0",
|
||||||
|
+ "order": 8
|
||||||
|
+ }
|
||||||
|
|
||||||
|
# Main agent method
|
||||||
|
def main():
|
||||||
|
conn = None
|
||||||
|
|
||||||
|
- device_opt = ["port", "no_password", "region", "access_key", "secret_key", "ram_role"]
|
||||||
|
+ device_opt = ["port", "no_password", "region", "access_key", "secret_key", "ram_role", "credentials_file", "credentials_file_profile", "filter"]
|
||||||
|
|
||||||
|
atexit.register(atexit_handler)
|
||||||
|
|
||||||
|
@@ -164,8 +209,25 @@
|
||||||
|
ram_role = options["--ram-role"]
|
||||||
|
role = EcsRamRoleCredential(ram_role)
|
||||||
|
conn = client.AcsClient(region_id=region, credential=role)
|
||||||
|
- region_provider.modify_point('Ecs', region, 'ecs.%s.aliyuncs.com' % region)
|
||||||
|
-
|
||||||
|
+ elif "--credentials-file" in options and "--credentials-file-profile" in options:
|
||||||
|
+ import os, configparser
|
||||||
|
+ try:
|
||||||
|
+ config = configparser.ConfigParser()
|
||||||
|
+ config.read(os.path.expanduser(options["--credentials-file"]))
|
||||||
|
+ access_key = config.get(options["--credentials-file-profile"], "aliyun_access_key_id")
|
||||||
|
+ secret_key = config.get(options["--credentials-file-profile"], "aliyun_access_key_secret")
|
||||||
|
+ conn = client.AcsClient(access_key, secret_key, region)
|
||||||
|
+ except Exception as e:
|
||||||
|
+ fail_usage("Failed: failed to read credentials file: %s" % e)
|
||||||
|
+ else:
|
||||||
|
+ fail_usage("Failed: User credentials are not set. Please set the Access Key and the Secret Key, or configure the RAM role.")
|
||||||
|
+
|
||||||
|
+ # Use intranet endpoint to access ECS service
|
||||||
|
+ try:
|
||||||
|
+ region_provider.modify_point('Ecs', region, 'ecs.%s.aliyuncs.com' % region)
|
||||||
|
+ except Exception as e:
|
||||||
|
+ logging.warning("Failed: failed to modify endpoint to 'ecs.%s.aliyuncs.com': %s" % (region, e))
|
||||||
|
+
|
||||||
|
# Operate the fencing device
|
||||||
|
result = fence_action(conn, options, set_power_status, get_power_status, get_nodes_list)
|
||||||
|
sys.exit(result)
|
@ -1,4 +0,0 @@
|
|||||||
azure-mgmt-compute
|
|
||||||
azure-mgmt-network
|
|
||||||
azure-identity
|
|
||||||
msrestazure
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user