Search in sources :

Example 11 with ServiceOfferingVO

use of com.cloud.service.ServiceOfferingVO in project cloudstack by apache.

the class UserVmManagerImpl method isImplicitPlannerUsedByOffering.

private boolean isImplicitPlannerUsedByOffering(long offeringId) {
    boolean implicitPlannerUsed = false;
    ServiceOfferingVO offering = _serviceOfferingDao.findByIdIncludingRemoved(offeringId);
    if (offering == null) {
        s_logger.error("Couldn't retrieve the offering by the given id : " + offeringId);
    } else {
        String plannerName = offering.getDeploymentPlanner();
        if (plannerName != null) {
            if (plannerName.equals("ImplicitDedicationPlanner")) {
                implicitPlannerUsed = true;
            }
        }
    }
    return implicitPlannerUsed;
}
Also used : ServiceOfferingVO(com.cloud.service.ServiceOfferingVO)

Example 12 with ServiceOfferingVO

use of com.cloud.service.ServiceOfferingVO in project cloudstack by apache.

the class DomainManagerImpl method cleanupDomainOfferings.

protected void cleanupDomainOfferings(Long domainId) {
    // delete the service and disk offerings associated with this domain
    List<DiskOfferingVO> diskOfferingsForThisDomain = _diskOfferingDao.listByDomainId(domainId);
    for (DiskOfferingVO diskOffering : diskOfferingsForThisDomain) {
        _diskOfferingDao.remove(diskOffering.getId());
    }
    List<ServiceOfferingVO> serviceOfferingsForThisDomain = _offeringsDao.findServiceOfferingByDomainId(domainId);
    for (ServiceOfferingVO serviceOffering : serviceOfferingsForThisDomain) {
        _offeringsDao.remove(serviceOffering.getId());
    }
}
Also used : DiskOfferingVO(com.cloud.storage.DiskOfferingVO) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO)

Example 13 with ServiceOfferingVO

use of com.cloud.service.ServiceOfferingVO in project cloudstack by apache.

the class ServiceOfferingVOTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    offeringCustom = new ServiceOfferingVO("custom", null, null, 500, 10, 10, false, "custom", Storage.ProvisioningType.THIN, false, false, "", false, VirtualMachine.Type.User, false);
    offering = new ServiceOfferingVO("normal", 1, 1000, 500, 10, 10, false, "normal", Storage.ProvisioningType.THIN, false, false, "", false, VirtualMachine.Type.User, false);
}
Also used : ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) Before(org.junit.Before)

Example 14 with ServiceOfferingVO

use of com.cloud.service.ServiceOfferingVO in project cloudstack by apache.

