Advertisement
Guest User

Untitled

a guest
May 20th, 2017
136
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import subprocess, os, uuid, syslog
  2.  
  3. def execute(cmd,shell):
  4. proc = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE)
  5. return proc.communicate()[0].decode()
  6.  
  7. output = execute(['/sbin/vdq','-q'],False)
  8.  
  9. capacityDisk = None
  10. cachingDisk = None
  11. largestDisk = None
  12. largestDiskSize = None
  13. usbDevice = None
  14.  
  15. results = eval(output)
  16. for disk in results:
  17. diskId = disk['Name']
  18.  
  19. if disk['State'] == 'Eligible for use by VSAN':
  20. print(" Found Disk: " + diskId)
  21.  
  22. diskcapacity_cmd = "localcli storage core device capacity list -d " + diskId + " | tail -1 | awk '{print $5}'"
  23. print(" Running disk capacity command: " + diskcapacity_cmd)
  24. ps = subprocess.Popen(diskcapacity_cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
  25. diskSize = ps.communicate()[0].decode().strip()
  26.  
  27. if largestDisk == None:
  28. largestDisk = diskId
  29. largestDiskSize = diskSize
  30. else:
  31. if diskSize > largestDiskSize:
  32. capacityDisk = diskId
  33. cachingDisk = largestDisk
  34. else:
  35. capacityDisk = largestDisk
  36. cachingDisk = diskId
  37.  
  38. print(" Largest Capacity Disk so far: " + diskId + " (" + diskSize + ")")
  39.  
  40.  
  41. if disk['State'] == 'Ineligible for use by VSAN' and disk['VSANUUID'] == "":
  42. usbDevice = diskId
  43. fo = open("/tmp/usbDevice.txt", "w")
  44. fo.write(usbDevice)
  45. fo.close()
  46.  
  47.  
  48. if cachingDisk != None and capacityDisk != None:
  49. # Tag Capacity Disk
  50. disktag_cmd = "localcli vsan storage tag add -d " + capacityDisk + " -t capacityFlash"
  51. print(" Running disk capacity tagging command: " + disktag_cmd)
  52.  
  53. # Create VSAN Disk Group
  54. diskgroup_cmd = "localcli vsan storage add -s " + cachingDisk + " -d " + capacityDisk
  55. print(" Running disk group create command: " + diskgroup_cmd)
Advertisement
RAW Paste Data Copied
Advertisement