Skip to content

Commit 118772e

Browse files
abhishaleman
authored andcommitted
Service load balancer contivmodel changes (#19)
* service load balancer service load balance service load balancer * modelgen update * service load balancer * service load balancer
1 parent b1378f4 commit 118772e

7 files changed

+548
-2
lines changed

client/contivModel.js

+65
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,71 @@ var ServiceInstanceModalView = React.createClass({
686686

687687
module.exports.ServiceInstanceSummaryView = ServiceInstanceSummaryView
688688
module.exports.ServiceInstanceModalView = ServiceInstanceModalView
689+
var ServiceLBSummaryView = React.createClass({
690+
render: function() {
691+
var self = this
692+
693+
// Walk thru all objects
694+
var serviceLBListView = self.props.serviceLBs.map(function(serviceLB){
695+
return (
696+
<ModalTrigger modal={<ServiceLBModalView serviceLB={ serviceLB }/>}>
697+
<tr key={ serviceLB.key } className="info">
698+
699+
700+
</tr>
701+
</ModalTrigger>
702+
);
703+
});
704+
705+
return (
706+
<div>
707+
<Table hover>
708+
<thead>
709+
<tr>
710+
711+
712+
</tr>
713+
</thead>
714+
<tbody>
715+
{ serviceLBListView }
716+
</tbody>
717+
</Table>
718+
</div>
719+
);
720+
}
721+
});
722+
723+
var ServiceLBModalView = React.createClass({
724+
render() {
725+
var obj = this.props.serviceLB
726+
return (
727+
<Modal {...this.props} bsStyle='primary' bsSize='large' title='ServiceLB' animation={false}>
728+
<div className='modal-body' style={ {margin: '5%',} }>
729+
730+
731+
<Input type='text' label='Service ip' ref='ipAddress' defaultValue={obj.ipAddress} placeholder='Service ip' />
732+
733+
<Input type='text' label='Service network name' ref='network' defaultValue={obj.network} placeholder='Service network name' />
734+
735+
<Input type='text' label='service provider port' ref='ports' defaultValue={obj.ports} placeholder='service provider port' />
736+
737+
<Input type='text' label='labels key value pair' ref='selectors' defaultValue={obj.selectors} placeholder='labels key value pair' />
738+
739+
<Input type='text' label='service name' ref='serviceName' defaultValue={obj.serviceName} placeholder='service name' />
740+
741+
<Input type='text' label='Tenant Name' ref='tenantName' defaultValue={obj.tenantName} placeholder='Tenant Name' />
742+
743+
</div>
744+
<div className='modal-footer'>
745+
<Button onClick={this.props.onRequestHide}>Close</Button>
746+
</div>
747+
</Modal>
748+
);
749+
}
750+
});
751+
752+
module.exports.ServiceLBSummaryView = ServiceLBSummaryView
753+
module.exports.ServiceLBModalView = ServiceLBModalView
689754
var TenantSummaryView = React.createClass({
690755
render: function() {
691756
var self = this

client/contivModelClient.go

+86
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ type Network struct {
240240
type NetworkLinkSets struct {
241241
AppProfiles map[string]Link `json:"AppProfiles,omitempty"`
242242
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
243+
Servicelbs map[string]Link `json:"Servicelbs,omitempty"`
243244
Services map[string]Link `json:"Services,omitempty"`
244245
}
245246

@@ -351,6 +352,25 @@ type ServiceInstanceLinks struct {
351352
Service Link `json:"Service,omitempty"`
352353
}
353354

355+
type ServiceLB struct {
356+
// every object has a key
357+
Key string `json:"key,omitempty"`
358+
359+
IpAddress string `json:"ipAddress,omitempty"` // Service ip
360+
Network string `json:"network,omitempty"` // Service network name
361+
Ports []string `json:"ports,omitempty"`
362+
Selectors []string `json:"selectors,omitempty"`
363+
ServiceName string `json:"serviceName,omitempty"` // service name
364+
TenantName string `json:"tenantName,omitempty"` // Tenant Name
365+
366+
Links ServiceLBLinks `json:"links,omitempty"`
367+
}
368+
369+
type ServiceLBLinks struct {
370+
Network Link `json:"Network,omitempty"`
371+
Tenant Link `json:"Tenant,omitempty"`
372+
}
373+
354374
type Tenant struct {
355375
// every object has a key
356376
Key string `json:"key,omitempty"`
@@ -367,6 +387,7 @@ type TenantLinkSets struct {
367387
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
368388
Networks map[string]Link `json:"Networks,omitempty"`
369389
Policies map[string]Link `json:"Policies,omitempty"`
390+
Servicelbs map[string]Link `json:"Servicelbs,omitempty"`
370391
VolumeProfiles map[string]Link `json:"VolumeProfiles,omitempty"`
371392
Volumes map[string]Link `json:"Volumes,omitempty"`
372393
}
@@ -1004,6 +1025,71 @@ func (c *ContivClient) ServiceInstanceDelete(tenantName string, appName string,
10041025
return nil
10051026
}
10061027

1028+
// ServiceLBPost posts the serviceLB object
1029+
func (c *ContivClient) ServiceLBPost(obj *ServiceLB) error {
1030+
// build key and URL
1031+
keyStr := obj.ServiceName + ":" + obj.TenantName
1032+
url := c.baseURL + "/api/serviceLBs/" + keyStr + "/"
1033+
1034+
// http post the object
1035+
err := httpPost(url, obj)
1036+
if err != nil {
1037+
log.Debugf("Error creating serviceLB %+v. Err: %v", obj, err)
1038+
return err
1039+
}
1040+
1041+
return nil
1042+
}
1043+
1044+
// ServiceLBList lists all serviceLB objects
1045+
func (c *ContivClient) ServiceLBList() (*[]*ServiceLB, error) {
1046+
// build key and URL
1047+
url := c.baseURL + "/api/serviceLBs/"
1048+
1049+
// http get the object
1050+
var objList []*ServiceLB
1051+
err := httpGet(url, &objList)
1052+
if err != nil {
1053+
log.Debugf("Error getting serviceLBs. Err: %v", err)
1054+
return nil, err
1055+
}
1056+
1057+
return &objList, nil
1058+
}
1059+
1060+
// ServiceLBGet gets the serviceLB object
1061+
func (c *ContivClient) ServiceLBGet(serviceName string, tenantName string) (*ServiceLB, error) {
1062+
// build key and URL
1063+
keyStr := serviceName + ":" + tenantName
1064+
url := c.baseURL + "/api/serviceLBs/" + keyStr + "/"
1065+
1066+
// http get the object
1067+
var obj ServiceLB
1068+
err := httpGet(url, &obj)
1069+
if err != nil {
1070+
log.Debugf("Error getting serviceLB %+v. Err: %v", keyStr, err)
1071+
return nil, err
1072+
}
1073+
1074+
return &obj, nil
1075+
}
1076+
1077+
// ServiceLBDelete deletes the serviceLB object
1078+
func (c *ContivClient) ServiceLBDelete(serviceName string, tenantName string) error {
1079+
// build key and URL
1080+
keyStr := serviceName + ":" + tenantName
1081+
url := c.baseURL + "/api/serviceLBs/" + keyStr + "/"
1082+
1083+
// http get the object
1084+
err := httpDelete(url)
1085+
if err != nil {
1086+
log.Debugf("Error deleting serviceLB %s. Err: %v", keyStr, err)
1087+
return err
1088+
}
1089+
1090+
return nil
1091+
}
1092+
10071093
// TenantPost posts the tenant object
10081094
func (c *ContivClient) TenantPost(obj *Tenant) error {
10091095
// build key and URL

client/contivModelClient.py

+37
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ def createNetwork(self, obj):
220220
"ipv6Gateway": obj.ipv6Gateway,
221221
"ipv6Subnet": obj.ipv6Subnet,
222222
"networkName": obj.networkName,
223+
"nwType": obj.nwType,
223224
"pktTag": obj.pktTag,
224225
"subnet": obj.subnet,
225226
"tenantName": obj.tenantName,
@@ -400,6 +401,42 @@ def listServiceInstance(self):
400401
if retData == "Error":
401402
errorExit("list ServiceInstance failed")
402403

404+
return json.loads(retData)
405+
# Create serviceLB
406+
def createServiceLB(self, obj):
407+
postUrl = self.baseUrl + '/api/serviceLBs/' + obj.serviceName + ":" + obj.tenantName + '/'
408+
409+
jdata = json.dumps({
410+
"ipAddress": obj.ipAddress,
411+
"network": obj.network,
412+
"ports": obj.ports,
413+
"selectors": obj.selectors,
414+
"serviceName": obj.serviceName,
415+
"tenantName": obj.tenantName,
416+
})
417+
418+
# Post the data
419+
response = httpPost(postUrl, jdata)
420+
421+
if response == "Error":
422+
errorExit("ServiceLB create failure")
423+
424+
# Delete serviceLB
425+
def deleteServiceLB(self, serviceName, tenantName):
426+
# Delete ServiceLB
427+
deleteUrl = self.baseUrl + '/api/serviceLBs/' + serviceName + ":" + tenantName + '/'
428+
response = httpDelete(deleteUrl)
429+
430+
if response == "Error":
431+
errorExit("ServiceLB create failure")
432+
433+
# List all serviceLB objects
434+
def listServiceLB(self):
435+
# Get a list of serviceLB objects
436+
retDate = urllib2.urlopen(self.baseUrl + '/api/serviceLBs/')
437+
if retData == "Error":
438+
errorExit("list ServiceLB failed")
439+
403440
return json.loads(retData)
404441
# Create tenant
405442
def createTenant(self, obj):

0 commit comments

Comments
 (0)