Search in sources :

Example 46 with HypervisorType

use of com.cloud.hypervisor.Hypervisor.HypervisorType in project cloudstack by apache.

the class TemplateAdapterBase method prepare.

@Override
public TemplateProfile prepare(RegisterTemplateCmd cmd) throws ResourceAllocationException {
    //check if the caller can operate with the template owner
    Account caller = CallContext.current().getCallingAccount();
    Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
    _accountMgr.checkAccess(caller, null, true, owner);
    boolean isRouting = (cmd.isRoutingType() == null) ? false : cmd.isRoutingType();
    Long zoneId = cmd.getZoneId();
    // ignore passed zoneId if we are using region wide image store
    List<ImageStoreVO> stores = _imgStoreDao.findRegionImageStores();
    if (stores != null && stores.size() > 0) {
        zoneId = -1L;
    }
    HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
    if (hypervisorType == HypervisorType.None) {
        throw new InvalidParameterValueException("Hypervisor Type: " + cmd.getHypervisor() + " is invalid. Supported Hypervisor types are " + EnumUtils.listValues(HypervisorType.values()).replace("None, ", ""));
    }
    return prepare(false, CallContext.current().getCallingUserId(), cmd.getTemplateName(), cmd.getDisplayText(), cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(), cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), zoneId, hypervisorType, cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), null, cmd.isDynamicallyScalable(), isRouting ? TemplateType.ROUTING : TemplateType.USER);
}
Also used : HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) Account(com.cloud.user.Account) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO)

Example 47 with HypervisorType

use of com.cloud.hypervisor.Hypervisor.HypervisorType in project cloudstack by apache.

the class TemplateAdapterBase method prepare.

@Override
public TemplateProfile prepare(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException {
    //check if the caller can operate with the template owner
    Account caller = CallContext.current().getCallingAccount();
    Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
    _accountMgr.checkAccess(caller, null, true, owner);
    boolean isRouting = (cmd.isRoutingType() == null) ? false : cmd.isRoutingType();
    Long zoneId = cmd.getZoneId();
    // ignore passed zoneId if we are using region wide image store
    List<ImageStoreVO> stores = _imgStoreDao.findRegionImageStores();
    if (stores != null && stores.size() > 0) {
        zoneId = -1L;
    }
    HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
    if (hypervisorType == HypervisorType.None) {
        throw new InvalidParameterValueException("Hypervisor Type: " + cmd.getHypervisor() + " is invalid. Supported Hypervisor types are " + EnumUtils.listValues(HypervisorType.values()).replace("None, ", ""));
    }
    return prepare(false, CallContext.current().getCallingUserId(), cmd.getName(), cmd.getDisplayText(), cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(), null, cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), zoneId, hypervisorType, cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled(), null, cmd.isDynamicallyScalable(), isRouting ? TemplateType.ROUTING : TemplateType.USER);
}
Also used : HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) Account(com.cloud.user.Account) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO)

Example 48 with HypervisorType

use of com.cloud.hypervisor.Hypervisor.HypervisorType in project cloudstack by apache.

the class OvsTunnelManagerImpl method getGreEndpointIP.

