Search in sources :

Example 51 with ImageStoreVO

use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.

the class ImageStoreProviderManagerImpl method listImageStoresByScope.

@Override
public List<DataStore> listImageStoresByScope(ZoneScope scope) {
    List<ImageStoreVO> stores = dataStoreDao.findByZone(scope, null);
    List<DataStore> imageStores = new ArrayList<DataStore>();
    for (ImageStoreVO store : stores) {
        imageStores.add(getImageStore(store.getId()));
    }
    return imageStores;
}
Also used : DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) ArrayList(java.util.ArrayList) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO)

Example 52 with ImageStoreVO

use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.

the class VolumeTestVmware method setUp.

@Test(priority = -1)
public void setUp() {
    ComponentContext.initComponentsLifeCycle();
    host = hostDao.findByGuid(this.getHostGuid());
    if (host != null) {
        dcId = host.getDataCenterId();
        clusterId = host.getClusterId();
        podId = host.getPodId();
        imageStore = this.imageStoreDao.findByName(imageStoreName);
    } else {
        // create data center
        DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
        dc = dcDao.persist(dc);
        dcId = dc.getId();
        // create pod
        HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), this.getHostGateway(), this.getHostCidr(), 8, "test");
        pod = podDao.persist(pod);
        podId = pod.getId();
        // create xen cluster
        ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
        cluster.setHypervisorType(HypervisorType.VMware.toString());
        cluster.setClusterType(ClusterType.ExternalManaged);
        cluster.setManagedState(ManagedState.Managed);
        cluster = clusterDao.persist(cluster);
        clusterId = cluster.getId();
        // setup vcenter
        ClusterDetailsVO clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "url", null);
        this.clusterDetailsDao.persist(clusterDetailVO);
        clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "username", null);
        this.clusterDetailsDao.persist(clusterDetailVO);
        clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "password", null);
        this.clusterDetailsDao.persist(clusterDetailVO);
        // create xen host
        host = new HostVO(this.getHostGuid());
        host.setName("devcloud vmware host");
        host.setType(Host.Type.Routing);
        host.setPrivateIpAddress(this.getHostIp());
        host.setDataCenterId(dc.getId());
        host.setVersion("6.0.1");
        host.setAvailable(true);
        host.setSetup(true);
        host.setPodId(podId);
        host.setLastPinged(0);
        host.setResourceState(ResourceState.Enabled);
        host.setHypervisorType(HypervisorType.VMware);
        host.setClusterId(cluster.getId());
        host = hostDao.persist(host);
        imageStore = new ImageStoreVO();
        imageStore.setName(imageStoreName);
        imageStore.setDataCenterId(dcId);
        imageStore.setProviderName("CloudStack ImageStore Provider");
        imageStore.setRole(DataStoreRole.Image);
        imageStore.setUrl(this.getSecondaryStorage());
        imageStore.setUuid(UUID.randomUUID().toString());
        imageStore.setProtocol("nfs");
        imageStore = imageStoreDao.persist(imageStore);
    }
    image = new VMTemplateVO();
    image.setTemplateType(TemplateType.USER);
    image.setUrl(this.getTemplateUrl());
    image.setUniqueName(UUID.randomUUID().toString());
    image.setName(UUID.randomUUID().toString());
    image.setPublicTemplate(true);
    image.setFeatured(true);
    image.setRequiresHvm(true);
    image.setBits(64);
    image.setFormat(Storage.ImageFormat.VHD);
    image.setEnablePassword(true);
    image.setEnableSshKey(true);
    image.setGuestOSId(1);
    image.setBootable(true);
    image.setPrepopulate(true);
    image.setCrossZones(true);
    image.setExtractable(true);
    image = imageDataDao.persist(image);
    /*
         * TemplateDataStoreVO templateStore = new TemplateDataStoreVO();
         *
         * templateStore.setDataStoreId(imageStore.getId());
         * templateStore.setDownloadPercent(100);
         * templateStore.setDownloadState(Status.DOWNLOADED);
         * templateStore.setDownloadUrl(imageStore.getUrl());
         * templateStore.setInstallPath(this.getImageInstallPath());
         * templateStore.setTemplateId(image.getId());
         * templateStoreDao.persist(templateStore);
         */
    DataStore store = this.dataStoreMgr.getDataStore(imageStore.getId(), DataStoreRole.Image);
    TemplateInfo template = templateFactory.getTemplate(image.getId(), DataStoreRole.Image);
    DataObject templateOnStore = store.create(template);
    TemplateObjectTO to = new TemplateObjectTO();
    to.setPath(this.getImageInstallPath());
    CopyCmdAnswer answer = new CopyCmdAnswer(to);
    templateOnStore.processEvent(Event.CreateOnlyRequested);
    templateOnStore.processEvent(Event.OperationSuccessed, answer);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) TemplateInfo(org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo) ClusterVO(com.cloud.dc.ClusterVO) DataObject(org.apache.cloudstack.engine.subsystem.api.storage.DataObject) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VMTemplateVO(com.cloud.storage.VMTemplateVO) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) HostPodVO(com.cloud.dc.HostPodVO) ClusterDetailsVO(com.cloud.dc.ClusterDetailsVO) HostVO(com.cloud.host.HostVO) CopyCmdAnswer(org.apache.cloudstack.storage.command.CopyCmdAnswer) Test(org.testng.annotations.Test)

