Compare commits
6 Commits
9a59e10b0c
...
v0.1.4
Author | SHA1 | Date | |
---|---|---|---|
7e5e295590 | |||
cb91ca3159 | |||
340f92ed04 | |||
2169b3d45f | |||
27792ff7f4 | |||
2334287437 |
@@ -13,13 +13,10 @@ env:
|
||||
DOCKER_IMAGE_NAME: watcher-server
|
||||
REGISTRY_URL: git.triggermeelmo.com
|
||||
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
||||
TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || github.ref == 'refs/heads/development' && 'development' || github.ref_type == 'tag' && github.ref_name || 'pr' }}
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
@@ -45,8 +42,6 @@ jobs:
|
||||
set-tag:
|
||||
name: Set Tag Name
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
outputs:
|
||||
tag_name: ${{ steps.set_tag.outputs.tag_name }}
|
||||
steps:
|
||||
@@ -75,7 +70,7 @@ jobs:
|
||||
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
||||
minor=$((minor + 1))
|
||||
patch=0
|
||||
else
|
||||
elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then
|
||||
patch=$((patch + 1))
|
||||
fi
|
||||
|
||||
@@ -84,8 +79,6 @@ jobs:
|
||||
|
||||
docker-build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
||||
needs: [build-and-test, set-tag]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -112,8 +105,6 @@ jobs:
|
||||
name: Create Tag
|
||||
needs: [docker-build-and-push]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
28
Tests/servicediscovery.py
Normal file
28
Tests/servicediscovery.py
Normal 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)
|
||||
|
||||
|
@@ -12,7 +12,7 @@ using Watcher.ViewModels;
|
||||
|
||||
namespace Watcher.Controllers;
|
||||
|
||||
public class RegistrationDto
|
||||
public class HardwareDto
|
||||
{
|
||||
// Server Identity
|
||||
[Required]
|
||||
@@ -101,9 +101,9 @@ public class MonitoringController : Controller
|
||||
}
|
||||
|
||||
|
||||
// Endpoint, an dem sich neue Agents registrieren
|
||||
[HttpPost("register-agent-by-id")]
|
||||
public async Task<IActionResult> Register([FromBody] RegistrationDto dto)
|
||||
// Endpoint, an den der Agent seine Hardwareinformationen schickt
|
||||
[HttpPost("hardware-info")]
|
||||
public async Task<IActionResult> Register([FromBody] HardwareDto dto)
|
||||
{
|
||||
// Gültigkeit des Payloads prüfen
|
||||
if (!ModelState.IsValid)
|
||||
@@ -140,7 +140,8 @@ public class MonitoringController : Controller
|
||||
return NotFound("No Matching Server found.");
|
||||
}
|
||||
|
||||
[HttpGet("server-id-by-ip")]
|
||||
// Endpoint, an dem sich ein Agent initial registriert
|
||||
[HttpGet("register")]
|
||||
public async Task<IActionResult> GetServerIdByIp([FromQuery] string IpAddress)
|
||||
{
|
||||
var server = await _context.Servers
|
||||
@@ -252,6 +253,8 @@ public class MonitoringController : Controller
|
||||
Name = dto.Name
|
||||
};
|
||||
|
||||
_logger.LogInformation(container.Name + " added for Host " + container.ServerId);
|
||||
|
||||
_context.Containers.Add(container);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
Reference in New Issue
Block a user