try to support ephemeral0.1 in cc_mounts

This commit is contained in:
Scott Moser
2013-10-04 17:29:25 -04:00
parent cb1dd63583
commit cc44ef561f
2 changed files with 83 additions and 84 deletions

View File

@@ -1835,40 +1835,3 @@ def expand_dotted_devname(dotted):
return toks
else:
return (dotted, None)
def devnode_for_dev_part(device, partition):
"""
Find the name of the partition. While this might seem rather
straight forward, its not since some devices are '<device><partition>'
while others are '<device>p<partition>'. For example, /dev/xvda3 on EC2
will present as /dev/xvda3p1 for the first partition since /dev/xvda3 is
a block device.
"""
if not os.path.exists(device):
return None
if not partition:
return device
short_name = os.path.basename(device)
sys_path = "/sys/block/%s" % short_name
if not os.path.exists(sys_path):
LOG.debug("did not find entry for %s in /sys/block", short_name)
return None
sys_long_path = sys_path + "/" + short_name
valid_mappings = [sys_long_path + "%s" % partition,
sys_long_path + "p%s" % partition]
for cdisk in valid_mappings:
if not os.path.exists(cdisk):
continue
dev_path = "/dev/%s" % os.path.basename(cdisk)
if os.path.exists(dev_path):
return dev_path
LOG.debug("Did not fine partition %s for device %s", partition, device)
return None