Search in sources :

Example 76 with NetworkVO

use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.

the class ManagementServerMock method createPublicVlanIpRange.

private void createPublicVlanIpRange() {
    CreateVlanIpRangeCmd cmd = new CreateVlanIpRangeCmd();
    BaseCmd proxy = ComponentContext.inject(cmd);
    Long public_net_id = null;
    List<NetworkVO> nets = _networksDao.listByZoneAndTrafficType(_zone.getId(), TrafficType.Public);
    if (nets != null && !nets.isEmpty()) {
        NetworkVO public_net = nets.get(0);
        public_net_id = public_net.getId();
    } else {
        s_logger.debug("no public network found in the zone: " + _zone.getId());
    }
    Account system = _accountMgr.getSystemAccount();
    setParameter(cmd, "accountName", BaseCmd.CommandType.STRING, system.getAccountName());
    setParameter(cmd, "domainId", BaseCmd.CommandType.LONG, Domain.ROOT_DOMAIN);
    setParameter(cmd, "startIp", BaseCmd.CommandType.STRING, "10.84.60.200");
    setParameter(cmd, "endIp", BaseCmd.CommandType.STRING, "10.84.60.250");
    setParameter(cmd, ApiConstants.GATEWAY, BaseCmd.CommandType.STRING, "10.84.60.254");
    setParameter(cmd, ApiConstants.NETMASK, BaseCmd.CommandType.STRING, "255.255.255.0");
    setParameter(cmd, "networkID", BaseCmd.CommandType.LONG, public_net_id);
    setParameter(cmd, "zoneId", BaseCmd.CommandType.LONG, _zone.getId());
    setParameter(cmd, "vlan", BaseCmd.CommandType.STRING, "untagged");
    s_logger.debug("createPublicVlanIpRange execute : zone id: " + _zone.getId() + ", public net id: " + public_net_id);
    try {
        _configService.createVlanAndPublicIpRange(cmd);
    } catch (Exception e) {
        s_logger.debug("createPublicVlanIpRange: " + e);
    }
}
Also used : Account(com.cloud.user.Account) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) CreateVlanIpRangeCmd(org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd) BaseCmd(org.apache.cloudstack.api.BaseCmd) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException)

Example 77 with NetworkVO

use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.

the class VxlanGuestNetworkGuru method implement.

@Override
public Network implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException {
    assert (network.getState() == State.Implementing) : "Why are we implementing " + network;
    long dcId = dest.getDataCenter().getId();
    //get physical network id
    Long physicalNetworkId = network.getPhysicalNetworkId();
    // physical network id can be null in Guest Network in Basic zone, so locate the physical network
    if (physicalNetworkId == null) {
        physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
    }
    NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated, network.getDataCenterId(), physicalNetworkId, offering.getRedundantRouter());
    allocateVnet(network, implemented, dcId, physicalNetworkId, context.getReservationId());
    if (network.getGateway() != null) {
        implemented.setGateway(network.getGateway());
    }
    if (network.getCidr() != null) {
        implemented.setCidr(network.getCidr());
    }
    return implemented;
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO)

Example 78 with NetworkVO

use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.

the class VxlanGuestNetworkGuru method shutdown.

@Override
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
    NetworkVO networkObject = _networkDao.findById(profile.getId());
    if (networkObject.getBroadcastDomainType() != BroadcastDomainType.Vxlan || networkObject.getBroadcastUri() == null) {
        s_logger.warn("BroadcastUri is empty or incorrect for guestnetwork " + networkObject.getDisplayText());
        return;
    }
    super.shutdown(profile, offering);
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO)

Example 79 with NetworkVO

use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.

the class VxlanGuestNetworkGuruTest method testImplement.

