2 # vim:set ts=4 sw=4 expandtab:
7 # NodeManager plugin to support mapping unused raw disks into a slice
8 # that has the rawdisk sliver tag
11 Raw disk support for NodeManager.
13 Copies all unused devices into slices with the rawdisk attribute set.
24 def start(options, config):
25 logger.log("rawdisk: plugin starting up...")
27 def get_unused_devices():
29 if os.path.exists("/dev/mapper/planetlab-rawdisk"):
30 devices.append("/dev/mapper/planetlab-rawdisk")
31 # Figure out which partitions are part of the VG
33 for i in os.listdir("/sys/block"):
34 if not i.startswith("dm-"):
36 in_vg.extend(os.listdir("/sys/block/%s/slaves" % i))
37 # Read the list of partitions
38 partitions = file("/proc/partitions", "r")
39 pat = re.compile("\s+")
41 buf = partitions.readline()
45 fields = re.split(pat, buf)
47 if not dev.startswith("dm-") and dev.endswith("1") and dev not in in_vg:
48 devices.append("/dev/%s" % dev)
52 def GetSlivers(data, config=None, plc=None):
53 if 'slivers' not in data:
54 logger.log_missing_data("rawdisk.GetSlivers",'slivers')
57 devices = get_unused_devices()
58 for sliver in data['slivers']:
59 for attribute in sliver['attributes']:
60 name = attribute.get('tagname',attribute.get('name',''))
64 path = "/vservers/%s%s" % (sliver['name'], i)
65 if os.path.exists(path):
66 # should check whether its the proper type of device
69 logger.log("rawdisk: Copying %s to %s" % (i, path))
71 if os.path.exists(path):
75 os.mknod(path, st.st_mode, st.st_rdev)