mirror of https://github.com/apache/cloudstack.git
NaaS: Implement shutdownProviderInstances for virtual router
This commit is contained in:
parent
1fe3bc066b
commit
3de3fc69d2
|
|
@ -265,8 +265,21 @@ public class DhcpElement extends AdapterBase implements DhcpElementService, User
|
|||
@Override
|
||||
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), VirtualRouterProviderType.DhcpElement);
|
||||
if (element == null) {
|
||||
return true;
|
||||
}
|
||||
//Find domain routers
|
||||
long elementId = element.getId();
|
||||
List<DomainRouterVO> routers = _routerDao.listByElementId(elementId);
|
||||
boolean result = true;
|
||||
for (DomainRouterVO router : routers) {
|
||||
if (forceShutdown) {
|
||||
result = result && (_routerMgr.stopRouter(router.getId(), true) != null);
|
||||
}
|
||||
result = result && (_routerMgr.destroyRouter(router.getId()) != null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -122,4 +122,23 @@ public class RedundantVirtualRouterElement extends VirtualRouterElement implemen
|
|||
return vr.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), VirtualRouterProviderType.RedundantVirtualRouterElement);
|
||||
if (element == null) {
|
||||
return true;
|
||||
}
|
||||
//Find domain routers
|
||||
long elementId = element.getId();
|
||||
List<DomainRouterVO> routers = _routerDao.listByElementId(elementId);
|
||||
boolean result = true;
|
||||
for (DomainRouterVO router : routers) {
|
||||
if (forceShutdown) {
|
||||
result = result && (_routerMgr.stopRouter(router.getId(), true) != null);
|
||||
}
|
||||
result = result && (_routerMgr.destroyRouter(router.getId()) != null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -417,8 +417,21 @@ public class VirtualRouterElement extends DhcpElement implements VirtualRouterEl
|
|||
@Override
|
||||
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context, boolean forceShutdown) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), VirtualRouterProviderType.VirtualRouterElement);
|
||||
if (element == null) {
|
||||
return true;
|
||||
}
|
||||
//Find domain routers
|
||||
long elementId = element.getId();
|
||||
List<DomainRouterVO> routers = _routerDao.listByElementId(elementId);
|
||||
boolean result = true;
|
||||
for (DomainRouterVO router : routers) {
|
||||
if (forceShutdown) {
|
||||
result = result && (_routerMgr.stopRouter(router.getId(), true) != null);
|
||||
}
|
||||
result = result && (_routerMgr.destroyRouter(router.getId()) != null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -122,9 +122,12 @@ import com.cloud.network.NetworkVO;
|
|||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.IsolationType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.SshKeysDistriMonitor;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualNetworkApplianceService;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.network.VpnUserVO;
|
||||
|
|
@ -136,7 +139,9 @@ import com.cloud.network.dao.LoadBalancerDao;
|
|||
import com.cloud.network.dao.LoadBalancerVMMapDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkRuleConfigDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDao;
|
||||
import com.cloud.network.dao.VirtualRouterProviderDao;
|
||||
import com.cloud.network.dao.VpnUserDao;
|
||||
import com.cloud.network.lb.LoadBalancingRule;
|
||||
import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
||||
|
|
@ -317,6 +322,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
UserVmDetailsDao _vmDetailsDao;
|
||||
@Inject
|
||||
ResourceManager _resourceMgr;
|
||||
@Inject
|
||||
PhysicalNetworkServiceProviderDao _physicalProviderDao;
|
||||
@Inject
|
||||
VirtualRouterProviderDao _vrProviderDao;
|
||||
|
||||
int _routerRamSize;
|
||||
int _routerCpuMHz;
|
||||
|
|
@ -1103,6 +1112,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (offering_id == null) {
|
||||
offering_id = _offering.getId();
|
||||
}
|
||||
VirtualRouterProviderType type = VirtualRouterProviderType.VirtualRouterElement;
|
||||
String typeString = "VirtualRouter";
|
||||
if (isRedundant) {
|
||||
type = VirtualRouterProviderType.RedundantVirtualRouterElement;
|
||||
typeString = "RedundantVirtualRouter";
|
||||
}
|
||||
PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(network.getPhysicalNetworkId(), typeString);
|
||||
VirtualRouterProvider vrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(), type);
|
||||
ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(offering_id);
|
||||
int retry = 0;
|
||||
for (HypervisorType hType : supportedHypervisors) {
|
||||
|
|
@ -1110,7 +1127,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
s_logger.debug("Allocating the domR with the hypervisor type " + hType);
|
||||
VMTemplateVO template = _templateDao.findRoutingTemplate(hType);
|
||||
|
||||
router = new DomainRouterVO(id, routerOffering.getId(), 0, VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(),
|
||||
router = new DomainRouterVO(id, routerOffering.getId(), vrProvider.getId(), VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(),
|
||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), isRedundant, 0, false, RedundantState.UNKNOWN, routerOffering.getOfferHA(), false);
|
||||
router = _itMgr.allocate(router, template, routerOffering, networks, plan, null, owner);
|
||||
break;
|
||||
|
|
@ -1320,7 +1337,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
/* Before starting router, already know the hypervisor type */
|
||||
VMTemplateVO template = _templateDao.findRoutingTemplate(hType);
|
||||
|
||||
router = new DomainRouterVO(id, routerOffering.getId(), 0, VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(),
|
||||
VirtualRouterProviderType type = VirtualRouterProviderType.DhcpElement;
|
||||
String typeString = "DhcpServer";
|
||||
PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(network.getPhysicalNetworkId(), typeString);
|
||||
VirtualRouterProvider vrProvider = _vrProviderDao.findByNspIdAndType(provider.getId(), type);
|
||||
|
||||
router = new DomainRouterVO(id, routerOffering.getId(), vrProvider.getId(), VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(),
|
||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), false, 0, false, RedundantState.UNKNOWN, routerOffering.getOfferHA(), false);
|
||||
router.setRole(Role.DHCP_USERDATA);
|
||||
router = _itMgr.allocate(router, template, routerOffering, networks, plan, null, owner);
|
||||
|
|
|
|||
|
|
@ -104,4 +104,6 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long> {
|
|||
List<DomainRouterVO> listByNetworkAndPodAndRole(long networkId, long podId, Role role);
|
||||
|
||||
List<DomainRouterVO> listByNetworkAndRole(long networkId, Role role);
|
||||
|
||||
List<DomainRouterVO> listByElementId(long elementId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
|||
AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
|
||||
AllFieldsSearch.and("network", AllFieldsSearch.entity().getNetworkId(), Op.EQ);
|
||||
AllFieldsSearch.and("podId", AllFieldsSearch.entity().getPodIdToDeployIn(), Op.EQ);
|
||||
AllFieldsSearch.and("elementId", AllFieldsSearch.entity().getElementId(), Op.EQ);
|
||||
AllFieldsSearch.done();
|
||||
|
||||
IdNetworkIdStatesSearch = createSearchBuilder();
|
||||
|
|
@ -238,4 +239,11 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
|||
sc.setParameters("role", role);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DomainRouterVO> listByElementId(long elementId) {
|
||||
SearchCriteria<DomainRouterVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("elementId", elementId);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -923,7 +923,7 @@ CREATE TABLE `cloud`.`user_vm_details` (
|
|||
|
||||
CREATE TABLE `cloud`.`domain_router` (
|
||||
`id` bigint unsigned UNIQUE NOT NULL COMMENT 'Primary Key',
|
||||
`element_id` bigint unsigned NOT NULL COMMENT 'correlated virtual router element ID',
|
||||
`element_id` bigint unsigned NOT NULL COMMENT 'correlated virtual router provider ID',
|
||||
`public_mac_address` varchar(17) COMMENT 'mac address of the public facing network card',
|
||||
`public_ip_address` char(40) COMMENT 'public ip address used for source net',
|
||||
`public_netmask` varchar(15) COMMENT 'netmask used for the domR',
|
||||
|
|
@ -939,8 +939,8 @@ CREATE TABLE `cloud`.`domain_router` (
|
|||
`template_version` varchar(100) COMMENT 'template version',
|
||||
`scripts_version` varchar(100) COMMENT 'scripts version',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_domain_router__id` FOREIGN KEY `fk_domain_router__id` (`id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE
|
||||
#CONSTRAINT `fk_domain_router__element_id` FOREIGN KEY `fk_domain_router__element_id` (`element_id`) REFERENCES `virtual_router_elements`(`id`)
|
||||
CONSTRAINT `fk_domain_router__id` FOREIGN KEY `fk_domain_router__id` (`id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_domain_router__element_id` FOREIGN KEY `fk_domain_router__element_id`(`element_id`) REFERENCES `virtual_router_providers`(`id`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET=utf8 COMMENT = 'information about the domR instance';
|
||||
|
||||
CREATE TABLE `cloud`.`upload` (
|
||||
|
|
|
|||
Loading…
Reference in New Issue