コード例 #1
0
def test_inventory_url_from_phase(try_satellite6_configuration,
                                  try_satellite5_configuration, get_proxies,
                                  init_session, config_kwargs):
    """
    Inventory URL is composed correctly from the default configuration.
    """
    config = InsightsConfig(**config_kwargs)
    config.load_all()  # Disables legacy upload.
    try_auto_configuration(
        config)  # Updates base_url if legacy upload is disabled.
    connection = InsightsConnection(config)
    assert connection.inventory_url == "https://cert-api.access.redhat.com/r/insights/platform/inventory/v1"
コード例 #2
0
ファイル: v1.py プロジェクト: Shreyanand/insights-core
 def _f():
     compile_config()
     client.set_up_logging()
     if config['debug']:
         logger.info("Core path: %s", os.path.dirname(__file__))
     try_auto_configuration()
     try:
         func()
     except Exception:
         logger.exception("Fatal error")
         sys.exit(1)
     else:
         sys.exit()  # Exit gracefully
コード例 #3
0
ファイル: v1.py プロジェクト: sagaraivale/insights-core
 def _f():
     try:
         compile_config()
     except ValueError as e:
         sys.stderr.write('ERROR:' + e)
         sys.exit(constants.sig_kill_bad)
     client.set_up_logging()
     if config['debug']:
         logger.info("Core path: %s", os.path.dirname(__file__))
     try_auto_configuration()
     try:
         func()
     except Exception:
         logger.exception("Fatal error")
         sys.exit(1)
     else:
         sys.exit()  # Exit gracefully
コード例 #4
0
ファイル: v1.py プロジェクト: sourabhtk37/insights-core
 def _f():
     try:
         config = InsightsConfig().load_all()
     except ValueError as e:
         sys.stderr.write('ERROR: ' + str(e) + '\n')
         sys.exit(constants.sig_kill_bad)
     client = InsightsClient(config)
     client.set_up_logging()
     if config.debug:
         logger.info("Core path: %s", os.path.dirname(__file__))
     try_auto_configuration(config)
     try:
         func(client, config)
     except Exception:
         logger.exception("Fatal error")
         sys.exit(1)
     else:
         sys.exit()  # Exit gracefully
コード例 #5
0
    def malware_detection_app(broker):
        """
        Custom datasource to collects content for malware scanner if a scanner is present on the system
        """

        try:
            # Only run malware-detection if it was passed as an option to insights-client
            insights_config = InsightsConfig().load_all()
            auto_config.try_auto_configuration(insights_config)
            if not (insights_config and hasattr(insights_config, 'app')
                    and insights_config.app == 'malware-detection'):
                raise SkipComponent
            mdc = MalwareDetectionClient(insights_config)
            scan_results = mdc.run()
            if scan_results:
                return DatasourceProvider(
                    content=scan_results,
                    relative_path="malware-detection-results.json")
            else:
                raise SkipComponent
        except Exception:
            raise SkipComponent
コード例 #6
0
def test_platform_path_added():
    '''
    Ensure /platform is added when legacy_upload is false
    Ensure it's not added when legacy_upload is true
    '''
    # auto_config=True, legacy_upload=True
    config = Mock(base_url='test.satellite.com:443/redhat_access/r/insights',
                  auto_config=True,
                  legacy_upload=True,
                  offline=False)
    try_auto_configuration(config)
    assert config.base_url == 'test.satellite.com:443/redhat_access/r/insights'

    # auto_config=True, legacy_upload=False
    config = Mock(base_url='test.satellite.com:443/redhat_access/r/insights',
                  auto_config=True,
                  legacy_upload=False,
                  offline=False)
    try_auto_configuration(config)
    assert config.base_url == 'test.satellite.com:443/redhat_access/r/insights/platform'

    # auto_config=False, legacy_upload=True
    config = Mock(base_url='test.satellite.com:443/redhat_access/r/insights',
                  auto_config=False,
                  legacy_upload=True,
                  offline=False)
    try_auto_configuration(config)
    assert config.base_url == 'test.satellite.com:443/redhat_access/r/insights'

    # auto_config=False, legacy_upload=False
    config = Mock(base_url='test.satellite.com:443/redhat_access/r/insights',
                  auto_config=False,
                  legacy_upload=False,
                  offline=False)
    try_auto_configuration(config)
    assert config.base_url == 'test.satellite.com:443/redhat_access/r/insights/platform'
コード例 #7
0
def test_platform_path_added_cloud_redhat():
    '''
    Ensure /platform is added when legacy_upload is false
    for any base_url ending in /r/insights, otherwise not added
    '''
    # classic API
    config = Mock(base_url='cert-api.access.redhat.com/r/insights',
                  auto_config=True,
                  legacy_upload=False,
                  offline=False)
    try_auto_configuration(config)
    assert config.base_url == 'cert-api.access.redhat.com/r/insights/platform'

    # satellite
    config = Mock(base_url='test.satellite.com:443/redhat_access/r/insights',
                  auto_config=True,
                  legacy_upload=False,
                  offline=False)
    try_auto_configuration(config)
    assert config.base_url == 'test.satellite.com:443/redhat_access/r/insights/platform'

    # cloud.redhat.com compatibility layer - classic API hosted on c.rh.c
    config = Mock(base_url='cloud.redhat.com/r/insights',
                  auto_config=True,
                  legacy_upload=False,
                  offline=False)
    try_auto_configuration(config)
    assert config.base_url == 'cloud.redhat.com/r/insights/platform'

    # cloud.redhat.com API directly connected
    config = Mock(base_url='cloud.redhat.com/api',
                  auto_config=True,
                  legacy_upload=False,
                  offline=False)
    try_auto_configuration(config)
    assert config.base_url == 'cloud.redhat.com/api'