mirror of https://github.com/apache/cloudstack.git
Internallb: new set of Web services APIs for managing Internal LB VMs
This commit is contained in:
parent
7680e1cc10
commit
408ee59d1f
|
|
@ -51,7 +51,8 @@ public interface AsyncJob extends Identity, InternalIdentity {
|
|||
AutoScaleVmGroup,
|
||||
GlobalLoadBalancerRule,
|
||||
LoadBalancerRule,
|
||||
AffinityGroup
|
||||
AffinityGroup,
|
||||
InternalLbVm
|
||||
}
|
||||
|
||||
long getUserId();
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -602,3 +602,8 @@ addCiscoAsa1000vResource=1
|
|||
deleteCiscoAsa1000vResource=1
|
||||
listCiscoAsa1000vResources=1
|
||||
|
||||
|
||||
#### Internal LB VM commands
|
||||
stopInternalLoadBalancerVM=1
|
||||
startInternalLoadBalancerVM=1
|
||||
listInternalLoadBalancerVMs=1
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -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,7 +975,21 @@ 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()]));
|
||||
|
|
@ -982,18 +998,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
|
|||
}
|
||||
|
||||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ known_categories = {
|
|||
'removeIpFromNic': 'Nic',
|
||||
'listNics':'Nic',
|
||||
'AffinityGroup': 'Affinity Group',
|
||||
'InternalLoadBalancer': 'Internal LB',
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue