本文整理汇总了Java中com.cloud.storage.Storage.ImageFormat.RAW属性的典型用法代码示例。如果您正苦于以下问题:Java ImageFormat.RAW属性的具体用法?Java ImageFormat.RAW怎么用?Java ImageFormat.RAW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.cloud.storage.Storage.ImageFormat
的用法示例。
在下文中一共展示了ImageFormat.RAW属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
@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;
}
示例2: getTemplateFormat
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;
}
示例3: getHypervisorTypeFromFormat
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;
}
示例4: getVirtualSize
protected long getVirtualSize(final File file, final ImageFormat format) {
Processor processor = null;
try {
if (format == null) {
return file.length();
} else if (format == ImageFormat.QCOW2) {
processor = new QCOW2Processor();
} else if (format == ImageFormat.VHD) {
processor = new VhdProcessor();
} else if (format == ImageFormat.RAW) {
processor = new RawImageProcessor();
}
if (format == ImageFormat.TAR) {
processor = new TARProcessor();
}
if (processor == null) {
return file.length();
}
final Map<String, Object> params = new HashMap<>();
params.put(StorageLayer.InstanceConfigKey, _storage);
processor.configure("template processor", params);
return processor.getVirtualSize(file);
} catch (final Exception e) {
s_logger.warn("Failed to get virtual size of file " + file.getPath() + ", returning file size instead: ", e);
return file.length();
}
}
示例5: createVolumeFromSnapshot
@Override
public Answer createVolumeFromSnapshot(final CopyCommand cmd) {
try {
final DataTO srcData = cmd.getSrcTO();
final SnapshotObjectTO snapshot = (SnapshotObjectTO) srcData;
final DataTO destData = cmd.getDestTO();
final PrimaryDataStoreTO pool = (PrimaryDataStoreTO) destData.getDataStore();
final DataStoreTO imageStore = srcData.getDataStore();
final VolumeObjectTO volume = snapshot.getVolume();
if (!(imageStore instanceof NfsTO)) {
return new CopyCmdAnswer("unsupported protocol");
}
final NfsTO nfsImageStore = (NfsTO) imageStore;
final String snapshotFullPath = snapshot.getPath();
final int index = snapshotFullPath.lastIndexOf("/");
final String snapshotPath = snapshotFullPath.substring(0, index);
final String snapshotName = snapshotFullPath.substring(index + 1);
final KvmStoragePool secondaryPool = storagePoolMgr.getStoragePoolByUri(
nfsImageStore.getUrl() + File.separator + snapshotPath);
final KvmPhysicalDisk snapshotDisk = secondaryPool.getPhysicalDisk(snapshotName);
if (volume.getFormat() == ImageFormat.RAW) {
snapshotDisk.setFormat(PhysicalDiskFormat.RAW);
} else if (volume.getFormat() == ImageFormat.QCOW2) {
snapshotDisk.setFormat(PhysicalDiskFormat.QCOW2);
}
final String primaryUuid = pool.getUuid();
final KvmStoragePool primaryPool = storagePoolMgr.getStoragePool(pool.getPoolType(), primaryUuid);
final String volUuid = UUID.randomUUID().toString();
final KvmPhysicalDisk disk = storagePoolMgr.copyPhysicalDisk(snapshotDisk, volUuid, primaryPool,
cmd.getWaitInMillSeconds());
final VolumeObjectTO newVol = new VolumeObjectTO();
newVol.setPath(disk.getName());
newVol.setSize(disk.getVirtualSize());
newVol.setFormat(ImageFormat.valueOf(disk.getFormat().toString().toUpperCase()));
return new CopyCmdAnswer(newVol);
} catch (final CloudRuntimeException e) {
logger.debug("Failed to createVolumeFromSnapshot: ", e);
return new CopyCmdAnswer(e.toString());
}
}