Exemplo n.º 1
0
def stop():
    client = S.LocalStorageRouterClient(get_config())
    maybe_id = client.get_volume_id(get_volume_path())
    if maybe_id == None:
        return OCF_ERR_GENERIC
    client.stop_volume(maybe_id)
    return OCF_SUCCESS
Exemplo n.º 2
0
def start():
    client = S.LocalStorageRouterClient(get_config())
    maybe_id = client.get_volume_id(get_volume_path())
    if maybe_id == None:
        return OCF_ERR_GENERIC
    client.migrate_volume(maybe_id, get_node_id())
    return OCF_SUCCESS
Exemplo n.º 3
0
    def check_for_halted_volumes(result_handler):
        """
        Checks for halted volumes on a single or multiple vPools
        :param result_handler: logging object
        :type result_handler: ovs.extensions.healthcheck.result.HCResults
        :return: None
        :rtype: NoneType
        """
        result_handler.info('Checking for halted volumes.', add_to_result=False)
        vpools = VPoolHelper.get_vpools()

        if len(vpools) == 0:
            result_handler.skip('No vPools found!'.format(len(vpools)))
            return

        for vp in vpools:
            if vp.guid not in VolumedriverHealthCheck.LOCAL_SR.vpools_guids:
                result_handler.skip('Skipping vPool {0} because it is not living here.'.format(vp.name))
                continue

            haltedvolumes = []
            result_handler.info('Checking vPool {0}: '.format(vp.name), add_to_result=False)
            if len(vp.storagedrivers) > 0:
                config_file = Configuration.get_configuration_path('/ovs/vpools/{0}/hosts/{1}/config'.format(vp.guid, vp.storagedrivers[0].name))
            else:
                result_handler.failure('The vpool {0} does not have any storagedrivers associated to it!'.format(vp.name))
                continue

            try:
                voldrv_client = src.LocalStorageRouterClient(config_file)
                # noinspection PyArgumentList
                voldrv_volume_list = voldrv_client.list_volumes()
                for volume in voldrv_volume_list:
                    # check if volume is halted, returns: 0 or 1
                    try:
                        # noinspection PyTypeChecker
                        if int(VolumedriverHealthCheck._info_volume(voldrv_client, volume).halted):
                            haltedvolumes.append(volume)
                    except ObjectNotFoundException:
                        # ignore ovsdb invalid entrees
                        # model consistency will handle it.
                        continue
                    except MaxRedirectsExceededException:
                        # this means the volume is not halted but detached or unreachable for the volumedriver
                        haltedvolumes.append(volume)
                    except RuntimeError:
                        haltedvolumes.append(volume)
                    except TimeoutError:
                        # timeout occurred
                        haltedvolumes.append(volume)
                result_handler.success('Volumedriver {0} is up and running.'.format(vp.name))
            except (ClusterNotReachableException, RuntimeError) as ex:
                result_handler.failure('Seems like the Volumedriver {0} is not running.'.format(vp.name, ex.message))
                continue

            # print all results
            if len(haltedvolumes) > 0:
                result_handler.failure('Detected volumes that are HALTED in vPool {0}: {1}'.format(vp.name, ', '.join(haltedvolumes)))
            else:
                result_handler.success('No halted volumes detected in vPool {0}'.format(vp.name))
Exemplo n.º 4
0
def monitor():
    client = S.LocalStorageRouterClient(get_config())
    maybe_id = client.get_volume_id(get_volume_path())
    if maybe_id == None:
        return OCF_NOT_RUNNING
    info = client.info_volume(maybe_id)
    doc = M.parseString(str(info))
    node_id = str(doc.getElementsByTagName(XML_NODE_ID_KEY)[0].firstChild.nodeValue)
    if node_id == None:
        return OCF_ERR_GENERIC
    elif node_id == get_node_id:
        return OCF_SUCCESS
    else:
        return OCF_NOT_RUNNING
Exemplo n.º 5
0
 def __init__(self, vpool_conf_file):
     self.vpool_conf_file = vpool_conf_file
     self.client = src.LocalStorageRouterClient(self.vpool_conf_file)
Exemplo n.º 6
0
    def check_model_consistency(result_handler):
        """
        Checks if the model consistency of OVSDB vs. VOLUMEDRIVER and does a preliminary check on RABBITMQ
        :param result_handler: logging object
        :type result_handler: ovs.extensions.healthcheck.result.HCResults
        :return: None
        :rtype: NoneType
        """
        result_handler.info('Checking model consistency: ')

        # Checking consistency of volumedriver vs. ovsdb and backwards
        for vp in VPoolHelper.get_vpools():
            if vp.guid not in OpenvStorageHealthCheck.LOCAL_SR.vpools_guids:
                result_handler.skip(
                    'Skipping vPool {0} because it is not living here.'.format(
                        vp.name))
                continue
            result_handler.info(
                'Checking consistency of volumedriver vs. ovsdb for {0}: '.
                format(vp.name),
                add_to_result=False)
            missing_in_volumedriver = []
            missing_in_model = []
            config_file = Configuration.get_configuration_path(
                '/ovs/vpools/{0}/hosts/{1}/config'.format(
                    vp.guid, vp.storagedrivers[0].name))
            try:
                voldrv_client = src.LocalStorageRouterClient(config_file)
                # noinspection PyArgumentList
                voldrv_volume_list = voldrv_client.list_volumes()
            except (ClusterNotReachableException, RuntimeError) as ex:
                result_handler.warning(
                    'Seems like the volumedriver {0} is not running. Got {1}'.
                    format(vp.name, ex.message))
                continue

            vdisk_volume_ids = []
            # cross-reference model vs. volumedriver
            for vdisk in vp.vdisks:
                vdisk_volume_ids.append(vdisk.volume_id)
                if vdisk.volume_id not in voldrv_volume_list:
                    missing_in_volumedriver.append(vdisk.guid)
                else:
                    voldrv_volume_list.remove(vdisk.volume_id)
            # cross-reference volumedriver vs. model
            for voldrv_id in voldrv_volume_list:
                if voldrv_id not in vdisk_volume_ids:
                    missing_in_model.append(voldrv_id)

            # display discrepancies for vPool
            if len(missing_in_volumedriver) != 0:
                result_handler.warning(
                    'Detected volumes that are MISSING in volumedriver but are in ovsdb in vpool: {0} - vdisk guid(s):{1}.'
                    .format(vp.name, ' '.join(missing_in_volumedriver)))
            else:
                result_handler.success(
                    'No discrepancies found for ovsdb in vPool {0}'.format(
                        vp.name))

            if len(missing_in_model) != 0:
                result_handler.warning(
                    'Detected volumes that are AVAILABLE in volumedriver but are not in ovsdb in vpool: {0} - vdisk volume id(s):{1}'
                    .format(vp.name, ', '.join(missing_in_model)))
            else:
                result_handler.success(
                    'No discrepancies found for voldrv in vpool {0}'.format(
                        vp.name))