Package com.cloud.offerings

Examples of com.cloud.offerings.NetworkOfferingVO


        if (networkId == null) {
            networkId = userIp.getAssociatedWithNetworkId();
        }
       
        NetworkVO network = _networksDao.findById(networkId);
        NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
        if (offering.getGuestType() != GuestType.Isolated) {
            return true;
        }
        PublicIp publicIp = new PublicIp(userIp, _vlanDao.findById(userIp.getVlanId()), NetUtils.createSequenceBasedMacAddress(userIp.getMacAddress()));
        if (!canIpUsedForService(publicIp, service, networkId)) {
            return false;
        }
        if (!offering.isConserveMode()) {
            return canIpUsedForNonConserveService(publicIp, service);
        }
        return true;
    }
View Full Code Here


                    throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {
       
        Account owner = _accountMgr.getAccount(networkOwnerId);
       
        // Get system network offeirng
        NetworkOfferingVO ntwkOff = _systemNetworks.get(NetworkOffering.SystemPrivateGatewayNetworkOffering);
       
        // Validate physical network
        PhysicalNetwork pNtwk = _physicalNetworkDao.findById(physicalNetworkId);
        if (pNtwk == null) {
            InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a physical network" +
                    " having the given id");
            ex.addProxyObject("physical_network", physicalNetworkId, "physicalNetworkId");
            throw ex;
        }
       
        // VALIDATE IP INFO
        // if end ip is not specified, default it to startIp
        if (!NetUtils.isValidIp(startIp)) {
            throw new InvalidParameterValueException("Invalid format for the startIp parameter");
        }
        if (endIp == null) {
            endIp = startIp;
        } else if (!NetUtils.isValidIp(endIp)) {
            throw new InvalidParameterValueException("Invalid format for the endIp parameter");
        }

        String cidr = null;
        if (!NetUtils.isValidIp(gateway)) {
            throw new InvalidParameterValueException("Invalid gateway");
        }
        if (!NetUtils.isValidNetmask(netmask)) {
            throw new InvalidParameterValueException("Invalid netmask");
        }

        cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
       
       
        Transaction txn = Transaction.currentTxn();
        txn.start();
       
        //lock datacenter as we need to get mac address seq from there
        DataCenterVO dc = _dcDao.lockRow(pNtwk.getDataCenterId(), true);
       
        //check if we need to create guest network
        Network privateNetwork = _networksDao.getPrivateNetwork(BroadcastDomainType.Vlan.toUri(vlan).toString(), cidr,
                networkOwnerId, pNtwk.getDataCenterId());
        if (privateNetwork == null) {
            //create Guest network
            privateNetwork = createGuestNetwork(ntwkOff.getId(), networkName, displayText, gateway, cidr, vlan,
                    null, owner, null, pNtwk, pNtwk.getDataCenterId(), ACLType.Account, null, null);
            s_logger.debug("Created private network " + privateNetwork);
        } else {
            s_logger.debug("Private network already exists: " + privateNetwork);
        }
View Full Code Here

        }

        //2) Control network
        s_logger.debug("Adding nic for Virtual Router in Control network ");
        List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
        NetworkOfferingVO controlOffering = offerings.get(0);
        NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
        networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
       
       
        //3) Public network
        if (setupPublicNetwork) {
            PublicIp sourceNatIp = publicNetwork.second();
            s_logger.debug("Adding nic for Virtual Router in Public network ");
            //if source nat service is supported by the network, get the source nat ip address
            NicProfile defaultNic = new NicProfile();
            defaultNic.setDefaultNic(true);
            defaultNic.setIp4Address(sourceNatIp.getAddress().addr());
            defaultNic.setGateway(sourceNatIp.getGateway());
            defaultNic.setNetmask(sourceNatIp.getNetmask());
            defaultNic.setMacAddress(sourceNatIp.getMacAddress());
            defaultNic.setBroadcastType(BroadcastDomainType.Vlan);
            defaultNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(sourceNatIp.getVlanTag()));
            defaultNic.setIsolationUri(IsolationType.Vlan.toUri(sourceNatIp.getVlanTag()));
            if (hasGuestNetwork) {
                defaultNic.setDeviceId(2);
            }
            NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
            List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
            networks.add(new Pair<NetworkVO, NicProfile>(publicNetworks.get(0), defaultNic));
        }

        return networks;
View Full Code Here

        //check if DNS provider is the domR
        if (!_networkMgr.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) {
            return null;
        }
       
        NetworkOfferingVO offering = _networkOfferingDao.findById(_networkDao.findById(defaultNic.getNetworkId()).getNetworkOfferingId());
        if (offering.getRedundantRouter()) {
            return findGatewayIp(userVmId);
        }
       
        DataCenter dc = _dcDao.findById(_networkMgr.getNetwork(defaultNic.getNetworkId()).getDataCenterId());
        boolean isZoneBasic = (dc.getNetworkType() == NetworkType.Basic);
