Skip to content

Commit

Permalink
Merge pull request #3833 from MarkSymsCtx/1.160-lcm
Browse files Browse the repository at this point in the history
CA-310173: remember multipath status with static vdi data
  • Loading branch information
edwintorok authored Mar 21, 2019
2 parents 4ac33cd + d6b9b25 commit f5ae6cc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/static-vdis
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"]
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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) = \
Expand Down

0 comments on commit f5ae6cc

Please sign in to comment.