Ejemplo n.º 1
0
    def test_dynamic_change(self):
        """
            Test with changing configuration
        """
        # start with the default on
        StorageConfiguration.CONFIG_PATH = "/"
        StorageConfiguration.CONFIG_FILE = "/configs/not-existing.conf"
        cfg = StorageConfiguration()
        self.logmgr.set_config(cfg)

        # log at various log levels)
        self.logger.error("E1")
        self.logger.warn("W1")
        self.logger.info("I1")
        self.logger.debug("D1")
        self.logger.trace_warn("w1")
        self.logger.trace_info("i1")
        self.logger.trace_verbose("v1")

        # enable tracing and stderr
        cfg.config.set("Log", "Debug", "true")
        cfg.config.set("Log", "Stderr", "true")
        cfg._call_listeners()

        # log at various log levels)
        self.logger.error("E2")
        self.logger.warn("W2")
        self.logger.info("I2")
        self.logger.debug("D2")
        self.logger.trace_warn("w2")
        self.logger.trace_info("i2")
        self.logger.trace_verbose("v2")

        # disable tracing and stderr
        cfg.config.set("Log", "Debug", "false")
        cfg.config.set("Log", "Stderr", "false")
        cfg._call_listeners()

        # log at various log levels)
        self.logger.error("E3")
        self.logger.warn("W3")
        self.logger.info("I3")
        self.logger.debug("D3")
        self.logger.trace_warn("w3")
        self.logger.trace_info("i3")
        self.logger.trace_verbose("v3")

        # check that the messages went through CMPILoggerMock
        cmpi = self.cmpi_stream.getvalue()
        stderr = self.stderr_stream.getvalue()
        self.assertEqual(cmpi, "I:INFO: CMPI log startedE:ERROR: E1W:WARNING: W1I:INFO: I1I:INFO: Started logging to stderr.v:DEBUG: Exiting LogManager._config_changedv:DEBUG: Exiting StorageConfiguration._call_listenersE:ERROR: E2W:WARNING: W2I:INFO: I2v:DEBUG: D2w:Level 19: w2i:Level 18: i2v:DEBUG: v2v:DEBUG: Entering StorageConfiguration._call_listenersv:DEBUG: Entering LogManager._config_changedI:INFO: Stopped logging to stderr.E:ERROR: E3W:WARNING: W3I:INFO: I3")
        self.assertEqual(stderr, "INFO: Started logging to stderr.\nDEBUG: Exiting LogManager._config_changed\nDEBUG: Exiting StorageConfiguration._call_listeners\nERROR: E2\nWARNING: W2\nINFO: I2\nDEBUG: D2\nLevel 19: w2\nLevel 18: i2\nDEBUG: v2\nDEBUG: Entering StorageConfiguration._call_listeners\nDEBUG: Entering LogManager._config_changed\nINFO: Stopped logging to stderr.\n")
