Esempio n. 1
0
def _validate_group_status(param_value):
    if param_value is None:
        msg = _("The 'status' can not be None.")
        raise webob.exc.HTTPBadRequest(explanation=msg)
    if len(param_value.strip()) == 0:
        msg = _("The 'status' can not be empty.")
        raise exception.InvalidGroupStatus(reason=msg)
    if param_value.lower() not in c_fields.GroupSnapshotStatus.ALL:
        msg = _("Group status: %(status)s is invalid, valid status "
                "are: %(valid)s.") % {'status': param_value,
                                      'valid': c_fields.GroupStatus.ALL}
        raise exception.InvalidGroupStatus(reason=msg)
    return True
Esempio n. 2
0
    def reset_status(self, context, group, status):
        """Reset status of generic group"""

        if status not in c_fields.GroupStatus.ALL:
            msg = _("Group status: %(status)s is invalid, valid status "
                    "are: %(valid)s.") % {'status': status,
                                          'valid': c_fields.GroupStatus.ALL}
            raise exception.InvalidGroupStatus(reason=msg)
        field = {'updated_at': timeutils.utcnow(),
                 'status': status}
        group.update(field)
        group.save()