|
|
0d90ce |
diff --git a/fence/agents/compute/fence_compute.py b/fence/agents/compute/fence_compute.py
|
|
|
0d90ce |
index 0a238b6..4b229b0 100644
|
|
|
0d90ce |
--- a/fence/agents/compute/fence_compute.py
|
|
|
0d90ce |
+++ b/fence/agents/compute/fence_compute.py
|
|
|
0d90ce |
@@ -4,6 +4,7 @@ import sys
|
|
|
0d90ce |
import time
|
|
|
0d90ce |
import atexit
|
|
|
0d90ce |
import logging
|
|
|
0d90ce |
+import inspect
|
|
|
0d90ce |
import requests.exceptions
|
|
|
0d90ce |
|
|
|
0d90ce |
sys.path.append("@FENCEAGENTSLIBDIR@")
|
|
|
0d90ce |
@@ -310,15 +311,46 @@ def create_nova_connection(options):
|
|
|
0d90ce |
|
|
|
0d90ce |
versions = [ "2.11", "2" ]
|
|
|
0d90ce |
for version in versions:
|
|
|
0d90ce |
- nova = client.Client(version,
|
|
|
0d90ce |
- options["--username"],
|
|
|
0d90ce |
- options["--password"],
|
|
|
0d90ce |
- options["--tenant-name"],
|
|
|
0d90ce |
- options["--auth-url"],
|
|
|
0d90ce |
- insecure=options["--insecure"],
|
|
|
0d90ce |
- region_name=options["--region-name"],
|
|
|
0d90ce |
- endpoint_type=options["--endpoint-type"],
|
|
|
0d90ce |
- http_log_debug=options.has_key("--verbose"))
|
|
|
0d90ce |
+ clientargs = inspect.getargspec(client.Client).varargs
|
|
|
0d90ce |
+
|
|
|
0d90ce |
+ # Some versions of Openstack prior to Ocata only
|
|
|
0d90ce |
+ # supported positional arguments for username,
|
|
|
0d90ce |
+ # password and tenant.
|
|
|
0d90ce |
+ #
|
|
|
0d90ce |
+ # Versions since Ocata only support named arguments.
|
|
|
0d90ce |
+ #
|
|
|
0d90ce |
+ # So we need to use introspection to figure out how to
|
|
|
0d90ce |
+ # create a Nova client.
|
|
|
0d90ce |
+ #
|
|
|
0d90ce |
+ # Happy days
|
|
|
0d90ce |
+ #
|
|
|
0d90ce |
+ if clientargs:
|
|
|
0d90ce |
+ # OSP < 11
|
|
|
0d90ce |
+ # ArgSpec(args=['version', 'username', 'password', 'project_id', 'auth_url'],
|
|
|
0d90ce |
+ # varargs=None,
|
|
|
0d90ce |
+ # keywords='kwargs', defaults=(None, None, None, None))
|
|
|
0d90ce |
+ nova = client.Client(version,
|
|
|
0d90ce |
+ options["--username"],
|
|
|
0d90ce |
+ options["--password"],
|
|
|
0d90ce |
+ options["--tenant-name"],
|
|
|
0d90ce |
+ options["--auth-url"],
|
|
|
0d90ce |
+ insecure=options["--insecure"],
|
|
|
0d90ce |
+ region_name=options["--region-name"],
|
|
|
0d90ce |
+ endpoint_type=options["--endpoint-type"],
|
|
|
0d90ce |
+ http_log_debug=options.has_key("--verbose"))
|
|
|
0d90ce |
+ else:
|
|
|
0d90ce |
+ # OSP >= 11
|
|
|
0d90ce |
+ # ArgSpec(args=['version'], varargs='args', keywords='kwargs', defaults=None)
|
|
|
0d90ce |
+ nova = client.Client(version,
|
|
|
0d90ce |
+ username=options["--username"],
|
|
|
0d90ce |
+ password=options["--password"],
|
|
|
0d90ce |
+ tenant_name=options["--tenant-name"],
|
|
|
0d90ce |
+ auth_url=options["--auth-url"],
|
|
|
0d90ce |
+ insecure=options["--insecure"],
|
|
|
0d90ce |
+ region_name=options["--region-name"],
|
|
|
0d90ce |
+ endpoint_type=options["--endpoint-type"],
|
|
|
0d90ce |
+ http_log_debug=options.has_key("--verbose"))
|
|
|
0d90ce |
+
|
|
|
0d90ce |
try:
|
|
|
0d90ce |
nova.hypervisors.list()
|
|
|
0d90ce |
return
|
|
|
0d90ce |
@@ -329,7 +361,7 @@ def create_nova_connection(options):
|
|
|
0d90ce |
except Exception as e:
|
|
|
0d90ce |
logging.warning("Nova connection failed. %s: %s" % (e.__class__.__name__, e))
|
|
|
0d90ce |
|
|
|
0d90ce |
- fail_usage("Couldn't obtain a supported connection to nova, tried: %s" % repr(versions))
|
|
|
0d90ce |
+ logging.warning("Couldn't obtain a supported connection to nova, tried: %s\n" % repr(versions))
|
|
|
0d90ce |
|
|
|
0d90ce |
def define_new_opts():
|
|
|
0d90ce |
all_opt["endpoint-type"] = {
|
|
|
0d90ce |
@@ -417,7 +449,7 @@ def main():
|
|
|
0d90ce |
global override_status
|
|
|
0d90ce |
atexit.register(atexit_handler)
|
|
|
0d90ce |
|
|
|
0d90ce |
- device_opt = ["login", "passwd", "tenant-name", "auth-url", "fabric_fencing", "on_target",
|
|
|
0d90ce |
+ device_opt = ["login", "passwd", "tenant-name", "auth-url", "fabric_fencing",
|
|
|
0d90ce |
"no_login", "no_password", "port", "domain", "no-shared-storage", "endpoint-type",
|
|
|
0d90ce |
"record-only", "instance-filtering", "insecure", "region-name"]
|
|
|
0d90ce |
define_new_opts()
|