Ejemplo n.º 2
0
def get_providers(env):
    """
        CIMOM callback. Initialize OpenLMI and return dictionary of all
        providers we implement.
    """
    # allow **magic here
    # pylint: disable-msg=W0142
    log_manager = cmpi_logging.LogManager(env)

    config = StorageConfiguration()
    config.load()
    log_manager.set_config(config)

    cmpi_logging.logger.info("Provider init.")

    # initialize the timer manager
    timer_manager = TimerManager.get_instance(env)

    indication_manager = IndicationManager.get_instance(
            env, "Storage", config.namespace)

    manager = ProviderManager()
    setting_manager = SettingManager(config, timer_manager)
    setting_manager.load()
    storage = init_anaconda(log_manager, config)

    job_manager = JobManager('Storage', config.namespace,
            indication_manager, timer_manager)

    providers = {}
    # common construction options
    opts = {'storage': storage,
            'config': config,
            'provider_manager': manager,
            'setting_manager': setting_manager,
            'job_manager' : job_manager}

    # StorageDevice providers
    provider = LMI_StorageExtent(**opts)
    manager.add_device_provider(provider)
    providers['LMI_StorageExtent'] = provider

    provider = LMI_MDRAIDStorageExtent(**opts)
    manager.add_device_provider(provider)
    providers['LMI_MDRAIDStorageExtent'] = provider
    setting_provider = SettingHelperProvider(
            setting_helper=provider,
            setting_classname="LMI_MDRAIDStorageSetting",
            **opts)
    manager.add_setting_provider(setting_provider)
    providers['LMI_MDRAIDStorageSetting'] = setting_provider
    assoc_provider = ElementSettingDataProvider(
            setting_provider=setting_provider,
            managed_element_classname="LMI_MDRAIDStorageExtent",
            setting_data_classname="LMI_MDRAIDStorageSetting",
            **opts)
    providers['LMI_MDRAIDElementSettingData'] = assoc_provider

    provider = LMI_DiskPartition(**opts)
    manager.add_device_provider(provider)
    providers['LMI_DiskPartition'] = provider

    provider = LMI_GenericDiskPartition(**opts)
    manager.add_device_provider(provider)
    providers['LMI_GenericDiskPartition'] = provider

    provider = LMI_LVStorageExtent(**opts)
    manager.add_device_provider(provider)
    providers['LMI_LVStorageExtent'] = provider
    setting_provider = SettingHelperProvider(
            setting_helper=provider,
            setting_classname="LMI_LVStorageSetting",
            **opts)
    manager.add_setting_provider(setting_provider)
    providers['LMI_LVStorageSetting'] = setting_provider
    assoc_provider = ElementSettingDataProvider(
            setting_provider=setting_provider,
            managed_element_classname="LMI_LVStorageExtent",
            setting_data_classname="LMI_LVStorageSetting",
            **opts)
    providers['LMI_LVElementSettingData'] = assoc_provider

    provider = LMI_VGStoragePool(**opts)
    manager.add_device_provider(provider)
    providers['LMI_VGStoragePool'] = provider
    setting_provider = SettingHelperProvider(
            setting_helper=provider,
            setting_classname="LMI_VGStorageSetting",
            **opts)
    manager.add_setting_provider(setting_provider)
    providers['LMI_VGStorageSetting'] = setting_provider
    assoc_provider = ElementSettingDataProvider(
            setting_provider=setting_provider,
            managed_element_classname="LMI_VGStoragePool",
            setting_data_classname="LMI_VGStorageSetting",
            **opts)
    providers['LMI_VGElementSettingData'] = assoc_provider
    cap_provider = LMI_LVStorageCapabilities(**opts)
    manager.add_capabilities_provider(cap_provider)
    providers['LMI_LVStorageCapabilities'] = cap_provider
    assoc_provider = LMI_LVElementCapabilities(
            "LMI_LVElementCapabilities",
            cap_provider, provider, **opts)
    providers['LMI_LVElementCapabilities'] = assoc_provider

    # mounting
    provider = LMI_MountedFileSystem(**opts)
    providers['LMI_MountedFileSystem'] = provider

    setting_provider = SettingHelperProvider(
            setting_helper=provider,
            setting_classname="LMI_MountedFileSystemSetting",
            **opts)
    manager.add_setting_provider(setting_provider)
    providers['LMI_MountedFileSystemSetting'] = setting_provider

    assoc_provider = ElementSettingDataProvider(
            setting_provider=setting_provider,
            managed_element_classname="LMI_MountedFileSystem",
            setting_data_classname="LMI_MountedFileSystemSetting",
            **opts)
    providers['LMI_MountedFileSystemElementSettingData'] = assoc_provider

    provider = LMI_HostedMount(**opts)
    providers['LMI_HostedMount'] = provider

    provider = LMI_MountPoint(**opts)
    providers['LMI_MountPoint'] = provider

    provider = LMI_AttachedFileSystem(**opts)
    providers['LMI_AttachedFileSystem'] = provider

    service_provider = LMI_MountConfigurationService(**opts)
    manager.add_service_provider(service_provider)
    providers['LMI_MountConfigurationService'] = service_provider

    cap_provider = LMI_MountedFileSystemCapabilities(**opts)
    manager.add_capabilities_provider(cap_provider)
    providers['LMI_MountedFileSystemCapabilities'] = cap_provider

    assoc_provider = ElementCapabilitiesProvider(
            'LMI_MountElementCapabilities',
            cap_provider, service_provider, **opts)
    providers['LMI_MountElementCapabilities'] = assoc_provider

    # settings
    setting_provider = LMI_DiskPartitionConfigurationSetting(
            ** opts)
    manager.add_setting_provider(setting_provider)
    providers['LMI_DiskPartitionConfigurationSetting'] = setting_provider
    assoc_provider = ElementSettingDataProvider(
            setting_provider=setting_provider,
            managed_element_classname="CIM_DiskPartition",
            setting_data_classname="LMI_DiskPartitionConfigurationSetting",
            **opts)
    providers['LMI_DiskPartitionElementSettingData'] = assoc_provider


    # services & capabilities
    service_provider = LMI_StorageConfigurationService(**opts)
    manager.add_service_provider(service_provider)
    providers['LMI_StorageConfigurationService'] = service_provider
    cap_provider = LMI_VGStorageCapabilities(**opts)
    manager.add_capabilities_provider(cap_provider)
    providers['LMI_VGStorageCapabilities'] = cap_provider
    assoc_provider = ElementCapabilitiesProvider(
            "LMI_VGElementCapabilities",
            cap_provider, service_provider, **opts)
    providers['LMI_VGElementCapabilities'] = assoc_provider

    cap_provider = LMI_MDRAIDStorageCapabilities(**opts)
    manager.add_capabilities_provider(cap_provider)
    providers['LMI_MDRAIDStorageCapabilities'] = cap_provider
    assoc_provider = ElementCapabilitiesProvider(
            "LMI_MDRAIDElementCapabilities",
            cap_provider, service_provider, **opts)
    providers['LMI_MDRAIDElementCapabilities'] = assoc_provider


    service_provider = LMI_DiskPartitionConfigurationService(
            ** opts)

    manager.add_service_provider(service_provider)
    providers['LMI_DiskPartitionConfigurationService'] = service_provider

    cap_provider = LMI_DiskPartitionConfigurationCapabilities(
            ** opts)
    manager.add_capabilities_provider(cap_provider)
    providers['LMI_DiskPartitionConfigurationCapabilities'] = cap_provider
    assoc_provider = ElementCapabilitiesProvider(
            "LMI_DiskPartitionElementCapabilities",
            cap_provider, service_provider, **opts)
    providers['LMI_DiskPartitionElementCapabilities'] = assoc_provider


    # Associations
    provider = LMI_PartitionBasedOn(**opts)
    providers['LMI_PartitionBasedOn'] = provider

    provider = LMI_MDRAIDBasedOn(**opts)
    providers['LMI_MDRAIDBasedOn'] = provider

    provider = LMI_LVBasedOn(**opts)
    providers['LMI_LVBasedOn'] = provider

    provider = LMI_LVAllocatedFromStoragePool(**opts)
    providers['LMI_LVAllocatedFromStoragePool'] = provider

    provider = LMI_VGAssociatedComponentExtent(**opts)
    providers['LMI_VGAssociatedComponentExtent'] = provider

    provider = LMI_HostedStorageService(**opts)
    providers['LMI_HostedStorageService'] = provider

    provider = LMI_SystemStorageDevice(**opts)
    providers['LMI_SystemStorageDevice'] = provider

    provider = LMI_InstalledPartitionTable(**opts)
    providers['LMI_InstalledPartitionTable'] = provider

    fmt = LMI_DataFormatProvider(**opts)
    manager.add_format_provider(fmt)
    providers['LMI_DataFormat'] = fmt

    fmt = LMI_MDRAIDFormatProvider(**opts)
    manager.add_format_provider(fmt)
    providers['LMI_MDRAIDFormat'] = fmt

    fmt = LMI_PVFormatProvider(**opts)
    manager.add_format_provider(fmt)
    providers['LMI_PVFormat'] = fmt

    fmt = LMI_LocalFileSystem(**opts)
    manager.add_format_provider(fmt)
    providers['LMI_LocalFileSystem'] = fmt
    setting_provider = SettingHelperProvider(
            setting_helper=fmt,
            setting_classname="LMI_FileSystemSetting",
            **opts)
    manager.add_setting_provider(setting_provider)
    providers['LMI_FileSystemSetting'] = setting_provider
    assoc_provider = ElementSettingDataProvider(
            setting_provider=setting_provider,
            managed_element_classname="LMI_LocalFileSystem",
            setting_data_classname="LMI_FileSystemSetting",
            **opts)
    providers['LMI_FileSystemElementSettingData'] = assoc_provider

    service_provider = LMI_FileSystemConfigurationService(**opts)
    manager.add_service_provider(service_provider)
    providers['LMI_FileSystemConfigurationService'] = service_provider
    cap_provider = LMI_FileSystemConfigurationCapabilities(
            ** opts)
    manager.add_capabilities_provider(cap_provider)
    providers['LMI_FileSystemConfigurationCapabilities'] = cap_provider
    assoc_provider = ElementCapabilitiesProvider(
            "LMI_FileSystemConfigurationElementCapabilities",
            cap_provider, service_provider, **opts)
    providers['LMI_FileSystemConfigurationElementCapabilities'] = assoc_provider

    provider = LMI_ResidesOnExtent(**opts)
    providers['LMI_ResidesOnExtent'] = provider

    job_providers = job_manager.get_providers()
    providers.update(job_providers)

    provider = LMI_HostedFileSystem(**opts)
    providers['LMI_HostedFileSystem'] = provider

    cmpi_logging.logger.trace_info("Registered providers: %s"
            % (str(providers)))
    return providers
