def get_by_operation_id(cls, context, operation_id, expected_attrs=[]):
        columns_to_join = [col for col in expected_attrs
                           if col in cls.INSTANCE_OPTIONAL_JOINED_FIELDS]

        db_state = db.scheduled_operation_state_get(
            context, operation_id, columns_to_join)
        if db_state:
            return cls._from_db_object(context, cls(),
                                       db_state, columns_to_join)
    def get_by_operation_id(cls, context, operation_id, expected_attrs=[]):
        columns_to_join = [col for col in expected_attrs
                           if col in cls.INSTANCE_OPTIONAL_JOINED_FIELDS]

        db_state = db.scheduled_operation_state_get(
            context, operation_id, columns_to_join)
        if db_state:
            return cls._from_db_object(context, cls(),
                                       db_state, columns_to_join)
示例#3
0
    def test_scheduled_operation_state_update(self):
        state_ref = self._create_scheduled_operation_state()
        operation_id = state_ref['operation_id']
        state_ref = db.scheduled_operation_state_update(
            self.ctxt, operation_id, {"state": "success"})
        self.assertEqual('success', state_ref['state'])

        state_ref = db.scheduled_operation_state_get(self.ctxt, operation_id)
        self.assertEqual('success', state_ref['state'])

        self.assertRaises(exception.ScheduledOperationStateNotFound,
                          db.scheduled_operation_state_update, self.ctxt,
                          '100', {"state": "success"})
示例#4
0
    def test_scheduled_operation_state_update(self):
        state_ref = self._create_scheduled_operation_state()
        operation_id = state_ref['operation_id']
        state_ref = db.scheduled_operation_state_update(self.ctxt,
                                                        operation_id,
                                                        {"state": "success"})
        self.assertEqual('success', state_ref['state'])

        state_ref = db.scheduled_operation_state_get(self.ctxt, operation_id)
        self.assertEqual('success', state_ref['state'])

        self.assertRaises(exception.ScheduledOperationStateNotFound,
                          db.scheduled_operation_state_update,
                          self.ctxt, '100', {"state": "success"})
示例#5
0
    def test_scheduled_operation_state_get_join_operation(self):
        def _create_scheduled_operation():
            values = {
                'id': '0354ca9ddcd046b693340d78759fd274',
                'name': 'protect vm',
                'operation_type': 'protect',
                'user_id': self.ctxt.user_id,
                'project_id': self.ctxt.tenant,
                'trigger_id': '0354ca9ddcd046b693340d78759fd275',
                'operation_definition': '{}'
            }
            return db.scheduled_operation_create(self.ctxt, values)

        operation_ref = _create_scheduled_operation()
        self._create_scheduled_operation_state()
        state_ref = db.scheduled_operation_state_get(self.ctxt,
                                                     operation_ref['id'],
                                                     ['operation'])
        self.assertEqual(operation_ref['id'], state_ref.operation['id'])
示例#6
0
    def test_scheduled_operation_state_get_join_operation(self):
        def _create_scheduled_operation():
            values = {
                'id': '0354ca9ddcd046b693340d78759fd274',
                'name': 'protect vm',
                'operation_type': 'protect',
                'user_id': self.ctxt.user_id,
                'project_id': self.ctxt.tenant,
                'trigger_id': '0354ca9ddcd046b693340d78759fd275',
                'operation_definition': '{}'
            }
            return db.scheduled_operation_create(self.ctxt, values)

        operation_ref = _create_scheduled_operation()
        self._create_scheduled_operation_state()
        state_ref = db.scheduled_operation_state_get(
            self.ctxt,
            operation_ref['id'],
            ['operation'])
        self.assertEqual(operation_ref['id'], state_ref.operation['id'])
示例#7
0
 def test_scheduled_operation_state_get(self):
     state_ref = self._create_scheduled_operation_state()
     state_ref = db.scheduled_operation_state_get(self.ctxt,
                                                  state_ref['operation_id'])
     self.assertEqual('init', state_ref['state'])
示例#8
0
 def test_scheduled_operation_state_get(self):
     state_ref = self._create_scheduled_operation_state()
     state_ref = db.scheduled_operation_state_get(self.ctxt,
                                                  state_ref['operation_id'])
     self.assertEqual('init', state_ref['state'])