当前位置: 首页>>代码示例>>Python>>正文


Python LiveActionDB.start_timestamp方法代码示例

本文整理汇总了Python中st2common.models.db.liveaction.LiveActionDB.start_timestamp方法的典型用法代码示例。如果您正苦于以下问题:Python LiveActionDB.start_timestamp方法的具体用法?Python LiveActionDB.start_timestamp怎么用?Python LiveActionDB.start_timestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在st2common.models.db.liveaction.LiveActionDB的用法示例。


在下文中一共展示了LiveActionDB.start_timestamp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_notify_triggers_end_timestamp_none

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def test_notify_triggers_end_timestamp_none(self):
        liveaction_db = LiveActionDB(action='core.local')
        liveaction_db.id = bson.ObjectId()
        liveaction_db.description = ''
        liveaction_db.status = 'succeeded'
        liveaction_db.parameters = {}
        on_success = NotificationSubSchema(message='Action succeeded.')
        on_failure = NotificationSubSchema(message='Action failed.')
        liveaction_db.notify = NotificationSchema(on_success=on_success,
                                                  on_failure=on_failure)
        liveaction_db.start_timestamp = date_utils.get_datetime_utc_now()

        # This tests for end_timestamp being set to None, which can happen when a policy cancels
        # a request.
        # The assertions within "MockDispatcher.dispatch" will validate that the underlying code
        # handles this properly, so all we need to do is keep the call to "notifier.process" below
        liveaction_db.end_timestamp = None
        LiveAction.add_or_update(liveaction_db)

        execution = MOCK_EXECUTION
        execution.liveaction = vars(LiveActionAPI.from_model(liveaction_db))
        execution.status = liveaction_db.status

        dispatcher = NotifierTestCase.MockDispatcher(self)
        notifier = Notifier(connection=None, queues=[], trigger_dispatcher=dispatcher)
        notifier.process(execution)
开发者ID:nzlosh,项目名称:st2,代码行数:28,代码来源:test_notifier.py

示例2: test_notify_triggers_jinja_patterns

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def test_notify_triggers_jinja_patterns(self, dispatch):
        liveaction_db = LiveActionDB(action='core.local')
        liveaction_db.id = bson.ObjectId()
        liveaction_db.description = ''
        liveaction_db.status = 'succeeded'
        liveaction_db.parameters = {'cmd': 'mamma mia', 'runner_foo': 'foo'}
        on_success = NotificationSubSchema(message='Command {{action_parameters.cmd}} succeeded.',
                                           data={'stdout': '{{action_results.stdout}}'})
        liveaction_db.notify = NotificationSchema(on_success=on_success)
        liveaction_db.start_timestamp = date_utils.get_datetime_utc_now()
        liveaction_db.end_timestamp = \
            (liveaction_db.start_timestamp + datetime.timedelta(seconds=50))

        LiveAction.add_or_update(liveaction_db)

        execution = MOCK_EXECUTION
        execution.liveaction = vars(LiveActionAPI.from_model(liveaction_db))
        execution.status = liveaction_db.status

        notifier = Notifier(connection=None, queues=[])
        notifier.process(execution)
        exp = {'status': 'succeeded',
               'start_timestamp': isotime.format(liveaction_db.start_timestamp),
               'route': 'notify.default', 'runner_ref': 'local-shell-cmd',
               'channel': 'notify.default', 'message': u'Command mamma mia succeeded.',
               'data': {'result': '{}', 'stdout': 'stuff happens'},
               'action_ref': u'core.local',
               'execution_id': str(MOCK_EXECUTION.id),
               'end_timestamp': isotime.format(liveaction_db.end_timestamp)}
        dispatch.assert_called_once_with('core.st2.generic.notifytrigger', payload=exp,
                                         trace_context={})
        notifier.process(execution)
开发者ID:nzlosh,项目名称:st2,代码行数:34,代码来源:test_notifier.py

示例3: test_update_same_liveaction_status

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def test_update_same_liveaction_status(self):
        liveaction_db = LiveActionDB()
        liveaction_db.status = 'requested'
        liveaction_db.start_timestamp = get_datetime_utc_now()
        liveaction_db.action = ResourceReference(
            name=ActionDBUtilsTestCase.action_db.name,
            pack=ActionDBUtilsTestCase.action_db.pack).ref
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555
        }
        liveaction_db.parameters = params
        liveaction_db = LiveAction.add_or_update(liveaction_db)
        origliveaction_db = copy.copy(liveaction_db)

        # Update by id.
        newliveaction_db = action_db_utils.update_liveaction_status(
            status='requested', liveaction_id=liveaction_db.id)

        # Verify id didn't change.
        self.assertEqual(origliveaction_db.id, newliveaction_db.id)
        self.assertEqual(newliveaction_db.status, 'requested')

        # Verify that state is not published.
        self.assertFalse(LiveActionPublisher.publish_state.called)
