Exemplo n.º 1
0
    def post(self, request, dname, command):
        with self._handle_exception(request):
            disk = self._validate_disk(dname, request)
            if (command == 'info'):
                return self._info(disk)
            elif (command == 'test'):
                test_type = request.DATA.get('test_type')
                if (re.search('short', test_type, re.IGNORECASE) is not None):
                    test_type = 'short'
                elif (re.search('extended', test_type, re.IGNORECASE) is not None):
                    test_type = 'long'
                elif (re.search('conveyance', test_type, re.IGNORECASE) is not None):
                    test_type = 'conveyance'
                else:
                    raise Exception('Unsupported Self-Test: %s' % test_type)
                smart.run_test(disk.name, test_type)
                return self._info(disk)

            e_msg = ('Unknown command: %s. Only valid commands are scan, '
                     'wipe' % command)
            handle_exception(Exception(e_msg), request)
Exemplo n.º 2
0
    def post(self, request, did, command):
        with self._handle_exception(request):
            disk = self._validate_disk(did, request)
            if (command == 'info'):
                return self._info(disk)
            elif (command == 'test'):
                test_type = request.data.get('test_type')
                if (re.search('short', test_type, re.IGNORECASE) is not None):
                    test_type = 'short'
                elif (re.search('extended', test_type, re.IGNORECASE) is not None):  # noqa E501
                    test_type = 'long'
                elif (re.search('conveyance', test_type, re.IGNORECASE) is not None):  # noqa E501
                    test_type = 'conveyance'
                else:
                    raise Exception(('Unsupported Self-Test: '
                                    '({}).').format(test_type))
                run_test(disk.name, test_type, disk.smart_options)
                return self._info(disk)

            e_msg = ('Unknown command: ({}). The only valid commands are info '
                     'and test.').format(command)
            handle_exception(Exception(e_msg), request)
Exemplo n.º 3
0
    def post(self, request, dname, command):
        with self._handle_exception(request):
            disk = self._validate_disk(dname, request)
            if (command == 'info'):
                return self._info(disk)
            elif (command == 'test'):
                test_type = request.data.get('test_type')
                if (re.search('short', test_type, re.IGNORECASE) is not None):
                    test_type = 'short'
                elif (re.search('extended', test_type, re.IGNORECASE)
                      is not None):
                    test_type = 'long'
                elif (re.search('conveyance', test_type, re.IGNORECASE)
                      is not None):
                    test_type = 'conveyance'
                else:
                    raise Exception('Unsupported Self-Test: %s' % test_type)
                run_test(disk.name, test_type, disk.smart_options)
                return self._info(disk)

            e_msg = ('Unknown command: %s. Only valid commands are info and '
                     'test' % command)
            handle_exception(Exception(e_msg), request)