Skip to content
This repository was archived by the owner on Nov 29, 2017. It is now read-only.

Commit 9cd997d

Browse files
committed
service load balance
1 parent 026e161 commit 9cd997d

File tree

2 files changed

+36
-39
lines changed

2 files changed

+36
-39
lines changed

client/contivModelClient.go

+35-39
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ import (
1111
"io/ioutil"
1212
"net/http"
1313

14+
"github.com/contiv/objdb/modeldb"
15+
1416
log "github.com/Sirupsen/logrus"
1517
)
1618

17-
// Link is a one way relattion between two objects
18-
type Link struct {
19-
ObjType string `json:"type,omitempty"`
20-
ObjKey string `json:"key,omitempty"`
21-
}
22-
2319
func httpGet(url string, jdata interface{}) error {
2420

2521
r, err := http.Get(url)
@@ -161,12 +157,12 @@ type AppProfile struct {
161157
}
162158

163159
type AppProfileLinkSets struct {
164-
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
160+
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
165161
}
166162

167163
type AppProfileLinks struct {
168-
Network Link `json:"Network,omitempty"`
169-
Tenant Link `json:"Tenant,omitempty"`
164+
Network modeldb.Link `json:"Network,omitempty"`
165+
Tenant modeldb.Link `json:"Tenant,omitempty"`
170166
}
171167

172168
type EndpointGroup struct {
@@ -185,14 +181,14 @@ type EndpointGroup struct {
185181
}
186182

187183
type EndpointGroupLinkSets struct {
188-
Policies map[string]Link `json:"Policies,omitempty"`
189-
Services map[string]Link `json:"Services,omitempty"`
184+
Policies map[string]modeldb.Link `json:"Policies,omitempty"`
185+
Services map[string]modeldb.Link `json:"Services,omitempty"`
190186
}
191187

192188
type EndpointGroupLinks struct {
193-
AppProfile Link `json:"AppProfile,omitempty"`
194-
Network Link `json:"Network,omitempty"`
195-
Tenant Link `json:"Tenant,omitempty"`
189+
AppProfile modeldb.Link `json:"AppProfile,omitempty"`
190+
Network modeldb.Link `json:"Network,omitempty"`
191+
Tenant modeldb.Link `json:"Tenant,omitempty"`
196192
}
197193

198194
type Global struct {
@@ -236,13 +232,13 @@ type Network struct {
236232
}
237233

238234
type NetworkLinkSets struct {
239-
AppProfiles map[string]Link `json:"AppProfiles,omitempty"`
240-
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
241-
Services map[string]Link `json:"Services,omitempty"`
235+
AppProfiles map[string]modeldb.Link `json:"AppProfiles,omitempty"`
236+
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
237+
Services map[string]modeldb.Link `json:"Services,omitempty"`
242238
}
243239

244240
type NetworkLinks struct {
245-
Tenant Link `json:"Tenant,omitempty"`
241+
Tenant modeldb.Link `json:"Tenant,omitempty"`
246242
}
247243

248244
type Policy struct {
@@ -258,12 +254,12 @@ type Policy struct {
258254
}
259255

260256
type PolicyLinkSets struct {
261-
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
262-
Rules map[string]Link `json:"Rules,omitempty"`
257+
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
258+
Rules map[string]modeldb.Link `json:"Rules,omitempty"`
263259
}
264260

265261
type PolicyLinks struct {
266-
Tenant Link `json:"Tenant,omitempty"`
262+
Tenant modeldb.Link `json:"Tenant,omitempty"`
267263
}
268264

269265
type Rule struct {
@@ -290,7 +286,7 @@ type Rule struct {
290286
}
291287

292288
type RuleLinkSets struct {
293-
Policies map[string]Link `json:"Policies,omitempty"`
289+
Policies map[string]modeldb.Link `json:"Policies,omitempty"`
294290
}
295291

296292
type Service struct {
@@ -316,14 +312,14 @@ type Service struct {
316312
}
317313

318314
type ServiceLinkSets struct {
319-
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
320-
Instances map[string]Link `json:"Instances,omitempty"`
321-
Networks map[string]Link `json:"Networks,omitempty"`
315+
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
316+
Instances map[string]modeldb.Link `json:"Instances,omitempty"`
317+
Networks map[string]modeldb.Link `json:"Networks,omitempty"`
322318
}
323319

324320
type ServiceLinks struct {
325-
App Link `json:"App,omitempty"`
326-
VolumeProfile Link `json:"VolumeProfile,omitempty"`
321+
App modeldb.Link `json:"App,omitempty"`
322+
VolumeProfile modeldb.Link `json:"VolumeProfile,omitempty"`
327323
}
328324

329325
type ServiceInstance struct {
@@ -342,11 +338,11 @@ type ServiceInstance struct {
342338
}
343339

344340
type ServiceInstanceLinkSets struct {
345-
Volumes map[string]Link `json:"Volumes,omitempty"`
341+
Volumes map[string]modeldb.Link `json:"Volumes,omitempty"`
346342
}
347343

348344
type ServiceInstanceLinks struct {
349-
Service Link `json:"Service,omitempty"`
345+
Service modeldb.Link `json:"Service,omitempty"`
350346
}
351347

352348
type ServiceLB struct {
@@ -374,12 +370,12 @@ type Tenant struct {
374370
}
375371

376372
type TenantLinkSets struct {
377-
AppProfiles map[string]Link `json:"AppProfiles,omitempty"`
378-
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
379-
Networks map[string]Link `json:"Networks,omitempty"`
380-
Policies map[string]Link `json:"Policies,omitempty"`
381-
VolumeProfiles map[string]Link `json:"VolumeProfiles,omitempty"`
382-
Volumes map[string]Link `json:"Volumes,omitempty"`
373+
AppProfiles map[string]modeldb.Link `json:"AppProfiles,omitempty"`
374+
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
375+
Networks map[string]modeldb.Link `json:"Networks,omitempty"`
376+
Policies map[string]modeldb.Link `json:"Policies,omitempty"`
377+
VolumeProfiles map[string]modeldb.Link `json:"VolumeProfiles,omitempty"`
378+
Volumes map[string]modeldb.Link `json:"Volumes,omitempty"`
383379
}
384380

385381
type Volume struct {
@@ -399,11 +395,11 @@ type Volume struct {
399395
}
400396

401397
type VolumeLinkSets struct {
402-
ServiceInstances map[string]Link `json:"ServiceInstances,omitempty"`
398+
ServiceInstances map[string]modeldb.Link `json:"ServiceInstances,omitempty"`
403399
}
404400

405401
type VolumeLinks struct {
406-
Tenant Link `json:"Tenant,omitempty"`
402+
Tenant modeldb.Link `json:"Tenant,omitempty"`
407403
}
408404

409405
type VolumeProfile struct {
@@ -423,11 +419,11 @@ type VolumeProfile struct {
423419
}
424420

425421
type VolumeProfileLinkSets struct {
426-
Services map[string]Link `json:"Services,omitempty"`
422+
Services map[string]modeldb.Link `json:"Services,omitempty"`
427423
}
428424

429425
type VolumeProfileLinks struct {
430-
Tenant Link `json:"Tenant,omitempty"`
426+
Tenant modeldb.Link `json:"Tenant,omitempty"`
431427
}
432428

433429
// AppProfilePost posts the appProfile object

client/contivModelClient.py

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def createNetwork(self, obj):
218218
"encap": obj.encap,
219219
"gateway": obj.gateway,
220220
"networkName": obj.networkName,
221+
"nwType": obj.nwType,
221222
"pktTag": obj.pktTag,
222223
"subnet": obj.subnet,
223224
"tenantName": obj.tenantName,

0 commit comments

Comments
 (0)