[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-deployment] branch master updated: change instance PATCH logic
From: |
gnunet |
Subject: |
[taler-deployment] branch master updated: change instance PATCH logic |
Date: |
Fri, 28 May 2021 22:07:33 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository deployment.
The following commit(s) were added to refs/heads/master by this push:
new 0add7c4 change instance PATCH logic
0add7c4 is described below
commit 0add7c44dc9f24b2b05f80706d331fdff085b8af
Author: MS <ms@taler.net>
AuthorDate: Fri May 28 22:07:22 2021 +0200
change instance PATCH logic
---
bin/taler-deployment-config-instances | 39 ++++++++++++++++++++---------------
1 file 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():
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-deployment] branch master updated: change instance PATCH logic,
gnunet <=