-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken fence_xenapi.py #559
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,9 +127,14 @@ def connect_and_login(options): | |
username = options["--username"] | ||
password = options["--password"] | ||
|
||
# Allow bypassing SSL verification for hosts without SSL certificates | ||
skipVerification = False | ||
if "--ssl-insecure" in options: | ||
skipVerification = True | ||
|
||
try: | ||
# Create the XML RPC session to the specified URL. | ||
session = XenAPI.Session(url) | ||
session = XenAPI.Session(url, None, None, 0, 1, skipVerification) | ||
# Login using the supplied credentials. | ||
session.xenapi.login_with_password(username, password) | ||
except Exception as exn: | ||
|
@@ -191,23 +196,42 @@ def return_vm_reference(session, options): | |
# to the VM). | ||
raise Exception("VM_LOGIC_ERROR") | ||
|
||
def define_new_opts(): | ||
all_opt["uuid"] = { | ||
"getopt" : ":", | ||
"longopt" : "uuid", | ||
"help" : "--uuid=[VM UUID] The VM UUID.", | ||
"default" : "", | ||
"required" : "0", | ||
"shortdesc" : "The VM UUID", | ||
"order" : 2} | ||
all_opt["plug-separator"] = { | ||
"getopt" : ":", | ||
"longopt" : "plug-separator", | ||
"help" : "--plug-separator=separator The saparator for multiple plugs.", | ||
"default" : ":", | ||
"required" : "0", | ||
"shortdesc" : "The saparator for multiple plugs", | ||
"order" : 3} | ||
|
||
def main(): | ||
|
||
device_opt = ["login", "passwd", "port", "no_login", "no_password", "session_url", "web"] | ||
device_opt = ["login", "passwd", "port", "no_login", "no_password", "session_url", "web", "ssl", "uuid", "plug_separator"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. plug_separator is included in "port" from fencing.py, so you can remove that and it's definition above. uuid isnt neither either, as the fencing library sets it based on the --plug/-n parameter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't get it to work without these two parameters. Maybe I'm just testing it wrong? This way works for me and I have no way of validating other solutions, so someone else might need to take over this pull request (or just delete it if you prefer). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably need to update your systems fencing library (usually located in /usr/share/fence). |
||
|
||
atexit.register(atexit_handler) | ||
define_new_opts() | ||
|
||
options = check_input(device_opt, process_input(device_opt)) | ||
|
||
docs = {} | ||
docs["shortdesc"] = "Fence agent for Citrix XenServer over XenAPI" | ||
docs["longdesc"] = "\ | ||
fence_cxs is an I/O Fencing agent used on Citrix XenServer hosts. \ | ||
fence_xenapi is an I/O Fencing agent used on Citrix XenServer and XCP-ng hosts. \ | ||
It uses the XenAPI, supplied by Citrix, to establish an XML-RPC session \ | ||
to a XenServer host. Once the session is established, further XML-RPC \ | ||
commands are issued in order to switch on, switch off, restart and query \ | ||
the status of virtual machines running on the host." | ||
docs["vendorurl"] = "http://www.xenproject.org" | ||
docs["vendorurl"] = "https://xenproject.org" | ||
show_docs(options, docs) | ||
|
||
run_delay(options) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Session() doesnt appear to have a parameter for skipVerification:
https://github.com/ClusterLabs/fence-agents/blob/main/lib/XenAPI.py.py#L121
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the XenAPI library bundled in this repo is significantly outdated. The latest version from https://github.com/xapi-project/xen-api/blob/master/scripts/examples/python/XenAPI/XenAPI.py should be loaded instead.