Пример #1
0
 def test_grafana_initial_admin_pw(self,
                                   cephadm_module: CephadmOrchestrator):
     with with_host(cephadm_module, 'test'):
         with with_service(cephadm_module, ServiceSpec('mgr')) as _, \
                 with_service(cephadm_module, GrafanaSpec(initial_admin_password='******')):
             out = cephadm_module.cephadm_services[
                 'grafana'].generate_config(
                     CephadmDaemonDeploySpec('test', 'daemon', 'grafana'))
             assert out == ({
                 'files': {
                     'grafana.ini':
                     '# This file is generated by cephadm.\n'
                     '[users]\n'
                     '  default_theme = light\n'
                     '[auth.anonymous]\n'
                     '  enabled = true\n'
                     "  org_name = 'Main Org.'\n"
                     "  org_role = 'Viewer'\n"
                     '[server]\n'
                     "  domain = 'bootstrap.storage.lab'\n"
                     '  protocol = https\n'
                     '  cert_file = /etc/grafana/certs/cert_file\n'
                     '  cert_key = /etc/grafana/certs/cert_key\n'
                     '  http_port = 3000\n'
                     '  http_addr = \n'
                     '[security]\n'
                     '  admin_user = admin\n'
                     '  admin_password = secure\n'
                     '  cookie_secure = true\n'
                     '  cookie_samesite = none\n'
                     '  allow_embedding = true',
                     'provisioning/datasources/ceph-dashboard.yml':
                     "# This file is generated by cephadm.\n"
                     'deleteDatasources:\n\n'
                     "  - name: 'Loki'\n"
                     '    orgId: 2\n\n'
                     'datasources:\n\n'
                     "  - name: 'Loki'\n"
                     "    type: 'loki'\n"
                     "    access: 'proxy'\n"
                     '    orgId: 2\n'
                     "    url: 'http://[1::4]:3100'\n"
                     '    basicAuth: false\n'
                     '    isDefault: true\n'
                     '    editable: false',
                     'certs/cert_file':
                     ANY,
                     'certs/cert_key':
                     ANY
                 }
             }, [])
Пример #2
0
    def test_grafana_config(self, _run_cephadm, cephadm_module: CephadmOrchestrator):
        _run_cephadm.side_effect = async_side_effect(('{}', '', 0))

        with with_host(cephadm_module, 'test'):
            cephadm_module.set_store('grafana_crt', 'c')
            cephadm_module.set_store('grafana_key', 'k')
            with with_service(cephadm_module, MonitoringSpec('prometheus')) as _, \
                    with_service(cephadm_module, GrafanaSpec('grafana')) as _:
                files = {
                    'grafana.ini': dedent("""
                        # This file is generated by cephadm.
                        [users]
                          default_theme = light
                        [auth.anonymous]
                          enabled = true
                          org_name = 'Main Org.'
                          org_role = 'Viewer'
                        [server]
                          domain = 'bootstrap.storage.lab'
                          protocol = https
                          cert_file = /etc/grafana/certs/cert_file
                          cert_key = /etc/grafana/certs/cert_key
                          http_port = 3000
                          http_addr = 
                        [security]
                          disable_initial_admin_creation = true
                          cookie_secure = true
                          cookie_samesite = none
                          allow_embedding = true""").lstrip(),  # noqa: W291
                    'provisioning/datasources/ceph-dashboard.yml': dedent("""
                        # This file is generated by cephadm.
                        deleteDatasources:
                          - name: 'Dashboard1'
                            orgId: 1

                        datasources:
                          - name: 'Dashboard1'
                            type: 'prometheus'
                            access: 'proxy'
                            orgId: 1
                            url: 'http://[1::4]:9095'
                            basicAuth: false
                            isDefault: true
                            editable: false
                        """).lstrip(),
                    'certs/cert_file': dedent("""
                        # generated by cephadm
                        c""").lstrip(),
                    'certs/cert_key': dedent("""
                        # generated by cephadm
                        k""").lstrip(),
                }

                _run_cephadm.assert_called_with(
                    'test',
                    'grafana.test',
                    'deploy',
                    [
                        '--name', 'grafana.test',
                        '--meta-json',
                        '{"service_name": "grafana", "ports": [3000], "ip": null, "deployed_by": [], "rank": null, "rank_generation": null}',
                        '--config-json', '-', '--tcp-ports', '3000'],
                    stdin=json.dumps({"files": files}),
                    image='')