View Full Code Here

        if (!canHandle(network, null)) {
            return false;
        }

        NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
        if (offering.isSystemOnly()) {
            return false;
        }
        if (!_networkMgr.isProviderEnabledInPhysicalNetwork(_networkMgr.getPhysicalNetworkId(network), getProvider().getName())) {
            return false;
        }

        @SuppressWarnings("unchecked")
        VirtualMachineProfile uservm = vm;
        List<DomainRouterVO> routers =
            _routerMgr.deployVirtualRouterInGuestNetwork(network, dest, _accountMgr.getAccount(network.getAccountId()), uservm.getParameters(),
                offering.getRedundantRouter());
        if ((routers == null) || (routers.size() == 0)) {
            throw new ResourceUnavailableException("Can't find at least one running router!", DataCenter.class, network.getDataCenterId());
        }
        return true;
    }
View Full Code Here

        Mockito.when(_itMgr.toNicTO(Matchers.any(NicProfile.class), Matchers.any(HypervisorType.class))).thenReturn(null);
        Mockito.when(_domainRouterDao.findById(Matchers.anyLong())).thenReturn(vm);
        DataCenterVO dc = new DataCenterVO(1L, null, null, null, null, null, null, null, null, null, NetworkType.Advanced, null, null);
        Mockito.when(_dcDao.findById(Matchers.anyLong())).thenReturn(dc);
        NetworkOfferingVO networkOfferingVO = new NetworkOfferingVO();
        networkOfferingVO.setConcurrentConnections(500);
        Mockito.when(_offeringDao.findById(Matchers.anyLong())).thenReturn(networkOfferingVO);

        Mockito.when(_domainRouterDao.findById(validVmId)).thenReturn(vm);
        Mockito.when(_domainRouterDao.findById(invalidVmId)).thenReturn(null);
View Full Code Here

        };
        for (Service svc: services) {
            serviceProviderMap.put(svc, providerSet);
        }
        ConfigurationManager configMgr = (ConfigurationManager) _configService;
        NetworkOfferingVO voffer = configMgr.createNetworkOffering(offeringName, offeringDisplayText,
                TrafficType.Public, null, true, Availability.Optional, null, serviceProviderMap, true,
                Network.GuestType.Shared, false, null, false, null, true, false, null, true, null, false);

        voffer.setState(NetworkOffering.State.Enabled);
        long id = voffer.getId();
        _networkOfferingDao.update(id, voffer);
        return _networkOfferingDao.findById(id);
    }
View Full Code Here

                continue;
            }
            serviceProviderMap.put(svc, providerSet);
        }
        ConfigurationManager configMgr = (ConfigurationManager)_configService;
        NetworkOfferingVO voffer =
                configMgr.createNetworkOffering(offeringName, offeringDisplayText, TrafficType.Guest, null, false, Availability.Optional, null, serviceProviderMap, true,
                        Network.GuestType.Isolated, false, null, false, null, false, true, null, true, null, false);

        voffer.setState(NetworkOffering.State.Enabled);
        if (offeringName.equals(vpcRouterOfferingName)) {
            voffer.setInternalLb(true);
        }
        long id = voffer.getId();
        _networkOfferingDao.update(id, voffer);
        return _networkOfferingDao.findById(id);
    }
View Full Code Here

        _vpcOffDao.update(id, (VpcOfferingVO)vpcOffer);
        return _vpcOffDao.findById(id);
    }

    private NetworkOffering EnableNetworkOffering(long id) {
        NetworkOfferingVO offering = _networkOfferingDao.createForUpdate(id);
        offering.setState(NetworkOffering.State.Enabled);
        _networkOfferingDao.update(id, offering);
        return _networkOfferingDao.findById(id);
    }
View Full Code Here

            if(pf != null){
                usageRecResponse.setUsageId(pf.getUuid());
            }
    } else if(usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING){
      //Network Offering Id
      NetworkOfferingVO netOff = _entityMgr.findByIdIncludingRemoved(NetworkOfferingVO.class, usageRecord.getOfferingId().toString());
      usageRecResponse.setOfferingId(netOff.getUuid());
      //is Default
      usageRecResponse.setDefault((usageRecord.getUsageId() == 1)? true:false);
        } else if(usageRecord.getUsageType() == UsageTypes.VPN_USERS){
            //VPN User ID
            VpnUserVO vpnUser = _entityMgr.findByIdIncludingRemoved(VpnUserVO.class, usageRecord.getUsageId().toString());
View Full Code Here

TOP

Related Classes of com.cloud.offerings.NetworkOfferingVO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.