mirror of https://github.com/apache/cloudstack.git
InternalLb: new set of Web Services APIs to add InternalLB as a network element to the cloudStack (the element is packaged as an independent plugin). New APIs:
1) configureInternalLoadBalancerElement 2) createInternalLoadBalancerElement 3) listInternalLoadBalancerElements
This commit is contained in:
parent
039e303d4a
commit
7b9af28094
|
|
@ -0,0 +1,133 @@
|
|||
// 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.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
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.VirtualRouterProviderResponse;
|
||||
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
|
||||
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.ResourceUnavailableException;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@APICommand(name = "configureInternalLoadBalancerElement", responseObject=VirtualRouterProviderResponse.class, description="Configures an internal load balancer element.")
|
||||
public class ConfigureInternalLoadBalancerElementCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ConfigureInternalLoadBalancerElementCmd.class.getName());
|
||||
private static final String s_name = "configureinternalloadbalancerelementresponse";
|
||||
|
||||
@Inject
|
||||
private List<InternalLoadBalancerElementService> _service;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = VirtualRouterProviderResponse.class,
|
||||
required=true, description="the ID of the internal lb provider")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.ENABLED, type=CommandType.BOOLEAN, required=true, description="Enables/Disables the Internal load balancer element")
|
||||
private Boolean enabled;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public static String getResultObjectName() {
|
||||
return "boolean";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_NETWORK_ELEMENT_CONFIGURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "configuring internal load balancer element: " + id;
|
||||
}
|
||||
|
||||
public AsyncJob.Type getInstanceType() {
|
||||
return AsyncJob.Type.None;
|
||||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
|
||||
s_logger.debug("hello alena");
|
||||
UserContext.current().setEventDetails("Internal load balancer element: " + id);
|
||||
s_logger.debug("hello alena");
|
||||
VirtualRouterProvider result = _service.get(0).configure(this);
|
||||
s_logger.debug("hello alena");
|
||||
if (result != null){
|
||||
VirtualRouterProviderResponse routerResponse = _responseGenerator.createVirtualRouterProviderResponse(result);
|
||||
routerResponse.setResponseName(getCommandName());
|
||||
this.setResponseObject(routerResponse);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the internal load balancer element");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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.admin.internallb;
|
||||
|
||||
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.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.ProviderResponse;
|
||||
import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
|
||||
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@APICommand(name = "createInternalLoadBalancerElement", responseObject=VirtualRouterProviderResponse.class, description="Create a virtual router element.")
|
||||
public class CreateInternalLoadBalancerElementCmd extends BaseAsyncCreateCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateInternalLoadBalancerElementCmd.class.getName());
|
||||
private static final String s_name = "createinternalloadbalancerelementresponse";
|
||||
|
||||
@Inject
|
||||
private List<InternalLoadBalancerElementService> _service;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_SERVICE_PROVIDER_ID, type=CommandType.UUID, entityType = ProviderResponse.class, required=true, description="the network service provider ID of the internal load balancer element")
|
||||
private Long nspId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public void setNspId(Long nspId) {
|
||||
this.nspId = nspId;
|
||||
}
|
||||
|
||||
public Long getNspId() {
|
||||
return nspId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
UserContext.current().setEventDetails("Virtual router element Id: "+getEntityId());
|
||||
VirtualRouterProvider result = _service.get(0).getCreatedElement(getEntityId());
|
||||
if (result != null) {
|
||||
VirtualRouterProviderResponse response = _responseGenerator.createVirtualRouterProviderResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException {
|
||||
VirtualRouterProvider result = _service.get(0).addElement(getNspId());
|
||||
if (result != null) {
|
||||
setEntityId(result.getId());
|
||||
setEntityUuid(result.getUuid());
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Internal Load Balancer entity to physical network");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_SERVICE_PROVIDER_CREATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Adding physical network element Internal Load Balancer: " + getEntityId();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
// 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.command.user.network.ListNetworkOfferingsCmd;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ProviderResponse;
|
||||
import org.apache.cloudstack.api.response.VirtualRouterProviderResponse;
|
||||
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=VirtualRouterProviderResponse.class)
|
||||
public class ListInternalLoadBalancerElementsCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListNetworkOfferingsCmd.class.getName());
|
||||
private static final String _name = "listinternalloadbalancerelementsresponse";
|
||||
|
||||
@Inject
|
||||
private List<InternalLoadBalancerElementService> _service;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = VirtualRouterProviderResponse.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 void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setNspId(Long nspId) {
|
||||
this.nspId = nspId;
|
||||
}
|
||||
|
||||
public Long getNspId() {
|
||||
return nspId;
|
||||
}
|
||||
|
||||
public void setEnabled(Boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
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.get(0).searchForInternalLoadBalancerElements(this);
|
||||
ListResponse<VirtualRouterProviderResponse> response = new ListResponse<VirtualRouterProviderResponse>();
|
||||
List<VirtualRouterProviderResponse> providerResponses = new ArrayList<VirtualRouterProviderResponse>();
|
||||
for (VirtualRouterProvider provider : providers) {
|
||||
VirtualRouterProviderResponse providerResponse = _responseGenerator.createVirtualRouterProviderResponse(provider);
|
||||
providerResponses.add(providerResponse);
|
||||
}
|
||||
response.setResponses(providerResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
// 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 org.apache.cloudstack.api.command.admin.internallb.ConfigureInternalLoadBalancerElementCmd;
|
||||
import org.apache.cloudstack.api.command.admin.internallb.ListInternalLoadBalancerElementsCmd;
|
||||
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
public interface InternalLoadBalancerElementService extends PluggableService{
|
||||
VirtualRouterProvider configure(ConfigureInternalLoadBalancerElementCmd cmd);
|
||||
VirtualRouterProvider addElement(Long nspId);
|
||||
VirtualRouterProvider getCreatedElement(long id);
|
||||
List<? extends VirtualRouterProvider> searchForInternalLoadBalancerElements(ListInternalLoadBalancerElementsCmd cmd);
|
||||
}
|
||||
|
|
@ -574,3 +574,9 @@ createLoadBalancer=15
|
|||
listLoadBalancers=15
|
||||
deleteLoadBalancer=15
|
||||
|
||||
#Internal Load Balancer Element commands
|
||||
configureInternalLoadBalancerElement=1
|
||||
createInternalLoadBalancerElement=1
|
||||
listInternalLoadBalancerElements=1
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -26,15 +26,16 @@ import java.util.Set;
|
|||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElementCmd;
|
||||
import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
|
||||
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.ListInternalLoadBalancerElementsCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
|
|
@ -46,18 +47,21 @@ import com.cloud.network.PhysicalNetworkServiceProvider;
|
|||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||
import com.cloud.network.dao.VirtualRouterProviderDao;
|
||||
import com.cloud.network.element.IpDeployer;
|
||||
import com.cloud.network.element.LoadBalancingServiceProvider;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.VirtualRouterElement;
|
||||
import com.cloud.network.element.VirtualRouterElementService;
|
||||
import com.cloud.network.element.VirtualRouterProviderVO;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.router.VirtualRouter.Role;
|
||||
import com.cloud.network.rules.LoadBalancerContainer;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.SearchCriteria2;
|
||||
import com.cloud.utils.db.SearchCriteriaService;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
|
|
@ -66,7 +70,7 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
|
||||
@Local(value = {NetworkElement.class})
|
||||
public class InternalLoadBalancerElement extends AdapterBase implements LoadBalancingServiceProvider, VirtualRouterElementService{
|
||||
public class InternalLoadBalancerElement extends AdapterBase implements LoadBalancingServiceProvider, InternalLoadBalancerElementService{
|
||||
private static final Logger s_logger = Logger.getLogger(InternalLoadBalancerElement.class);
|
||||
protected static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
||||
|
||||
|
|
@ -74,6 +78,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
|
|||
@Inject NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject DomainRouterDao _routerDao;
|
||||
@Inject VirtualRouterProviderDao _vrProviderDao;
|
||||
@Inject PhysicalNetworkServiceProviderDao _pNtwkSvcProviderDao;
|
||||
|
||||
private boolean canHandle(Network config, List<LoadBalancingRule> rules) {
|
||||
if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType() != TrafficType.Guest) {
|
||||
|
|
@ -212,40 +217,75 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
|
|||
@Override
|
||||
public List<Class<?>> getCommands() {
|
||||
List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
||||
cmdList.add(CreateVirtualRouterElementCmd.class);
|
||||
cmdList.add(ConfigureVirtualRouterElementCmd.class);
|
||||
cmdList.add(ListVirtualRouterElementsCmd.class);
|
||||
cmdList.add(CreateInternalLoadBalancerElementCmd.class);
|
||||
cmdList.add(ConfigureInternalLoadBalancerElementCmd.class);
|
||||
cmdList.add(ListInternalLoadBalancerElementsCmd.class);
|
||||
return cmdList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualRouterProvider configure(ConfigureVirtualRouterElementCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public VirtualRouterProvider configure(ConfigureInternalLoadBalancerElementCmd cmd) {
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findById(cmd.getId());
|
||||
if (element == null || element.getType() != VirtualRouterProviderType.InternalLbVm) {
|
||||
s_logger.debug("Can't find " + this.getName() + " element with network service provider id " + cmd.getId() +
|
||||
" to be used as a provider for " + this.getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
element.setEnabled(cmd.getEnabled());
|
||||
_vrProviderDao.persist(element);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualRouterProvider addElement(Long nspId, VirtualRouterProviderType providerType) {
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(nspId, providerType);
|
||||
public VirtualRouterProvider addElement(Long nspId) {
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(nspId, VirtualRouterProviderType.InternalLbVm);
|
||||
if (element != null) {
|
||||
s_logger.debug("There is already a virtual router element with service provider id " + nspId);
|
||||
s_logger.debug("There is already an " + this.getName() + " with service provider id " + nspId);
|
||||
return null;
|
||||
}
|
||||
element = new VirtualRouterProviderVO(nspId, providerType);
|
||||
|
||||
PhysicalNetworkServiceProvider provider = _pNtwkSvcProviderDao.findById(nspId);
|
||||
if (provider == null || !provider.getProviderName().equalsIgnoreCase(this.getName())) {
|
||||
throw new InvalidParameterValueException("Invalid network service provider is specified");
|
||||
}
|
||||
|
||||
element = new VirtualRouterProviderVO(nspId, VirtualRouterProviderType.InternalLbVm);
|
||||
_vrProviderDao.persist(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualRouterProvider getCreatedElement(long id) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
VirtualRouterProvider provider = _vrProviderDao.findById(id);
|
||||
if (provider.getType() != VirtualRouterProviderType.InternalLbVm) {
|
||||
throw new InvalidParameterValueException("Unable to find " + this.getName() + " by id");
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends VirtualRouterProvider> searchForVirtualRouterElement(ListVirtualRouterElementsCmd cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public List<? extends VirtualRouterProvider> searchForInternalLoadBalancerElements(ListInternalLoadBalancerElementsCmd cmd) {
|
||||
Long id = cmd.getId();
|
||||
Long nspId = cmd.getNspId();
|
||||
Boolean enabled = cmd.getEnabled();
|
||||
|
||||
SearchCriteriaService<VirtualRouterProviderVO, VirtualRouterProviderVO> sc = SearchCriteria2.create(VirtualRouterProviderVO.class);
|
||||
if (id != null) {
|
||||
sc.addAnd(sc.getEntity().getId(), Op.EQ, id);
|
||||
}
|
||||
if (nspId != null) {
|
||||
sc.addAnd(sc.getEntity().getNspId(), Op.EQ, nspId);
|
||||
}
|
||||
if (enabled != null) {
|
||||
sc.addAnd(sc.getEntity().isEnabled(), Op.EQ, enabled);
|
||||
}
|
||||
|
||||
//return only Internal LB elements
|
||||
sc.addAnd(sc.getEntity().getType(), Op.EQ, VirtualRouterProvider.VirtualRouterProviderType.InternalLbVm);
|
||||
|
||||
return sc.list();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.sql.PreparedStatement;
|
||||
|
|
@ -31,6 +31,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -42,18 +43,17 @@ import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementors
|
|||
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
|
||||
import org.bouncycastle.util.IPAddress;
|
||||
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
|
|
@ -69,11 +69,16 @@ import com.cloud.event.EventTypes;
|
|||
import com.cloud.event.UsageEventUtils;
|
||||
import com.cloud.event.dao.EventDao;
|
||||
import com.cloud.event.dao.UsageEventDao;
|
||||
import com.cloud.exception.*;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.UnsupportedServiceException;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.IpAddress.State;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.GuestType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
|
|
@ -83,16 +88,29 @@ import com.cloud.network.Networks.TrafficType;
|
|||
import com.cloud.network.PhysicalNetwork.BroadcastDomainRange;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.*;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkDomainDao;
|
||||
import com.cloud.network.dao.NetworkDomainVO;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.VirtualRouterElement;
|
||||
import com.cloud.network.element.VpcVirtualRouterElement;
|
||||
import com.cloud.network.guru.NetworkGuru;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.rules.FirewallRuleVO;
|
||||
import com.cloud.network.rules.PortForwardingRuleVO;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.vpc.PrivateIpVO;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.network.vpc.VpcManager;
|
||||
|
|
@ -107,27 +125,43 @@ import com.cloud.projects.ProjectManager;
|
|||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.tags.ResourceTagVO;
|
||||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import com.cloud.user.*;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.DomainManager;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.AnnotationHelper;
|
||||
import com.cloud.utils.Journal;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.db.*;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.*;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.ReservationContextImpl;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.NicSecondaryIpDao;
|
||||
import com.cloud.vm.dao.NicSecondaryIpVO;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* NetworkServiceImpl implements NetworkService.
|
||||
|
|
@ -3077,22 +3111,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
|
||||
return nsp;
|
||||
}
|
||||
|
||||
|
||||
protected PhysicalNetworkServiceProvider addDefaultInternalLbProviderToPhysicalNetwork(long physicalNetworkId) {
|
||||
|
||||
PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.InternalLbVm.getName(), null, null);
|
||||
// add instance of the provider
|
||||
NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.InternalLbVm.getName());
|
||||
if (networkElement == null) {
|
||||
throw new CloudRuntimeException("Unable to find the Network Element implementing the " + Network.Provider.InternalLbVm.getName() + " Provider");
|
||||
}
|
||||
|
||||
VirtualRouterElement element = (VirtualRouterElement)networkElement;
|
||||
element.addElement(nsp.getId(), VirtualRouterProviderType.InternalLbVm);
|
||||
|
||||
return nsp;
|
||||
}
|
||||
|
||||
protected PhysicalNetworkServiceProvider addDefaultSecurityGroupProviderToPhysicalNetwork(long physicalNetworkId) {
|
||||
|
||||
|
|
|
|||
|
|
@ -811,7 +811,11 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
|
|||
|
||||
@Override
|
||||
public VirtualRouterProvider getCreatedElement(long id) {
|
||||
return _vrProviderDao.findById(id);
|
||||
VirtualRouterProvider provider = _vrProviderDao.findById(id);
|
||||
if (!(provider.getType() == VirtualRouterProviderType.VirtualRouter || provider.getType() == VirtualRouterProviderType.VPCVirtualRouter)) {
|
||||
throw new InvalidParameterValueException("Unable to find provider by id");
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ import org.apache.cloudstack.api.command.admin.host.PrepareForMaintenanceCmd;
|
|||
import org.apache.cloudstack.api.command.admin.host.ReconnectHostCmd;
|
||||
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.ListInternalLoadBalancerElementsCmd;
|
||||
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;
|
||||
|
|
@ -2528,6 +2531,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
cmdList.add(CreateApplicationLoadBalancerCmd.class);
|
||||
cmdList.add(ListApplicationLoadBalancersCmd.class);
|
||||
cmdList.add(DeleteApplicationLoadBalancerCmd.class);
|
||||
cmdList.add(ConfigureInternalLoadBalancerElementCmd.class);
|
||||
cmdList.add(CreateInternalLoadBalancerElementCmd.class);
|
||||
cmdList.add(ListInternalLoadBalancerElementsCmd.class);
|
||||
return cmdList;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue