summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mic/imager/baseimager.py14
-rw-r--r--mic/imager/loop.py4
-rwxr-xr-xmic/imager/raw.py3
-rw-r--r--mic/kickstart/custom_commands/partition.py5
4 files changed, 25 insertions, 1 deletions
diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py
index 2d0a03d..5ace0e2 100644
--- a/mic/imager/baseimager.py
+++ b/mic/imager/baseimager.py
@@ -1209,6 +1209,18 @@ class BaseImageCreator(object):
f.write("%s %s" % (md5sum, os.path.basename(image_name)))
self.outimage.append(image_name+".md5sum")
+ def remove_exclude_image(self):
+ for item in self._instloops[:]:
+ if item['exclude_image']:
+ msger.info("Removing %s in image." % item['name'])
+ imgfile = os.path.join(self._imgdir, item['name'])
+ try:
+ os.remove(imgfile)
+ except OSError as err:
+ if err.errno == errno.ENOENT:
+ pass
+ self._instloops.remove(item)
+
def package(self, destdir = "."):
"""Prepares the created image for final delivery.
@@ -1221,6 +1233,8 @@ class BaseImageCreator(object):
this defaults to the current directory.
"""
+ self.remove_exclude_image()
+
self._stage_final_image()
if not os.path.exists(destdir):
diff --git a/mic/imager/loop.py b/mic/imager/loop.py
index 51d8181..0943ec7 100644
--- a/mic/imager/loop.py
+++ b/mic/imager/loop.py
@@ -157,6 +157,7 @@ class LoopImageCreator(BaseImageCreator):
'loop': None, # to be created in _mount_instroot
'uuid': part.uuid or None,
'kspart' : part,
+ 'exclude_image' : part.exclude_image or None,
})
self._instloops = allloops
@@ -329,7 +330,8 @@ class LoopImageCreator(BaseImageCreator):
"extopts": None,
"loop": None,
"uuid": None,
- "kspart": None
+ "kspart": None,
+ "exclude_image" : None
})
self._check_imgdir()
diff --git a/mic/imager/raw.py b/mic/imager/raw.py
index 08f9683..82e9a16 100755
--- a/mic/imager/raw.py
+++ b/mic/imager/raw.py
@@ -597,3 +597,6 @@ class RawImageCreator(BaseImageCreator):
if self.compress_image:
self.image_files.update({'compress': self.compress_image})
super(RawImageCreator, self).create_manifest()
+
+ def remove_exclude_image(self):
+ pass
diff --git a/mic/kickstart/custom_commands/partition.py b/mic/kickstart/custom_commands/partition.py
index d4c39bf..89dad58 100644
--- a/mic/kickstart/custom_commands/partition.py
+++ b/mic/kickstart/custom_commands/partition.py
@@ -28,6 +28,7 @@ class Mic_PartData(FC4_PartData):
self.extopts = kwargs.get("extopts", None)
self.part_type = kwargs.get("part_type", None)
self.uuid = kwargs.get("uuid", None)
+ self.exclude_image = kwargs.get("exclude_from_image", False)
def _getArgsAsStr(self):
retval = FC4_PartData._getArgsAsStr(self)
@@ -40,6 +41,8 @@ class Mic_PartData(FC4_PartData):
retval += " --part-type=%s" % self.part_type
if self.uuid:
retval += " --uuid=%s" % self.uuid
+ if self.exclude_image:
+ retval += " --exclude-from-image"
return retval
@@ -58,4 +61,6 @@ class Mic_Partition(FC4_Partition):
op.add_option("--part-type", type="string", action="store", dest="part_type",
default=None)
op.add_option("--uuid", dest="uuid", action="store", type="string")
+ op.add_option("--exclude-from-image", action="store_true", dest="exclude_image",
+ default=False)
return op