Search in sources :

Example 36 with NetworkOfferingVO

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

the class CreateNetworkOfferingTest method createSharedNtwkOffWithVlan.

// Test Shared network offerings
@Test
public void createSharedNtwkOffWithVlan() {
    NetworkOfferingVO off = configMgr.createNetworkOffering("shared", "shared", TrafficType.Guest, null, true, Availability.Optional, 200, null, false, Network.GuestType.Shared, false, null, false, null, true, false, null, false, null, true, false, null, null, false);
    assertNotNull("Shared network offering with specifyVlan=true failed to create ", off);
}
Also used : NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) Test(org.junit.Test)

Example 37 with NetworkOfferingVO

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

the class CreateNetworkOfferingTest method createIsolatedNtwkOffWithVlan.

@Test
public void createIsolatedNtwkOffWithVlan() {
    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, true, 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 specifyVlan=true wasn't created", 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 38 with NetworkOfferingVO

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

the class ConfigurationServerImpl method createDefaultNetworks.

private void createDefaultNetworks() {
    List<DataCenterVO> zones = _dataCenterDao.listAll();
    long id = 1;
    HashMap<TrafficType, String> guruNames = new HashMap<TrafficType, String>();
    guruNames.put(TrafficType.Public, PublicNetworkGuru.class.getSimpleName());
    guruNames.put(TrafficType.Management, PodBasedNetworkGuru.class.getSimpleName());
    guruNames.put(TrafficType.Control, ControlNetworkGuru.class.getSimpleName());
    guruNames.put(TrafficType.Storage, StorageNetworkGuru.class.getSimpleName());
    guruNames.put(TrafficType.Guest, DirectPodBasedNetworkGuru.class.getSimpleName());
    for (DataCenterVO zone : zones) {
        long zoneId = zone.getId();
        long accountId = 1L;
        Long domainId = zone.getDomainId();
        if (domainId == null) {
            domainId = 1L;
        }
        // Create default networks - system only
        List<NetworkOfferingVO> ntwkOff = _networkOfferingDao.listSystemNetworkOfferings();
        for (NetworkOfferingVO offering : ntwkOff) {
            if (offering.isSystemOnly()) {
                long related = id;
                long networkOfferingId = offering.getId();
                Mode mode = Mode.Static;
                String networkDomain = null;
                BroadcastDomainType broadcastDomainType = null;
                TrafficType trafficType = offering.getTrafficType();
                boolean specifyIpRanges = false;
                if (trafficType == TrafficType.Management) {
                    broadcastDomainType = BroadcastDomainType.Native;
                } else if (trafficType == TrafficType.Storage) {
                    broadcastDomainType = BroadcastDomainType.Native;
                    specifyIpRanges = true;
                } else if (trafficType == TrafficType.Control) {
                    broadcastDomainType = BroadcastDomainType.LinkLocal;
                } else if (offering.getTrafficType() == TrafficType.Public) {
                    if ((zone.getNetworkType() == NetworkType.Advanced && !zone.isSecurityGroupEnabled()) || zone.getNetworkType() == NetworkType.Basic) {
                        specifyIpRanges = true;
                        broadcastDomainType = BroadcastDomainType.Vlan;
                    } else {
                        continue;
                    }
                }
                if (broadcastDomainType != null) {
                    NetworkVO network = new NetworkVO(id, trafficType, mode, broadcastDomainType, networkOfferingId, domainId, accountId, related, null, null, networkDomain, Network.GuestType.Shared, zoneId, null, null, specifyIpRanges, null, offering.isRedundantRouter());
                    network.setGuruName(guruNames.get(network.getTrafficType()));
                    network.setDns1(zone.getDns1());
                    network.setDns2(zone.getDns2());
                    network.setState(State.Implemented);
                    _networkDao.persist(network, false, getServicesAndProvidersForNetwork(networkOfferingId));
                    id++;
                }
            }
        }
    }
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkVO(com.cloud.network.dao.NetworkVO) HashMap(java.util.HashMap) Mode(com.cloud.network.Networks.Mode) StorageNetworkGuru(com.cloud.network.guru.StorageNetworkGuru) PublicNetworkGuru(com.cloud.network.guru.PublicNetworkGuru) ControlNetworkGuru(com.cloud.network.guru.ControlNetworkGuru) BroadcastDomainType(com.cloud.network.Networks.BroadcastDomainType) PodBasedNetworkGuru(com.cloud.network.guru.PodBasedNetworkGuru) DirectPodBasedNetworkGuru(com.cloud.network.guru.DirectPodBasedNetworkGuru) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) DirectPodBasedNetworkGuru(com.cloud.network.guru.DirectPodBasedNetworkGuru) TrafficType(com.cloud.network.Networks.TrafficType)

Example 39 with NetworkOfferingVO

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

the class IpAddressManagerTest method setup.

@Before
public void setup() throws ResourceUnavailableException {
    ipAddressVO = new IPAddressVO(new Ip("192.0.0.1"), 1L, 1L, 1L, false);
    ipAddressVO.setAllocatedToAccountId(1L);
    account = new AccountVO("admin", 1L, null, (short) 1, 1L, "c65a73d5-ebbd-11e7-8f45-107b44277808");
    account.setId(1L);
    NetworkOfferingVO networkOfferingVO = Mockito.mock(NetworkOfferingVO.class);
    networkOfferingVO.setSharedSourceNat(false);
    Mockito.when(networkOfferingDao.findById(Mockito.anyLong())).thenReturn(networkOfferingVO);
}
Also used : Ip(com.cloud.utils.net.Ip) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) IPAddressVO(com.cloud.network.dao.IPAddressVO) AccountVO(com.cloud.user.AccountVO) Before(org.junit.Before)

Example 40 with NetworkOfferingVO

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

the class ConfigDriveNetworkElementTest method testCanHandle.

@Test
public void testCanHandle() throws InsufficientCapacityException, ResourceUnavailableException {
    final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class);
    when(ntwkoffer.getTrafficType()).thenReturn(Networks.TrafficType.Guest);
    assertTrue(_configDrivesNetworkElement.implement(null, ntwkoffer, null, null));
    when(ntwkoffer.getTrafficType()).thenReturn(Networks.TrafficType.Public);
    assertFalse(_configDrivesNetworkElement.implement(null, ntwkoffer, null, null));
}
Also used : NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) 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