Updated Branches: refs/heads/internallb 7680e1cc1 -> 4f9c47ce5
Internallb: new set of Web services APIs for managing Internal LB VMs Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/408ee59d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/408ee59d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/408ee59d Branch: refs/heads/internallb Commit: 408ee59d1fe64ce5d6a5e57b76e25cc505fda5dc Parents: 7680e1c Author: Alena Prokharchyk <[email protected]> Authored: Wed Apr 24 17:08:08 2013 -0700 Committer: Alena Prokharchyk <[email protected]> Committed: Thu Apr 25 14:03:40 2013 -0700 ---------------------------------------------------------------------- api/src/com/cloud/async/AsyncJob.java | 3 +- api/src/com/cloud/event/EventTypes.java | 22 ++- .../admin/internallb/ListInternalLBVMsCmd.java | 144 +++++++++++++++ .../admin/internallb/StartInternalLBVMCmd.java | 120 ++++++++++++ .../admin/internallb/StopInternalLBVMCmd.java | 123 ++++++++++++ .../api/command/admin/router/ListRoutersCmd.java | 6 +- .../api/command/admin/router/StartRouterCmd.java | 4 +- .../api/command/admin/router/StopRouterCmd.java | 4 +- .../org/apache/cloudstack/query/QueryService.java | 3 + client/tomcatconf/commands.properties.in | 5 + .../lb/InternalLoadBalancerVMManagerImpl.java | 19 +-- .../src/com/cloud/api/query/QueryManagerImpl.java | 41 +++-- .../api/query/dao/DomainRouterJoinDaoImpl.java | 7 +- .../src/com/cloud/server/ManagementServerImpl.java | 6 + setup/db/db/schema-40to410.sql | 3 +- tools/apidoc/gen_toc.py | 1 + 16 files changed, 462 insertions(+), 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/api/src/com/cloud/async/AsyncJob.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/async/AsyncJob.java b/api/src/com/cloud/async/AsyncJob.java index 386d4ef..6b212e1 100644 --- a/api/src/com/cloud/async/AsyncJob.java +++ b/api/src/com/cloud/async/AsyncJob.java @@ -51,7 +51,8 @@ public interface AsyncJob extends Identity, InternalIdentity { AutoScaleVmGroup, GlobalLoadBalancerRule, LoadBalancerRule, - AffinityGroup + AffinityGroup, + InternalLbVm } long getUserId(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/api/src/com/cloud/event/EventTypes.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index 0ee7f40..c13163c 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -16,6 +16,9 @@ // under the License. package com.cloud.event; +import java.util.HashMap; +import java.util.Map; + import com.cloud.configuration.Configuration; import com.cloud.dc.DataCenter; import com.cloud.dc.Pod; @@ -23,8 +26,17 @@ import com.cloud.dc.StorageNetworkIpRange; import com.cloud.dc.Vlan; import com.cloud.domain.Domain; import com.cloud.host.Host; -import com.cloud.network.*; -import com.cloud.network.as.*; +import com.cloud.network.Network; +import com.cloud.network.PhysicalNetwork; +import com.cloud.network.PhysicalNetworkServiceProvider; +import com.cloud.network.PhysicalNetworkTrafficType; +import com.cloud.network.PublicIpAddress; +import com.cloud.network.RemoteAccessVpn; +import com.cloud.network.as.AutoScaleCounter; +import com.cloud.network.as.AutoScalePolicy; +import com.cloud.network.as.AutoScaleVmGroup; +import com.cloud.network.as.AutoScaleVmProfile; +import com.cloud.network.as.Condition; import com.cloud.network.router.VirtualRouter; import com.cloud.network.rules.LoadBalancer; import com.cloud.network.rules.StaticNat; @@ -43,9 +55,6 @@ import com.cloud.user.Account; import com.cloud.user.User; import com.cloud.vm.VirtualMachine; -import java.util.HashMap; -import java.util.Map; - public class EventTypes { //map of Event and corresponding entity for which Event is applicable @@ -389,6 +398,9 @@ public class EventTypes { public static final String EVENT_AFFINITY_GROUP_ASSIGN = "AG.ASSIGN"; public static final String EVENT_AFFINITY_GROUP_REMOVE = "AG.REMOVE"; public static final String EVENT_VM_AFFINITY_GROUP_UPDATE = "VM.AG.UPDATE"; + + public static final String EVENT_INTERNAL_LB_VM_START = "INTERNALLBVM.START"; + public static final String EVENT_INTERNAL_LB_VM_STOP = "INTERNALLBVM.STOP"; static { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/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..5c80e58 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java @@ -0,0 +1,144 @@ +// 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; + + + ///////////////////////////////////////////////////// + /////////////////// 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(); + } + + ///////////////////////////////////////////////////// + /////////////// 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/408ee59d/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/408ee59d/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/408ee59d/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 296d95c..a74eb89 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 { @@ -75,9 +76,6 @@ 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; - @Parameter(name=ApiConstants.ROLE, type=CommandType.STRING, description="list routers by role (Virtual_router or Internal_lb_vm)", since="4.2.0") - private String role; - ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -119,7 +117,7 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd { } public String getRole() { - return role; + return Role.VIRTUAL_ROUTER.toString(); } ///////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/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 9ef2ab9..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 @@ -104,10 +104,8 @@ public class StartRouterCmd extends BaseAsyncCmd { UserContext.current().setEventDetails("Router Id: "+getId()); VirtualRouter result = null; VirtualRouter router = _routerService.findRouter(getId()); - if (router == null) { + if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) { throw new InvalidParameterValueException("Can't find router by id"); - } else if (router.getRole() == Role.INTERNAL_LB_VM) { - result = _internalLbSvc.startInternalLbVm(getId(), UserContext.current().getCaller(), UserContext.current().getCallerUserId()); } else { result = _routerService.startRouter(getId()); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/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 ff8ba36..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 @@ -107,10 +107,8 @@ public class StopRouterCmd extends BaseAsyncCmd { UserContext.current().setEventDetails("Router Id: "+getId()); VirtualRouter result = null; VirtualRouter router = _routerService.findRouter(getId()); - if (router == null) { + if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) { throw new InvalidParameterValueException("Can't find router by id"); - } else if (router.getRole() == Role.INTERNAL_LB_VM) { - result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), UserContext.current().getCaller(), UserContext.current().getCallerUserId()); } else { result = _routerService.stopRouter(getId(), isForced()); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/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/408ee59d/client/tomcatconf/commands.properties.in ---------------------------------------------------------------------- diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 7f61fb5..ec4f0c8 100644 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -602,3 +602,8 @@ addCiscoAsa1000vResource=1 deleteCiscoAsa1000vResource=1 listCiscoAsa1000vResources=1 + +#### Internal LB VM commands +stopInternalLoadBalancerVM=1 +startInternalLoadBalancerVM=1 +listInternalLoadBalancerVMs=1 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java ---------------------------------------------------------------------- diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java index 7a48d7e..b4645e9 100644 --- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java +++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java @@ -173,8 +173,6 @@ InternalLoadBalancerVMManager, VirtualMachineGuru<DomainRouterVO> { public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile, DeployDestination dest, ReservationContext context) { - //1) Prepare boot loader elements related with Control network - StringBuilder buf = profile.getBootArgsBuilder(); buf.append(" template=domP"); buf.append(" name=").append(profile.getHostName()); @@ -184,8 +182,6 @@ InternalLoadBalancerVMManager, VirtualMachineGuru<DomainRouterVO> { } NicProfile controlNic = null; - String defaultDns1 = null; - String defaultDns2 = null; Network guestNetwork = null; for (NicProfile nic : profile.getNics()) { @@ -193,15 +189,15 @@ InternalLoadBalancerVMManager, VirtualMachineGuru<DomainRouterVO> { buf.append(" eth").append(deviceId).append("ip=").append(nic.getIp4Address()); buf.append(" eth").append(deviceId).append("mask=").append(nic.getNetmask()); - if (nic.isDefaultNic()) { buf.append(" gateway=").append(nic.getGateway()); - defaultDns1 = nic.getDns1(); - defaultDns2 = nic.getDns2(); + //FIXME - remove the DNS from boot args if decide to send DhcpEntry command for the Internal LB vm just the way we do for regular user vm + buf.append(" dns1=").append(nic.getGateway()); } if (nic.getTrafficType() == TrafficType.Guest) { guestNetwork = _ntwkModel.getNetwork(nic.getNetworkId()); + //FIXME - not sure if sshonguest is required for this type of VM. Fix if needed buf.append(" sshonguest=true"); } else if (nic.getTrafficType() == TrafficType.Management) { buf.append(" localgw=").append(dest.getPod().getGateway()); @@ -237,16 +233,11 @@ InternalLoadBalancerVMManager, VirtualMachineGuru<DomainRouterVO> { } } - buf.append(" dns1=").append(defaultDns1); - if (defaultDns2 != null) { - buf.append(" dns2=").append(defaultDns2); - } - - //FIXME - change if use other template for internal lb vm + //FIXME - fix the type once earlyconfig and patchsystem vm scripts are fixed String type = "elbvm"; buf.append(" type=" + type); - //FIXME - change it to DEBUG level later + //FIXME - change it to DEBUG level later. // if (s_logger.isDebugEnabled()) { // s_logger.debug("Boot Args for " + profile + ": " + buf.toString()); // } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/server/src/com/cloud/api/query/QueryManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java index 7d38db7..3edbc94 100644 --- a/server/src/com/cloud/api/query/QueryManagerImpl.java +++ b/server/src/com/cloud/api/query/QueryManagerImpl.java @@ -29,7 +29,9 @@ import javax.inject.Inject; import org.apache.cloudstack.affinity.AffinityGroupResponse; import org.apache.cloudstack.affinity.AffinityGroupVMMapVO; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; +import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; 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; @@ -973,27 +975,32 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { @Override public ListResponse<DomainRouterResponse> searchForRouters(ListRoutersCmd cmd) { - Pair<List<DomainRouterJoinVO>, Integer> result = searchForRoutersInternal(cmd); + Pair<List<DomainRouterJoinVO>, Integer> result = searchForRoutersInternal(cmd, cmd.getId(), cmd.getRouterName(), + cmd.getState(), cmd.getZoneId(), cmd.getPodId(), cmd.getHostId(), cmd.getKeyword(), cmd.getNetworkId(), + cmd.getVpcId(), cmd.getForVpc(), cmd.getRole()); ListResponse<DomainRouterResponse> response = new ListResponse<DomainRouterResponse>(); List<DomainRouterResponse> routerResponses = ViewResponseHelper.createDomainRouterResponse(result.first().toArray(new DomainRouterJoinVO[result.first().size()])); response.setResponses(routerResponses, result.second()); return response; } + + @Override + public ListResponse<DomainRouterResponse> searchForInternalLbVms(ListInternalLBVMsCmd cmd) { + Pair<List<DomainRouterJoinVO>, Integer> result = searchForRoutersInternal(cmd, cmd.getId(), cmd.getRouterName(), + cmd.getState(), cmd.getZoneId(), cmd.getPodId(), cmd.getHostId(), cmd.getKeyword(), cmd.getNetworkId(), + cmd.getVpcId(), cmd.getForVpc(), cmd.getRole()); + ListResponse<DomainRouterResponse> response = new ListResponse<DomainRouterResponse>(); + List<DomainRouterResponse> routerResponses = ViewResponseHelper.createDomainRouterResponse(result.first().toArray(new DomainRouterJoinVO[result.first().size()])); + response.setResponses(routerResponses, result.second()); + return response; + } - private Pair<List<DomainRouterJoinVO>, Integer> searchForRoutersInternal(ListRoutersCmd cmd) { - Long id = cmd.getId(); - String name = cmd.getRouterName(); - String state = cmd.getState(); - Long zone = cmd.getZoneId(); - Long pod = cmd.getPodId(); - Long hostId = cmd.getHostId(); - String keyword = cmd.getKeyword(); - Long networkId = cmd.getNetworkId(); - Long vpcId = cmd.getVpcId(); - Boolean forVpc = cmd.getForVpc(); - String role = cmd.getRole(); + + private Pair<List<DomainRouterJoinVO>, Integer> searchForRoutersInternal(BaseListProjectAndAccountResourcesCmd cmd, Long id, + String name, String state, Long zoneId, Long podId, Long hostId, String keyword, Long networkId, Long vpcId, Boolean forVpc, String role) { + Account caller = UserContext.current().getCaller(); List<Long> permittedAccounts = new ArrayList<Long>(); @@ -1061,12 +1068,12 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { sc.setParameters("state", state); } - if (zone != null) { - sc.setParameters("dataCenterId", zone); + if (zoneId != null) { + sc.setParameters("dataCenterId", zoneId); } - if (pod != null) { - sc.setParameters("podId", pod); + if (podId != null) { + sc.setParameters("podId", podId); } if (hostId != null) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java index e7357ed..80398f4 100644 --- a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java @@ -32,6 +32,7 @@ import com.cloud.api.query.vo.DomainRouterJoinVO; import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.network.Networks.TrafficType; import com.cloud.network.router.VirtualRouter; +import com.cloud.network.router.VirtualRouter.Role; import com.cloud.user.Account; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; @@ -163,7 +164,11 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO, routerResponse.setJobId(router.getJobUuid()); routerResponse.setJobStatus(router.getJobStatus()); - routerResponse.setObjectName("router"); + if (router.getRole() == Role.INTERNAL_LB_VM) { + routerResponse.setObjectName("internalloadbalancervm"); + } else { + routerResponse.setObjectName("router"); + } return routerResponse; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/server/src/com/cloud/server/ManagementServerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 38a0c3f..f48ce3a 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -82,7 +82,10 @@ import org.apache.cloudstack.api.command.admin.host.UpdateHostCmd; import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd; import org.apache.cloudstack.api.command.admin.internallb.ConfigureInternalLoadBalancerElementCmd; import org.apache.cloudstack.api.command.admin.internallb.CreateInternalLoadBalancerElementCmd; +import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd; import org.apache.cloudstack.api.command.admin.internallb.ListInternalLoadBalancerElementsCmd; +import org.apache.cloudstack.api.command.admin.internallb.StartInternalLBVMCmd; +import org.apache.cloudstack.api.command.admin.internallb.StopInternalLBVMCmd; import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd; import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd; import org.apache.cloudstack.api.command.admin.network.AddNetworkDeviceCmd; @@ -2798,6 +2801,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe cmdList.add(ListAffinityGroupsCmd.class); cmdList.add(UpdateVMAffinityGroupCmd.class); cmdList.add(ListAffinityGroupTypesCmd.class); + cmdList.add(StopInternalLBVMCmd.class); + cmdList.add(StartInternalLBVMCmd.class); + cmdList.add(ListInternalLBVMsCmd.class); return cmdList; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/setup/db/db/schema-40to410.sql ---------------------------------------------------------------------- diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql index 386dc15..70a9342 100644 --- a/setup/db/db/schema-40to410.sql +++ b/setup/db/db/schema-40to410.sql @@ -681,7 +681,8 @@ CREATE VIEW `cloud`.`domain_router_view` AS domain_router.scripts_version scripts_version, domain_router.is_redundant_router is_redundant_router, domain_router.redundant_state redundant_state, - domain_router.stop_pending stop_pending + domain_router.stop_pending stop_pending, + domain_router.role role from `cloud`.`domain_router` inner join http://git-wip-us.apache.org/repos/asf/cloudstack/blob/408ee59d/tools/apidoc/gen_toc.py ---------------------------------------------------------------------- diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py index f8bdae2..bd8c0f1 100644 --- a/tools/apidoc/gen_toc.py +++ b/tools/apidoc/gen_toc.py @@ -140,6 +140,7 @@ known_categories = { 'removeIpFromNic': 'Nic', 'listNics':'Nic', 'AffinityGroup': 'Affinity Group', + 'InternalLoadBalancer': 'Internal LB', }
