Skip to content

Commit

Permalink
Add DevMapper bs.
Browse files Browse the repository at this point in the history
  • Loading branch information
alenz33 committed Mar 31, 2015
1 parent c22bd69 commit 82e7c19
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
45 changes: 42 additions & 3 deletions conduct/buildsteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from conduct.param import Parameter, oneof, none_or, dictof, listof, tupleof

__all__ = ['BuildStep', 'SystemCall', 'Config', 'TmpDir', 'RmPath',
'Partitioning']
'Partitioning', 'DevMapper']


class BuildStepMeta(type):
Expand Down Expand Up @@ -418,8 +418,7 @@ def run(self):
shCmd = '(%s)' % ''.join([ 'echo %s;' % entry for entry in cmds])
shCmd += '| fdisk %s 2>&1' % self.dev

output = systemCall(shCmd, captureOutput=True, log=self.log)
self.log.debug(output)
systemCall(shCmd, captureOutput=True, log=self.log)

def _createPartitionCmds(self, index, size):
cmds = [
Expand All @@ -438,6 +437,46 @@ def _createPartitionCmds(self, index, size):

return cmds

class DevMapper(BuildStep):
'''
This build step uses kpartx (devmapper) to map the partitions of the given
device to own device files.
'''
parameters = {
'dev' : Parameter(type=str,
description='Path to the device file'),
}

outparameters = {
'mapped' : Parameter(type=list,
description='Created device files',)
}

def run(self):
# create device files
systemCall('kpartx -v -a -s %s' % self.dev,
captureOutput=True,
log=self.log)

# request a proper formated list of devs
out = systemCall('kpartx -v -l -s %s' % self.dev,
captureOutput=True,
log=self.log)

# store created device file paths
self.mapped = []
for line in out.splitlines():
devFile = line.rpartition(':')[0].strip()
self.mapped.append(path.join('/dev/mapper', devFile))

def cleanup(self):
systemCall('kpartx -v -d -s %s' % self.dev,
captureOutput=True,
log=self.log)







Expand Down
4 changes: 4 additions & 0 deletions etc/chains/frm2/boximg.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@
dev='{steps.tmpdir.tmpdir}/{chain.imgname}.img',
partitions=[3,5])

steps.devmap = Step('conduct.DevMapper',
description='Map new image partitions to device files',
dev='{steps.tmpdir.tmpdir}/{chain.imgname}.img')


0 comments on commit 82e7c19

Please sign in to comment.