public NetworkTopology retrieveNetworkTopology(final DataCenter dc) { if (!_flyweight.containsKey(dc.getNetworkType())) { throw new IllegalArgumentException("The given type cannot be related to a NetworkTopology implementation. " + "Please, give a correct type."); } return _flyweight.get(dc.getNetworkType()); }
public boolean isBasic() { return dest.getDataCenter().getNetworkType() == NetworkType.Basic; }
@Override protected boolean canHandle(NetworkOffering offering, DataCenter dc, PhysicalNetwork physnet) { // this guru handles system Direct pod based network in Basic zones only (no isolation type specified) if (dc.getNetworkType() == NetworkType.Basic && isMyTrafficType(offering.getTrafficType())) { return true; } else { s_logger.trace("We only take care of Guest Direct Pod based networks"); return false; } }
/** * Get the default network for the console proxy VM, based on the zone it is in. Delegates to * either {@link #getDefaultNetworkForZone(DataCenter)} or {@link #getDefaultNetworkForAdvancedSGZone(DataCenter)}, * depending on the zone network type and whether or not security groups are enabled in the zone. * @param dc - The zone (DataCenter) of the console proxy VM. * @return The default network for use with the console proxy VM. */ protected NetworkVO getDefaultNetworkForCreation(DataCenter dc) { if (dc.getNetworkType() == NetworkType.Advanced) { return getDefaultNetworkForAdvancedZone(dc); } else { return getDefaultNetworkForBasicZone(dc); } }
/** * Get default network for console proxy VM for starting up in a basic zone. Basic zones select * the Guest network whether or not the zone is SG-enabled. * @param dc - The zone. * @return The default network according to the zone's network selection rules. * @throws CloudRuntimeException - If the zone is not a valid choice or a network couldn't be found. */ protected NetworkVO getDefaultNetworkForBasicZone(DataCenter dc) { if (dc.getNetworkType() != NetworkType.Basic) { throw new CloudRuntimeException("Zone " + dc + "is not basic."); } TrafficType defaultTrafficType = TrafficType.Guest; 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 boolean canHandle(NetworkOffering offering, DataCenter dc) { // This guru handles only system Guest network if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() == Network.GuestType.Isolated && offering.isSystemOnly()) { return true; } else { s_logger.trace("We only take care of system Guest networks of type " + GuestType.Isolated + " in zone of type " + NetworkType.Advanced); return false; } }
private boolean canHandle(DeployDestination dest) { if (dest.getDataCenter().getNetworkType() == NetworkType.Basic && dest.getHost().getHypervisorType() == HypervisorType.BareMetal) { return true; } return false; }
@Override public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ResourceUnavailableException, ConcurrentOperationException { DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId()); // don't have to implement network is Basic zone if (zone.getNetworkType() == NetworkType.Basic) { s_logger.debug("Not handling network shutdown in zone of type " + NetworkType.Basic); return false; } if (!canHandle(network, null)) { return false; } try { return manageGuestNetworkWithExternalFirewall(false, network); } catch (InsufficientCapacityException capacityException) { // TODO: handle out of capacity exception return false; } }
private boolean isBasicZoneNetwok(Network config) { DataCenter zone = _dcDao.findById(config.getDataCenterId()); return (zone.getNetworkType() == NetworkType.Basic && config.getGuestType() == Network.GuestType.Shared && config.getTrafficType() == TrafficType.Guest); }
public NetworkType getNetworkType() { Network ntwk = _entityMgr.findById(Network.class, getNetworkId()); DataCenter dc = _entityMgr.findById(DataCenter.class, ntwk.getDataCenterId()); return dc.getNetworkType(); }
public NetworkType getNetworkType() { Network ntwk = _entityMgr.findById(Network.class, getNetworkId()); if (ntwk != null) { DataCenter dc = _entityMgr.findById(DataCenter.class, ntwk.getDataCenterId()); return dc.getNetworkType(); } return null; }
@Override public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { if (dest.getDataCenter().getNetworkType() == DataCenter.NetworkType.Advanced){ return true; } if (offering.isSystemOnly() || !canHandle(dest, offering.getTrafficType(), network.getGuestType())) { s_logger.debug("BaremetalPxeElement can not handle network offering: " + offering.getName()); return false; } return true; }
protected String getGuestDhcpRange(final NicProfile guestNic, final Network guestNetwork, final DataCenter dc) { String dhcpRange = null; // setup dhcp range if (dc.getNetworkType() == NetworkType.Basic) { final long cidrSize = NetUtils.getCidrSize(guestNic.getIPv4Netmask()); final String cidr = NetUtils.getCidrSubNet(guestNic.getIPv4Gateway(), cidrSize); if (cidr != null) { dhcpRange = NetUtils.getIpRangeStartIpFromCidr(cidr, cidrSize); } } else if (dc.getNetworkType() == NetworkType.Advanced) { final String cidr = guestNetwork.getCidr(); if (cidr != null) { dhcpRange = NetUtils.getDhcpRange(cidr); } } return dhcpRange; } }
protected boolean isSharedNetworkWithServices(final Network network) { assert network != null; final DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId()); if (network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced && isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { return true; } return false; }
private boolean canHandle(Network config, Service service) { DataCenter zone = _dcDao.findById(config.getDataCenterId()); // Create a NCC Resource on Demand for the zone. boolean handleInAdvanceZone = (zone.getNetworkType() == NetworkType.Advanced && (config.getGuestType() == Network.GuestType.Isolated || config.getGuestType() == Network.GuestType.Shared) && config.getTrafficType() == TrafficType.Guest); boolean handleInBasicZone = (zone.getNetworkType() == NetworkType.Basic && config.getGuestType() == Network.GuestType.Shared && config.getTrafficType() == TrafficType.Guest); if (!(handleInAdvanceZone || handleInBasicZone)) { s_logger.trace("Not handling network with Type " + config.getGuestType() + " and traffic type " + config.getTrafficType() + " in zone of type " + zone.getNetworkType()); return false; } return (_networkManager.isProviderForNetwork(getProvider(), config.getId()) && _ntwkSrvcDao .canProviderSupportServiceInNetwork(config.getId(), service, Network.Provider.Netscaler)); }
@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; }
protected boolean canHandle(NetworkOffering offering, DataCenter dc, PhysicalNetwork physnet) { if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && isMyIsolationMethod(physnet) && offering.getGuestType() == GuestType.Shared && !_ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.NuageVsp) && !_ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.NiciraNvp)) { return true; } else { s_logger.trace("We only take care of Guest networks of type " + GuestType.Shared); return false; } }
@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; }
private boolean canHandle(DeployDestination dest, TrafficType trafficType, GuestType networkType) { Pod pod = dest.getPod(); if (pod != null && dest.getDataCenter().getNetworkType() == NetworkType.Basic && trafficType == TrafficType.Guest) { QueryBuilder<BaremetalDhcpVO> sc = QueryBuilder.create(BaremetalDhcpVO.class); sc.and(sc.entity().getPodId(), Op.EQ, pod.getId()); return sc.find() != null; } return false; }
private boolean canHandle(Network network, Service service) { DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId()); if (zone.getNetworkType() == NetworkType.Advanced && network.getGuestType() != Network.GuestType.Isolated) { s_logger.trace("Element " + getProvider().getName() + "is not handling network type = " + network.getGuestType()); return false; } if (service == null) { if (!_networkManager.isProviderForNetwork(getProvider(), network.getId())) { s_logger.trace("Element " + getProvider().getName() + " is not a provider for the network " + network); return false; } } else { if (!_networkManager.isProviderSupportServiceInNetwork(network.getId(), service, getProvider())) { s_logger.trace("Element " + getProvider().getName() + " doesn't support service " + service.getName() + " in the network " + network); return false; } } return true; }