开发者ID:StackStorm,项目名称:st2,代码行数:28,代码来源:test_action_db_utils.py

示例4: setup_action_models

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def setup_action_models(cls):
        pack = 'wolfpack'
        name = 'action-1'
        parameters = {
            'actionint': {'type': 'number', 'default': 10, 'position': 0},
            'actionfloat': {'type': 'float', 'required': False, 'position': 1},
            'actionstr': {'type': 'string', 'required': True, 'position': 2},
            'actionbool': {'type': 'boolean', 'required': False, 'position': 3},
            'actionlist': {'type': 'list', 'required': False, 'position': 4},
            'actionobject': {'type': 'object', 'required': False, 'position': 5},
            'actionnull': {'type': 'null', 'required': False, 'position': 6},

            'runnerdummy': {'type': 'string', 'default': 'actiondummy'}
        }
        action_db = ActionDB(pack=pack, name=name, description='awesomeness',
                             enabled=True,
                             ref=ResourceReference(name=name, pack=pack).ref,
                             entry_point='', runner_type={'name': 'test-runner'},
                             parameters=parameters)
        ActionDBUtilsTestCase.action_db = Action.add_or_update(action_db)

        liveaction_db = LiveActionDB()
        liveaction_db.status = 'initializing'
        liveaction_db.start_timestamp = get_datetime_utc_now()
        liveaction_db.action = ActionDBUtilsTestCase.action_db.ref
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555
        }
        liveaction_db.parameters = params
        ActionDBUtilsTestCase.liveaction_db = LiveAction.add_or_update(liveaction_db)
开发者ID:StackStorm,项目名称:st2,代码行数:34,代码来源:test_action_db_utils.py

示例5: setup_action_models

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def setup_action_models(cls):
        action_db = ActionDB()
        action_db.name = 'action-1'
        action_db.description = 'awesomeness'
        action_db.enabled = True
        action_db.pack = 'wolfpack'
        action_db.ref = ResourceReference(name=action_db.name, pack=action_db.pack).ref
        action_db.entry_point = ''
        action_db.runner_type = {'name': 'test-runner'}
        action_db.parameters = {
            'actionstr': {'type': 'string', 'position': 1, 'required': True},
            'actionint': {'type': 'number', 'default': 10, 'position': 0},
            'runnerdummy': {'type': 'string', 'default': 'actiondummy'}
        }
        ActionDBUtilsTestCase.action_db = Action.add_or_update(action_db)

        liveaction_db = LiveActionDB()
        liveaction_db.status = 'initializing'
        liveaction_db.start_timestamp = get_datetime_utc_now()
        liveaction_db.action = ActionDBUtilsTestCase.action_db.ref
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555
        }
        liveaction_db.parameters = params
        ActionDBUtilsTestCase.liveaction_db = LiveAction.add_or_update(liveaction_db)
开发者ID:ipv1337,项目名称:st2,代码行数:29,代码来源:test_action_db_utils.py

示例6: _get_execution_db_model

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
 def _get_execution_db_model(self, status=action_constants.LIVEACTION_STATUS_REQUESTED):
     live_action_db = LiveActionDB()
     live_action_db.status = status
     live_action_db.start_timestamp = date_utils.get_datetime_utc_now()
     live_action_db.action = ResourceReference(
         name='test_action',
         pack='test_pack').ref
     live_action_db.parameters = None
     return action.LiveAction.add_or_update(live_action_db, publish=False)
开发者ID:meirwah,项目名称:st2,代码行数:11,代码来源:test_queue_consumers.py

示例7: _get_action_exec_db_model

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def _get_action_exec_db_model(self, params):
        liveaction_db = LiveActionDB()
        liveaction_db.status = 'initializing'
        liveaction_db.start_timestamp = datetime.datetime.utcnow()
        liveaction_db.action = ResourceReference(name=ParamsUtilsTest.action_db.name,
                                                 pack=ParamsUtilsTest.action_db.pack).ref
        liveaction_db.parameters = params

        return liveaction_db
开发者ID:Kailashkatheth1,项目名称:st2,代码行数:11,代码来源:test_param_utils.py

示例8: _create_inquiry

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
 def _create_inquiry(self, ttl, timestamp):
     action_db = self.models['actions']['ask.yaml']
     liveaction_db = LiveActionDB()
     liveaction_db.status = action_constants.LIVEACTION_STATUS_PENDING
     liveaction_db.start_timestamp = timestamp
     liveaction_db.action = ResourceReference(name=action_db.name, pack=action_db.pack).ref
     liveaction_db.result = {'ttl': ttl}
     liveaction_db = LiveAction.add_or_update(liveaction_db)
     executions.create_execution_object(liveaction_db)
