@Override public PhysicalNetwork getPhysicalNetwork(Long physicalNetworkId) { return _physicalNetworkDao.findById(physicalNetworkId); }
public static PhysicalNetworkVO findPhysicalNetworkById(long id) { return s_physicalNetworkDao.findById(id); }
@Override public boolean isReady(PhysicalNetworkServiceProvider provider) { PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(provider.getPhysicalNetworkId()); assert (physicalNetwork != null); if (fetchSspClients(physicalNetwork.getId(), physicalNetwork.getDataCenterId(), false).size() > 0) { return true; } s_logger.warn("Ssp api endpoint not found. " + physicalNetwork.toString()); return false; }
@Override public Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long physicalNetworkId) { PhysicalNetworkVO network = _physicalNetworkDao.findById(physicalNetworkId); if (network == null) { throwInvalidIdException("Physical Network with specified id doesn't exist in the system", physicalNetworkId.toString(), "physicalNetworkId"); } Pair<List<PhysicalNetworkTrafficTypeVO>, Integer> result = _pNTrafficTypeDao.listAndCountBy(physicalNetworkId); return new Pair<List<? extends PhysicalNetworkTrafficType>, Integer>(result.first(), result.second()); }
private boolean canHandle(Network network) { if (canHandle(_physicalNetworkDao.findById(network.getPhysicalNetworkId()))) { if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), Service.Connectivity, getProvider())) { s_logger.info("SSP is implicitly active for " + network); } return true; } return false; }
@Override public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) { // Check if the isolation type of the physical network is BCF_SEGMENT, then delegate GuestNetworkGuru to design PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId()); if (physnet == null || physnet.getIsolationMethods() == null || !physnet.getIsolationMethods().contains("BCF_SEGMENT")) { s_logger.debug("Refusing to design this network, the physical isolation type is not BCF_SEGMENT"); return null; } List<BigSwitchBcfDeviceVO> devices = _bigswitchBcfDao.listByPhysicalNetwork(physnet.getId()); if (devices.isEmpty()) { s_logger.error("No BigSwitch Controller on physical network " + physnet.getName()); return null; } for (BigSwitchBcfDeviceVO d: devices){ s_logger.debug("BigSwitch Controller " + d.getUuid() + " found on physical network " + physnet.getId()); } s_logger.debug("Physical isolation type is BCF_SEGMENT, asking GuestNetworkGuru to design this network"); NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner); if (networkObject == null) { return null; } // Override the broadcast domain type networkObject.setBroadcastDomainType(BroadcastDomainType.Vlan); return networkObject; }
@Override public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { PhysicalNetwork pNtwk = _physicalNetworkDao.findById(provider.getPhysicalNetworkId()); Host host = getGloboDnsHost(pNtwk.getDataCenterId()); if (host != null) { _resourceMgr.deleteHost(host.getId(), true, false); } return true; }
@Override public List<BigSwitchBcfDeviceVO> listBigSwitchBcfDevices(ListBigSwitchBcfDevicesCmd cmd) { Long physicalNetworkId = cmd.getPhysicalNetworkId(); Long bigswitchBcfDeviceId = cmd.getBigSwitchBcfDeviceId(); List<BigSwitchBcfDeviceVO> responseList = new ArrayList<BigSwitchBcfDeviceVO>(); if (physicalNetworkId == null && bigswitchBcfDeviceId == null) { throw new InvalidParameterValueException("Either physical network Id or bigswitch device Id must be specified"); } if (bigswitchBcfDeviceId != null) { BigSwitchBcfDeviceVO bigswitchBcfDevice = _bigswitchBcfDao.findById(bigswitchBcfDeviceId); if (bigswitchBcfDevice == null) { throw new InvalidParameterValueException("Could not find BigSwitch controller with id: " + bigswitchBcfDevice); } responseList.add(bigswitchBcfDevice); } else { PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId); if (physicalNetwork == null) { throw new InvalidParameterValueException("Could not find a physical network with id: " + physicalNetworkId); } responseList = _bigswitchBcfDao.listByPhysicalNetwork(physicalNetworkId); } return responseList; }
@Override public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) { // Check of the isolation type of the related physical network is VLAN PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId()); DataCenter dc = _dcDao.findById(plan.getDataCenterId()); if (!canHandle(offering, dc.getNetworkType(), physnet)) { s_logger.debug("Refusing to design this network"); return null; } s_logger.debug("Physical isolation type is VCS, asking GuestNetworkGuru to design this network"); NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner); if (networkObject == null) { return null; } // Override the broadcast domain type networkObject.setBroadcastDomainType(BroadcastDomainType.Vcs); networkObject.setState(State.Allocated); return networkObject; }
@Override public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) { PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan .getPhysicalNetworkId()); DataCenter dc = _dcDao.findById(plan.getDataCenterId()); if (!canHandle(offering, dc.getNetworkType(), physnet)) { s_logger.debug("Refusing to design this network"); return null; } NetworkVO config = (NetworkVO)super.design(offering, plan, userSpecified, owner); if (config == null) { return null; } config.setBroadcastDomainType(BroadcastDomainType.Vswitch); return config; }
@Override public List<Host> listExternalLoadBalancers(long physicalNetworkId, String deviceName) { List<Host> lbHosts = new ArrayList<Host>(); NetworkDevice lbNetworkDevice = NetworkDevice.getNetworkDevice(deviceName); PhysicalNetworkVO pNetwork = null; pNetwork = _physicalNetworkDao.findById(physicalNetworkId); if ((pNetwork == null) || (lbNetworkDevice == null)) { throw new InvalidParameterValueException("Atleast one of the required parameter physical networkId, device name is invalid."); } PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(pNetwork.getId(), lbNetworkDevice.getNetworkServiceProvder()); // if provider not configured in to physical network, then there can be no instances if (ntwkSvcProvider == null) { return null; } List<ExternalLoadBalancerDeviceVO> lbDevices = _externalLoadBalancerDeviceDao.listByPhysicalNetworkAndProvider(physicalNetworkId, ntwkSvcProvider.getProviderName()); for (ExternalLoadBalancerDeviceVO provderInstance : lbDevices) { lbHosts.add(_hostDao.findById(provderInstance.getHostId())); } return lbHosts; }
@Override public List<Host> listExternalFirewalls(long physicalNetworkId, String deviceName) { List<Host> firewallHosts = new ArrayList<Host>(); NetworkDevice fwNetworkDevice = NetworkDevice.getNetworkDevice(deviceName); PhysicalNetworkVO pNetwork = null; pNetwork = _physicalNetworkDao.findById(physicalNetworkId); if (pNetwork == null) { throw new InvalidParameterValueException("Could not find phyical network with ID: " + physicalNetworkId); } if ((pNetwork == null) || (fwNetworkDevice == null)) { throw new InvalidParameterValueException("Atleast one of ther required parameter physical networkId, device name is missing or invalid."); } PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(pNetwork.getId(), fwNetworkDevice.getNetworkServiceProvder()); if (ntwkSvcProvider == null) { return null; } List<ExternalFirewallDeviceVO> fwDevices = _externalFirewallDeviceDao.listByPhysicalNetworkAndProvider(physicalNetworkId, ntwkSvcProvider.getProviderName()); for (ExternalFirewallDeviceVO fwDevice : fwDevices) { firewallHosts.add(_hostDao.findById(fwDevice.getHostId())); } return firewallHosts; }
private PhysicalNetworkServiceProvider addConfigDriveToPhysicalNetwork(long physicalNetworkId) { PhysicalNetworkVO pvo = _physicalNetworkDao.findById(physicalNetworkId); DataCenterVO dvo = _dcDao.findById(pvo.getDataCenterId()); if (dvo.getNetworkType() == NetworkType.Advanced) { Provider provider = Network.Provider.getProvider("ConfigDrive"); if (provider == null) { return null; } addProviderToPhysicalNetwork(physicalNetworkId, Provider.ConfigDrive.getName(), null, null); enableProvider(Provider.ConfigDrive.getName()); } return null; }
public int getVlanOffset(final long physicalNetworkId, final int vlanTag) { final PhysicalNetworkVO pNetwork = _physicalNetworkDao.findById(physicalNetworkId); if (pNetwork == null) { throw new CloudRuntimeException("Could not find the physical Network " + physicalNetworkId + "."); } if (pNetwork.getVnet() == null) { throw new CloudRuntimeException("Could not find vlan range for physical Network " + physicalNetworkId + "."); } Integer lowestVlanTag = null; final List<Pair<Integer, Integer>> vnetList = pNetwork.getVnet(); //finding the vlanrange in which the vlanTag lies. for (final Pair<Integer, Integer> vnet : vnetList) { if (vlanTag >= vnet.first() && vlanTag <= vnet.second()) { lowestVlanTag = vnet.first(); } } if (lowestVlanTag == null) { throw new InvalidParameterValueException("The vlan tag does not belong to any of the existing vlan ranges"); } return vlanTag - lowestVlanTag; }
public int getVlanOffset(long physicalNetworkId, int vlanTag) { PhysicalNetworkVO pNetwork = _physicalNetworkDao.findById(physicalNetworkId); if (pNetwork == null) { throw new CloudRuntimeException("Could not find the physical Network " + physicalNetworkId + "."); } if (pNetwork.getVnet() == null) { throw new CloudRuntimeException("Could not find vlan range for physical Network " + physicalNetworkId + "."); } Integer lowestVlanTag = null; List<Pair<Integer, Integer>> vnetList = pNetwork.getVnet(); //finding the vlanrange in which the vlanTag lies. for (Pair<Integer, Integer> vnet : vnetList) { if (vlanTag >= vnet.first() && vlanTag <= vnet.second()) { lowestVlanTag = vnet.first(); } } if (lowestVlanTag == null) { throw new InvalidParameterValueException("The vlan tag does not belong to any of the existing vlan ranges"); } return vlanTag - lowestVlanTag; }
private PhysicalNetworkServiceProvider addDefaultBaremetalProvidersToPhysicalNetwork(long physicalNetworkId) { PhysicalNetworkVO pvo = _physicalNetworkDao.findById(physicalNetworkId); DataCenterVO dvo = _dcDao.findById(pvo.getDataCenterId()); if (dvo.getNetworkType() == NetworkType.Basic) { Provider provider = Network.Provider.getProvider("BaremetalDhcpProvider"); if (provider == null) { // baremetal is not loaded return null; } addProviderToPhysicalNetwork(physicalNetworkId, "BaremetalDhcpProvider", null, null); addProviderToPhysicalNetwork(physicalNetworkId, "BaremetalPxeProvider", null, null); addProviderToPhysicalNetwork(physicalNetworkId, "BaremetalUserdataProvider", null, null); } else if (dvo.getNetworkType() == NetworkType.Advanced) { addProviderToPhysicalNetwork(physicalNetworkId, "BaremetalPxeProvider", null, null); enableProvider("BaremetalPxeProvider"); } return null; }
@Override public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) { // Check of the isolation type of the related physical network is L3VPN PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId()); DataCenter dc = _dcDao.findById(plan.getDataCenterId()); if (!canHandle(offering, dc.getNetworkType(),physnet)) { s_logger.debug("Refusing to design this network"); return null; } NetworkVO network = new NetworkVO(offering.getTrafficType(), Mode.Dhcp, BroadcastDomainType.Lswitch, offering.getId(), State.Allocated, plan.getDataCenterId(), plan.getPhysicalNetworkId(), offering.isRedundantRouter()); if (userSpecified.getCidr() != null) { network.setCidr(userSpecified.getCidr()); network.setGateway(userSpecified.getGateway()); } s_logger.debug("Allocated network " + userSpecified.getName() + (network.getCidr() == null ? "" : " subnet: " + network.getCidr())); return network; }
@Override public BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo) { BaremetalPxeResponse response = new BaremetalPxeResponse(); response.setId(vo.getUuid()); HostVO host = _hostDao.findById(vo.getHostId()); response.setUrl(host.getPrivateIpAddress()); PhysicalNetworkServiceProviderVO providerVO = _physicalNetworkServiceProviderDao.findById(vo.getNetworkServiceProviderId()); response.setPhysicalNetworkId(providerVO.getUuid()); PhysicalNetworkVO nwVO = _physicalNetworkDao.findById(vo.getPhysicalNetworkId()); response.setPhysicalNetworkId(nwVO.getUuid()); response.setObjectName("baremetalpxeserver"); return response; }
@Override @ActionEvent(eventType = EventTypes.EVENT_TRAFFIC_TYPE_DELETE, eventDescription = "Deleting physical network TrafficType", async = true) public boolean deletePhysicalNetworkTrafficType(Long id) { PhysicalNetworkTrafficTypeVO trafficType = _pNTrafficTypeDao.findById(id); if (trafficType == null) { throw new InvalidParameterValueException("Traffic Type with id=" + id + "doesn't exist in the system"); } // check if there are any networks associated to this physical network with this traffic type if (TrafficType.Guest.equals(trafficType.getTrafficType())) { if (!_networksDao.listByPhysicalNetworkTrafficType(trafficType.getPhysicalNetworkId(), trafficType.getTrafficType()).isEmpty()) { throw new CloudRuntimeException("The Traffic Type is not deletable because there are existing networks with this traffic type:" + trafficType.getTrafficType()); } } else if (TrafficType.Storage.equals(trafficType.getTrafficType())) { PhysicalNetworkVO pn = _physicalNetworkDao.findById(trafficType.getPhysicalNetworkId()); if (_stnwMgr.isAnyStorageIpInUseInZone(pn.getDataCenterId())) { throw new CloudRuntimeException("The Traffic Type is not deletable because there are still some storage network ip addresses in use:" + trafficType.getTrafficType()); } } return _pNTrafficTypeDao.remove(id); }
@Override public BaremetalDhcpResponse generateApiResponse(BaremetalDhcpVO vo) { BaremetalDhcpResponse response = new BaremetalDhcpResponse(); response.setDeviceType(vo.getDeviceType()); response.setId(vo.getUuid()); HostVO host = _hostDao.findById(vo.getHostId()); response.setUrl(host.getPrivateIpAddress()); PhysicalNetworkVO nwVO = _physicalNetworkDao.findById(vo.getPhysicalNetworkId()); response.setPhysicalNetworkId(nwVO.getUuid()); PhysicalNetworkServiceProviderVO providerVO = _physicalNetworkServiceProviderDao.findById(vo.getNetworkServiceProviderId()); response.setProviderId(providerVO.getUuid()); response.setObjectName("baremetaldhcp"); return response; }