1
1
/*
2
- Copyright (c) 2017 VMware, Inc. All Rights Reserved.
2
+ Copyright (c) 2017-2024 VMware, Inc. All Rights Reserved.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
6
6
You may obtain a copy of the License at
7
7
8
- http://www.apache.org/licenses/LICENSE-2.0
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
9
10
10
Unless required by applicable law or agreed to in writing, software
11
11
distributed under the License is distributed on an "AS IS" BASIS,
12
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
- // Copyright 2017 VMware, Inc. All Rights Reserved.
17
- //
18
- // Licensed under the Apache License, Version 2.0 (the "License");
19
- // you may not use this file except in compliance with the License.
20
- // You may obtain a copy of the License at
21
- //
22
- // http://www.apache.org/licenses/LICENSE-2.0
23
- //
24
- // Unless required by applicable law or agreed to in writing, software
25
- // distributed under the License is distributed on an "AS IS" BASIS,
26
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
- // See the License for the specific language governing permissions and
28
- // limitations under the License.
29
16
30
17
package simulator
31
18
@@ -67,12 +54,19 @@ func (m *LicenseManager) init(r *Registry) {
67
54
m .Licenses = []types.LicenseManagerLicenseInfo {EvalLicense }
68
55
69
56
if r .IsVPX () {
70
- am := Map .Put (& LicenseAssignmentManager {}).Reference ()
71
- m .LicenseAssignmentManager = & am
57
+ if m .LicenseAssignmentManager == nil {
58
+ m .LicenseAssignmentManager = & types.ManagedObjectReference {
59
+ Type : "LicenseAssignmentManager" ,
60
+ Value : "LicenseAssignmentManager" ,
61
+ }
62
+ }
63
+ r .Put (& LicenseAssignmentManager {
64
+ mo.LicenseAssignmentManager {Self : * m .LicenseAssignmentManager },
65
+ })
72
66
}
73
67
}
74
68
75
- func (m * LicenseManager ) AddLicense (req * types.AddLicense ) soap.HasFault {
69
+ func (m * LicenseManager ) AddLicense (ctx * Context , req * types.AddLicense ) soap.HasFault {
76
70
body := & methods.AddLicenseBody {
77
71
Res : & types.AddLicenseResponse {},
78
72
}
@@ -94,7 +88,7 @@ func (m *LicenseManager) AddLicense(req *types.AddLicense) soap.HasFault {
94
88
return body
95
89
}
96
90
97
- func (m * LicenseManager ) RemoveLicense (req * types.RemoveLicense ) soap.HasFault {
91
+ func (m * LicenseManager ) RemoveLicense (ctx * Context , req * types.RemoveLicense ) soap.HasFault {
98
92
body := & methods.RemoveLicenseBody {
99
93
Res : & types.RemoveLicenseResponse {},
100
94
}
@@ -108,7 +102,7 @@ func (m *LicenseManager) RemoveLicense(req *types.RemoveLicense) soap.HasFault {
108
102
return body
109
103
}
110
104
111
- func (m * LicenseManager ) UpdateLicenseLabel (req * types.UpdateLicenseLabel ) soap.HasFault {
105
+ func (m * LicenseManager ) UpdateLicenseLabel (ctx * Context , req * types.UpdateLicenseLabel ) soap.HasFault {
112
106
body := & methods.UpdateLicenseLabelBody {}
113
107
114
108
for i := range m .Licenses {
@@ -149,20 +143,20 @@ type LicenseAssignmentManager struct {
149
143
mo.LicenseAssignmentManager
150
144
}
151
145
152
- func (m * LicenseAssignmentManager ) QueryAssignedLicenses (req * types.QueryAssignedLicenses ) soap.HasFault {
146
+ func (m * LicenseAssignmentManager ) QueryAssignedLicenses (ctx * Context , req * types.QueryAssignedLicenses ) soap.HasFault {
153
147
body := & methods.QueryAssignedLicensesBody {
154
148
Res : & types.QueryAssignedLicensesResponse {},
155
149
}
156
150
157
151
// EntityId can be a HostSystem or the vCenter InstanceUuid
158
152
if req .EntityId != "" {
159
- if req .EntityId != Map .content ().About .InstanceUuid {
153
+ if req .EntityId != ctx . Map .content ().About .InstanceUuid {
160
154
id := types.ManagedObjectReference {
161
155
Type : "HostSystem" ,
162
156
Value : req .EntityId ,
163
157
}
164
158
165
- if Map .Get (id ) == nil {
159
+ if ctx . Map .Get (id ) == nil {
166
160
return body
167
161
}
168
162
}
@@ -178,6 +172,16 @@ func (m *LicenseAssignmentManager) QueryAssignedLicenses(req *types.QueryAssigne
178
172
return body
179
173
}
180
174
175
+ func (m * LicenseAssignmentManager ) UpdateAssignedLicense (ctx * Context , req * types.UpdateAssignedLicense ) soap.HasFault {
176
+ body := & methods.UpdateAssignedLicenseBody {
177
+ Res : & types.UpdateAssignedLicenseResponse {
178
+ Returnval : licenseInfo (req .LicenseKey , nil ),
179
+ },
180
+ }
181
+
182
+ return body
183
+ }
184
+
181
185
func licenseInfo (key string , labels []types.KeyValue ) types.LicenseManagerLicenseInfo {
182
186
info := EvalLicense
183
187
0 commit comments