Ejemplo n.º 3
0
def get_providers(env):
    """
        CIMOM callback. Initialize OpenLMI and return dictionary of all
        providers we implement.
    """
    # allow **magic here
    # pylint: disable-msg=W0142
    log_manager = cmpi_logging.LogManager(env)

    config = StorageConfiguration()
    config.load()
    log_manager.set_config(config)

    global indication_manager
    indication_manager = IndicationManager(env, "Storage", config.namespace)

    manager = ProviderManager()
    setting_manager = SettingManager(config)
    setting_manager.load()
    storage = init_anaconda(log_manager, config)

    providers = {}

    job_manager = JobManager("Storage", config.namespace, indication_manager)

    # common construction options
    opts = {
        "storage": storage,
        "config": config,
        "provider_manager": manager,
        "setting_manager": setting_manager,
        "job_manager": job_manager,
    }

    # StorageDevice providers
    provider = LMI_StorageExtent(**opts)
    manager.add_device_provider(provider)
    providers["LMI_StorageExtent"] = provider

    provider = LMI_MDRAIDStorageExtent(**opts)
    manager.add_device_provider(provider)
    providers["LMI_MDRAIDStorageExtent"] = provider
    setting_provider = SettingHelperProvider(
        setting_helper=provider, setting_classname="LMI_MDRAIDStorageSetting", **opts
    )
    manager.add_setting_provider(setting_provider)
    providers["LMI_MDRAIDStorageSetting"] = setting_provider
    assoc_provider = ElementSettingDataProvider(
        setting_provider=setting_provider,
        managed_element_classname="LMI_MDRAIDStorageExtent",
        setting_data_classname="LMI_MDRAIDStorageSetting",
        **opts
    )
    providers["LMI_MDRAIDElementSettingData"] = assoc_provider

    provider = LMI_DiskPartition(**opts)
    manager.add_device_provider(provider)
    providers["LMI_DiskPartition"] = provider

    provider = LMI_GenericDiskPartition(**opts)
    manager.add_device_provider(provider)
    providers["LMI_GenericDiskPartition"] = provider

    provider = LMI_LVStorageExtent(**opts)
    manager.add_device_provider(provider)
    providers["LMI_LVStorageExtent"] = provider
    setting_provider = SettingHelperProvider(setting_helper=provider, setting_classname="LMI_LVStorageSetting", **opts)
    manager.add_setting_provider(setting_provider)
    providers["LMI_LVStorageSetting"] = setting_provider
    assoc_provider = ElementSettingDataProvider(
        setting_provider=setting_provider,
        managed_element_classname="LMI_LVStorageExtent",
        setting_data_classname="LMI_LVStorageSetting",
        **opts
    )
    providers["LMI_LVElementSettingData"] = assoc_provider

    provider = LMI_VGStoragePool(**opts)
    manager.add_device_provider(provider)
    providers["LMI_VGStoragePool"] = provider
    setting_provider = SettingHelperProvider(setting_helper=provider, setting_classname="LMI_VGStorageSetting", **opts)
    manager.add_setting_provider(setting_provider)
    providers["LMI_VGStorageSetting"] = setting_provider
    assoc_provider = ElementSettingDataProvider(
        setting_provider=setting_provider,
        managed_element_classname="LMI_VGStoragePool",
        setting_data_classname="LMI_VGStorageSetting",
        **opts
    )
    providers["LMI_VGElementSettingData"] = assoc_provider
    cap_provider = LMI_LVStorageCapabilities(**opts)
    manager.add_capabilities_provider(cap_provider)
    providers["LMI_LVStorageCapabilities"] = cap_provider
    assoc_provider = LMI_LVElementCapabilities("LMI_LVElementCapabilities", cap_provider, provider, **opts)
    providers["LMI_LVElementCapabilities"] = assoc_provider

    # settings
    setting_provider = LMI_DiskPartitionConfigurationSetting(**opts)
    manager.add_setting_provider(setting_provider)
    providers["LMI_DiskPartitionConfigurationSetting"] = setting_provider
    assoc_provider = ElementSettingDataProvider(
        setting_provider=setting_provider,
        managed_element_classname="CIM_DiskPartition",
        setting_data_classname="LMI_DiskPartitionConfigurationSetting",
        **opts
    )
    providers["LMI_DiskPartitionElementSettingData"] = assoc_provider

    # services & capabilities
    service_provider = LMI_StorageConfigurationService(**opts)
    manager.add_service_provider(service_provider)
    providers["LMI_StorageConfigurationService"] = service_provider
    cap_provider = LMI_VGStorageCapabilities(**opts)
    manager.add_capabilities_provider(cap_provider)
    providers["LMI_VGStorageCapabilities"] = cap_provider
    assoc_provider = ElementCapabilitiesProvider("LMI_VGElementCapabilities", cap_provider, service_provider, **opts)
    providers["LMI_VGElementCapabilities"] = assoc_provider

    cap_provider = LMI_MDRAIDStorageCapabilities(**opts)
    manager.add_capabilities_provider(cap_provider)
    providers["LMI_MDRAIDStorageCapabilities"] = cap_provider
    assoc_provider = ElementCapabilitiesProvider(
        "LMI_MDRAIDElementCapabilities", cap_provider, service_provider, **opts
    )
    providers["LMI_MDRAIDElementCapabilities"] = assoc_provider

    service_provider = LMI_DiskPartitionConfigurationService(**opts)

    manager.add_service_provider(service_provider)
    providers["LMI_DiskPartitionConfigurationService"] = service_provider

    cap_provider = LMI_DiskPartitionConfigurationCapabilities(**opts)
    manager.add_capabilities_provider(cap_provider)
    providers["LMI_DiskPartitionConfigurationCapabilities"] = cap_provider
    assoc_provider = ElementCapabilitiesProvider(
        "LMI_DiskPartitionElementCapabilities", cap_provider, service_provider, **opts
    )
    providers["LMI_DiskPartitionElementCapabilities"] = assoc_provider

    # Associations
    provider = LMI_PartitionBasedOn(**opts)
    providers["LMI_PartitionBasedOn"] = provider

    provider = LMI_MDRAIDBasedOn(**opts)
    providers["LMI_MDRAIDBasedOn"] = provider

    provider = LMI_LVBasedOn(**opts)
    providers["LMI_LVBasedOn"] = provider

    provider = LMI_LVAllocatedFromStoragePool(**opts)
    providers["LMI_LVAllocatedFromStoragePool"] = provider

    provider = LMI_VGAssociatedComponentExtent(**opts)
    providers["LMI_VGAssociatedComponentExtent"] = provider

    provider = LMI_HostedStorageService(**opts)
    providers["LMI_HostedStorageService"] = provider

    provider = LMI_SystemStorageDevice(**opts)
    providers["LMI_SystemStorageDevice"] = provider

    provider = LMI_InstalledPartitionTable(**opts)
    providers["LMI_InstalledPartitionTable"] = provider

    fmt = LMI_DataFormatProvider(**opts)
    manager.add_format_provider(fmt)
    providers["LMI_DataFormat"] = fmt

    fmt = LMI_MDRAIDFormatProvider(**opts)
    manager.add_format_provider(fmt)
    providers["LMI_MDRAIDFormat"] = fmt

    fmt = LMI_PVFormatProvider(**opts)
    manager.add_format_provider(fmt)
    providers["LMI_PVFormat"] = fmt

    fmt = LMI_LocalFileSystem(**opts)
    manager.add_format_provider(fmt)
    providers["LMI_LocalFileSystem"] = fmt
    setting_provider = SettingHelperProvider(setting_helper=fmt, setting_classname="LMI_FileSystemSetting", **opts)
    manager.add_setting_provider(setting_provider)
    providers["LMI_FileSystemSetting"] = setting_provider
    assoc_provider = ElementSettingDataProvider(
        setting_provider=setting_provider,
        managed_element_classname="LMI_LocalFileSystem",
        setting_data_classname="LMI_FileSystemSetting",
        **opts
    )
    providers["LMI_FileSystemElementSettingData"] = assoc_provider

    service_provider = LMI_FileSystemConfigurationService(**opts)
    manager.add_service_provider(service_provider)
    providers["LMI_FileSystemConfigurationService"] = service_provider
    cap_provider = LMI_FileSystemConfigurationCapabilities(**opts)
    manager.add_capabilities_provider(cap_provider)
    providers["LMI_FileSystemConfigurationCapabilities"] = cap_provider
    assoc_provider = ElementCapabilitiesProvider(
        "LMI_FileSystemConfigurationElementCapabilities", cap_provider, service_provider, **opts
    )
    providers["LMI_FileSystemConfigurationElementCapabilities"] = assoc_provider

    provider = LMI_ResidesOnExtent(**opts)
    providers["LMI_ResidesOnExtent"] = provider

    job_providers = job_manager.get_providers()
    providers.update(job_providers)

    print "providers:", providers
    return providers