Skip to content

Commit de250b0

Browse files
abhishaleman
authored andcommitted
Oper state changes for service lb (#28)
* fixing minor issues * avoid generating operlinks * support for oper only objects * service lb oper state * updating changes
1 parent db845cd commit de250b0

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

client/contivModelClient.go

+9
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,17 @@ type ServiceLBLinks struct {
407407
Tenant Link `json:"Tenant,omitempty"`
408408
}
409409

410+
type ServiceLBOper struct {
411+
NumProviders int `json:"numProviders,omitempty"` // number of provider endpoints for the service
412+
Providers []EndpointOper `json:"providers,omitempty"`
413+
ServiceVip string `json:"serviceVip,omitempty"` // allocated IP addresses
414+
415+
}
416+
410417
type ServiceLBInspect struct {
411418
Config ServiceLB
419+
420+
Oper ServiceLBOper
412421
}
413422

414423
type Tenant struct {

client/contivModelClient.py

+10
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,16 @@ def listServiceLB(self):
463463

464464

465465

466+
# Inspect serviceLB
467+
def createServiceLB(self, obj):
468+
postUrl = self.baseUrl + '/api/v1/inspect/serviceLB/' + obj.tenantName + ":" + obj.serviceName + '/'
469+
470+
retDate = urllib2.urlopen(postUrl)
471+
if retData == "Error":
472+
errorExit("list ServiceLB failed")
473+
474+
return json.loads(retData)
475+
466476

467477
# Create tenant
468478
def createTenant(self, obj):

contivModel.go

+34
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,17 @@ type ServiceLBLinks struct {
281281
Tenant modeldb.Link `json:"Tenant,omitempty"`
282282
}
283283

284+
type ServiceLBOper struct {
285+
NumProviders int `json:"numProviders,omitempty"` // number of provider endpoints for the service
286+
Providers []EndpointOper `json:"providers,omitempty"`
287+
ServiceVip string `json:"serviceVip,omitempty"` // allocated IP addresses
288+
289+
}
290+
284291
type ServiceLBInspect struct {
285292
Config ServiceLB
293+
294+
Oper ServiceLBOper
286295
}
287296

288297
type Tenant struct {
@@ -440,6 +449,8 @@ type RuleCallbacks interface {
440449
}
441450

442451
type ServiceLBCallbacks interface {
452+
ServiceLBGetOper(serviceLB *ServiceLBInspect) error
453+
443454
ServiceLBCreate(serviceLB *ServiceLB) error
444455
ServiceLBUpdate(serviceLB, params *ServiceLB) error
445456
ServiceLBDelete(serviceLB *ServiceLB) error
@@ -3218,10 +3229,33 @@ func httpInspectServiceLB(w http.ResponseWriter, r *http.Request, vars map[strin
32183229
}
32193230
obj.Config = *objConfig
32203231

3232+
if err := GetOperServiceLB(&obj); err != nil {
3233+
log.Errorf("GetServiceLB error for: %+v. Err: %v", obj, err)
3234+
return nil, err
3235+
}
3236+
32213237
// Return the obj
32223238
return &obj, nil
32233239
}
32243240

3241+
// Get a serviceLBOper object
3242+
func GetOperServiceLB(obj *ServiceLBInspect) error {
3243+
// Check if we handle this object
3244+
if objCallbackHandler.ServiceLBCb == nil {
3245+
log.Errorf("No callback registered for serviceLB object")
3246+
return errors.New("Invalid object type")
3247+
}
3248+
3249+
// Perform callback
3250+
err := objCallbackHandler.ServiceLBCb.ServiceLBGetOper(obj)
3251+
if err != nil {
3252+
log.Errorf("ServiceLBDelete retruned error for: %+v. Err: %v", obj, err)
3253+
return err
3254+
}
3255+
3256+
return nil
3257+
}
3258+
32253259
// LIST REST call
32263260
func httpListServiceLBs(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
32273261
log.Debugf("Received httpListServiceLBs: %+v", vars)

servicelb.json

+15
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@
4343
"items" : "string"
4444
}
4545
},
46+
"operProperties": {
47+
"serviceVip": {
48+
"type": "string",
49+
"title": "allocated IP addresses"
50+
},
51+
"numProviders": {
52+
"type": "int",
53+
"title": " number of provider endpoints for the service"
54+
},
55+
"providers": {
56+
"type": "array",
57+
"items": "endpoint",
58+
"title": "provider endpoints for the service"
59+
}
60+
},
4661
"links": {
4762
"tenant": {
4863
"ref": "tenant"

0 commit comments

Comments
 (0)