Browse code

Edit fstab to include UUID value of disk for ami, gce

Change-Id: I1018c7e3051ae9754ddf96f81209f16a87539a11
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/1692
Reviewed-by: suezzelur <anishs@vmware.com>
Tested-by: suezzelur <anishs@vmware.com>

suezzelur authored on 2016/11/16 08:03:41
Showing 1 changed files
... ...
@@ -110,6 +110,7 @@ if __name__ == '__main__':
110 110
     try:
111 111
         print "Generating PARTUUID for the loop device ..."
112 112
         partuuidval = (utils.runshellcommand("blkid -s PARTUUID -o value {}".format(loop_device_path))).rstrip('\n')
113
+        uuidval = (utils.runshellcommand("blkid -s UUID -o value {}".format(loop_device_path))).rstrip('\n')
113 114
         if (partuuidval == ''):
114 115
             sgdiskout = utils.runshellcommand("sgdisk -i 2 {} ".format(disk_device))
115 116
             partuuidval = (re.findall(r'Partition unique GUID.*', sgdiskout))[0].split(':')[1].strip(' ')
... ...
@@ -130,7 +131,10 @@ if __name__ == '__main__':
130 130
         os.remove(options.mount_path + "/etc/fstab")
131 131
 
132 132
         f = open(options.mount_path + "/etc/fstab", "w")
133
-        f.write("PARTUUID={}    /    ext4    defaults 1 1\n".format(partuuidval))
133
+        if (uuidval != ''):
134
+            f.write("UUID={}    /    ext4    defaults 1 1\n".format(uuidval))
135
+        else:
136
+            f.write("PARTUUID={}    /    ext4    defaults 1 1\n".format(partuuidval))
134 137
         f.close()
135 138
         utils.replaceinfile(options.mount_path + "/boot/grub/grub.cfg", "rootpartition=PARTUUID=.*$", "rootpartition=PARTUUID={}".format(partuuidval))
136 139