Example 53 with ImageStoreVO

use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.

the class SnapshotTestWithFakeData method setUp.

@Before
public void setUp() {
    // create data center
    DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, DataCenter.NetworkType.Basic, null, null, true, true, null, null);
    dc = dcDao.persist(dc);
    dcId = dc.getId();
    // create pod
    HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), "10.223.0.1", "10.233.2.2/25", 8, "test");
    pod = podDao.persist(pod);
    podId = pod.getId();
    // create xenserver cluster
    ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
    cluster.setHypervisorType(Hypervisor.HypervisorType.XenServer.toString());
    cluster.setClusterType(Cluster.ClusterType.CloudManaged);
    cluster.setManagedState(Managed.ManagedState.Managed);
    cluster = clusterDao.persist(cluster);
    clusterId = cluster.getId();
    imageStore = new ImageStoreVO();
    imageStore.setName(UUID.randomUUID().toString());
    imageStore.setDataCenterId(dcId);
    imageStore.setProviderName(DataStoreProvider.NFS_IMAGE);
    imageStore.setRole(DataStoreRole.Image);
    imageStore.setUrl(UUID.randomUUID().toString());
    imageStore.setUuid(UUID.randomUUID().toString());
    imageStore.setProtocol("nfs");
    imageStore = imageStoreDao.persist(imageStore);
    when(primaryDataStoreProvider.configure(Matchers.anyMap())).thenReturn(true);
    Set<DataStoreProvider.DataStoreProviderType> types = new HashSet<DataStoreProvider.DataStoreProviderType>();
    types.add(DataStoreProvider.DataStoreProviderType.PRIMARY);
    when(primaryDataStoreProvider.getTypes()).thenReturn(types);
    when(primaryDataStoreProvider.getName()).thenReturn(DataStoreProvider.DEFAULT_PRIMARY);
    when(primaryDataStoreProvider.getDataStoreDriver()).thenReturn(driver);
    User user = mock(User.class);
    when(user.getId()).thenReturn(1L);
    Account account = mock(Account.class);
    when(account.getId()).thenReturn(1L);
    when(accountManager.getSystemAccount()).thenReturn(account);
    when(accountManager.getSystemUser()).thenReturn(user);
    if (Merovingian2.getLockController() == null) {
        _lockController = Merovingian2.createLockController(1234);
    } else {
        _lockController = Merovingian2.getLockController();
    }
    _lockController.cleanupThisServer();
    ComponentContext.initComponentsLifeCycle();
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) Account(com.cloud.user.Account) ClusterVO(com.cloud.dc.ClusterVO) User(com.cloud.user.User) PrimaryDataStoreProvider(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider) DataStoreProvider(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO) HostPodVO(com.cloud.dc.HostPodVO) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 54 with ImageStoreVO

use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.

the class ImageStoreHelper method convertToStagingStore.

/**
 * Convert current NFS secondary storage to Staging store to be ready to migrate to S3 object store.
 * @param store NFS image store.
 * @return true if successful.
 */
public boolean convertToStagingStore(DataStore store) {
    ImageStoreVO nfsStore = imageStoreDao.findById(store.getId());
    nfsStore.setRole(DataStoreRole.ImageCache);
    imageStoreDao.update(store.getId(), nfsStore);
    // clear snapshot entry on primary store to make next snapshot become full snapshot
    snapshotStoreDao.deleteSnapshotRecordsOnPrimary();
    return true;
}
Also used : ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO)

Example 55 with ImageStoreVO

use of org.apache.cloudstack.storage.datastore.db.ImageStoreVO in project cloudstack by apache.

the class ImageStoreHelper method deleteImageStore.

public boolean deleteImageStore(long id) {
    ImageStoreVO store = imageStoreDao.findById(id);
    if (store == null) {
        throw new CloudRuntimeException("can't find image store:" + id);
    }
    imageStoreDao.remove(id);
    return true;
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ImageStoreVO(org.apache.cloudstack.storage.datastore.db.ImageStoreVO)

Aggregations

ImageStoreVO (org.apache.cloudstack.storage.datastore.db.ImageStoreVO)55 ArrayList (java.util.ArrayList)19 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)18 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)17 DataCenterVO (com.cloud.dc.DataCenterVO)12 Account (com.cloud.user.Account)12 HashMap (java.util.HashMap)12 HostVO (com.cloud.host.HostVO)11 HostPodVO (com.cloud.dc.HostPodVO)10 VMTemplateVO (com.cloud.storage.VMTemplateVO)10 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)9 ClusterVO (com.cloud.dc.ClusterVO)8 Map (java.util.Map)8 ZoneScope (org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope)8 Test (org.junit.Test)8 VolumeVO (com.cloud.storage.VolumeVO)6 VMInstanceVO (com.cloud.vm.VMInstanceVO)6 Random (java.util.Random)6 DataStoreProvider (org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider)6 TemplateDataStoreVO (org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO)6