def handle(self, request, data):
     image_id = data['image_id']
     try:
         api.image_update(request, image_id, image_meta={'is_public': False})
     except glance_exception.ClientConnectionError, e:
         LOG.error("Error connecting to glance", exc_info=True)
         messages.error(request,
                        "Error connecting to glance: %s" % e.message)
Example #2
0
    def handle(self, request, data):
        image_id = data['image_id']
        error_updating = _('Unable to update image "%s".')

        if data['disk_format'] in ['aki', 'ari', 'ami']:
            container_format = data['disk_format']
        else:
            container_format = 'bare'

        meta = {'is_public': data['public'],
                'disk_format': data['disk_format'],
                'container_format': container_format,
                'name': data['name'],
                'properties': {}}
        if data['kernel']:
            meta['properties']['kernel_id'] = data['kernel']
        if data['ramdisk']:
            meta['properties']['ramdisk_id'] = data['ramdisk']
        if data['architecture']:
            meta['properties']['architecture'] = data['architecture']
        # Ensure we do not delete properties that have already been
        # set on an image.
        meta['purge_props'] = False

        try:
            image = api.image_update(request, image_id, **meta)
            messages.success(request, _('Image was successfully updated.'))
            return image
        except:
            exceptions.handle(request, error_updating % image_id)
Example #3
0
    def handle(self, request, data):
        image_id = data['image_id']
        error_updating = _('Unable to update image "%s".')

        if data['disk_format'] in ['aki', 'ari', 'ami']:
            container_format = data['disk_format']
        else:
            container_format = 'bare'

        meta = {'is_public': data['public'],
                'disk_format': data['disk_format'],
                'container_format': container_format,
                'name': data['name'],
                'properties': {}}
        if data['kernel']:
            meta['properties']['kernel_id'] = data['kernel']
        if data['ramdisk']:
            meta['properties']['ramdisk_id'] = data['ramdisk']
        if data['architecture']:
            meta['properties']['architecture'] = data['architecture']
        # Ensure we do not delete properties that have already been
        # set on an image.
        meta['purge_props'] = False

        try:
            image = api.image_update(request, image_id, **meta)
            messages.success(request, _('Image was successfully updated.'))
            return image
        except:
            exceptions.handle(request, error_updating % image_id)
 metadata = {
     'is_public': True,
     'disk_format': image_form['disk_format'],
     'container_format': image_form['container_format'],
     'name': image_form['name'],
 }
 try:
     # TODO add public flag to properties
     metadata['properties'] = {}
     if image_form['kernel']:
         metadata['properties']['kernel_id'] = image_form['kernel']
     if image_form['ramdisk']:
         metadata['properties']['ramdisk_id'] = image_form['ramdisk']
     if image_form['architecture']:
         metadata['properties']['architecture'] = image_form['architecture']
     api.image_update(request, image_id, metadata)
     messages.success(request, "Image was successfully updated.")
 except glance_exception.ClientConnectionError, e:
     LOG.error("Error connecting to glance", exc_info=True)
     messages.error(request,
                    "Error connecting to glance: %s" % e.message)
 except glance_exception.Error, e:
     LOG.error('Error updating image with id "%s"' % image_id,
               exc_info=True)
     messages.error(request, "Error updating image: %s" % e.message)
 except:
     LOG.error('Unspecified Exception in image update',
               exc_info=True)
     messages.error(request,
                    "Image could not be updated, please try again.")
 return redirect(topbar + "/images")