-
Notifications
You must be signed in to change notification settings - Fork 479
Expand file tree
/
Copy pathmachineconfignode.go
More file actions
170 lines (137 loc) · 5.77 KB
/
machineconfignode.go
File metadata and controls
170 lines (137 loc) · 5.77 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
package extended
import (
exutil "github.com/openshift/machine-config-operator/test/extended-priv/util"
)
// MachineConfigNode resource type declaration
type MachineConfigNode struct {
Resource
}
// MachineConfigNodeList resource type declaration
type MachineConfigNodeList struct {
ResourceList
}
// NewMachineConfigNode constructor to get MCN resource
func NewMachineConfigNode(oc *exutil.CLI, node string) *MachineConfigNode {
return &MachineConfigNode{Resource: *NewResource(oc, "machineconfignode", node)}
}
// NewMachineConfigNodeList constructor to get MCN list
func NewMachineConfigNodeList(oc *exutil.CLI) *MachineConfigNodeList {
return &MachineConfigNodeList{ResourceList: *NewResourceList(oc, "machineconfignodes")}
}
// GetAll get list of MachineConfigNode
func (mcnl *MachineConfigNodeList) GetAll() ([]*MachineConfigNode, error) {
resources, err := mcnl.ResourceList.GetAll()
if err != nil {
return nil, err
}
allMCNs := make([]*MachineConfigNode, 0, len(resources))
for _, mcn := range resources {
allMCNs = append(allMCNs, NewMachineConfigNode(mcnl.oc, mcn.GetName()))
}
return allMCNs, nil
}
// GetDesiredMachineConfigOfSpec get value of `.spec.configVersion.desired`
func (mcn *MachineConfigNode) GetDesiredMachineConfigOfSpec() string {
return mcn.GetOrFail(`{.spec.configVersion.desired}`)
}
// GetDesiredMachineConfigOfStatus get value of `.status.configVersion.desired`
func (mcn *MachineConfigNode) GetDesiredMachineConfigOfStatus() string {
return mcn.GetOrFail(`{.status.configVersion.desired}`)
}
// GetCurrentMachineConfigOfStatus get value of `.status.configVersion.current`
func (mcn *MachineConfigNode) GetCurrentMachineConfigOfStatus() string {
return mcn.GetOrFail(`{.status.configVersion.current}`)
}
// GetPool get value of `.spec.pool.name`
func (mcn *MachineConfigNode) GetPoolName() (string, error) {
return mcn.Get(`{.spec.pool.name}`)
}
// GetNode get value of `.spec.node.name`
func (mcn *MachineConfigNode) GetNode() string {
return mcn.GetOrFail(`{.spec.node.name}`)
}
// GetUpdated get condition status of `Updated`
func (mcn *MachineConfigNode) GetUpdated() string {
return mcn.GetConditionStatusByType("Updated")
}
// GetUpdatePrepared get condition status of `UpdatePrepared`
func (mcn *MachineConfigNode) GetUpdatePrepared() string {
return mcn.GetConditionStatusByType("UpdatePrepared")
}
// GetUpdateExecuted get condition status of `UpdateExecuted`
func (mcn *MachineConfigNode) GetUpdateExecuted() string {
return mcn.GetConditionStatusByType("UpdateExecuted")
}
// GetUpdatePostActionComplete get condition status of `UpdatePostActionComplete`
func (mcn *MachineConfigNode) GetUpdatePostActionComplete() string {
return mcn.GetConditionStatusByType("UpdatePostActionComplete")
}
// GetUpdateComplete get condition status of `UpdateComplete`
func (mcn *MachineConfigNode) GetUpdateComplete() string {
return mcn.GetConditionStatusByType("UpdateComplete")
}
// GetResumed get condition status of `Resumed`
func (mcn *MachineConfigNode) GetResumed() string {
return mcn.GetConditionStatusByType("Resumed")
}
// GetUpdateCompatible get condition status of `UpdateCompatible`
func (mcn *MachineConfigNode) GetUpdateCompatible() string {
return mcn.GetConditionStatusByType("UpdateCompatible")
}
// GetAppliedFiles get condition status of `AppliedFiles`
func (mcn *MachineConfigNode) GetAppliedFiles() string {
return mcn.GetConditionStatusByType("AppliedFiles")
}
// GetAppliedConditionStatus returns the status of the appropriate Applied condition.
// It checks for AppliedFilesAndOS first (non-TP clusters), then falls back to AppliedFiles (TP clusters)
func (mcn *MachineConfigNode) GetAppliedConditionStatus() string {
// Try AppliedFilesAndOS first (non-TechPreview clusters)
status, err := mcn.Get(`{.status.conditions[?(@.type=="AppliedFilesAndOS")].status}`)
if err == nil && status != "" {
return status
}
// Fall back to AppliedFiles (TechPreview clusters)
return mcn.GetAppliedFiles()
}
// GetCordoned get condition status of `Cordoned`
func (mcn *MachineConfigNode) GetCordoned() string {
return mcn.GetConditionStatusByType("Cordoned")
}
// GetUncordoned get condition status of `Uncordoned`
func (mcn *MachineConfigNode) GetUncordoned() string {
return mcn.GetConditionStatusByType("Uncordoned")
}
// GetDrained get condition status of `Drained`
func (mcn *MachineConfigNode) GetDrained() string {
return mcn.GetConditionStatusByType("Drained")
}
// GetRebootedNode get condition status of `RebootedNode`
func (mcn *MachineConfigNode) GetRebootedNode() string {
return mcn.GetConditionStatusByType("RebootedNode")
}
// GetReloadedCRIO get condition status of `ReloadedCRIO`
func (mcn *MachineConfigNode) GetReloadedCRIO() string {
return mcn.GetConditionStatusByType("ReloadedCRIO")
}
func (mcn *MachineConfigNode) IsPinnedImageSetsDegraded() bool {
return mcn.IsConditionStatusTrue("PinnedImageSetsDegraded")
}
func (mcn *MachineConfigNode) IsPinnedImageSetsProgressing() bool {
return mcn.IsConditionStatusTrue("PinnedImageSetsProgressing")
}
// GetDesiredMachineConfigOfSpec get value of `.spec.configVersion.desired`
func (mcn *MachineConfigNode) GetPinnedImageSetLastFailedError() string {
return mcn.GetOrFail(`{.status.pinnedImageSets[*].lastFailedGenerationError}`)
}
// GetDesiredImage get value of `.spec.configImage.desiredImage`
func (mcn *MachineConfigNode) GetSpecDesiredImage() (string, error) {
return mcn.Get(`{.spec.configImage.desiredImage}`)
}
// GetStatusDesiredImage get value of `.status.configImage.desiredImage`
func (mcn *MachineConfigNode) GetStatusDesiredImage() (string, error) {
return mcn.Get(`{.status.configImage.desiredImage}`)
}
// GetStatusCurrentImage get value of `.status.configImage.currentImage`
func (mcn *MachineConfigNode) GetStatusCurrentImage() (string, error) {
return mcn.Get(`{.status.configImage.currentImage}`)
}