Skip to content

Commit 5ef9e88

Browse files
authored
Merge pull request #1688 from grycap/dydns
Fix error
2 parents 425668d + e27ec31 commit 5ef9e88

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

IM/connectors/EGI.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def add_dns_entry(self, hostname, domain, ip, auth_data, extra_args=None):
7878
"""
7979
Add a DNS entry to the DNS server
8080
"""
81+
domain = domain[:-1] if domain.endswith(".") else domain
8182
im_auth = auth_data.getAuthInfo("InfrastructureManager")
8283
try:
8384
secret = None
@@ -116,7 +117,6 @@ def add_dns_entry(self, hostname, domain, ip, auth_data, extra_args=None):
116117
parts = hostname[6:].split("@")
117118
secret = parts[0]
118119
hostname = parts[1]
119-
domain = domain[:-1]
120120
else:
121121
self.log_error(f"Error updating DNS entry {hostname}.{domain}: No secret nor token provided")
122122
return False
@@ -144,6 +144,7 @@ def del_dns_entry(self, hostname, domain, ip, auth_data, extra_args=None):
144144
"""
145145
Delete a DNS entry from the DNS server
146146
"""
147+
domain = domain[:-1] if domain.endswith(".") else domain
147148
im_auth = auth_data.getAuthInfo("InfrastructureManager")
148149
try:
149150
if im_auth and im_auth[0].get("token"):

test/unit/connectors/EGI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_del_dns(self, mock_get_domains, mock_get_host, mock_get):
7070
mock_get.return_value = MagicMock(status_code=200, json=lambda: {"status": "ok"})
7171
auth_data = Authentication([{'type': 'InfrastructureManager', 'token': 'access_token'}])
7272
cloud = EGICloudConnector(None, None)
73-
success = EGICloudConnector.del_dns_entry(cloud, "hostname", "domain", "ip", auth_data)
73+
success = EGICloudConnector.del_dns_entry(cloud, "hostname", "domain.", "ip", auth_data)
7474
self.assertTrue(success)
7575
eurl = f"{EGICloudConnector.DYDNS_URL}/nic/unregister?fqdn=hostname.domain"
7676
mock_get.assert_called_with(eurl, headers={'Authorization': 'Bearer access_token'}, timeout=10)

0 commit comments

Comments
 (0)