Skip to content

Commit 3b1aca1

Browse files
Murali reddyMurali reddy
authored andcommitted
bug CS-14291: support EIP with multiple NetScalers in basic zone
This fix will enable support for multiple NetScaler devices providing EIP service in same zone. - Introduced global setting "eip.use.multiple.netscalers" to turn multiple netscaler support - Enhanced configureNetscalerLoadBalancer API to take the PBR setup between the POD's subnet and NetScaler device - logic to pick a NetScaler (based on the guest IP and corresponding pod) while configuring INAT rule
1 parent ca5683e commit 3b1aca1

File tree

10 files changed

+325
-35
lines changed

10 files changed

+325
-35
lines changed

api/src/com/cloud/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public class ApiConstants {
127127
public static final String SSHKEY_ENABLED = "sshkeyenabled";
128128
public static final String PATH = "path";
129129
public static final String POD_ID = "podid";
130+
public static final String POD_IDS = "podids";
130131
public static final String POLICY_ID = "policyid";
131132
public static final String PORT = "port";
132133
public static final String PORTAL = "portal";

api/src/com/cloud/api/response/NetscalerLoadBalancerResponse.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
// Automatically generated by addcopyright.py at 04/03/2012
1313
package com.cloud.api.response;
1414

15+
import java.util.List;
16+
1517
import com.cloud.api.ApiConstants;
18+
import com.cloud.api.Parameter;
19+
import com.cloud.api.BaseCmd.CommandType;
1620
import com.cloud.utils.IdentityProxy;
1721
import com.cloud.serializer.Param;
1822
import com.google.gson.annotations.SerializedName;
1923

24+
@SuppressWarnings("unused")
2025
public class NetscalerLoadBalancerResponse extends BaseResponse {
2126

2227
@SerializedName(ApiConstants.LOAD_BALANCER_DEVICE_ID) @Param(description="device id of the netscaler load balancer")
@@ -52,6 +57,11 @@ public class NetscalerLoadBalancerResponse extends BaseResponse {
5257
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="the management IP address of the external load balancer")
5358
private String ipAddress;
5459

60+
@SerializedName(ApiConstants.POD_IDS) @Param(description="Used when NetScaler device is provider of EIP service." +
61+
" This parameter represents the list of pod's, for which there exists a policy based route on datacenter L3 router to " +
62+
"route pod's subnet IP to a NetScaler device.")
63+
private List<Long> podIds;
64+
5565
public void setId(long lbDeviceId) {
5666
this.id.setValue(lbDeviceId);
5767
}
@@ -95,4 +105,8 @@ public void setPrivateInterface(String privateInterface) {
95105
public void setIpAddress(String ipAddress) {
96106
this.ipAddress = ipAddress;
97107
}
108+
109+
public void setAssociatedPods(List<Long> pods) {
110+
this.podIds = pods;
111+
}
98112
}

server/src/com/cloud/api/commands/ConfigureNetscalerLoadBalancerCmd.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// Automatically generated by addcopyright.py at 04/03/2012
1313
package com.cloud.api.commands;
1414

15+
import java.util.List;
16+
1517
import org.apache.log4j.Logger;
1618

1719
import com.cloud.api.ApiConstants;
@@ -22,6 +24,7 @@
2224
import com.cloud.api.Parameter;
2325
import com.cloud.api.PlugService;
2426
import com.cloud.api.ServerApiException;
27+
import com.cloud.api.BaseCmd.CommandType;
2528
import com.cloud.api.response.NetscalerLoadBalancerResponse;
2629
import com.cloud.event.EventTypes;
2730
import com.cloud.exception.ConcurrentOperationException;
@@ -58,6 +61,12 @@ public class ConfigureNetscalerLoadBalancerCmd extends BaseAsyncCmd {
5861
@Parameter (name=ApiConstants.INLINE, type=CommandType.BOOLEAN, required=false, description="true if netscaler load balancer is intended to be used in in-line with firewall, false if netscaler load balancer will side-by-side with firewall")
5962
private Boolean inline;
6063

64+
@IdentityMapper(entityTableName="host_pod_ref")
65+
@Parameter(name=ApiConstants.POD_IDS, type=CommandType.LIST, required=false, description="Used when NetScaler device is provider of EIP service." +
66+
" This parameter represents the list of pod's, for which there exists a policy based route on datacenter L3 router to " +
67+
"route pod's subnet IP to a NetScaler device.")
68+
private List<Long> podIds;
69+
6170
/////////////////////////////////////////////////////
6271
/////////////////// Accessors ///////////////////////
6372
/////////////////////////////////////////////////////
@@ -78,6 +87,10 @@ public Boolean getLoadBalancerInline() {
7887
return inline;
7988
}
8089

90+
public List<Long> getPodIds() {
91+
return podIds;
92+
}
93+
8194
/////////////////////////////////////////////////////
8295
/////////////// API Implementation///////////////////
8396
/////////////////////////////////////////////////////

server/src/com/cloud/configuration/Config.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ public enum Config {
328328

329329
DefaultExternalLoadBalancerCapacity("Advanced", ManagementServer.class, String.class, "external.lb.default.capacity", "50", "default number of networks permitted per external load balancer device", null),
330330
DefaultExternalFirewallCapacity("Advanced", ManagementServer.class, String.class, "external.firewall.default.capacity", "50", "default number of networks permitted per external load firewall device", null),
331+
EIPWithMultipleNetScalersEnabled("Advanced", ManagementServer.class, Boolean.class, "eip.use.multiple.netscalers", "false", "Should be set to true, if there will be multiple NetScaler devices providing EIP service in a zone", null),
331332
CustomDiskOfferingMinSize("Advanced", ManagementServer.class, Long.class, "custom.diskoffering.size.min", "1", "Minimum size in GB for custom disk offering", null),
332333
CustomDiskOfferingMaxSize("Advanced", ManagementServer.class, Long.class, "custom.diskoffering.size.max", "1024", "Maximum size in GB for custom disk offering", null),
333334
ConsoleProxyServiceOffering("Advanced", ManagementServer.class, Long.class, "consoleproxy.service.offering", null, "Service offering used by console proxy; if NULL - system offering will be used", null),

server/src/com/cloud/configuration/DefaultComponentLibrary.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import com.cloud.network.dao.LBStickinessPolicyDaoImpl;
8080
import com.cloud.network.dao.LoadBalancerDaoImpl;
8181
import com.cloud.network.dao.LoadBalancerVMMapDaoImpl;
82+
import com.cloud.network.dao.NetScalerPodDaoImpl;
8283
import com.cloud.network.dao.NetworkDaoImpl;
8384
import com.cloud.network.dao.NetworkDomainDaoImpl;
8485
import com.cloud.network.dao.NetworkExternalFirewallDaoImpl;
@@ -315,6 +316,7 @@ protected void populateDaos() {
315316
addDao("ExternalFirewallDeviceDao", ExternalFirewallDeviceDaoImpl.class);
316317
addDao("NetworkExternalLoadBalancerDao", NetworkExternalLoadBalancerDaoImpl.class);
317318
addDao("NetworkExternalFirewallDao", NetworkExternalFirewallDaoImpl.class);
319+
addDao("NetScalerPodDao", NetScalerPodDaoImpl.class);
318320
addDao("PhysicalNetworkTrafficTypeDao", PhysicalNetworkTrafficTypeDaoImpl.class);
319321
addDao("NetworkServiceMapDao", NetworkServiceMapDaoImpl.class);
320322
addDao("StorageNetworkIpAddressDao", StorageNetworkIpAddressDaoImpl.class);
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright 2012 Citrix Systems, Inc. Licensed under the
2+
// Apache License, Version 2.0 (the "License"); you may not use this
3+
// file except in compliance with the License. Citrix Systems, Inc.
4+
// reserves all rights not expressly granted by the License.
5+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an "AS IS" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
12+
package com.cloud.network;
13+
14+
import javax.persistence.Column;
15+
import javax.persistence.Entity;
16+
import javax.persistence.GeneratedValue;
17+
import javax.persistence.GenerationType;
18+
import javax.persistence.Id;
19+
import javax.persistence.Table;
20+
21+
/**
22+
* NetScalerPodVO contains information about a EIP deployment where on datacenter L3 router a PBR (policy
23+
* based routing) is setup between a POD's subnet IP range to a NetScaler device. This VO object
24+
* represents a mapping between a POD and NetScaler device where PBR is setup.
25+
*
26+
*/
27+
@Entity
28+
@Table(name="netscaler_pod_ref")
29+
public class NetScalerPodVO {
30+
31+
@Column(name="external_load_balancer_device_id")
32+
private long netscalerDeviceId;
33+
34+
@Id
35+
@Column(name="id")
36+
private long id;
37+
38+
@Column(name="pod_id")
39+
private long podId;
40+
41+
public NetScalerPodVO() {
42+
43+
}
44+
45+
public NetScalerPodVO(long netscalerDeviceId, long podId) {
46+
this.netscalerDeviceId = netscalerDeviceId;
47+
this.podId = podId;
48+
}
49+
50+
public long getId() {
51+
return id;
52+
}
53+
54+
public long getPodId() {
55+
return podId;
56+
}
57+
58+
public long getNetscalerDeviceId() {
59+
return netscalerDeviceId;
60+
}
61+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2012 Citrix Systems, Inc. Licensed under the
2+
// Apache License, Version 2.0 (the "License"); you may not use this
3+
// file except in compliance with the License. Citrix Systems, Inc.
4+
// reserves all rights not expressly granted by the License.
5+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an "AS IS" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
12+
package com.cloud.network.dao;
13+
14+
import java.util.List;
15+
16+
import com.cloud.network.NetScalerPodVO;
17+
import com.cloud.utils.db.GenericDao;
18+
19+
public interface NetScalerPodDao extends GenericDao<NetScalerPodVO, Long> {
20+
21+
NetScalerPodVO findByPodId(long podId);
22+
23+
List<NetScalerPodVO> listByNetScalerDeviceId(long netscalerDeviceId);
24+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2012 Citrix Systems, Inc. Licensed under the
2+
// Apache License, Version 2.0 (the "License"); you may not use this
3+
// file except in compliance with the License. Citrix Systems, Inc.
4+
// reserves all rights not expressly granted by the License.
5+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an "AS IS" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
12+
package com.cloud.network.dao;
13+
14+
import java.util.List;
15+
16+
import javax.ejb.Local;
17+
18+
import com.cloud.network.NetScalerPodVO;
19+
import com.cloud.utils.db.DB;
20+
import com.cloud.utils.db.GenericDaoBase;
21+
import com.cloud.utils.db.SearchBuilder;
22+
import com.cloud.utils.db.SearchCriteria;
23+
import com.cloud.utils.db.SearchCriteria.Op;
24+
25+
@Local(value=NetScalerPodDao.class) @DB(txn=false)
26+
public class NetScalerPodDaoImpl extends GenericDaoBase<NetScalerPodVO, Long> implements NetScalerPodDao {
27+
28+
final SearchBuilder<NetScalerPodVO> podIdSearch;
29+
final SearchBuilder<NetScalerPodVO> deviceIdSearch;
30+
31+
protected NetScalerPodDaoImpl() {
32+
super();
33+
34+
podIdSearch = createSearchBuilder();
35+
podIdSearch.and("pod_id", podIdSearch.entity().getPodId(), Op.EQ);
36+
podIdSearch.done();
37+
38+
deviceIdSearch = createSearchBuilder();
39+
deviceIdSearch.and("netscalerDeviceId", deviceIdSearch.entity().getNetscalerDeviceId(), Op.EQ);
40+
deviceIdSearch.done();
41+
}
42+
43+
@Override
44+
public NetScalerPodVO findByPodId(long podId) {
45+
SearchCriteria<NetScalerPodVO> sc = podIdSearch.create();
46+
sc.setParameters("pod_id", podId);
47+
return findOneBy(sc);
48+
}
49+
50+
@Override
51+
public List<NetScalerPodVO> listByNetScalerDeviceId(long netscalerDeviceId) {
52+
SearchCriteria<NetScalerPodVO> sc = deviceIdSearch.create();
53+
sc.setParameters("netscalerDeviceId", netscalerDeviceId);
54+
return search(sc, null);
55+
}
56+
57+
}

0 commit comments

Comments
 (0)