當前位置: 首頁>>代碼示例>>Python>>正文


Python models.AgentHeartBeat類代碼示例

本文整理匯總了Python中trove.guestagent.models.AgentHeartBeat的典型用法代碼示例。如果您正苦於以下問題:Python AgentHeartBeat類的具體用法?Python AgentHeartBeat怎麽用?Python AgentHeartBeat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AgentHeartBeat類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_find_by_instance_id

    def test_find_by_instance_id(self):
        """
        Test to retrieve a guest agents by it's id
        """
        # create a unique record
        instance_id = str(uuid.uuid4())
        heartbeat = AgentHeartBeat.create(
            instance_id=instance_id, guest_agent_version="1.2.3")
        self.assertIsNotNone(heartbeat)
        self.assertIsNotNone(heartbeat.id)
        self.assertIsNotNone(heartbeat.instance_id)
        self.assertEqual(instance_id, heartbeat.instance_id)
        self.assertIsNotNone(heartbeat.updated_at)
        self.assertIsNotNone(heartbeat.guest_agent_version)
        self.assertEqual("1.2.3", heartbeat.guest_agent_version)

        # retrieve the record
        heartbeat_found = AgentHeartBeat.find_by_instance_id(
            instance_id=instance_id)
        self.assertIsNotNone(heartbeat_found)
        self.assertEqual(heartbeat.id, heartbeat_found.id)
        self.assertEqual(heartbeat.instance_id, heartbeat_found.instance_id)
        self.assertEqual(heartbeat.updated_at, heartbeat_found.updated_at)
        self.assertEqual(heartbeat.guest_agent_version,
                         heartbeat_found.guest_agent_version)
開發者ID:magictour,項目名稱:trove,代碼行數:25,代碼來源:test_agent_heartbeats_models.py

示例2: update_db

 def update_db():
     status = InstanceServiceStatus.find_by(instance_id=self.id)
     if instance_name.endswith('GUEST_ERROR'):
         status.status = rd_instance.ServiceStatuses.FAILED
     else:
         status.status = rd_instance.ServiceStatuses.RUNNING
     status.save()
     AgentHeartBeat.create(instance_id=self.id)
開發者ID:paramtech,項目名稱:tesora-trove,代碼行數:8,代碼來源:guestagent.py

示例3: test_save_invalid_model_error

 def test_save_invalid_model_error(self):
     """
     Test the save failure of an agent heartbeat record
     """
     instance_id = str(uuid.uuid4())
     heartbeat = AgentHeartBeat.create(
         instance_id=instance_id)
     with patch.object(AgentHeartBeat, 'is_valid', return_value=False):
         self.assertRaises(exception.InvalidModelError, heartbeat.save)
開發者ID:Hopebaytech,項目名稱:trove,代碼行數:9,代碼來源:test_agent_heartbeats_models.py

示例4: test_find_all_by_version

    def test_find_all_by_version(self):
        """
        Test to retrieve all guest agents with a particular version
        """
        # create some unique records with the same version
        version = str(uuid.uuid4())

        for x in xrange(5):
            instance_id = str(uuid.uuid4())
            heartbeat = AgentHeartBeat.create(
                instance_id=instance_id,
                guest_agent_version=version,
                deleted=0)
            self.assertIsNotNone(heartbeat)

        # get all guests by version
        heartbeats = AgentHeartBeat.find_all_by_version(version)
        self.assertIsNotNone(heartbeats)
        self.assertEqual(5, heartbeats.count())
開發者ID:magictour,項目名稱:trove,代碼行數:19,代碼來源:test_agent_heartbeats_models.py

