Skip to content

Commit

Permalink
Fix handling for missing params. +CreateFileSystems
Browse files Browse the repository at this point in the history
  • Loading branch information
alenz33 committed Mar 31, 2015
1 parent 82e7c19 commit 18dbfcb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
36 changes: 33 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', 'DevMapper']
'Partitioning', 'DevMapper', 'CreateFileSystem']


class BuildStepMeta(type):
Expand Down Expand Up @@ -236,8 +236,13 @@ def _initLogger(self):
self.log.setLevel(LOGLEVELS[self.loglevel])

def _applyParams(self, paramValues):
for name, value in paramValues.iteritems():
setattr(self, name, value)

for name, paramDef in self.parameters.iteritems():
if name in paramValues:
setattr(self, name, paramValues[name])
elif paramDef.default is None:
raise RuntimeError('%s: Mandatory parameter %s is missing'
% (self.name, name))


class SystemCall(BuildStep):
Expand Down Expand Up @@ -474,6 +479,31 @@ def cleanup(self):
captureOutput=True,
log=self.log)

class CreateFileSystem(BuildStep):
'''
This build step creates the desired file system on the given device.
Used tool: mkfs
'''

parameters = {
'dev' : Parameter(type=str,
description='Path to the device file'),
'fstype' : Parameter(type=oneof('bfs',
'cramfs',
'ext2',
'ext3',
'ext4',
'fat',
'ntfs',
'vfat'),
description='Desired file system'),
}

def run(self):
systemCall('mkfs -t %s %s' % (self.fstype, self.dev),
captureOutput=True,
log=self.log)




Expand Down
10 changes: 10 additions & 0 deletions etc/chains/frm2/boximg.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,14 @@
description='Map new image partitions to device files',
dev='{steps.tmpdir.tmpdir}/{chain.imgname}.img')

steps.mkfs1 = Step('conduct.CreateFileSystem',
description='Create ext2 file systems for first image partition',
dev='{steps.devmap.mapped[0]}',
fstype='ext2')

steps.mkfs2 = Step('conduct.CreateFileSystem',
description='Create ext2 file systems for second image partition',
dev='{steps.devmap.mapped[1]}',
fstype='ext2')


0 comments on commit 18dbfcb

Please sign in to comment.