Mercurial > hg > orthanc-tests
annotate PerfsDb/ConfigFileBuilder.py @ 205:42e4c00fe7c8 Orthanc-1.5.2
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 Jan 2019 19:11:20 +0100 |
parents | 616da104a996 |
children |
rev | line source |
---|---|
156 | 1 import typing |
2 import json | |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
3 import os |
159 | 4 import platform |
156 | 5 |
6 from DbType import DbType | |
7 | |
8 class ConfigFileBuilder: | |
9 | |
10 @staticmethod | |
11 def generate( | |
12 outputPath: str, | |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
13 pluginsPath: str, |
156 | 14 storagePath: str, |
15 dbType: DbType, | |
16 dbSize: str, | |
17 port: int | |
18 ): | |
19 | |
20 config = {} | |
21 config["StorageDirectory"] = storagePath | |
22 | |
23 dbConfig = {} | |
24 dbConfig["EnableIndex"] = True | |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
25 |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
26 if dbType.isServer(): |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
27 dbConfig["Host"] = "127.0.0.1" |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
28 dbConfig["Lock"] = False |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
29 dbConfig["Port"] = port |
156 | 30 |
31 if dbType == DbType.MySQL: | |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
32 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancMySQLIndex.so")] |
156 | 33 dbConfig["EnableStorage"] = False |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
34 # config["Plugins"] = [os.path.join(pluginsPath, "libOrthancMySQLStorage.so")] |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
35 |
156 | 36 dbConfig["Database"] = "orthanc" |
37 dbConfig["Username"] = "orthanc" | |
38 dbConfig["Password"] = "orthanc" | |
39 | |
40 config["MySQL"] = dbConfig | |
41 | |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
42 elif dbType.isPG(): |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
43 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancPostgreSQLIndex.so")] |
156 | 44 dbConfig["EnableStorage"] = False |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
45 # config["Plugins"] = [os.path.join(pluginsPath, "libOrthancPostgreSQLStorage.so")] |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
46 |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
47 dbConfig["Database"] = "postgres" |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
48 dbConfig["Username"] = "postgres" |
156 | 49 |
50 config["PostgreSQL"] = dbConfig | |
51 | |
52 elif dbType == DbType.MSSQL: | |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
53 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancMsSqlIndex.so")] |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
54 dbConfig["EnableStorage"] = False |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
55 |
159 | 56 if platform.node() == "benchmark": # the benchmark VM on Azure is a 18.04 -> it has version 17 |
57 odbcVersion = 17 | |
58 else: | |
59 odbcVersion = 13 | |
60 | |
61 dbConfig["ConnectionString"] = "Driver={ODBC Driver " + str(odbcVersion) + " for SQL Server};Server=tcp:127.0.0.1," + str(port) + ";Database=master;Uid=sa;Pwd=MyStrOngPa55word!;Encrypt=yes;TrustServerCertificate=yes;Connection Timeout=30" | |
156 | 62 dbConfig["LicenseString"] = "1abaamBcReVXv6EtE_X___demo-orthanc%osimis.io___HHHnqVHYvEkR3jGs2Y3EvpbxZgTt7yaCniJa2Bz7hFWTMa" # note: this is a trial license expiring on 2018-09-30, replace with your license code |
63 | |
64 config["MSSQL"] = dbConfig | |
65 | |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
66 elif dbType.isSqlite(): |
156 | 67 config["IndexDirectory"] = storagePath |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
68 if dbType == DbType.SqlitePlugin: |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
69 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancSQLiteIndex.so")] |
156 | 70 |
71 else: | |
72 raise NotImplementedError | |
73 | |
74 with open(outputPath, "w") as configFile: | |
75 json.dump(config, fp=configFile, indent=4) |