@@ -53,7 +53,9 @@ func ovfNetwork(ctx *Context, req *types.CreateImportSpec, item ovf.ResourceAllo
53
53
ref := ctx .Map .getEntityDatacenter (pool ).defaultNetwork ()[0 ] // Default to VM Network
54
54
c := item .Connection [0 ]
55
55
56
- for _ , net := range req .Cisp .NetworkMapping {
56
+ cisp := req .Cisp .GetOvfCreateImportSpecParams ()
57
+
58
+ for _ , net := range cisp .NetworkMapping {
57
59
if net .Name == c {
58
60
ref = net .Network
59
61
break
@@ -109,12 +111,14 @@ func (m *OvfManager) CreateImportSpec(ctx *Context, req *types.CreateImportSpec)
109
111
return body
110
112
}
111
113
114
+ cisp := req .Cisp .GetOvfCreateImportSpecParams ()
115
+
112
116
ds := ctx .Map .Get (req .Datastore ).(* Datastore )
113
117
path := object.DatastorePath {Datastore : ds .Name }
114
118
vapp := & types.VAppConfigSpec {}
115
119
spec := & types.VirtualMachineImportSpec {
116
120
ConfigSpec : types.VirtualMachineConfigSpec {
117
- Name : req . Cisp .EntityName ,
121
+ Name : cisp .EntityName ,
118
122
Version : esx .HardwareVersion ,
119
123
GuestId : string (types .VirtualMachineGuestOsIdentifierOtherGuest ),
120
124
Files : & types.VirtualMachineFileInfo {
@@ -148,7 +152,7 @@ func (m *OvfManager) CreateImportSpec(ctx *Context, req *types.CreateImportSpec)
148
152
key := product .Key (p )
149
153
val := ""
150
154
151
- for _ , m := range req . Cisp .PropertyMapping {
155
+ for _ , m := range cisp .PropertyMapping {
152
156
if m .Key == key {
153
157
val = m .Value
154
158
}
@@ -176,10 +180,10 @@ func (m *OvfManager) CreateImportSpec(ctx *Context, req *types.CreateImportSpec)
176
180
}
177
181
}
178
182
179
- if req . Cisp .DeploymentOption == "" && env .DeploymentOption != nil {
183
+ if cisp .DeploymentOption == "" && env .DeploymentOption != nil {
180
184
for _ , c := range env .DeploymentOption .Configuration {
181
185
if isTrue (c .Default ) {
182
- req . Cisp .DeploymentOption = c .ID
186
+ cisp .DeploymentOption = c .ID
183
187
break
184
188
}
185
189
}
@@ -206,8 +210,8 @@ func (m *OvfManager) CreateImportSpec(ctx *Context, req *types.CreateImportSpec)
206
210
resources := make (map [string ]types.BaseVirtualDevice )
207
211
208
212
for _ , item := range hw .Item {
209
- if req . Cisp .DeploymentOption != "" && item .Configuration != nil {
210
- if req . Cisp .DeploymentOption != * item .Configuration {
213
+ if cisp .DeploymentOption != "" && item .Configuration != nil {
214
+ if cisp .DeploymentOption != * item .Configuration {
211
215
continue
212
216
}
213
217
}
@@ -232,7 +236,7 @@ func (m *OvfManager) CreateImportSpec(ctx *Context, req *types.CreateImportSpec)
232
236
233
237
upload := func (file ovf.File , c types.BaseVirtualDevice , n int ) {
234
238
result .FileItem = append (result .FileItem , types.OvfFileItem {
235
- DeviceId : fmt .Sprintf ("/%s/%s:%d" , req . Cisp .EntityName , device .Type (c ), n ),
239
+ DeviceId : fmt .Sprintf ("/%s/%s:%d" , cisp .EntityName , device .Type (c ), n ),
236
240
Path : file .Href ,
237
241
Size : int64 (file .Size ),
238
242
CimType : int32 (* item .ResourceType ),
@@ -289,7 +293,7 @@ func (m *OvfManager) CreateImportSpec(ctx *Context, req *types.CreateImportSpec)
289
293
if len (item .HostResource ) != 0 {
290
294
for _ , file := range env .References {
291
295
if strings .HasSuffix (item .HostResource [0 ], file .ID ) {
292
- path .Path = fmt .Sprintf ("%s/_deviceImage%d.iso" , req . Cisp .EntityName , ndev )
296
+ path .Path = fmt .Sprintf ("%s/_deviceImage%d.iso" , cisp .EntityName , ndev )
293
297
device .InsertIso (d , path .String ())
294
298
upload (file , d , ndev )
295
299
break
@@ -303,10 +307,10 @@ func (m *OvfManager) CreateImportSpec(ctx *Context, req *types.CreateImportSpec)
303
307
if ! ok {
304
308
continue // Parent is unsupported()
305
309
}
306
- path .Path = fmt .Sprintf ("%s/disk-%d.vmdk" , req . Cisp .EntityName , ndisk )
310
+ path .Path = fmt .Sprintf ("%s/disk-%d.vmdk" , cisp .EntityName , ndisk )
307
311
d := device .CreateDisk (c .(types.BaseVirtualController ), ds .Reference (), path .String ())
308
312
309
- switch types .OvfCreateImportSpecParamsDiskProvisioningType (req . Cisp .DiskProvisioning ) {
313
+ switch types .OvfCreateImportSpecParamsDiskProvisioningType (cisp .DiskProvisioning ) {
310
314
case "" ,
311
315
types .OvfCreateImportSpecParamsDiskProvisioningTypeMonolithicFlat ,
312
316
types .OvfCreateImportSpecParamsDiskProvisioningTypeFlat ,
@@ -321,9 +325,9 @@ func (m *OvfManager) CreateImportSpec(ctx *Context, req *types.CreateImportSpec)
321
325
default :
322
326
result .Error = append (result .Error , types.LocalizedMethodFault {
323
327
Fault : & types.OvfUnsupportedDiskProvisioning {
324
- DiskProvisioning : req . Cisp .DiskProvisioning ,
328
+ DiskProvisioning : cisp .DiskProvisioning ,
325
329
},
326
- LocalizedMessage : "Disk provisioning type not supported: " + req . Cisp .DiskProvisioning ,
330
+ LocalizedMessage : "Disk provisioning type not supported: " + cisp .DiskProvisioning ,
327
331
})
328
332
}
329
333
@@ -349,7 +353,7 @@ func (m *OvfManager) CreateImportSpec(ctx *Context, req *types.CreateImportSpec)
349
353
350
354
spec .ConfigSpec .DeviceChange , _ = device .ConfigSpec (types .VirtualDeviceConfigSpecOperationAdd )
351
355
352
- for _ , p := range req . Cisp .PropertyMapping {
356
+ for _ , p := range cisp .PropertyMapping {
353
357
spec .ConfigSpec .ExtraConfig = append (spec .ConfigSpec .ExtraConfig , & types.OptionValue {
354
358
Key : p .Key ,
355
359
Value : p .Value ,
0 commit comments