From d6b9b25fda0b6d6de5fefaa2a9fe51964b777c45 Mon Sep 17 00:00:00 2001 From: Mark Syms Date: Thu, 21 Mar 2019 16:51:58 +0000 Subject: [PATCH] CA-310173: remember multipath status with static vdi data Signed-off-by: Mark Syms --- scripts/static-vdis | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/static-vdis b/scripts/static-vdis index 58cd6103277..cc6a05d0384 100755 --- a/scripts/static-vdis +++ b/scripts/static-vdis @@ -3,6 +3,7 @@ # Common functions for managing statically-attached (ie onboot, without xapi) VDIs import sys, os, subprocess, json, urlparse, itertools +import os.path import time import XenAPI, inventory, xmlrpclib @@ -11,6 +12,8 @@ main_dir = "/etc/xensource/static-vdis" xapi_storage_script = "/usr/libexec/xapi-storage-script" smapiv3_config = "device-config" +MULTIPATH_FLAG = "/var/run/nonpersistent/multipath_enabled" + def call_volume_plugin(name, command, args): cmd_args = [(xapi_storage_script + "/volume/org.xen.xapi.storage." + name + "/" + command), "static-vdis"] @@ -175,6 +178,7 @@ def add(session, vdi_uuid, reason): stat = call_volume_plugin(ty, "Volume.stat", [ sr, location ]) data["volume-uri"] = stat["uri"][0] data["volume-key"] = stat["key"] + data["multipath"] = json.dumps(os.path.exists(MULTIPATH_FLAG)) else: # SMAPIv1 try: @@ -286,7 +290,12 @@ def attach(vdi_uuid): configuration = json.loads(read_whole_file(d + "/" + smapiv3_config)) vol_key = read_whole_file(d + "/volume-key") vol_uri = read_whole_file(d + "/volume-uri") + multipath = json.loads(read_whole_file(d + "/multipath")) scheme = urlparse.urlparse(vol_uri).scheme + # Set the multipath flag if required + if multipath: + with open(MULTIPATH_FLAG, 'a'): + os.utime(MULTIPATH_FLAG, None) sr = sr_attach(volume_plugin, configuration) attach = call_datapath_plugin(scheme, "Datapath.attach", [ vol_uri, "0" ]) (name, implementation) = \