- fence_kubevirt: new fence agent
Resolves: rhbz#2000954
This commit is contained in:
parent
a54cc9d046
commit
d306c0c4c1
102
bz2000954-3-fence_kubevirt-get-namespace-from-context.patch
Normal file
102
bz2000954-3-fence_kubevirt-get-namespace-from-context.patch
Normal file
@ -0,0 +1,102 @@
|
||||
From 647841dea9d93922779a4aa7d0b5f52f5bc2b4e9 Mon Sep 17 00:00:00 2001
|
||||
From: Dan Kenigsberg <danken@redhat.com>
|
||||
Date: Thu, 13 Jan 2022 14:57:26 +0200
|
||||
Subject: [PATCH] fence_kubevirt: take default namespace from context
|
||||
|
||||
If --namespace is not provided to kubectl, a default one is taken from
|
||||
kubeconfig context. Let fence_kubevirt behave similarly.
|
||||
|
||||
Signed-off-by: Dan Kenigsberg <danken@redhat.com>
|
||||
---
|
||||
agents/kubevirt/fence_kubevirt.py | 24 +++++++++++++-----------
|
||||
tests/data/metadata/fence_kubevirt.xml | 2 +-
|
||||
2 files changed, 14 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/agents/kubevirt/fence_kubevirt.py b/agents/kubevirt/fence_kubevirt.py
|
||||
index 8392b75a0..8c27a0334 100755
|
||||
--- a/agents/kubevirt/fence_kubevirt.py
|
||||
+++ b/agents/kubevirt/fence_kubevirt.py
|
||||
@@ -12,12 +12,21 @@
|
||||
except ImportError:
|
||||
logging.error("Couldn\'t import kubernetes.client.exceptions.ApiException - not found or not accessible")
|
||||
|
||||
+def _get_namespace(options):
|
||||
+ from kubernetes import config
|
||||
+
|
||||
+ ns = options.get("--namespace")
|
||||
+ if ns is None:
|
||||
+ ns = config.kube_config.list_kube_config_contexts()[1]['context']['namespace']
|
||||
+
|
||||
+ return ns
|
||||
+
|
||||
def get_nodes_list(conn, options):
|
||||
logging.debug("Starting list/monitor operation")
|
||||
result = {}
|
||||
try:
|
||||
apiversion = options.get("--apiversion")
|
||||
- namespace = options.get("--namespace")
|
||||
+ namespace = _get_namespace(options)
|
||||
include_uninitialized = True
|
||||
vm_api = conn.resources.get(api_version=apiversion, kind='VirtualMachine')
|
||||
vm_list = vm_api.get(namespace=namespace)
|
||||
@@ -31,7 +40,7 @@ def get_power_status(conn, options):
|
||||
logging.debug("Starting get status operation")
|
||||
try:
|
||||
apiversion = options.get("--apiversion")
|
||||
- namespace = options.get("--namespace")
|
||||
+ namespace = _get_namespace(options)
|
||||
name = options.get("--plug")
|
||||
vmi_api = conn.resources.get(api_version=apiversion,
|
||||
kind='VirtualMachineInstance')
|
||||
@@ -61,7 +70,7 @@ def set_power_status(conn, options):
|
||||
logging.debug("Starting set status operation")
|
||||
try:
|
||||
apiversion= options.get("--apiversion")
|
||||
- namespace = options.get("--namespace")
|
||||
+ namespace = _get_namespace(options)
|
||||
name = options.get("--plug")
|
||||
action = 'start' if options["--action"] == "on" else 'stop'
|
||||
virtctl_vm_action(conn, action, namespace, name, apiversion)
|
||||
@@ -75,7 +84,7 @@ def define_new_opts():
|
||||
"longopt" : "namespace",
|
||||
"help" : "--namespace=[namespace] Namespace of the KubeVirt machine",
|
||||
"shortdesc" : "Namespace of the KubeVirt machine.",
|
||||
- "required" : "1",
|
||||
+ "required" : "0",
|
||||
"order" : 2
|
||||
}
|
||||
all_opt["kubeconfig"] = {
|
||||
@@ -101,11 +110,6 @@ def virtctl_vm_action(conn, action, namespace, name, apiversion):
|
||||
path = path.format(api_version=apiversion, namespace=namespace, name=name, action=action)
|
||||
return conn.request('put', path, header_params={'accept': '*/*'})
|
||||
|
||||
-def validate_options(required_options_list, options):
|
||||
- for required_option in required_options_list:
|
||||
- if required_option not in options:
|
||||
- fail_usage("Failed: %s option must be provided" % required_option)
|
||||
-
|
||||
# Main agent method
|
||||
def main():
|
||||
conn = None
|
||||
@@ -127,8 +131,6 @@ def main():
|
||||
|
||||
run_delay(options)
|
||||
|
||||
- validate_options(['--namespace'], options)
|
||||
-
|
||||
# Disable insecure-certificate-warning message
|
||||
if "--ssl-insecure" in options:
|
||||
import urllib3
|
||||
diff --git a/tests/data/metadata/fence_kubevirt.xml b/tests/data/metadata/fence_kubevirt.xml
|
||||
index 24e975587..ccb20c224 100644
|
||||
--- a/tests/data/metadata/fence_kubevirt.xml
|
||||
+++ b/tests/data/metadata/fence_kubevirt.xml
|
||||
@@ -23,7 +23,7 @@
|
||||
<content type="boolean" />
|
||||
<shortdesc lang="en">Use SSL connection without verifying certificate</shortdesc>
|
||||
</parameter>
|
||||
- <parameter name="namespace" unique="0" required="1">
|
||||
+ <parameter name="namespace" unique="0" required="0">
|
||||
<getopt mixed="--namespace=[namespace]" />
|
||||
<content type="string" />
|
||||
<shortdesc lang="en">Namespace of the KubeVirt machine.</shortdesc>
|
@ -59,7 +59,7 @@
|
||||
Name: fence-agents
|
||||
Summary: Set of unified programs capable of host isolation ("fencing")
|
||||
Version: 4.10.0
|
||||
Release: 14%{?alphatag:.%{alphatag}}%{?dist}
|
||||
Release: 15%{?alphatag:.%{alphatag}}%{?dist}
|
||||
License: GPLv2+ and LGPLv2+
|
||||
URL: https://github.com/ClusterLabs/fence-agents
|
||||
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.gz
|
||||
@ -228,6 +228,7 @@ Patch11: bz2000954-2-fence_kubevirt.patch
|
||||
Patch12: bz2022334-fence_zvmip-add-ssl-tls-support.patch
|
||||
Patch13: bz2029791-1-fence_openstack-add-ssl-insecure.patch
|
||||
Patch14: bz2029791-2-fence_openstack-cacert-default.patch
|
||||
Patch15: bz2000954-3-fence_kubevirt-get-namespace-from-context.patch
|
||||
|
||||
%global supportedagents amt_ws apc apc_snmp bladecenter brocade cisco_mds cisco_ucs compute drac5 eaton_snmp emerson eps evacuate hpblade ibmblade ifmib ilo ilo_moonshot ilo_mp ilo_ssh intelmodular ipdu ipmilan kdump kubevirt lpar mpath redfish rhevm rsa rsb sbd scsi vmware_rest vmware_soap wti
|
||||
%ifarch x86_64
|
||||
@ -338,7 +339,23 @@ BuildRequires: %{systemd_units}
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}-%{version}%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:-%{alphatag}}%{?dirty:-%{dirty}}
|
||||
%autopatch -p1
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
%patch7 -p1
|
||||
%patch8 -p1
|
||||
%patch9 -p1
|
||||
%patch10 -p1
|
||||
%patch11 -p1
|
||||
%patch12 -p1
|
||||
%patch13 -p1
|
||||
%patch14 -p1
|
||||
%patch15 -p1 -F2
|
||||
|
||||
# prevent compilation of something that won't get used anyway
|
||||
sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
|
||||
|
||||
@ -1406,6 +1423,10 @@ are located on corosync cluster nodes.
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Jan 17 2022 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-15
|
||||
- fence_kubevirt: new fence agent
|
||||
Resolves: rhbz#2000954
|
||||
|
||||
* Tue Jan 11 2022 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-14
|
||||
- fence_openstack: add --ssl-insecure
|
||||
Resolves: rhbz#2029791
|
||||
@ -1418,10 +1439,6 @@ are located on corosync cluster nodes.
|
||||
- fence_zvmip: add SSL/TLS support
|
||||
Resolves: rhbz#2022334
|
||||
|
||||
* Mon Nov 8 2021 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-11
|
||||
- fence_kubevirt: new fence agent
|
||||
Resolves: rhbz#2000954
|
||||
|
||||
* Tue Oct 5 2021 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-10
|
||||
- fence_azure_arm: fix sovereign cloud and MSI support
|
||||
Resolves: rhbz#2010652
|
||||
|
Loading…
Reference in New Issue
Block a user