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