You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/05/10 02:37:45 UTC
[15/18] CLOUDSTACK-747: Internal LB between VPC tiers support
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java
new file mode 100644
index 0000000..e314b32
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java
@@ -0,0 +1,151 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.api.command.admin.internallb;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.response.VpcResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.network.router.VirtualRouter.Role;
+
+@APICommand(name = "listInternalLoadBalancerVMs", description="List internal LB VMs.", responseObject=DomainRouterResponse.class)
+public class ListInternalLBVMsCmd extends BaseListProjectAndAccountResourcesCmd {
+ public static final Logger s_logger = Logger.getLogger(ListInternalLBVMsCmd.class.getName());
+
+ private static final String s_name = "listinternallbvmssresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType=HostResponse.class,
+ description="the host ID of the Internal LB VM")
+ private Long hostId;
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class,
+ description="the ID of the Internal LB VM")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the Internal LB VM")
+ private String routerName;
+
+ @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
+ description="the Pod ID of the Internal LB VM")
+ private Long podId;
+
+ @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="the state of the Internal LB VM")
+ private String state;
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
+ description="the Zone ID of the Internal LB VM")
+ private Long zoneId;
+
+ @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType=NetworkResponse.class,
+ description="list by network id")
+ private Long networkId;
+
+ @Parameter(name=ApiConstants.VPC_ID, type=CommandType.UUID, entityType=VpcResponse.class,
+ description="List Internal LB VMs by VPC")
+ private Long vpcId;
+
+ @Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC Internal LB VMs")
+ private Boolean forVpc;
+
+ @Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network type of the zone that the virtual machine belongs to")
+ private String zoneType;
+
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getHostId() {
+ return hostId;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getRouterName() {
+ return routerName;
+ }
+
+ public Long getPodId() {
+ return podId;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ public Long getNetworkId() {
+ return networkId;
+ }
+
+ public Long getVpcId() {
+ return vpcId;
+ }
+
+ public Boolean getForVpc() {
+ return forVpc;
+ }
+
+ public String getRole() {
+ return Role.INTERNAL_LB_VM.toString();
+ }
+
+ public String getZoneType() {
+ return zoneType;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.DomainRouter;
+ }
+
+ @Override
+ public void execute(){
+ ListResponse<DomainRouterResponse> response = _queryService.searchForInternalLbVms(this);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java
new file mode 100644
index 0000000..1853619
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java
@@ -0,0 +1,99 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.api.command.admin.internallb;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.ProviderResponse;
+import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.VirtualRouterProvider;
+
+@APICommand(name = "listInternalLoadBalancerElements", description="Lists all available Internal Load Balancer elements.",
+ responseObject=InternalLoadBalancerElementResponse.class, since="4.2.0")
+public class ListInternalLoadBalancerElementsCmd extends BaseListCmd {
+ public static final Logger s_logger = Logger.getLogger(ListInternalLoadBalancerElementsCmd.class.getName());
+ private static final String _name = "listinternalloadbalancerelementsresponse";
+
+ @Inject
+ private InternalLoadBalancerElementService _service;
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = InternalLoadBalancerElementResponse.class,
+ description="list internal load balancer elements by id")
+ private Long id;
+
+ @Parameter(name=ApiConstants.NSP_ID, type=CommandType.UUID, entityType = ProviderResponse.class,
+ description="list internal load balancer elements by network service provider id")
+ private Long nspId;
+
+ @Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, description="list internal load balancer elements by enabled state")
+ private Boolean enabled;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public Long getNspId() {
+ return nspId;
+ }
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ @Override
+ public String getCommandName() {
+ return _name;
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
+ List<? extends VirtualRouterProvider> providers = _service.searchForInternalLoadBalancerElements(getId(), getNspId(), getEnabled());
+ ListResponse<InternalLoadBalancerElementResponse> response = new ListResponse<InternalLoadBalancerElementResponse>();
+ List<InternalLoadBalancerElementResponse> providerResponses = new ArrayList<InternalLoadBalancerElementResponse>();
+ for (VirtualRouterProvider provider : providers) {
+ InternalLoadBalancerElementResponse providerResponse = _responseGenerator.createInternalLbElementResponse(provider);
+ providerResponses.add(providerResponse);
+ }
+ response.setResponses(providerResponses);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
new file mode 100644
index 0000000..31d132b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java
@@ -0,0 +1,120 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.api.command.admin.internallb;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "startInternalLoadBalancerVM", responseObject=DomainRouterResponse.class, description="Starts an existing internal lb vm.")
+public class StartInternalLBVMCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(StartInternalLBVMCmd.class.getName());
+ private static final String s_name = "startinternallbvmresponse";
+
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=DomainRouterResponse.class,
+ required=true, description="the ID of the internal lb vm")
+ private Long id;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public static String getResultObjectName() {
+ return "router";
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ VirtualRouter router = _entityMgr.findById(VirtualRouter.class, getId());
+ if (router != null && router.getRole() == Role.INTERNAL_LB_VM) {
+ return router.getAccountId();
+ } else {
+ throw new InvalidParameterValueException("Unable to find internal lb vm by id");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_INTERNAL_LB_VM_START;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "starting internal lb vm: " + getId();
+ }
+
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.InternalLbVm;
+ }
+
+ public Long getInstanceId() {
+ return getId();
+ }
+
+ @Override
+ public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
+ UserContext.current().setEventDetails("Internal Lb Vm Id: "+getId());
+ VirtualRouter result = null;
+ VirtualRouter router = _routerService.findRouter(getId());
+ if (router == null || router.getRole() != Role.INTERNAL_LB_VM) {
+ throw new InvalidParameterValueException("Can't find internal lb vm by id");
+ } else {
+ result = _internalLbSvc.startInternalLbVm(getId(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
+ }
+
+ if (result != null){
+ DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
+ routerResponse.setResponseName(getCommandName());
+ this.setResponseObject(routerResponse);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start internal lb vm");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
new file mode 100644
index 0000000..f40db49
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java
@@ -0,0 +1,123 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.api.command.admin.internallb;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.DomainRouterResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "stopInternalLoadBalancerVM", description = "Stops an Internal LB vm.", responseObject = DomainRouterResponse.class)
+public class StopInternalLBVMCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(StopInternalLBVMCmd.class.getName());
+ private static final String s_name = "stopinternallbvmresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class,
+ required = true, description = "the ID of the internal lb vm")
+ private Long id;
+
+ @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM. The caller knows the VM is stopped.")
+ private Boolean forced;
+
+ // ///////////////////////////////////////////////////
+ // ///////////////// Accessors ///////////////////////
+ // ///////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ VirtualRouter vm = _entityMgr.findById(VirtualRouter.class, getId());
+ if (vm != null && vm.getRole() == Role.INTERNAL_LB_VM) {
+ return vm.getAccountId();
+ } else {
+ throw new InvalidParameterValueException("Unable to find internal lb vm by id");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_INTERNAL_LB_VM_STOP;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "stopping internal lb vm: " + getId();
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.InternalLbVm;
+ }
+
+ @Override
+ public Long getInstanceId() {
+ return getId();
+ }
+
+ public boolean isForced() {
+ return (forced != null) ? forced : false;
+ }
+
+ @Override
+ public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
+ UserContext.current().setEventDetails("Internal lb vm Id: "+getId());
+ VirtualRouter result = null;
+ VirtualRouter vm = _routerService.findRouter(getId());
+ if (vm == null || vm.getRole() != Role.INTERNAL_LB_VM) {
+ throw new InvalidParameterValueException("Can't find internal lb vm by id");
+ } else {
+ result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), UserContext.current().getCaller(), UserContext.current().getCallerUserId());
+ }
+
+ if (result != null) {
+ DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop internal lb vm");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
index b48bf9e..6410715 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java
@@ -31,7 +31,6 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
-
import org.apache.log4j.Logger;
import com.cloud.exception.InvalidParameterValueException;
@@ -95,6 +94,10 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
@Parameter(name=ApiConstants.IS_PERSISTENT, type=CommandType.BOOLEAN, description="true if network offering supports persistent networks; defaulted to false if not specified")
private Boolean isPersistent;
+
+ @Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, since="4.2.0", description="Template details in key/value pairs." +
+ " Supported keys are internallbprovider/publiclbprovider with service provider as a value")
+ protected Map details;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@@ -215,6 +218,16 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
return capabilityMap;
}
+
+ public Map<String, String> getDetails() {
+ if (details == null || details.isEmpty()) {
+ return null;
+ }
+
+ Collection paramsCollection = details.values();
+ Map<String, String> params = (Map<String, String>) (paramsCollection.toArray())[0];
+ return params;
+ }
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
index 39fac13..b3fca5a 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
@@ -31,6 +31,7 @@ import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.network.VirtualRouterProvider;
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
@@ -52,6 +53,9 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.UUID, entityType = ProviderResponse.class, required=true, description="the network service provider ID of the virtual router element")
private Long nspId;
+
+ @Parameter(name=ApiConstants.PROVIDER_TYPE, type=CommandType.UUID, entityType = ProviderResponse.class, description="The provider type. Supported types are VirtualRouter (default) and VPCVirtualRouter")
+ private String providerType;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@@ -61,16 +65,27 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
this.nspId = nspId;
}
-
-
public Long getNspId() {
return nspId;
}
+
+ public VirtualRouterProviderType getProviderType() {
+ if (providerType != null) {
+ if (providerType.equalsIgnoreCase(VirtualRouterProviderType.VirtualRouter.toString())) {
+ return VirtualRouterProviderType.VirtualRouter;
+ } else if (providerType.equalsIgnoreCase(VirtualRouterProviderType.VPCVirtualRouter.toString())) {
+ return VirtualRouterProviderType.VPCVirtualRouter;
+ } else throw new InvalidParameterValueException("Invalid providerType specified");
+ }
+ return VirtualRouterProviderType.VirtualRouter;
+ }
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
+
+
@Override
public String getCommandName() {
return s_name;
@@ -96,7 +111,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
@Override
public void create() throws ResourceAllocationException {
- VirtualRouterProvider result = _service.get(0).addElement(getNspId(), VirtualRouterProviderType.VirtualRouter);
+ VirtualRouterProvider result = _service.get(0).addElement(getNspId(), getProviderType());
if (result != null) {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
index 9fbc940..78c3554 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java
@@ -31,6 +31,7 @@ import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
+import com.cloud.network.router.VirtualRouter.Role;
@APICommand(name = "listRouters", description="List routers.", responseObject=DomainRouterResponse.class)
public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
@@ -77,7 +78,7 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
@Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC routers")
private Boolean forVpc;
-
+
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@@ -121,6 +122,10 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
public Boolean getForVpc() {
return forVpc;
}
+
+ public String getRole() {
+ return Role.VIRTUAL_ROUTER.toString();
+ }
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
index 1d3930b..ad0461e 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
@@ -29,8 +29,10 @@ import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@@ -100,7 +102,13 @@ public class StartRouterCmd extends BaseAsyncCmd {
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
UserContext.current().setEventDetails("Router Id: "+getId());
- VirtualRouter result = _routerService.startRouter(id);
+ VirtualRouter result = null;
+ VirtualRouter router = _routerService.findRouter(getId());
+ if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
+ throw new InvalidParameterValueException("Can't find router by id");
+ } else {
+ result = _routerService.startRouter(getId());
+ }
if (result != null){
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
routerResponse.setResponseName(getCommandName());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
index 60dd938..94473cf 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
@@ -28,8 +28,10 @@ import org.apache.log4j.Logger;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@@ -103,7 +105,14 @@ public class StopRouterCmd extends BaseAsyncCmd {
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
UserContext.current().setEventDetails("Router Id: "+getId());
- VirtualRouter result = _routerService.stopRouter(getId(), isForced());
+ VirtualRouter result = null;
+ VirtualRouter router = _routerService.findRouter(getId());
+ if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
+ throw new InvalidParameterValueException("Can't find router by id");
+ } else {
+ result = _routerService.stopRouter(getId(), isForced());
+ }
+
if (result != null) {
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
response.setResponseName(getCommandName());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java
new file mode 100644
index 0000000..17ae959
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java
@@ -0,0 +1,218 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.api.command.user.loadbalancer;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InsufficientAddressCapacityException;
+import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.Network;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.user.UserContext;
+import com.cloud.utils.net.NetUtils;
+
+@APICommand(name = "createLoadBalancer", description="Creates a Load Balancer", responseObject=ApplicationLoadBalancerResponse.class, since="4.2.0")
+public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd {
+ public static final Logger s_logger = Logger.getLogger(CreateApplicationLoadBalancerCmd.class.getName());
+
+ private static final String s_name = "createloadbalancerresponse";
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="name of the Load Balancer")
+ private String loadBalancerName;
+
+ @Parameter(name=ApiConstants.DESCRIPTION, type=CommandType.STRING, description="the description of the Load Balancer", length=4096)
+ private String description;
+
+ @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, required=true, entityType = NetworkResponse.class,
+ description="The guest network the Load Balancer will be created for")
+ private Long networkId;
+
+ @Parameter(name=ApiConstants.SOURCE_PORT, type=CommandType.INTEGER, required=true, description="the source port the network traffic will be load balanced from")
+ private Integer sourcePort;
+
+ @Parameter(name=ApiConstants.ALGORITHM, type=CommandType.STRING, required=true, description="load balancer algorithm (source, roundrobin, leastconn)")
+ private String algorithm;
+
+ @Parameter(name=ApiConstants.INSTANCE_PORT, type=CommandType.INTEGER, required=true, description="the TCP port of the virtual machine where the network traffic will be load balanced to")
+ private Integer instancePort;
+
+ @Parameter(name=ApiConstants.SOURCE_IP, type=CommandType.STRING, description="the source ip address the network traffic will be load balanced from")
+ private String sourceIp;
+
+ @Parameter(name=ApiConstants.SOURCE_IP_NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class, required=true,
+ description="the network id of the source ip address")
+ private Long sourceIpNetworkId;
+
+ @Parameter(name=ApiConstants.SCHEME, type=CommandType.STRING, required=true, description="the load balancer scheme. Supported value in this release is Internal")
+ private String scheme;
+
+
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getLoadBalancerName() {
+ return loadBalancerName;
+ }
+
+ public Integer getPrivatePort() {
+ return instancePort;
+ }
+
+ public long getNetworkId() {
+ return networkId;
+ }
+
+ public String getName() {
+ return loadBalancerName;
+ }
+
+ public Integer getSourcePort() {
+ return sourcePort.intValue();
+ }
+
+ public String getProtocol() {
+ return NetUtils.TCP_PROTO;
+ }
+
+ public long getAccountId() {
+ //get account info from the network object
+ Network ntwk = _networkService.getNetwork(networkId);
+ if (ntwk == null) {
+ throw new InvalidParameterValueException("Invalid network id specified");
+ }
+
+ return ntwk.getAccountId();
+
+ }
+
+ public int getInstancePort() {
+ return instancePort.intValue();
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_LOAD_BALANCER_CREATE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "creating load balancer: " + getName() + " account: " + getAccountId();
+
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.LoadBalancerRule;
+ }
+
+ public String getSourceIp() {
+ return sourceIp;
+ }
+
+ public long getSourceIpNetworkId() {
+ return sourceIpNetworkId;
+ }
+
+ public Scheme getScheme() {
+ if (scheme.equalsIgnoreCase(Scheme.Internal.toString())) {
+ return Scheme.Internal;
+ } else {
+ throw new InvalidParameterValueException("Invalid value for scheme. Supported value is Internal");
+ }
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return getAccountId();
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public void execute() throws ResourceAllocationException, ResourceUnavailableException {
+ ApplicationLoadBalancerRule rule = null;
+ try {
+ UserContext.current().setEventDetails("Load Balancer Id: " + getEntityId());
+ // State might be different after the rule is applied, so get new object here
+ rule = _entityMgr.findById(ApplicationLoadBalancerRule.class, getEntityId());
+ ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getEntityId()));
+ setResponseObject(lbResponse);
+ lbResponse.setResponseName(getCommandName());
+ } catch (Exception ex) {
+ s_logger.warn("Failed to create Load Balancer due to exception ", ex);
+ } finally {
+ if (rule == null) {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Load Balancer");
+ }
+ }
+ }
+
+ @Override
+ public void create() {
+ try {
+
+ ApplicationLoadBalancerRule result = _appLbService.createApplicationLoadBalancer(getName(), getDescription(), getScheme(),
+ getSourceIpNetworkId(), getSourceIp(), getSourcePort(), getInstancePort(), getAlgorithm(), getNetworkId(), getEntityOwnerId());
+ this.setEntityId(result.getId());
+ this.setEntityUuid(result.getUuid());
+ }catch (NetworkRuleConflictException e) {
+ s_logger.warn("Exception: ", e);
+ throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
+ } catch (InsufficientAddressCapacityException e) {
+ s_logger.warn("Exception: ", e);
+ throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
+ } catch (InsufficientVirtualNetworkCapcityException e) {
+ s_logger.warn("Exception: ", e);
+ throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage());
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
index 5f1d97b..f6cc1f1 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
@@ -148,7 +148,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
}
- public Long getNetworkId() {
+ public long getNetworkId() {
if (networkId != null) {
return networkId;
}
@@ -278,7 +278,9 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command");
}
try {
- LoadBalancer result = _lbService.createLoadBalancerRule(this, getOpenFirewall());
+ LoadBalancer result = _lbService.createPublicLoadBalancerRule(getXid(), getName(), getDescription(),
+ getSourcePortStart(), getSourcePortEnd(), getDefaultPortStart(), getDefaultPortEnd(), getSourceIpAddressId(), getProtocol(), getAlgorithm(),
+ getNetworkId(), getEntityOwnerId(), getOpenFirewall());
this.setEntityId(result.getId());
this.setEntityUuid(result.getUuid());
} catch (NetworkRuleConflictException e) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java
new file mode 100644
index 0000000..bc6cd09
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java
@@ -0,0 +1,116 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.api.command.user.loadbalancer;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.FirewallRuleResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
+import org.apache.log4j.Logger;
+
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.user.UserContext;
+
+@APICommand(name = "deleteLoadBalancer", description="Deletes a load balancer", responseObject=SuccessResponse.class, since="4.2.0")
+public class DeleteApplicationLoadBalancerCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(DeleteApplicationLoadBalancerCmd.class.getName());
+ private static final String s_name = "deleteloadbalancerresponse";
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = FirewallRuleResponse.class,
+ required=true, description="the ID of the Load Balancer")
+ private Long id;
+
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ ApplicationLoadBalancerRule lb = _entityMgr.findById(ApplicationLoadBalancerRule.class, getId());
+ if (lb != null) {
+ return lb.getAccountId();
+ } else {
+ throw new InvalidParameterValueException("Can't find load balancer by id specified");
+ }
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_LOAD_BALANCER_DELETE;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "deleting load balancer: " + getId();
+ }
+
+ @Override
+ public void execute(){
+ UserContext.current().setEventDetails("Load balancer Id: " + getId());
+ boolean result = _appLbService.deleteApplicationLoadBalancer(getId());
+
+ if (result) {
+ SuccessResponse response = new SuccessResponse(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete load balancer");
+ }
+ }
+
+ @Override
+ public String getSyncObjType() {
+ return BaseAsyncCmd.networkSyncObject;
+ }
+
+ @Override
+ public Long getSyncObjId() {
+ ApplicationLoadBalancerRule lb = _appLbService.getApplicationLoadBalancer(id);
+ if(lb == null){
+ throw new InvalidParameterValueException("Unable to find load balancer by id ");
+ }
+ return lb.getNetworkId();
+ }
+
+ @Override
+ public AsyncJob.Type getInstanceType() {
+ return AsyncJob.Type.FirewallRule;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java
new file mode 100644
index 0000000..8e5df31
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java
@@ -0,0 +1,131 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.api.command.user.loadbalancer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse;
+import org.apache.cloudstack.api.response.FirewallRuleResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.NetworkResponse;
+import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.utils.Pair;
+
+@APICommand(name = "listLoadBalancers", description = "Lists Load Balancers", responseObject = ApplicationLoadBalancerResponse.class, since="4.2.0")
+public class ListApplicationLoadBalancersCmd extends BaseListTaggedResourcesCmd {
+ public static final Logger s_logger = Logger.getLogger(ListApplicationLoadBalancersCmd.class.getName());
+
+ private static final String s_name = "listloadbalancerssresponse";
+
+ // ///////////////////////////////////////////////////
+ // ////////////// API parameters /////////////////////
+ // ///////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class,
+ description = "the ID of the Load Balancer")
+ private Long id;
+
+ @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the Load Balancer")
+ private String loadBalancerName;
+
+ @Parameter(name = ApiConstants.SOURCE_IP, type = CommandType.STRING, description = "the source ip address of the Load Balancer")
+ private String sourceIp;
+
+ @Parameter(name=ApiConstants.SOURCE_IP_NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
+ description="the network id of the source ip address")
+ private Long sourceIpNetworkId;
+
+ @Parameter(name = ApiConstants.SCHEME, type = CommandType.STRING, description = "the scheme of the Load Balancer. Supported value is Internal in the current release")
+ private String scheme;
+
+ @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType = NetworkResponse.class,
+ description="the network id of the Load Balancer")
+ private Long networkId;
+
+
+ // ///////////////////////////////////////////////////
+ // ///////////////// Accessors ///////////////////////
+ // ///////////////////////////////////////////////////
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getLoadBalancerRuleName() {
+ return loadBalancerName;
+ }
+
+ public String getLoadBalancerName() {
+ return loadBalancerName;
+ }
+
+ public String getSourceIp() {
+ return sourceIp;
+ }
+
+ public Long getSourceIpNetworkId() {
+ return sourceIpNetworkId;
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ public Scheme getScheme() {
+ if (scheme != null) {
+ if (scheme.equalsIgnoreCase(Scheme.Internal.toString())) {
+ return Scheme.Internal;
+ } else {
+ throw new InvalidParameterValueException("Invalid value for scheme. Supported value is Internal");
+ }
+ }
+ return null;
+ }
+
+ public Long getNetworkId() {
+ return networkId;
+ }
+ // ///////////////////////////////////////////////////
+ // ///////////// API Implementation///////////////////
+ // ///////////////////////////////////////////////////
+
+ @Override
+ public void execute() {
+ Pair<List<? extends ApplicationLoadBalancerRule>, Integer> loadBalancers = _appLbService.listApplicationLoadBalancers(this);
+ ListResponse<ApplicationLoadBalancerResponse> response = new ListResponse<ApplicationLoadBalancerResponse>();
+ List<ApplicationLoadBalancerResponse> lbResponses = new ArrayList<ApplicationLoadBalancerResponse>();
+ for (ApplicationLoadBalancerRule loadBalancer : loadBalancers.first()) {
+ ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(loadBalancer, _lbService.getLbInstances(loadBalancer.getId()));
+ lbResponse.setObjectName("loadbalancer");
+ lbResponses.add(lbResponse);
+ }
+ response.setResponses(lbResponses, loadBalancers.second());
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java
new file mode 100644
index 0000000..2d6614d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java
@@ -0,0 +1,63 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.api.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ *
+ * Load Balancer instance is the User Vm instance participating in the Load Balancer
+ *
+ */
+
+@SuppressWarnings("unused")
+public class ApplicationLoadBalancerInstanceResponse extends BaseResponse{
+
+ @SerializedName(ApiConstants.ID) @Param(description = "the instance ID")
+ private String id;
+
+ @SerializedName(ApiConstants.NAME) @Param(description = "the name of the instance")
+ private String name;
+
+ @SerializedName(ApiConstants.STATE) @Param(description="the state of the instance")
+ private String state;
+
+ @SerializedName(ApiConstants.IP_ADDRESS)
+ @Param(description="the ip address of the instance")
+ private String ipAddress;
+
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java
new file mode 100644
index 0000000..de9bce6
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java
@@ -0,0 +1,142 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+
+package org.apache.cloudstack.api.response;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+@SuppressWarnings("unused")
+public class ApplicationLoadBalancerResponse extends BaseResponse implements ControlledEntityResponse{
+ @SerializedName(ApiConstants.ID) @Param(description = "the Load Balancer ID")
+ private String id;
+
+ @SerializedName(ApiConstants.NAME) @Param(description = "the name of the Load Balancer")
+ private String name;
+
+ @SerializedName(ApiConstants.DESCRIPTION) @Param(description = "the description of the Load Balancer")
+ private String description;
+
+ @SerializedName(ApiConstants.ALGORITHM) @Param(description = "the load balancer algorithm (source, roundrobin, leastconn)")
+ private String algorithm;
+
+ @SerializedName(ApiConstants.NETWORK_ID) @Param(description="Load Balancer network id")
+ private String networkId;
+
+ @SerializedName(ApiConstants.SOURCE_IP) @Param(description="Load Balancer source ip")
+ private String sourceIp;
+
+ @SerializedName(ApiConstants.SOURCE_IP_NETWORK_ID) @Param(description="Load Balancer source ip network id")
+ private String sourceIpNetworkId;
+
+ @SerializedName(ApiConstants.ACCOUNT)
+ @Param(description = "the account of the Load Balancer")
+ private String accountName;
+
+ @SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the Load Balancer")
+ private String projectId;
+
+ @SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the Load Balancer")
+ private String projectName;
+
+ @SerializedName(ApiConstants.DOMAIN_ID)
+ @Param(description = "the domain ID of the Load Balancer")
+ private String domainId;
+
+ @SerializedName(ApiConstants.DOMAIN)
+ @Param(description = "the domain of the Load Balancer")
+ private String domainName;
+
+ @SerializedName("loadbalancerrule") @Param(description="the list of rules associated with the Load Balancer", responseObject = ApplicationLoadBalancerRuleResponse.class)
+ private List<ApplicationLoadBalancerRuleResponse> lbRules;
+
+ @SerializedName("loadbalancerinstance") @Param(description="the list of instances associated with the Load Balancer", responseObject = ApplicationLoadBalancerInstanceResponse.class)
+ private List<ApplicationLoadBalancerInstanceResponse> lbInstances;
+
+ @SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with the Load Balancer", responseObject = ResourceTagResponse.class)
+ private List<ResourceTagResponse> tags;
+
+ public void setAccountName(String accountName) {
+ this.accountName = accountName;
+ }
+
+ @Override
+ public void setDomainId(String domainId) {
+ this.domainId = domainId;
+ }
+
+ public void setDomainName(String domainName) {
+ this.domainName = domainName;
+ }
+
+ @Override
+ public void setProjectId(String projectId) {
+ this.projectId = projectId;
+ }
+
+ @Override
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public void setTags(List<ResourceTagResponse> tags) {
+ this.tags = tags;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setAlgorithm(String algorithm) {
+ this.algorithm = algorithm;
+ }
+
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ public void setSourceIp(String sourceIp) {
+ this.sourceIp = sourceIp;
+ }
+
+ public void setSourceIpNetworkId(String sourceIpNetworkId) {
+ this.sourceIpNetworkId = sourceIpNetworkId;
+ }
+
+ public void setLbRules(List<ApplicationLoadBalancerRuleResponse> lbRules) {
+ this.lbRules = lbRules;
+ }
+
+ public void setLbInstances(List<ApplicationLoadBalancerInstanceResponse> lbInstances) {
+ this.lbInstances = lbInstances;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerRuleResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerRuleResponse.java b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerRuleResponse.java
new file mode 100644
index 0000000..ffc64d5
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerRuleResponse.java
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+
+package org.apache.cloudstack.api.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Subobject of the load balancer container response
+ */
+@SuppressWarnings("unused")
+public class ApplicationLoadBalancerRuleResponse extends BaseResponse{
+ @SerializedName(ApiConstants.SOURCE_PORT) @Param(description = "source port of the load balancer rule")
+ private Integer sourcePort;
+
+ @SerializedName(ApiConstants.INSTANCE_PORT) @Param(description = "instance port of the load balancer rule")
+ private Integer instancePort;
+
+ @SerializedName(ApiConstants.STATE) @Param(description = "the state of the load balancer rule")
+ private String state;
+
+ public void setSourcePort(Integer sourcePort) {
+ this.sourcePort = sourcePort;
+ }
+
+ public void setInstancePort(Integer instancePort) {
+ this.instancePort = instancePort;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java b/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java
index 79c8596..852d988 100644
--- a/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java
@@ -153,8 +153,11 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
@SerializedName("scriptsversion") @Param(description="the version of scripts")
private String scriptsVersion;
- @SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the network belongs to")
+ @SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the router belongs to")
private String vpcId;
+
+ @SerializedName(ApiConstants.ROLE) @Param(description="role of the domain router")
+ private String role;
@SerializedName("nic") @Param(description="the list of nics associated with the router",
responseObject = NicResponse.class, since="4.0")
@@ -164,15 +167,11 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
nics = new LinkedHashSet<NicResponse>();
}
-
-
@Override
public String getObjectId() {
return this.getId();
}
-
-
public String getId() {
return id;
}
@@ -372,4 +371,8 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
public void setIp6Dns2(String ip6Dns2) {
this.ip6Dns2 = ip6Dns2;
}
+
+ public void setRole(String role) {
+ this.role = role;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/response/InternalLoadBalancerElementResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/InternalLoadBalancerElementResponse.java b/api/src/org/apache/cloudstack/api/response/InternalLoadBalancerElementResponse.java
new file mode 100644
index 0000000..b7e8634
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/InternalLoadBalancerElementResponse.java
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.api.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+@EntityReference(value=VirtualRouterProvider.class)
+@SuppressWarnings("unused")
+public class InternalLoadBalancerElementResponse extends BaseResponse {
+ @SerializedName(ApiConstants.ID) @Param(description="the id of the internal load balancer element")
+ private String id;
+
+ @SerializedName(ApiConstants.NSP_ID) @Param(description="the physical network service provider id of the element")
+ private String nspId;
+
+ @SerializedName(ApiConstants.ENABLED) @Param(description="Enabled/Disabled the element")
+ private Boolean enabled;
+
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setNspId(String nspId) {
+ this.nspId = nspId;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java
index b1dcd42..7a7e371 100644
--- a/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java
@@ -18,6 +18,7 @@ package org.apache.cloudstack.api.response;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
@@ -83,6 +84,10 @@ public class NetworkOfferingResponse extends BaseResponse {
@SerializedName(ApiConstants.IS_PERSISTENT) @Param(description="true if network offering supports persistent networks, false otherwise")
private Boolean isPersistent;
+
+ @SerializedName(ApiConstants.DETAILS) @Param(description="additional key/value details tied with network offering", since="4.2.0")
+ private Map details;
+
public void setId(String id) {
this.id = id;
@@ -156,5 +161,9 @@ public class NetworkOfferingResponse extends BaseResponse {
public void setIsPersistent(Boolean isPersistent) {
this.isPersistent = isPersistent;
}
+
+ public void setDetails(Map details) {
+ this.details = details;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/api/response/VirtualRouterProviderResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/VirtualRouterProviderResponse.java b/api/src/org/apache/cloudstack/api/response/VirtualRouterProviderResponse.java
index 92d9a1d..de355bd 100644
--- a/api/src/org/apache/cloudstack/api/response/VirtualRouterProviderResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/VirtualRouterProviderResponse.java
@@ -25,6 +25,7 @@ import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@EntityReference(value=VirtualRouterProvider.class)
+@SuppressWarnings("unused")
public class VirtualRouterProviderResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID) @Param(description="the id of the router")
private String id;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/network/element/InternalLoadBalancerElementService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/network/element/InternalLoadBalancerElementService.java b/api/src/org/apache/cloudstack/network/element/InternalLoadBalancerElementService.java
new file mode 100644
index 0000000..33a0c64
--- /dev/null
+++ b/api/src/org/apache/cloudstack/network/element/InternalLoadBalancerElementService.java
@@ -0,0 +1,56 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.network.element;
+
+import java.util.List;
+
+
+import com.cloud.network.VirtualRouterProvider;
+import com.cloud.utils.component.PluggableService;
+
+public interface InternalLoadBalancerElementService extends PluggableService{
+ /**
+ * Configures existing Internal Load Balancer Element (enables or disables it)
+ * @param id
+ * @param enable
+ * @return
+ */
+ VirtualRouterProvider configureInternalLoadBalancerElement(long id, boolean enable);
+
+ /**
+ * Adds Internal Load Balancer element to the Network Service Provider
+ * @param ntwkSvcProviderId
+ * @return
+ */
+ VirtualRouterProvider addInternalLoadBalancerElement(long ntwkSvcProviderId);
+
+ /**
+ * Retrieves existing Internal Load Balancer element
+ * @param id
+ * @return
+ */
+ VirtualRouterProvider getInternalLoadBalancerElement(long id);
+
+ /**
+ * Searches for existing Internal Load Balancer elements based on parameters passed to the call
+ * @param id
+ * @param ntwkSvsProviderId
+ * @param enabled
+ * @return
+ */
+ List<? extends VirtualRouterProvider> searchForInternalLoadBalancerElements(Long id, Long ntwkSvsProviderId, Boolean enabled);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerContainer.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerContainer.java b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerContainer.java
new file mode 100644
index 0000000..df94d3d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerContainer.java
@@ -0,0 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.network.lb;
+
+import com.cloud.network.rules.LoadBalancerContainer;
+import com.cloud.utils.net.Ip;
+
+public interface ApplicationLoadBalancerContainer extends LoadBalancerContainer{
+
+ public Long getSourceIpNetworkId();
+
+ public Ip getSourceIp();
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerRule.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerRule.java b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerRule.java
new file mode 100644
index 0000000..f4acb73
--- /dev/null
+++ b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerRule.java
@@ -0,0 +1,24 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+
+package org.apache.cloudstack.network.lb;
+
+import com.cloud.network.rules.LoadBalancer;
+
+public interface ApplicationLoadBalancerRule extends ApplicationLoadBalancerContainer, LoadBalancer{
+ int getInstancePort();
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java
new file mode 100644
index 0000000..b2ac358
--- /dev/null
+++ b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java
@@ -0,0 +1,42 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+
+package org.apache.cloudstack.network.lb;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.command.user.loadbalancer.ListApplicationLoadBalancersCmd;
+
+import com.cloud.exception.InsufficientAddressCapacityException;
+import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.utils.Pair;
+
+public interface ApplicationLoadBalancerService {
+
+ ApplicationLoadBalancerRule createApplicationLoadBalancer(String name, String description, Scheme scheme, long sourceIpNetworkId, String sourceIp,
+ int sourcePort, int instancePort, String algorithm, long networkId, long lbOwnerId) throws InsufficientAddressCapacityException,
+ NetworkRuleConflictException, InsufficientVirtualNetworkCapcityException;
+
+ boolean deleteApplicationLoadBalancer(long id);
+
+ Pair<List<? extends ApplicationLoadBalancerRule>, Integer> listApplicationLoadBalancers(ListApplicationLoadBalancersCmd cmd);
+
+ ApplicationLoadBalancerRule getApplicationLoadBalancer(long ruleId);
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMService.java b/api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMService.java
new file mode 100644
index 0000000..91cd88d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMService.java
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package org.apache.cloudstack.network.lb;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.exception.StorageUnavailableException;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.user.Account;
+
+public interface InternalLoadBalancerVMService {
+
+ VirtualRouter startInternalLbVm(long internalLbVmId, Account caller, long callerUserId)
+ throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
+
+ VirtualRouter stopInternalLbVm(long vmId, boolean forced, Account caller, long callerUserId)
+ throws ConcurrentOperationException, ResourceUnavailableException;
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/api/src/org/apache/cloudstack/query/QueryService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/query/QueryService.java b/api/src/org/apache/cloudstack/query/QueryService.java
index 443c5df..2f50d63 100644
--- a/api/src/org/apache/cloudstack/query/QueryService.java
+++ b/api/src/org/apache/cloudstack/query/QueryService.java
@@ -18,6 +18,7 @@ package org.apache.cloudstack.query;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
+import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
@@ -101,4 +102,6 @@ public interface QueryService {
public ListResponse<AffinityGroupResponse> listAffinityGroups(Long affinityGroupId, String affinityGroupName,
String affinityGroupType, Long vmId, Long startIndex, Long pageSize);
+
+ ListResponse<DomainRouterResponse> searchForInternalLbVms(ListInternalLBVMsCmd cmd);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 147959b..197ba27 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -85,6 +85,11 @@
<artifactId>cloud-plugin-network-midonet</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.cloudstack</groupId>
+ <artifactId>cloud-plugin-network-internallb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-hypervisor-xen</artifactId>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 36f232c..67c8ccf 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -363,6 +363,9 @@
<bean id="vpcOfferingServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcOfferingServiceMapDaoImpl" />
<bean id="vpcServiceMapDaoImpl" class="com.cloud.network.vpc.dao.VpcServiceMapDaoImpl" />
<bean id="vpnUserDaoImpl" class="com.cloud.network.dao.VpnUserDaoImpl" />
+ <bean id="applicationLbRuleDaoImpl" class="org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDaoImpl" />
+ <bean id="networkOfferingDetailsDaoImpl" class="com.cloud.offerings.dao.NetworkOfferingDetailsDaoImpl" />
+
<!--
Checkers
@@ -406,10 +409,12 @@
<bean id="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement">
<property name="name" value="VpcVirtualRouter"/>
</bean>
-
<bean id="elasticLoadBalancerElement" class="com.cloud.network.element.ElasticLoadBalancerElement">
<property name="name" value="ElasticLoadBalancerElement"/>
</bean>
+ <bean id="InternalLbVm" class="org.apache.cloudstack.network.element.InternalLoadBalancerElement">
+ <property name="name" value="InternalLbVm"/>
+ </bean>
<!--
General allocators
@@ -789,6 +794,8 @@
<bean id="vMSnapshotManagerImpl" class="com.cloud.vm.snapshot.VMSnapshotManagerImpl" />
<bean id="volumeManagerImpl" class="com.cloud.storage.VolumeManagerImpl" />
<bean id="ClassicalPrimaryDataStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.CloudStackPrimaryDataStoreProviderImpl" />
+ <bean id="ApplicationLoadBalancerService" class="org.apache.cloudstack.network.lb.ApplicationLoadBalancerManagerImpl" />
+ <bean id="InternalLoadBalancerVMManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl" />
<!--=======================================================================================================-->