-
Notifications
You must be signed in to change notification settings - Fork 48
/
VPCHandler.go
543 lines (489 loc) · 19 KB
/
VPCHandler.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
package resources
import (
"errors"
"fmt"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers"
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
call "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/call-log"
irs "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources"
)
const (
VPC = "VPC"
)
type OpenStackVPCHandler struct {
Client *gophercloud.ServiceClient
}
type NetworkWithExt struct {
networks.Network
external.NetworkExternalExt
}
func (vpcHandler *OpenStackVPCHandler) setterVPC(nvpc NetworkWithExt) *irs.VPCInfo {
// VPC 정보 맵핑
vpcInfo := irs.VPCInfo{
IId: irs.IID{
NameId: nvpc.Name,
SystemId: nvpc.ID,
},
}
var External string
if nvpc.External == true {
External = "Yes"
} else if nvpc.External == false {
External = "No"
}
keyValueList := []irs.KeyValue{
{Key: "External Network", Value: External},
}
vpcInfo.KeyValueList = keyValueList
// 서브넷 정보 조회
subnetInfoList := make([]irs.SubnetInfo, len(nvpc.Subnets))
for i, subnetId := range nvpc.Subnets {
subnetInfo, err := vpcHandler.GetSubnet(irs.IID{SystemId: subnetId})
if err != nil {
cblogger.Error("Failed to Get Subnet with Id %s, err=%s", subnetId, err)
continue
}
subnetInfoList[i] = subnetInfo
}
vpcInfo.SubnetInfoList = subnetInfoList
return &vpcInfo
}
func (vpcHandler *OpenStackVPCHandler) setterSubnet(subnet subnets.Subnet) *irs.SubnetInfo {
subnetInfo := irs.SubnetInfo{
IId: irs.IID{
NameId: subnet.Name,
SystemId: subnet.ID,
},
IPv4_CIDR: subnet.CIDR,
}
return &subnetInfo
}
func (vpcHandler *OpenStackVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCInfo, error) {
// log HisCall
hiscallInfo := GetCallLogScheme(vpcHandler.Client.IdentityEndpoint, call.VPCSUBNET, vpcReqInfo.IId.NameId, "CreateVPC()")
// Check VPC Exists
listOpts := networks.ListOpts{Name: vpcReqInfo.IId.NameId}
page, err := networks.List(vpcHandler.Client, listOpts).AllPages()
if err != nil {
cblogger.Error(err.Error())
LoggingError(hiscallInfo, err)
return irs.VPCInfo{}, err
}
vpcList, err := networks.ExtractNetworks(page)
if err != nil {
cblogger.Error(err.Error())
LoggingError(hiscallInfo, err)
return irs.VPCInfo{}, err
}
if len(vpcList) != 0 {
createErr := errors.New(fmt.Sprintf("Failed to Create VPC. The VPC name %s already exists", vpcReqInfo.IId.NameId))
cblogger.Error(createErr.Error())
LoggingError(hiscallInfo, createErr)
return irs.VPCInfo{}, createErr
}
// Create VPC
createOpts := networks.CreateOpts{
Name: vpcReqInfo.IId.NameId,
}
start := call.Start()
vpc, err := networks.Create(vpcHandler.Client, createOpts).Extract()
if err != nil {
createErr := errors.New(fmt.Sprintf("Failed to Create VPC with name %s err=%s and Finished to rollback deleting", vpcReqInfo.IId.NameId, err.Error()))
cblogger.Error(createErr.Error())
LoggingError(hiscallInfo, createErr)
return irs.VPCInfo{}, createErr
}
LoggingInfo(hiscallInfo, start)
// Create Subnet
for _, subnet := range vpcReqInfo.SubnetInfoList {
_, err := vpcHandler.CreateSubnet(vpc.ID, subnet)
if err != nil {
// CreateSubnet Error => DeleteNetwork
networkDeleteErr := networks.Delete(vpcHandler.Client, vpc.ID).ExtractErr()
createErr := errors.New(fmt.Sprintf("Failed to Create VPC with name %s. While Create Failed Subnet with name %s, err=%s and Finished to rollback deleting", vpcReqInfo.IId.NameId, subnet.IId.NameId, err.Error()))
if networkDeleteErr != nil {
// CreateSubnet Error => DeleteNetwork Error => return error + error
createErr = errors.New(fmt.Sprintf("Failed to Create VPC with name %s. While Create Failed subnet with name %s, err=%s and Failed to rollback delete Network with name %s. err=%s", vpcReqInfo.IId.NameId, subnet.IId.NameId, err.Error(), vpcReqInfo.IId.NameId, networkDeleteErr.Error()))
}
cblogger.Error(createErr.Error())
LoggingError(hiscallInfo, createErr)
return irs.VPCInfo{}, createErr
}
}
vpcInfo, err := vpcHandler.GetVPC(irs.IID{SystemId: vpc.ID})
if err != nil {
createErr := errors.New(fmt.Sprintf("Failed to Create VPC with name %s, err=%s and Finished to rollback deleting", vpcReqInfo.IId.NameId, err.Error()))
networkDeleteErr := networks.Delete(vpcHandler.Client, vpc.ID).ExtractErr()
if networkDeleteErr != nil {
// CreateSubnet Error => DeleteNetwork Error => return error + error
createErr = errors.New(fmt.Sprintf("Failed to Create VPC with name %s, err=%s and Failed to rollback delete Network with name %s err=%s", vpcReqInfo.IId.NameId, err.Error(), vpcReqInfo.IId.NameId, networkDeleteErr.Error()))
}
cblogger.Error(createErr.Error())
LoggingError(hiscallInfo, createErr)
return irs.VPCInfo{}, createErr
}
// TODO: nested flow 개선
// Create Router
routerId, err := vpcHandler.CreateRouter(vpcReqInfo.IId.NameId)
if err != nil {
// CreateRouter Error => DeleteNetwork
createErr := errors.New(fmt.Sprintf("Failed to Create VPC with name %s, and Finished to rollback deleting", vpcReqInfo.IId.NameId))
networkDeleteErr := networks.Delete(vpcHandler.Client, vpc.ID).ExtractErr()
if networkDeleteErr != nil {
// CreateRouter Error => DeleteNetwork Error => return error + error
err = errors.New(fmt.Sprintf("Failed to Create VPC with name %s err=%s, and Failed to rollback delete Network with name %s err=%s", vpcReqInfo.IId.NameId, err.Error(), vpcReqInfo.IId.NameId, networkDeleteErr.Error()))
}
cblogger.Error(createErr.Error())
LoggingError(hiscallInfo, createErr)
return irs.VPCInfo{}, createErr
}
// TODO: nested flow 개선
// Create Interface
for subnetIndex, subnet := range vpcInfo.SubnetInfoList {
if ok, err := vpcHandler.AddInterface(subnet.IId.SystemId, *routerId); !ok {
// AddInterface Error => Delete PreInterfaceDelete
if subnetIndex != 0 {
preSubnetList := vpcInfo.SubnetInfoList[:subnetIndex]
for _, deleteSubnet := range preSubnetList {
if deleteCheck, err := vpcHandler.DeleteInterface(deleteSubnet.IId.SystemId, *routerId); !deleteCheck {
if err == nil {
createErr := errors.New(fmt.Sprintf("Failed to Create VPC with name %s and Failed to rollback delete Interface", vpcReqInfo.IId.NameId))
cblogger.Error(createErr.Error())
LoggingError(hiscallInfo, createErr)
return irs.VPCInfo{}, createErr
}
createErr := errors.New(fmt.Sprintf("Failed to Create VPC with name %s and Failed to rollback delete Network with name %s, Router with name %s-Router, Interfaces err=%s", vpcReqInfo.IId.NameId, vpcReqInfo.IId.NameId, vpcReqInfo.IId.NameId, err.Error()))
cblogger.Error(createErr.Error())
LoggingError(hiscallInfo, createErr)
return irs.VPCInfo{}, createErr
}
}
}
// AddInterface Error => Delete Router
if err == nil {
createErr := errors.New(fmt.Sprintf("Failed to Create VPC with name %s, and Finished to rollback deleting", vpcReqInfo.IId.NameId))
cblogger.Error(createErr.Error())
LoggingError(hiscallInfo, createErr)
return irs.VPCInfo{}, createErr
}
createErr := errors.New(fmt.Sprintf("Failed to Create VPC with name %s, and Finished to rollback deleting", vpcReqInfo.IId.NameId))
// Delete Router
routerDeleteErr := routers.Delete(vpcHandler.Client, *routerId).ExtractErr()
if routerDeleteErr != nil {
// AddInterface Error => Delete Router Error return error + error
createErr = errors.New(fmt.Sprintf("Failed to Create VPC with name %s err=%s and Failed to rollback delete Network with name %s, Router with name %s-Router err=%s", vpcReqInfo.IId.NameId, err.Error(), vpcReqInfo.IId.NameId, vpcReqInfo.IId.NameId, routerDeleteErr.Error()))
} else {
// AddInterface Error => Delete Router Success => Delete Network
networkDeleteErr := networks.Delete(vpcHandler.Client, vpc.ID).ExtractErr()
if networkDeleteErr != nil {
// AddInterface Error => Delete Router Success => Delete Network Error return error + error
createErr = errors.New(fmt.Sprintf("Failed to Create VPC with name %s err=%s, and Failed to rollback delete Network with name %s err=%s", vpcReqInfo.IId.NameId, err.Error(), vpcReqInfo.IId.NameId, networkDeleteErr.Error()))
}
}
cblogger.Error(createErr.Error())
LoggingError(hiscallInfo, createErr)
return irs.VPCInfo{}, createErr
}
}
return vpcInfo, nil
}
func (vpcHandler *OpenStackVPCHandler) ListVPC() ([]*irs.VPCInfo, error) {
// log HisCall
hiscallInfo := GetCallLogScheme(vpcHandler.Client.IdentityEndpoint, call.VPCSUBNET, VPC, "ListVPC()")
listOpts := external.ListOptsExt{
ListOptsBuilder: networks.ListOpts{},
}
start := call.Start()
page, err := networks.List(vpcHandler.Client, listOpts).AllPages()
if err != nil {
getErr := errors.New(fmt.Sprintf("Failed to Get VPC List, err=%s", err.Error()))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return nil, getErr
}
LoggingInfo(hiscallInfo, start)
var vpcList []NetworkWithExt
err = networks.ExtractNetworksInto(page, &vpcList)
if err != nil {
getErr := errors.New(fmt.Sprintf("Failed to Get VPC List, err=%s", err.Error()))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return nil, getErr
}
// Get VPC List
vpcInfoList := make([]*irs.VPCInfo, len(vpcList))
for i, vpc := range vpcList {
vpcInfo := vpcHandler.setterVPC(vpc)
vpcInfoList[i] = vpcInfo
}
return vpcInfoList, nil
}
func (vpcHandler *OpenStackVPCHandler) GetVPC(vpcIID irs.IID) (irs.VPCInfo, error) {
// log HisCall
hiscallInfo := GetCallLogScheme(vpcHandler.Client.IdentityEndpoint, call.VPCSUBNET, vpcIID.NameId, "GetVPC()")
var vpc NetworkWithExt
start := call.Start()
if iidCheck := CheckIIDValidation(vpcIID); !iidCheck {
getErr := errors.New(fmt.Sprintf("Failed to Get VPC err = InValid IID"))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return irs.VPCInfo{}, getErr
}
if vpcIID.SystemId == "" {
listOpts := external.ListOptsExt{
ListOptsBuilder: networks.ListOpts{
Name: vpcIID.NameId,
},
}
page, err := networks.List(vpcHandler.Client, listOpts).AllPages()
if err != nil {
getErr := errors.New(fmt.Sprintf("Failed to Get VPC with Id %s, err=%s", vpcIID.SystemId, err.Error()))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return irs.VPCInfo{}, getErr
}
LoggingInfo(hiscallInfo, start)
var vpcList []NetworkWithExt
err = networks.ExtractNetworksInto(page, &vpcList)
if err != nil {
getErr := errors.New(fmt.Sprintf("Failed to Get VPC with Id %s, err=%s", vpcIID.SystemId, err.Error()))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return irs.VPCInfo{}, getErr
}
for _, vpc := range vpcList {
if vpc.Name == vpcIID.NameId {
vpcInfo := vpcHandler.setterVPC(vpc)
return *vpcInfo, nil
}
}
notExistVpcErr := errors.New(fmt.Sprintf("Failed to Get VPC with Id %s, not Exist VPC", vpcIID.SystemId))
getErr := errors.New(fmt.Sprintf("Failed to Get VPC with Id %s, err=%s", vpcIID.SystemId, notExistVpcErr))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return irs.VPCInfo{}, getErr
} else {
err := networks.Get(vpcHandler.Client, vpcIID.SystemId).ExtractInto(&vpc)
if err != nil {
getErr := errors.New(fmt.Sprintf("Failed to Get VPC with Id %s, err=%s", vpcIID.SystemId, err.Error()))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return irs.VPCInfo{}, getErr
}
LoggingInfo(hiscallInfo, start)
vpcInfo := vpcHandler.setterVPC(vpc)
return *vpcInfo, nil
}
}
func (vpcHandler *OpenStackVPCHandler) DeleteVPC(vpcIID irs.IID) (bool, error) {
// log HisCall
hiscallInfo := GetCallLogScheme(vpcHandler.Client.IdentityEndpoint, call.VPCSUBNET, vpcIID.NameId, "DeleteVPC()")
vpcInfo, err := vpcHandler.GetVPC(vpcIID)
if err != nil {
getErr := errors.New(fmt.Sprintf("Failed to Delete VPC with name %s err=%s", vpcIID.NameId, err.Error()))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return false, getErr
}
// Delete Interface
routerId, err := vpcHandler.GetRouter(vpcIID.NameId)
if err == nil {
// Delete Interface
for _, subnet := range vpcInfo.SubnetInfoList {
if ok, err := vpcHandler.DeleteInterface(subnet.IId.SystemId, *routerId); !ok {
if err != nil && err.Error() != ResourceNotFound {
// DeleteInterface Error except Resource not found
getErr := errors.New(fmt.Sprintf("Failed to Delete VPC with name %s err=%s", vpcIID.NameId, err.Error()))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return false, getErr
}
}
}
// Delete Router
if routerId != nil {
err = routers.Delete(vpcHandler.Client, *routerId).ExtractErr()
if err != nil {
getErr := errors.New(fmt.Sprintf("Failed to Delete VPC with name %s err=%s", vpcIID.NameId, err.Error()))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return false, getErr
}
}
} else if err.Error() != ResourceNotFound {
getErr := errors.New(fmt.Sprintf("Failed to Delete VPC with name %s err=%s", vpcIID.NameId, err.Error()))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return false, getErr
}
// TODO: nested flow 개선
//Delete VPC
start := call.Start()
err = networks.Delete(vpcHandler.Client, vpcInfo.IId.SystemId).ExtractErr()
if err != nil {
getErr := errors.New(fmt.Sprintf("Failed to Delete VPC with name %s err=%s", vpcIID.NameId, err.Error()))
cblogger.Error(getErr.Error())
LoggingError(hiscallInfo, getErr)
return false, getErr
}
LoggingInfo(hiscallInfo, start)
return true, nil
}
func (vpcHandler *OpenStackVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.SubnetInfo) (irs.SubnetInfo, error) {
subnetCreateOpts := subnets.CreateOpts{
NetworkID: vpcId,
Name: reqSubnetInfo.IId.NameId,
CIDR: reqSubnetInfo.IPv4_CIDR,
IPVersion: gophercloud.IPv4,
DNSNameservers: []string{DNSNameservers},
}
subnet, err := subnets.Create(vpcHandler.Client, subnetCreateOpts).Extract()
if err != nil {
cblogger.Error("Failed to Create Subnet with name %s, err=%s", reqSubnetInfo.IId.NameId, err)
return irs.SubnetInfo{}, err
}
subnetInfo := vpcHandler.setterSubnet(*subnet)
return *subnetInfo, nil
}
func (vpcHandler *OpenStackVPCHandler) GetSubnet(subnetIId irs.IID) (irs.SubnetInfo, error) {
subnet, err := subnets.Get(vpcHandler.Client, subnetIId.SystemId).Extract()
if err != nil {
cblogger.Error("Failed to Get Subnet with Id %s, err=%s", subnetIId.SystemId, err)
return irs.SubnetInfo{}, nil
}
subnetInfo := vpcHandler.setterSubnet(*subnet)
return *subnetInfo, nil
}
func (vpcHandler *OpenStackVPCHandler) DeleteSubnet(subnetIId irs.IID) (bool, error) {
err := subnets.Delete(vpcHandler.Client, subnetIId.SystemId).ExtractErr()
if err != nil {
cblogger.Error("Failed to Delete Subnet with Id %s, err=%s", subnetIId.SystemId, err)
return false, err
}
return true, nil
}
func (vpcHandler *OpenStackVPCHandler) CreateRouter(vpcName string) (*string, error) {
externVPCId, _ := GetPublicVPCInfo(vpcHandler.Client, "ID")
routerName := vpcName + "-Router"
AdminStateUp := true
createOpts := routers.CreateOpts{
Name: routerName,
AdminStateUp: &AdminStateUp,
GatewayInfo: &routers.GatewayInfo{
NetworkID: externVPCId,
},
}
// Create Router
router, err := routers.Create(vpcHandler.Client, createOpts).Extract()
if err != nil {
return nil, err
}
return &router.ID, nil
}
func (vpcHandler *OpenStackVPCHandler) GetRouter(vpcName string) (*string, error) {
// Get Router Info
routerName := vpcName + "-Router"
listOpts := routers.ListOpts{Name: routerName}
page, err := routers.List(vpcHandler.Client, listOpts).AllPages()
if err != nil {
cblogger.Error("Failed to Get Router List, err=%s", err)
return nil, err
}
routerList, err := routers.ExtractRouters(page)
if err != nil {
cblogger.Error("Failed to extract Router, err=%s", err)
return nil, err
}
if len(routerList) != 1 {
notExistErr := errors.New(ResourceNotFound)
cblogger.Error("Failed to Get Router with name %s, err=%s", routerName, notExistErr)
return nil, notExistErr
}
routerId := routerList[0].ID
return &routerId, nil
}
func (vpcHandler *OpenStackVPCHandler) DeleteRouter(vpcName string) (bool, error) {
// Get Router
routerId, err := vpcHandler.GetRouter(vpcName)
if err != nil {
if err.Error() == ResourceNotFound {
cblogger.Error("Failed to Delete Router with Id %s, err=%s", routerId, ResourceNotFound)
return false, err
}
cblogger.Error("Failed to Delete Router with Id %s, err=%s", routerId)
return false, err
}
// Delete Router
err = routers.Delete(vpcHandler.Client, *routerId).ExtractErr()
if err != nil {
cblogger.Error("Failed to Delete Router with Id %s, err=%s", routerId)
return false, err
}
return true, nil
}
////////////////////////////////////TEST 진행
func (vpcHandler *OpenStackVPCHandler) AddInterface(subnetId string, routerId string) (bool, error) {
createOpts := routers.AddInterfaceOpts{
SubnetID: subnetId,
}
// Add Interface
_, err := routers.AddInterface(vpcHandler.Client, routerId, createOpts).Extract()
if err != nil {
return false, err
}
return true, nil
}
func (vpcHandler *OpenStackVPCHandler) DeleteInterface(subnetId string, routerId string) (bool, error) {
deleteOpts := routers.RemoveInterfaceOpts{
SubnetID: subnetId,
}
// Delete Interface
_, err := routers.RemoveInterface(vpcHandler.Client, routerId, deleteOpts).Extract()
if err != nil {
return false, err
}
return true, nil
}
func (vpcHandler *OpenStackVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.SubnetInfo) (irs.VPCInfo, error) {
// log HisCall
hiscallInfo := GetCallLogScheme(vpcHandler.Client.IdentityEndpoint, call.VPCSUBNET, subnetInfo.IId.NameId, "AddSubnet()")
subnetCreateOpts := subnets.CreateOpts{
NetworkID: vpcIID.SystemId,
Name: subnetInfo.IId.NameId,
CIDR: subnetInfo.IPv4_CIDR,
IPVersion: gophercloud.IPv4,
DNSNameservers: []string{DNSNameservers},
}
start := call.Start()
_, err := subnets.Create(vpcHandler.Client, subnetCreateOpts).Extract()
if err != nil {
createErr := errors.New(fmt.Sprintf("Failed to Create Subnet with name %s, err=%s", subnetCreateOpts.Name, err.Error()))
cblogger.Error(createErr.Error())
LoggingError(hiscallInfo, createErr)
return irs.VPCInfo{}, createErr
}
LoggingInfo(hiscallInfo, start)
result, err := vpcHandler.GetVPC(vpcIID)
if err != nil {
cblogger.Error(err.Error())
LoggingError(hiscallInfo, err)
return irs.VPCInfo{}, err
}
return result, nil
}
func (vpcHandler *OpenStackVPCHandler) RemoveSubnet(vpcIID irs.IID, subnetIID irs.IID) (bool, error) {
// log HisCall
hiscallInfo := GetCallLogScheme(vpcHandler.Client.IdentityEndpoint, call.VPCSUBNET, subnetIID.NameId, "RemoveSubnet()")
start := call.Start()
err := subnets.Delete(vpcHandler.Client, subnetIID.SystemId).ExtractErr()
if err != nil {
cblogger.Error(err.Error())
LoggingError(hiscallInfo, err)
return false, err
}
LoggingInfo(hiscallInfo, start)
return true, nil
}