-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerService.cs
53 lines (48 loc) · 1.76 KB
/
DockerService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Text;
namespace StackDeployCheck
{
public class DockerService
{
public string Id { get; internal set; }
public string Name { get; internal set; }
public string Mode { get; internal set; }
public string ReplicasDesc { get; internal set; }
public int CurrentReplicas { get; internal set; }
public int DesiredReplicas { get; internal set; }
public string Image { get; internal set; }
public string Ports { get; internal set; }
public UpdateState UpdateState { get; internal set; }
public string LastUpdated { get; internal set; }
public string UpdateMessage { get; internal set; }
public int TotalTasks { get; internal set; }
public int StableTasks { get; internal set; }
public int CompleteTasks { get; internal set; }
public DockerService()
{
UpdateState = UpdateState.NotUpdated;
}
public void SetReplicas(string replicasString)
{
ReplicasDesc = replicasString;
var parts = replicasString.Split(@"/");
CurrentReplicas = 0;
DesiredReplicas = 0;
int current;
if (!int.TryParse(parts[0], out current))
{
Console.Error.WriteLine($"ERROR: unable to parse current replicas {replicasString}");
return;
}
CurrentReplicas = current;
int desired;
if (!int.TryParse(parts[1], out desired))
{
Console.Error.WriteLine($"ERROR: unable to parse desired replicas {replicasString}");
return;
}
DesiredReplicas = desired;
}
}
}