private String getGreEndpointIP(Host host, Network nw) throws AgentUnavailableException, OperationTimedoutException {
    String endpointIp = null;
    // Fetch fefault name for network label from configuration
    String physNetLabel = _configDao.getValue(Config.OvsTunnelNetworkDefaultLabel.key());
    Long physNetId = nw.getPhysicalNetworkId();
    PhysicalNetworkTrafficType physNetTT = _physNetTTDao.findBy(physNetId, TrafficType.Guest);
    HypervisorType hvType = host.getHypervisorType();
    String label = null;
    switch(hvType) {
        case XenServer:
            label = physNetTT.getXenNetworkLabel();
            if ((label != null) && (!label.equals(""))) {
                physNetLabel = label;
            }
            break;
        case KVM:
            label = physNetTT.getKvmNetworkLabel();
            if ((label != null) && (!label.equals(""))) {
                physNetLabel = label;
            }
            break;
        default:
            throw new CloudRuntimeException("Hypervisor " + hvType.toString() + " unsupported by OVS Tunnel Manager");
    }
    // Try to fetch GRE endpoint IP address for cloud db
    // If not found, then find it on the hypervisor
    OvsTunnelInterfaceVO tunnelIface = _tunnelInterfaceDao.getByHostAndLabel(host.getId(), physNetLabel);
    if (tunnelIface == null) {
        //Now find and fetch configuration for physical interface
        //for network with label on target host
        Commands fetchIfaceCmds = new Commands(new OvsFetchInterfaceCommand(physNetLabel));
        s_logger.debug("Ask host " + host.getId() + " to retrieve interface for phy net with label:" + physNetLabel);
        Answer[] fetchIfaceAnswers = _agentMgr.send(host.getId(), fetchIfaceCmds);
        //And finally save it for future use
        endpointIp = handleFetchInterfaceAnswer(fetchIfaceAnswers, host.getId());
    } else {
        endpointIp = tunnelIface.getIp();
    }
    return endpointIp;
}
Also used : HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) OvsFetchInterfaceAnswer(com.cloud.agent.api.OvsFetchInterfaceAnswer) Answer(com.cloud.agent.api.Answer) OvsCreateTunnelAnswer(com.cloud.agent.api.OvsCreateTunnelAnswer) OvsFetchInterfaceCommand(com.cloud.agent.api.OvsFetchInterfaceCommand) OvsTunnelInterfaceVO(com.cloud.network.ovs.dao.OvsTunnelInterfaceVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Commands(com.cloud.agent.manager.Commands) PhysicalNetworkTrafficType(com.cloud.network.PhysicalNetworkTrafficType)

Example 49 with HypervisorType

use of com.cloud.hypervisor.Hypervisor.HypervisorType in project cloudstack by apache.

the class SolidFireSharedPrimaryDataStoreLifeCycle method createStoragePool.

private boolean createStoragePool(HostVO host, StoragePool storagePool) {
    long hostId = host.getId();
    HypervisorType hypervisorType = host.getHypervisorType();
    CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, storagePool);
    if (HypervisorType.VMware.equals(hypervisorType)) {
        cmd.setCreateDatastore(true);
        Map<String, String> details = new HashMap<String, String>();
        StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.DATASTORE_NAME);
        details.put(CreateStoragePoolCommand.DATASTORE_NAME, storagePoolDetail.getValue());
        storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.IQN);
        details.put(CreateStoragePoolCommand.IQN, storagePoolDetail.getValue());
        storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.STORAGE_VIP);
        details.put(CreateStoragePoolCommand.STORAGE_HOST, storagePoolDetail.getValue());
        storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.STORAGE_PORT);
        details.put(CreateStoragePoolCommand.STORAGE_PORT, storagePoolDetail.getValue());
        cmd.setDetails(details);
    }
    Answer answer = _agentMgr.easySend(hostId, cmd);
    if (answer != null && answer.getResult()) {
        return true;
    } else {
        _primaryDataStoreDao.expunge(storagePool.getId());
        String msg = "";
        if (answer != null) {
            msg = "Cannot create storage pool through host '" + hostId + "' due to the following: " + answer.getDetails();
        } else {
            msg = "Cannot create storage pool through host '" + hostId + "' due to CreateStoragePoolCommand returns null";
        }
        s_logger.warn(msg);
        throw new CloudRuntimeException(msg);
    }
}
Also used : HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) Answer(com.cloud.agent.api.Answer) HashMap(java.util.HashMap) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO) CreateStoragePoolCommand(com.cloud.agent.api.CreateStoragePoolCommand)

Example 50 with HypervisorType

use of com.cloud.hypervisor.Hypervisor.HypervisorType in project cloudstack by apache.

the class SolidFireSharedPrimaryDataStoreLifeCycle method deleteDataStore.

// invoked to delete primary storage that is based on the SolidFire plug-in
@Override
public boolean deleteDataStore(DataStore dataStore) {
    List<StoragePoolHostVO> hostPoolRecords = _storagePoolHostDao.listByPoolId(dataStore.getId());
    HypervisorType hypervisorType = null;
    if (hostPoolRecords.size() > 0) {
        hypervisorType = getHypervisorType(hostPoolRecords.get(0).getHostId());
    }
    if (!isSupportedHypervisorType(hypervisorType)) {
        throw new CloudRuntimeException(hypervisorType + " is not a supported hypervisor type.");
    }
    StoragePool storagePool = (StoragePool) dataStore;
    StoragePoolVO storagePoolVO = _primaryDataStoreDao.findById(storagePool.getId());
    List<VMTemplateStoragePoolVO> unusedTemplatesInPool = _tmpltMgr.getUnusedTemplatesInPool(storagePoolVO);
    for (VMTemplateStoragePoolVO templatePoolVO : unusedTemplatesInPool) {
        _tmpltMgr.evictTemplateFromStoragePool(templatePoolVO);
    }
    Long clusterId = null;
    for (StoragePoolHostVO host : hostPoolRecords) {
        DeleteStoragePoolCommand deleteCmd = new DeleteStoragePoolCommand(storagePool);
        if (HypervisorType.VMware.equals(hypervisorType)) {
            deleteCmd.setRemoveDatastore(true);
            Map<String, String> details = new HashMap<String, String>();
            StoragePoolDetailVO storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.DATASTORE_NAME);
            details.put(DeleteStoragePoolCommand.DATASTORE_NAME, storagePoolDetail.getValue());
            storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.IQN);
            details.put(DeleteStoragePoolCommand.IQN, storagePoolDetail.getValue());
            storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.STORAGE_VIP);
            details.put(DeleteStoragePoolCommand.STORAGE_HOST, storagePoolDetail.getValue());
            storagePoolDetail = _storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.STORAGE_PORT);
            details.put(DeleteStoragePoolCommand.STORAGE_PORT, storagePoolDetail.getValue());
            deleteCmd.setDetails(details);
        }
        final Answer answer = _agentMgr.easySend(host.getHostId(), deleteCmd);
        if (answer != null && answer.getResult()) {
            s_logger.info("Successfully deleted storage pool using Host ID " + host.getHostId());
            HostVO hostVO = _hostDao.findById(host.getHostId());
            if (hostVO != null) {
                clusterId = hostVO.getClusterId();
            }
            break;
        } else {
            s_logger.error("Failed to delete storage pool using Host ID " + host.getHostId() + ": " + answer.getResult());
        }
    }
    if (clusterId != null) {
        ClusterVO cluster = _clusterDao.findById(clusterId);
        GlobalLock lock = GlobalLock.getInternLock(cluster.getUuid());
        if (!lock.lock(SolidFireUtil.s_lockTimeInSeconds)) {
            String errMsg = "Couldn't lock the DB on the following string: " + cluster.getUuid();
            s_logger.debug(errMsg);
            throw new CloudRuntimeException(errMsg);
        }
        try {
            removeVolumeFromVag(storagePool.getId(), clusterId);
        } finally {
            lock.unlock();
            lock.releaseRef();
        }
    }
    deleteSolidFireVolume(storagePool.getId());
    return _primaryDataStoreHelper.deletePrimaryDataStore(dataStore);
}
Also used : StoragePool(com.cloud.storage.StoragePool) ClusterVO(com.cloud.dc.ClusterVO) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) HashMap(java.util.HashMap) DeleteStoragePoolCommand(com.cloud.agent.api.DeleteStoragePoolCommand) StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO) HostVO(com.cloud.host.HostVO) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) GlobalLock(com.cloud.utils.db.GlobalLock) Answer(com.cloud.agent.api.Answer) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO)

Aggregations

HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)57 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)25 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)20 ArrayList (java.util.ArrayList)19 Account (com.cloud.user.Account)15 VMTemplateVO (com.cloud.storage.VMTemplateVO)12 ClusterVO (com.cloud.dc.ClusterVO)10 HostVO (com.cloud.host.HostVO)8 UserVmVO (com.cloud.vm.UserVmVO)8 HashMap (java.util.HashMap)8 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)8 DataCenterVO (com.cloud.dc.DataCenterVO)7 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)7 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)7 Answer (com.cloud.agent.api.Answer)6 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)6 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)6 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)6 ServiceOfferingVO (com.cloud.service.ServiceOfferingVO)6 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)5