Skip to content

Commit 9c6f550

Browse files
gaurav-dalvishaleman
authored andcommitted
Fixing Issue#360 (#363)
1 parent 34d2171 commit 9c6f550

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

netmaster/objApi/apiController.go

+22-22
Original file line numberDiff line numberDiff line change
@@ -364,18 +364,8 @@ func (ac *APIController) EndpointGroupCreate(endpointGroup *contivModel.Endpoint
364364
return core.Errorf("Tenant not found")
365365
}
366366

367-
// Setup links
368-
modeldb.AddLink(&endpointGroup.Links.Tenant, tenant)
369-
modeldb.AddLinkSet(&tenant.LinkSets.EndpointGroups, endpointGroup)
370-
371-
// Save the tenant too since we added the links
372-
err := tenant.Write()
373-
if err != nil {
374-
return err
375-
}
376-
377367
// create the endpoint group state
378-
err = master.CreateEndpointGroup(endpointGroup.TenantName, endpointGroup.NetworkName,
368+
err := master.CreateEndpointGroup(endpointGroup.TenantName, endpointGroup.NetworkName,
379369
endpointGroup.GroupName, endpointGroup.EndpointGroupID)
380370
if err != nil {
381371
log.Errorf("Error creating endpoing group %+v. Err: %v", endpointGroup, err)
@@ -410,6 +400,16 @@ func (ac *APIController) EndpointGroupCreate(endpointGroup *contivModel.Endpoint
410400
}
411401
}
412402

403+
// Setup links
404+
modeldb.AddLink(&endpointGroup.Links.Tenant, tenant)
405+
modeldb.AddLinkSet(&tenant.LinkSets.EndpointGroups, endpointGroup)
406+
407+
// Save the tenant too since we added the links
408+
err = tenant.Write()
409+
if err != nil {
410+
return err
411+
}
412+
413413
return nil
414414
}
415415

@@ -550,17 +550,6 @@ func (ac *APIController) NetworkCreate(network *contivModel.Network) error {
550550
return core.Errorf("Tenant not found")
551551
}
552552

553-
// Setup links
554-
modeldb.AddLink(&network.Links.Tenant, tenant)
555-
modeldb.AddLinkSet(&tenant.LinkSets.Networks, network)
556-
557-
// Save the tenant too since we added the links
558-
err := tenant.Write()
559-
if err != nil {
560-
log.Errorf("Error updating tenant state(%+v). Err: %v", tenant, err)
561-
return err
562-
}
563-
564553
// Get the state driver
565554
stateDriver, err := utils.GetStateDriver()
566555
if err != nil {
@@ -584,6 +573,17 @@ func (ac *APIController) NetworkCreate(network *contivModel.Network) error {
584573
return err
585574
}
586575

576+
// Setup links
577+
modeldb.AddLink(&network.Links.Tenant, tenant)
578+
modeldb.AddLinkSet(&tenant.LinkSets.Networks, network)
579+
580+
// Save the tenant too since we added the links
581+
err = tenant.Write()
582+
if err != nil {
583+
log.Errorf("Error updating tenant state(%+v). Err: %v", tenant, err)
584+
return err
585+
}
586+
587587
return nil
588588
}
589589

0 commit comments

Comments
 (0)