File 0004-fence_compute-Fix-handling-of-domain-None.patch of Package fence-agents.openSUSE_Leap_42.3_Update

From bf16b0230caff84fa902340136377f7b510ec09d Mon Sep 17 00:00:00 2001
From: Vincent Untz <vuntz@suse.com>
Date: Wed, 29 Jun 2016 09:43:57 +0200
Subject: [PATCH 4/7] fence_compute: Fix handling of domain == None

---
 fence/agents/compute/fence_compute.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Index: fence-agents-4.0.25+git.1485179354.eb43835/fence/agents/compute/fence_compute.py
===================================================================
--- fence-agents-4.0.25+git.1485179354.eb43835.orig/fence/agents/compute/fence_compute.py
+++ fence-agents-4.0.25+git.1485179354.eb43835/fence/agents/compute/fence_compute.py
@@ -252,20 +252,18 @@ def fix_domain(options):
 
 	elif len(domains) == 1 and "--domain" not in options:
 		options["--domain"] = last_domain
-		return options["--domain"]
 
 	elif len(domains) == 1 and options["--domain"] != last_domain:
 		logging.error("Overriding supplied domain '%s' as it does not match the one calculated from: %s"
 			      % (options["--domain"], service.host))
 		options["--domain"] = last_domain
-		return options["--domain"]
 
 	elif len(domains) > 1:
 		logging.error("The supplied domain '%s' did not match any used inside nova: %s"
 			      % (options["--domain"], repr(domains)))
 		sys.exit(1)
 
-	return None
+	return last_domain
 
 def fix_plug_name(options):
 	if options["--action"] == "list":
@@ -275,14 +273,15 @@ def fix_plug_name(options):
 		return
 
 	calculated = fix_domain(options)
-	short_plug = options["--plug"].split('.')[0]
-	logging.debug("Checking target '%s' against calculated domain '%s'"% (options["--plug"], options["--domain"]))
 
-	if "--domain" not in options:
+	if calculated is None or "--domain" not in options:
 		# Nothing supplied and nova not available... what to do... nothing
 		return
 
-	elif options["--domain"] == "":
+	short_plug = options["--plug"].split('.')[0]
+	logging.debug("Checking target '%s' against calculated domain '%s'"% (options["--plug"], calculated))
+
+	if options["--domain"] == "":
 		# Ensure any domain is stripped off since nova isn't using FQDN
 		options["--plug"] = short_plug
 
openSUSE Build Service is sponsored by