Compare commits
21 Commits
v0.1.2
...
2be4331a6e
Author | SHA1 | Date | |
---|---|---|---|
2be4331a6e | |||
98754be109 | |||
9ee2750534 | |||
9920c94a8b | |||
b7bc477d2e | |||
ab11665665 | |||
37468b6785 | |||
471767c4ed | |||
596baba5ef | |||
12390031f9 | |||
daed8c1462 | |||
7e5e295590 | |||
cb91ca3159 | |||
340f92ed04 | |||
2169b3d45f | |||
27792ff7f4 | |||
9a59e10b0c | |||
7860d7e0f7 | |||
2334287437 | |||
d68022d831 | |||
b3b97d4c09 |
@@ -2,24 +2,26 @@ name: Gitea CI/CD
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ "development", "main", "feature/*", "bugfix/*", "enhancement/*" ]
|
||||
tags: [ "v*.*.*" ]
|
||||
#push:
|
||||
#branches: [ "development", "main", "staging"]
|
||||
#tags: [ "v*.*.*" ]
|
||||
pull_request:
|
||||
branches: [ "development", "main" ]
|
||||
branches: [ "development", "main", "staging" ]
|
||||
tags: [ "v*.*.*" ]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
env:
|
||||
DOTNET_VERSION: '8.0.x'
|
||||
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,12 +47,12 @@ 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:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Determine next semantic version tag
|
||||
id: set_tag
|
||||
@@ -80,12 +82,11 @@ jobs:
|
||||
fi
|
||||
|
||||
new_tag="v${major}.${minor}.${patch}"
|
||||
echo "Creating new version tag: ${new_tag}"
|
||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
||||
|
||||
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
|
||||
@@ -110,23 +111,37 @@ jobs:
|
||||
|
||||
tag:
|
||||
name: Create Tag
|
||||
needs: [docker-build, build, set-tag]
|
||||
needs: [docker-build-and-push]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Git user
|
||||
- name: Check if tag already exists
|
||||
id: check_tag
|
||||
run: |
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git fetch --tags
|
||||
if git rev-parse "${{ needs.set-tag.outputs.tag_name }}" >/dev/null 2>&1; then
|
||||
echo "Tag ${{ needs.set-tag.outputs.tag_name }} already exists!"
|
||||
echo "exists=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Tag ${{ needs.set-tag.outputs.tag_name }} does not exist"
|
||||
echo "exists=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Create and push tag
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: steps.check_tag.outputs.exists == 'false'
|
||||
run: |
|
||||
echo "Creating new tag: ${{ needs.set-tag.outputs.tag_name }}"
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git tag ${{ needs.set-tag.outputs.tag_name }}
|
||||
git push origin ${{ needs.set-tag.outputs.tag_name }}
|
||||
git push -u origin ${{ needs.set-tag.outputs.tag_name }}
|
||||
echo "Tag created and pushed successfully"
|
||||
|
||||
- name: Skip tag creation
|
||||
if: steps.check_tag.outputs.exists == 'true'
|
||||
run: |
|
||||
echo "Skipping tag creation - ${{ needs.set-tag.outputs.tag_name }} already exists"
|
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)
|
||||
|
||||
|
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Watcher.Data;
|
||||
@@ -11,7 +12,7 @@ using Watcher.ViewModels;
|
||||
|
||||
namespace Watcher.Controllers;
|
||||
|
||||
public class RegistrationDto
|
||||
public class HardwareDto
|
||||
{
|
||||
// Server Identity
|
||||
[Required]
|
||||
@@ -77,6 +78,13 @@ public class MetricDto
|
||||
public double NET_Out { get; set; } // Bytes/s
|
||||
}
|
||||
|
||||
public class ServiceDto
|
||||
{
|
||||
public int ServerId { get; set; } // Vom Watcher-Server zugewiesene ID des Hosts
|
||||
public String? ContainerId { get; set; }
|
||||
public String? Image { get; set; }
|
||||
public String? Name { get; set; }
|
||||
}
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
@@ -93,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)
|
||||
@@ -128,13 +136,12 @@ public class MonitoringController : Controller
|
||||
_logger.LogInformation("Agent für '{server}' erfolgreich registriert.", server.Name);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
_logger.LogError("Kein Server für Registrierung gefunden");
|
||||
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
|
||||
@@ -215,6 +222,50 @@ public class MonitoringController : Controller
|
||||
|
||||
}
|
||||
|
||||
// Endpoint, an dem Agents Ihre laufenden Services registrieren
|
||||
[HttpPost("service-discovery")]
|
||||
public async Task<IActionResult> ServiceDetection([FromBody] ServiceDto dto)
|
||||
{
|
||||
// Gültigkeit des Payloads prüfen
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
var errors = ModelState.Values
|
||||
.SelectMany(v => v.Errors)
|
||||
.Select(e => e.ErrorMessage)
|
||||
.ToList();
|
||||
|
||||
_logger.LogError("Ungültiger ServiceDetection-Payload.");
|
||||
return BadRequest(new { error = "Ungültiger Payload", details = errors });
|
||||
}
|
||||
|
||||
// Metrics für Container, die zu ServerId gehören, löschen
|
||||
|
||||
// Container, die zu ServerId gehören löschen
|
||||
|
||||
// Container neu in Datenbank einlesen
|
||||
try
|
||||
{
|
||||
Container container = new Container
|
||||
{
|
||||
ServerId = dto.ServerId,
|
||||
ContainerId = dto.ContainerId,
|
||||
Image = dto.Name,
|
||||
Name = dto.Name
|
||||
};
|
||||
|
||||
_logger.LogInformation(container.Name + " added for Host " + container.ServerId);
|
||||
|
||||
_context.Containers.Add(container);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
catch (SqliteException e)
|
||||
{
|
||||
_logger.LogError("ServiceDiscovery failed: " + e.Message);
|
||||
}
|
||||
|
||||
return Ok();
|
||||
|
||||
}
|
||||
|
||||
// Durchschnittliche Werte Berechnen
|
||||
[HttpGet("median")]
|
||||
@@ -317,6 +368,4 @@ public class MonitoringController : Controller
|
||||
return metric_input;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
355
Watcher/Migrations/20251003135555_ContainerUpdate.Designer.cs
generated
Normal file
355
Watcher/Migrations/20251003135555_ContainerUpdate.Designer.cs
generated
Normal file
@@ -0,0 +1,355 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Watcher.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20251003135555_ContainerUpdate")]
|
||||
partial class ContainerUpdate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ContainerId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Image")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ImageId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsRunning")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("ServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ImageId");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Tag")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Images");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("ContainerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Level")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContainerId");
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("LogEvents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Metric", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("CPU_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Usage")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Temp")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Vram_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Vram_Usage")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("NET_In")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("NET_Out")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RAM_Load")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RAM_Size")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<int?>("ServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Metrics");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<double>("CPU_Load_Critical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Load_Warning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Temp_Critical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("CPU_Temp_Warning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<int>("CpuCores")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("CpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("DISK_Temp_Critical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("DISK_Temp_Warning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("DiskSpace")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("Disk_Usage_Critical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("Disk_Usage_Warning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Load_Critical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Load_Warning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Temp_Critical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("GPU_Temp_Warning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<string>("GpuType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("IPAddress")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("IsOnline")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsVerified")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("LastSeen")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<double>("RAM_Load_Critical")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RAM_Load_Warning")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<double>("RamSize")
|
||||
.HasColumnType("REAL");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
|
||||
b.ToTable("Servers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Tags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("IdentityProvider")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("LastLogin")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("OIDC_Id")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Image", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("ImageId");
|
||||
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("TagId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Container", "Container")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContainerId");
|
||||
|
||||
b.HasOne("Watcher.Models.Server", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId");
|
||||
|
||||
b.Navigation("Container");
|
||||
|
||||
b.Navigation("Server");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Server", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Servers")
|
||||
.HasForeignKey("TagId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Image", b =>
|
||||
{
|
||||
b.Navigation("Containers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Tag", b =>
|
||||
{
|
||||
b.Navigation("Containers");
|
||||
|
||||
b.Navigation("Servers");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
113
Watcher/Migrations/20251003135555_ContainerUpdate.cs
Normal file
113
Watcher/Migrations/20251003135555_ContainerUpdate.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Watcher.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ContainerUpdate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Containers_Servers_HostServerId",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Containers_HostServerId",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedAt",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ExposedPort",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Health",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HostServerId",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Status",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "InternalPort",
|
||||
table: "Containers",
|
||||
newName: "ServerId");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ContainerId",
|
||||
table: "Containers",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ContainerId",
|
||||
table: "Containers");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "ServerId",
|
||||
table: "Containers",
|
||||
newName: "InternalPort");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CreatedAt",
|
||||
table: "Containers",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ExposedPort",
|
||||
table: "Containers",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Health",
|
||||
table: "Containers",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "HostServerId",
|
||||
table: "Containers",
|
||||
type: "INTEGER",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Status",
|
||||
table: "Containers",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Containers_HostServerId",
|
||||
table: "Containers",
|
||||
column: "HostServerId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Containers_Servers_HostServerId",
|
||||
table: "Containers",
|
||||
column: "HostServerId",
|
||||
principalTable: "Servers",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
}
|
||||
}
|
@@ -23,45 +23,29 @@ namespace Watcher.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
b.Property<string>("ContainerId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("ExposedPort")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Health")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("HostServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Image")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int?>("ImageId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("InternalPort")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("IsRunning")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
b.Property<int>("ServerId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int?>("TagId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HostServerId");
|
||||
|
||||
b.HasIndex("ImageId");
|
||||
|
||||
b.HasIndex("TagId");
|
||||
@@ -320,10 +304,6 @@ namespace Watcher.Migrations
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.Container", b =>
|
||||
{
|
||||
b.HasOne("Watcher.Models.Server", "HostServer")
|
||||
.WithMany()
|
||||
.HasForeignKey("HostServerId");
|
||||
|
||||
b.HasOne("Watcher.Models.Image", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("ImageId");
|
||||
@@ -331,8 +311,6 @@ namespace Watcher.Migrations
|
||||
b.HasOne("Watcher.Models.Tag", null)
|
||||
.WithMany("Containers")
|
||||
.HasForeignKey("TagId");
|
||||
|
||||
b.Navigation("HostServer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Watcher.Models.LogEvent", b =>
|
||||
|
@@ -4,22 +4,11 @@ public class Container
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
// Container Details
|
||||
public string? Name { get; set; }
|
||||
public int ServerId { get; set; }
|
||||
|
||||
public int ExposedPort { get; set; }
|
||||
|
||||
public int InternalPort { get; set; }
|
||||
|
||||
public string Status { get; set; } = string.Empty;
|
||||
|
||||
public string Health { get; set; } = string.Empty;
|
||||
|
||||
public string? Image { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public String? ContainerId { get; set; }
|
||||
public String? Image { get; set; }
|
||||
public String? Name { get; set; }
|
||||
|
||||
public Boolean IsRunning { get; set; } = true;
|
||||
|
||||
public Server? HostServer { get; set; }
|
||||
}
|
||||
|
@@ -10,26 +10,21 @@
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<div >
|
||||
<!-- TODO: Später auf > 0 ändern! -->
|
||||
<table class="ServiceList">
|
||||
<!-- foreach (var container in Model.Containers)-->
|
||||
<tr>
|
||||
<th>Service</th>
|
||||
<th>HostServer</th>
|
||||
<th>Status</th>
|
||||
<th>SSL/TLS</th>
|
||||
<th>Proxy</th>
|
||||
<th>Deployment</th>
|
||||
<th></th>
|
||||
|
||||
</tr>
|
||||
@for (int i = 0; i < 3; i++)
|
||||
@foreach (Container container in Model.Containers)
|
||||
{
|
||||
<tr class="ServiceRow">
|
||||
<td>test</td>
|
||||
<td><a class="ServiceEntry" href="/Server/Details/7">test</a></td>
|
||||
<td>Online</td>
|
||||
<td>true</td>
|
||||
<td>true</td>
|
||||
<td>@container.Name</td>
|
||||
<td><a class="ServiceEntry" href="/Server/Details/${containerId}">@container.ServerId</a></td>
|
||||
<td>nicht automatisiert</td>
|
||||
<td>Docker</td>
|
||||
</tr>
|
||||
}
|
||||
|
@@ -139,12 +139,12 @@
|
||||
<div class="card shadow rounded-3 p-4 h-100">
|
||||
<h2 class="h5 fw-semibold mb-3">Services</h2>
|
||||
<ul class="list-group list-group-flush serverlist">
|
||||
@foreach (var service in Model.Containers)
|
||||
@foreach (var container in Model.Containers)
|
||||
{
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span>@service.Name</span>
|
||||
<span class="badge @(service.Status == "Running" ? "bg-success" : "bg-warning")">
|
||||
@service.Status
|
||||
<span>@container.Name</span>
|
||||
<span class="badge @(container.Name == "Running" ? "bg-success" : "bg-warning")">
|
||||
@container.Name
|
||||
</span>
|
||||
</li>
|
||||
}
|
||||
|
Reference in New Issue
Block a user