@@ -240,6 +240,7 @@ type Network struct {
240
240
type NetworkLinkSets struct {
241
241
AppProfiles map [string ]Link `json:"AppProfiles,omitempty"`
242
242
EndpointGroups map [string ]Link `json:"EndpointGroups,omitempty"`
243
+ Servicelbs map [string ]Link `json:"Servicelbs,omitempty"`
243
244
Services map [string ]Link `json:"Services,omitempty"`
244
245
}
245
246
@@ -351,6 +352,25 @@ type ServiceInstanceLinks struct {
351
352
Service Link `json:"Service,omitempty"`
352
353
}
353
354
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
+
354
374
type Tenant struct {
355
375
// every object has a key
356
376
Key string `json:"key,omitempty"`
@@ -367,6 +387,7 @@ type TenantLinkSets struct {
367
387
EndpointGroups map [string ]Link `json:"EndpointGroups,omitempty"`
368
388
Networks map [string ]Link `json:"Networks,omitempty"`
369
389
Policies map [string ]Link `json:"Policies,omitempty"`
390
+ Servicelbs map [string ]Link `json:"Servicelbs,omitempty"`
370
391
VolumeProfiles map [string ]Link `json:"VolumeProfiles,omitempty"`
371
392
Volumes map [string ]Link `json:"Volumes,omitempty"`
372
393
}
@@ -1004,6 +1025,71 @@ func (c *ContivClient) ServiceInstanceDelete(tenantName string, appName string,
1004
1025
return nil
1005
1026
}
1006
1027
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
+
1007
1093
// TenantPost posts the tenant object
1008
1094
func (c * ContivClient ) TenantPost (obj * Tenant ) error {
1009
1095
// build key and URL
0 commit comments