Exemple #1
0
    def handle(self, request, data):
        group_id = self.initial['group_id']
        name = self.initial['name']
        search_opts = {'group_id': group_id}

        try:
            # get list of assigned volumes
            assigned_vols = []
            volumes = cinder.volume_list(request, search_opts=search_opts)
            for volume in volumes:
                assigned_vols.append(volume.id)

            cinder.group_update(request,
                                group_id,
                                remove_volumes=assigned_vols)

            message = _('Removing volumes from volume group "%s"') % name
            messages.info(request, message)
            return True

        except Exception:
            redirect = reverse("horizon:project:volume_groups:index")
            exceptions.handle(request,
                              _('Errors occurred in removing volumes '
                                'from group.'),
                              redirect=redirect)
Exemple #2
0
    def handle(self, request, data):
        group_id = self.initial['group_id']
        name = self.initial['name']
        search_opts = {'group_id': group_id}

        try:
            # get list of assigned volumes
            assigned_vols = []
            volumes = cinder.volume_list(request,
                                         search_opts=search_opts)
            for volume in volumes:
                assigned_vols.append(volume.id)

            cinder.group_update(request, group_id,
                                remove_volumes=assigned_vols)

            message = _('Removing volumes from volume group "%s"') % name
            messages.info(request, message)
            return True

        except Exception:
            redirect = reverse(self.failure_url)
            exceptions.handle(request,
                              _('Errors occurred in removing volumes '
                                'from group.'),
                              redirect=redirect)
Exemple #3
0
    def handle(self, request, data):
        group_id = self.initial['group_id']

        try:
            cinder.group_update(request, group_id, data['name'],
                                data['description'])

            message = _('Updating volume group "%s"') % data['name']
            messages.info(request, message)
            return True
        except Exception:
            redirect = reverse("horizon:project:volume_groups:index")
            exceptions.handle(request,
                              _('Unable to update volume group.'),
                              redirect=redirect)
Exemple #4
0
    def handle(self, request, data):
        group_id = self.initial['group_id']

        try:
            cinder.group_update(request, group_id,
                                data['name'],
                                data['description'])

            message = _('Updating volume group "%s"') % data['name']
            messages.info(request, message)
            return True
        except Exception:
            redirect = reverse("horizon:project:volume_groups:index")
            exceptions.handle(request,
                              _('Unable to update volume group.'),
                              redirect=redirect)
Exemple #5
0
    def handle(self, request, context):
        group_id = context['group_id']
        add_vols = []
        remove_vols = []
        try:
            selected_volumes = context['volumes']
            volumes = cinder.volume_list(request)

            # scan all volumes and make correct consistency group is set
            for volume in volumes:
                selected = False
                for selection in selected_volumes:
                    if selection == volume.id:
                        selected = True
                        break

                if selected:
                    # ensure this volume is in this consistency group
                    if hasattr(volume, 'group_id'):
                        if volume.group_id != group_id:
                            add_vols.append(volume.id)
                    else:
                        add_vols.append(volume.id)
                else:
                    # ensure this volume is not in our consistency group
                    if hasattr(volume, 'group_id'):
                        if volume.group_id == group_id:
                            # remove from this group
                            remove_vols.append(volume.id)

            if not add_vols and not remove_vols:
                # nothing to change
                return True

            cinder.group_update(request,
                                group_id,
                                add_volumes=add_vols,
                                remove_volumes=remove_vols)

        except Exception:
            # error message supplied by form
            return False

        return True
Exemple #6
0
    def handle(self, request, context):
        group_id = context['group_id']
        add_vols = []
        remove_vols = []
        try:
            selected_volumes = context['volumes']
            volumes = cinder.volume_list(request)

            # scan all volumes and make correct consistency group is set
            for volume in volumes:
                selected = False
                for selection in selected_volumes:
                    if selection == volume.id:
                        selected = True
                        break

                if selected:
                    # ensure this volume is in this consistency group
                    if hasattr(volume, 'group_id'):
                        if volume.group_id != group_id:
                            add_vols.append(volume.id)
                    else:
                        add_vols.append(volume.id)
                else:
                    # ensure this volume is not in our consistency group
                    if hasattr(volume, 'group_id'):
                        if volume.group_id == group_id:
                            # remove from this group
                            remove_vols.append(volume.id)

            if not add_vols and not remove_vols:
                # nothing to change
                return True

            cinder.group_update(request, group_id,
                                add_volumes=add_vols,
                                remove_volumes=remove_vols)

        except Exception:
            # error message supplied by form
            return False

        return True