示例5: test_update_heartbeat

    def test_update_heartbeat(self):
        """
        Test to show the upgrade scenario that will be used by conductor
        """
        # create a unique record
        instance_id = str(uuid.uuid4())
        heartbeat = AgentHeartBeat.create(
            instance_id=instance_id, guest_agent_version="1.2.3")
        self.assertIsNotNone(heartbeat)
        self.assertIsNotNone(heartbeat.id)
        self.assertIsNotNone(heartbeat.instance_id)
        self.assertEqual(instance_id, heartbeat.instance_id)
        self.assertIsNotNone(heartbeat.updated_at)
        self.assertIsNotNone(heartbeat.guest_agent_version)
        self.assertEqual("1.2.3", heartbeat.guest_agent_version)

        # retrieve the record
        heartbeat_found = AgentHeartBeat.find_by_instance_id(
            instance_id=instance_id)
        self.assertIsNotNone(heartbeat_found)
        self.assertEqual(heartbeat.id, heartbeat_found.id)
        self.assertEqual(heartbeat.instance_id, heartbeat_found.instance_id)
        self.assertEqual(heartbeat.updated_at, heartbeat_found.updated_at)
        self.assertEqual(heartbeat.guest_agent_version,
                         heartbeat_found.guest_agent_version)

        # update
        AgentHeartBeat().update(id=heartbeat_found.id,
                                instance_id=instance_id,
                                guest_agent_version="1.2.3")

        # retrieve the record
        updated_heartbeat = AgentHeartBeat.find_by_instance_id(
            instance_id=instance_id)
        self.assertIsNotNone(updated_heartbeat)
        self.assertEqual(heartbeat.id, updated_heartbeat.id)
        self.assertEqual(heartbeat.instance_id, updated_heartbeat.instance_id)
        self.assertEqual(heartbeat.guest_agent_version,
                         updated_heartbeat.guest_agent_version)

        self.assertEqual(heartbeat.updated_at, updated_heartbeat.updated_at)
開發者ID:magictour,項目名稱:trove,代碼行數:41,代碼來源:test_agent_heartbeats_models.py

示例6: test_find_all_by_version_none

    def test_find_all_by_version_none(self):
        """
        Test to retrieve all guest agents with a None version
        """
        heartbeats = None
        exception_raised = False
        try:
            heartbeats = AgentHeartBeat.find_all_by_version(None)
        except exception.ModelNotFoundError:
            exception_raised = True

        self.assertIsNone(heartbeats)
        self.assertTrue(exception_raised)
開發者ID:magictour,項目名稱:trove,代碼行數:13,代碼來源:test_agent_heartbeats_models.py

示例7: test_find_by_instance_id_none

    def test_find_by_instance_id_none(self):
        """
        Test to retrieve a guest agents when id is None
        """
        heartbeat_found = None
        exception_raised = False
        try:
            heartbeat_found = AgentHeartBeat.find_by_instance_id(
                instance_id=None)
        except exception.ModelNotFoundError:
            exception_raised = True

        self.assertIsNone(heartbeat_found)
        self.assertTrue(exception_raised)
開發者ID:magictour,項目名稱:trove,代碼行數:14,代碼來源:test_agent_heartbeats_models.py

示例8: test_find_all_by_version_not_found

    def test_find_all_by_version_not_found(self):
        """
        Test to retrieve all guest agents with a non-existing version
        """
        version = str(uuid.uuid4())
        exception_raised = False
        heartbeats = None
        try:
            heartbeats = AgentHeartBeat.find_all_by_version(version)
        except exception.ModelNotFoundError:
            exception_raised = True

        self.assertIsNone(heartbeats)
        self.assertTrue(exception_raised)
開發者ID:magictour,項目名稱:trove,代碼行數:14,代碼來源:test_agent_heartbeats_models.py

示例9: test_create

    def test_create(self):
        """
        Test the creation of a new agent heartbeat record
        """
        instance_id = str(uuid.uuid4())
        heartbeat = AgentHeartBeat.create(
            instance_id=instance_id)
        self.assertIsNotNone(heartbeat)

        self.assertIsNotNone(heartbeat.id)
        self.assertIsNotNone(heartbeat.instance_id)
        self.assertEqual(instance_id,
                         heartbeat.instance_id)
        self.assertIsNotNone(heartbeat.updated_at)
        self.assertIsNone(heartbeat.guest_agent_version)
開發者ID:magictour,項目名稱:trove,代碼行數:15,代碼來源:test_agent_heartbeats_models.py

示例10: test_find_by_instance_id_not_found

    def test_find_by_instance_id_not_found(self, mock_logging):
        """
        Test to retrieve a guest agents when id is not found
        """
        instance_id = str(uuid.uuid4())
        heartbeat_found = None
        exception_raised = False
        try:
            heartbeat_found = AgentHeartBeat.find_by_instance_id(
                instance_id=instance_id)
        except exception.ModelNotFoundError:
            exception_raised = True

        self.assertIsNone(heartbeat_found)
        self.assertTrue(exception_raised)
開發者ID:magictour,項目名稱:trove,代碼行數:15,代碼來源:test_agent_heartbeats_models.py


注:本文中的trove.guestagent.models.AgentHeartBeat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。