Skip to content

Commit

Permalink
add network oper proerties
Browse files Browse the repository at this point in the history
  • Loading branch information
Vipin Jain committed Jun 9, 2016
1 parent 0a63e9c commit 38fd643
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 115 deletions.
13 changes: 13 additions & 0 deletions client/contivModelClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,21 @@ type NetworkLinks struct {
Tenant Link `json:"Tenant,omitempty"`
}

type NetworkOper struct {
AllocatedAddressesCount int `json:"allocatedAddressesCount,omitempty"` // Vlan/Vxlan Tag
AllocatedIPAddresses string `json:"allocatedIPAddresses,omitempty"` // allocated IP addresses
DnsServerIP string `json:"dnsServerIP,omitempty"` // dns IP for the network
ExternalPktTag int `json:"externalPktTag,omitempty"` // external packet tag
NumEndpoints int `json:"numEndpoints,omitempty"` // external packet tag
PktTag int `json:"pktTag,omitempty"` // internal packet tag

OperLinks NetworkLinks `json:"links,omitempty"`
}

type NetworkInspect struct {
Config Network

Oper NetworkOper
}

type Policy struct {
Expand Down
147 changes: 32 additions & 115 deletions contivModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,21 @@ type NetworkLinks struct {
Tenant modeldb.Link `json:"Tenant,omitempty"`
}

type NetworkOper struct {
AllocatedAddressesCount int `json:"allocatedAddressesCount,omitempty"` // Vlan/Vxlan Tag
AllocatedIPAddresses string `json:"allocatedIPAddresses,omitempty"` // allocated IP addresses
DnsServerIP string `json:"dnsServerIP,omitempty"` // dns IP for the network
ExternalPktTag int `json:"externalPktTag,omitempty"` // external packet tag
NumEndpoints int `json:"numEndpoints,omitempty"` // external packet tag
PktTag int `json:"pktTag,omitempty"` // internal packet tag

OperLinks NetworkLinks `json:"links,omitempty"`
}

type NetworkInspect struct {
Config Network

Oper NetworkOper
}
type Policy struct {
// every object has a key
Expand Down Expand Up @@ -361,6 +374,8 @@ type GlobalCallbacks interface {
}

type NetworkCallbacks interface {
NetworkGetOper(network *NetworkInspect) error

NetworkCreate(network *Network) error
NetworkUpdate(network, params *Network) error
NetworkDelete(network *Network) error
Expand Down Expand Up @@ -726,17 +741,6 @@ func httpInspectAppProfile(w http.ResponseWriter, r *http.Request, vars map[stri
return &obj, nil
}

// Get a appProfileOper object
func GetOperAppProfile(key string) error {
obj := collections.appProfiles[key]
if obj == nil {
log.Errorf("appProfile %s not found", key)
return errors.New("appProfile not found")
}

return nil
}

// CREATE REST call
func httpCreateAppProfile(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpGetAppProfile: %+v", vars)
Expand Down Expand Up @@ -1012,17 +1016,6 @@ func httpInspectBgp(w http.ResponseWriter, r *http.Request, vars map[string]stri
return &obj, nil
}

// Get a BgpOper object
func GetOperBgp(key string) error {
obj := collections.Bgps[key]
if obj == nil {
log.Errorf("Bgp %s not found", key)
return errors.New("Bgp not found")
}

return nil
}

// CREATE REST call
func httpCreateBgp(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpGetBgp: %+v", vars)
Expand Down Expand Up @@ -1315,17 +1308,6 @@ func httpInspectEndpointGroup(w http.ResponseWriter, r *http.Request, vars map[s
return &obj, nil
}

// Get a endpointGroupOper object
func GetOperEndpointGroup(key string) error {
obj := collections.endpointGroups[key]
if obj == nil {
log.Errorf("endpointGroup %s not found", key)
return errors.New("endpointGroup not found")
}

return nil
}

// CREATE REST call
func httpCreateEndpointGroup(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpGetEndpointGroup: %+v", vars)
Expand Down Expand Up @@ -1867,17 +1849,6 @@ func httpInspectGlobal(w http.ResponseWriter, r *http.Request, vars map[string]s
return &obj, nil
}

// Get a globalOper object
func GetOperGlobal(key string) error {
obj := collections.globals[key]
if obj == nil {
log.Errorf("global %s not found", key)
return errors.New("global not found")
}

return nil
}

// CREATE REST call
func httpCreateGlobal(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpGetGlobal: %+v", vars)
Expand Down Expand Up @@ -2159,16 +2130,28 @@ func httpInspectNetwork(w http.ResponseWriter, r *http.Request, vars map[string]
}
obj.Config = *objConfig

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

// Return the obj
return &obj, nil
}

// Get a networkOper object
func GetOperNetwork(key string) error {
obj := collections.networks[key]
if obj == nil {
log.Errorf("network %s not found", key)
return errors.New("network not found")
func GetOperNetwork(obj *NetworkInspect) error {
// Check if we handle this object
if objCallbackHandler.NetworkCb == nil {
log.Errorf("No callback registered for network object")
return errors.New("Invalid object type")
}

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

return nil
Expand Down Expand Up @@ -2487,17 +2470,6 @@ func httpInspectPolicy(w http.ResponseWriter, r *http.Request, vars map[string]s
return &obj, nil
}

// Get a policyOper object
func GetOperPolicy(key string) error {
obj := collections.policys[key]
if obj == nil {
log.Errorf("policy %s not found", key)
return errors.New("policy not found")
}

return nil
}

// CREATE REST call
func httpCreatePolicy(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpGetPolicy: %+v", vars)
Expand Down Expand Up @@ -2773,17 +2745,6 @@ func httpInspectRule(w http.ResponseWriter, r *http.Request, vars map[string]str
return &obj, nil
}

// Get a ruleOper object
func GetOperRule(key string) error {
obj := collections.rules[key]
if obj == nil {
log.Errorf("rule %s not found", key)
return errors.New("rule not found")
}

return nil
}

// CREATE REST call
func httpCreateRule(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpGetRule: %+v", vars)
Expand Down Expand Up @@ -3145,17 +3106,6 @@ func httpInspectServiceLB(w http.ResponseWriter, r *http.Request, vars map[strin
return &obj, nil
}

// Get a serviceLBOper object
func GetOperServiceLB(key string) error {
obj := collections.serviceLBs[key]
if obj == nil {
log.Errorf("serviceLB %s not found", key)
return errors.New("serviceLB not found")
}

return nil
}

// CREATE REST call
func httpCreateServiceLB(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpGetServiceLB: %+v", vars)
Expand Down Expand Up @@ -3449,17 +3399,6 @@ func httpInspectTenant(w http.ResponseWriter, r *http.Request, vars map[string]s
return &obj, nil
}

// Get a tenantOper object
func GetOperTenant(key string) error {
obj := collections.tenants[key]
if obj == nil {
log.Errorf("tenant %s not found", key)
return errors.New("tenant not found")
}

return nil
}

// CREATE REST call
func httpCreateTenant(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpGetTenant: %+v", vars)
Expand Down Expand Up @@ -3735,17 +3674,6 @@ func httpInspectVolume(w http.ResponseWriter, r *http.Request, vars map[string]s
return &obj, nil
}

// Get a volumeOper object
func GetOperVolume(key string) error {
obj := collections.volumes[key]
if obj == nil {
log.Errorf("volume %s not found", key)
return errors.New("volume not found")
}

return nil
}

// CREATE REST call
func httpCreateVolume(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpGetVolume: %+v", vars)
Expand Down Expand Up @@ -4003,17 +3931,6 @@ func httpInspectVolumeProfile(w http.ResponseWriter, r *http.Request, vars map[s
return &obj, nil
}

// Get a volumeProfileOper object
func GetOperVolumeProfile(key string) error {
obj := collections.volumeProfiles[key]
if obj == nil {
log.Errorf("volumeProfile %s not found", key)
return errors.New("volumeProfile not found")
}

return nil
}

// CREATE REST call
func httpCreateVolumeProfile(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
log.Debugf("Received httpGetVolumeProfile: %+v", vars)
Expand Down
26 changes: 26 additions & 0 deletions network.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,32 @@
"showSummary": true
}
},
"operProperties": {
"pktTag": {
"type": "int",
"title": "internal packet tag"
},
"externalPktTag": {
"type": "int",
"title": "external packet tag"
},
"numEndpoints": {
"type": "int",
"title": "external packet tag"
},
"allocatedAddressesCount": {
"type": "int",
"title": "Vlan/Vxlan Tag"
},
"allocatedIPAddresses": {
"type": "string",
"title": "allocated IP addresses"
},
"dnsServerIP": {
"type": "string",
"title": "dns IP for the network"
}
},
"link-sets": {
"services": {
"ref": "service"
Expand Down

0 comments on commit 38fd643

Please sign in to comment.