• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.InstanceServiceStatus类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中trove.instance.models.InstanceServiceStatus的典型用法代码示例。如果您正苦于以下问题:Python InstanceServiceStatus类的具体用法?Python InstanceServiceStatus怎么用?Python InstanceServiceStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_upgrade

    def test_upgrade(self, task_upgrade):
        instance_model = DBInstance(
            InstanceTasks.NONE,
            id=str(uuid.uuid4()),
            name="TestUpgradeInstance",
            datastore_version_id=self.datastore_version1.id)
        instance_model.set_task_status(InstanceTasks.NONE)
        instance_model.save()
        instance_status = InstanceServiceStatus(
            ServiceStatuses.RUNNING,
            id=str(uuid.uuid4()),
            instance_id=instance_model.id)
        instance_status.save()
        self.assertIsNotNone(instance_model)
        instance = models.load_instance(models.Instance, self.context,
                                        instance_model.id)

        try:
            instance.upgrade(self.datastore_version2)

            self.assertEqual(self.datastore_version2.id,
                             instance.db_info.datastore_version_id)
            self.assertEqual(InstanceTasks.UPGRADING,
                             instance.db_info.task_status)
            self.assertTrue(task_upgrade.called)
        finally:
            instance_status.delete()
            instance_model.delete()
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:28,代码来源:test_instance_models.py


示例2: get_inst_service_status

 def get_inst_service_status(self, status_id, statuses):
     answers = []
     for i, status in enumerate(statuses):
         inst_svc_status = InstanceServiceStatus(status, id="%s-%s" % (status_id, i))
         inst_svc_status.save = MagicMock(return_value=None)
         answers.append(inst_svc_status)
     return answers
开发者ID:rumale,项目名称:trove,代码行数:7,代码来源:test_models.py


示例3: setUp

 def setUp(self):
     super(BaseDbStatusTest, self).setUp()
     util.init_db()
     self.orig_dbaas_time_sleep = dbaas.time.sleep
     self.FAKE_ID = randint(1, 10000)
     InstanceServiceStatus.create(instance_id=self.FAKE_ID, status=rd_instance.ServiceStatuses.NEW)
     dbaas.CONF.guest_id = self.FAKE_ID
开发者ID:ReVolly,项目名称:trove,代码行数:7,代码来源:test_dbaas.py


示例4: build_db_instance

 def build_db_instance(self, status, task_status=InstanceTasks.NONE):
     version = datastore_models.DBDatastoreVersion.get_by(name='5.5')
     instance = DBInstance(InstanceTasks.NONE,
                           name='test_name',
                           id=str(uuid.uuid4()),
                           flavor_id='flavor_1',
                           datastore_version_id=
                           version.id,
                           compute_instance_id='compute_id_1',
                           server_id='server_id_1',
                           tenant_id='tenant_id_1',
                           server_status=
                           rd_instance.ServiceStatuses.
                           BUILDING.api_status,
                           deleted=False)
     instance.save()
     service_status = InstanceServiceStatus(
         rd_instance.ServiceStatuses.RUNNING,
         id=str(uuid.uuid4()),
         instance_id=instance.id,
     )
     service_status.save()
     instance.set_task_status(task_status)
     instance.server_status = status
     instance.save()
     return instance, service_status
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:26,代码来源:test_models.py


示例5: tearDown

 def tearDown(self):
     super(MySqlAppStatusTest, self).tearDown()
     dbaas.utils.execute_with_timeout = self.orig_utils_execute_with_timeout
     dbaas.load_mysqld_options = self.orig_load_mysqld_options
     dbaas.os.path.exists = self.orig_dbaas_os_path_exists
     dbaas.time.sleep = self.orig_dbaas_time_sleep
     InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
     dbaas.CONF.guest_id = None
开发者ID:dadu1688,项目名称:trove,代码行数:8,代码来源:test_dbaas.py


