Test und Log

This commit is contained in:
2025-10-03 17:17:28 +02:00
parent 9a59e10b0c
commit 27792ff7f4
2 changed files with 30 additions and 0 deletions

28
Tests/servicediscovery.py Normal file
View File

@@ -0,0 +1,28 @@
import json
import urllib.request
url = "http://localhost:5000/monitoring/service-discovery"
payload = {
"ServerId": 1,
"ContainerId": "aaaaaaaaaaaa",
"Name": "test-Name",
"Image": "test-Image"
}
data = json.dumps(payload).encode("utf-8")
req = urllib.request.Request(
url,
data=data,
headers={"Content-Type": "application/json"},
method="POST"
)
try:
with urllib.request.urlopen(req) as response:
resp_data = response.read().decode("utf-8")
print("Status Code:", response.status)
print("Response:", resp_data)
except Exception as e:
print("Fehler beim Senden der Request:", e)

View File

@@ -252,6 +252,8 @@ public class MonitoringController : Controller
Name = dto.Name
};
_logger.LogInformation(container.Name + " added for Host " + container.ServerId);
_context.Containers.Add(container);
await _context.SaveChangesAsync();
}