summaryrefslogtreecommitdiff
path: root/bin/taler-deployment-config-instances
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-05-28 22:07:22 +0200
committerMS <ms@taler.net>2021-05-28 22:07:22 +0200
commit0add7c44dc9f24b2b05f80706d331fdff085b8af (patch)
treeadb82034f94289ed0aa95fb897c575691f1b9c69 /bin/taler-deployment-config-instances
parent63ca16886ea5ffe9d0630dc35bcf228b5d4ab468 (diff)
downloaddeployment-0add7c44dc9f24b2b05f80706d331fdff085b8af.tar.gz
deployment-0add7c44dc9f24b2b05f80706d331fdff085b8af.tar.bz2
deployment-0add7c44dc9f24b2b05f80706d331fdff085b8af.zip
change instance PATCH logic
Diffstat (limited to 'bin/taler-deployment-config-instances')
-rwxr-xr-xbin/taler-deployment-config-instances39
1 files changed, 22 insertions, 17 deletions
diff --git a/bin/taler-deployment-config-instances b/bin/taler-deployment-config-instances
index 1a7284f..4570109 100755
--- a/bin/taler-deployment-config-instances
+++ b/bin/taler-deployment-config-instances
@@ -61,6 +61,25 @@ TALER_ENV_FRONTENDS_APITOKEN = expect_env("TALER_ENV_FRONTENDS_APITOKEN")
authorization_header = {"Authorization": f"Bearer {TALER_ENV_FRONTENDS_APITOKEN}"}
def ensure_instance(instance_id, name, payto_uris, auth):
+
+ resp = requests.get(urljoin(MERCHANT_BACKEND_BASE_URL, f"private/instances/{instance_id}"))
+
+ # Instance exists, we PATCH the auth just in case it changed.
+ if resp.status_code == 200:
+ if instance_id != "Tutorial":
+ print(f"Patching (auth of) instance '{instance_id}'")
+ patch_resp = requests.post(
+ urljoin(MERCHANT_BACKEND_BASE_URL,
+ f"private/instances/{instance_id}/auth"),
+ json=auth,
+ headers = authorization_header
+ )
+ if patch_resp.status_code < 200 or patch_resp.status_code >= 300:
+ print(f"Failed to update auth of '{instance_id}', backend responds: {patch_resp.status_code}/{patch_resp.text}")
+ exit(1)
+ return
+
+ print(f"Instance '{instance_id}' not found, trying to create it.")
req = dict(
id=instance_id,
name=name,
@@ -72,31 +91,17 @@ def ensure_instance(instance_id, name, payto_uris, auth):
default_max_deposit_fee=f"{TALER_CONFIG_CURRENCY}:1",
default_wire_transfer_delay=dict(d_ms="forever"),
default_pay_delay=dict(d_ms="forever"),
- # FIXME: Eventually, this should be an actual secret token
auth=auth,
)
- # Here authenticates as 'default' (with same credentials of other instances.)
create_resp = requests.post(
urljoin(MERCHANT_BACKEND_BASE_URL, "private/instances"),
json=req,
headers = authorization_header
)
- print(f"POSTing to /private/instances for '{instance_id}', responded with: {create_resp.status_code}")
if create_resp.status_code < 200 or create_resp.status_code >= 300:
- print(f"Instance '{instance_id}' could not be (re)created, backend says: {create_resp.text}. Updating its auth now")
- if instance_id != "Tutorial":
- patch_resp = requests.post(
- urljoin(MERCHANT_BACKEND_BASE_URL,
- f"private/instances/{instance_id}/auth"),
- json=auth,
- headers = authorization_header
- )
- if patch_resp.status_code < 200 or patch_resp.status_code >= 300:
- print(f"Failed to update auth of '{instance_id}'")
- print(patch_resp.text)
- exit(1)
- else:
- exit(1)
+ print(f"Could not create instance '{instance_id}', backend responds: {create_resp.status_code}/{create_resp.text}")
+ exit(1)
+
def is_merchant_running():
for proc in psutil.process_iter():