@@ -10,17 +10,18 @@ package vcdsdk
10
10
import (
11
11
"context"
12
12
"fmt"
13
+ "net/http"
14
+ "net/url"
15
+ "strconv"
16
+ "strings"
17
+
13
18
"github.com/antihax/optional"
14
19
"github.com/peterhellberg/link"
15
20
"github.com/vmware/cloud-provider-for-cloud-director/pkg/util"
16
21
swaggerClient "github.com/vmware/cloud-provider-for-cloud-director/pkg/vcdswaggerclient_36_0"
17
22
"github.com/vmware/go-vcloud-director/v2/govcd"
18
23
"github.com/vmware/go-vcloud-director/v2/types/v56"
19
24
"k8s.io/klog"
20
- "net/http"
21
- "net/url"
22
- "strconv"
23
- "strings"
24
25
)
25
26
26
27
type OneArm struct {
@@ -1104,7 +1105,7 @@ func (gatewayManager *GatewayManager) checkIfGatewayIsReady(ctx context.Context)
1104
1105
}
1105
1106
1106
1107
func (gatewayManager * GatewayManager ) UpdateVirtualService (ctx context.Context , virtualServiceName string ,
1107
- virtualServiceIP string , externalPort int32 , oneArmEnabled bool ) (* swaggerClient.EntityReference , error ) {
1108
+ virtualServiceIP string , externalPort int32 , oneArmEnabled bool , applicationProfile string ) (* swaggerClient.EntityReference , error ) {
1108
1109
client := gatewayManager .Client
1109
1110
vsSummary , err := gatewayManager .GetVirtualService (ctx , virtualServiceName )
1110
1111
if err != nil {
@@ -1147,6 +1148,12 @@ func (gatewayManager *GatewayManager) UpdateVirtualService(ctx context.Context,
1147
1148
// update the virtual IP address of the virtual service when one arm is nil
1148
1149
vs .VirtualIpAddress = virtualServiceIP
1149
1150
}
1151
+
1152
+ if applicationProfile != "" && vs .ApplicationProfile .Name != applicationProfile {
1153
+ vs .ApplicationProfile .Name = applicationProfile
1154
+ vs .ApplicationProfile .SystemDefined = false
1155
+ }
1156
+
1150
1157
resp , err := client .APIClient .EdgeGatewayLoadBalancerVirtualServiceApi .UpdateVirtualService (ctx , vs , vsSummary .Id , org .Org .ID )
1151
1158
if resp != nil && resp .StatusCode != http .StatusAccepted {
1152
1159
var responseMessageBytes []byte
@@ -1187,7 +1194,7 @@ func (gatewayManager *GatewayManager) UpdateVirtualService(ctx context.Context,
1187
1194
func (gatewayManager * GatewayManager ) CreateVirtualService (ctx context.Context , virtualServiceName string ,
1188
1195
lbPoolRef * swaggerClient.EntityReference , segRef * swaggerClient.EntityReference ,
1189
1196
freeIP string , vsType string , externalPort int32 ,
1190
- useSSL bool , certificateAlias string ) (* swaggerClient.EntityReference , error ) {
1197
+ useSSL bool , certificateAlias , applicationProfile string ) (* swaggerClient.EntityReference , error ) {
1191
1198
1192
1199
client := gatewayManager .Client
1193
1200
if gatewayManager .GatewayRef == nil {
@@ -1259,6 +1266,11 @@ func (gatewayManager *GatewayManager) CreateVirtualService(ctx context.Context,
1259
1266
return nil , fmt .Errorf ("unhandled virtual service type [%s]" , vsType )
1260
1267
}
1261
1268
1269
+ if applicationProfile != "" {
1270
+ virtualServiceConfig .ApplicationProfile .Name = applicationProfile
1271
+ virtualServiceConfig .ApplicationProfile .SystemDefined = false
1272
+ }
1273
+
1262
1274
clusterOrg , err := client .VCDClient .GetOrgByName (client .ClusterOrgName )
1263
1275
if err != nil {
1264
1276
return nil , fmt .Errorf ("unable to get org for org [%s]: [%v]" , client .ClusterOrgName , err )
@@ -1502,7 +1514,7 @@ func (gatewayManager *GatewayManager) GetLoadBalancerPoolMemberIPs(ctx context.C
1502
1514
1503
1515
func (gm * GatewayManager ) CreateLoadBalancer (ctx context.Context , virtualServiceNamePrefix string , lbPoolNamePrefix string ,
1504
1516
ips []string , portDetailsList []PortDetails , oneArm * OneArm , enableVirtualServiceSharedIP bool ,
1505
- portNameToIP map [string ]string , providedIP string , resourcesAllocated * util.AllocatedResourcesMap ) (string , error ) {
1517
+ portNameToIP map [string ]string , providedIP string , resourcesAllocated * util.AllocatedResourcesMap , applicationProfile string ) (string , error ) {
1506
1518
if len (portDetailsList ) == 0 {
1507
1519
// nothing to do here
1508
1520
klog .Infof ("There is no port specified. Hence nothing to do." )
@@ -1707,7 +1719,7 @@ func (gm *GatewayManager) CreateLoadBalancer(ctx context.Context, virtualService
1707
1719
1708
1720
virtualServiceRef , err := gm .CreateVirtualService (ctx , virtualServiceName , lbPoolRef , segRef ,
1709
1721
virtualServiceIP , portDetails .Protocol , portDetails .ExternalPort ,
1710
- portDetails .UseSSL , portDetails .CertAlias )
1722
+ portDetails .UseSSL , portDetails .CertAlias , applicationProfile )
1711
1723
if err != nil {
1712
1724
// return plain error if vcdsdk.VirtualServicePendingError is returned. Helps the caller recognize that the
1713
1725
// error is because VirtualService is still in Pending state.
@@ -1833,7 +1845,7 @@ func (gm *GatewayManager) DeleteLoadBalancer(ctx context.Context, virtualService
1833
1845
1834
1846
func (gm * GatewayManager ) UpdateLoadBalancer (ctx context.Context , lbPoolName string , virtualServiceName string ,
1835
1847
ips []string , externalIP string , internalPort int32 , externalPort int32 , oneArm * OneArm , enableVirtualServiceSharedIP bool , protocol string ,
1836
- resourcesAllocated * util.AllocatedResourcesMap ) (string , error ) {
1848
+ resourcesAllocated * util.AllocatedResourcesMap , applicationProfile string ) (string , error ) {
1837
1849
1838
1850
if gm == nil {
1839
1851
return "" , fmt .Errorf ("GatewayManager cannot be nil" )
@@ -1852,7 +1864,7 @@ func (gm *GatewayManager) UpdateLoadBalancer(ctx context.Context, lbPoolName str
1852
1864
return "" , fmt .Errorf ("unable to update load balancer pool [%s]: [%v]" , lbPoolName , err )
1853
1865
}
1854
1866
resourcesAllocated .Insert (VcdResourceLoadBalancerPool , lbPoolRef )
1855
- vsRef , err := gm .UpdateVirtualService (ctx , virtualServiceName , externalIP , externalPort , oneArm != nil )
1867
+ vsRef , err := gm .UpdateVirtualService (ctx , virtualServiceName , externalIP , externalPort , oneArm != nil , applicationProfile )
1856
1868
if vsRef != nil {
1857
1869
resourcesAllocated .Insert (VcdResourceVirtualService , vsRef )
1858
1870
}
0 commit comments