當前位置: 首頁>>代碼示例>>Java>>正文


Java Storage類代碼示例

本文整理匯總了Java中com.cloud.storage.Storage的典型用法代碼示例。如果您正苦於以下問題:Java Storage類的具體用法?Java Storage怎麽用?Java Storage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Storage類屬於com.cloud.storage包,在下文中一共展示了Storage類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: userIsoSearch

import com.cloud.storage.Storage; //導入依賴的package包/類
@Override
public List<VMTemplateVO> userIsoSearch(final boolean listRemoved) {

    SearchBuilder<VMTemplateVO> sb = null;
    sb = UserIsoSearch;
    final SearchCriteria<VMTemplateVO> sc = sb.create();

    sc.setParameters("format", Storage.ImageFormat.ISO);
    sc.setParameters("type", TemplateType.USER.toString());

    if (!listRemoved) {
        sc.setParameters("state", VirtualMachineTemplate.State.Active);
    }

    return listBy(sc);
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:17,代碼來源:VMTemplateDaoImpl.java

示例2: findSystemVMTemplate

import com.cloud.storage.Storage; //導入依賴的package包/類
@Override
public VMTemplateVO findSystemVMTemplate(final long zoneId) {
    final SearchCriteria<VMTemplateVO> sc = tmpltTypeHyperSearch.create();
    sc.setParameters("templateType", Storage.TemplateType.SYSTEM);
    sc.setJoinParameters("tmplHyper", "type", Host.Type.Routing);
    sc.setJoinParameters("tmplHyper", "zoneId", zoneId);

    // order by descending order of id and select the first (this is going
    // to be the latest)
    final List<VMTemplateVO> tmplts = listBy(sc, new Filter(VMTemplateVO.class, "id", false, null, 1l));

    if (tmplts.size() > 0) {
        return tmplts.get(0);
    } else {
        return null;
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:18,代碼來源:VMTemplateDaoImpl.java

示例3: findSystemVMReadyTemplate

import com.cloud.storage.Storage; //導入依賴的package包/類
@Override
public VMTemplateVO findSystemVMReadyTemplate(final long zoneId, final HypervisorType hypervisorType) {
    final SearchCriteria<VMTemplateVO> sc = readySystemTemplateSearch.create();
    sc.setParameters("templateType", Storage.TemplateType.SYSTEM);
    sc.setParameters("state", VirtualMachineTemplate.State.Active);
    sc.setJoinParameters("tmplHyper", "type", Host.Type.Routing);
    sc.setJoinParameters("tmplHyper", "zoneId", zoneId);
    sc.setJoinParameters("vmTemplateJoinTemplateStoreRef", "downloadState", VMTemplateStorageResourceAssoc.Status.DOWNLOADED);

    // order by descending order of id
    final List<VMTemplateVO> tmplts = listBy(sc, new Filter(VMTemplateVO.class, "id", false, null, null));

    if (tmplts.size() > 0) {
        if (hypervisorType == HypervisorType.Any) {
            return tmplts.get(0);
        }
        for (final VMTemplateVO tmplt : tmplts) {
            if (tmplt.getHypervisorType() == hypervisorType) {
                return tmplt;
            }
        }
    }
    return null;
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:25,代碼來源:VMTemplateDaoImpl.java

示例4: testProcess

import com.cloud.storage.Storage; //導入依賴的package包/類
@Test
public void testProcess() throws Exception {
    final String templatePath = "/tmp";
    final String templateName = "template";
    final long virtualSize = 2000;
    final long actualSize = 1000;

    Mockito.when(mockStorageLayer.exists(Mockito.anyString())).thenReturn(true);
    final File mockFile = Mockito.mock(File.class);

    Mockito.when(mockStorageLayer.getFile(Mockito.anyString())).thenReturn(mockFile);
    Mockito.when(mockStorageLayer.getSize(Mockito.anyString())).thenReturn(actualSize);
    Mockito.doReturn(virtualSize).when(processor).getTemplateVirtualSize((File) Mockito.any());

    final Processor.FormatInfo info = processor.process(templatePath, null, templateName);
    Assert.assertEquals(Storage.ImageFormat.QCOW2, info.format);
    Assert.assertEquals(actualSize, info.size);
    Assert.assertEquals(virtualSize, info.virtualSize);
    Assert.assertEquals(templateName + ".qcow2", info.filename);
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:21,代碼來源:QCOW2ProcessorTest.java

示例5: testProcess

import com.cloud.storage.Storage; //導入依賴的package包/類
@Test
public void testProcess() throws Exception {
    final String templatePath = "/tmp";
    final String templateName = "template";
    final long virtualSize = 2000;
    final long actualSize = 1000;

    Mockito.when(mockStorageLayer.exists(Mockito.anyString())).thenReturn(true);
    final File mockFile = Mockito.mock(File.class);

    Mockito.when(mockStorageLayer.getFile(Mockito.anyString())).thenReturn(mockFile);
    Mockito.when(mockStorageLayer.getSize(Mockito.anyString())).thenReturn(actualSize);
    Mockito.doReturn(virtualSize).when(processor).getTemplateVirtualSize((File) Mockito.any());

    final Processor.FormatInfo info = processor.process(templatePath, null, templateName);
    Assert.assertEquals(Storage.ImageFormat.VHD, info.format);
    Assert.assertEquals(actualSize, info.size);
    Assert.assertEquals(virtualSize, info.virtualSize);
    Assert.assertEquals(templateName + ".vhd", info.filename);
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:21,代碼來源:VhdProcessorTest.java

示例6: initialize

import com.cloud.storage.Storage; //導入依賴的package包/類
@Override
public StartupCommand[] initialize() {

    final StartupStorageCommand cmd =
            new StartupStorageCommand(_parent, StoragePoolType.Filesystem, 1024l * 1024l * 1024l * 1024l, _dlMgr.gatherTemplateInfo(_parent));
    cmd.setResourceType(Storage.StorageResourceType.LOCAL_SECONDARY_STORAGE);
    cmd.setIqn("local://");
    fillNetworkInformation(cmd);
    cmd.setDataCenter(_dc);
    cmd.setPod(_pod);
    cmd.setGuid(_guid);
    cmd.setName(_guid);
    cmd.setVersion(LocalSecondaryStorageResource.class.getPackage().getImplementationVersion());

    return new StartupCommand[]{cmd};
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:17,代碼來源:LocalSecondaryStorageResource.java

示例7: processConnect

import com.cloud.storage.Storage; //導入依賴的package包/類
@Override
public void processConnect(final Host agent, final StartupCommand cmd, final boolean forRebalance) {
    if ((cmd instanceof StartupStorageCommand)) {
        final StartupStorageCommand scmd = (StartupStorageCommand) cmd;
        if (scmd.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE) {
            _ssVmMgr.generateSetupCommand(agent.getId());
            return;
        }
    } else if (cmd instanceof StartupSecondaryStorageCommand) {
        if (s_logger.isInfoEnabled()) {
            s_logger.info("Received a host startup notification " + cmd);
        }
        _ssVmMgr.onAgentConnect(agent.getDataCenterId(), cmd);
        _ssVmMgr.generateSetupCommand(agent.getId());
        _ssVmMgr.generateFirewallConfiguration(agent.getId());
        _ssVmMgr.generateVMSetupCommand(agent.getId());
        return;
    }
    return;
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:21,代碼來源:SecondaryStorageListener.java

示例8: initialize

import com.cloud.storage.Storage; //導入依賴的package包/類
@Override
public StartupCommand[] initialize() {
    final StartupStorageCommand cmd =
            new StartupStorageCommand("dummy", StoragePoolType.NetworkFilesystem, 1024 * 1024 * 1024 * 100L, new HashMap<>());

    cmd.setResourceType(Storage.StorageResourceType.SECONDARY_STORAGE);
    cmd.setIqn(null);
    cmd.setNfsShare(_guid);

    fillNetworkInformation(cmd);
    cmd.setDataCenter(_dc);
    cmd.setPod(_pod);
    cmd.setGuid(_guid);

    cmd.setName(_guid);
    cmd.setVersion(DummySecondaryStorageResource.class.getPackage().getImplementationVersion());
    /* gather TemplateInfo in second storage */
    cmd.setTemplateInfo(getDefaultSystemVmTemplateInfo());
    cmd.getHostDetails().put("mount.parent", "dummy");
    cmd.getHostDetails().put("mount.path", "dummy");
    cmd.getHostDetails().put("orig.url", _guid);

    final String[] tok = _dummyPath.split(":");
    cmd.setPrivateIpAddress(tok[0]);
    return new StartupCommand[]{cmd};
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:27,代碼來源:DummySecondaryStorageResource.java

示例9: processConnect

import com.cloud.storage.Storage; //導入依賴的package包/類
@Override
public void processConnect(final Host server, final StartupCommand startup, final boolean forRebalance) throws ConnectionException {

    if (!(startup instanceof StartupStorageCommand)) {
        return;
    }

    final StartupStorageCommand ssCmd = (StartupStorageCommand) startup;
    if (ssCmd.getResourceType() == Storage.StorageResourceType.STORAGE_HOST) {
        final BigDecimal overProvFactor = BigDecimal.valueOf(CapacityManager.StorageOverprovisioningFactor.value());
        final CapacityVO capacity =
                new CapacityVO(server.getId(), server.getDataCenterId(), server.getPodId(), server.getClusterId(), 0L, (overProvFactor.multiply(new BigDecimal(
                        server.getTotalSize()))).longValue(), Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
        _capacityDao.persist(capacity);
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:17,代碼來源:StorageCapacityListener.java

示例10: getSvcoffering

import com.cloud.storage.Storage; //導入依賴的package包/類
private ServiceOfferingVO getSvcoffering(final int ramSize) {

        final long id = 4L;
        final String name = "name";
        final String displayText = "displayText";
        final int cpu = 1;
        //int ramSize = 256;
        final int speed = 128;

        final boolean ha = false;
        final boolean useLocalStorage = false;

        final ServiceOfferingVO serviceOffering =
                new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, ha, displayText, Storage.ProvisioningType.THIN,
                        useLocalStorage, false, null, false, null, false);
        return serviceOffering;
    }
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:18,代碼來源:UserVmManagerTest.java

示例11: createDiskFromTemplate

import com.cloud.storage.Storage; //導入依賴的package包/類
public KvmPhysicalDisk createDiskFromTemplate(final KvmPhysicalDisk template, final String name,
                                              final Storage.ProvisioningType provisioningType,
                                              final KvmStoragePool destPool, final long size, final int timeout) {
    final StorageAdaptor adaptor = getStorageAdaptor(destPool.getType());

    // LibvirtStorageAdaptor-specific statement
    if (destPool.getType() == StoragePoolType.RBD) {
        return adaptor.createDiskFromTemplate(template, name,
                PhysicalDiskFormat.RAW, provisioningType,
                size, destPool, timeout);
    } else if (destPool.getType() == StoragePoolType.CLVM) {
        return adaptor.createDiskFromTemplate(template, name,
                PhysicalDiskFormat.RAW, provisioningType,
                size, destPool, timeout);
    } else if (template.getFormat() == PhysicalDiskFormat.DIR) {
        return adaptor.createDiskFromTemplate(template, name,
                PhysicalDiskFormat.DIR, provisioningType,
                size, destPool, timeout);
    } else {
        return adaptor.createDiskFromTemplate(template, name,
                PhysicalDiskFormat.QCOW2, provisioningType,
                size, destPool, timeout);
    }
}
 
開發者ID:MissionCriticalCloud,項目名稱:cosmic,代碼行數:25,代碼來源:KvmStoragePoolManager.java

示例12: initialize

import com.cloud.storage.Storage; //導入依賴的package包/類
@Override
public StartupCommand[] initialize() {
    final List<Object> info = getHostInfo();

    final StartupRoutingCommand cmd =
        new StartupRoutingCommand((Integer)info.get(0), (Long)info.get(1), (Long)info.get(2), (Long)info.get(4), (String)info.get(3), HypervisorType.KVM,
            RouterPrivateIpStrategy.HostLocal);
    fillNetworkInformation(cmd);
    cmd.getHostDetails().putAll(getVersionStrings());
    cmd.setCluster(getConfiguredProperty("cluster", "1"));
    StoragePoolInfo pi = initializeLocalStorage();
    StartupStorageCommand sscmd = new StartupStorageCommand();
    sscmd.setPoolInfo(pi);
    sscmd.setGuid(pi.getUuid());
    sscmd.setDataCenter((String)_params.get("zone"));
    sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);

    return new StartupCommand[] {cmd, sscmd};
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:20,代碼來源:DummyResource.java

示例13: createTemplateInDb

import com.cloud.storage.Storage; //導入依賴的package包/類
private VMTemplateVO createTemplateInDb() {
    image = new VMTemplateVO();
    image.setTemplateType(TemplateType.USER);

    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);
    return image;
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:22,代碼來源:VolumeTestVmware.java

示例14: createImageData

import com.cloud.storage.Storage; //導入依賴的package包/類
private VMTemplateVO createImageData() {
    VMTemplateVO 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.setImageDataStoreId(storeId);
    image = imageDataDao.persist(image);

    return image;
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:25,代碼來源:VolumeServiceTest.java

示例15: createDataStore

import com.cloud.storage.Storage; //導入依賴的package包/類
private DataStore createDataStore() throws URISyntaxException {
    StoragePoolVO pool = new StoragePoolVO();
    pool.setClusterId(clusterId);
    pool.setDataCenterId(dcId);
    URI uri = new URI("nfs://jfkdkf/fjdkfj");
    pool.setHostAddress(uri.getHost());
    pool.setPath(uri.getPath());
    pool.setPort(0);
    pool.setName(UUID.randomUUID().toString());
    pool.setUuid(UUID.randomUUID().toString());
    pool.setStatus(StoragePoolStatus.Up);
    pool.setPoolType(Storage.StoragePoolType.NetworkFilesystem);
    pool.setPodId(podId);
    pool.setScope(ScopeType.CLUSTER);
    pool.setStorageProviderName(DataStoreProvider.DEFAULT_PRIMARY);
    pool = primaryDataStoreDao.persist(pool);
    DataStore store = dataStoreManager.getPrimaryDataStore(pool.getId());
    return store;
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:20,代碼來源:SnapshotTestWithFakeData.java


注:本文中的com.cloud.storage.Storage類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。