Revision e482b7f9

b/image_creator/dialog_main.py
101 101
                   "image": image,
102 102
                   "metadata": metadata}
103 103

  
104
        if hasattr(image, "unsupported"):
105

  
106
            session['excluded_tasks'] = [-1]
107
            session['task_metadata'] = ["EXCLUDE_ALL_TASKS"]
108

  
109
            msg = "The system on the input media is not supported." \
110
                "\n\nReason: %s\n\n" \
111
                "We highly recommend not to create an image out of this, " \
112
                "since the image won't be cleaned up and you will not be " \
113
                "able to configure it during the deployment. Press <YES> if " \
114
                "you still want to continue with the image creation process." \
115
                % image.unsupported
116

  
117
            if not d.yesno(msg, width=WIDTH, defaultno=1, height=12):
118
                main_menu(session)
119

  
120
            d.infobox("Thank you for using snf-image-creator. Bye", width=53)
121
            return 0
122

  
104 123
        msg = "snf-image-creator detected a %s system on the input media. " \
105 124
              "Would you like to run a wizard to assist you through the " \
106 125
              "image creation process?\n\nChoose <Wizard> to run the wizard," \
b/image_creator/dialog_menu.py
583 583
def exclude_tasks(session):
584 584
    """Exclude specific tasks from running during image deployment"""
585 585
    d = session['dialog']
586
    image = session['image']
587

  
588
    if hasattr(image, "unsupported"):
589
        d.msgbox("You cannot configure the deployment tasks for an unsupported"
590
                 " image.", width=SMALL_WIDTH)
591
        return False
586 592

  
587 593
    index = 0
588 594
    displayed_index = 1
b/image_creator/image.py
88 88

  
89 89
        self.out.output('Inspecting Operating System ...', False)
90 90
        roots = self.g.inspect_os()
91
        if len(roots) == 0:
92
            raise FatalError("No operating system found")
93
        if len(roots) > 1:
94
            raise FatalError("Multiple operating systems found."
95
                             "We only support images with one OS.")
91

  
92
        if len(roots) == 0 or len(roots) > 1:
93
            self.root = None
94
            self.ostype = "unsupported"
95
            self.distro = "unsupported"
96
            self.guestfs_device = '/dev/sda'
97
            self.size = self.g.blockdev_getsize64(self.guestfs_device)
98
            if len(roots) > 1:
99
                self.unsupported = "Multiple operating systems found on the " \
100
                    "media. We only support images with one OS."
101
            else:
102
                self.unsupported = \
103
                    "Unable to detect any operating system on the media"
104

  
105
            self.meta['UNSUPPORTED'] = "Reason: %s" % self.unsupported
106
            self.out.warn('Media is not supported. %s' %
107
                          self.meta['UNSUPPORTED'])
108
            return
109

  
96 110
        self.root = roots[0]
97 111
        self.guestfs_device = self.g.part_to_dev(self.root)
98 112
        self.size = self.g.blockdev_getsize64(self.guestfs_device)
......
264 278

  
265 279
        self.out.output("Shrinking image (this may take a while) ...", False)
266 280

  
281
        if hasattr(self, "unsupported"):
282
            self.out.warn("Unable to shrink unsupported image")
283
            return self.size
284

  
267 285
        sector_size = self.g.blockdev_getss(self.guestfs_device)
268 286

  
269 287
        last_part = None
b/image_creator/main.py
140 140
                      help="register image with the cloud as public",
141 141
                      action="store_true")
142 142

  
143
    parser.add_option("--allow-unsupported", dest="allow_unsupported",
144
                      help="Proceed with the image creation even if the media "
145
                      "is not supported", default=False, action="store_true")
146

  
143 147
    parser.add_option("--tmpdir", dest="tmp", type="string", default=None,
144 148
                      help="create large temporary image files under DIR",
145 149
                      metavar="DIR")
......
273 277

  
274 278
        image = disk.get_image(snapshot, sysprep_params=options.sysprep_params)
275 279

  
280
        if hasattr(image, 'unsupported') and not options.allow_unsupported:
281
            raise FatalError(
282
                "The media seems to be unsupported. If you insist on creating "
283
                "an image out of it, use the `--allow-unsupported' option. "
284
                "Using this is highly discouraged, since the resulting image "
285
                "will not be cleaned up from sensitive data and will not get "
286
                "configured during the deployment")
287

  
276 288
        for sysprep in options.disabled_syspreps:
277 289
            image.os.disable_sysprep(image.os.get_sysprep_by_name(sysprep))
278 290

  
......
298 310
        size = options.shrink and image.shrink() or image.size
299 311
        metadata.update(image.meta)
300 312

  
313
        if hasattr(image, 'unsupported'):
314
            metadata['EXCLUDE_ALL_TASKS'] = "yes"
315

  
301 316
        # Add command line metadata to the collected ones...
302 317
        metadata.update(options.metadata)
303 318

  
b/image_creator/os_type/__init__.py
247 247
    def do_sysprep(self):
248 248
        """Prepare system for image creation."""
249 249

  
250
        self.out.output('Preparing system for image creation:')
251

  
252
        if hasattr(self.image, "unsupported"):
253
            self.out.warn(
254
                "System preparation is disabled for unsupported media")
255
            return
256

  
250 257
        try:
251 258
            if not self.mount(readonly=False):
252 259
                raise FatalError("Unable to mount the media read-write")
253 260

  
254
            self.out.output('Preparing system for image creation:')
255

  
256 261
            enabled = [task for task in self.list_syspreps() if task.enabled]
257 262

  
258 263
            size = len(enabled)
b/image_creator/os_type/unsupported.py
1
# -*- coding: utf-8 -*-
2
#
3
# Copyright 2013 GRNET S.A. All rights reserved.
4
#
5
# Redistribution and use in source and binary forms, with or
6
# without modification, are permitted provided that the following
7
# conditions are met:
8
#
9
#   1. Redistributions of source code must retain the above
10
#      copyright notice, this list of conditions and the following
11
#      disclaimer.
12
#
13
#   2. Redistributions in binary form must reproduce the above
14
#      copyright notice, this list of conditions and the following
15
#      disclaimer in the documentation and/or other materials
16
#      provided with the distribution.
17
#
18
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
19
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
22
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
# POSSIBILITY OF SUCH DAMAGE.
30
#
31
# The views and conclusions contained in the software and
32
# documentation are those of the authors and should not be
33
# interpreted as representing official policies, either expressed
34
# or implied, of GRNET S.A.
35

  
36
"""This module hosts code to handle unknown OSs."""
37

  
38
from image_creator.os_type import OSBase
39

  
40

  
41
class Unsupported(OSBase):
42
    """OS class for unsupported OSs"""
43
    def __init__(self, image, **kargs):
44
        super(Unsupported, self).__init__(image, **kargs)
45

  
46
    def collect_metadata(self):
47
        """Collect metadata about the OS"""
48
        self.out.warn("Unable to collect metadata for unsupported media")
49

  
50
    def _do_mount(self, readonly):
51
        """Mount partitions in corrent order"""
52
        self.out.warn('not supported on this media.')
53
        return False
54

  
55
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :

Also available in: Unified diff