示例6: update_statuses_on_time_out

    def update_statuses_on_time_out(self):

        if CONF.update_status_on_fail:
            #Updating service status
            service = InstanceServiceStatus.find_by(instance_id=self.id)
            service.set_status(ServiceStatuses.
                               FAILED_TIMEOUT_GUESTAGENT)
            service.save()
            LOG.error(_("Service status: %(status)s") %
                      {'status': ServiceStatuses.
                       FAILED_TIMEOUT_GUESTAGENT.api_status})
            LOG.error(_("Service error description: %(desc)s") %
                      {'desc': ServiceStatuses.
                       FAILED_TIMEOUT_GUESTAGENT.description})
            #Updating instance status
            db_info = DBInstance.find_by(name=self.name)
            db_info.set_task_status(InstanceTasks.
                                    BUILDING_ERROR_TIMEOUT_GA)
            db_info.save()
            LOG.error(_("Trove instance status: %(action)s") %
                      {'action': InstanceTasks.
                       BUILDING_ERROR_TIMEOUT_GA.action})
            LOG.error(_("Trove instance status description: %(text)s") %
                      {'text': InstanceTasks.
                       BUILDING_ERROR_TIMEOUT_GA.db_text})
开发者ID:adamfokken,项目名称:trove,代码行数:25,代码来源:models.py


示例7: setUp

    def setUp(self):
        util.init_db()

        self.datastore = datastore_models.DBDatastore.create(
            id=str(uuid.uuid4()), name="name", default_version_id=str(uuid.uuid4())
        )

        self.datastore_version = datastore_models.DBDatastoreVersion.create(
            id=self.datastore.default_version_id,
            name="name",
            image_id=str(uuid.uuid4()),
            packages=str(uuid.uuid4()),
            datastore_id=self.datastore.id,
            manager="mysql",
            active=1,
        )

        self.master = DBInstance(
            InstanceTasks.NONE,
            id=str(uuid.uuid4()),
            name="TestMasterInstance",
            datastore_version_id=self.datastore_version.id,
        )
        self.master.set_task_status(InstanceTasks.NONE)
        self.master.save()
        self.master_status = InstanceServiceStatus(
            ServiceStatuses.RUNNING, id=str(uuid.uuid4()), instance_id=self.master.id
        )
        self.master_status.save()

        self.safe_nova_client = models.create_nova_client
        models.create_nova_client = nova.fake_create_nova_client
        super(TestReplication, self).setUp()
开发者ID:pombredanne,项目名称:RDS,代码行数:33,代码来源:test_instance_models.py


示例8: _init

 def _init(self):
     self.mock = mox.Mox()
     self.instance_id = 500
     context = trove_testtools.TroveTestContext(self)
     self.db_info = DBInstance.create(
         name="instance",
         flavor_id=OLD_FLAVOR_ID,
         tenant_id=999,
         volume_size=None,
         datastore_version_id=test_config.dbaas_datastore_version_id,
         task_status=InstanceTasks.RESIZING)
     self.server = self.mock.CreateMock(Server)
     self.instance = models.BuiltInstanceTasks(
         context,
         self.db_info,
         self.server,
         datastore_status=InstanceServiceStatus.create(
             instance_id=self.db_info.id,
             status=rd_instance.ServiceStatuses.RUNNING))
     self.instance.server.flavor = {'id': OLD_FLAVOR_ID}
     self.guest = self.mock.CreateMock(guest.API)
     self.instance._guest = self.guest
     self.instance.refresh_compute_server_info = lambda: None
     self.instance._refresh_datastore_status = lambda: None
     self.mock.StubOutWithMock(self.instance, 'update_db')
     self.mock.StubOutWithMock(self.instance,
                               'set_datastore_status_to_paused')
     self.poll_until_mocked = False
     self.action = None
开发者ID:paramtech,项目名称:tesora-trove,代码行数:29,代码来源:instances_resize.py


示例9: _service_is_active

    def _service_is_active(self):
        """
        Check that the database guest is active.

        This function is meant to be called with poll_until to check that
        the guest is alive before sending a 'create' message. This prevents
        over billing a customer for a instance that they can never use.

        Returns: boolean if the service is active.
        Raises: TroveError if the service is in a failure state.
        """
        service = InstanceServiceStatus.find_by(instance_id=self.id)
        status = service.get_status()
        if status == rd_instance.ServiceStatuses.RUNNING:
            return True
        elif status not in [rd_instance.ServiceStatuses.NEW,
                            rd_instance.ServiceStatuses.BUILDING]:
            raise TroveError(_("Service not active, status: %s") % status)

        c_id = self.db_info.compute_instance_id
        nova_status = self.nova_client.servers.get(c_id).status
        if nova_status in [InstanceStatus.ERROR,
                           InstanceStatus.FAILED]:
            raise TroveError(_("Server not active, status: %s") % nova_status)
        return False