@Test
public void testImplement() throws InsufficientVirtualNetworkCapacityException {
    PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById(anyLong())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VXLAN" }));
    when(physnet.getId()).thenReturn(42L);
    NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(42L);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    NetworkVO network = mock(NetworkVO.class);
    when(network.getName()).thenReturn("testnetwork");
    when(network.getState()).thenReturn(State.Implementing);
    when(network.getPhysicalNetworkId()).thenReturn(42L);
    DeployDestination dest = mock(DeployDestination.class);
    DataCenter dc = mock(DataCenter.class);
    when(dest.getDataCenter()).thenReturn(dc);
    when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
    //TODO(VXLAN): doesn't support VNI specified
    //when(confsvr.getConfigValue((String) any(), (String) any(), anyLong())).thenReturn("true");
    when(dcdao.allocateVnet(anyLong(), anyLong(), anyLong(), (String) any(), eq(true))).thenReturn("42");
    doNothing().when(guru).allocateVnetComplete((Network) any(), (NetworkVO) any(), anyLong(), anyLong(), (String) any(), eq("42"));
    Domain dom = mock(Domain.class);
    when(dom.getName()).thenReturn("domain");
    Account acc = mock(Account.class);
    when(acc.getAccountName()).thenReturn("accountname");
    ReservationContext res = mock(ReservationContext.class);
    when(res.getDomain()).thenReturn(dom);
    when(res.getAccount()).thenReturn(acc);
    Network implementednetwork = guru.implement(network, offering, dest, res);
    assertTrue(implementednetwork != null);
}
Also used : Account(com.cloud.user.Account) NetworkVO(com.cloud.network.dao.NetworkVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) DataCenter(com.cloud.dc.DataCenter) NetworkOffering(com.cloud.offering.NetworkOffering) DeployDestination(com.cloud.deploy.DeployDestination) Network(com.cloud.network.Network) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) Domain(com.cloud.domain.Domain) ReservationContext(com.cloud.vm.ReservationContext) Test(org.junit.Test)

Example 80 with NetworkVO

use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.

the class NetscalerElement method listNetworks.

@Override
public List<? extends Network> listNetworks(ListNetscalerLoadBalancerNetworksCmd cmd) {
    Long lbDeviceId = cmd.getLoadBalancerDeviceId();
    List<NetworkVO> networks = new ArrayList<NetworkVO>();
    ExternalLoadBalancerDeviceVO lbDeviceVo = _lbDeviceDao.findById(lbDeviceId);
    if (lbDeviceVo == null || !isNetscalerDevice(lbDeviceVo.getDeviceName())) {
        throw new InvalidParameterValueException("Could not find Netscaler load balancer device with ID " + lbDeviceId);
    }
    List<NetworkExternalLoadBalancerVO> networkLbMaps = _networkLBDao.listByLoadBalancerDeviceId(lbDeviceId);
    if (networkLbMaps != null && !networkLbMaps.isEmpty()) {
        for (NetworkExternalLoadBalancerVO networkLbMap : networkLbMaps) {
            NetworkVO network = _networkDao.findById(networkLbMap.getNetworkId());
            networks.add(network);
        }
    }
    return networks;
}
Also used : ExternalLoadBalancerDeviceVO(com.cloud.network.dao.ExternalLoadBalancerDeviceVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) NetworkExternalLoadBalancerVO(com.cloud.network.dao.NetworkExternalLoadBalancerVO)

Aggregations

NetworkVO (com.cloud.network.dao.NetworkVO)230 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)108 ArrayList (java.util.ArrayList)79 Test (org.junit.Test)56 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)55 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)49 Account (com.cloud.user.Account)44 Network (com.cloud.network.Network)39 DataCenterVO (com.cloud.dc.DataCenterVO)35 DataCenter (com.cloud.dc.DataCenter)34 NicVO (com.cloud.vm.NicVO)33 NicProfile (com.cloud.vm.NicProfile)27 HostVO (com.cloud.host.HostVO)24 NetworkOffering (com.cloud.offering.NetworkOffering)24 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)22 ReservationContext (com.cloud.vm.ReservationContext)22 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)20 DeployDestination (com.cloud.deploy.DeployDestination)19 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)19 NetworkGuru (com.cloud.network.guru.NetworkGuru)19