summaryrefslogtreecommitdiff
path: root/config/generate-config
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2019-06-11 16:52:33 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2019-06-11 16:52:33 +0200
commit29d8195fb7f108378404a7e7385426f8e92885b1 (patch)
tree8d93e9345f4d4cea1f3fb2f252eb612c26f55b3c /config/generate-config
parentd5dc9d68b50ead14c78eb6c2f1db06dfe947e60b (diff)
downloaddeployment-29d8195fb7f108378404a7e7385426f8e92885b1.tar.gz
deployment-29d8195fb7f108378404a7e7385426f8e92885b1.tar.bz2
deployment-29d8195fb7f108378404a7e7385426f8e92885b1.zip
Refactoring config generator
Diffstat (limited to 'config/generate-config')
-rwxr-xr-xconfig/generate-config549
1 files changed, 265 insertions, 284 deletions
diff --git a/config/generate-config b/config/generate-config
index aff3ec3..5bb06b9 100755
--- a/config/generate-config
+++ b/config/generate-config
@@ -7,281 +7,287 @@ import os
import urllib.parse
import stat
-sections = OrderedDict()
-
-def cfg_put(section_name, key, value):
- s = sections[section_name] = sections.get(section_name, OrderedDict())
- s[key] = value
-
-def cfg_write(file):
- for section_name, section in sections.items():
- file.write("[" + section_name + "]" + "\n")
- for key, value in section.items():
- file.write(key + " = " + value + "\n")
- file.write("\n")
-
-def coin(currency,
- name,
- value,
- d_overlap="5 minutes",
- d_withdraw="3 years",
- d_spend="5 years",
- d_legal="10 years",
- f_withdraw="0.01",
- f_deposit="0.01",
- f_refresh="0.01",
- f_refund="0.01",
- rsa_keysize="2048"):
- sec = "coin_"+currency+"_"+name
- cfg_put(sec, "value", currency+":"+value)
- cfg_put(sec, "duration_overlap", d_overlap)
- cfg_put(sec, "duration_withdraw", d_withdraw)
- cfg_put(sec, "duration_spend", d_spend)
- cfg_put(sec, "duration_legal", d_legal)
- cfg_put(sec, "fee_withdraw", currency+":"+f_withdraw)
- cfg_put(sec, "fee_refresh", currency+":"+f_refresh)
- cfg_put(sec, "fee_refund", currency+":"+f_refund)
- cfg_put(sec, "fee_deposit", currency+":"+f_deposit)
- cfg_put(sec, "rsa_keysize", rsa_keysize)
-
-def config(currency, envname, exchange_pub, standalone):
- cfg_put("paths", "TALER_DEPLOYMENT_SHARED", "${HOME}/shared-data")
- cfg_put("taler", "CURRENCY", currency)
+class ConfigFile:
+ def __init__(self, standalone, envname, currency, exchange_pub, filename):
+ self.sections = OrderedDict()
+ self.envname = envname
+ self.standalone = standalone
+ self.filename = filename
+ self.currency = currency
+ self.exchange_pub = exchange_pub
+
+ def destroy(self):
+ del self.sections
+ self.sections = OrderedDict()
+
+ def cfg_put(self, section_name, key, value):
+ s = self.sections[section_name] = self.sections.get(section_name, OrderedDict())
+ s[key] = value
+
+ def cfg_write(self, outdir):
+
+ if outdir:
+ fstream = open(os.path.join(outdir, self.filename), "w")
+ else:
+ fstream = open(sys.stdout)
+
+ for section_name, section in self.sections.items():
+ fstream.write("[" + section_name + "]" + "\n")
+ for key, value in section.items():
+ fstream.write(key + " = " + value + "\n")
+ fstream.write("\n")
+ fstream.close()
+
+def coin(obj,
+ name,
+ value,
+ d_overlap="5 minutes",
+ d_withdraw="3 years",
+ d_spend="5 years",
+ d_legal="10 years",
+ f_withdraw="0.01",
+ f_deposit="0.01",
+ f_refresh="0.01",
+ f_refund="0.01",
+ rsa_keysize="2048"):
+ sec = "coin_"+obj.currency+"_"+name
+ obj.cfg_put(sec, "value", obj.currency+":"+value)
+ obj.cfg_put(sec, "duration_overlap", d_overlap)
+ obj.cfg_put(sec, "duration_withdraw", d_withdraw)
+ obj.cfg_put(sec, "duration_spend", d_spend)
+ obj.cfg_put(sec, "duration_legal", d_legal)
+ obj.cfg_put(sec, "fee_withdraw", obj.currency+":"+f_withdraw)
+ obj.cfg_put(sec, "fee_refresh", obj.currency+":"+f_refresh)
+ obj.cfg_put(sec, "fee_refund", obj.currency+":"+f_refund)
+ obj.cfg_put(sec, "fee_deposit", obj.currency+":"+f_deposit)
+ obj.cfg_put(sec, "rsa_keysize", rsa_keysize)
+
+def config(obj):
+ obj.cfg_put("paths", "TALER_DEPLOYMENT_SHARED", "${HOME}/shared-data")
+ obj.cfg_put("taler", "CURRENCY", obj.currency)
# Twisting the merchant backend responses.
- if "test" == envname:
- cfg_put("twister", "serve", "unix")
- cfg_put("twister", "chaos_rate", "20")
- cfg_put("twister", "destination_base_url", "https://backend.test.taler.net/")
- cfg_put("twister", "serve_unixpath", "$HOME/sockets/twister.http")
- cfg_put("twister", "serve_unixmode", "660")
- cfg_put("twister", "unixpath", "$HOME/sockets/twister-control.sock")
- cfg_put("twister", "unix_match_uid", "no")
- cfg_put("twister", "unix_match_gid", "yes")
-
- cfg_put("bank", "serve", "uwsgi")
- cfg_put("bank", "uwsgi_serve", "unix")
- cfg_put("bank", "uwsgi_unixpath", "$HOME/sockets/bank.uwsgi")
- cfg_put("bank", "uwsgi_unixpath_mode", "660")
- cfg_put("bank", "database", "taler"+envname)
- cfg_put("bank", "max_debt", "%s:20.0" % currency)
- cfg_put("bank", "max_debt_bank", "%s:0.0" % currency)
- if standalone:
- cfg_put("bank", "database", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
+ if "test" == obj.envname:
+ obj.cfg_put("twister", "serve", "unix")
+ obj.cfg_put("twister", "chaos_rate", "20")
+ obj.cfg_put("twister", "destination_base_url", "https://backend.test.taler.net/")
+ obj.cfg_put("twister", "serve_unixpath", "$HOME/sockets/twister.http")
+ obj.cfg_put("twister", "serve_unixmode", "660")
+ obj.cfg_put("twister", "unixpath", "$HOME/sockets/twister-control.sock")
+ obj.cfg_put("twister", "unix_match_uid", "no")
+ obj.cfg_put("twister", "unix_match_gid", "yes")
+
+ obj.cfg_put("bank", "serve", "uwsgi")
+ obj.cfg_put("bank", "uwsgi_serve", "unix")
+ obj.cfg_put("bank", "uwsgi_unixpath", "$HOME/sockets/bank.uwsgi")
+ obj.cfg_put("bank", "uwsgi_unixpath_mode", "660")
+ obj.cfg_put("bank", "database", "taler"+obj.envname)
+ obj.cfg_put("bank", "max_debt", "%s:20.0" % obj.currency)
+ obj.cfg_put("bank", "max_debt_bank", "%s:0.0" % obj.currency)
+
+
+ if obj.standalone:
+ obj.cfg_put("bank", "database", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
else:
- cfg_put("bank", "database", "postgres:///taler{}".format(envname))
+ obj.cfg_put("bank", "database", "postgres:///taler{}".format(obj.envname))
- if standalone:
- cfg_put("bank", "suggested_exchange", "https://env.taler.net/{}/exchange/".format(envname))
+ if obj.standalone:
+ obj.cfg_put("bank", "suggested_exchange", "https://env.taler.net/{}/exchange/".format(obj.envname))
else:
- cfg_put("bank", "suggested_exchange", "https://exchange.{}.taler.net/".format(envname))
+ obj.cfg_put("bank", "suggested_exchange", "https://exchange.{}.taler.net/".format(obj.envname))
- cfg_put("bank-admin", "uwsgi_serve", "unix")
- cfg_put("bank-admin", "uwsgi_unixpath", "$HOME/sockets/bank-admin.uwsgi")
- cfg_put("bank-admin", "uwsgi_unixpath_mode", "660")
+ obj.cfg_put("bank-admin", "uwsgi_serve", "unix")
+ obj.cfg_put("bank-admin", "uwsgi_unixpath", "$HOME/sockets/bank-admin.uwsgi")
+ obj.cfg_put("bank-admin", "uwsgi_unixpath_mode", "660")
- cfg_put("donations", "uwsgi_serve", "unix")
- cfg_put("donations", "uwsgi_unixpath", "$HOME/sockets/donations.uwsgi")
- cfg_put("donations", "uwsgi_unixpath_mode", "660")
+ obj.cfg_put("donations", "uwsgi_serve", "unix")
+ obj.cfg_put("donations", "uwsgi_unixpath", "$HOME/sockets/donations.uwsgi")
+ obj.cfg_put("donations", "uwsgi_unixpath_mode", "660")
- cfg_put("survey", "uwsgi_serve", "unix")
- cfg_put("survey", "uwsgi_unixpath", "$HOME/sockets/survey.uwsgi")
- cfg_put("survey", "uwsgi_unixpath_mode", "660")
+ obj.cfg_put("survey", "uwsgi_serve", "unix")
+ obj.cfg_put("survey", "uwsgi_unixpath", "$HOME/sockets/survey.uwsgi")
+ obj.cfg_put("survey", "uwsgi_unixpath_mode", "660")
- cfg_put("blog", "uwsgi_serve", "unix")
- cfg_put("blog", "uwsgi_unixpath", "$HOME/sockets/shop.uwsgi")
- cfg_put("blog", "uwsgi_unixpath_mode", "660")
- cfg_put("blog", "instance", "FSF")
+ obj.cfg_put("blog", "uwsgi_serve", "unix")
+ obj.cfg_put("blog", "uwsgi_unixpath", "$HOME/sockets/shop.uwsgi")
+ obj.cfg_put("blog", "uwsgi_unixpath_mode", "660")
+ obj.cfg_put("blog", "instance", "FSF")
- cfg_put("playground", "uwsgi_serve", "unix")
- cfg_put("playground", "uwsgi_unixpath", "$HOME/sockets/playground.uwsgi")
- cfg_put("playground", "uwsgi_unixpath_mode", "660")
+ obj.cfg_put("playground", "uwsgi_serve", "unix")
+ obj.cfg_put("playground", "uwsgi_unixpath", "$HOME/sockets/playground.uwsgi")
+ obj.cfg_put("playground", "uwsgi_unixpath_mode", "660")
- if standalone:
- cfg_put("backoffice-all", "backend", "https://env.taler.net/{}/merchant-backend/".format(envname))
+ if obj.standalone:
+ obj.cfg_put("backoffice-all", "backend", "https://env.taler.net/{}/merchant-backend/".format(obj.envname))
else:
- cfg_put("backoffice-all", "backend", "https://backend.{}.taler.net/".format(envname))
+ obj.cfg_put("backoffice-all", "backend", "https://backend.{}.taler.net/".format(obj.envname))
# Keep only one back-office service for all instances, for simplicity.
- cfg_put("backoffice-all", "uwsgi_serve", "unix")
- cfg_put("backoffice-all", "uwsgi_unixpath_mode", "660")
- cfg_put("backoffice-all", "uwsgi_unixpath", "$HOME/sockets/backoffice.uwsgi")
- cfg_put("backoffice-all", "instances", "FSF default Tor")
-
- cfg_put("merchant", "wireformat", "test")
- cfg_put("merchant", "serve", "unix")
- cfg_put("merchant", "unixpath", "$HOME/sockets/merchant.http")
- cfg_put("merchant", "wire_transfer_delay", "0 s")
- cfg_put("merchant", "default_max_wire_fee", currency + ":" + "0.01")
- cfg_put("merchant", "default_max_deposit_fee", currency + ":" + "0.05")
-
- if standalone:
- cfg_put("merchantdb-postgres", "config", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
+ obj.cfg_put("backoffice-all", "uwsgi_serve", "unix")
+ obj.cfg_put("backoffice-all", "uwsgi_unixpath_mode", "660")
+ obj.cfg_put("backoffice-all", "uwsgi_unixpath", "$HOME/sockets/backoffice.uwsgi")
+ obj.cfg_put("backoffice-all", "instances", "FSF default Tor")
+
+ obj.cfg_put("merchant", "wireformat", "test")
+ obj.cfg_put("merchant", "serve", "unix")
+ obj.cfg_put("merchant", "unixpath", "$HOME/sockets/merchant.http")
+ obj.cfg_put("merchant", "wire_transfer_delay", "0 s")
+ obj.cfg_put("merchant", "default_max_wire_fee", obj.currency + ":" + "0.01")
+ obj.cfg_put("merchant", "default_max_deposit_fee", obj.currency + ":" + "0.05")
+
+ if obj.standalone:
+ obj.cfg_put("merchantdb-postgres", "config", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
else:
- cfg_put("merchantdb-postgres", "config", "postgres:///taler{}".format(envname))
+ obj.cfg_put("merchantdb-postgres", "config", "postgres:///taler{}".format(obj.envname))
- if standalone:
- cfg_put("merchant-exchange-test", "url", "https://env.taler.net/{}/exchange/".format(envname))
+ if obj.standalone:
+ obj.cfg_put("merchant-exchange-test", "url", "https://env.taler.net/{}/exchange/".format(obj.envname))
else:
- cfg_put("merchant-exchange-test", "url", "https://exchange.{}.taler.net/".format(envname))
+ obj.cfg_put("merchant-exchange-test", "url", "https://exchange.{}.taler.net/".format(obj.envname))
- cfg_put("merchant-exchange-test", "master_key", exchange_pub)
+ obj.cfg_put("merchant-exchange-test", "master_key", obj.exchange_pub)
- cfg_put("frontends", "backend_apikey", "sandbox".format(envname))
+ obj.cfg_put("frontends", "backend_apikey", "sandbox".format(obj.envname))
- if standalone:
- cfg_put("frontends", "backend", "https://env.taler.net/{}/merchant-backend/".format(envname))
+ if obj.standalone:
+ obj.cfg_put("frontends", "backend", "https://env.taler.net/{}/merchant-backend/".format(obj.envname))
else:
- if "test" == envname:
- cfg_put("frontends", "backend", "https://twister-backend.wild.gv.taler.net/")
+ if "test" == obj.envname:
+ obj.cfg_put("frontends", "backend", "https://twister-backend.wild.gv.taler.net/")
else:
- assert ("demo" == envname)
- cfg_put("frontends", "backend", "https://backend.{}.taler.net/".format(envname))
+ assert ("demo" == obj.envname)
+ obj.cfg_put("frontends", "backend", "https://backend.{}.taler.net/".format(obj.envname))
- cfg_put("exchange-{}".format(currency), "master_key", exchange_pub)
- cfg_put("exchange-{}".format(currency), "currency", currency)
- if standalone:
- cfg_put("exchange-{}".format(currency), "base_url", "https://env.taler.net/{}/exchange".format(envname))
+ obj.cfg_put("exchange-{}".format(obj.currency), "master_key", obj.exchange_pub)
+ obj.cfg_put("exchange-{}".format(obj.currency), "currency", obj.currency)
+ if obj.standalone:
+ obj.cfg_put("exchange-{}".format(obj.currency), "base_url", "https://env.taler.net/{}/exchange".format(obj.envname))
else:
- cfg_put("exchange-{}".format(currency), "base_url", "https://exchange.{}.taler.net/".format(envname))
-
- cfg_put("auditor", "auditor_priv_file", "${TALER_DEPLOYMENT_SHARED}/auditor/offline-keys/auditor.priv")
- cfg_put("auditor", "serve", "unix")
- cfg_put("auditor", "auditor_url", "https://auditor.{}.taler.net/service/".format(envname))
- cfg_put("auditor", "unixpath", "$HOME/sockets/auditor.http")
- cfg_put("auditor", "reports", "${TALER_DEPLOYMENT_SHARED}/auditor/reports")
-
- cfg_put("exchange", "base_url", "https://exchange.{}.taler.net/".format(envname))
- cfg_put("exchange", "serve", "unix")
- cfg_put("exchange", "unixpath", "$HOME/sockets/exchange.http")
- cfg_put("exchange", "master_public_key", exchange_pub)
-
- cfg_put("exchange", "master_priv_file", "${TALER_DEPLOYMENT_SHARED}/exchange/offline-keys/master.priv")
- cfg_put("exchange", "keydir", "${TALER_DEPLOYMENT_SHARED}/exchange/live-keys/")
-
- cfg_put("exchangedb", "auditor_base_dir", "${TALER_DEPLOYMENT_SHARED}/exchange/auditors/")
- cfg_put("exchangedb", "wirefee_base_dir", "${TALER_DEPLOYMENT_SHARED}/exchange/wirefees/")
- cfg_put("exchangedb", "auditor_inputs", "${TALER_DEPLOYMENT_SHARED}/exchange/auditor-inputs/")
-
- if standalone:
- cfg_put("exchangedb-postgres", "db_conn_str", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
- cfg_put("exchangedb-postgres", "config", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
- cfg_put("auditordb-postgres", "db_conn_str", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
- cfg_put("auditordb-postgres", "config", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
+ obj.cfg_put("exchange-{}".format(obj.currency), "base_url", "https://exchange.{}.taler.net/".format(obj.envname))
+
+ obj.cfg_put("auditor", "auditor_priv_file", "${TALER_DEPLOYMENT_SHARED}/auditor/offline-keys/auditor.priv")
+ obj.cfg_put("auditor", "serve", "unix")
+ obj.cfg_put("auditor", "auditor_url", "https://auditor.{}.taler.net/service/".format(obj.envname))
+ obj.cfg_put("auditor", "unixpath", "$HOME/sockets/auditor.http")
+ obj.cfg_put("auditor", "reports", "${TALER_DEPLOYMENT_SHARED}/auditor/reports")
+
+ obj.cfg_put("exchange", "base_url", "https://exchange.{}.taler.net/".format(obj.envname))
+ obj.cfg_put("exchange", "serve", "unix")
+ obj.cfg_put("exchange", "unixpath", "$HOME/sockets/exchange.http")
+ obj.cfg_put("exchange", "master_public_key", obj.exchange_pub)
+
+ obj.cfg_put("exchange", "master_priv_file", "${TALER_DEPLOYMENT_SHARED}/exchange/offline-keys/master.priv")
+ obj.cfg_put("exchange", "keydir", "${TALER_DEPLOYMENT_SHARED}/exchange/live-keys/")
+
+ obj.cfg_put("exchangedb", "auditor_base_dir", "${TALER_DEPLOYMENT_SHARED}/exchange/auditors/")
+ obj.cfg_put("exchangedb", "wirefee_base_dir", "${TALER_DEPLOYMENT_SHARED}/exchange/wirefees/")
+ obj.cfg_put("exchangedb", "auditor_inputs", "${TALER_DEPLOYMENT_SHARED}/exchange/auditor-inputs/")
+
+ if obj.standalone:
+ obj.cfg_put("exchangedb-postgres", "db_conn_str", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
+ obj.cfg_put("exchangedb-postgres", "config", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
+ obj.cfg_put("auditordb-postgres", "db_conn_str", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
+ obj.cfg_put("auditordb-postgres", "config", "postgres:///taler?host={}/sockets".format(os.getenv("HOME")))
else:
- cfg_put("exchangedb-postgres", "db_conn_str", "postgres:///taler{}".format(envname))
- cfg_put("exchangedb-postgres", "config", "postgres:///taler{}".format(envname))
- cfg_put("auditordb-postgres", "db_conn_str", "postgres:///taler{}".format(envname))
- cfg_put("auditordb-postgres", "config", "postgres:///taler{}".format(envname))
+ obj.cfg_put("exchangedb-postgres", "db_conn_str", "postgres:///taler{}".format(obj.envname))
+ obj.cfg_put("exchangedb-postgres", "config", "postgres:///taler{}".format(obj.envname))
+ obj.cfg_put("auditordb-postgres", "db_conn_str", "postgres:///taler{}".format(obj.envname))
+ obj.cfg_put("auditordb-postgres", "config", "postgres:///taler{}".format(obj.envname))
- if standalone:
- cfg_put("account-1", "url", "payto://x-taler-bank/env.taler.net/{}/bank/2".format(envname))
+ if obj.standalone:
+ obj.cfg_put("account-1", "url", "payto://x-taler-bank/env.taler.net/{}/bank/2".format(obj.envname))
else:
- cfg_put("account-1", "url", "payto://x-taler-bank/bank.{}.taler.net/2".format(envname))
-
- cfg_put("account-1", "wire_response", "${TALER_DEPLOYMENT_SHARED}/exchange/wire/test.json")
- cfg_put("account-1", "plugin", "taler_bank")
- cfg_put("account-1", "taler_bank_auth_method", "basic")
- cfg_put("account-1", "username", "Exchange")
- cfg_put("account-1", "password", "x")
- cfg_put("account-1", "enable_debit", "yes")
- cfg_put("account-1", "enable_credit", "yes")
-
- cfg_put("fees-x-taler-bank", "wire-fee-2018", currency + ":" + "0.02")
- cfg_put("fees-x-taler-bank", "wire-fee-2019", currency + ":" + "0.03")
- cfg_put("fees-x-taler-bank", "wire-fee-2020", currency + ":" + "0.04")
- cfg_put("fees-x-taler-bank", "wire-fee-2021", currency + ":" + "0.04")
- cfg_put("fees-x-taler-bank", "wire-fee-2022", currency + ":" + "0.05")
- cfg_put("fees-x-taler-bank", "wire-fee-2023", currency + ":" + "0.06")
- cfg_put("fees-x-taler-bank", "wire-fee-2024", currency + ":" + "0.07")
- cfg_put("fees-x-taler-bank", "wire-fee-2025", currency + ":" + "0.08")
-
- cfg_put("fees-x-taler-bank", "closing-fee-2018", currency + ":" + "0.01")
- cfg_put("fees-x-taler-bank", "closing-fee-2019", currency + ":" + "0.01")
- cfg_put("fees-x-taler-bank", "closing-fee-2020", currency + ":" + "0.01")
- cfg_put("fees-x-taler-bank", "closing-fee-2021", currency + ":" + "0.01")
- cfg_put("fees-x-taler-bank", "closing-fee-2022", currency + ":" + "0.01")
- cfg_put("fees-x-taler-bank", "closing-fee-2023", currency + ":" + "0.01")
- cfg_put("fees-x-taler-bank", "closing-fee-2024", currency + ":" + "0.01")
- cfg_put("fees-x-taler-bank", "closing-fee-2025", currency + ":" + "0.01")
+ obj.cfg_put("account-1", "url", "payto://x-taler-bank/bank.{}.taler.net/2".format(obj.envname))
+
+ obj.cfg_put("account-1", "wire_response", "${TALER_DEPLOYMENT_SHARED}/exchange/wire/test.json")
+ obj.cfg_put("account-1", "plugin", "taler_bank")
+ obj.cfg_put("account-1", "taler_bank_auth_method", "basic")
+ obj.cfg_put("account-1", "username", "Exchange")
+ obj.cfg_put("account-1", "password", "x")
+ obj.cfg_put("account-1", "enable_debit", "yes")
+ obj.cfg_put("account-1", "enable_credit", "yes")
+
+ obj.cfg_put("fees-x-taler-bank", "wire-fee-2018", obj.currency + ":" + "0.02")
+ obj.cfg_put("fees-x-taler-bank", "wire-fee-2019", obj.currency + ":" + "0.03")
+ obj.cfg_put("fees-x-taler-bank", "wire-fee-2020", obj.currency + ":" + "0.04")
+ obj.cfg_put("fees-x-taler-bank", "wire-fee-2021", obj.currency + ":" + "0.04")
+ obj.cfg_put("fees-x-taler-bank", "wire-fee-2022", obj.currency + ":" + "0.05")
+ obj.cfg_put("fees-x-taler-bank", "wire-fee-2023", obj.currency + ":" + "0.06")
+ obj.cfg_put("fees-x-taler-bank", "wire-fee-2024", obj.currency + ":" + "0.07")
+ obj.cfg_put("fees-x-taler-bank", "wire-fee-2025", obj.currency + ":" + "0.08")
+
+ obj.cfg_put("fees-x-taler-bank", "closing-fee-2018", obj.currency + ":" + "0.01")
+ obj.cfg_put("fees-x-taler-bank", "closing-fee-2019", obj.currency + ":" + "0.01")
+ obj.cfg_put("fees-x-taler-bank", "closing-fee-2020", obj.currency + ":" + "0.01")
+ obj.cfg_put("fees-x-taler-bank", "closing-fee-2021", obj.currency + ":" + "0.01")
+ obj.cfg_put("fees-x-taler-bank", "closing-fee-2022", obj.currency + ":" + "0.01")
+ obj.cfg_put("fees-x-taler-bank", "closing-fee-2023", obj.currency + ":" + "0.01")
+ obj.cfg_put("fees-x-taler-bank", "closing-fee-2024", obj.currency + ":" + "0.01")
+ obj.cfg_put("fees-x-taler-bank", "closing-fee-2025", obj.currency + ":" + "0.01")
# how long is one signkey valid?
- cfg_put("exchange_keys", "signkey_duration", "18 weeks")
+ obj.cfg_put("exchange_keys", "signkey_duration", "18 weeks")
# how long are the signatures with the signkey valid?
- cfg_put("exchange_keys", "legal_duration", "2 years")
+ obj.cfg_put("exchange_keys", "legal_duration", "2 years")
# how long do we generate denomination and signing keys
# ahead of time?
- cfg_put("exchange_keys", "lookahead_sign", "32 weeks 1 day")
+ obj.cfg_put("exchange_keys", "lookahead_sign", "32 weeks 1 day")
- cfg_put("exchange_keys", "lookahead_provide", "4 weeks 1 day")
+ obj.cfg_put("exchange_keys", "lookahead_provide", "4 weeks 1 day")
# instance FSF
- cfg_put("instance-FSF", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/fsf.priv")
- cfg_put("instance-FSF", "name", "Free Software Foundation")
- cfg_put("merchant-location-FSF-address", "street", "51 Franklin Street, Fifth Floor.")
- cfg_put("merchant-location-FSF-address", "city", "Boston")
- cfg_put("merchant-location-FSF-address", "country", "USA")
+ obj.cfg_put("instance-FSF", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/fsf.priv")
+ obj.cfg_put("instance-FSF", "name", "Free Software Foundation")
+ obj.cfg_put("merchant-location-FSF-address", "street", "51 Franklin Street, Fifth Floor.")
+ obj.cfg_put("merchant-location-FSF-address", "city", "Boston")
+ obj.cfg_put("merchant-location-FSF-address", "country", "USA")
# instance Tor
- cfg_put("instance-Tor", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/tor.priv")
- cfg_put("instance-Tor", "name", "The Tor Project")
+ obj.cfg_put("instance-Tor", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/tor.priv")
+ obj.cfg_put("instance-Tor", "name", "The Tor Project")
# instance GNUnet
- cfg_put("instance-GNUnet", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/gnunet.priv")
- cfg_put("instance-GNUnet", "name", "GNUnet Project")
+ obj.cfg_put("instance-GNUnet", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/gnunet.priv")
+ obj.cfg_put("instance-GNUnet", "name", "GNUnet Project")
# instance Taler
- cfg_put("instance-Taler", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/taler.priv")
- cfg_put("instance-Taler", "name", "Taler")
+ obj.cfg_put("instance-Taler", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/taler.priv")
+ obj.cfg_put("instance-Taler", "name", "Taler")
# instance default
- cfg_put("instance-default", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/default.priv")
- cfg_put("instance-default", "name", "Kudos Inc.")
- cfg_put("merchant-location-default-address", "country", "Kudosland")
- cfg_put("instance-default", "tip_reserve_priv_filename", "${TALER_DEPLOYMENT_SHARED}/merchant/default-tip.priv")
- cfg_put("instance-default", "tip_exchange", "https://exchange.{}.taler.net/".format(envname))
+ obj.cfg_put("instance-default", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/default.priv")
+ obj.cfg_put("instance-default", "name", "Kudos Inc.")
+ obj.cfg_put("merchant-location-default-address", "country", "Kudosland")
+ obj.cfg_put("instance-default", "tip_reserve_priv_filename", "${TALER_DEPLOYMENT_SHARED}/merchant/default-tip.priv")
+ obj.cfg_put("instance-default", "tip_exchange", "https://exchange.{}.taler.net/".format(obj.envname))
# instance tutorial
- cfg_put("instance-Tutorial", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/tutorial.priv")
- cfg_put("instance-Tutorial", "name", "Tutorial")
+ obj.cfg_put("instance-Tutorial", "keyfile", "${TALER_DEPLOYMENT_SHARED}/merchant/tutorial.priv")
+ obj.cfg_put("instance-Tutorial", "name", "Tutorial")
- if standalone:
- cfg_put("account-merchant", "url", "payto://x-taler-bank/env.taler.net/{}/bank/{}".format(envname, "3"))
+ if obj.standalone:
+ obj.cfg_put("account-merchant", "url", "payto://x-taler-bank/env.taler.net/{}/bank/{}".format(obj.envname, "3"))
else:
- cfg_put("account-merchant", "url", "payto://x-taler-bank/bank.{}.taler.net/{}".format(envname, "3"))
-
- cfg_put("account-merchant", "plugin", "taler_bank")
- cfg_put("account-merchant", "taler_bank_auth_method", "basic")
- cfg_put("account-merchant", "username", "user")
- cfg_put("account-merchant", "password", "pass")
- cfg_put("account-merchant", "wire_response", "${TALER_DEPLOYMENT_SHARED}/merchant/wire/merchant.json")
-
- cfg_put("account-merchant", "HONOR_default", "YES")
- cfg_put("account-merchant", "HONOR_Tor", "YES")
- cfg_put("account-merchant", "HONOR_GNUnet", "YES")
- cfg_put("account-merchant", "HONOR_Taler", "YES")
- cfg_put("account-merchant", "HONOR_FSF", "YES")
- cfg_put("account-merchant", "HONOR_Tutorial", "YES")
-
- coin(currency, "ct_10", "0.10")
- coin(currency, "1", "1")
- coin(currency, "2", "2")
- coin(currency, "5", "5")
- coin(currency, "10", "10")
- coin(currency, "1000", "1000")
-
+ obj.cfg_put("account-merchant", "url", "payto://x-taler-bank/bank.{}.taler.net/{}".format(obj.envname, "3"))
-def merchant_wf(envname, acct_no, standalone):
+ obj.cfg_put("account-merchant", "plugin", "taler_bank")
+ obj.cfg_put("account-merchant", "taler_bank_auth_method", "basic")
+ obj.cfg_put("account-merchant", "username", "user")
+ obj.cfg_put("account-merchant", "password", "pass")
+ obj.cfg_put("account-merchant", "wire_response", "${TALER_DEPLOYMENT_SHARED}/merchant/wire/merchant.json")
- if standalone:
- payto_url = "payto://x-taler-bank/env.taler.net/{}/bank/{}".format(envname, acct_no)
- else:
- payto_url = "payto://x-taler-bank/bank.{}.taler.net/{}".format(envname, acct_no)
+ obj.cfg_put("account-merchant", "HONOR_default", "YES")
+ obj.cfg_put("account-merchant", "HONOR_Tor", "YES")
+ obj.cfg_put("account-merchant", "HONOR_GNUnet", "YES")
+ obj.cfg_put("account-merchant", "HONOR_Taler", "YES")
+ obj.cfg_put("account-merchant", "HONOR_FSF", "YES")
+ obj.cfg_put("account-merchant", "HONOR_Tutorial", "YES")
- data = OrderedDict(
- url=payto_url,
- salt="SALT"
- )
+ coin(obj, "ct_10", "0.10")
+ coin(obj, "1", "1")
+ coin(obj, "2", "2")
+ coin(obj, "5", "5")
+ coin(obj, "10", "10")
+ coin(obj, "1000", "1000")
- return json.dumps(data, indent=2)
@click.command()
@click.option("--currency", default="KUDOS")
@@ -305,66 +311,41 @@ def main(currency, envname, outdir, shared_outdir, exchange_pub, standalone):
else:
standalone = False
- config(currency, envname, exchange_pub, standalone)
-
- merchant_wireformats = [
- merchant_wf(envname, 3, standalone)
- ]
-
- if outdir:
- os.makedirs(outdir, exist_ok=True)
-
- tc = os.path.join(outdir, "taler.conf")
- cfg_write(open(tc, "w"))
-
- if "test" == envname:
-
- # Emptying all first.
- for k in sections.keys():
- del sections[k]
-
- # Twisting the exchange.
- cfg_put("twister", "serve", "unix")
- cfg_put("twister", "chaos_rate", "20")
- cfg_put("twister", "destination_base_url", "https://exchange.test.taler.net/")
- cfg_put("twister", "serve_unixpath", "$HOME/sockets/twister-exchange.http")
- cfg_put("twister", "serve_unixmode", "660")
- cfg_put("twister", "unixpath", "$HOME/sockets/twister-exchange-control.sock")
- cfg_put("twister", "unix_match_uid", "no")
- cfg_put("twister", "unix_match_gid", "yes")
-
- tc_twister_exchange = os.path.join(outdir, "twister-exchange.conf")
- cfg_write(open(tc_twister_exchange, "w"))
-
- # Twisting the bank.
- cfg_put("twister", "serve", "unix")
- cfg_put("twister", "chaos_rate", "20")
- cfg_put("twister", "destination_base_url", "https://bank.test.taler.net/")
- cfg_put("twister", "serve_unixpath", "$HOME/sockets/twister-bank.http")
- cfg_put("twister", "serve_unixmode", "660")
- cfg_put("twister", "unixpath", "$HOME/sockets/twister-bank-control.sock")
- cfg_put("twister", "unix_match_uid", "no")
- cfg_put("twister", "unix_match_gid", "yes")
-
- tc_twister_bank = os.path.join(outdir, "twister-bank.conf")
- cfg_write(open(tc_twister_bank, "w"))
-
- else:
- cfg_write(sys.stdout)
-
- if shared_outdir:
- d = os.path.join(shared_outdir, "merchant", "wire")
- os.makedirs(d, exist_ok=True)
+ config_files = []
- for data in merchant_wireformats:
- filename = os.path.join(d, "merchant.json")
- f = open(filename, "w")
- f.write(data)
- f.close()
+ mc = ConfigFile(standalone, envname, currency, exchange_pub, "taler.conf")
+ config(mc)
+ config_files.append(mc)
- os.makedirs(d, exist_ok=True)
- else:
- cfg_write(sys.stdout)
+ if "test" == envname:
+ # Twisting the exchange.
+ twist_exchange_conf = ConfigFile(standalone, envname, currency, exchange_pub, "twister-exchange.conf")
+ twist_exchange_conf.cfg_put("twister", "serve", "unix")
+ twist_exchange_conf.cfg_put("twister", "chaos_rate", "20")
+ twist_exchange_conf.cfg_put("twister", "destination_base_url", "https://exchange.test.taler.net/")
+ twist_exchange_conf.cfg_put("twister", "serve_unixpath", "$HOME/sockets/twister-exchange.http")
+ twist_exchange_conf.cfg_put("twister", "serve_unixmode", "660")
+ twist_exchange_conf.cfg_put("twister", "unixpath", "$HOME/sockets/twister-exchange-control.sock")
+ twist_exchange_conf.cfg_put("twister", "unix_match_uid", "no")
+ twist_exchange_conf.cfg_put("twister", "unix_match_gid", "yes")
+ config_files.append(twist_exchange_conf)
+
+ # Twisting the bank.
+ twist_bank_conf = ConfigFile(standalone, envname, currency, exchange_pub, "twister-bank.conf")
+ twist_bank_conf.cfg_put("twister", "serve", "unix")
+ twist_bank_conf.cfg_put("twister", "chaos_rate", "20")
+ twist_bank_conf.cfg_put("twister", "destination_base_url", "https://bank.test.taler.net/")
+ twist_bank_conf.cfg_put("twister", "serve_unixpath", "$HOME/sockets/twister-bank.http")
+ twist_bank_conf.cfg_put("twister", "serve_unixmode", "660")
+ twist_bank_conf.cfg_put("twister", "unixpath", "$HOME/sockets/twister-bank-control.sock")
+ twist_bank_conf.cfg_put("twister", "unix_match_uid", "no")
+ twist_bank_conf.cfg_put("twister", "unix_match_gid", "yes")
+
+ config_files.append(twist_bank_conf)
+
+ assert (0 < len(config_files))
+ for obj in config_files:
+ obj.cfg_write(outdir)
if __name__ == "__main__":
main()