Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
40c3859
change job to run every minute
WarriorAchilles Dec 15, 2021
8b7c2c5
stubbed out code for TestLabVmConnection service and added VmStatusJo…
WarriorAchilles Dec 23, 2021
f5a5353
removed code that isn't part of card, removed unneeded try/catch
WarriorAchilles Dec 23, 2021
67d7053
Merge branch 'dev' into ze/labvm-status-job
WarriorAchilles Dec 24, 2021
4e99555
implemented attempts to restart vm if vm is down
WarriorAchilles Dec 27, 2021
695903e
changed implementation of TestLabVmConnection to use correct method c…
WarriorAchilles Dec 28, 2021
3479d33
removed unused variable
WarriorAchilles Dec 28, 2021
f36704c
renamed file to better reflect usage
WarriorAchilles Dec 28, 2021
1e3e2a5
removed WIP code unrelated to card
WarriorAchilles Dec 28, 2021
9e2a103
refactored code into recursive function
WarriorAchilles Dec 30, 2021
3c8f762
Merge branch 'dev' into ze/labvm-status-job
WarriorAchilles Dec 30, 2021
34b4be4
added database context to ProxmoxApi and fixed resulting errors
WarriorAchilles Jan 4, 2022
354f071
added code to save vm status to database
WarriorAchilles Jan 4, 2022
f49158b
added ProxmoxDBApi class to handle Api calls that require the database
WarriorAchilles Jan 28, 2022
47acc84
changed job to run every minute
WarriorAchilles Jan 28, 2022
77123c8
removed unused imports
WarriorAchilles Jan 28, 2022
5b7dd18
removed another unused import
WarriorAchilles Jan 28, 2022
952828b
started testing and fixed some errors. Print statements will need rem…
WarriorAchilles Feb 24, 2022
4928be0
fixed problems and removed debug print statements
WarriorAchilles Feb 24, 2022
3c8328d
added line to save changes to database in ProxmoxDBApi
WarriorAchilles Feb 24, 2022
ce76973
fixed a logic error
WarriorAchilles Feb 24, 2022
820d90e
changed time interval to what it should be and removed a couple lefto…
WarriorAchilles Feb 24, 2022
04050a9
requested changes to make job more testable later on
WarriorAchilles Mar 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CSLabs.Api/Jobs/JobRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ public class JobRegistry : Registry
{
public JobRegistry(IServiceProvider provider)
{
// Every minute check the status of each Lab VM within each Lab
// Every 3 minutes check to see if we have quorum (at least 50% of the ProxMox nodes are up)

// Schedule new jobs here
Schedule(() => new ExampleJob(provider)).ToRunEvery(1).Minutes();

Schedule(() => new VmStatusJob(provider)).ToRunNow().AndEvery(10).Seconds();
}
}
}
25 changes: 25 additions & 0 deletions CSLabs.Api/Jobs/VmStatusJob.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Threading.Tasks;
using CSLabs.Api.Models;
using CSLabs.Api.Services;
using Microsoft.Extensions.DependencyInjection;

namespace CSLabs.Api.Jobs
{
public class VmStatusJob : AsyncJob
{
private readonly IServiceProvider _provider;
public VmStatusJob(IServiceProvider provider)
{
_provider = provider;
}

protected override async Task ExecuteAsync()
{
using var scope = _provider.CreateScope();
var connectionService = scope.ServiceProvider.GetService<TestVmConnectionService>();
await connectionService.TestLabVmConnection();

}
}
}
Loading