You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mu...@apache.org on 2012/06/25 18:23:57 UTC
[3/3] moving out F5 code from server into plugins/network-elements/f5/
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java b/server/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java
deleted file mode 100644
index bec0998..0000000
--- a/server/src/com/cloud/api/commands/AddF5LoadBalancerCmd.java
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by the License.
-// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.F5LoadBalancerResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.ExternalLoadBalancerDeviceVO;
-import com.cloud.network.element.F5ExternalLoadBalancerElementService;
-import com.cloud.user.UserContext;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Implementation(responseObject=F5LoadBalancerResponse.class, description="Adds a F5 BigIP load balancer device")
-public class AddF5LoadBalancerCmd extends BaseAsyncCmd {
-
- public static final Logger s_logger = Logger.getLogger(AddF5LoadBalancerCmd.class.getName());
- private static final String s_name = "addf5bigiploadbalancerresponse";
- @PlugService F5ExternalLoadBalancerElementService _f5DeviceManagerService;
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="physical_network")
- @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true, description="the Physical Network ID")
- private Long physicalNetworkId;
-
- @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required = true, description="URL of the F5 load balancer appliance.")
- private String url;
-
- @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required = true, description="Credentials to reach F5 BigIP load balancer device")
- private String username;
-
- @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required = true, description="Credentials to reach F5 BigIP load balancer device")
- private String password;
-
- @Parameter(name = ApiConstants.NETWORK_DEVICE_TYPE, type = CommandType.STRING, required = true, description = "supports only F5BigIpLoadBalancer")
- private String deviceType;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getPhysicalNetworkId() {
- return physicalNetworkId;
- }
-
- public String getUrl() {
- return url;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public String getDeviceType() {
- return deviceType;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
- try {
- ExternalLoadBalancerDeviceVO lbDeviceVO = _f5DeviceManagerService.addF5LoadBalancer(this);
- if (lbDeviceVO != null) {
- F5LoadBalancerResponse response = _f5DeviceManagerService.createF5LoadBalancerResponse(lbDeviceVO);
- response.setObjectName("f5loadbalancer");
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to add F5 Big IP load balancer due to internal error.");
- }
- } catch (InvalidParameterValueException invalidParamExcp) {
- throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
- } catch (CloudRuntimeException runtimeExcp) {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
- }
- }
-
- @Override
- public String getEventDescription() {
- return "Adding a F5 Big Ip load balancer device";
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_EXTERNAL_LB_DEVICE_ADD;
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return UserContext.current().getCaller().getId();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java b/server/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java
deleted file mode 100644
index 20b2e5a..0000000
--- a/server/src/com/cloud/api/commands/ConfigureF5LoadBalancerCmd.java
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by the License.
-// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseAsyncCmd;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.F5LoadBalancerResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.ExternalLoadBalancerDeviceVO;
-import com.cloud.network.element.F5ExternalLoadBalancerElementService;
-import com.cloud.user.UserContext;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Implementation(responseObject=F5LoadBalancerResponse.class, description="configures a F5 load balancer device")
-public class ConfigureF5LoadBalancerCmd extends BaseAsyncCmd {
-
- public static final Logger s_logger = Logger.getLogger(ConfigureF5LoadBalancerCmd.class.getName());
- private static final String s_name = "configuref5Rloadbalancerresponse";
- @PlugService F5ExternalLoadBalancerElementService _f5DeviceManagerService;
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="external_load_balancer_devices")
- @Parameter(name=ApiConstants.LOAD_BALANCER_DEVICE_ID, type=CommandType.LONG, required=true, description="F5 load balancer device ID")
- private Long lbDeviceId;
-
- @Parameter(name=ApiConstants.LOAD_BALANCER_DEVICE_CAPACITY, type=CommandType.LONG, required=false, description="capacity of the device, Capacity will be interpreted as number of networks device can handle")
- private Long capacity;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getLoadBalancerDeviceId() {
- return lbDeviceId;
- }
-
- public Long getLoadBalancerCapacity() {
- return capacity;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
- try {
- ExternalLoadBalancerDeviceVO lbDeviceVO = _f5DeviceManagerService.configureF5LoadBalancer(this);
- if (lbDeviceVO != null) {
- F5LoadBalancerResponse response = _f5DeviceManagerService.createF5LoadBalancerResponse(lbDeviceVO);
- response.setObjectName("f5loadbalancer");
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseAsyncCmd.INTERNAL_ERROR, "Failed to configure F5 load balancer due to internal error.");
- }
- } catch (InvalidParameterValueException invalidParamExcp) {
- throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
- } catch (CloudRuntimeException runtimeExcp) {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
- }
- }
-
- @Override
- public String getEventDescription() {
- return "Configuring a F5 load balancer device";
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_EXTERNAL_LB_DEVICE_CONFIGURE;
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return UserContext.current().getCaller().getId();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/api/commands/DeleteExternalLoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/DeleteExternalLoadBalancerCmd.java b/server/src/com/cloud/api/commands/DeleteExternalLoadBalancerCmd.java
deleted file mode 100644
index c4b903a..0000000
--- a/server/src/com/cloud/api/commands/DeleteExternalLoadBalancerCmd.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by the License.
-// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.network.element.F5ExternalLoadBalancerElementService;
-import com.cloud.user.Account;
-
-@Implementation(description="Deletes a F5 external load balancer appliance added in a zone.", responseObject = SuccessResponse.class)
-@Deprecated // API supported for backward compatibility.
-public class DeleteExternalLoadBalancerCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteExternalLoadBalancerCmd.class.getName());
- private static final String s_name = "deleteexternalloadbalancerresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="host")
- @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required = true, description="Id of the external loadbalancer appliance.")
- private Long id;
-
- ///////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getId() {
- return id;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @PlugService
- F5ExternalLoadBalancerElementService _f5DeviceManagerService;
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- @Override
- public void execute(){
- try {
- boolean result = _f5DeviceManagerService.deleteExternalLoadBalancer(this);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete external load balancer.");
- }
- } catch (InvalidParameterValueException e) {
- throw new ServerApiException(BaseCmd.PARAM_ERROR, "Failed to delete external load balancer.");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java b/server/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java
deleted file mode 100644
index 4fcd734..0000000
--- a/server/src/com/cloud/api/commands/DeleteF5LoadBalancerCmd.java
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by the License.
-// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.BaseAsyncCmd;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.element.F5ExternalLoadBalancerElementService;
-import com.cloud.user.UserContext;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Implementation(responseObject=SuccessResponse.class, description=" delete a F5 load balancer device")
-public class DeleteF5LoadBalancerCmd extends BaseAsyncCmd {
- public static final Logger s_logger = Logger.getLogger(DeleteF5LoadBalancerCmd.class.getName());
- private static final String s_name = "deletef5loadbalancerresponse";
- @PlugService F5ExternalLoadBalancerElementService _f5DeviceManagerService;
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="external_load_balancer_devices")
- @Parameter(name=ApiConstants.LOAD_BALANCER_DEVICE_ID, type=CommandType.LONG, required=true, description="netscaler load balancer device ID")
- private Long lbDeviceId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getLoadBalancerDeviceId() {
- return lbDeviceId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
- try {
- boolean result = _f5DeviceManagerService.deleteF5LoadBalancer(this);
- if (result) {
- SuccessResponse response = new SuccessResponse(getCommandName());
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } else {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete F5 load balancer.");
- }
- } catch (InvalidParameterValueException invalidParamExcp) {
- throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
- } catch (CloudRuntimeException runtimeExcp) {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
- }
- }
-
- @Override
- public String getEventDescription() {
- return "Deleting a F5 load balancer device";
- }
-
- @Override
- public String getEventType() {
- return EventTypes.EVENT_LOAD_BALANCER_DELETE;
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public long getEntityOwnerId() {
- return UserContext.current().getCaller().getId();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java b/server/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java
deleted file mode 100644
index 6551985..0000000
--- a/server/src/com/cloud/api/commands/ListExternalLoadBalancersCmd.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by the License.
-// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseListCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.response.HostResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.host.Host;
-import com.cloud.network.element.F5ExternalLoadBalancerElementService;
-import com.cloud.server.api.response.ExternalLoadBalancerResponse;
-
-@Implementation(description="Lists F5 external load balancer appliances added in a zone.", responseObject = HostResponse.class)
-@Deprecated // API supported for backward compatibility.
-public class ListExternalLoadBalancersCmd extends BaseListCmd {
- public static final Logger s_logger = Logger.getLogger(ListExternalLoadBalancersCmd.class.getName());
- private static final String s_name = "listexternalloadbalancersresponse";
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="data_center")
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="zone Id")
- private long zoneId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public long getZoneId() {
- return zoneId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @PlugService
- F5ExternalLoadBalancerElementService _f5DeviceManagerService;
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- @Override
- public void execute(){
- List<? extends Host> externalLoadBalancers = _f5DeviceManagerService.listExternalLoadBalancers(this);
- ListResponse<ExternalLoadBalancerResponse> listResponse = new ListResponse<ExternalLoadBalancerResponse>();
- List<ExternalLoadBalancerResponse> responses = new ArrayList<ExternalLoadBalancerResponse>();
- for (Host externalLoadBalancer : externalLoadBalancers) {
- ExternalLoadBalancerResponse response = _f5DeviceManagerService.createExternalLoadBalancerResponse(externalLoadBalancer);
- response.setObjectName("externalloadbalancer");
- response.setResponseName(getCommandName());
- responses.add(response);
- }
-
- listResponse.setResponses(responses);
- listResponse.setResponseName(getCommandName());
- this.setResponseObject(listResponse);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java b/server/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java
deleted file mode 100644
index efa71b5..0000000
--- a/server/src/com/cloud/api/commands/ListF5LoadBalancerNetworksCmd.java
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by the License.
-// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.BaseListCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.ListResponse;
-import com.cloud.api.response.NetworkResponse;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.Network;
-import com.cloud.network.element.F5ExternalLoadBalancerElementService;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Implementation(responseObject=NetworkResponse.class, description="lists network that are using a F5 load balancer device")
-public class ListF5LoadBalancerNetworksCmd extends BaseListCmd {
-
- public static final Logger s_logger = Logger.getLogger(ListF5LoadBalancerNetworksCmd.class.getName());
- private static final String s_name = "listf5loadbalancernetworksresponse";
- @PlugService F5ExternalLoadBalancerElementService _f5DeviceManagerService;
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="external_load_balancer_devices")
- @Parameter(name=ApiConstants.LOAD_BALANCER_DEVICE_ID, type=CommandType.LONG, required = true, description="f5 load balancer device ID")
- private Long lbDeviceId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getLoadBalancerDeviceId() {
- return lbDeviceId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
- try {
- List<? extends Network> networks = _f5DeviceManagerService.listNetworks(this);
- ListResponse<NetworkResponse> response = new ListResponse<NetworkResponse>();
- List<NetworkResponse> networkResponses = new ArrayList<NetworkResponse>();
-
- if (networks != null && !networks.isEmpty()) {
- for (Network network : networks) {
- NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(network);
- networkResponses.add(networkResponse);
- }
- }
-
- response.setResponses(networkResponses);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } catch (InvalidParameterValueException invalidParamExcp) {
- throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
- } catch (CloudRuntimeException runtimeExcp) {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
- }
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/api/commands/ListF5LoadBalancersCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/ListF5LoadBalancersCmd.java b/server/src/com/cloud/api/commands/ListF5LoadBalancersCmd.java
deleted file mode 100644
index 228bab5..0000000
--- a/server/src/com/cloud/api/commands/ListF5LoadBalancersCmd.java
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by the License.
-// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiConstants;
-import com.cloud.api.BaseCmd;
-import com.cloud.api.BaseListCmd;
-import com.cloud.api.IdentityMapper;
-import com.cloud.api.Implementation;
-import com.cloud.api.Parameter;
-import com.cloud.api.PlugService;
-import com.cloud.api.ServerApiException;
-import com.cloud.api.response.F5LoadBalancerResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.ExternalLoadBalancerDeviceVO;
-import com.cloud.network.element.F5ExternalLoadBalancerElementService;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Implementation(responseObject=F5LoadBalancerResponse.class, description="lists F5 load balancer devices")
-public class ListF5LoadBalancersCmd extends BaseListCmd {
- public static final Logger s_logger = Logger.getLogger(ListF5LoadBalancersCmd.class.getName());
- private static final String s_name = "listf5loadbalancerresponse";
- @PlugService F5ExternalLoadBalancerElementService _f5DeviceManagerService;
-
- /////////////////////////////////////////////////////
- //////////////// API parameters /////////////////////
- /////////////////////////////////////////////////////
-
- @IdentityMapper(entityTableName="physical_network")
- @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="the Physical Network ID")
- private Long physicalNetworkId;
-
- @IdentityMapper(entityTableName="external_load_balancer_devices")
- @Parameter(name=ApiConstants.LOAD_BALANCER_DEVICE_ID, type=CommandType.LONG, description="f5 load balancer device ID")
- private Long lbDeviceId;
-
- /////////////////////////////////////////////////////
- /////////////////// Accessors ///////////////////////
- /////////////////////////////////////////////////////
-
- public Long getLoadBalancerDeviceId() {
- return lbDeviceId;
- }
-
- public Long getPhysicalNetworkId() {
- return physicalNetworkId;
- }
-
- /////////////////////////////////////////////////////
- /////////////// API Implementation///////////////////
- /////////////////////////////////////////////////////
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
- try {
- List<ExternalLoadBalancerDeviceVO> lbDevices = _f5DeviceManagerService.listF5LoadBalancers(this);
- ListResponse<F5LoadBalancerResponse> response = new ListResponse<F5LoadBalancerResponse>();
- List<F5LoadBalancerResponse> lbDevicesResponse = new ArrayList<F5LoadBalancerResponse>();
-
- if (lbDevices != null && !lbDevices.isEmpty()) {
- for (ExternalLoadBalancerDeviceVO lbDeviceVO : lbDevices) {
- F5LoadBalancerResponse lbdeviceResponse = _f5DeviceManagerService.createF5LoadBalancerResponse(lbDeviceVO);
- lbDevicesResponse.add(lbdeviceResponse);
- }
- }
-
- response.setResponses(lbDevicesResponse);
- response.setResponseName(getCommandName());
- this.setResponseObject(response);
- } catch (InvalidParameterValueException invalidParamExcp) {
- throw new ServerApiException(BaseCmd.PARAM_ERROR, invalidParamExcp.getMessage());
- } catch (CloudRuntimeException runtimeExcp) {
- throw new ServerApiException(BaseCmd.INTERNAL_ERROR, runtimeExcp.getMessage());
- }
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/configuration/DefaultComponentLibrary.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
index 2da9612..97cb6aa 100755
--- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java
+++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
@@ -96,8 +96,6 @@ import com.cloud.network.dao.VirtualRouterProviderDaoImpl;
import com.cloud.network.dao.VpnUserDaoImpl;
import com.cloud.network.element.CiscoNexusVSMElement;
import com.cloud.network.element.CiscoNexusVSMElementService;
-import com.cloud.network.element.F5ExternalLoadBalancerElement;
-import com.cloud.network.element.F5ExternalLoadBalancerElementService;
import com.cloud.network.element.JuniperSRXExternalFirewallElement;
import com.cloud.network.element.JuniperSRXFirewallElementService;
import com.cloud.network.element.VirtualRouterElement;
@@ -416,7 +414,6 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
protected void populateServices() {
addService("VirtualRouterElementService", VirtualRouterElementService.class, VirtualRouterElement.class);
- addService("F5LoadBalancerElementService", F5ExternalLoadBalancerElementService.class, F5ExternalLoadBalancerElement.class);
addService("JuniperSRXFirewallElementService", JuniperSRXFirewallElementService.class, JuniperSRXExternalFirewallElement.class);
addService("CiscoNexusVSMElementService", CiscoNexusVSMElementService.class, CiscoNexusVSMElement.class);
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
index f0f403e..640b216 100755
--- a/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
+++ b/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
@@ -54,9 +54,7 @@ import com.cloud.network.dao.NetworkExternalLoadBalancerDao;
import com.cloud.network.dao.PhysicalNetworkDao;
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
import com.cloud.network.dao.VpnUserDao;
-import com.cloud.network.element.F5ExternalLoadBalancerElementService;
import com.cloud.network.element.JuniperSRXFirewallElementService;
-import com.cloud.network.resource.F5BigIpResource;
import com.cloud.network.resource.JuniperSrxResource;
import com.cloud.network.rules.dao.PortForwardingRulesDao;
import com.cloud.offerings.dao.NetworkOfferingDao;
@@ -104,7 +102,6 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
@Inject NetworkExternalLoadBalancerDao _networkExternalLBDao;
@Inject NetworkExternalFirewallDao _networkExternalFirewallDao;
- @PlugService F5ExternalLoadBalancerElementService _f5LbElementService;
@PlugService JuniperSRXFirewallElementService _srxElementService;
ScheduledExecutorService _executor;
@@ -184,19 +181,6 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
} else {
throw new CloudRuntimeException("Failed to add SRX firewall device due to internal error");
}
- } else if (cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
- Long physicalNetworkId = (params.get(ApiConstants.PHYSICAL_NETWORK_ID)==null)?Long.parseLong((String)params.get(ApiConstants.PHYSICAL_NETWORK_ID)):null;
- String url = (String) params.get(ApiConstants.URL);
- String username = (String) params.get(ApiConstants.USERNAME);
- String password = (String) params.get(ApiConstants.PASSWORD);
- ExternalLoadBalancerDeviceManager lbDeviceMgr = (ExternalLoadBalancerDeviceManager) _f5LbElementService;
- ExternalLoadBalancerDeviceVO lbDeviceVO = lbDeviceMgr.addExternalLoadBalancer(physicalNetworkId, url, username, password,
- cmd.getDeviceType(), (ServerResource) new F5BigIpResource());
- if (lbDeviceVO != null) {
- return _hostDao.findById(lbDeviceVO.getHostId());
- } else {
- throw new CloudRuntimeException("Failed to add Netscaler load balancer device due to internal error");
- }
} else {
throw new CloudRuntimeException("Unsupported network device type:" + cmd.getDeviceType());
}
@@ -229,9 +213,6 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
} else {
throw new CloudRuntimeException("Unsupported PXE server type:" + pxeType);
}
- } else if (host.getType() == Host.Type.ExternalLoadBalancer) {
- ExternalLoadBalancerDeviceManager lbDeviceMgr = (ExternalLoadBalancerDeviceManager) _f5LbElementService;
- response = _f5LbElementService.createExternalLoadBalancerResponse(host);
} else if (host.getType() == Host.Type.ExternalFirewall) {
response = _srxElementService.createExternalFirewallResponse(host);
} else {
@@ -278,14 +259,6 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
Long zoneId = Long.parseLong((String) params.get(ApiConstants.ZONE_ID));
Long podId = Long.parseLong((String)params.get(ApiConstants.POD_ID));
res = listNetworkDevice(zoneId, null, podId, Host.Type.PxeServer);
- } else if (cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.NetscalerMPXLoadBalancer.getName()) ||
- cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.NetscalerVPXLoadBalancer.getName()) ||
- cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.NetscalerSDXLoadBalancer.getName()) ||
- cmd.getDeviceType().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
- Long zoneId = Long.parseLong((String) params.get(ApiConstants.ZONE_ID));
- Long physicalNetworkId = (params.get(ApiConstants.PHYSICAL_NETWORK_ID)==null)?Long.parseLong((String)params.get(ApiConstants.PHYSICAL_NETWORK_ID)):null;
- ExternalLoadBalancerDeviceManager lbDeviceMgr = (ExternalLoadBalancerDeviceManager) _f5LbElementService;
- return lbDeviceMgr.listExternalLoadBalancers(physicalNetworkId, cmd.getDeviceType());
} else if (NetworkDevice.JuniperSRXFirewall.getName().equalsIgnoreCase(cmd.getDeviceType())) {
Long zoneId = Long.parseLong((String) params.get(ApiConstants.ZONE_ID));
Long physicalNetworkId = (params.get(ApiConstants.PHYSICAL_NETWORK_ID)==null)?Long.parseLong((String)params.get(ApiConstants.PHYSICAL_NETWORK_ID)):null;
@@ -315,10 +288,7 @@ public class ExternalNetworkDeviceManagerImpl implements ExternalNetworkDeviceMa
@Override
public boolean deleteNetworkDevice(DeleteNetworkDeviceCmd cmd) {
HostVO device = _hostDao.findById(cmd.getId());
- if (device.getType() == Type.ExternalLoadBalancer) {
- ExternalLoadBalancerDeviceManager lbDeviceMgr = (ExternalLoadBalancerDeviceManager) _f5LbElementService;
- return lbDeviceMgr.deleteExternalLoadBalancer(cmd.getId());
- } else if (device.getType() == Type.ExternalLoadBalancer) {
+ if (device.getType() == Type.ExternalFirewall) {
ExternalFirewallDeviceManager fwDeviceManager = (ExternalFirewallDeviceManager) _srxElementService;
return fwDeviceManager.deleteExternalFirewall(cmd.getId());
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java b/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
deleted file mode 100644
index 1b1cbf7..0000000
--- a/server/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
+++ /dev/null
@@ -1,470 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by the License.
-// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.network.element;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.commands.AddExternalLoadBalancerCmd;
-import com.cloud.api.commands.AddF5LoadBalancerCmd;
-import com.cloud.api.commands.ConfigureF5LoadBalancerCmd;
-import com.cloud.api.commands.DeleteExternalLoadBalancerCmd;
-import com.cloud.api.commands.DeleteF5LoadBalancerCmd;
-import com.cloud.api.commands.ListExternalLoadBalancersCmd;
-import com.cloud.api.commands.ListF5LoadBalancerNetworksCmd;
-import com.cloud.api.commands.ListF5LoadBalancersCmd;
-import com.cloud.api.response.F5LoadBalancerResponse;
-import com.cloud.configuration.Config;
-import com.cloud.configuration.ConfigurationManager;
-import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InsufficientNetworkCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.host.dao.HostDao;
-import com.cloud.host.dao.HostDetailsDao;
-import com.cloud.network.ExternalLoadBalancerDeviceManager;
-import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl;
-import com.cloud.network.ExternalLoadBalancerDeviceVO;
-import com.cloud.network.ExternalLoadBalancerDeviceVO.LBDeviceState;
-import com.cloud.network.ExternalNetworkDeviceManager.NetworkDevice;
-import com.cloud.network.Network;
-import com.cloud.network.Network.Capability;
-import com.cloud.network.Network.Provider;
-import com.cloud.network.Network.Service;
-import com.cloud.network.NetworkExternalLoadBalancerVO;
-import com.cloud.network.NetworkManager;
-import com.cloud.network.NetworkVO;
-import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.PhysicalNetworkServiceProvider;
-import com.cloud.network.PhysicalNetworkVO;
-import com.cloud.network.PublicIpAddress;
-import com.cloud.network.dao.ExternalLoadBalancerDeviceDao;
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.dao.NetworkExternalLoadBalancerDao;
-import com.cloud.network.dao.NetworkServiceMapDao;
-import com.cloud.network.dao.PhysicalNetworkDao;
-import com.cloud.network.lb.LoadBalancingRule;
-import com.cloud.network.resource.F5BigIpResource;
-import com.cloud.network.rules.LbStickinessMethod;
-import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.resource.ServerResource;
-import com.cloud.server.api.response.ExternalLoadBalancerResponse;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.component.Inject;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-import com.google.gson.Gson;
-
-@Local(value = NetworkElement.class)
-public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, IpDeployer, F5ExternalLoadBalancerElementService, ExternalLoadBalancerDeviceManager {
-
- private static final Logger s_logger = Logger.getLogger(F5ExternalLoadBalancerElement.class);
-
- @Inject
- NetworkManager _networkManager;
- @Inject
- ConfigurationManager _configMgr;
- @Inject
- NetworkServiceMapDao _ntwkSrvcDao;
- @Inject
- DataCenterDao _dcDao;
- @Inject
- PhysicalNetworkDao _physicalNetworkDao;
- @Inject
- HostDao _hostDao;
- @Inject
- ExternalLoadBalancerDeviceDao _lbDeviceDao;
- @Inject
- NetworkExternalLoadBalancerDao _networkLBDao;
- @Inject
- NetworkDao _networkDao;
- @Inject
- HostDetailsDao _detailsDao;
- @Inject
- ConfigurationDao _configDao;
-
- private boolean canHandle(Network config) {
- if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType() != TrafficType.Guest) {
- s_logger.trace("Not handling network with Type " + config.getGuestType() + " and traffic type " + config.getTrafficType());
- return false;
- }
-
- return (_networkManager.isProviderForNetwork(getProvider(), config.getId()) && _ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb, Network.Provider.F5BigIp));
- }
-
- @Override
- public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException,
- InsufficientNetworkCapacityException {
-
- if (!canHandle(guestConfig)) {
- return false;
- }
-
- try {
- return manageGuestNetworkWithExternalLoadBalancer(true, guestConfig);
- } catch (InsufficientCapacityException capacityException) {
- throw new ResourceUnavailableException("There are no F5 load balancer devices with the free capacity for implementing this network", DataCenter.class, guestConfig.getDataCenterId());
- }
- }
-
- @Override
- public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
- InsufficientNetworkCapacityException, ResourceUnavailableException {
- return true;
- }
-
- @Override
- public boolean release(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) {
- return true;
- }
-
- @Override
- public boolean shutdown(Network guestConfig, ReservationContext context, boolean cleanup) throws ResourceUnavailableException, ConcurrentOperationException {
- if (!canHandle(guestConfig)) {
- return false;
- }
-
- try {
- return manageGuestNetworkWithExternalLoadBalancer(false, guestConfig);
- } catch (InsufficientCapacityException capacityException) {
- // TODO: handle out of capacity exception
- return false;
- }
- }
-
- @Override
- public boolean destroy(Network config) {
- return true;
- }
-
- @Override
- public boolean validateLBRule(Network network, LoadBalancingRule rule) {
- return true;
- }
-
- @Override
- public boolean applyLBRules(Network config, List<LoadBalancingRule> rules) throws ResourceUnavailableException {
- if (!canHandle(config)) {
- return false;
- }
-
- return applyLoadBalancerRules(config, rules);
- }
-
- @Override
- public Map<Service, Map<Capability, String>> getCapabilities() {
- Map<Service, Map<Capability, String>> capabilities = new HashMap<Service, Map<Capability, String>>();
-
- // Set capabilities for LB service
- Map<Capability, String> lbCapabilities = new HashMap<Capability, String>();
-
- // Specifies that the RoundRobin and Leastconn algorithms are supported for load balancing rules
- lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn");
-
- // specifies that F5 BIG IP network element can provide shared mode only
- lbCapabilities.put(Capability.SupportedLBIsolation, "dedicated, shared");
-
- // Specifies that load balancing rules can be made for either TCP or UDP traffic
- lbCapabilities.put(Capability.SupportedProtocols, "tcp,udp");
-
- // Specifies that this element can measure network usage on a per public IP basis
- lbCapabilities.put(Capability.TrafficStatistics, "per public ip");
-
- // Specifies that load balancing rules can only be made with public IPs that aren't source NAT IPs
- lbCapabilities.put(Capability.LoadBalancingSupportedIps, "additional");
-
- LbStickinessMethod method;
- List<LbStickinessMethod> methodList = new ArrayList<LbStickinessMethod>();
- method = new LbStickinessMethod(StickinessMethodType.LBCookieBased, "This is cookie based sticky method, can be used only for http");
- methodList.add(method);
- method.addParam("holdtime", false, "time period (in seconds) for which persistence is in effect.", false);
-
- Gson gson = new Gson();
- String stickyMethodList = gson.toJson(methodList);
- lbCapabilities.put(Capability.SupportedStickinessMethods, stickyMethodList);
-
- capabilities.put(Service.Lb, lbCapabilities);
-
- return capabilities;
- }
-
- @Override
- public Provider getProvider() {
- return Provider.F5BigIp;
- }
-
- @Override
- public boolean isReady(PhysicalNetworkServiceProvider provider) {
- List<ExternalLoadBalancerDeviceVO> lbDevices = _lbDeviceDao.listByPhysicalNetworkAndProvider(provider.getPhysicalNetworkId(), Provider.F5BigIp.getName());
-
- // true if at-least one F5 device is added in to physical network and is in configured (in enabled state) state
- if (lbDevices != null && !lbDevices.isEmpty()) {
- for (ExternalLoadBalancerDeviceVO lbDevice : lbDevices) {
- if (lbDevice.getState() == LBDeviceState.Enabled) {
- return true;
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
- ResourceUnavailableException {
- // TODO Auto-generated method stub
- return true;
- }
-
- @Override
- public boolean canEnableIndividualServices() {
- return false;
- }
-
- @Override
- public String getPropertiesFile() {
- return "f5bigip_commands.properties";
- }
-
- @Override
- @Deprecated
- public Host addExternalLoadBalancer(AddExternalLoadBalancerCmd cmd) {
- Long zoneId = cmd.getZoneId();
- DataCenterVO zone = null;
- PhysicalNetworkVO pNetwork = null;
- ExternalLoadBalancerDeviceVO lbDeviceVO = null;
- HostVO lbHost = null;
-
- zone = _dcDao.findById(zoneId);
- if (zone == null) {
- throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
- }
-
- List<PhysicalNetworkVO> physicalNetworks = _physicalNetworkDao.listByZone(zoneId);
- if ((physicalNetworks == null) || (physicalNetworks.size() > 1)) {
- throw new InvalidParameterValueException("There are no physical networks or multiple physical networks configured in zone with ID: "
- + zoneId + " to add this device.");
- }
- pNetwork = physicalNetworks.get(0);
-
- String deviceType = NetworkDevice.F5BigIpLoadBalancer.getName();
- lbDeviceVO = addExternalLoadBalancer(pNetwork.getId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceType, (ServerResource) new F5BigIpResource());
-
- if (lbDeviceVO != null) {
- lbHost = _hostDao.findById(lbDeviceVO.getHostId());
- }
-
- return lbHost;
- }
-
- @Override
- @Deprecated
- public boolean deleteExternalLoadBalancer(DeleteExternalLoadBalancerCmd cmd) {
- return deleteExternalLoadBalancer(cmd.getId());
- }
-
- @Override
- @Deprecated
- public List<Host> listExternalLoadBalancers(ListExternalLoadBalancersCmd cmd) {
- Long zoneId = cmd.getZoneId();
- DataCenterVO zone = null;
- PhysicalNetworkVO pNetwork = null;
-
- if (zoneId != null) {
- zone = _dcDao.findById(zoneId);
- if (zone == null) {
- throw new InvalidParameterValueException("Could not find zone with ID: " + zoneId);
- }
-
- List<PhysicalNetworkVO> physicalNetworks = _physicalNetworkDao.listByZone(zoneId);
- if ((physicalNetworks == null) || (physicalNetworks.size() > 1)) {
- throw new InvalidParameterValueException("There are no physical networks or multiple physical networks configured in zone with ID: "
- + zoneId + " to add this device.");
- }
- pNetwork = physicalNetworks.get(0);
- return listExternalLoadBalancers(pNetwork.getId(), NetworkDevice.F5BigIpLoadBalancer.getName());
- } else {
- throw new InvalidParameterValueException("Zone Id must be specified to list the external load balancers");
- }
- }
-
- @Override
- @Deprecated
- public ExternalLoadBalancerResponse createExternalLoadBalancerResponse(Host externalLb) {
- return super.createExternalLoadBalancerResponse(externalLb);
- }
-
- @Override
- public ExternalLoadBalancerDeviceVO addF5LoadBalancer(AddF5LoadBalancerCmd cmd) {
- String deviceName = cmd.getDeviceType();
- if (!deviceName.equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
- throw new InvalidParameterValueException("Invalid F5 load balancer device type");
- }
-
- return addExternalLoadBalancer(cmd.getPhysicalNetworkId(), cmd.getUrl(), cmd.getUsername(), cmd.getPassword(), deviceName, (ServerResource) new F5BigIpResource());
-
- }
-
- @Override
- public boolean deleteF5LoadBalancer(DeleteF5LoadBalancerCmd cmd) {
- Long lbDeviceId = cmd.getLoadBalancerDeviceId();
-
- ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
- if ((lbDeviceVo == null) || !lbDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
- throw new InvalidParameterValueException("No F5 load balancer device found with ID: " + lbDeviceId);
- }
-
- return deleteExternalLoadBalancer(lbDeviceVo.getHostId());
- }
-
- @Override
- public ExternalLoadBalancerDeviceVO configureF5LoadBalancer(ConfigureF5LoadBalancerCmd cmd) {
- Long lbDeviceId = cmd.getLoadBalancerDeviceId();
- Long capacity = cmd.getLoadBalancerCapacity();
-
- ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
- if ((lbDeviceVo == null) || !lbDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
- throw new InvalidParameterValueException("No F5 load balancer device found with ID: " + lbDeviceId);
- }
-
- if (capacity != null) {
- // check if any networks are using this F5 device
- List<NetworkExternalLoadBalancerVO> networks = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
- if ((networks != null) && !networks.isEmpty()) {
- if (capacity < networks.size()) {
- throw new CloudRuntimeException("There are more number of networks already using this F5 device than configured capacity");
- }
- }
- if (capacity != null) {
- lbDeviceVo.setCapacity(capacity);
- }
- }
-
- lbDeviceVo.setState(LBDeviceState.Enabled);
- _lbDeviceDao.update(lbDeviceId, lbDeviceVo);
- return lbDeviceVo;
- }
-
- @Override
- public List<ExternalLoadBalancerDeviceVO> listF5LoadBalancers(ListF5LoadBalancersCmd cmd) {
- Long physcialNetworkId = cmd.getPhysicalNetworkId();
- Long lbDeviceId = cmd.getLoadBalancerDeviceId();
- PhysicalNetworkVO pNetwork = null;
- List<ExternalLoadBalancerDeviceVO> lbDevices = new ArrayList<ExternalLoadBalancerDeviceVO>();
-
- if (physcialNetworkId == null && lbDeviceId == null) {
- throw new InvalidParameterValueException("Either physical network Id or load balancer device Id must be specified");
- }
-
- if (lbDeviceId != null) {
- ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
- if (lbDeviceVo == null || !lbDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
- throw new InvalidParameterValueException("Could not find F5 load balancer device with ID: " + lbDeviceId);
- }
- lbDevices.add(lbDeviceVo);
- return lbDevices;
- }
-
- if (physcialNetworkId != null) {
- pNetwork = _physicalNetworkDao.findById(physcialNetworkId);
- if (pNetwork == null) {
- throw new InvalidParameterValueException("Could not find phyical network with ID: " + physcialNetworkId);
- }
- lbDevices = _lbDeviceDao.listByPhysicalNetworkAndProvider(physcialNetworkId, Provider.F5BigIp.getName());
- return lbDevices;
- }
-
- return null;
- }
-
- @Override
- public List<? extends Network> listNetworks(ListF5LoadBalancerNetworksCmd cmd) {
- Long lbDeviceId = cmd.getLoadBalancerDeviceId();
- List<NetworkVO> networks = new ArrayList<NetworkVO>();
-
- ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
- if (lbDeviceVo == null || !lbDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.F5BigIpLoadBalancer.getName())) {
- throw new InvalidParameterValueException("Could not find F5 load balancer device with ID " + lbDeviceId);
- }
-
- List<NetworkExternalLoadBalancerVO> networkLbMaps = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
- if (networkLbMaps != null && !networkLbMaps.isEmpty()) {
- for (NetworkExternalLoadBalancerVO networkLbMap : networkLbMaps) {
- NetworkVO network = _networkDao.findById(networkLbMap.getNetworkId());
- networks.add(network);
- }
- }
-
- return networks;
- }
-
- @Override
- public F5LoadBalancerResponse createF5LoadBalancerResponse(ExternalLoadBalancerDeviceVO lbDeviceVO) {
- F5LoadBalancerResponse response = new F5LoadBalancerResponse();
- Host lbHost = _hostDao.findById(lbDeviceVO.getHostId());
- Map<String, String> lbDetails = _detailsDao.findDetails(lbDeviceVO.getHostId());
-
- response.setId(lbDeviceVO.getId());
- response.setIpAddress(lbHost.getPrivateIpAddress());
- response.setPhysicalNetworkId(lbDeviceVO.getPhysicalNetworkId());
- response.setPublicInterface(lbDetails.get("publicInterface"));
- response.setPrivateInterface(lbDetails.get("privateInterface"));
- response.setDeviceName(lbDeviceVO.getDeviceName());
- if (lbDeviceVO.getCapacity() == 0) {
- long defaultLbCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalLoadBalancerCapacity.key()), 50);
- response.setDeviceCapacity(defaultLbCapacity);
- } else {
- response.setDeviceCapacity(lbDeviceVO.getCapacity());
- }
- response.setInlineMode(lbDeviceVO.getIsInLineMode());
- response.setDedicatedLoadBalancer(lbDeviceVO.getIsDedicatedDevice());
- response.setProvider(lbDeviceVO.getProviderName());
- response.setDeviceState(lbDeviceVO.getState().name());
- response.setObjectName("f5loadbalancer");
- return response;
- }
-
- @Override
- public boolean verifyServicesCombination(List<String> services) {
- return true;
- }
-
- @Override
- public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> service) throws ResourceUnavailableException {
- // return true, as IP will be associated as part of LB rule configuration
- return false;
- }
-
- @Override
- public IpDeployer getIpDeployer(Network network) {
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/422c4ce5/server/src/com/cloud/network/element/F5ExternalLoadBalancerElementService.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/F5ExternalLoadBalancerElementService.java b/server/src/com/cloud/network/element/F5ExternalLoadBalancerElementService.java
deleted file mode 100644
index ee288ef..0000000
--- a/server/src/com/cloud/network/element/F5ExternalLoadBalancerElementService.java
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2012 Citrix Systems, Inc. Licensed under the
-// Apache License, Version 2.0 (the "License"); you may not use this
-// file except in compliance with the License. Citrix Systems, Inc.
-// reserves all rights not expressly granted by the License.
-// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.network.element;
-
-import java.util.List;
-
-import com.cloud.api.commands.AddExternalLoadBalancerCmd;
-import com.cloud.api.commands.AddF5LoadBalancerCmd;
-import com.cloud.api.commands.ConfigureF5LoadBalancerCmd;
-import com.cloud.api.commands.DeleteExternalLoadBalancerCmd;
-import com.cloud.api.commands.DeleteF5LoadBalancerCmd;
-import com.cloud.api.commands.ListExternalLoadBalancersCmd;
-import com.cloud.api.commands.ListF5LoadBalancerNetworksCmd;
-import com.cloud.api.commands.ListF5LoadBalancersCmd;
-import com.cloud.api.response.F5LoadBalancerResponse;
-import com.cloud.host.Host;
-import com.cloud.network.ExternalLoadBalancerDeviceVO;
-import com.cloud.network.Network;
-import com.cloud.server.api.response.ExternalLoadBalancerResponse;
-import com.cloud.utils.component.PluggableService;
-
-@SuppressWarnings("deprecation")
-public interface F5ExternalLoadBalancerElementService extends PluggableService {
-
- /**
- * adds a F5 load balancer device in to a physical network
- * @param AddF5LoadBalancerCmd
- * @return ExternalLoadBalancerDeviceVO object for the device added
- */
- public ExternalLoadBalancerDeviceVO addF5LoadBalancer(AddF5LoadBalancerCmd cmd);
-
- /**
- * removes a F5 load balancer device from a physical network
- * @param DeleteF5LoadBalancerCmd
- * @return true if F5 load balancer device is successfully deleted
- */
- public boolean deleteF5LoadBalancer(DeleteF5LoadBalancerCmd cmd);
-
- /**
- * configures a F5 load balancer device added in a physical network
- * @param ConfigureF5LoadBalancerCmd
- * @return ExternalLoadBalancerDeviceVO for the device configured
- */
- public ExternalLoadBalancerDeviceVO configureF5LoadBalancer(ConfigureF5LoadBalancerCmd cmd);
-
- /**
- * lists all the load balancer devices added in to a physical network
- * @param ListF5LoadBalancersCmd
- * @return list of ExternalLoadBalancerDeviceVO for the devices in the physical network.
- */
- public List<ExternalLoadBalancerDeviceVO> listF5LoadBalancers(ListF5LoadBalancersCmd cmd);
-
- /**
- * lists all the guest networks using a F5 load balancer device
- * @param ListF5LoadBalancerNetworksCmd
- * @return list of the guest networks that are using this F5 load balancer
- */
- public List<? extends Network> listNetworks(ListF5LoadBalancerNetworksCmd cmd);
-
- public F5LoadBalancerResponse createF5LoadBalancerResponse(ExternalLoadBalancerDeviceVO lbDeviceVO);
-
- /* Deprecated API helper function */
- @Deprecated // API helper function supported for backward compatibility
- public Host addExternalLoadBalancer(AddExternalLoadBalancerCmd cmd);
-
- @Deprecated // API helper function supported for backward compatibility
- public boolean deleteExternalLoadBalancer(DeleteExternalLoadBalancerCmd cmd);
-
- @Deprecated // API helper function supported for backward compatibility
- public List<Host> listExternalLoadBalancers(ListExternalLoadBalancersCmd cmd);
-
- @Deprecated // API helper function supported for backward compatibility
- public ExternalLoadBalancerResponse createExternalLoadBalancerResponse(Host externalLb);
-}