mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
making devices enabled independent of config commands
adding default device capacity when admin does not specify a vlaue fixed bug in device allocation logic
This commit is contained in:
parent
fc7bbc39f3
commit
beb38c8310
@ -89,7 +89,7 @@ public class NetscalerResource implements ServerResource {
|
|||||||
private String _objectNamePathSep = "-";
|
private String _objectNamePathSep = "-";
|
||||||
|
|
||||||
nitro_service _netscalerService ;
|
nitro_service _netscalerService ;
|
||||||
Long timeout = new Long(100000);
|
Long _timeout = new Long(100000);
|
||||||
base_response apiCallResult;
|
base_response apiCallResult;
|
||||||
|
|
||||||
public NetscalerResource () {
|
public NetscalerResource () {
|
||||||
@ -157,10 +157,12 @@ public class NetscalerResource implements ServerResource {
|
|||||||
|
|
||||||
_inline = Boolean.parseBoolean((String) params.get("inline"));
|
_inline = Boolean.parseBoolean((String) params.get("inline"));
|
||||||
|
|
||||||
|
// validate device configration parameters
|
||||||
login();
|
login();
|
||||||
enableNetScalerLoadBalancing();
|
checkLoadBalancingFeatureEnabled();
|
||||||
validateInterfaces(_publicInterface, _privateInterface);
|
validateInterfaces(_publicInterface, _privateInterface);
|
||||||
validateDeviceType(_deviceName);
|
validateDeviceType(_deviceName);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException(e.getMessage());
|
throw new ConfigurationException(e.getMessage());
|
||||||
@ -170,7 +172,9 @@ public class NetscalerResource implements ServerResource {
|
|||||||
private void login() throws ExecutionException {
|
private void login() throws ExecutionException {
|
||||||
try {
|
try {
|
||||||
_netscalerService = new nitro_service(_ip, "https");
|
_netscalerService = new nitro_service(_ip, "https");
|
||||||
apiCallResult = _netscalerService.login(_username, _password, timeout);
|
_netscalerService.set_credential(_username, _password);
|
||||||
|
_netscalerService.set_timeout(_timeout);
|
||||||
|
apiCallResult = _netscalerService.login();
|
||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException ("Failed to log in to Netscaler device at " + _ip + " due to error " + apiCallResult.errorcode + " and message " + apiCallResult.message);
|
throw new ExecutionException ("Failed to log in to Netscaler device at " + _ip + " due to error " + apiCallResult.errorcode + " and message " + apiCallResult.message);
|
||||||
}
|
}
|
||||||
@ -181,15 +185,21 @@ public class NetscalerResource implements ServerResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableNetScalerLoadBalancing() throws ExecutionException {
|
private void checkLoadBalancingFeatureEnabled() throws ExecutionException {
|
||||||
try {
|
try {
|
||||||
String[] feature = new String[1];
|
String[] features = _netscalerService.get_enabled_features();
|
||||||
feature[0] = "LB";
|
if (features != null) {
|
||||||
_netscalerService.enable_features(feature);
|
for (String feature : features) {
|
||||||
|
if (feature.equalsIgnoreCase("LB")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new ExecutionException("Load balancing feature is not enabled on the device. Please enable the load balancing feature and add the device.");
|
||||||
} catch (nitro_exception e) {
|
} catch (nitro_exception e) {
|
||||||
throw new ExecutionException("Enabling netscaler load balancing feature failed due to error " + apiCallResult.errorcode + " and message " + e.getMessage());
|
throw new ExecutionException("Failed to verify load balancing is enalbed due to error " + apiCallResult.errorcode + " and message " + e.getMessage());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ExecutionException("Enabling netscaler load balancing feature failed due to " + e.getMessage());
|
throw new ExecutionException("Failed to verify load balancing is enalbed due to " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,32 +301,16 @@ public class NetscalerResource implements ServerResource {
|
|||||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
String lbProtocol;
|
|
||||||
String lbMethod;
|
|
||||||
LoadBalancerTO[] loadBalancers = cmd.getLoadBalancers();
|
LoadBalancerTO[] loadBalancers = cmd.getLoadBalancers();
|
||||||
|
if (loadBalancers == null) {
|
||||||
|
return new Answer(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
for (LoadBalancerTO loadBalancer : loadBalancers) {
|
for (LoadBalancerTO loadBalancer : loadBalancers) {
|
||||||
|
|
||||||
if (loadBalancer.getProtocol() == null) {
|
|
||||||
lbProtocol = "TCP";
|
|
||||||
} else if (loadBalancer.getProtocol().equals(NetUtils.TCP_PROTO)){
|
|
||||||
lbProtocol = "TCP";
|
|
||||||
} else if (loadBalancer.getProtocol().equals(NetUtils.UDP_PROTO)) {
|
|
||||||
lbProtocol = "UDP";
|
|
||||||
} else {
|
|
||||||
throw new ExecutionException("Got invalid protocol: " + loadBalancer.getProtocol());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loadBalancer.getAlgorithm().equals("roundrobin")) {
|
|
||||||
lbMethod = "ROUNDROBIN";
|
|
||||||
} else if (loadBalancer.getAlgorithm().equals("leastconn")) {
|
|
||||||
lbMethod = "LEASTCONNECTION";
|
|
||||||
} else {
|
|
||||||
throw new ExecutionException("Got invalid load balancing algorithm: " + loadBalancer.getAlgorithm());
|
|
||||||
}
|
|
||||||
|
|
||||||
String srcIp = loadBalancer.getSrcIp();
|
String srcIp = loadBalancer.getSrcIp();
|
||||||
int srcPort = loadBalancer.getSrcPort();
|
int srcPort = loadBalancer.getSrcPort();
|
||||||
|
String lbProtocol = loadBalancer.getProtocol();
|
||||||
|
String lbAlgorithm = loadBalancer.getAlgorithm();
|
||||||
String nsVirtualServerName = generateNSVirtualServerName(srcIp, srcPort, lbProtocol);
|
String nsVirtualServerName = generateNSVirtualServerName(srcIp, srcPort, lbProtocol);
|
||||||
|
|
||||||
boolean destinationsToAdd = false;
|
boolean destinationsToAdd = false;
|
||||||
@ -330,7 +324,7 @@ public class NetscalerResource implements ServerResource {
|
|||||||
if (!loadBalancer.isRevoked() && destinationsToAdd) {
|
if (!loadBalancer.isRevoked() && destinationsToAdd) {
|
||||||
|
|
||||||
// create a load balancing virtual server
|
// create a load balancing virtual server
|
||||||
addLBVirtualServer(nsVirtualServerName, srcIp, srcPort, lbMethod, lbProtocol);
|
addLBVirtualServer(nsVirtualServerName, srcIp, srcPort, lbAlgorithm, lbProtocol);
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Created load balancing virtual server " + nsVirtualServerName + " on the Netscaler device");
|
s_logger.debug("Created load balancing virtual server " + nsVirtualServerName + " on the Netscaler device");
|
||||||
}
|
}
|
||||||
@ -391,13 +385,13 @@ public class NetscalerResource implements ServerResource {
|
|||||||
// delete the binding
|
// delete the binding
|
||||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.delete(_netscalerService, binding);
|
apiCallResult = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.delete(_netscalerService, binding);
|
||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException("Failed to delete the binding between the virtual server: " + nsVirtualServerName + " and service:" + nsServiceName);
|
throw new ExecutionException("Failed to delete the binding between the virtual server: " + nsVirtualServerName + " and service:" + nsServiceName + " due to" + apiCallResult.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the service
|
// delete the service
|
||||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.service.delete(_netscalerService, nsServiceName);
|
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.service.delete(_netscalerService, nsServiceName);
|
||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException("Failed to delete service: " + nsServiceName);
|
throw new ExecutionException("Failed to delete service: " + nsServiceName + " due to " + apiCallResult.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the server if there is no associated services
|
// delete the server if there is no associated services
|
||||||
@ -405,7 +399,7 @@ public class NetscalerResource implements ServerResource {
|
|||||||
if ((services == null) || (services.length == 0)) {
|
if ((services == null) || (services.length == 0)) {
|
||||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.delete(_netscalerService, nsServerName);
|
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.delete(_netscalerService, nsServerName);
|
||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException("Failed to remove server:" + nsServerName);
|
throw new ExecutionException("Failed to remove server:" + nsServerName + " due to " + apiCallResult.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -414,8 +408,8 @@ public class NetscalerResource implements ServerResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// delete the deployed load balancing rule and its destinations
|
// delete the implemented load balancing rule and its destinations
|
||||||
lbvserver lbserver = lbvserver.get(_netscalerService, nsVirtualServerName);
|
lbvserver lbserver = getVirtualServerIfExisits(nsVirtualServerName);
|
||||||
if (lbserver == null) {
|
if (lbserver == null) {
|
||||||
throw new ExecutionException("Failed to find virtual server with name:" + nsVirtualServerName);
|
throw new ExecutionException("Failed to find virtual server with name:" + nsVirtualServerName);
|
||||||
}
|
}
|
||||||
@ -427,7 +421,7 @@ public class NetscalerResource implements ServerResource {
|
|||||||
String serviceName = binding.get_servicename();
|
String serviceName = binding.get_servicename();
|
||||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.delete(_netscalerService, binding);
|
apiCallResult = com.citrix.netscaler.nitro.resource.config.lb.lbvserver_service_binding.delete(_netscalerService, binding);
|
||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException("Failed to unbind servic from the lb virtual server: " + nsVirtualServerName);
|
throw new ExecutionException("Failed to unbind service from the lb virtual server: " + nsVirtualServerName + " due to " + apiCallResult.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
com.citrix.netscaler.nitro.resource.config.basic.service svc = com.citrix.netscaler.nitro.resource.config.basic.service.get(_netscalerService, serviceName);
|
com.citrix.netscaler.nitro.resource.config.basic.service svc = com.citrix.netscaler.nitro.resource.config.basic.service.get(_netscalerService, serviceName);
|
||||||
@ -441,7 +435,7 @@ public class NetscalerResource implements ServerResource {
|
|||||||
if ((services == null) || (services.length == 0)) {
|
if ((services == null) || (services.length == 0)) {
|
||||||
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.delete(_netscalerService, nsServerName);
|
apiCallResult = com.citrix.netscaler.nitro.resource.config.basic.server.delete(_netscalerService, nsServerName);
|
||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException("Failed to remove server:" + nsServerName);
|
throw new ExecutionException("Failed to remove server:" + nsServerName + " due to " + apiCallResult.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,10 +488,7 @@ public class NetscalerResource implements ServerResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addGuestVlanAndSubnet(long vlanTag, String vlanSelfIp, String vlanNetmask) throws ExecutionException {
|
private void addGuestVlanAndSubnet(long vlanTag, String vlanSelfIp, String vlanNetmask) throws ExecutionException {
|
||||||
org.apache.axis.types.UnsignedInt result;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String vlanName = generateVlanName(vlanTag);
|
|
||||||
if (!nsVlanExists(vlanTag)) {
|
if (!nsVlanExists(vlanTag)) {
|
||||||
// add new vlan
|
// add new vlan
|
||||||
vlan vlanObj = new vlan();
|
vlan vlanObj = new vlan();
|
||||||
@ -547,8 +538,6 @@ public class NetscalerResource implements ServerResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void deleteGuestVlan(long vlanTag, String vlanSelfIp, String vlanNetmask) throws ExecutionException {
|
private void deleteGuestVlan(long vlanTag, String vlanSelfIp, String vlanNetmask) throws ExecutionException {
|
||||||
org.apache.axis.types.UnsignedInt result;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (nsVlanExists(vlanTag)) {
|
if (nsVlanExists(vlanTag)) {
|
||||||
|
|
||||||
@ -624,6 +613,20 @@ public class NetscalerResource implements ServerResource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private lbvserver getVirtualServerIfExisits(String lbVServerName ) throws ExecutionException {
|
||||||
|
try {
|
||||||
|
return lbvserver.get(_netscalerService, lbVServerName);
|
||||||
|
} catch (nitro_exception e) {
|
||||||
|
if (e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
throw new ExecutionException(e.getMessage());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ExecutionException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean nsServiceExists(String serviceName) throws ExecutionException {
|
private boolean nsServiceExists(String serviceName) throws ExecutionException {
|
||||||
try {
|
try {
|
||||||
if (com.citrix.netscaler.nitro.resource.config.basic.service.get(_netscalerService, serviceName) != null) {
|
if (com.citrix.netscaler.nitro.resource.config.basic.service.get(_netscalerService, serviceName) != null) {
|
||||||
@ -698,15 +701,49 @@ public class NetscalerResource implements ServerResource {
|
|||||||
|
|
||||||
private void addLBVirtualServer(String virtualServerName, String srcIp, int srcPort, String lbMethod, String lbProtocol) throws ExecutionException {
|
private void addLBVirtualServer(String virtualServerName, String srcIp, int srcPort, String lbMethod, String lbProtocol) throws ExecutionException {
|
||||||
try {
|
try {
|
||||||
lbvserver vserver = new lbvserver();
|
|
||||||
|
if (lbProtocol == null) {
|
||||||
|
lbProtocol = "TCP";
|
||||||
|
} else if (lbProtocol.equals(NetUtils.TCP_PROTO)){
|
||||||
|
lbProtocol = "TCP";
|
||||||
|
} else if (lbProtocol.equals(NetUtils.UDP_PROTO)) {
|
||||||
|
lbProtocol = "UDP";
|
||||||
|
} else {
|
||||||
|
throw new ExecutionException("Got invalid protocol: " + lbProtocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lbMethod.equals("roundrobin")) {
|
||||||
|
lbMethod = "ROUNDROBIN";
|
||||||
|
} else if (lbMethod.equals("leastconn")) {
|
||||||
|
lbMethod = "LEASTCONNECTION";
|
||||||
|
} else {
|
||||||
|
throw new ExecutionException("Got invalid load balancing algorithm: " + lbMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean vserverExisis = false;
|
||||||
|
lbvserver vserver = getVirtualServerIfExisits(virtualServerName);
|
||||||
|
if (vserver == null) {
|
||||||
|
vserver = new lbvserver();
|
||||||
|
} else {
|
||||||
|
vserverExisis = true;
|
||||||
|
}
|
||||||
vserver.set_name(virtualServerName);
|
vserver.set_name(virtualServerName);
|
||||||
vserver.set_ipv46(srcIp);
|
vserver.set_ipv46(srcIp);
|
||||||
vserver.set_port(srcPort);
|
vserver.set_port(srcPort);
|
||||||
vserver.set_servicetype(lbProtocol);
|
vserver.set_servicetype(lbProtocol);
|
||||||
vserver.set_lbmethod(lbMethod);
|
vserver.set_lbmethod(lbMethod);
|
||||||
|
|
||||||
|
if (vserverExisis) {
|
||||||
|
apiCallResult = lbvserver.update(_netscalerService,vserver);
|
||||||
|
} else {
|
||||||
apiCallResult = lbvserver.add(_netscalerService,vserver);
|
apiCallResult = lbvserver.add(_netscalerService,vserver);
|
||||||
|
}
|
||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException("Failed to create new virtual server:" + virtualServerName);
|
throw new ExecutionException("Failed to create new virtual server:" + virtualServerName+ " due to " + apiCallResult.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug("Created load balancing virtual server " + virtualServerName + " on the Netscaler device");
|
||||||
}
|
}
|
||||||
} catch (nitro_exception e) {
|
} catch (nitro_exception e) {
|
||||||
if (e.getErrorCode() != NitroError.NS_RESOURCE_EXISTS) {
|
if (e.getErrorCode() != NitroError.NS_RESOURCE_EXISTS) {
|
||||||
@ -725,10 +762,14 @@ public class NetscalerResource implements ServerResource {
|
|||||||
}
|
}
|
||||||
apiCallResult = lbvserver.delete(_netscalerService, vserver);
|
apiCallResult = lbvserver.delete(_netscalerService, vserver);
|
||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException("Failed to remove virtual server:" + virtualServerName);
|
throw new ExecutionException("Failed to remove virtual server:" + virtualServerName + " due to " + apiCallResult.message);
|
||||||
}
|
}
|
||||||
} catch (nitro_exception e) {
|
} catch (nitro_exception e) {
|
||||||
throw new ExecutionException("Failed to remove virtual server:" + virtualServerName +" due to " + e.getMessage());
|
if (e.getErrorCode() == NitroError.NS_RESOURCE_NOT_EXISTS) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw new ExecutionException("Failed remove virtual server:" + virtualServerName +" due to " + e.getMessage());
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ExecutionException("Failed to remove virtual server:" + virtualServerName +" due to " + e.getMessage());
|
throw new ExecutionException("Failed to remove virtual server:" + virtualServerName +" due to " + e.getMessage());
|
||||||
}
|
}
|
||||||
@ -738,7 +779,7 @@ public class NetscalerResource implements ServerResource {
|
|||||||
try {
|
try {
|
||||||
apiCallResult = nsconfig.save(_netscalerService);
|
apiCallResult = nsconfig.save(_netscalerService);
|
||||||
if (apiCallResult.errorcode != 0) {
|
if (apiCallResult.errorcode != 0) {
|
||||||
throw new ExecutionException("Error occured while saving configuration changes to Netscaler device due to error:" + apiCallResult.errorcode);
|
throw new ExecutionException("Error occured while saving configuration changes to Netscaler device due to " + apiCallResult.message);
|
||||||
}
|
}
|
||||||
} catch (nitro_exception e) {
|
} catch (nitro_exception e) {
|
||||||
throw new ExecutionException("Failed to save configuration changes to Netscaler device due to " + e.getMessage());
|
throw new ExecutionException("Failed to save configuration changes to Netscaler device due to " + e.getMessage());
|
||||||
@ -796,10 +837,6 @@ public class NetscalerResource implements ServerResource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateVlanName(long vlanTag) {
|
|
||||||
return genObjectName("cloud-vlan", String.valueOf(vlanTag));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateNSVirtualServerName(String srcIp, long srcPort, String protocol) {
|
private String generateNSVirtualServerName(String srcIp, long srcPort, String protocol) {
|
||||||
return genObjectName("cloud-VirtualServer", protocol, srcIp, srcPort);
|
return genObjectName("cloud-VirtualServer", protocol, srcIp, srcPort);
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
deps/cloud-netscaler.jar
vendored
Normal file → Executable file
BIN
deps/cloud-netscaler.jar
vendored
Normal file → Executable file
Binary file not shown.
@ -322,7 +322,10 @@ public enum Config {
|
|||||||
ProjectSMTPPassword("Project Defaults", ManagementServer.class, String.class, "project.smtp.password", null, "Password for SMTP authentication (applies only if project.smtp.useAuth is true)", null),
|
ProjectSMTPPassword("Project Defaults", ManagementServer.class, String.class, "project.smtp.password", null, "Password for SMTP authentication (applies only if project.smtp.useAuth is true)", null),
|
||||||
ProjectSMTPPort("Project Defaults", ManagementServer.class, Integer.class, "project.smtp.port", "465", "Port the SMTP server is listening on", null),
|
ProjectSMTPPort("Project Defaults", ManagementServer.class, Integer.class, "project.smtp.port", "465", "Port the SMTP server is listening on", null),
|
||||||
ProjectSMTPUseAuth("Project Defaults", ManagementServer.class, String.class, "project.smtp.useAuth", null, "If true, use SMTP authentication when sending emails", null),
|
ProjectSMTPUseAuth("Project Defaults", ManagementServer.class, String.class, "project.smtp.useAuth", null, "If true, use SMTP authentication when sending emails", null),
|
||||||
ProjectSMTPUsername("Project Defaults", ManagementServer.class, String.class, "project.smtp.username", null, "Username for SMTP authentication (applies only if project.smtp.useAuth is true)", null);
|
ProjectSMTPUsername("Project Defaults", ManagementServer.class, String.class, "project.smtp.username", null, "Username for SMTP authentication (applies only if project.smtp.useAuth is true)", null),
|
||||||
|
|
||||||
|
DefaultExternalLoadBalancerCapacity("Advanced", ManagementServer.class, String.class, "external.lb.default.capacity", "50", "default number of networks permitted per external load balancer device", null),
|
||||||
|
DefaultExternalFirewallCapacity("Advanced", ManagementServer.class, String.class, "external.firewall.default.capacity", "50", "default number of networks permitted per external load firewall device", null);
|
||||||
|
|
||||||
private final String _category;
|
private final String _category;
|
||||||
private final Class<?> _componentClass;
|
private final Class<?> _componentClass;
|
||||||
|
|||||||
@ -214,9 +214,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
|
|||||||
|
|
||||||
ExternalFirewallDeviceVO fwDevice = new ExternalFirewallDeviceVO(externalFirewall.getId(), pNetwork.getId(), ntwkSvcProvider.getProviderName(),
|
ExternalFirewallDeviceVO fwDevice = new ExternalFirewallDeviceVO(externalFirewall.getId(), pNetwork.getId(), ntwkSvcProvider.getProviderName(),
|
||||||
deviceName, capacity, dedicatedUse);
|
deviceName, capacity, dedicatedUse);
|
||||||
if (capacity != 0) {
|
|
||||||
fwDevice.setState(FirewallDeviceState.Enabled);
|
|
||||||
}
|
|
||||||
_externalFirewallDeviceDao.persist(fwDevice);
|
_externalFirewallDeviceDao.persist(fwDevice);
|
||||||
|
|
||||||
DetailVO hostDetail = new DetailVO(externalFirewall.getId(), ApiConstants.FIREWALL_DEVICE_ID, String.valueOf(fwDevice.getId()));
|
DetailVO hostDetail = new DetailVO(externalFirewall.getId(), ApiConstants.FIREWALL_DEVICE_ID, String.valueOf(fwDevice.getId()));
|
||||||
|
|||||||
@ -56,9 +56,9 @@ public class ExternalFirewallDeviceVO {
|
|||||||
@Column(name = "device_name")
|
@Column(name = "device_name")
|
||||||
private String deviceName;
|
private String deviceName;
|
||||||
|
|
||||||
@Column(name="state")
|
@Column(name="device_state")
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
FirewallDeviceState state;
|
FirewallDeviceState deviceState;
|
||||||
|
|
||||||
@Column(name="is_dedicated")
|
@Column(name="is_dedicated")
|
||||||
private boolean isDedicatedDevice;
|
private boolean isDedicatedDevice;
|
||||||
@ -86,10 +86,11 @@ public class ExternalFirewallDeviceVO {
|
|||||||
this.providerName = provider_name;
|
this.providerName = provider_name;
|
||||||
this.deviceName = device_name;
|
this.deviceName = device_name;
|
||||||
this.hostId = hostId;
|
this.hostId = hostId;
|
||||||
this.state = FirewallDeviceState.Disabled;
|
this.deviceState = FirewallDeviceState.Disabled;
|
||||||
this.allocationState = FirewallDeviceAllocationState.Free;
|
this.allocationState = FirewallDeviceAllocationState.Free;
|
||||||
this.capacity = capacity;
|
this.capacity = capacity;
|
||||||
this.isDedicatedDevice = dedicated;
|
this.isDedicatedDevice = dedicated;
|
||||||
|
this.deviceState = FirewallDeviceState.Enabled;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,12 +126,12 @@ public class ExternalFirewallDeviceVO {
|
|||||||
this.capacity = capacity;
|
this.capacity = capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FirewallDeviceState getState() {
|
public FirewallDeviceState getDeviceState() {
|
||||||
return state;
|
return deviceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState(FirewallDeviceState state) {
|
public void setDeviceState(FirewallDeviceState state) {
|
||||||
this.state = state;
|
this.deviceState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FirewallDeviceAllocationState getAllocationState() {
|
public FirewallDeviceAllocationState getAllocationState() {
|
||||||
|
|||||||
@ -35,6 +35,9 @@ import com.cloud.utils.component.Manager;
|
|||||||
|
|
||||||
public interface ExternalLoadBalancerDeviceManager extends Manager{
|
public interface ExternalLoadBalancerDeviceManager extends Manager{
|
||||||
|
|
||||||
|
|
||||||
|
public static final int DEFAULT_LOAD_BALANCER_CAPACITY = 50;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds a load balancer device in to a physical network
|
* adds a load balancer device in to a physical network
|
||||||
* @param physicalNetworkId physical network id of the network in to which device to be added
|
* @param physicalNetworkId physical network id of the network in to which device to be added
|
||||||
|
|||||||
@ -122,35 +122,62 @@ import com.cloud.vm.dao.NicDao;
|
|||||||
|
|
||||||
public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase implements ExternalLoadBalancerDeviceManager, ResourceStateAdapter {
|
public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase implements ExternalLoadBalancerDeviceManager, ResourceStateAdapter {
|
||||||
|
|
||||||
@Inject NetworkExternalLoadBalancerDao _networkExternalLBDao;
|
@Inject
|
||||||
@Inject ExternalLoadBalancerDeviceDao _externalLoadBalancerDeviceDao;
|
NetworkExternalLoadBalancerDao _networkExternalLBDao;
|
||||||
@Inject HostDao _hostDao;
|
@Inject
|
||||||
@Inject DataCenterDao _dcDao;
|
ExternalLoadBalancerDeviceDao _externalLoadBalancerDeviceDao;
|
||||||
@Inject HostDetailsDao _detailsDao;
|
@Inject
|
||||||
@Inject NetworkManager _networkMgr;
|
HostDao _hostDao;
|
||||||
@Inject InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
@Inject
|
||||||
@Inject NicDao _nicDao;
|
DataCenterDao _dcDao;
|
||||||
@Inject AgentManager _agentMgr;
|
@Inject
|
||||||
@Inject ResourceManager _resourceMgr;
|
HostDetailsDao _detailsDao;
|
||||||
@Inject IPAddressDao _ipAddressDao;
|
@Inject
|
||||||
@Inject VlanDao _vlanDao;
|
NetworkManager _networkMgr;
|
||||||
@Inject NetworkOfferingDao _networkOfferingDao;
|
@Inject
|
||||||
@Inject AccountDao _accountDao;
|
InlineLoadBalancerNicMapDao _inlineLoadBalancerNicMapDao;
|
||||||
@Inject PhysicalNetworkDao _physicalNetworkDao;
|
@Inject
|
||||||
@Inject PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
|
NicDao _nicDao;
|
||||||
@Inject AccountManager _accountMgr;
|
@Inject
|
||||||
@Inject UserStatisticsDao _userStatsDao;
|
AgentManager _agentMgr;
|
||||||
@Inject NetworkDao _networkDao;
|
@Inject
|
||||||
@Inject DomainRouterDao _routerDao;
|
ResourceManager _resourceMgr;
|
||||||
@Inject LoadBalancerDao _loadBalancerDao;
|
@Inject
|
||||||
@Inject PortForwardingRulesDao _portForwardingRulesDao;
|
IPAddressDao _ipAddressDao;
|
||||||
@Inject ConfigurationDao _configDao;
|
@Inject
|
||||||
@Inject HostDetailsDao _hostDetailDao;
|
VlanDao _vlanDao;
|
||||||
@Inject NetworkExternalLoadBalancerDao _networkLBDao;
|
@Inject
|
||||||
@Inject NetworkServiceMapDao _ntwkSrvcProviderDao;
|
NetworkOfferingDao _networkOfferingDao;
|
||||||
|
@Inject
|
||||||
|
AccountDao _accountDao;
|
||||||
|
@Inject
|
||||||
|
PhysicalNetworkDao _physicalNetworkDao;
|
||||||
|
@Inject
|
||||||
|
PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao;
|
||||||
|
@Inject
|
||||||
|
AccountManager _accountMgr;
|
||||||
|
@Inject
|
||||||
|
UserStatisticsDao _userStatsDao;
|
||||||
|
@Inject
|
||||||
|
NetworkDao _networkDao;
|
||||||
|
@Inject
|
||||||
|
DomainRouterDao _routerDao;
|
||||||
|
@Inject
|
||||||
|
LoadBalancerDao _loadBalancerDao;
|
||||||
|
@Inject
|
||||||
|
PortForwardingRulesDao _portForwardingRulesDao;
|
||||||
|
@Inject
|
||||||
|
ConfigurationDao _configDao;
|
||||||
|
@Inject
|
||||||
|
HostDetailsDao _hostDetailDao;
|
||||||
|
@Inject
|
||||||
|
NetworkExternalLoadBalancerDao _networkLBDao;
|
||||||
|
@Inject
|
||||||
|
NetworkServiceMapDao _ntwkSrvcProviderDao;
|
||||||
|
|
||||||
ScheduledExecutorService _executor;
|
ScheduledExecutorService _executor;
|
||||||
int _externalNetworkStatsInterval;
|
private int _externalNetworkStatsInterval;
|
||||||
|
private long _defaultLbCapacity;
|
||||||
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(ExternalLoadBalancerDeviceManagerImpl.class);
|
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(ExternalLoadBalancerDeviceManagerImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -222,9 +249,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||||||
|
|
||||||
ExternalLoadBalancerDeviceVO lbDeviceVO = new ExternalLoadBalancerDeviceVO(host.getId(), pNetwork.getId(), ntwkSvcProvider.getProviderName(),
|
ExternalLoadBalancerDeviceVO lbDeviceVO = new ExternalLoadBalancerDeviceVO(host.getId(), pNetwork.getId(), ntwkSvcProvider.getProviderName(),
|
||||||
deviceName, capacity, dedicatedUse, inline);
|
deviceName, capacity, dedicatedUse, inline);
|
||||||
if (capacity != 0) {
|
|
||||||
lbDeviceVO.setState(LBDeviceState.Enabled);
|
|
||||||
}
|
|
||||||
_externalLoadBalancerDeviceDao.persist(lbDeviceVO);
|
_externalLoadBalancerDeviceDao.persist(lbDeviceVO);
|
||||||
|
|
||||||
DetailVO hostDetail = new DetailVO(host.getId(), ApiConstants.LOAD_BALANCER_DEVICE_ID, String.valueOf(lbDeviceVO.getId()));
|
DetailVO hostDetail = new DetailVO(host.getId(), ApiConstants.LOAD_BALANCER_DEVICE_ID, String.valueOf(lbDeviceVO.getId()));
|
||||||
@ -322,20 +347,12 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||||||
if (dedicatedLb) {
|
if (dedicatedLb) {
|
||||||
lbDevices = _externalLoadBalancerDeviceDao.listByProviderAndDeviceAllocationState(physicalNetworkId, provider, LBDeviceAllocationState.Free);
|
lbDevices = _externalLoadBalancerDeviceDao.listByProviderAndDeviceAllocationState(physicalNetworkId, provider, LBDeviceAllocationState.Free);
|
||||||
if (lbDevices != null && !lbDevices.isEmpty()) {
|
if (lbDevices != null && !lbDevices.isEmpty()) {
|
||||||
|
// return first device that is free, fully configured and meant for dedicated use
|
||||||
//return first device that is free, fully configured and meant for dedicated use
|
|
||||||
for (ExternalLoadBalancerDeviceVO lbdevice : lbDevices) {
|
for (ExternalLoadBalancerDeviceVO lbdevice : lbDevices) {
|
||||||
if (lbdevice.getState() == LBDeviceState.Enabled && lbdevice.getIsDedicatedDevice()) {
|
if (lbdevice.getState() == LBDeviceState.Enabled && lbdevice.getIsDedicatedDevice()) {
|
||||||
return lbdevice;
|
return lbdevice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if there are no dedicated lb device then return first device that is free, fully configured
|
|
||||||
for (ExternalLoadBalancerDeviceVO lbdevice : lbDevices) {
|
|
||||||
if (lbdevice.getState() == LBDeviceState.Enabled) {
|
|
||||||
return lbdevice;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// get the LB devices that are already allocated for shared use
|
// get the LB devices that are already allocated for shared use
|
||||||
@ -354,33 +371,36 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip if the device is intended to be used in dedicated mode only
|
// get the used capacity from the list of guest networks that are mapped to this load balancer
|
||||||
if (lbdevice.getIsDedicatedDevice()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<NetworkExternalLoadBalancerVO> mappedNetworks = _networkExternalLBDao.listByLoadBalancerDeviceId(lbdevice.getId());
|
List<NetworkExternalLoadBalancerVO> mappedNetworks = _networkExternalLBDao.listByLoadBalancerDeviceId(lbdevice.getId());
|
||||||
// get the list of guest networks that are mapped to this load balancer
|
|
||||||
long usedCapacity = ((mappedNetworks == null) || (mappedNetworks.isEmpty()))? 0 : mappedNetworks.size();
|
long usedCapacity = ((mappedNetworks == null) || (mappedNetworks.isEmpty()))? 0 : mappedNetworks.size();
|
||||||
// get max number of guest networks that can be mapped to this device
|
|
||||||
|
// get the configured capacity for this device
|
||||||
long fullCapacity = lbdevice.getCapacity();
|
long fullCapacity = lbdevice.getCapacity();
|
||||||
|
if (fullCapacity == 0) {
|
||||||
|
fullCapacity = _defaultLbCapacity; // if capacity not configured then use the default
|
||||||
|
}
|
||||||
|
|
||||||
long freeCapacity = fullCapacity - usedCapacity;
|
long freeCapacity = fullCapacity - usedCapacity;
|
||||||
if (freeCapacity > 0) {
|
if (freeCapacity > 0) {
|
||||||
if (maxFreeCapacityLbdevice == null) {
|
if (maxFreeCapacityLbdevice == null) {
|
||||||
maxFreeCapacityLbdevice = lbdevice;
|
maxFreeCapacityLbdevice = lbdevice;
|
||||||
maxFreeCapacity = freeCapacity;
|
maxFreeCapacity = freeCapacity;
|
||||||
}
|
} else if (freeCapacity > maxFreeCapacity) {
|
||||||
if (freeCapacity > maxFreeCapacity) {
|
|
||||||
maxFreeCapacityLbdevice = lbdevice;
|
maxFreeCapacityLbdevice = lbdevice;
|
||||||
maxFreeCapacity = freeCapacity;
|
maxFreeCapacity = freeCapacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return the device with maximum free capacity and is meant for shared use
|
||||||
|
if (maxFreeCapacityLbdevice != null) {
|
||||||
|
return maxFreeCapacityLbdevice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we are here then there are no existing LB devices in shared use or the devices in shared use has no free capacity
|
// if we are here then there are no existing LB devices in shared use or the devices in shared use has no free capacity left
|
||||||
// so allocate a new one from the pool of free LB devices
|
// so allocate a new load balancer configured for shared use from the pool of free LB devices
|
||||||
lbDevices = _externalLoadBalancerDeviceDao.listByProviderAndDeviceAllocationState(physicalNetworkId, provider, LBDeviceAllocationState.Free);
|
lbDevices = _externalLoadBalancerDeviceDao.listByProviderAndDeviceAllocationState(physicalNetworkId, provider, LBDeviceAllocationState.Free);
|
||||||
if (lbDevices != null && !lbDevices.isEmpty()) {
|
if (lbDevices != null && !lbDevices.isEmpty()) {
|
||||||
for (ExternalLoadBalancerDeviceVO lbdevice : lbDevices) {
|
for (ExternalLoadBalancerDeviceVO lbdevice : lbDevices) {
|
||||||
@ -391,6 +411,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// there are no devices which capcity
|
||||||
throw new InsufficientNetworkCapacityException("Unable to find a load balancing provider with sufficient capcity " +
|
throw new InsufficientNetworkCapacityException("Unable to find a load balancing provider with sufficient capcity " +
|
||||||
" to implement the network", Network.class, network.getId());
|
" to implement the network", Network.class, network.getId());
|
||||||
}
|
}
|
||||||
@ -614,9 +635,9 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||||||
// FIXME: should the device allocation be done during network implement phase or do a lazy allocation
|
// FIXME: should the device allocation be done during network implement phase or do a lazy allocation
|
||||||
// when first rule for the network is configured??
|
// when first rule for the network is configured??
|
||||||
|
|
||||||
// find a load balancer device as per the network offering
|
|
||||||
boolean dedicatedLB = offering.getDedicatedLB();
|
boolean dedicatedLB = offering.getDedicatedLB();
|
||||||
try {
|
try {
|
||||||
|
// find a load balancer device for this network as per the network offering
|
||||||
ExternalLoadBalancerDeviceVO lbDevice = findSuitableLoadBalancerForNetwork(guestConfig, dedicatedLB);
|
ExternalLoadBalancerDeviceVO lbDevice = findSuitableLoadBalancerForNetwork(guestConfig, dedicatedLB);
|
||||||
lbDeviceId = lbDevice.getId();
|
lbDeviceId = lbDevice.getId();
|
||||||
|
|
||||||
@ -763,6 +784,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
|
|||||||
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("ExternalNetworkMonitor"));
|
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("ExternalNetworkMonitor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_defaultLbCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalLoadBalancerCapacity.key()), 50);
|
||||||
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
|
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public class ExternalLoadBalancerDeviceVO {
|
|||||||
@Column(name = "device_name")
|
@Column(name = "device_name")
|
||||||
private String deviceName;
|
private String deviceName;
|
||||||
|
|
||||||
@Column(name="state")
|
@Column(name="device_state")
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(value=EnumType.STRING)
|
||||||
private LBDeviceState state;
|
private LBDeviceState state;
|
||||||
|
|
||||||
@ -105,6 +105,7 @@ public class ExternalLoadBalancerDeviceVO {
|
|||||||
this.isDedicatedDevice = dedicated;
|
this.isDedicatedDevice = dedicated;
|
||||||
this.isInlineMode = inline;
|
this.isInlineMode = inline;
|
||||||
this.isManagedDevice = false;
|
this.isManagedDevice = false;
|
||||||
|
this.state = LBDeviceState.Enabled;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
|
|
||||||
if (device_name.equalsIgnoreCase(ExternalNetworkDeviceManager.NetworkDevice.NetscalerSDXLoadBalancer.getName())) {
|
if (device_name.equalsIgnoreCase(ExternalNetworkDeviceManager.NetworkDevice.NetscalerSDXLoadBalancer.getName())) {
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class ExternalFirewallDeviceDaoImpl extends GenericDaoBase<ExternalFirewa
|
|||||||
deviceStatusSearch = createSearchBuilder();
|
deviceStatusSearch = createSearchBuilder();
|
||||||
deviceStatusSearch.and("physicalNetworkId", deviceStatusSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
deviceStatusSearch.and("physicalNetworkId", deviceStatusSearch.entity().getPhysicalNetworkId(), Op.EQ);
|
||||||
deviceStatusSearch.and("providerName", deviceStatusSearch.entity().getProviderName(), Op.EQ);
|
deviceStatusSearch.and("providerName", deviceStatusSearch.entity().getProviderName(), Op.EQ);
|
||||||
deviceStatusSearch.and("deviceState", deviceStatusSearch.entity().getState(), Op.EQ);
|
deviceStatusSearch.and("deviceState", deviceStatusSearch.entity().getDeviceState(), Op.EQ);
|
||||||
deviceStatusSearch.done();
|
deviceStatusSearch.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -83,7 +83,6 @@ import com.cloud.vm.ReservationContext;
|
|||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.VirtualMachineProfile;
|
import com.cloud.vm.VirtualMachineProfile;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Local(value=NetworkElement.class)
|
@Local(value=NetworkElement.class)
|
||||||
public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, F5ExternalLoadBalancerElementService, ExternalLoadBalancerDeviceManager {
|
public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, F5ExternalLoadBalancerElementService, ExternalLoadBalancerDeviceManager {
|
||||||
|
|
||||||
|
|||||||
@ -288,7 +288,7 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
|||||||
// true if at-least one SRX device is added in to physical network and is in configured (in enabled state) state
|
// true if at-least one SRX device is added in to physical network and is in configured (in enabled state) state
|
||||||
if (fwDevices != null && !fwDevices.isEmpty()) {
|
if (fwDevices != null && !fwDevices.isEmpty()) {
|
||||||
for (ExternalFirewallDeviceVO fwDevice : fwDevices) {
|
for (ExternalFirewallDeviceVO fwDevice : fwDevices) {
|
||||||
if (fwDevice.getState() == FirewallDeviceState.Enabled) {
|
if (fwDevice.getDeviceState() == FirewallDeviceState.Enabled) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fwDeviceVO.setState(FirewallDeviceState.Enabled);
|
fwDeviceVO.setDeviceState(FirewallDeviceState.Enabled);
|
||||||
_fwDevicesDao.update(fwDeviceId, fwDeviceVO);
|
_fwDevicesDao.update(fwDeviceId, fwDeviceVO);
|
||||||
return fwDeviceVO;
|
return fwDeviceVO;
|
||||||
}
|
}
|
||||||
@ -488,7 +488,7 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
|||||||
response.setDeviceName(fwDeviceVO.getDeviceName());
|
response.setDeviceName(fwDeviceVO.getDeviceName());
|
||||||
response.setDeviceCapacity(fwDeviceVO.getCapacity());
|
response.setDeviceCapacity(fwDeviceVO.getCapacity());
|
||||||
response.setProvider(fwDeviceVO.getProviderName());
|
response.setProvider(fwDeviceVO.getProviderName());
|
||||||
response.setDeviceState(fwDeviceVO.getState().name());
|
response.setDeviceState(fwDeviceVO.getDeviceState().name());
|
||||||
response.setIpAddress(fwHost.getPrivateIpAddress());
|
response.setIpAddress(fwHost.getPrivateIpAddress());
|
||||||
response.setPublicInterface(fwDetails.get("publicInterface"));
|
response.setPublicInterface(fwDetails.get("publicInterface"));
|
||||||
response.setUsageInterface(fwDetails.get("usageInterface"));
|
response.setUsageInterface(fwDetails.get("usageInterface"));
|
||||||
|
|||||||
@ -234,21 +234,19 @@ public class NetscalerExternalLoadBalancerElement extends ExternalLoadBalancerDe
|
|||||||
throw new InvalidParameterValueException("No netscaler device found with ID: " + lbDeviceId);
|
throw new InvalidParameterValueException("No netscaler device found with ID: " + lbDeviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dedicatedUse != null || capacity != null || inline != null) {
|
|
||||||
|
|
||||||
String deviceName = lbDeviceVo.getDeviceName();
|
String deviceName = lbDeviceVo.getDeviceName();
|
||||||
if (NetworkDevice.NetscalerSDXLoadBalancer.getName().equalsIgnoreCase(deviceName)) {
|
if (dedicatedUse != null || capacity != null || inline != null) {
|
||||||
// FIXME: how to interpret SDX device capacity
|
if (NetworkDevice.NetscalerSDXLoadBalancer.getName().equalsIgnoreCase(deviceName) ||
|
||||||
} else if (NetworkDevice.NetscalerMPXLoadBalancer.getName().equalsIgnoreCase(deviceName)) {
|
NetworkDevice.NetscalerMPXLoadBalancer.getName().equalsIgnoreCase(deviceName)) {
|
||||||
if (dedicatedUse != null && dedicatedUse == true) {
|
if (dedicatedUse != null && dedicatedUse == true) {
|
||||||
throw new InvalidParameterValueException("Netscaler MPX device should be shared and can not be dedicated to a single accoutnt.");
|
throw new InvalidParameterValueException("Netscaler MPX and SDX device should be shared and can not be dedicated to a single account.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if any networks are using this netscaler device
|
// check if any networks are using this netscaler device
|
||||||
List<NetworkExternalLoadBalancerVO> networks = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
|
List<NetworkExternalLoadBalancerVO> networks = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
|
||||||
if ((networks != null) && !networks.isEmpty()) {
|
if ((networks != null) && !networks.isEmpty()) {
|
||||||
if (capacity < networks.size()) {
|
if (capacity != null && capacity < networks.size()) {
|
||||||
throw new CloudRuntimeException("There are more number of networks already using this netscaler device than configured capacity");
|
throw new CloudRuntimeException("There are more number of networks already using this netscaler device than configured capacity");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,9 +263,13 @@ public class NetscalerExternalLoadBalancerElement extends ExternalLoadBalancerDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!NetworkDevice.NetscalerSDXLoadBalancer.getName().equalsIgnoreCase(deviceName)) {
|
||||||
if (capacity != null) {
|
if (capacity != null) {
|
||||||
lbDeviceVo.setCapacity(capacity);
|
lbDeviceVo.setCapacity(capacity);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// FIXME how to interpret configured capacity of the SDX device
|
||||||
|
}
|
||||||
|
|
||||||
if(dedicatedUse != null) {
|
if(dedicatedUse != null) {
|
||||||
lbDeviceVo.setIsDedicatedDevice(dedicatedUse);
|
lbDeviceVo.setIsDedicatedDevice(dedicatedUse);
|
||||||
@ -284,9 +286,9 @@ public class NetscalerExternalLoadBalancerElement extends ExternalLoadBalancerDe
|
|||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
txn.start();
|
||||||
|
|
||||||
lbDeviceVo.setState(LBDeviceState.Enabled);
|
|
||||||
_lbDeviceDao.update(lbDeviceId, lbDeviceVo);
|
_lbDeviceDao.update(lbDeviceId, lbDeviceVo);
|
||||||
|
|
||||||
|
// FIXME get the row lock to avoid race condition
|
||||||
_detailsDao.persist(lbDeviceVo.getHostId(), lbDetails);
|
_detailsDao.persist(lbDeviceVo.getHostId(), lbDetails);
|
||||||
HostVO host = _hostDao.findById(lbDeviceVo.getHostId());
|
HostVO host = _hostDao.findById(lbDeviceVo.getHostId());
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|||||||
@ -1948,13 +1948,13 @@ CREATE TABLE `cloud`.`external_load_balancer_devices` (
|
|||||||
`provider_name` varchar(255) NOT NULL COMMENT 'Service Provider name corresponding to this load balancer device',
|
`provider_name` varchar(255) NOT NULL COMMENT 'Service Provider name corresponding to this load balancer device',
|
||||||
`device_name` varchar(255) NOT NULL COMMENT 'name of the load balancer device',
|
`device_name` varchar(255) NOT NULL COMMENT 'name of the load balancer device',
|
||||||
`capacity` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Capacity of the load balancer device',
|
`capacity` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Capacity of the load balancer device',
|
||||||
`state` varchar(32) NOT NULL DEFAULT 'Disabled' COMMENT 'state (enabled/disabled/shutdown) of the device',
|
`device_state` varchar(32) NOT NULL DEFAULT 'Disabled' COMMENT 'state (enabled/disabled/shutdown) of the device',
|
||||||
`allocation_state` varchar(32) NOT NULL DEFAULT 'Free' COMMENT 'Allocation state (Free/Shared/Dedicated/Provider) of the device',
|
`allocation_state` varchar(32) NOT NULL DEFAULT 'Free' COMMENT 'Allocation state (Free/Shared/Dedicated/Provider) of the device',
|
||||||
`is_dedicated` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if device/appliance meant for dedicated use only',
|
`is_dedicated` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if device/appliance is provisioned for dedicated use only',
|
||||||
`is_inline` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if netscaler load balancer to be used in in-line configuration with firewall',
|
`is_inline` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if load balancer will be used in in-line configuration with firewall',
|
||||||
`is_managed` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if device/appliance is provisioned and its life cycle is managed by by cloudstack',
|
`is_managed` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if load balancer appliance is provisioned and its life cycle is managed by by cloudstack',
|
||||||
`host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the external load balancer device',
|
`host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the external load balancer device',
|
||||||
`parent_host_id` bigint unsigned COMMENT 'if the device/appliance is cloudstack managed, then host id on which this device/appliance is provisioned',
|
`parent_host_id` bigint unsigned COMMENT 'if the load balancer appliance is cloudstack managed, then host id on which this appliance is provisioned',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
CONSTRAINT `fk_external_lb_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
|
CONSTRAINT `fk_external_lb_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
|
||||||
CONSTRAINT `fk_external_lb_devices_parent_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
|
CONSTRAINT `fk_external_lb_devices_parent_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE,
|
||||||
@ -1967,7 +1967,7 @@ CREATE TABLE `cloud`.`external_firewall_devices` (
|
|||||||
`physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network in to which firewall device is added',
|
`physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network in to which firewall device is added',
|
||||||
`provider_name` varchar(255) NOT NULL COMMENT 'Service Provider name corresponding to this firewall device',
|
`provider_name` varchar(255) NOT NULL COMMENT 'Service Provider name corresponding to this firewall device',
|
||||||
`device_name` varchar(255) NOT NULL COMMENT 'name of the firewall device',
|
`device_name` varchar(255) NOT NULL COMMENT 'name of the firewall device',
|
||||||
`state` varchar(32) NOT NULL DEFAULT 'Disabled' COMMENT 'state (enabled/disabled/shutdown) of the device',
|
`device_state` varchar(32) NOT NULL DEFAULT 'Disabled' COMMENT 'state (enabled/disabled/shutdown) of the device',
|
||||||
`is_dedicated` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if device/appliance meant for dedicated use only',
|
`is_dedicated` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if device/appliance meant for dedicated use only',
|
||||||
`allocation_state` varchar(32) NOT NULL DEFAULT 'Free' COMMENT 'Allocation state (Free/Allocated) of the device',
|
`allocation_state` varchar(32) NOT NULL DEFAULT 'Free' COMMENT 'Allocation state (Free/Allocated) of the device',
|
||||||
`host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the external firewall device',
|
`host_id` bigint unsigned NOT NULL COMMENT 'host id coresponding to the external firewall device',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user