forked from ciscoecosystem/aci-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maint_upg_job.go
156 lines (132 loc) · 5.51 KB
/
maint_upg_job.go
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
package models
import (
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const MaintUpgJobClassName = "maintUpgJob"
type UpgJob struct {
BaseAttributes
UpgJobAttributes
}
type UpgJobAttributes struct {
CreationDate string `json:",omitempty"`
DesiredVersion string `json:",omitempty"`
DnldPercent string `json:",omitempty"`
DnldStatus string `json:",omitempty"`
DnldStatusStr string `json:",omitempty"`
EndDate string `json:",omitempty"`
FwGrp string `json:",omitempty"`
FwPolName string `json:",omitempty"`
GrpPriKey string `json:",omitempty"`
IUrl string `json:",omitempty"`
InstallId string `json:",omitempty"`
InstallStage string `json:",omitempty"`
InstlProgPct string `json:",omitempty"`
InternalLabel string `json:",omitempty"`
LastInstallDate string `json:",omitempty"`
MaintGrp string `json:",omitempty"`
NumAttempts string `json:",omitempty"`
NumAttemptsToBootupReady string `json:",omitempty"`
PolName string `json:",omitempty"`
SrDesiredVer string `json:",omitempty"`
SrUpg string `json:",omitempty"`
StartDate string `json:",omitempty"`
UpgradeStatus string `json:",omitempty"`
UpgradeStatusStr string `json:",omitempty"`
}
/*
* No NewUpgJob as this is a non-configurable MO
func NewUpgJob(maintUpgJobRn, parentDn, description string, maintUpgJobattr UpgJobAttributes) *UpgJob {
dn := fmt.Sprintf("%s/%s", parentDn, maintUpgJobRn)
return &UpgJob{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: MaintUpgJobClassName,
Rn: maintUpgJobRn,
},
UpgJobAttributes: maintUpgJobattr,
}
}
*/
func (maintUpgJob *UpgJob) ToMap() (map[string]string, error) {
maintUpgJobMap, err := maintUpgJob.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(maintUpgJobMap, "creationDate",maintUpgJob.CreationDate)
A(maintUpgJobMap, "desiredVersion",maintUpgJob.DesiredVersion)
A(maintUpgJobMap, "dnldPercent",maintUpgJob.DnldPercent)
A(maintUpgJobMap, "dnldStatus",maintUpgJob.DnldStatus)
A(maintUpgJobMap, "dnldStatusStr",maintUpgJob.DnldStatusStr)
A(maintUpgJobMap, "endDate",maintUpgJob.EndDate)
A(maintUpgJobMap, "fwGrp",maintUpgJob.FwGrp)
A(maintUpgJobMap, "fwPolName",maintUpgJob.FwPolName)
A(maintUpgJobMap, "grpPriKey",maintUpgJob.GrpPriKey)
A(maintUpgJobMap, "iUrl",maintUpgJob.IUrl)
A(maintUpgJobMap, "installId",maintUpgJob.InstallId)
A(maintUpgJobMap, "installStage",maintUpgJob.InstallStage)
A(maintUpgJobMap, "instlProgPct",maintUpgJob.InstlProgPct)
A(maintUpgJobMap, "internalLabel",maintUpgJob.InternalLabel)
A(maintUpgJobMap, "lastInstallDate",maintUpgJob.LastInstallDate)
A(maintUpgJobMap, "maintGrp",maintUpgJob.MaintGrp)
A(maintUpgJobMap, "numAttempts",maintUpgJob.NumAttempts)
A(maintUpgJobMap, "numAttemptsToBootupReady",maintUpgJob.NumAttemptsToBootupReady)
A(maintUpgJobMap, "polName",maintUpgJob.PolName)
A(maintUpgJobMap, "srDesiredVer",maintUpgJob.SrDesiredVer)
A(maintUpgJobMap, "srUpg",maintUpgJob.SrUpg)
A(maintUpgJobMap, "startDate",maintUpgJob.StartDate)
A(maintUpgJobMap, "upgradeStatus",maintUpgJob.UpgradeStatus)
A(maintUpgJobMap, "upgradeStatusStr",maintUpgJob.UpgradeStatusStr)
return maintUpgJobMap, err
}
func UpgJobFromContainerList(cont *container.Container, index int) *UpgJob {
UpgJobCont := cont.S("imdata").Index(index).S(MaintUpgJobClassName, "attributes")
return &UpgJob{
BaseAttributes{
DistinguishedName: G(UpgJobCont, "dn"),
Description: G(UpgJobCont, "descr"),
Status: G(UpgJobCont, "status"),
ClassName: MaintUpgJobClassName,
Rn: G(UpgJobCont, "rn"),
},
UpgJobAttributes{
CreationDate : G(UpgJobCont,"creationDate"),
DesiredVersion : G(UpgJobCont,"desiredVersion"),
DnldPercent : G(UpgJobCont,"dnldPercent"),
DnldStatus : G(UpgJobCont,"dnldStatus"),
DnldStatusStr : G(UpgJobCont,"dnldStatusStr"),
EndDate : G(UpgJobCont,"endDate"),
FwGrp : G(UpgJobCont,"fwGrp"),
FwPolName : G(UpgJobCont,"fwPolName"),
GrpPriKey : G(UpgJobCont,"grpPriKey"),
IUrl : G(UpgJobCont,"iUrl"),
InstallId : G(UpgJobCont,"installId"),
InstallStage : G(UpgJobCont,"installStage"),
InstlProgPct : G(UpgJobCont,"instlProgPct"),
InternalLabel : G(UpgJobCont,"internalLabel"),
LastInstallDate : G(UpgJobCont,"lastInstallDate"),
MaintGrp : G(UpgJobCont,"maintGrp"),
NumAttempts : G(UpgJobCont,"numAttempts"),
NumAttemptsToBootupReady : G(UpgJobCont,"numAttemptsToBootupReady"),
PolName : G(UpgJobCont,"polName"),
SrDesiredVer : G(UpgJobCont,"srDesiredVer"),
SrUpg : G(UpgJobCont,"srUpg"),
StartDate : G(UpgJobCont,"startDate"),
UpgradeStatus : G(UpgJobCont,"upgradeStatus"),
UpgradeStatusStr : G(UpgJobCont,"upgradeStatusStr"),
},
}
}
func UpgJobFromContainer(cont *container.Container) *UpgJob {
return UpgJobFromContainerList(cont, 0)
}
func UpgJobListFromContainer(cont *container.Container) []*UpgJob {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*UpgJob, length)
for i := 0; i < length; i++ {
arr[i] = UpgJobFromContainerList(cont, i)
}
return arr
}