@@ -366,107 +366,6 @@ func endpointGroupCleanup(endpointGroup *contivModel.EndpointGroup) {
366
366
// FIXME: hack to allocate unique endpoint group ids
367
367
var globalEpgID = 1
368
368
369
- /*
370
- // Some utility functions to work with the external contracts
371
- func extContractsGrpDeregister(epg *contivModel.EndpointGroup, contractsGrp *contivModel.ExtContractsGroup, contractType string) error {
372
- if contractsGrp == nil {
373
- errStr := fmt.Sprintf("%s External contracts group not found", contractType)
374
- log.Errorf(errStr)
375
- return core.Errorf(errStr)
376
- }
377
-
378
- modeldb.RemoveLinkSet(&contractsGrp.LinkSets.EndpointGroups, epg)
379
- if contractType == "provided" {
380
- modeldb.RemoveLinkSet(&epg.LinkSets.ProvExtContractsGrps, contractsGrp)
381
- } else if contractType == "consumed" {
382
- modeldb.RemoveLinkSet(&epg.LinkSets.ConsExtContractsGrps, contractsGrp)
383
- }
384
- // Links broken, update the contracts group object.
385
- err := contractsGrp.Write()
386
- if err != nil {
387
- return err
388
- }
389
-
390
- return nil
391
- }
392
-
393
- func extContractsGrpValidateAndRegister(epg *contivModel.EndpointGroup, contractsGrp *contivModel.ExtContractsGroup, contractType string) error {
394
- if contractsGrp == nil {
395
- errStr := fmt.Sprintf("%s External contracts group not found", contractType)
396
- log.Errorf(errStr)
397
- return core.Errorf(errStr)
398
- }
399
-
400
- if strings.ToLower(contractsGrp.ContractsType) != contractType {
401
- errStr := fmt.Sprintf("Incorrect type for contract group: %v", contractsGrp)
402
- log.Errorf(errStr)
403
- return core.Errorf(errStr)
404
- }
405
-
406
- // Establish the necessary links.
407
- // TBD: Error handling. In the loop, we are bailing out
408
- // on failure. How do we take care of already established
409
- // links?
410
- modeldb.AddLinkSet(&contractsGrp.LinkSets.EndpointGroups, epg)
411
- if contractType == "provided" {
412
- modeldb.AddLinkSet(&epg.LinkSets.ProvExtContractsGrps, contractsGrp)
413
- } else if contractType == "consumed" {
414
- modeldb.AddLinkSet(&epg.LinkSets.ConsExtContractsGrps, contractsGrp)
415
- }
416
-
417
- // Links made, write the policy set object.
418
- err := contractsGrp.Write()
419
- if err != nil {
420
- return err
421
- }
422
-
423
- return nil
424
- }
425
-
426
- func cleanupExternalContracts(endpointGroup *contivModel.EndpointGroup) error {
427
- // Cleanup consumed external contracts
428
- for _, consExtContractsGrp := range endpointGroup.ConsExtContractsGrps {
429
- contractsGrp := contivModel.FindExtContractsGroup(consExtContractsGrp)
430
- err = extContractsGrpDeregister(endpointGroup, contractsGrp, "consumed")
431
- if err != nil {
432
- return err
433
- }
434
- }
435
-
436
- // Cleanup provided external contracts
437
- for _, provExtContractsGrp := range endpointGroup.ProvExtContractsGrps {
438
- contractsGrp := contivModel.FindExtContractsGroup(provExtContractsGrp)
439
- err = extContractsGrpDeregister(endpointGroup, contractsGrp, "provided")
440
- if err != nil {
441
- return err
442
- }
443
- }
444
-
445
- return nil
446
- }
447
-
448
- func setupExternalContracts(endpointGroup *contivModel.EndpointGroup, consContractsGrps, provContractsGrps string[]) error {
449
- // Validate presence and register consumed external contracts
450
- for _, consExtContractsGrp := range consContractsGrps {
451
- contractsGrp := contivModel.FindExtContractsGroup(consExtContractsGrp)
452
- err = extContractsGrpValidateAndRegister(endpointGroup, contractsGrp, "consumed")
453
- if err != nil {
454
- return err
455
- }
456
- }
457
-
458
- // Validate presence and register provided external contracts
459
- for _, provExtContractsGrp := range provContractsGrps {
460
- contractsGrp := contivModel.FindExtContractsGroup(provExtContractsGrp)
461
- err = extContractsGrpValidateAndRegister(endpointGroup, contractsGrp, "provided")
462
- if err != nil {
463
- return err
464
- }
465
- }
466
-
467
- return nil
468
- }
469
- */
470
369
// EndpointGroupCreate creates end point group
471
370
func (ac * APIController ) EndpointGroupCreate (endpointGroup * contivModel.EndpointGroup ) error {
472
371
log .Infof ("Received EndpointGroupCreate: %+v" , endpointGroup )
0 commit comments