开发者ID:adamfokken,项目名称:trove,代码行数:25,代码来源:models.py


示例10: monitor_ha

    def monitor_ha(self, context):
        """Monitors the status of MySQL masters to make sure they are up."""
        LOG.debug("Monitoring Trove Replica Sources (Masters)")

        db_infos = t_models.DBInstance.find_all(deleted=False)
        masters_to_watch = [(instance.slave_of_id, instance) for instance
                            in db_infos.all() if instance.slave_of_id and
                            instance.task_status == InstanceTasks.NONE]

        LOG.debug("Monitoring %s",  masters_to_watch)
        for (master_id, slave) in masters_to_watch:
            master = t_models.DBInstance.find_by(deleted=False, id=master_id)
            service = InstanceServiceStatus.find_by(instance_id=master_id)

            if self._engage_failover(service):
                LOG.debug("Engage FAILOVER from %s to %s NOW!",
                          master_id, slave.id)
                master = t_models.DBInstance.find_by(id=master_id,
                                                     deleted=False)

                self._create_and_auth_clients()

                # Failover Slave to Master by detaching replica source on slave
                self.trove_client.instances.edit(slave.id,
                                                 detach_replica_source=True)

                # Update DNS records for master and slave
                master_dns, slave_dns = self._update_dns_records(master, slave)

                # Finally update the hostnames in trove to
                # reflect the updated DNS information
                self._reflect_dns_updates_in_trove(master, master_dns,
                                                   slave, slave_dns)
开发者ID:SlickNik,项目名称:trove-monitoring-manager,代码行数:33,代码来源:monitoring_manager.py


示例11: _set_status

    def _set_status(self, new_status="RUNNING"):
        from trove.instance.models import InstanceServiceStatus

        print("Setting status to %s" % new_status)
        states = {"RUNNING": rd_instance.ServiceStatuses.RUNNING, "SHUTDOWN": rd_instance.ServiceStatuses.SHUTDOWN}
        status = InstanceServiceStatus.find_by(instance_id=self.id)
        status.status = states[new_status]
        status.save()
开发者ID:jeredding,项目名称:trove,代码行数:8,代码来源:guestagent.py


示例12: 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


示例13: _set_task_status

 def _set_task_status(self, new_status='RUNNING'):
     from trove.instance.models import InstanceServiceStatus
     print("Setting status to %s" % new_status)
     states = {'RUNNING': rd_instance.ServiceStatuses.RUNNING,
               'SHUTDOWN': rd_instance.ServiceStatuses.SHUTDOWN,
               }
     status = InstanceServiceStatus.find_by(instance_id=self.id)
     status.status = states[new_status]
     status.save()
开发者ID:paramtech,项目名称:tesora-trove,代码行数:9,代码来源:guestagent.py


示例14: setUp

 def setUp(self):
     super(MySqlAppTest, self).setUp()
     self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
     self.orig_time_sleep = dbaas.time.sleep
     util.init_db()
     self.FAKE_ID = randint(1, 10000)
     InstanceServiceStatus.create(instance_id=self.FAKE_ID,
                                  status=rd_instance.ServiceStatuses.NEW)
     self.appStatus = FakeAppStatus(self.FAKE_ID,
                                    rd_instance.ServiceStatuses.NEW)
     self.mySqlApp = MySqlApp(self.appStatus)
     mysql_service = {'cmd_start': Mock(),
                      'cmd_stop': Mock(),
                      'cmd_enable': Mock(),
                      'cmd_disable': Mock(),
                      'bin': Mock()}
     dbaas.operating_system.service_discovery = Mock(return_value=
                                                     mysql_service)
     dbaas.time.sleep = Mock()
开发者ID:adamfokken,项目名称:trove,代码行数:19,代码来源:test_dbaas.py


示例15: __call__

 def __call__(self):
     audit_start, audit_end = NotificationTransformer._get_audit_period()
     messages = []
     db_infos = instance_models.DBInstance.find_all(deleted=False)
     for db_info in db_infos:
         service_status = InstanceServiceStatus.find_by(
             instance_id=db_info.id)
         instance = SimpleMgmtInstance(None, db_info, None, service_status)
         message = self.transform_instance(instance, audit_start, audit_end)
         messages.append(message)
     return messages
