def handle(self, request, data): instance_choices = dict(self.fields['instance'].choices) instance_name = instance_choices.get(data['instance'], _("Unknown instance (None)")) # The name of the instance in the choices list has the ID appended to # it, so let's slice that off... instance_name = instance_name.rsplit(" (")[0] try: api.volume_attach(request, data['volume_id'], data['instance'], data['device']) vol_name = api.volume_get(request, data['volume_id']).display_name message = _('Attaching volume %(vol)s to instance ' '%(inst)s on %(dev)s.') % {"vol": vol_name, "inst": instance_name, "dev": data['device']} messages.info(request, message) return True except: redirect = reverse("horizon:nova:volumes:index") exceptions.handle(request, _('Unable to attach volume.'), redirect=redirect)
def handle(self, request, data): try: api.volume_attach(request, data['volume_id'], data['instance'], data['device']) message = (_('Attaching volume %s to instance %s at %s') % (data['volume_id'], data['instance'], data['device'])) LOG.info(message) messages.info(request, message) except novaclient_exceptions.ClientException, e: LOG.exception("ClientException in AttachVolume") messages.error(request, _('Error attaching volume: %s') % e.message)
def handle(self, request, data): instance_choices = dict(self.fields['instance'].choices) instance_name = instance_choices.get(data['instance'], _("Unknown instance (None)")) # The name of the instance in the choices list has the ID appended to # it, so let's slice that off... instance_name = instance_name.rsplit(" (")[0] try: vol = api.volume_attach(request, data['volume_id'], data['instance'], data.get('device', '')) vol_name = api.volume_get(request, data['volume_id']).display_name message = _('Attaching volume %(vol)s to instance ' '%(inst)s on %(dev)s.') % {"vol": vol_name, "inst": instance_name, "dev": vol.device} messages.info(request, message) return True except: redirect = reverse("horizon:nova:volumes:index") exceptions.handle(request, _('Unable to attach volume.'), redirect=redirect)
def handle(self, request, data): image_id = data['image_id'] instance_choices = dict(self.fields['instance'].choices) instance_name = instance_choices.get(data['instance'], _("Unknown instance (None)")) # The name of the instance in the choices list has the ID appended to # it, so let's slice that off... instance_name = instance_name.rsplit(" (")[0] try: vol = api.volume_attach(request, data['volume_id'], data['instance'], data.get('device', '')) vol_name = api.volume_get(request, data['volume_id']).display_name message = _('Attaching volume %(vol)s to instance ' '%(inst)s on %(dev)s.') % {"vol": vol_name, "inst": instance_name, "dev": vol.device} messages.info(request, message) return True except: redirect = reverse("horizon:nova:volumes:index") exceptions.handle(request, _('Unable to attach volume.'), redirect=redirect) 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)
def handle(self, request, data): try: api.volume_attach(request, data["volume_id"], data["instance"], data["device"]) vol_name = api.volume_get(request, data["volume_id"]).displayName message = ( _( "Attaching volume %(vol)s to instance \ %(inst)s at %(dev)s" ) % {"vol": vol_name, "inst": data["instance"], "dev": data["device"]} ) LOG.info(message) messages.info(request, message) except novaclient_exceptions.ClientException, e: LOG.exception("ClientException in AttachVolume") messages.error(request, _("Error attaching volume: %s") % e.message)
def handle(self, request, data): try: api.volume_attach(request, data['volume_id'], data['instance'], data['device']) vol_name = api.volume_get(request, data['volume_id']).display_name message = (_('Attaching volume %(vol)s to instance ' '%(inst)s at %(dev)s') % {"vol": vol_name, "inst": data['instance'], "dev": data['device']}) LOG.info(message) messages.info(request, message) except novaclient_exceptions.ClientException, e: LOG.exception("ClientException in AttachVolume") messages.error(request, _('Error attaching volume: %s') % e.message)
def handle(self, request, data): instance_choices = dict(self.fields["instance"].choices) instance_name = instance_choices.get(data["instance"], _("Unknown instance (None)")) # The name of the instance in the choices list has the ID appended to # it, so let's slice that off... instance_name = instance_name.rsplit(" (")[0] try: api.volume_attach(request, data["volume_id"], data["instance"], data["device"]) vol_name = api.volume_get(request, data["volume_id"]).display_name message = _("Attaching volume %(vol)s to instance " "%(inst)s on %(dev)s.") % { "vol": vol_name, "inst": instance_name, "dev": data["device"], } messages.info(request, message) except: exceptions.handle(request, _("Unable to attach volume.")) return shortcuts.redirect("horizon:nova:volumes:index")