-
Notifications
You must be signed in to change notification settings - Fork 980
/
build_status.rb
85 lines (75 loc) · 1.83 KB
/
build_status.rb
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
module HostStatus
class BuildStatus < Status
PENDING = 1
TOKEN_EXPIRED = 2
BUILD_FAILED = 3
BUILT = 0
def self.status_name
N_("Build")
end
def to_label(options = {})
case to_status
when PENDING
N_("Pending installation")
when TOKEN_EXPIRED
N_("Token expired")
when BUILT
N_("Installed")
when BUILD_FAILED
N_("Installation error")
else
N_("Unknown build status")
end
end
def to_global(options = {})
case to_status
when TOKEN_EXPIRED, BUILD_FAILED
HostStatus::Global::ERROR
else
HostStatus::Global::OK
end
end
def to_status(options = {})
if waiting_for_build?
if token_expired?
TOKEN_EXPIRED
else
PENDING
end
else
if build_errors?
BUILD_FAILED
else
BUILT
end
end
end
def relevant?(options = {})
SETTINGS[:unattended] && host.managed?
end
def waiting_for_build?
host&.build
end
def token_expired?
host&.token_expired?
end
def build_errors?
host && host.build_errors.present?
end
def remediation_help_text
case to_status
when PENDING
N_("Installation haven't started yet or in progress")
when TOKEN_EXPIRED
N_("Build token is no longer valid, cancel build mode and enter it again to generate new token")
when BUILT
N_("OS installer reported end of installation and rebooted the system")
when BUILD_FAILED
N_("OS installer post script reported failure, check logs")
else
N_("The host was not scheduled for build yet")
end
end
end
end
HostStatus.status_registry.add(HostStatus::BuildStatus)