Search in sources :

Example 31 with NetworkOfferingVO

use of com.cloud.offerings.NetworkOfferingVO in project cloudstack by apache.

the class NetworkModelImpl method checkIpForService.

@Override
public boolean checkIpForService(IpAddress userIp, Service service, Long networkId) {
    if (networkId == null) {
        networkId = userIp.getAssociatedWithNetworkId();
    }
    NetworkVO network = _networksDao.findById(networkId);
    NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
    if (offering.getGuestType() != GuestType.Isolated) {
        return true;
    }
    IPAddressVO ipVO = _ipAddressDao.findById(userIp.getId());
    PublicIp publicIp = PublicIp.createFromAddrAndVlan(ipVO, _vlanDao.findById(userIp.getVlanId()));
    if (!canIpUsedForService(publicIp, service, networkId)) {
        return false;
    }
    if (!offering.isConserveMode()) {
        return canIpUsedForNonConserveService(publicIp, service);
    }
    return true;
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) PublicIp(com.cloud.network.addr.PublicIp) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) IPAddressVO(com.cloud.network.dao.IPAddressVO)

Example 32 with NetworkOfferingVO

use of com.cloud.offerings.NetworkOfferingVO in project cloudstack by apache.

the class NetworkModelImpl method getSystemNetworkByZoneAndTrafficType.

@Override
public NetworkVO getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType) {
    // find system public network offering
    Long networkOfferingId = null;
    List<NetworkOfferingVO> offerings = _networkOfferingDao.listSystemNetworkOfferings();
    for (NetworkOfferingVO offering : offerings) {
        if (offering.getTrafficType() == trafficType) {
            networkOfferingId = offering.getId();
            break;
        }
    }
    if (networkOfferingId == null) {
        throw new InvalidParameterValueException("Unable to find system network offering with traffic type " + trafficType);
    }
    List<NetworkVO> networks = _networksDao.listBy(Account.ACCOUNT_ID_SYSTEM, networkOfferingId, zoneId);
    if (networks == null || networks.isEmpty()) {
        // TBD: send uuid instead of zoneId. Hardcode tablename in call to addProxyObject().
        throw new InvalidParameterValueException("Unable to find network with traffic type " + trafficType + " in zone " + zoneId);
    }
    return networks.get(0);
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO)

Example 33 with NetworkOfferingVO

use of com.cloud.offerings.NetworkOfferingVO in project cloudstack by apache.

the class CreateNetworkOfferingTest method createIsolatedNtwkOffWithNoVlan.

// Test Isolated network offerings
@Test
public void createIsolatedNtwkOffWithNoVlan() {
    Map<Service, Set<Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
    Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
    vrProvider.add(Provider.VirtualRouter);
    serviceProviderMap.put(Network.Service.SourceNat, vrProvider);
    NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, false, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, false, null, null, false);
    assertNotNull("Isolated network offering with specifyIpRanges=false failed to create ", off);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Network(com.cloud.network.Network) Service(com.cloud.network.Network.Service) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) Provider(com.cloud.network.Network.Provider) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 34 with NetworkOfferingVO

use of com.cloud.offerings.NetworkOfferingVO in project cloudstack by apache.

the class CreateNetworkOfferingTest method setUp.

@Override
@Before
public void setUp() {
    ComponentContext.initComponentsLifeCycle();
    ConfigurationVO configVO = new ConfigurationVO("200", "200", "200", "200", "200", "200");
    Mockito.when(configDao.findByName(anyString())).thenReturn(configVO);
    Mockito.when(offDao.persist(any(NetworkOfferingVO.class))).thenReturn(new NetworkOfferingVO());
    Mockito.when(offDao.persist(any(NetworkOfferingVO.class), nullable(Map.class))).thenReturn(new NetworkOfferingVO());
    Mockito.when(mapDao.persist(any(NetworkOfferingServiceMapVO.class))).thenReturn(new NetworkOfferingServiceMapVO());
    Mockito.when(accountMgr.getSystemUser()).thenReturn(new UserVO(1));
    Mockito.when(accountMgr.getSystemAccount()).thenReturn(new AccountVO(2));
    CallContext.register(accountMgr.getSystemUser(), accountMgr.getSystemAccount());
}
Also used : NetworkOfferingServiceMapVO(com.cloud.offerings.NetworkOfferingServiceMapVO) ConfigurationVO(org.apache.cloudstack.framework.config.impl.ConfigurationVO) UserVO(com.cloud.user.UserVO) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) HashMap(java.util.HashMap) Map(java.util.Map) AccountVO(com.cloud.user.AccountVO) Before(org.junit.Before)

Example 35 with NetworkOfferingVO

use of com.cloud.offerings.NetworkOfferingVO in project cloudstack by apache.

the class CreateNetworkOfferingTest method createVpcNtwkOff.

@Test
public void createVpcNtwkOff() {
    Map<Service, Set<Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
    Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
    vrProvider.add(Provider.VPCVirtualRouter);
    serviceProviderMap.put(Network.Service.Dhcp, vrProvider);
    serviceProviderMap.put(Network.Service.Dns, vrProvider);
    serviceProviderMap.put(Network.Service.Lb, vrProvider);
    serviceProviderMap.put(Network.Service.SourceNat, vrProvider);
    serviceProviderMap.put(Network.Service.Gateway, vrProvider);
    serviceProviderMap.put(Network.Service.Lb, vrProvider);
    NetworkOfferingVO off = configMgr.createNetworkOffering("isolated", "isolated", TrafficType.Guest, null, true, Availability.Optional, 200, serviceProviderMap, false, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, null, null, false);
    // System.out.println("Creating Vpc Network Offering");
    assertNotNull("Vpc Isolated network offering with Vpc provider ", off);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Network(com.cloud.network.Network) Service(com.cloud.network.Network.Service) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) Provider(com.cloud.network.Network.Provider) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)128 NetworkVO (com.cloud.network.dao.NetworkVO)45 ArrayList (java.util.ArrayList)34 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)32 Network (com.cloud.network.Network)27 DB (com.cloud.utils.db.DB)27 Test (org.junit.Test)27 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)26 Service (com.cloud.network.Network.Service)26 Account (com.cloud.user.Account)24 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)23 Provider (com.cloud.network.Network.Provider)22 PhysicalNetwork (com.cloud.network.PhysicalNetwork)21 HashSet (java.util.HashSet)21 TransactionStatus (com.cloud.utils.db.TransactionStatus)20 HashMap (java.util.HashMap)20 Set (java.util.Set)20 DataCenterVO (com.cloud.dc.DataCenterVO)19 NetworkOffering (com.cloud.offering.NetworkOffering)19 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)18