@Override public boolean shutdown(final Network network, final ReservationContext context, final boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException { final List<DomainRouterVO> routers = getRouters(network); if (routers == null || routers.isEmpty()) { return true; } boolean stopResult = true; boolean destroyResult = true; for (final DomainRouterVO router : routers) { stopResult = stopResult && _routerMgr.stop(router, false, context.getCaller(), context.getAccount()) != null; if (!stopResult) { s_logger.warn("Failed to stop virtual router element " + router + ", but would try to process clean up anyway."); } if (cleanup) { destroyResult = destroyResult && _routerMgr.destroyRouter(router.getId(), context.getAccount(), context.getCaller().getId()) != null; if (!destroyResult) { s_logger.warn("Failed to clean up virtual router element " + router); } } } return stopResult & destroyResult; }
@Override public void commitMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst) { release(nic, vm, src.getReservationId()); } }
@Override public Network implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException { assert (network.getState() == State.Implementing) : "Why are we implementing " + network; Network implemented = super.implement(network, offering, dest, context); int vlanTag = Integer.parseInt(BroadcastDomainType.getValue(implemented.getBroadcastUri())); //get physical network id Long physicalNetworkId = network.getPhysicalNetworkId(); List<BrocadeVcsDeviceVO> devices = _brocadeVcsDao.listByPhysicalNetwork(physicalNetworkId); if (devices.isEmpty()) { s_logger.error("No Brocade VCS Switch on physical network " + physicalNetworkId); return null; } for (BrocadeVcsDeviceVO brocadeVcsDevice : devices) { HostVO brocadeVcsHost = _hostDao.findById(brocadeVcsDevice.getHostId()); // create createNetworkCmd instance and agentMgr execute it. CreateNetworkCommand cmd = new CreateNetworkCommand(vlanTag, network.getId(), context.getDomain().getName() + "-" + context.getAccount().getAccountName()); CreateNetworkAnswer answer = (CreateNetworkAnswer)_agentMgr.easySend(brocadeVcsHost.getId(), cmd); if (answer == null || !answer.getResult()) { s_logger.error("CreateNetworkCommand failed"); s_logger.error("Unable to create network " + network.getId()); return null; } } // Persist the network-vlan mapping from db BrocadeVcsNetworkVlanMappingVO brocadeVcsNetworkVlanMapping = new BrocadeVcsNetworkVlanMappingVO(network.getId(), vlanTag); _brocadeVcsNetworkVlanDao.persist(brocadeVcsNetworkVlanMapping); return implemented; }
@Override public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { super.reserve(nic, network, vm, dest, context); //get physical network id Long physicalNetworkId = network.getPhysicalNetworkId(); List<OpenDaylightControllerVO> devices = openDaylightControllerMappingDao.listByPhysicalNetwork(physicalNetworkId); if (devices.isEmpty()) { s_logger.error("No Controller on physical network " + physicalNetworkId); throw new InsufficientVirtualNetworkCapacityException("No OpenDaylight Controller configured for this network", dest.getPod().getId()); } OpenDaylightControllerVO controller = devices.get(0); AddHypervisorCommand addCmd = new AddHypervisorCommand(dest.getHost().getUuid(), dest.getHost().getPrivateIpAddress()); AddHypervisorAnswer addAnswer = (AddHypervisorAnswer)agentManager.easySend(controller.getHostId(), addCmd); if (addAnswer == null || !addAnswer.getResult()) { s_logger.error("Failed to add " + dest.getHost().getName() + " as a node to the controller"); throw new InsufficientVirtualNetworkCapacityException("Failed to add destination hypervisor to the OpenDaylight Controller", dest.getPod().getId()); } ConfigurePortCommand cmd = new ConfigurePortCommand(UUID.fromString(nic.getUuid()), UUID.fromString(BroadcastDomainType.getValue(network.getBroadcastUri())), context .getAccount().getAccountName(), nic.getMacAddress()); ConfigurePortAnswer answer = (ConfigurePortAnswer)agentManager.easySend(controller.getHostId(), cmd); if (answer == null || !answer.getResult()) { s_logger.error("ConfigureNetworkCommand failed"); throw new InsufficientVirtualNetworkCapacityException("Failed to configure the port on the OpenDaylight Controller", dest.getPod().getId()); } }
@Override public boolean destroy(final Network config, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(config.getId(), Role.VIRTUAL_ROUTER); if (routers == null || routers.isEmpty()) { return true; } boolean result = true; // NOTE that we need to pass caller account to destroyRouter, otherwise // it will fail permission check there. Context passed in from // deleteNetwork is the network account, // not caller account final Account callerAccount = _accountMgr.getAccount(context.getCaller().getAccountId()); for (final DomainRouterVO router : routers) { result = result && _routerMgr.destroyRouter(router.getId(), callerAccount, context.getCaller().getId()) != null; } return result; }
s_logger.error("Failed to implement shared network " + network.getUuid() + " under domain " + context.getDomain().getUuid()); throw new InsufficientVirtualNetworkCapacityException("Failed to implement shared network " + network.getUuid() + " under domain " + context.getDomain().getUuid(), Network.class, network.getId());
ExcludeList avoids = null; try { final Journal journal = start.second().getJournal();
@Override public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { super.reserve(nic, network, vm, dest, context); DataCenter dc = _dcDao.findById(network.getDataCenterId()); String interfaceMac = nic.getMacAddress(); List<BrocadeVcsDeviceVO> devices = _brocadeVcsDao.listByPhysicalNetwork(network.getPhysicalNetworkId()); if (devices.isEmpty()) { s_logger.error("No Brocade VCS Switch on physical network " + network.getPhysicalNetworkId()); return; } for (BrocadeVcsDeviceVO brocadeVcsDevice : devices) { HostVO brocadeVcsHost = _hostDao.findById(brocadeVcsDevice.getHostId()); // create AssociateMacToNetworkCmd instance and agentMgr execute it. AssociateMacToNetworkCommand cmd = new AssociateMacToNetworkCommand(network.getId(), interfaceMac, context.getDomain().getName() + "-" + context.getAccount().getAccountName()); AssociateMacToNetworkAnswer answer = (AssociateMacToNetworkAnswer)_agentMgr.easySend(brocadeVcsHost.getId(), cmd); if (answer == null || !answer.getResult()) { s_logger.error("AssociateMacToNetworkCommand failed"); throw new InsufficientVirtualNetworkCapacityException("Unable to associate mac " + interfaceMac + " to network " + network.getId(), DataCenter.class, dc.getId()); } } }
ConfigureNetworkCommand cmd = new ConfigureNetworkCommand(name, context.getAccount().getAccountName()); ConfigureNetworkAnswer answer = (ConfigureNetworkAnswer)agentManager.easySend(controller.getHostId(), cmd);
if (!deleteVlansInNetwork(networkFinal.getId(), context.getCaller().getId(), callerAccount)) { s_logger.warn("Failed to delete network " + networkFinal + "; was unable to cleanup corresponding ip ranges"); throw new CloudRuntimeException("Failed to delete network " + networkFinal + "; was unable to cleanup corresponding ip ranges");
@Override public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { List<? extends VirtualRouter> internalLbVms = _routerDao.listByNetworkAndRole(network.getId(), Role.INTERNAL_LB_VM); if (internalLbVms == null || internalLbVms.isEmpty()) { return true; } boolean result = true; for (VirtualRouter internalLbVm : internalLbVms) { result = result && (_internalLbMgr.destroyInternalLbVm(internalLbVm.getId(), context.getAccount(), context.getCaller().getId())); } return result; }
final CreateLogicalSwitchCommand cmd = new CreateLogicalSwitchCommand(transportzoneuuid, transportzoneisotype, name, context.getDomain().getName() + "-" + context.getAccount().getAccountName()); final CreateLogicalSwitchAnswer answer = (CreateLogicalSwitchAnswer) agentMgr.easySend(niciraNvpHost.getId(), cmd);
@Override public void rollbackMigration(NicProfile nic, Network network, VirtualMachineProfile vm, ReservationContext src, ReservationContext dst) { release(nic, vm, dst.getReservationId()); }
@Override public boolean shutdownVpc(final Vpc vpc, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { final List<DomainRouterVO> routers = _routerDao.listByVpcId(vpc.getId()); if (routers == null || routers.isEmpty()) { return true; } boolean result = true; for (final DomainRouterVO router : routers) { result = result && _routerMgr.destroyRouter(router.getId(), context.getAccount(), context.getCaller().getId()) != null; } return result; }
hostDao.loadDetails(niciraNvpHost); Account owner = context.getAccount(); String ownerName = context.getDomain().getName() + "-" + context.getAccount().getAccountName(); return sharedNetworkSupport(network, lSwitchUuid, ownerName, niciraNvpHost); "router-" + network.getDisplayText(), publicCidr, sourceNatIp.getGateway(), internalCidr, context.getDomain().getName() + "-" + context.getAccount().getAccountName()); CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer)agentMgr.easySend(niciraNvpHost.getId(), cmd); if (answer.getResult() == false) {
public void setPlan(DeploymentPlan plan) { if (plan != null) { dcId = plan.getDataCenterId(); podId = plan.getPodId(); clusterId = plan.getClusterId(); hostId = plan.getHostId(); poolId = plan.getPoolId(); physicalNetworkId = plan.getPhysicalNetworkId(); avoids = plan.getAvoids(); if (plan.getReservationContext() != null) reservationId = plan.getReservationContext().getReservationId(); } }
@Override public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException { List<? extends VirtualRouter> internalLbVms = _routerDao.listByNetworkAndRole(network.getId(), Role.INTERNAL_LB_VM); if (internalLbVms == null || internalLbVms.isEmpty()) { return true; } boolean result = true; for (VirtualRouter internalLbVm : internalLbVms) { result = result && _internalLbMgr.destroyInternalLbVm(internalLbVm.getId(), context.getAccount(), context.getCaller().getId()); if (cleanup) { if (!result) { s_logger.warn("Failed to stop internal lb element " + internalLbVm + ", but would try to process clean up anyway."); } result = (_internalLbMgr.destroyInternalLbVm(internalLbVm.getId(), context.getAccount(), context.getCaller().getId())); if (!result) { s_logger.warn("Failed to clean up internal lb element " + internalLbVm); } } } return result; }
UpdateLogicalSwitchPortCommand cmd = new UpdateLogicalSwitchPortCommand(existingNicMap.getLogicalSwitchPortUuid(), BroadcastDomainType.getValue(network.getBroadcastUri()), nicVO.getUuid(), context.getDomain().getName() + "-" + context.getAccount().getAccountName(), nic.getName()); agentMgr.easySend(niciraNvpHost.getId(), cmd); return true; new CreateLogicalSwitchPortCommand(BroadcastDomainType.getValue(network.getBroadcastUri()), nicVO.getUuid(), context.getDomain().getName() + "-" + context.getAccount().getAccountName(), nic.getName()); CreateLogicalSwitchPortAnswer answer = (CreateLogicalSwitchPortAnswer)agentMgr.easySend(niciraNvpHost.getId(), cmd);
String reservationId = context.getReservationId(); List<SspUuidVO> tenantPortUuidVos = _sspUuidDao.listUUidVoByNicProfile(nic); for (SspUuidVO tenantPortUuidVo : tenantPortUuidVos) {
@Override public void destroyExpendableRouters(final List<? extends VirtualRouter> routers, final ReservationContext context) throws ResourceUnavailableException { final List<VirtualRouter> remainingRouters = new ArrayList<>(); for (final VirtualRouter router : routers) { if (router.getState() == VirtualMachine.State.Stopped || router.getState() == VirtualMachine.State.Error || router.getState() == VirtualMachine.State.Shutdowned || router.getState() == VirtualMachine.State.Unknown) { s_logger.debug("Destroying old router " + router); _routerService.destroyRouter(router.getId(), context.getAccount(), context.getCaller().getId()); } else { remainingRouters.add(router); } } if (remainingRouters.size() < 2) { return; } VirtualRouter backupRouter = null; for (final VirtualRouter router : remainingRouters) { if (router.getRedundantState() == VirtualRouter.RedundantState.BACKUP) { backupRouter = router; } } if (backupRouter == null) { backupRouter = routers.get(routers.size() - 1); } if (backupRouter != null) { _routerService.destroyRouter(backupRouter.getId(), context.getAccount(), context.getCaller().getId()); } }