Ejemplo n.º 1
0
    def test_ok(self, pop_mock, reapply_mock):
        process.reapply(self.uuid)
        pop_mock.assert_called_once_with(self.uuid, locked=False)
        pop_mock.return_value.acquire_lock.assert_called_once_with(
            blocking=False)

        reapply_mock.assert_called_once_with(pop_mock.return_value)
Ejemplo n.º 2
0
 def test_reapply_with_data(self, pop_mock, reapply_mock):
     process.reapply(self.uuid, data=self.data)
     pop_mock.assert_called_once_with(self.uuid, locked=False)
     pop_mock.return_value.acquire_lock.assert_called_once_with(
         blocking=False)
     reapply_mock.assert_called_once_with(pop_mock.return_value,
                                          introspection_data=self.data)
Ejemplo n.º 3
0
    def test_ok(self, pop_mock, reapply_mock):
        process.reapply(self.uuid)
        pop_mock.assert_called_once_with(self.uuid)
        pop_mock.return_value.acquire_lock.assert_called_once_with(
            blocking=False)

        reapply_mock.assert_called_once_with(pop_mock.return_value,
                                             introspection_data=None)
Ejemplo n.º 4
0
    def test_ok(self, pop_mock, reapply_mock):
        process.reapply(self.uuid)
        pop_mock.assert_called_once_with(self.uuid, locked=False)
        pop_mock.return_value.acquire_lock.assert_called_once_with(
            blocking=False
        )

        reapply_mock.assert_called_once_with(pop_mock.return_value)
Ejemplo n.º 5
0
 def test_reapply_with_data(self, pop_mock, reapply_mock):
     process.reapply(self.uuid, data=self.data)
     pop_mock.assert_called_once_with(self.uuid, locked=False)
     pop_mock.return_value.acquire_lock.assert_called_once_with(
         blocking=False
     )
     reapply_mock.assert_called_once_with(pop_mock.return_value,
                                          introspection_data=self.data)
Ejemplo n.º 6
0
 def do_reapply(self, context, node_id, token=None):
     try:
         data = process.get_introspection_data(node_id, processed=False,
                                               get_json=True)
     except utils.IntrospectionDataStoreDisabled:
         raise utils.Error(_('Inspector is not configured to store '
                             'data. Set the [processing]store_data '
                             'configuration option to change this.'),
                           code=400)
     process.reapply(node_id, data)
Ejemplo n.º 7
0
    def test_locking_failed(self, pop_mock, reapply_mock):
        pop_mock.return_value.acquire_lock.return_value = False
        exc = utils.Error('Node locked, please, try again later')

        with self.assertRaises(type(exc)) as cm:
            process.reapply(self.uuid)

        self.assertEqual(str(exc), str(cm.exception))

        pop_mock.assert_called_once_with(self.uuid, locked=False)
        pop_mock.return_value.acquire_lock.assert_called_once_with(
            blocking=False)
Ejemplo n.º 8
0
    def test_locking_failed(self, pop_mock, reapply_mock):
        pop_mock.return_value.acquire_lock.return_value = False
        exc = utils.Error('Node locked, please, try again later')

        with self.assertRaises(type(exc)) as cm:
            process.reapply(self.uuid)

        self.assertEqual(str(exc), str(cm.exception))

        pop_mock.assert_called_once_with(self.uuid, locked=False)
        pop_mock.return_value.acquire_lock.assert_called_once_with(
            blocking=False
        )
Ejemplo n.º 9
0
def api_introspection_reapply(node_id):
    if flask.request.content_length:
        return error_response(_('User data processing is not '
                                'supported yet'), code=400)

    if CONF.processing.store_data == 'swift':
        process.reapply(node_id)
        return '', 202
    else:
        return error_response(_('Inspector is not configured to store'
                                ' data. Set the [processing] '
                                'store_data configuration option to '
                                'change this.'), code=400)
Ejemplo n.º 10
0
    def do_reapply(self, context, node_uuid, token=None, data=None):
        if not data:
            try:
                data = process.get_introspection_data(node_uuid,
                                                      processed=False,
                                                      get_json=True)
            except utils.IntrospectionDataStoreDisabled:
                raise utils.Error(_('Inspector is not configured to store '
                                    'introspection data. Set the '
                                    '[processing]store_data configuration '
                                    'option to change this.'))
        else:
            process.store_introspection_data(node_uuid, data, processed=False)

        process.reapply(node_uuid, data=data)
Ejemplo n.º 11
0
def api_introspection_reapply(uuid):
    utils.check_auth(flask.request)

    if flask.request.content_length:
        return error_response(_('User data processing is not '
                                'supported yet'), code=400)

    if CONF.processing.store_data == 'swift':
        process.reapply(uuid)
        return '', 202
    else:
        return error_response(_('Inspector is not configured to store'
                                ' data. Set the [processing] '
                                'store_data configuration option to '
                                'change this.'), code=400)
Ejemplo n.º 12
0
    def do_reapply(self, context, node_uuid, token=None, data=None):
        if not data:
            try:
                data = process.get_introspection_data(node_uuid,
                                                      processed=False,
                                                      get_json=True)
            except utils.IntrospectionDataStoreDisabled:
                raise utils.Error(
                    _('Inspector is not configured to store '
                      'introspection data. Set the '
                      '[processing]store_data configuration '
                      'option to change this.'))
        else:
            process.store_introspection_data(node_uuid, data, processed=False)

        process.reapply(node_uuid, data=data)
Ejemplo n.º 13
0
 def do_reapply(self, context, node_id, token=None):
     process.reapply(node_id)