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

Python test_utils.get_instance_id_bytenant函数代码示例

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

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



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

示例1: ha_to_sg

 def ha_to_sg(self):
     self.create()
     master_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
     utils.check_ha_to_sg(master_id, True)
     self.create()
     master_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
     utils.check_ha_to_sg(master_id, False)
     pass
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:8,代码来源:HAInstance.py


示例2: create

 def create(self):
     inst_id = None
     try:
         inst_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
     except Exception as e:
         print e
         pass
     self.inst_id = inst_id
     if not self.inst_id:
         self.inst_id = utils.create_rds_byclient("HA")
     
     utils.check_server_status(self.inst_id, expected_task=utils.tasks.InstanceTasks.NONE,
                               type=DBInstanceType.MASTER,
                               expected_svr_status=utils.ServiceStatuses.RUNNING,
                               deleted=False, timeout=240)
     self.vip_id = utils.get_vip_id(self.inst_id) 
     _inst = utils.get_instance(self.inst_id, deleted = False)
     self.group_id = _inst.group_id
     origin_id = inst_utils.virtual_instid_2_origin_instid(self.inst_id)
     assert _inst.id == origin_id, (_inst.id, origin_id)
  
     self.dbslave_id = utils.get_instance_id(self.group_id, DBInstanceType.STANDBY)
      
     LOG.info('master_id:%s slave_id:%s' % (self.inst_id, self.dbslave_id))
     
     self.validate()
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:26,代码来源:HAInstance.py


示例3: _override_master_to_point_in_time_after_operation

    def _override_master_to_point_in_time_after_operation(self, op_method):
        old_master_inst_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
        master = utils.get_builtin_instance(old_master_inst_id)
        master_vid = master.virtual_instance_id

        # Prepare data before resize.
        db_count = 100 
        utils.generate_databases(master_vid, count = db_count)
        utils.check_generated_databases(master_vid, count = db_count)
        time.sleep(3)
        dt1 = datetime.datetime.now()
        time1 = dt1.strftime('%Y-%m-%d %H:%M:%S')

        def _get_restorable_time(sleep = None):
            if sleep != None:
                time.sleep(sleep)
                
            restorable_time = utils.get_restorable_time(master_vid)
            return restorable_time
        
        before_rt = _get_restorable_time(30)
        op_method()
        after_op_master = utils.get_builtin_instance(master_vid)
        after_rt = _get_restorable_time(30)
        assert before_rt.begin == after_rt.begin and after_rt.end > before_rt.end, \
                                ("before: [%s, %s], after: [%s, %s]" % (before_rt.begin, before_rt.end, after_rt.begin, after_rt.end)) 
        
        # Clear data after resize.
        utils.clear_generated_databases(master_vid, count = db_count)
        utils.check_generated_databases(master_vid, count = 0)
        
        # Restore & check data correctness.
        utils.override_with_backup_byclient(master_vid, None, time1)
        utils.check_server_deleted(after_op_master.id, DBInstanceType.PENDING, timeout = RESTORE_TIME_OUT)
        utils.check_generated_databases(master_vid, count = db_count)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:35,代码来源:HAInstance.py


示例4: override_with_backup

    def override_with_backup(self, instance_id=None):
        self.inst_id = instance_id
        if not self.inst_id:
            self.create()
            self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)

        old_master_instance = utils.get_builtin_instance(self.inst_id)
        old_group_id = old_master_instance.group_id
        
        old_adm_user_1 = utils.check_mysql_adminuser(self.inst_id)
        backup1 = utils.create_backup_byclient(self.inst_id)
        utils.check_backup_status(backup1.id)
                
        new_password = "new_admin_psw" + str(random.randint(0, 100))
        utils.reset_admin_user_byclient(self.inst_id, new_password)
        new_adm_user_1 = utils.check_mysql_adminuser(self.inst_id)
        assert old_adm_user_1['_password'] != new_adm_user_1['_password'], \
            (old_adm_user_1['_password'], new_adm_user_1['_password'])
        backup2 = utils.create_backup_byclient(self.inst_id)
        utils.check_backup_status(backup2.id)
        
        utils.override_with_backup_byclient(self.inst_id, backup1.id)
        utils.check_server_deleted(old_master_instance.id, type = DBInstanceType.PENDING, timeout = 600)


        self.inst_id = utils.get_instance_id(old_group_id, DBInstanceType.MASTER)
        new_master_instance = utils.get_builtin_instance(self.inst_id)
        self.dbslave_id = utils.get_instance_id(old_group_id, DBInstanceType.STANDBY)
        self.vip_id = utils.get_vip_id(self.inst_id)
        self.group_id = new_master_instance.group_id
        self.validate()
        
        new_adm_user_2 = utils.check_mysql_adminuser(self.inst_id)
        assert old_adm_user_1['_password'] == new_adm_user_2['_password'], \
            (old_adm_user_1['_password'], new_adm_user_2['_password'])
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:35,代码来源:HAInstance.py


示例5: switch_master

 def switch_master(self):
     self.create()
     inst_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
     inst = utils.get_builtin_instance(inst_id)
     inst_standby_id = utils.get_instance_id(inst.group_id, DBInstanceType.STANDBY)
     utils.check_switch_master(inst.id, inst_standby_id)
     pass
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:7,代码来源:HAInstance.py


示例6: restart

 def restart(self, instance_id=None):
     self.inst_id = instance_id
     if self.inst_id is None:
         self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
     utils.restart_mysql(self.inst_id)
     utils.check_server_status(self.inst_id, expected_task=utils.tasks.InstanceTasks.NONE,
                               type=DBInstanceType.STANDBY,
                               expected_svr_status=utils.ServiceStatuses.RUNNING,
                               deleted=False, timeout=240)
     self.vip_id = utils.get_vip_id(self.inst_id)
     _inst = utils.get_builtin_instance(self.inst_id)
     self.group_id = _inst.group_id
     assert self.inst_id == _inst.virtual_instance_id, (self.inst_id, _inst.virtual_instance_id)
     self.dbslave_id = utils.get_instance_id(self.group_id, DBInstanceType.STANDBY)
     LOG.info('master_id:%s slave_id:%s' % (self.inst_id, self.dbslave_id))
     
     utils.check_server_status(self.dbslave_id, expected_task=utils.tasks.InstanceTasks.REBOOTING,
                               type=DBInstanceType.STANDBY,
                               expected_svr_status=utils.ServiceStatuses.RUNNING,
                               deleted=False, timeout=240)
     
     utils.check_server_status(self.dbslave_id, expected_task=utils.tasks.InstanceTasks.NONE,
                               type=DBInstanceType.STANDBY,
                               expected_svr_status=utils.ServiceStatuses.RUNNING,
                               deleted=False, timeout=240)
     self.validate()
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:26,代码来源:HAInstance.py


示例7: create_with_backup

    def create_with_backup(self, master_id=None, check_admin=True):

        def _create_with_backup(self, backup, admin_user=None, admin_password=None):
            self.inst_id = utils.create_rds_byclient("HA", backup=backup.id, admin_user=admin_user,
                                                     admin_password=admin_password)
            utils.check_server_status(self.inst_id, expected_task=utils.tasks.InstanceTasks.NONE,
                                      type=DBInstanceType.MASTER,
                                      expected_svr_status=utils.ServiceStatuses.RUNNING,
                                      deleted=False, timeout=600)
            self.vip_id = utils.get_vip_id(self.inst_id)
            _inst = utils.get_builtin_instance(self.inst_id)
            self.group_id = _inst.group_id
            self.dbslave_id = utils.get_instance_id(self.group_id, DBInstanceType.STANDBY)
            LOG.info('master_id:%s slave_id:%s' % (self.inst_id, self.dbslave_id))
            self.validate()
            return self.inst_id

        if master_id is not None:
            self.inst_id = master_id
        else:
            self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)

        if self.inst_id is None:
            raise Exception("not found HA instance")
        #backup = utils.create_backup_byclient(self.inst_id, backup_type='snapshot')
        backup = utils.create_backup_byclient(self.inst_id)
        utils.check_backup_status(backup.id)
        utils.check_backup_path(backup.id)
        _create_with_backup(self, backup, admin_user=None, admin_password=None)
        if check_admin:
            old_adm_user_1 = utils.check_mysql_adminuser(self.inst_id)
            utils.check_admin(self, _create_with_backup, backup, old_adm_user_1)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:32,代码来源:HAInstance.py


示例8: migrate

 def migrate(self, instance_id=None):
     self.inst_id = instance_id
     if not self.inst_id:
         self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.SINGLE)
     
     utils.check_server_status(self.inst_id, 
                               expected_task=utils.tasks.InstanceTasks.NONE,
                               type=DBInstanceType.SINGLE,
                               expected_svr_status=utils.ServiceStatuses.RUNNING,
                               deleted=False)
     
     inst_db_info = utils.get_instance(self.inst_id, deleted= False)
     old_nova_server_id = inst_db_info.compute_instance_id
     
     ran_count = 45
     utils.generate_databases(self.inst_id, count = ran_count)
     _ret = rpc.call(utils.get_context(),
                     "taskmanager",
                     {"method": "migrate",
                      "args": {'migrate_id': inst_db_info.id}})
     
     utils.check_server_status(self.inst_id, 
                               expected_task=utils.tasks.InstanceTasks.NONE,
                               type=DBInstanceType.SINGLE,
                               expected_svr_status=utils.ServiceStatuses.RUNNING,
                               deleted=False)
     
     new_nova_server_id = utils.get_instance(self.inst_id, deleted= False).compute_instance_id
     assert old_nova_server_id != new_nova_server_id
     
     utils.check_generated_databases(self.inst_id, count = ran_count)
     self.validate()
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:32,代码来源:SGInstance.py


示例9: validate

 def validate(self):
     rids = self._get_rids()
     if self.master_id == None:
         self.master_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
         
     for rid in rids:
         self._validate(self.master_id, rid)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:7,代码来源:RRInstance.py


示例10: reset_adm_user

    def reset_adm_user(self):
        self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.SINGLE)
        old_adm_user = utils.check_mysql_adminuser(self.inst_id)

        new_password = "new_admin_psw" + str(random.randint(0, 100))
        utils.reset_admin_user_byclient(self.inst_id, new_password)
        new_adm_user = utils.check_mysql_adminuser(self.inst_id)
        assert old_adm_user['_password'] != new_adm_user['_password'], (old_adm_user, new_adm_user)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:8,代码来源:SGInstance.py


示例11: _lock

 def _lock(self):
     self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
     utils.lock_byclient(self.inst_id)
     utils.check_server_status(self.inst_id, expected_task=utils.tasks.InstanceTasks.LOCKED,
                       type=DBInstanceType.MASTER,
                       expected_svr_status=utils.ServiceStatuses.RUNNING,
                       deleted=False, timeout=240)
     utils.check_instance_is_lock(self.inst_id)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:8,代码来源:HAInstance.py


示例12: attach_vip

 def attach_vip(self):
     self.create()
     instance_id = utils.get_instance_id_bytenant(DBInstanceType.SINGLE)
     self.inst_id = utils.create_rds_byclient("SG")
     self.validate()
     attach_instance_id = self.inst_id
     utils.check_vip_attach(instance_id, attach_instance_id)
     pass
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:8,代码来源:SGInstance.py


示例13: resize_ha

    def resize_ha(self, instance_id=None):
        self.inst_id = instance_id
        if not self.inst_id:
            self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
        _inst = utils.get_instance(self.inst_id, deleted=0)
        self.group_id = _inst.group_id

        master = InstanceGroupItem.get_by_gid_type(utils.get_context(), self.group_id, DBInstanceType.MASTER)
        standby = InstanceGroupItem.get_by_gid_type(utils.get_context(), self.group_id, DBInstanceType.STANDBY)
        if master:
            old_master_inst_id = master.instance_id
        if standby:
            old_standy_inst_id = standby.instance_id
        
        old_master_inst = utils.get_builtin_instance(old_master_inst_id)
        old_flavor_id = old_master_inst.flavor_id
        old_virtual_instance_id = old_master_inst.virtual_instance_id
        self.inst_id = old_master_inst.id
        
        if old_flavor_id not in ['1', '2', '3', '4']:
            raise Exception("It is not support to do resizing based on flavor id: %s, supported flavor_ids should be in (1,2,3,4)" % (old_flavor_id))
        
        flavor = str(int(old_flavor_id) + 1)
        LOG.info("old flavor : %s, new flavor : %s" % (old_flavor_id, flavor))
        
        utils.resize_flavor_byclient(self.inst_id, flavor)
        inst_ids = utils.check_resize_status(self.group_id)

        if len(inst_ids) >= 2:
            utils.check_rpl_delay(inst_ids[0])
            utils.check_rpl_delay(inst_ids[1])

            import time

            time.sleep(60)

            new_master = utils.get_builtin_instance(old_virtual_instance_id)
            new_standby = InstanceGroupItem.get_by_gid_type(utils.get_context(), new_master.group_id, DBInstanceType.STANDBY)

            if new_master.virtual_instance_id == old_virtual_instance_id and \
                            new_master.id != old_master_inst.id:
                self.inst_id = new_master.id
                self.dbslave_id = new_standby.instance_id
                self.vip_id = utils.get_vip_id(self.inst_id)
            else:
                raise Exception("resize for ha failed,new_master.virtual_instance_id %s,"
                                " old_virtual_instance_id %s, new_master.id %s,"
                                " old_master_inst.id %s, new_standby_id %s,"
                                " old_standy_inst_id %s" % (
                                    new_master.virtual_instance_id, old_virtual_instance_id,
                                    new_master.id, old_master_inst.id,
                                    new_standby.instance_id, old_standy_inst_id))
            
            self.validate()
            
        else:
            raise Exception("the num of instance_id should be equal or greater than two after resize HA ")
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:57,代码来源:HAInstance.py