the class SecondaryStorageManagerImpl method configure.

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    if (s_logger.isInfoEnabled()) {
        s_logger.info("Start configuring secondary storage vm manager : " + name);
    }
    Map<String, String> configs = _configDao.getConfiguration("management-server", params);
    _secStorageVmMtuSize = NumbersUtil.parseInt(configs.get("secstorage.vm.mtu.size"), DEFAULT_SS_VM_MTUSIZE);
    String useServiceVM = _configDao.getValue("secondary.storage.vm");
    boolean _useServiceVM = false;
    if ("true".equalsIgnoreCase(useServiceVM)) {
        _useServiceVM = true;
    }
    String sslcopy = _configDao.getValue("secstorage.encrypt.copy");
    if ("true".equalsIgnoreCase(sslcopy)) {
        _useSSlCopy = true;
    }
    //default to HTTP in case of missing domain
    String ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain");
    if (_useSSlCopy && (ssvmUrlDomain == null || ssvmUrlDomain.isEmpty())) {
        s_logger.warn("Empty secondary storage url domain, explicitly disabling SSL");
        _useSSlCopy = false;
    }
    _allowedInternalSites = _configDao.getValue("secstorage.allowed.internal.sites");
    String value = configs.get("secstorage.capacityscan.interval");
    _capacityScanInterval = NumbersUtil.parseLong(value, DEFAULT_CAPACITY_SCAN_INTERVAL);
    _instance = configs.get("instance.name");
    if (_instance == null) {
        _instance = "DEFAULT";
    }
    Map<String, String> agentMgrConfigs = _configDao.getConfiguration("AgentManager", params);
    value = agentMgrConfigs.get("port");
    _mgmtPort = NumbersUtil.parseInt(value, 8250);
    _listener = new SecondaryStorageListener(this);
    _agentMgr.registerForHostEvents(_listener, true, false, true);
    _itMgr.registerGuru(VirtualMachine.Type.SecondaryStorageVm, this);
    //check if there is a default service offering configured
    String ssvmSrvcOffIdStr = configs.get(Config.SecondaryStorageServiceOffering.key());
    if (ssvmSrvcOffIdStr != null) {
        _serviceOffering = _offeringDao.findByUuid(ssvmSrvcOffIdStr);
        if (_serviceOffering == null) {
            try {
                _serviceOffering = _offeringDao.findById(Long.parseLong(ssvmSrvcOffIdStr));
            } catch (NumberFormatException ex) {
                s_logger.debug("The system service offering specified by global config is not id, but uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm");
            }
        }
        if (_serviceOffering == null) {
            s_logger.warn("Can't find system service offering specified by global config, uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm");
        }
    }
    if (_serviceOffering == null || !_serviceOffering.getSystemUse()) {
        int ramSize = NumbersUtil.parseInt(_configDao.getValue("ssvm.ram.size"), DEFAULT_SS_VM_RAMSIZE);
        int cpuFreq = NumbersUtil.parseInt(_configDao.getValue("ssvm.cpu.mhz"), DEFAULT_SS_VM_CPUMHZ);
        List<ServiceOfferingVO> offerings = _offeringDao.createSystemServiceOfferings("System Offering For Secondary Storage VM", ServiceOffering.ssvmDefaultOffUniqueName, 1, ramSize, cpuFreq, null, null, false, null, Storage.ProvisioningType.THIN, true, null, true, VirtualMachine.Type.SecondaryStorageVm, true);
        // this can sometimes happen, if DB is manually or programmatically manipulated
        if (offerings == null || offerings.size() < 2) {
            String msg = "Data integrity problem : System Offering For Secondary Storage VM has been removed?";
            s_logger.error(msg);
            throw new ConfigurationException(msg);
        }
    }
    if (_useServiceVM) {
        _loadScanner = new SystemVmLoadScanner<Long>(this);
        _loadScanner.initScan(STARTUP_DELAY, _capacityScanInterval);
    }
    _httpProxy = configs.get(Config.SecStorageProxy.key());
    if (_httpProxy != null) {
        boolean valid = true;
        String errMsg = null;
        try {
            URI uri = new URI(_httpProxy);
            if (!"http".equalsIgnoreCase(uri.getScheme())) {
                errMsg = "Only support http proxy";
                valid = false;
            } else if (uri.getHost() == null) {
                errMsg = "host can not be null";
                valid = false;
            } else if (uri.getPort() == -1) {
                _httpProxy = _httpProxy + ":3128";
            }
        } catch (URISyntaxException e) {
            errMsg = e.toString();
        } finally {
            if (!valid) {
                s_logger.debug("ssvm http proxy " + _httpProxy + " is invalid: " + errMsg);
                throw new ConfigurationException("ssvm http proxy " + _httpProxy + "is invalid: " + errMsg);
            }
        }
    }
    if (s_logger.isInfoEnabled()) {
        s_logger.info("Secondary storage vm Manager is configured.");
    }
    _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
    return true;
}
Also used : URISyntaxException(java.net.URISyntaxException) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) URI(java.net.URI) SecondaryStorageListener(com.cloud.storage.secondary.SecondaryStorageListener) ConfigurationException(javax.naming.ConfigurationException)

Example 15 with ServiceOfferingVO

use of com.cloud.service.ServiceOfferingVO in project cloudstack by apache.

the class ConfigurationServerImpl method createServiceOffering.

private ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, ProvisioningType provisioningType, boolean localStorageRequired, boolean offerHA, String tags) {
    tags = cleanupTags(tags);
    ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, displayText, provisioningType, localStorageRequired, false, tags, false, null, false);
    offering.setUniqueName("Cloud.Com-" + name);
    // leaving the above reference to cloud.com in as it is an identifyer and has no real world relevance
    offering = _serviceOfferingDao.persistSystemServiceOffering(offering);
    return offering;
}
Also used : ServiceOfferingVO(com.cloud.service.ServiceOfferingVO)

Aggregations

ServiceOfferingVO (com.cloud.service.ServiceOfferingVO)72 ArrayList (java.util.ArrayList)24 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)18 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)18 Account (com.cloud.user.Account)17 List (java.util.List)14 Network (com.cloud.network.Network)10 DB (com.cloud.utils.db.DB)10 VolumeVO (com.cloud.storage.VolumeVO)9 NicProfile (com.cloud.vm.NicProfile)9 VMInstanceVO (com.cloud.vm.VMInstanceVO)9 HashMap (java.util.HashMap)9 LinkedHashMap (java.util.LinkedHashMap)9 ConfigurationException (javax.naming.ConfigurationException)9 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)8 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)8 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)8 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)8 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)8 DomainRouterVO (com.cloud.vm.DomainRouterVO)8