@Override public void onPublishMessage(String senderAddress, String subject, Object args) { try { NetworkVO network = (NetworkVO) args; String bridgeName=generateBridgeNameForVpc(network.getVpcId()); if (network.getVpcId() != null && isVpcEnabledForDistributedRouter(network.getVpcId())) { long vpcId = network.getVpcId(); OvsVpcRoutingPolicyConfigCommand cmd = prepareVpcRoutingPolicyUpdate(vpcId); cmd.setSequenceNumber(getNextRoutingPolicyUpdateSequenceNumber(vpcId)); // get the list of hosts on which VPC spans (i.e hosts that need to be aware of VPC // network ACL update) List<Long> vpcSpannedHostIds = _ovsNetworkToplogyGuru.getVpcSpannedHosts(vpcId); for (Long id: vpcSpannedHostIds) { if (!sendVpcRoutingPolicyChangeUpdate(cmd, id, bridgeName)) { s_logger.debug("Failed to send VPC routing policy change update to host : " + id + ". But moving on with sending the updates to the rest of the hosts."); } } } } catch (Exception e) { s_logger.debug("Failed to send VPC routing policy change updates all hosts in vpc", e); } } }
@Override public List<NetworkVO> listVpcNetworks() { final SearchBuilder<NetworkVO> sb = createSearchBuilder(); sb.and("vpcId", sb.entity().getVpcId(), Op.NNULL); sb.done(); final SearchCriteria<NetworkVO> sc = sb.create(); return listBy(sc); }
if (network.getVpcId() == null) { throw new InvalidParameterValueException("Network is not part of a VPC: " + network.getUuid()); if (!network.getVpcId().equals(acl.getVpcId())) { throw new InvalidParameterValueException("Network: " + networkId + " and ACL: " + aclId + " do not belong to the same VPC");
@Override @ActionEvent(eventType = EventTypes.EVENT_NETWORK_MIGRATE, eventDescription = "migrating network", async = true) public Network migrateGuestNetwork(long networkId, long networkOfferingId, Account callerAccount, User callerUser, boolean resume) { NetworkVO network = _networksDao.findById(networkId); NetworkOffering newNtwkOff = _networkOfferingDao.findById(networkOfferingId); //perform below validation if the network is vpc network if (network.getVpcId() != null) { s_logger.warn("Failed to migrate network as the specified network is a vpc tier. Use migrateVpc."); throw new InvalidParameterValueException("Failed to migrate network as the specified network is a vpc tier. Use migrateVpc."); } if (_configMgr.isOfferingForVpc(newNtwkOff)) { s_logger.warn("Failed to migrate network as the specified network offering is a VPC offering"); throw new InvalidParameterValueException("Failed to migrate network as the specified network offering is a VPC offering"); } verifyNetworkCanBeMigrated(callerAccount, network); //Retrieve new Physical NetworkId long newPhysicalNetworkId = findPhysicalNetworkId(network.getDataCenterId(), newNtwkOff.getTags(), newNtwkOff.getTrafficType()); final long oldNetworkOfferingId = network.getNetworkOfferingId(); NetworkOffering oldNtwkOff = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId); if (!resume && network.getRelated() != network.getId()) { s_logger.warn("Related network is not equal to network id. You might want to re-run migration with resume = true command."); throw new CloudRuntimeException("Failed to migrate network as previous migration left this network in transient condition. Specify resume as true."); } if (networkNeedsMigration(network, newPhysicalNetworkId, oldNtwkOff, newNtwkOff)) { return migrateNetworkToPhysicalNetwork(network, oldNtwkOff, newNtwkOff, null, null, newPhysicalNetworkId, callerAccount, callerUser); } else { s_logger.info("Network does not need migration."); return network; } }
final Long vpcId = network.getVpcId();
NetworkVO designedNetwork = _networkDao.findById(networkId); String externalId = designedNetwork.getExternalId(); boolean isVpc = designedNetwork.getVpcId() != null; if (isVpc && _networkDao.listByVpc(designedNetwork.getVpcId()).size() > 1) { boolean isVsdManagedVpc = isVsdManagedVpc(designedNetwork.getVpcId()); if (isVsdManagedVpc && externalId == null) { throw new CloudRuntimeException("Refusing to design network. Network is vsdManaged but is part of a non vsd managed vpc."); saveNetworkAndVpcDetails(vspNetwork, implementAnswer.getNetworkRelatedVsdIds(), designedNetwork.getVpcId()); saveNetworkDetail(networkId, NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID, externalId); saveNetworkDetail(networkId, NuageVspManager.NETWORK_METADATA_VSD_MANAGED, "true");
throw new InvalidParameterValueException("Unable to find network by id " + networkIdList.get(0).longValue()); if (network.getVpcId() != null) {
if (network.getVpcId() != null && networkOfferingId != null) { Vpc vpc = _entityMgr.findById(Vpc.class, network.getVpcId()); _vpcMgr.validateNtwkOffForNtwkInVpc(networkId, networkOfferingId, null, null, vpc, null, _accountMgr.getAccount(network.getAccountId()), network.getNetworkACLId()); && (networkOfferingId == null || _networkOfferingDao.findById(networkOfferingId).isRedundantRouter()) && network.getVpcId() == null) { _networkMgr.canUpdateInSequence(network, forced); NetworkDetailVO networkDetail = new NetworkDetailVO(network.getId(), Network.updatingInSequence, "true", true);
if (network.getVpcId() != null) { if (vpcNetwork) { throw new InvalidParameterValueException("Vm can't be a part of more than 1 VPC network");
AllFieldsSearch.and("physicalNetwork", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ); AllFieldsSearch.and("broadcastUri", AllFieldsSearch.entity().getBroadcastUri(), Op.EQ); AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ); AllFieldsSearch.and("aclId", AllFieldsSearch.entity().getNetworkACLId(), Op.EQ); AllFieldsSearch.and("redundant", AllFieldsSearch.entity().isRedundant(), Op.EQ); AccountSearch.and("datacenter", AccountSearch.entity().getDataCenterId(), Op.EQ); AccountSearch.and("cidr", AccountSearch.entity().getCidr(), Op.EQ); AccountSearch.and("vpcId", AccountSearch.entity().getVpcId(), Op.EQ); AccountSearch.done(); CountBy.select(null, Func.COUNT, CountBy.entity().getId()); CountBy.and("offeringId", CountBy.entity().getNetworkOfferingId(), Op.EQ); CountBy.and("vpcId", CountBy.entity().getVpcId(), Op.EQ); CountBy.and("removed", CountBy.entity().getRemoved(), Op.NULL); final SearchBuilder<NetworkOfferingVO> ntwkOffJoin = _ntwkOffDao.createSearchBuilder(); VpcNetworksCount.and("vpcId", VpcNetworksCount.entity().getVpcId(), Op.EQ); VpcNetworksCount.select(null, Func.COUNT, VpcNetworksCount.entity().getId()); final SearchBuilder<NetworkOfferingVO> join9 = _ntwkOffDao.createSearchBuilder();