Search in sources :

Example 6 with ClusterScope

use of org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope in project cloudstack by apache.

the class StorageSystemDataMotionStrategy method getZoneScope.

private Scope getZoneScope(Scope scope) {
    ZoneScope zoneScope;
    if (scope instanceof ClusterScope) {
        ClusterScope clusterScope = (ClusterScope) scope;
        zoneScope = new ZoneScope(clusterScope.getZoneId());
    } else if (scope instanceof HostScope) {
        HostScope hostScope = (HostScope) scope;
        zoneScope = new ZoneScope(hostScope.getZoneId());
    } else {
        zoneScope = (ZoneScope) scope;
    }
    return zoneScope;
}
Also used : ZoneScope(org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope) ClusterScope(org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope) HostScope(org.apache.cloudstack.engine.subsystem.api.storage.HostScope)

Example 7 with ClusterScope

use of org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope in project cloudstack by apache.

the class VolumeServiceTest method testCreatePrimaryStorage.

@Test
public void testCreatePrimaryStorage() {
    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("sample primary data store provider");
    Map<String, Object> params = new HashMap<String, Object>();
    URI uri = null;
    try {
        uri = new URI(this.getPrimaryStorageUrl());
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    params.put("url", this.getPrimaryStorageUrl());
    params.put("server", uri.getHost());
    params.put("path", uri.getPath());
    params.put("protocol", StoragePoolType.NetworkFilesystem);
    params.put("dcId", dcId.toString());
    params.put("hypervisorType", HypervisorType.None);
    params.put("clusterId", clusterId.toString());
    params.put("name", this.primaryName);
    params.put("port", "1");
    params.put("roles", DataStoreRole.Primary.toString());
    params.put("uuid", UUID.nameUUIDFromBytes(this.getPrimaryStorageUrl().getBytes()).toString());
    params.put("providerName", String.valueOf(provider.getName()));
    DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle();
    this.primaryStore = lifeCycle.initialize(params);
    ClusterScope scope = new ClusterScope(clusterId, podId, dcId);
    lifeCycle.attachCluster(this.primaryStore, scope);
}
Also used : DataStoreLifeCycle(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle) ClusterScope(org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope) HashMap(java.util.HashMap) DataStoreProvider(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider) DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 8 with ClusterScope

use of org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope in project cloudstack by apache.

the class PrimaryDataStoreImpl method getScope.

@Override
public Scope getScope() {
    StoragePoolVO vo = dataStoreDao.findById(pdsv.getId());
    if (vo.getScope() == ScopeType.CLUSTER) {
        return new ClusterScope(vo.getClusterId(), vo.getPodId(), vo.getDataCenterId());
    } else if (vo.getScope() == ScopeType.ZONE) {
        return new ZoneScope(vo.getDataCenterId());
    } else if (vo.getScope() == ScopeType.HOST) {
        List<StoragePoolHostVO> poolHosts = poolHostDao.listByPoolId(vo.getId());
        if (poolHosts.size() > 0) {
            return new HostScope(poolHosts.get(0).getHostId(), vo.getClusterId(), vo.getDataCenterId());
        }
        s_logger.debug("can't find a local storage in pool host table: " + vo.getId());
    }
    return null;
}
Also used : ZoneScope(org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope) ClusterScope(org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) HostScope(org.apache.cloudstack.engine.subsystem.api.storage.HostScope)

Aggregations

ClusterScope (org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope)8 ZoneScope (org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope)5 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)3 URISyntaxException (java.net.URISyntaxException)3 HashMap (java.util.HashMap)3 DataObject (org.apache.cloudstack.engine.subsystem.api.storage.DataObject)3 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)3 DataStoreLifeCycle (org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle)3 DataStoreProvider (org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider)3 HostScope (org.apache.cloudstack.engine.subsystem.api.storage.HostScope)3 URI (java.net.URI)2 ExecutionException (java.util.concurrent.ExecutionException)2 Test (org.junit.Test)2 ClusterVO (com.cloud.dc.ClusterVO)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 AgentUnavailableException (com.cloud.exception.AgentUnavailableException)1 ConnectionException (com.cloud.exception.ConnectionException)1 DiscoveryException (com.cloud.exception.DiscoveryException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1