-
-
Save mgwilliams/b14abd0b50448844ce60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/salt/modules/qemu_nbd.py b/salt/modules/qemu_nbd.py | |
index 0336db1..6bb5a68 100644 | |
--- a/salt/modules/qemu_nbd.py | |
+++ b/salt/modules/qemu_nbd.py | |
@@ -38,15 +38,20 @@ def connect(image): | |
''' | |
if not os.path.isfile(image): | |
return '' | |
+ | |
+ if salt.utils.which('cfdisk'): | |
+ fdisk = 'cfdisk -P t' | |
+ else: | |
+ fdisk = 'fdisk -l' | |
__salt__['cmd.run']('modprobe nbd max_part=63') | |
for nbd in glob.glob('/dev/nbd?'): | |
- if __salt__['cmd.retcode']('fdisk -l {0}'.format(nbd)): | |
- while True: | |
+ if __salt__['cmd.retcode']('{0} {1}'.format(fdisk, nbd)): | |
+ for _ in range(1, 10): | |
# Sometimes nbd does not "take hold", loop until we can verify | |
__salt__['cmd.run']( | |
'qemu-nbd -c {0} {1}'.format(nbd, image) | |
) | |
- if not __salt__['cmd.retcode']('fdisk -l {0}'.format(nbd)): | |
+ if not __salt__['cmd.retcode']('{0} {1}'.format(fdisk, nbd)): | |
break | |
return nbd | |
return '' | |
@@ -61,6 +66,9 @@ def mount(nbd): | |
salt '*' qemu_nbd.mount /dev/nbd0 | |
''' | |
+ __salt__['cmd.run']( | |
+ 'partprobe {0}'.format(nbd) | |
+ ) | |
ret = {} | |
for part in glob.glob('{0}p*'.format(nbd)): | |
root = os.path.join( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment