Esempio n. 1
0
    def online_asmdisk(self, params={}):
        rc = msg_pds.ResponseCode()

        ret, dbs = asm.get_grid_env()
        if ret:
            logger.run.error("Parse oratab env failed: %s" % dbs)
            rc.retcode = msg_mds.RC_MDS_GET_GRID_ENV_FAILED
            return rc, None

        if dbs.has_key("grid_home"):
            grid_home = dbs["grid_home"]
        else:
            logger.run.error("Can not find Oracle grid home")
            rc.retcode = msg_mds.RC_MDS_GET_GRID_ENV_FAILED
            return rc, None

        sql = AsmOraSQLPlus(grid_home)
        if self.asmdisk_name:
            ret, result = sql.online_asm_disk(self.diskgroup_name,
                                              self.asmdisk_name)
        else:
            ret, result = sql.online_asm_disk(self.diskgroup_name,
                                              failgroup=self.failgroup)
        if ret:
            logger.run.error("ASMDisk online failed: %s" % result)
            rc.retcode = msg_mds.RC_MDS_ASMDISK_ONLINE_FAILED
            return rc, None

        logger.run.info("ASMDisk %s online success" % self.asmdisk_name)
        rc.retcode = msg_pds.RC_SUCCESS
        return rc, None
Esempio n. 2
0
    def INIT(self, request):
        self.response = MakeResponse(msg_mds.ASMDISK_DROP_RESPONSE, request)
        self.request = request
        self.request_body = request.body.Extensions[
            msg_mds.asmdisk_drop_request]

        if g.is_ready == False:
            self.response.rc.retcode = msg_mds.RC_MDS_SERVICE_IS_NOT_READY
            self.response.rc.message = "MDS service is not ready"
            self.SendResponse(self.response)
            return MS_FINISH

        asmdisk_name = self.request_body.asmdisk_name
        rebalance_power = self.request_body.rebalance_power
        force = self.request_body.force
        asmdisk_info = common.GetASMDiskInfoByName(asmdisk_name)
        if not asmdisk_info:
            self.response.rc.retcode = msg_mds.RC_MDS_ASMDISK_NOT_EXIST
            self.response.rc.message = "ASMDisk %s not exist" % asmdisk_name
            self.SendResponse(self.response)
            return MS_FINISH
        diskgroup_info = common.GetDiskgroupInfoByID(asmdisk_info.diskgroup_id)
        diskgroup_name = diskgroup_info.diskgroup_name

        ret, dbs = asm.get_grid_env()
        if ret:
            self.response.rc.retcode = msg_mds.RC_MDS_GET_GRID_ENV_FAILED
            self.response.rc.message = "Parse oratab env failed: %s" % dbs
            self.SendResponse(self.response)
            return MS_FINISH

        if dbs.has_key("grid_home"):
            grid_home = dbs["grid_home"]
        else:
            self.response.rc.retcode = msg_mds.RC_MDS_GET_GRID_ENV_FAILED
            self.response.rc.message = "Can not find Oracle grid home"
            self.SendResponse(self.response)
            return MS_FINISH

        sql = AsmOraSQLPlus(grid_home)
        ret, result = sql.drop_asm_disk(diskgroup_name, asmdisk_name, force)
        if ret:
            self.response.rc.retcode = msg_mds.RC_MDS_ASMDISK_DROP_FAILED
            self.response.rc.message = "ASMDisk drop failed: %s" % result
            self.SendResponse(self.response)
            return MS_FINISH

        if rebalance_power:
            ret, result = sql.alter_asm_rebalance(diskgroup_name,
                                                  rebalance_power)
            if ret:
                self.response.rc.retcode = msg_mds.RC_MDS_DISKGROUP_REBALANCE_FAILED
                self.response.rc.message = "Alter diskgroup rebalance failed: %s" % result
                self.SendResponse(self.response)
                return MS_FINISH

        self.response.rc.retcode = msg_pds.RC_SUCCESS
        self.SendResponse(self.response)
        return MS_FINISH
Esempio n. 3
0
    def INIT(self, request):
        self.response = MakeResponse(msg_mds.DISKGROUP_ADD_RESPONSE, request)
        self.request = request
        self.request_body = request.body.Extensions[
            msg_mds.diskgroup_add_request]

        if g.is_ready == False:
            self.response.rc.retcode = msg_mds.RC_MDS_SERVICE_IS_NOT_READY
            self.response.rc.message = "MDS service is not ready"
            self.SendResponse(self.response)
            return MS_FINISH

        diskgroup_name = self.request_body.diskgroup_name
        asmdisk_paths = self.request_body.asmdisk_paths
        failgroups = self.request_body.failgroups
        redundancy = self.request_body.redundancy
        compatible_asm = self.request_body.compatible_asm
        compatible_rdbms = self.request_body.compatible_rdbms

        diskgroup_info = common.GetDiskgroupInfoByName(diskgroup_name)
        if diskgroup_info:
            self.response.rc.retcode = msg_mds.RC_MDS_DISKGROUP_ALREADY_EXIST
            self.response.rc.message = "Diskgroup %s already exist" % diskgroup_name
            self.SendResponse(self.response)
            return MS_FINISH

        ret, dbs = asm.get_grid_env()
        if ret:
            self.response.rc.retcode = msg_mds.RC_MDS_GET_GRID_ENV_FAILED
            self.response.rc.message = "Parse oratab env failed: %s" % dbs
            self.SendResponse(self.response)
            return MS_FINISH

        if dbs.has_key("grid_home"):
            self.grid_home = dbs["grid_home"]
        else:
            self.response.rc.retcode = msg_mds.RC_MDS_GET_GRID_ENV_FAILED
            self.response.rc.message = "Can not find Oracle grid home"
            self.SendResponse(self.response)
            return MS_FINISH

        sql = AsmOraSQLPlus(self.grid_home)
        ret, result = sql.add_asm_group(diskgroup_name, asmdisk_paths,
                                        failgroups, redundancy, compatible_asm,
                                        compatible_rdbms)
        if ret:
            self.response.rc.retcode = msg_mds.RC_MDS_DISKGROUP_ADD_FAILED
            self.response.rc.message = "Diskgroup add failed: %s" % result
            self.SendResponse(self.response)
            return MS_FINISH

        self.response.rc.retcode = msg_pds.RC_SUCCESS
        self.SendResponse(self.response)
        return MS_FINISH
Esempio n. 4
0
    def INIT(self, request):
        self.response = MakeResponse(msg_mds.DISKGROUP_UMOUNT_RESPONSE,
                                     request)
        self.request = request
        self.request_body = request.body.Extensions[
            msg_mds.diskgroup_umount_request]

        if g.is_ready == False:
            self.response.rc.retcode = msg_mds.RC_MDS_SERVICE_IS_NOT_READY
            self.response.rc.message = "MDS service is not ready"
            self.SendResponse(self.response)
            return MS_FINISH

        diskgroup_name = self.request_body.diskgroup_name
        diskgroup_info = common.GetDiskgroupInfoByName(diskgroup_name)
        if not diskgroup_info:
            self.response.rc.retcode = msg_mds.RC_MDS_DISKGROUP_NOT_EXIST
            self.response.rc.message = "Diskgroup %s not exist" % diskgroup_name
            self.SendResponse(self.response)
            return MS_FINISH
        if diskgroup_info.state == "DISMOUNTED":
            self.response.rc.retcode = msg_mds.RC_MDS_DISKGROUP_ALREADY_UMOUNTED
            self.response.rc.message = "Diskgroup %s is not mounted" % diskgroup_name
            self.SendResponse(self.response)
            return MS_FINISH

        ret, dbs = asm.get_grid_env()
        if ret:
            self.response.rc.retcode = msg_mds.RC_MDS_GET_GRID_ENV_FAILED
            self.response.rc.message = "Parse oratab env failed: %s" % dbs
            self.SendResponse(self.response)
            return MS_FINISH

        if dbs.has_key("grid_home"):
            grid_home = dbs["grid_home"]
        else:
            self.response.rc.retcode = msg_mds.RC_MDS_GET_GRID_ENV_FAILED
            self.response.rc.message = "Can not find Oracle grid home"
            self.SendResponse(self.response)
            return MS_FINISH

        sql = AsmOraSQLPlus(grid_home)
        ret, result = sql.umount_asm_group(diskgroup_name)
        if ret:
            self.response.rc.retcode = msg_mds.RC_MDS_DISKGROUP_UMOUNT_FAILED
            self.response.rc.message = "Umount asm diskgroup failed: %s" % result
            self.SendResponse(self.response)
            return MS_FINISH

        self.response.rc.retcode = msg_pds.RC_SUCCESS
        self.SendResponse(self.response)
        return MS_FINISH
Esempio n. 5
0
    def INIT(self, request):
        self.response     = MakeResponse(msg_mds.ASMDISK_OFFLINE_RESPONSE, request)
        self.request      = request
        self.request_body = request.body.Extensions[msg_mds.asmdisk_offline_request]

        if g.is_ready == False:
            self.response.rc.retcode = msg_mds.RC_MDS_SERVICE_IS_NOT_READY
            self.response.rc.message = "MDS service is not ready"
            self.SendResponse(self.response)
            return MS_FINISH

        asmdisk_name = ""
        if self.request_body.HasField('asmdisk_name'):
            asmdisk_name = self.request_body.asmdisk_name
            asmdisk_info = common.GetASMDiskInfoByName(asmdisk_name)
            if not asmdisk_info:
                self.response.rc.retcode = msg_mds.RC_MDS_ASMDISK_NOT_EXIST
                self.response.rc.message = "ASMDisk %s not exist" % asmdisk_name
                self.SendResponse(self.response)
                return MS_FINISH
            if asmdisk_info.mode_status == "OFFLINE":
                self.response.rc.retcode = msg_mds.RC_MDS_ASMDISK_ALREADY_OFFLINE
                self.response.rc.message = "ASMDisk %s is already offline state" % asmdisk_name
                self.SendResponse(self.response)
                return MS_FINISH
            diskgroup_info = common.GetDiskgroupInfoByID(asmdisk_info.diskgroup_id)
            diskgroup_name = diskgroup_info.diskgroup_name
        elif self.request_body.HasField('diskgroup_name') and self.request_body.HasField('failgroup'):
            diskgroup_name = self.request_body.diskgroup_name
            diskgroup_info = common.GetDiskgroupInfoByName(diskgroup_name)
            if not diskgroup_info:
                self.response.rc.retcode = msg_mds.RC_MDS_DISKGROUP_NOT_EXIST
                self.response.rc.message = "Diskgroup %s not exist" % diskgroup_name
                self.SendResponse(self.response)
                return MS_FINISH

            failgroup = self.request_body.failgroup.upper()
            failgroup_list = [asmdisk_info.failgroup for asmdisk_info in g.asmdisk_list.asmdisk_infos if asmdisk_info.diskgroup_id == diskgroup_info.diskgroup_id]
            if failgroup not in failgroup_list:
                self.response.rc.retcode = msg_mds.RC_MDS_FAILGROUP_NOT_IN_DISKGROUP
                self.response.rc.message = "Failgroup %s not in diskgroup %s" % (failgroup, diskgroup_name)
                self.SendResponse(self.response)
                return MS_FINISH
        else:
            self.response.rc.retcode = msg_mds.RC_MDS_ERROR_PARAMS
            self.response.rc.message = "Miss asmdisk/diskgroup/failgroup name"
            self.SendResponse(self.response)
            return MS_FINISH

        ret, dbs = asm.get_grid_env()
        if ret:
            self.response.rc.retcode = msg_mds.RC_MDS_GET_GRID_ENV_FAILED
            self.response.rc.message = "Parse oratab env failed: %s" %dbs
            self.SendResponse(self.response)
            return MS_FINISH

        if dbs.has_key("grid_home"):
            grid_home = dbs["grid_home"]
        else:
            self.response.rc.retcode = msg_mds.RC_MDS_GET_GRID_ENV_FAILED
            self.response.rc.message = "Can not find Oracle grid home"
            self.SendResponse(self.response)
            return MS_FINISH

        sql = AsmOraSQLPlus(grid_home)
        if asmdisk_name:
            ret, result = sql.offline_asm_disk(diskgroup_name, asmdisk_name)
        else:
            ret, result = sql.offline_asm_disk(diskgroup_name, failgroup=failgroup)
        if ret:
            self.response.rc.retcode = msg_mds.RC_MDS_ASMDISK_ONLINE_FAILED
            self.response.rc.message = "ASMDisk offline failed: %s" % result
            self.SendResponse(self.response)
            return MS_FINISH

        self.response.rc.retcode = msg_pds.RC_SUCCESS
        self.SendResponse(self.response)
        return MS_FINISH