本文整理汇总了Java中com.cloud.storage.Storage.ImageFormat类的典型用法代码示例。如果您正苦于以下问题:Java ImageFormat类的具体用法?Java ImageFormat怎么用?Java ImageFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageFormat类属于com.cloud.storage.Storage包,在下文中一共展示了ImageFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: userIsoSearch
import com.cloud.storage.Storage.ImageFormat; //导入依赖的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);
}
示例2: remove
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
@Override
@DB
public boolean remove(final Long id) {
final TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
final VMTemplateVO template = createForUpdate();
template.setRemoved(new Date());
final VMTemplateVO vo = findById(id);
if (vo != null) {
if (vo.getFormat() == ImageFormat.ISO) {
_tagsDao.removeByIdAndType(id, ResourceObjectType.ISO);
} else {
_tagsDao.removeByIdAndType(id, ResourceObjectType.Template);
}
}
final boolean result = update(id, template);
txn.commit();
return result;
}
示例3: VolumeHostVO
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
public VolumeHostVO(final long hostId, final long volumeId, final long zoneId, final Date lastUpdated, final int downloadPercent, final Status downloadState, final String
localDownloadPath,
final String errorString, final String jobId, final String installPath, final String downloadUrl, final String checksum, final ImageFormat format) {
// super();
this.hostId = hostId;
this.volumeId = volumeId;
this.zoneId = zoneId;
this.lastUpdated = lastUpdated;
this.downloadPercent = downloadPercent;
this.downloadState = downloadState;
this.localDownloadPath = localDownloadPath;
this.errorString = errorString;
this.jobId = jobId;
this.installPath = installPath;
this.setDownloadUrl(downloadUrl);
this.checksum = checksum;
this.format = format;
}
示例4: VMTemplateVO
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
public VMTemplateVO(final Long id, final String uniqueName, final String name, final ImageFormat format, final boolean isPublic, final boolean featured, final TemplateType
type, final String url, final Date created,
final boolean requiresHvm, final int bits, final long accountId, final String cksum, final String displayText, final boolean enablePassword, final long
guestOSId, final boolean bootable,
final HypervisorType hyperType) {
this.id = id;
this.name = name;
publicTemplate = isPublic;
this.featured = featured;
templateType = type;
this.url = url;
this.requiresHvm = requiresHvm;
this.bits = bits;
this.accountId = accountId;
checksum = cksum;
this.uniqueName = uniqueName;
this.displayText = displayText;
this.enablePassword = enablePassword;
this.format = format;
this.created = created;
this.guestOSId = guestOSId;
this.bootable = bootable;
hypervisorType = hyperType;
uuid = UUID.randomUUID().toString();
state = State.Active;
}
示例5: process
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
@Override
public FormatInfo process(final String templatePath, final ImageFormat format, final String templateName) {
if (format != null) {
s_logger.debug("We don't handle conversion from " + format + " to ISO.");
return null;
}
final String isoPath = templatePath + File.separator + templateName + "." + ImageFormat.ISO.getFileExtension();
if (!_storage.exists(isoPath)) {
s_logger.debug("Unable to find the iso file: " + isoPath);
return null;
}
final FormatInfo info = new FormatInfo();
info.format = ImageFormat.ISO;
info.filename = templateName + "." + ImageFormat.ISO.getFileExtension();
info.size = _storage.getSize(isoPath);
info.virtualSize = info.size;
return info;
}
示例6: deleteFormat
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
protected FormatInfo deleteFormat(final ImageFormat format) {
final Iterator<FormatInfo> it = _formats.iterator();
while (it.hasNext()) {
final FormatInfo info = it.next();
if (info.format == format) {
it.remove();
_props.remove(format.getFileExtension());
_props.remove(format.getFileExtension() + ".filename");
_props.remove(format.getFileExtension() + ".size");
_props.remove(format.getFileExtension() + ".virtualsize");
return info;
}
}
return null;
}
示例7: process
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
@Override
public FormatInfo process(final String templatePath, final ImageFormat format, final String templateName) {
if (format != null) {
s_logger.debug("We currently don't handle conversion from " + format + " to TAR.");
return null;
}
final String tarPath = templatePath + File.separator + templateName + "." + ImageFormat.TAR.getFileExtension();
if (!_storage.exists(tarPath)) {
s_logger.debug("Unable to find the tar file: " + tarPath);
return null;
}
final FormatInfo info = new FormatInfo();
info.format = ImageFormat.TAR;
info.filename = templateName + "." + ImageFormat.TAR.getFileExtension();
final File tarFile = _storage.getFile(tarPath);
info.size = _storage.getSize(tarPath);
info.virtualSize = getVirtualSize(tarFile);
return info;
}
示例8: process
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
@Override
public FormatInfo process(final String templatePath, final ImageFormat format, final String templateName) throws InternalErrorException {
if (format != null) {
s_logger.debug("We currently don't handle conversion from " + format + " to raw image.");
return null;
}
final String imgPath = templatePath + File.separator + templateName + "." + ImageFormat.RAW.getFileExtension();
if (!_storage.exists(imgPath)) {
s_logger.debug("Unable to find raw image:" + imgPath);
return null;
}
final FormatInfo info = new FormatInfo();
info.format = ImageFormat.RAW;
info.filename = templateName + "." + ImageFormat.RAW.getFileExtension();
info.size = _storage.getSize(imgPath);
info.virtualSize = info.size;
s_logger.debug("Process raw image " + info.filename + " successfully");
return info;
}
示例9: testDownload
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
@Test
public void testDownload() {
s_logger.info("Testing Download answer");
final VirtualMachineTemplate template = Mockito.mock(VirtualMachineTemplate.class);
Mockito.when(template.getId()).thenReturn(1L);
Mockito.when(template.getFormat()).thenReturn(ImageFormat.QCOW2);
Mockito.when(template.getName()).thenReturn("templatename");
Mockito.when(template.getTemplateType()).thenReturn(TemplateType.USER);
Mockito.when(template.getDisplayText()).thenReturn("displayText");
Mockito.when(template.getHypervisorType()).thenReturn(HypervisorType.KVM);
Mockito.when(template.getUrl()).thenReturn("url");
final NfsTO nfs = new NfsTO("secUrl", DataStoreRole.Image);
final TemplateObjectTO to = new TemplateObjectTO(template);
to.setImageDataStore(nfs);
final DownloadCommand cmd = new DownloadCommand(to, 30000000l);
final Request req = new Request(1, 1, cmd, true);
req.logD("Debug for Download");
final DownloadAnswer answer = new DownloadAnswer("jobId", 50, "errorString", Status.ABANDONED, "filesystempath", "installpath", 10000000, 20000000, "chksum");
final Response resp = new Response(req, answer);
resp.logD("Debug for Download");
}
示例10: getTemplateFormat
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
private ImageFormat getTemplateFormat(final String filePath) {
String ext = null;
final int extensionPos = filePath.lastIndexOf('.');
final int lastSeparator = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'));
final int i = lastSeparator > extensionPos ? -1 : extensionPos;
if (i > 0) {
ext = filePath.substring(i + 1);
}
if (ext != null) {
if (ext.equalsIgnoreCase("vhd")) {
return ImageFormat.VHD;
} else if (ext.equalsIgnoreCase("qcow2")) {
return ImageFormat.QCOW2;
} else if (ext.equalsIgnoreCase("tar")) {
return ImageFormat.TAR;
} else if (ext.equalsIgnoreCase("img") || ext.equalsIgnoreCase("raw")) {
return ImageFormat.RAW;
} else if (ext.equalsIgnoreCase("vdi")) {
return ImageFormat.VDI;
}
}
return null;
}
示例11: getHypervisorTypeFromFormat
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
public static HypervisorType getHypervisorTypeFromFormat(final long dcId, final ImageFormat format) {
HypervisorType type = s_storageMgr.getHypervisorTypeFromFormat(format);
if (format == ImageFormat.RAW) {
// Currently, KVM only suppoorts RBD images of type RAW.
// This results in a weird collision with OVM volumes which
// can only be raw, thus making KVM RBD volumes show up as OVM
// rather than RBD. This block of code can (hopefuly) by checking to
// see if the pool is using either RBD or NFS. However, it isn't
// quite clear what to do if both storage types are used. If the image
// format is RAW, it narrows the hypervisor choice down to OVM and KVM / RBD or KVM / CLVM
// This would be better implemented at a cluster level.
final List<StoragePoolVO> pools = s_storagePoolDao.listByDataCenterId(dcId);
final ListIterator<StoragePoolVO> itr = pools.listIterator();
while (itr.hasNext()) {
final StoragePoolVO pool = itr.next();
if (pool.getPoolType() == StoragePoolType.RBD || pool.getPoolType() == StoragePoolType.CLVM) {
// This case will note the presence of non-qcow2 primary stores, suggesting KVM without NFS. Otherwse,
// If this check is not passed, the hypervisor type will remain OVM.
type = HypervisorType.KVM;
break;
}
}
}
return type;
}
示例12: prepare
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
@Override
public TemplateProfile prepare(final RegisterIsoCmd cmd) throws ResourceAllocationException {
//check if the caller can operate with the template owner
final Account caller = CallContext.current().getCallingAccount();
final Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId());
_accountMgr.checkAccess(caller, null, true, owner);
Long zoneId = cmd.getZoneId();
// ignore passed zoneId if we are using region wide image store
final List<ImageStoreVO> stores = _imgStoreDao.findRegionImageStores();
if (stores != null && stores.size() > 0) {
zoneId = -1L;
}
return prepare(true, CallContext.current().getCallingUserId(), cmd.getIsoName(), cmd.getDisplayText(), 64, false, true, cmd.getUrl(), cmd.isPublic(),
cmd.isFeatured(), cmd.isExtractable(), ImageFormat.ISO.toString(), cmd.getOsTypeId(), zoneId, HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null,
owner, null, false, cmd.getImageStoreUuid(), cmd.isDynamicallyScalable(), TemplateType.USER);
}
示例13: prepareDelete
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
@Override
public TemplateProfile prepareDelete(final DeleteTemplateCmd cmd) {
final Long templateId = cmd.getId();
Long userId = CallContext.current().getCallingUserId();
final Account account = CallContext.current().getCallingAccount();
final Long zoneId = cmd.getZoneId();
final VMTemplateVO template = _tmpltDao.findById(templateId);
if (template == null) {
throw new InvalidParameterValueException("unable to find template with id " + templateId);
}
userId = accountAndUserValidation(account, userId, null, template, "Unable to delete template ");
final UserVO user = _userDao.findById(userId);
if (user == null) {
throw new InvalidParameterValueException("Please specify a valid user.");
}
if (template.getFormat() == ImageFormat.ISO) {
throw new InvalidParameterValueException("Please specify a valid template.");
}
return new TemplateProfile(userId, template, zoneId);
}
示例14: getUnusedTemplatesInPool
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
@Override
public List<VMTemplateStoragePoolVO> getUnusedTemplatesInPool(final StoragePoolVO pool) {
final List<VMTemplateStoragePoolVO> unusedTemplatesInPool = new ArrayList<>();
final List<VMTemplateStoragePoolVO> allTemplatesInPool = _tmpltPoolDao.listByPoolId(pool.getId());
for (final VMTemplateStoragePoolVO templatePoolVO : allTemplatesInPool) {
final VMTemplateVO template = _tmpltDao.findByIdIncludingRemoved(templatePoolVO.getTemplateId());
// If this is a routing template, consider it in use
if (template.getTemplateType() == TemplateType.SYSTEM) {
continue;
}
// If the template is not yet downloaded to the pool, consider it in
// use
if (templatePoolVO.getDownloadState() != Status.DOWNLOADED) {
continue;
}
if (template.getFormat() != ImageFormat.ISO && !_volumeDao.isAnyVolumeActivelyUsingTemplateOnPool(template.getId(), pool.getId())) {
unusedTemplatesInPool.add(templatePoolVO);
}
}
return unusedTemplatesInPool;
}
示例15: prepareIso
import com.cloud.storage.Storage.ImageFormat; //导入依赖的package包/类
@Override
public TemplateInfo prepareIso(final long isoId, final long dcId) {
final TemplateInfo tmplt = _tmplFactory.getTemplate(isoId, DataStoreRole.Image, dcId);
if (tmplt == null || tmplt.getFormat() != ImageFormat.ISO) {
s_logger.warn("ISO: " + isoId + " does not exist in vm_template table");
return null;
}
if (tmplt.getDataStore() != null && !(tmplt.getDataStore().getTO() instanceof NfsTO)) {
// if it is s3, need to download into cache storage first
final Scope destScope = new ZoneScope(dcId);
final TemplateInfo cacheData = (TemplateInfo) cacheMgr.createCacheObject(tmplt, destScope);
if (cacheData == null) {
s_logger.error("Failed in copy iso from S3 to cache storage");
return null;
}
return cacheData;
} else {
return tmplt;
}
}