开发者ID:nzlosh,项目名称:st2,代码行数:11,代码来源:test_garbage_collector.py

示例9: _get_failingaction_exec_db_model

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
 def _get_failingaction_exec_db_model(self, params):
     liveaction_db = LiveActionDB()
     liveaction_db.status = action_constants.LIVEACTION_STATUS_REQUESTED
     liveaction_db.start_timestamp = datetime.datetime.now()
     liveaction_db.action = ResourceReference(
         name=RunnerContainerTest.failingaction_db.name,
         pack=RunnerContainerTest.failingaction_db.pack).ref
     liveaction_db.parameters = params
     liveaction_db.context = {'user': cfg.CONF.system_user.user}
     return liveaction_db
开发者ID:Kailashkatheth1,项目名称:st2,代码行数:12,代码来源:test_runner_container.py

示例10: _get_action_exec_db_model

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
 def _get_action_exec_db_model(self, action_db, params):
     liveaction_db = LiveActionDB()
     liveaction_db.status = action_constants.LIVEACTION_STATUS_REQUESTED
     liveaction_db.start_timestamp = date_utils.get_datetime_utc_now()
     liveaction_db.action = ResourceReference(
         name=action_db.name,
         pack=action_db.pack).ref
     liveaction_db.parameters = params
     liveaction_db.context = {'user': cfg.CONF.system_user.user}
     return liveaction_db
开发者ID:ipv1337,项目名称:st2,代码行数:12,代码来源:test_runner_container.py

示例11: test_update_canceled_liveaction

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def test_update_canceled_liveaction(self):
        liveaction_db = LiveActionDB()
        liveaction_db.status = 'initializing'
        liveaction_db.start_timestamp = get_datetime_utc_now()
        liveaction_db.action = ResourceReference(
            name=ActionDBUtilsTestCase.action_db.name,
            pack=ActionDBUtilsTestCase.action_db.pack).ref
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555
        }
        liveaction_db.parameters = params
        liveaction_db = LiveAction.add_or_update(liveaction_db)
        origliveaction_db = copy.copy(liveaction_db)

        # Update by id.
        newliveaction_db = action_db_utils.update_liveaction_status(
            status='running', liveaction_id=liveaction_db.id)

        # Verify id didn't change.
        self.assertEqual(origliveaction_db.id, newliveaction_db.id)
        self.assertEqual(newliveaction_db.status, 'running')

        # Verify that state is published.
        self.assertTrue(LiveActionPublisher.publish_state.called)
        LiveActionPublisher.publish_state.assert_called_once_with(newliveaction_db, 'running')

        # Cancel liveaction.
        now = get_datetime_utc_now()
        status = 'canceled'
        newliveaction_db = action_db_utils.update_liveaction_status(
            status=status, end_timestamp=now, liveaction_id=liveaction_db.id)
        self.assertEqual(origliveaction_db.id, newliveaction_db.id)
        self.assertEqual(newliveaction_db.status, status)
        self.assertEqual(newliveaction_db.end_timestamp, now)

        # Since liveaction has already been canceled, check that anymore update of
        # status, result, context, and end timestamp are not processed.
        now = get_datetime_utc_now()
        status = 'succeeded'
        result = 'Work is done.'
        context = {'third_party_id': uuid.uuid4().hex}
        newliveaction_db = action_db_utils.update_liveaction_status(
            status=status, result=result, context=context, end_timestamp=now,
            liveaction_id=liveaction_db.id)

        self.assertEqual(origliveaction_db.id, newliveaction_db.id)
        self.assertEqual(newliveaction_db.status, 'canceled')
        self.assertNotEqual(newliveaction_db.result, result)
        self.assertNotEqual(newliveaction_db.context, context)
        self.assertNotEqual(newliveaction_db.end_timestamp, now)
开发者ID:StackStorm,项目名称:st2,代码行数:54,代码来源:test_action_db_utils.py

示例12: test_notify_triggers

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def test_notify_triggers(self):
        liveaction = LiveActionDB(action='core.local')
        liveaction.description = ''
        liveaction.status = 'succeeded'
        liveaction.parameters = {}
        on_success = NotificationSubSchema(message='Action succeeded.')
        on_failure = NotificationSubSchema(message='Action failed.')
        liveaction.notify = NotificationSchema(on_success=on_success,
                                               on_failure=on_failure)
        liveaction.start_timestamp = date_utils.get_datetime_utc_now()

        dispatcher = NotifierTestCase.MockDispatcher(self)
        notifier = Notifier(connection=None, queues=[], trigger_dispatcher=dispatcher)
        notifier.process(liveaction)
