@Override @DB public Network getNetwork(long id) { return _networksDao.findById(id); }
@Override public List<? extends Network> listBrocadeVcsDeviceNetworks(ListBrocadeVcsDeviceNetworksCmd cmd) { Long brocadeDeviceId = cmd.getBrocadeVcsDeviceId(); BrocadeVcsDeviceVO brocadeVcsDevice = _brocadeVcsDao.findById(brocadeDeviceId); if (brocadeVcsDevice == null) { throw new InvalidParameterValueException("Could not find a Brocade VCS Switch with id " + brocadeDeviceId); } // Find the physical network we work for Long physicalNetworkId = brocadeVcsDevice.getPhysicalNetworkId(); PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId); if (physicalNetwork == null) { // No such physical network, so no provisioned networks return Collections.emptyList(); } // Find the brocade networks on this physical network List<NetworkVO> networkList = _networkDao.listByPhysicalNetwork(physicalNetworkId); if (networkList == null) { return Collections.emptyList(); } // Networks with broadcast type vcs are ours List<NetworkVO> responseList = new ArrayList<NetworkVO>(); for (NetworkVO network : networkList) { if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.Vcs) { responseList.add(network); } } return responseList; }
protected void unlock() { if (tableLockId != null) { networkDao.releaseFromLockTable(tableLockId); if (logger.isDebugEnabled()) { logger.debug("Lock is released for network id " + tableLockId + " as a part of router startup in " + dest); } } }
@Override public String getNextAvailableMacAddressInNetwork(long networkId) throws InsufficientAddressCapacityException { NetworkVO network = _networksDao.findById(networkId); String mac = _networksDao.getNextAvailableMacAddress(networkId, MACIdentifier.value()); if (mac == null) { throw new InsufficientAddressCapacityException("Unable to create another mac address", Network.class, networkId); } return mac; }
@Override public void doInTransactionWithoutResult(final TransactionStatus status) { _nicDao.update(nic.getId(), nic); if (nic.getVmType() == VirtualMachine.Type.User) { s_logger.debug("Changing active number of nics for network id=" + networkId + " on " + count); _networksDao.changeActiveNicsBy(networkId, count); } if (nic.getVmType() == VirtualMachine.Type.User || nic.getVmType() == VirtualMachine.Type.DomainRouter && _networksDao.findById(networkId).getTrafficType() == TrafficType.Guest) { _networksDao.setCheckForGc(networkId); } } });
@Override public void updateBroadcastUri(Network network) throws InsufficientVirtualNetworkCapacityException { NetworkVO updatedNetwork = _networkDao.createForUpdate(network.getId()); URI broadcastUri = calculateBroadcastUri(network); if (!broadcastUri.equals(network.getBroadcastUri())) { updatedNetwork.setBroadcastUri(broadcastUri); _networkDao.update(network.getId(), updatedNetwork); } }
@Override @DB public boolean shutdownNetwork(final long networkId, final ReservationContext context, final boolean cleanupElements) { NetworkVO network = _networksDao.findById(networkId); if (network.getState() == Network.State.Allocated) { s_logger.debug("Network is already shutdown: " + network); network = _networksDao.acquireInLockTable(networkId, NetworkLockTimeout.value()); if (network == null) { s_logger.warn("Unable to acquire lock for the network " + network + " as a part of network shutdown"); _networksDao.update(network.getId(), network); } else { try { } catch (final NoTransitionException e) { network.setState(Network.State.Shutdown); _networksDao.update(network.getId(), network); } finally { if (network != null) { _networksDao.releaseFromLockTable(network.getId()); if (s_logger.isDebugEnabled()) { s_logger.debug("Lock is released for network " + network + " as a part of network shutdown");
NetworkVO network = _networksDao.findById(networkId); if (network == null) { throwInvalidIdException("Network with specified id doesn't exist", networkId.toString(), "networkId"); if (!_networksDao.update(network.getId(), network)) { throw new CloudRuntimeException("Failed to update network into a redundant one, please try again");
network = _networkDao.findById(network.getId()); vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(vm.getVirtualMachine().getDomainId(), network, null); NetworkVO networkToUpdate = _networkDao.findById(network.getId()); String broadcastUriStr = networkToUpdate.getUuid() + "/" + vspNetwork.getVirtualRouterIp(); networkToUpdate.setBroadcastUri(Networks.BroadcastDomainType.Vsp.toUri(broadcastUriStr)); _networkDao.update(network.getId(), networkToUpdate); if (network instanceof NetworkVO) { ((NetworkVO) network).setBroadcastUri(networkToUpdate.getBroadcastUri()); _networkDao.releaseFromLockTable(network.getId()); if (s_logger.isDebugEnabled()) { s_logger.debug("Unlocked network " + network.getId() + " for creation of user VM " + vm.getInstanceName());
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) { NetworkVO forUpdate = _networkDao.createForUpdate(networkId); _networkDao.update(networkId, forUpdate);
@Override public void deleteCopyOfNetwork(long networkCopyId, long originalNetworkId) { NetworkVO networkCopy = _networksDao.findById(networkCopyId); NicVO userNic = _nicDao.findByNetworkIdAndType(networkCopyId, VirtualMachine.Type.User); if (userNic != null) { s_logger.error("Something went wrong while migrating nics from the old network to the new network. Failed to delete copy of network. There are still user nics present in the network."); throw new CloudRuntimeException("Failed to delete copy of network. There are still user nics present in the network."); } NetworkVO originalNetwork = _networksDao.findById(originalNetworkId); swapUuids(originalNetwork, networkCopy); try { if (!_networkService.deleteNetwork(networkCopy.getId(), true)) { throw new CloudRuntimeException("Failed to delete network. Clean up not successful."); } } finally { swapUuids(networkCopy, originalNetwork); } originalNetwork.setRelated(originalNetworkId); _networksDao.persist(originalNetwork); }
final Network lock = _networkDao.acquireInLockTable(guestNetwork.getId(), NetworkOrchestrationService.NetworkLockTimeout.value()); if (lock == null) { throw new ConcurrentOperationException("Unable to lock network " + guestNetwork.getId()); _networkDao.releaseFromLockTable(lock.getId()); if (s_logger.isDebugEnabled()) { s_logger.debug("Lock is released for network id " + lock.getId() + " as a part of internal lb vm startup in " + dest);
private void setRestartRequired(final NetworkVO network, final boolean restartRequired) { s_logger.debug("Marking network " + network + " with restartRequired=" + restartRequired); network.setRestartRequired(restartRequired); _networksDao.update(network.getId(), network); }
NetworkVO defaultPublicNetwork = null; if (dc.getNetworkType() == NetworkType.Advanced && dc.isSecurityGroupEnabled()) { List<NetworkVO> networks = _networkDao.listByZoneSecurityGroup(dataCenterId); if (networks == null || networks.size() == 0) { throw new CloudRuntimeException("Can not found security enabled network in SG Zone " + dc); } else { TrafficType defaultTrafficType = TrafficType.Management; List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, defaultTrafficType); List<NetworkVO> publicNetworks = _networkDao.listByZoneAndTrafficType(dataCenterId, publicTrafficType); defaultNic2.setIPv4Gateway(""); defaultNic2.setIPv4Netmask(""); String macAddress = _networkDao.getNextAvailableMacAddress(defaultPublicNetwork.getId(), null); defaultNic2.setMacAddress(macAddress);
@Override public void findInfrastructureNetworks(PhysicalNetworkVO phys, List<NetworkVO> dbList) { final TrafficType[] ttypes = {TrafficType.Control, // maps to __link_local__ TrafficType.Management, // maps to ip-fabric TrafficType.Public, TrafficType.Storage // maps to ip-fabric }; for (int i = 0; i < ttypes.length; i++) { List<NetworkVO> phys_nets; phys_nets = _networksDao.listByZoneAndTrafficType(phys.getDataCenterId(), ttypes[i]); dbList.addAll(phys_nets); } }
List<NetworkVO> networks = _networksDao.listByPhysicalNetwork(physicalNetworkId); if (networks != null && !networks.isEmpty()) { for (NetworkVO network : networks) { _networksDao.remove(network.getId());
/** * Get default network for a console proxy VM starting up in an advanced zone. If the zone * is security group-enabled, the first network found that supports SG services is returned. * If the zone is not SG-enabled, the Public network is returned. * @param dc - The zone. * @return The selected default network. * @throws CloudRuntimeException - If the zone is not a valid choice or a network couldn't be found. */ protected NetworkVO getDefaultNetworkForAdvancedZone(DataCenter dc) { if (dc.getNetworkType() != NetworkType.Advanced) { throw new CloudRuntimeException("Zone " + dc + " is not advanced."); } if (dc.isSecurityGroupEnabled()) { List<NetworkVO> networks = _networkDao.listByZoneSecurityGroup(dc.getId()); if (CollectionUtils.isEmpty(networks)) { throw new CloudRuntimeException("Can not found security enabled network in SG Zone " + dc); } return networks.get(0); } else { TrafficType defaultTrafficType = TrafficType.Public; List<NetworkVO> defaultNetworks = _networkDao.listByZoneAndTrafficType(dc.getId(), defaultTrafficType); // api should never allow this situation to happen if (defaultNetworks.size() != 1) { throw new CloudRuntimeException("Found " + defaultNetworks.size() + " networks of type " + defaultTrafficType + " when expect to find 1"); } return defaultNetworks.get(0); } }
protected void lock() { final Network lock = networkDao.acquireInLockTable(guestNetwork.getId(), NetworkOrchestrationService.NetworkLockTimeout.value()); if (lock == null) { throw new ConcurrentOperationException("Unable to lock network " + guestNetwork.getId()); } tableLockId = lock.getId(); }
|| (isolationMethod != null && isolationMethods.contains(isolationMethod) && isolationMethod.toLowerCase().equals("vxlan"))) { NetworkVO publicNetwork = _networksDao.listByZoneAndTrafficType(network.getDataCenterId(), TrafficType.Public).get(0); if (publicNetwork != null) { s_logger.debug("setting public network " + publicNetwork + " to broadcast type vxlan"); publicNetwork.setBroadcastDomainType(BroadcastDomainType.Vxlan); _networksDao.persist(publicNetwork);
_networksDao.update(networkFinal.getId(), networkFinal); _networksDao.clearCheckForGc(networkId); result = true; } else { } catch (final NoTransitionException e) { networkFinal.setState(Network.State.Implemented); _networksDao.update(networkFinal.getId(), networkFinal);