예제 #1
0
 def create_backup(self):
     self.inst_id = self._get_rid()
     utils.check_server_status(self.inst_id, type = DBInstanceType.READ_REPLI)
     
     backup = utils.create_backup_byclient(self.inst_id, backup_type='snapshot')
     utils.check_backup_status(backup.id)
     utils.check_backup_path(backup.id)
예제 #2
0
    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)
예제 #3
0
    def create_with_backup(self, inst_id=None, check_admin=True):

        def _create_with_backup(self, backup, admin_user=None, admin_password=None):
            self.inst_id = utils.create_rds_byclient("SG", backup=backup.id, admin_user=admin_user,
                                                     admin_password=admin_password)
            self.validate()
            return self.inst_id

        if inst_id != None:
            self.inst_id = inst_id
        else:
            self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.SINGLE)
        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)
예제 #4
0
    def validate(self):
        utils.check_server_status(self.inst_id, expected_task=utils.tasks.InstanceTasks.NONE,
                                  expected_svr_status=utils.ServiceStatuses.RUNNING,
                                  deleted=False)
        inst_db_info = utils.get_instance(self.inst_id)
        self.group_id = inst_db_info.group_id

        utils.check_mysql_adminuser(inst_db_info.id)
        
        _ret = utils.get_builtin_instance(inst_db_info.id)
        self.nova_instance = _ret.server
        
#         ip = utils.check_allocate_ip(self.nova_instance)
        utils.check_mysql_is_running(inst_db_info.id)
        utils.check_vip(inst_db_info.id)
        
        self.backup_id = utils.check_backup(self.group_id)
        utils.check_backup_status(self.backup_id)
        utils.check_backup_path(self.backup_id)
        
        utils.check_rpl_topo_single(self.group_id)
예제 #5
0
 def validate(self):
     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)
     
     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=600)
     
     rr_items = InstanceGroupItem.get_by_gid_type(utils.get_context(), self.group_id, DBInstanceType.READ_REPLI, deleted = False)
     slave_ids = []
     for rr in rr_items:
         slave_ids.append(rr.instance_id)
     slave_ids.append(self.dbslave_id)
     
     utils.check_mysql_adminuser(self.inst_id)
     utils.check_mysql_adminuser(self.dbslave_id)
     
     for _id in [self.inst_id, self.dbslave_id]:
         utils.check_mysql_is_running(self.inst_id)
     
     utils.check_vip(self.inst_id, vip_id=self.vip_id)
     self.backup_id = utils.check_backup(self.group_id)
     utils.check_backup_status(self.backup_id) 
     utils.check_backup_path(self.backup_id)
     
     for slave_id in slave_ids:
         utils.check_rpl_delay(slave_id)
         
     master_inst = utils.get_builtin_instance(self.inst_id)
     slave_inst = utils.get_builtin_instance(self.dbslave_id)
     master_ip = utils.check_allocate_ip(master_inst.server)
     slave_ip = utils.check_allocate_ip(slave_inst.server)
     LOG.info("master_ip:%s  slave_ip:%s" % (master_ip, slave_ip))
     utils.check_rpl_consist(self.inst_id, slave_ids, master_ip, [slave_ip])
     utils.check_rpl_topo_ha(self.group_id)
예제 #6
0
 def create_backup(self):
     self.inst_id = utils.get_instance_id_bytenant(DBInstanceType.SINGLE)
     
     backup = utils.create_backup_byclient(self.inst_id)
     utils.check_backup_status(backup.id)
     utils.check_backup_path(backup.id)