开发者ID:SlickNik,项目名称:trove,代码行数:11,代码来源:models.py


示例16: _instance_ids_with_failures

 def _instance_ids_with_failures(ids):
     LOG.debug("Checking for service status failures for "
               "instance ids: %s" % ids)
     failed_instance_ids = []
     for instance_id in ids:
         status = InstanceServiceStatus.find_by(
             instance_id=instance_id).get_status()
         if (status == ServiceStatuses.FAILED or
            status == ServiceStatuses.FAILED_TIMEOUT_GUESTAGENT):
                 failed_instance_ids.append(instance_id)
     return failed_instance_ids
开发者ID:ShaguftaMethwani,项目名称:trove,代码行数:11,代码来源:taskmanager.py


示例17: __call__

 def __call__(self):
     audit_start, audit_end = NotificationTransformer._get_audit_period()
     messages = []
     db_infos = instance_models.DBInstance.find_all(deleted=False)
     for db_info in db_infos:
         try:
             service_status = InstanceServiceStatus.find_by(instance_id=db_info.id)
         except exception.ModelNotFoundError:
             # There is a small window of opportunity during when the db
             # resource for an instance exists, but no InstanceServiceStatus
             # for it has yet been created. We skip sending the notification
             # message for all such instances. These instance are too new
             # and will get picked up the next round of notifications.
             LOG.debug("InstanceServiceStatus not found for %s. " "Will wait to send notification." % db_info.id)
             continue
         instance = SimpleMgmtInstance(None, db_info, None, service_status)
         message = self.transform_instance(instance, audit_start, audit_end)
         messages.append(message)
     return messages
开发者ID:zjtheone,项目名称:trove,代码行数:19,代码来源:models.py


示例18: _all_status_ready

 def _all_status_ready(ids):
     LOG.debug("Checking service status of instance ids: %s" % ids)
     for instance_id in ids:
         status = InstanceServiceStatus.find_by(
             instance_id=instance_id).get_status()
         if (status == ServiceStatuses.FAILED or
            status == ServiceStatuses.FAILED_TIMEOUT_GUESTAGENT):
                 # if one has failed, no need to continue polling
                 LOG.debug("Instance %s in %s, exiting polling." % (
                     instance_id, status))
                 return True
         if (status != ServiceStatuses.RUNNING and
            status != ServiceStatuses.BUILD_PENDING):
                 # if one is not in a ready state, continue polling
                 LOG.debug("Instance %s in %s, continue polling." % (
                     instance_id, status))
                 return False
     LOG.debug("Instances are ready, exiting polling for: %s" % ids)
     return True
开发者ID:ShaguftaMethwani,项目名称:trove,代码行数:19,代码来源:taskmanager.py


示例19: __init__

 def __init__(self, host_info):
     self.name = host_info.name
     self.percent_used = host_info.percentUsed
     self.total_ram = host_info.totalRAM
     self.used_ram = host_info.usedRAM
     self.instances = host_info.instances
     for instance in self.instances:
         instance["server_id"] = instance["uuid"]
         del instance["uuid"]
         try:
             db_info = DBInstance.find_by(compute_instance_id=instance["server_id"])
             instance["id"] = db_info.id
             instance["tenant_id"] = db_info.tenant_id
             status = InstanceServiceStatus.find_by(instance_id=db_info.id)
             instance_info = SimpleInstance(None, db_info, status)
             instance["status"] = instance_info.status
         except exception.TroveError as re:
             LOG.error(re)
             LOG.error("Compute Instance ID found with no associated RD " "instance: %s" % instance["server_id"])
             instance["id"] = None
开发者ID:jimbobhickville,项目名称:trove,代码行数:20,代码来源:models.py


示例20: _create

 def _create(self,group_id,type):
     id = self.instance_id
     InstanceServiceStatus.create(status=ServiceStatuses.RUNNING,instance_id=id)
     return InstanceGroupItem.create(self.context,self.tenant_id,id,group_id,type)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:4,代码来源:test_groupItem_models.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tasks.InstanceTask类代码示例发布时间:2022-05-27
下一篇:
Python models.Instance类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap