本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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()
示例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)
示例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'])
示例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
示例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()
示例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)
示例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()
示例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)
示例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)
示例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)
示例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
示例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 ")
示例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)
示例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)