diff --git a/imageroot/actions/configure-module/02_validate_bcc_server b/imageroot/actions/configure-module/02_validate_bcc_server index d0ac33d..356f1e0 100755 --- a/imageroot/actions/configure-module/02_validate_bcc_server +++ b/imageroot/actions/configure-module/02_validate_bcc_server @@ -33,9 +33,6 @@ def get_always_bcc(email): # check if the always_bcc is set to the email elif response['output']['bcc'] == email: sys.exit(0) - # check if the always_bcc is previouslys set to piler (archive@host.domain.com) - elif response['output']['bcc'] == 'archive@'+os.environ.get('TRAEFIK_HOST'): - sys.exit(0) else: agent.set_status('validation-failed') json.dump([{'field':'mail_server','parameter':'mail_server','value': response['output']['bcc'],'error':'always_bcc_is_already_set'}], fp=sys.stdout) @@ -44,5 +41,4 @@ def get_always_bcc(email): if providers: # we need to set bcc address for the mail server - get_always_bcc('archive@'+data['host']) - + get_always_bcc('archive@'+os.environ['MODULE_ID']) diff --git a/imageroot/actions/configure-module/90add-relay-rule b/imageroot/actions/configure-module/90add-relay-rule index 7af4c91..df93bef 100755 --- a/imageroot/actions/configure-module/90add-relay-rule +++ b/imageroot/actions/configure-module/90add-relay-rule @@ -31,7 +31,7 @@ if providers: # first configuration, we add the relay rule response = agent.tasks.run(f"module/{mail_id}", action='add-relay-rule', data={ "rule_type": "always-bcc", - "rule_subject": "archive@"+data["host"], + "rule_subject": "archive@"+os.environ['MODULE_ID'], "host": ip_address, "port": int(os.environ['TCP_PORT_ARCHIVE']), "mandatory_tls": False, @@ -41,7 +41,7 @@ if providers: agent.assert_exp(response['exit_code'] == 0) # we need to set bcc address for the mail server response = agent.tasks.run(f"module/{mail_id}", action='set-always-bcc', data={ - "bcc": "archive@"+data["host"] + "bcc": "archive@"+os.environ['MODULE_ID'] }) agent.assert_exp(response['exit_code'] == 0) elif os.environ.get("MAIL_SERVER") and data["mail_server"] != os.environ.get("MAIL_SERVER"): @@ -52,7 +52,7 @@ if providers: if providers_old: mail_id_old = providers_old[0]["module_id"] response = agent.tasks.run(f"module/{mail_id_old}", action='remove-relay-rule', data={ - "rule_subject": "archive@"+data["host"]}) + "rule_subject": "archive@"+os.environ['MODULE_ID']}) agent.assert_exp(response['exit_code'] == 0) # we need to remove bcc address for the mail server response = agent.tasks.run(f"module/{mail_id_old}", action='set-always-bcc', data={ @@ -62,7 +62,7 @@ if providers: # add the new relay rule response = agent.tasks.run(f"module/{mail_id}", action='add-relay-rule', data={ "rule_type": "always-bcc", - "rule_subject": "archive@"+data["host"], + "rule_subject": "archive@"+os.environ['MODULE_ID'], "host": ip_address, "port": int(os.environ['TCP_PORT_ARCHIVE']), "mandatory_tls": False, @@ -72,14 +72,14 @@ if providers: agent.assert_exp(response['exit_code'] == 0) # we need to set bcc address for the mail server response = agent.tasks.run(f"module/{mail_id}", action='set-always-bcc', data={ - "bcc": "archive@"+data["host"] + "bcc": "archive@"+os.environ['MODULE_ID'] }) agent.assert_exp(response['exit_code'] == 0) else: # same mail server, we just update the relay rule response = agent.tasks.run(f"module/{mail_id}", action='alter-relay-rule', data={ "rule_type": "always-bcc", - "rule_subject": "archive@"+data["host"], + "rule_subject": "archive@"+os.environ['MODULE_ID'], "host": ip_address, "port": int(os.environ['TCP_PORT_ARCHIVE']), "mandatory_tls": False, @@ -89,7 +89,7 @@ if providers: agent.assert_exp(response['exit_code'] == 0) # we need to set bcc address for the mail server response = agent.tasks.run(f"module/{mail_id}", action='set-always-bcc', data={ - "bcc": "archive@"+data["host"] + "bcc": "archive@"+os.environ['MODULE_ID'] }) agent.assert_exp(response['exit_code'] == 0) diff --git a/imageroot/actions/destroy-module/20destroy b/imageroot/actions/destroy-module/20destroy index 358ed4b..02a3ffa 100755 --- a/imageroot/actions/destroy-module/20destroy +++ b/imageroot/actions/destroy-module/20destroy @@ -36,10 +36,11 @@ rdb = agent.redis_connect() providers_old = agent.list_service_providers(rdb, 'imap', 'tcp', { 'module_uuid': os.environ.get("MAIL_SERVER") }) + if providers_old: mail_id_old = providers_old[0]["module_id"] response = agent.tasks.run(f"module/{mail_id_old}", action='remove-relay-rule', data={ - "rule_subject": "archive@"+os.environ.get("TRAEFIK_HOST")}) + "rule_subject": "archive@"+os.environ['MODULE_ID']}) # we need to set bcc address for the mail server response = agent.tasks.run(f"module/{mail_id_old}", action='set-always-bcc', data={ "bcc": ""