开发者ID:ipv1337,项目名称:st2,代码行数:16,代码来源:test_notifier.py

示例13: test_update_liveaction_result_with_dotted_key

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def test_update_liveaction_result_with_dotted_key(self):
        liveaction_db = LiveActionDB()
        liveaction_db.status = 'initializing'
        liveaction_db.start_timestamp = get_datetime_utc_now()
        liveaction_db.action = ResourceReference(
            name=ActionDBUtilsTestCase.action_db.name,
            pack=ActionDBUtilsTestCase.action_db.pack).ref
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555
        }
        liveaction_db.parameters = params
        liveaction_db = LiveAction.add_or_update(liveaction_db)
        origliveaction_db = copy.copy(liveaction_db)

        # Update by id.
        newliveaction_db = action_db_utils.update_liveaction_status(
            status='running', liveaction_id=liveaction_db.id)

        # Verify id didn't change.
        self.assertEqual(origliveaction_db.id, newliveaction_db.id)
        self.assertEqual(newliveaction_db.status, 'running')

        # Verify that state is published.
        self.assertTrue(LiveActionPublisher.publish_state.called)
        LiveActionPublisher.publish_state.assert_called_once_with(newliveaction_db, 'running')

        now = get_datetime_utc_now()
        status = 'succeeded'
        result = {'a': 1, 'b': True, 'a.b.c': 'abc'}
        context = {'third_party_id': uuid.uuid4().hex}
        newliveaction_db = action_db_utils.update_liveaction_status(
            status=status, result=result, context=context, end_timestamp=now,
            liveaction_id=liveaction_db.id)

        self.assertEqual(origliveaction_db.id, newliveaction_db.id)
        self.assertEqual(newliveaction_db.status, status)
        self.assertIn('a.b.c', list(result.keys()))
        self.assertDictEqual(newliveaction_db.result, result)
        self.assertDictEqual(newliveaction_db.context, context)
        self.assertEqual(newliveaction_db.end_timestamp, now)
开发者ID:StackStorm,项目名称:st2,代码行数:44,代码来源:test_action_db_utils.py

示例14: test_update_LiveAction_status_invalid

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def test_update_LiveAction_status_invalid(self):
        liveaction_db = LiveActionDB()
        liveaction_db.status = 'initializing'
        liveaction_db.start_timestamp = get_datetime_utc_now()
        liveaction_db.action = ResourceReference(
            name=ActionDBUtilsTestCase.action_db.name,
            pack=ActionDBUtilsTestCase.action_db.pack).ref
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555
        }
        liveaction_db.parameters = params
        liveaction_db = LiveAction.add_or_update(liveaction_db)

        # Update by id.
        self.assertRaises(ValueError, action_db_utils.update_liveaction_status,
                          status='mea culpa', liveaction_id=liveaction_db.id)

        # Verify that state is not published.
        self.assertFalse(LiveActionPublisher.publish_state.called)
开发者ID:StackStorm,项目名称:st2,代码行数:23,代码来源:test_action_db_utils.py

示例15: test_notify_triggers

# 需要导入模块: from st2common.models.db.liveaction import LiveActionDB [as 别名]
# 或者: from st2common.models.db.liveaction.LiveActionDB import start_timestamp [as 别名]
    def test_notify_triggers(self):
        liveaction_db = LiveActionDB(action='core.local')
        liveaction_db.id = bson.ObjectId()
        liveaction_db.description = ''
        liveaction_db.status = 'succeeded'
        liveaction_db.parameters = {}
        on_success = NotificationSubSchema(message='Action succeeded.')
        on_failure = NotificationSubSchema(message='Action failed.')
        liveaction_db.notify = NotificationSchema(on_success=on_success,
                                                  on_failure=on_failure)
        liveaction_db.start_timestamp = date_utils.get_datetime_utc_now()
        liveaction_db.end_timestamp = \
            (liveaction_db.start_timestamp + datetime.timedelta(seconds=50))
        LiveAction.add_or_update(liveaction_db)

        execution = MOCK_EXECUTION
        execution.liveaction = vars(LiveActionAPI.from_model(liveaction_db))
        execution.status = liveaction_db.status

        dispatcher = NotifierTestCase.MockDispatcher(self)
        notifier = Notifier(connection=None, queues=[], trigger_dispatcher=dispatcher)
        notifier.process(execution)
开发者ID:nzlosh,项目名称:st2,代码行数:24,代码来源:test_notifier.py


注:本文中的st2common.models.db.liveaction.LiveActionDB.start_timestamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。