2 # vim:set ts=4 sw=4 expandtab:
3 # NodeManager plugin to support mapping unused raw disks into a slice
4 # that has the rawdisk sliver tag
7 Raw disk support for NodeManager.
9 Copies all unused devices into slices with the rawdisk attribute set.
20 def start(options, config):
21 logger.log("rawdisk plugin starting up...")
23 def get_unused_devices():
25 if os.path.exists("/dev/mapper/planetlab-rawdisk"):
26 devices.append("/dev/mapper/planetlab-rawdisk")
27 # Figure out which partitions are part of the VG
29 for i in os.listdir("/sys/block"):
30 if not i.startswith("dm-"):
32 in_vg.extend(os.listdir("/sys/block/%s/slaves" % i))
33 # Read the list of partitions
34 partitions = file("/proc/partitions", "r")
35 pat = re.compile("\s+")
37 buf = partitions.readline()
41 fields = re.split(pat, buf)
43 if not dev.startswith("dm-") and dev.endswith("1") and dev not in in_vg:
44 devices.append("/dev/%s" % dev)
48 def GetSlivers(data, config=None, plc=None):
49 if 'slivers' not in data:
50 logger.log("sliverauth: getslivers data lack's sliver information. IGNORING!")
53 devices = get_unused_devices()
54 for sliver in data['slivers']:
55 for attribute in sliver['attributes']:
56 name = attribute.get('tagname',attribute.get('name',''))
60 path = "/vservers/%s%s" % (sliver['name'], i)
61 if os.path.exists(path):
62 # should check whether its the proper type of device
65 logger.log("Copying %s to %s" % (i, path))
67 if os.path.exists(path):
71 os.mknod(path, st.st_mode, st.st_rdev)