Skip to content

Commit

Permalink
Adding inspect support for endpointGroup (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav-dalvi authored and shaleman committed Aug 1, 2016
1 parent 731af51 commit 185e865
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/contivModelClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,18 @@ type EndpointGroupLinks struct {
Tenant Link `json:"Tenant,omitempty"`
}

type EndpointGroupOper struct {
Endpoints []EndpointOper `json:"endpoints,omitempty"`
ExternalPktTag int `json:"externalPktTag,omitempty"` // external packet tag
NumEndpoints int `json:"numEndpoints,omitempty"` // external packet tag
PktTag int `json:"pktTag,omitempty"` // internal packet tag

}

type EndpointGroupInspect struct {
Config EndpointGroup

Oper EndpointGroupOper
}

type ExtContractsGroup struct {
Expand Down
10 changes: 10 additions & 0 deletions client/contivModelClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ def listEndpointGroup(self):



# Inspect endpointGroup
def createEndpointGroup(self, obj):
postUrl = self.baseUrl + '/api/v1/inspect/endpointGroup/' + obj.tenantName + ":" + obj.groupName + '/'

retDate = urllib2.urlopen(postUrl)
if retData == "Error":
errorExit("list EndpointGroup failed")

return json.loads(retData)


# Create extContractsGroup
def createExtContractsGroup(self, obj):
Expand Down
35 changes: 35 additions & 0 deletions contivModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,18 @@ type EndpointGroupLinks struct {
Tenant modeldb.Link `json:"Tenant,omitempty"`
}

type EndpointGroupOper struct {
Endpoints []EndpointOper `json:"endpoints,omitempty"`
ExternalPktTag int `json:"externalPktTag,omitempty"` // external packet tag
NumEndpoints int `json:"numEndpoints,omitempty"` // external packet tag
PktTag int `json:"pktTag,omitempty"` // internal packet tag

}

type EndpointGroupInspect struct {
Config EndpointGroup

Oper EndpointGroupOper
}

type ExtContractsGroup struct {
Expand Down Expand Up @@ -441,6 +451,8 @@ type EndpointCallbacks interface {
}

type EndpointGroupCallbacks interface {
EndpointGroupGetOper(endpointGroup *EndpointGroupInspect) error

EndpointGroupCreate(endpointGroup *EndpointGroup) error
EndpointGroupUpdate(endpointGroup, params *EndpointGroup) error
EndpointGroupDelete(endpointGroup *EndpointGroup) error
Expand Down Expand Up @@ -1448,10 +1460,33 @@ func httpInspectEndpointGroup(w http.ResponseWriter, r *http.Request, vars map[s
}
obj.Config = *objConfig

if err := GetOperEndpointGroup(&obj); err != nil {
log.Errorf("GetEndpointGroup error for: %+v. Err: %v", obj, err)
return nil, err
}

// Return the obj
return &obj, nil
}

// Get a endpointGroupOper object
func GetOperEndpointGroup(obj *EndpointGroupInspect) error {
// Check if we handle this object
if objCallbackHandler.EndpointGroupCb == nil {
log.Errorf("No callback registered for endpointGroup object")
return errors.New("Invalid object type")
}

// Perform callback
err := objCallbackHandler.EndpointGroupCb.EndpointGroupGetOper(obj)
if err != nil {
log.Errorf("EndpointGroupDelete retruned error for: %+v. Err: %v", obj, err)
return err
}

return nil
}

// LIST REST call
func httpListEndpointGroups(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpListEndpointGroups: %+v", vars)
Expand Down
19 changes: 19 additions & 0 deletions endpointGroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@
"ShowSummary": true
}
},
"operProperties": {
"pktTag": {
"type": "int",
"title": "internal packet tag"
},
"externalPktTag": {
"type": "int",
"title": "external packet tag"
},
"numEndpoints": {
"type": "int",
"title": "external packet tag"
},
"endpoints": {
"type": "array",
"items": "endpoint",
"title": "endpoints in the group"
}
},
"link-sets": {
"services": {
"ref": "service"
Expand Down

0 comments on commit 185e865

Please sign in to comment.