示例14: modify

    def modify(self):
        modify_name = 'modify_name' + str(random.randint(0, 100))
        modify_admin_user = 'master' + str(random.randint(0, 100))
        modify_admin_password = str(random.randint(0, 100))
        self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.SINGLE)
        if self.inst_id is None:
            raise Exception("not found SINGLE instance")
        instance = utils.get_builtin_instance(self.inst_id)

        utils.check_modify(self, instance, modify_name, modify_admin_user, modify_admin_password)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:10,代码来源:SGInstance.py


示例15: delete_backup

 def delete_backup(self):
     self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.SINGLE)
     _list = Backup.list_for_instance(self.inst_id)
     _backup = None
     for _item in _list:
         _backup = _item
         break
     if _backup is None:
         raise Exception("not found backup")
     utils.delete_backup_byclient(_backup.id)
     utils.check_backup_status(_backup.id, 'DELETED', deleted=True)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:11,代码来源:SGInstance.py


示例16: create

 def create(self):
     inst_id = None
     try:
         inst_id = utils.get_instance_id_bytenant(DBInstanceType.SINGLE)
     except Exception as e:
         LOG.error(e)
         pass
     self.inst_id = inst_id
     if not self.inst_id:
         self.inst_id = utils.create_rds_byclient("SG")
     self.validate()
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:11,代码来源:SGInstance.py


示例17: delete

    def delete(self):
        self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.SINGLE)
        _master_vm_id = utils.get_instance(self.inst_id).compute_instance_id

        utils.delete_rds_byclient(self.inst_id)
        utils.check_vm_is_running(_master_vm_id, expect_status="DELETED", timeout=CONF.nova_delete_timeout)
        
        utils.check_server_status(self.inst_id, expected_task=utils.tasks.InstanceTasks.NONE,
                                  expected_svr_status=utils.ServiceStatuses.DELETED,
                                  deleted=True, timeout=CONF.nova_delete_timeout)
        
        utils.check_vip(self.inst_id, deleted=True)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:12,代码来源:SGInstance.py


示例18: upgradeha

 def upgradeha(self,instance_id=None):
     self.inst_id = instance_id
     if not self.inst_id:
         self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.SINGLE)
     self.group_id = utils.get_instance(self.inst_id).group_id
     
     utils.upgrade_ha_byclient(self.inst_id)
     utils.check_server_status(self.inst_id, expected_task=utils.tasks.InstanceTasks.NONE,
                               type=DBInstanceType.MASTER,
                               expected_svr_status=utils.ServiceStatuses.RUNNING,
                               deleted=False)
     _ha = HAInstance()
     _ha.create()
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:13,代码来源:SGInstance.py


示例19: _unlock

 def _unlock(self):
     self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
     utils.unlock_byclient(self.inst_id)
     utils.check_server_status(self.inst_id, expected_task=utils.tasks.InstanceTasks.NONE,
                       type=DBInstanceType.MASTER,
                       expected_svr_status=utils.ServiceStatuses.RUNNING,
                       deleted=False, timeout=240)
     self.vip_id = utils.get_vip_id(self.inst_id) 
     _inst = utils.get_builtin_instance(self.inst_id)
     self.group_id = _inst.group_id
     assert self.inst_id == _inst.virtual_instance_id, (self.inst_id, _inst.virtual_instance_id)
     self.dbslave_id = utils.get_instance_id(self.group_id, DBInstanceType.STANDBY)
     LOG.info('master_id:%s slave_id:%s' % (self.inst_id, self.dbslave_id))
     self.validate()
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:14,代码来源:HAInstance.py


示例20: create_with_config

    def create_with_config(self):
        self.master_id = utils.get_instance_id_bytenant(DBInstanceType.MASTER)
        
        utils.check_server_status(self.master_id,expected_task=utils.tasks.InstanceTasks.NONE,
                                  type=DBInstanceType.MASTER,
                                  expected_svr_status=utils.ServiceStatuses.RUNNING,
                                  deleted=False,timeout=10)
        _inst = utils.get_builtin_instance(self.master_id)
        self.group_id = _inst.group_id

        config = utils.get_config_bytenant()
        if not config:
            raise Exception("not found template config")
        self.inst_id = utils.create_rds_byclient("RR",instance_id = self.master_id, config_id = config.id)
        self.validate()
        utils.check_instancedb_mysql_variables(self.inst_id)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:16,代码来源:RRInstance.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python config.CONFIG类代码示例发布时间:2022-05-27
下一篇:
Python instance_info.get_address函数代码示例发布时间: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