/// <summary> /// Creates a new virtual disk that is a linked clone of an existing disk. /// </summary> /// <param name="path">The path to the new disk</param> /// <param name="type">The type of the new disk</param> /// <param name="parent">The disk to clone</param> /// <returns>The new virtual disk</returns> public static DiskImageFile InitializeDifferencing(string path, DiskCreateType type, string parent) { if (type != DiskCreateType.MonolithicSparse && type != DiskCreateType.TwoGbMaxExtentSparse && type != DiskCreateType.VmfsSparse) { throw new ArgumentException("Differencing disks must be sparse", "type"); } using (DiskImageFile parentFile = new DiskImageFile(parent, FileAccess.Read)) { DescriptorFile baseDescriptor = CreateDifferencingDiskDescriptor(type, parentFile, parent); FileLocator locator = new LocalFileLocator(Path.GetDirectoryName(path)); return(DoInitialize(locator, Path.GetFileName(path), parentFile.Capacity, type, baseDescriptor)); } }
/// <summary> /// Creates a new virtual disk that is a linked clone of an existing disk. /// </summary> /// <param name="fileSystem">The file system to create the VMDK on</param> /// <param name="path">The path to the new disk</param> /// <param name="type">The type of the new disk</param> /// <param name="parent">The disk to clone</param> /// <returns>The new virtual disk</returns> public static DiskImageFile InitializeDifferencing(DiscFileSystem fileSystem, string path, DiskCreateType type, string parent) { if (type != DiskCreateType.MonolithicSparse && type != DiskCreateType.TwoGbMaxExtentSparse && type != DiskCreateType.VmfsSparse) { throw new ArgumentException("Differencing disks must be sparse", "type"); } string basePath = Utilities.GetDirectoryFromPath(path); FileLocator locator = new DiscFileLocator(fileSystem, basePath); FileLocator parentLocator = locator.GetRelativeLocator(Utilities.GetDirectoryFromPath(parent)); using (DiskImageFile parentFile = new DiskImageFile(parentLocator, Utilities.GetFileFromPath(parent), FileAccess.Read)) { DescriptorFile baseDescriptor = CreateDifferencingDiskDescriptor(type, parentFile, parent); return(DoInitialize(locator, Utilities.GetFileFromPath(path), parentFile.Capacity, type, baseDescriptor)); } }
internal Disk(DiskImageFile file, Ownership ownsStream) { _files = new List <ThinkAway.Tuple <VirtualDiskLayer, Ownership> >(); _files.Add(new ThinkAway.Tuple <VirtualDiskLayer, Ownership>(file, ownsStream)); ResolveFileChain(); }
internal static Disk Initialize(FileLocator fileLocator, string path, DiskParameters parameters) { return(new Disk(DiskImageFile.Initialize(fileLocator, path, parameters), Ownership.Dispose)); }
/// <summary> /// Creates a new virtual disk as a thin clone of an existing disk. /// </summary> /// <param name="fileSystem">The file system to contain the disk</param> /// <param name="path">The path to the new disk.</param> /// <param name="type">The type of disk to create</param> /// <param name="parentPath">The path to the parent disk.</param> /// <returns>The new disk.</returns> public static Disk InitializeDifferencing(DiscFileSystem fileSystem, string path, DiskCreateType type, string parentPath) { return(new Disk(DiskImageFile.InitializeDifferencing(fileSystem, path, type, parentPath), Ownership.Dispose)); }
/// <summary> /// Creates a new virtual disk at the specified location on a file system. /// </summary> /// <param name="fileSystem">The file system to contain the disk</param> /// <param name="path">The file system path to the disk</param> /// <param name="capacity">The desired capacity of the new disk</param> /// <param name="type">The type of virtual disk to create</param> /// <param name="adapterType">The type of virtual disk adapter</param> /// <returns>The newly created disk image</returns> public static Disk Initialize(DiscFileSystem fileSystem, string path, long capacity, DiskCreateType type, DiskAdapterType adapterType) { return(new Disk(DiskImageFile.Initialize(fileSystem, path, capacity, type, adapterType), Ownership.Dispose)); }
/// <summary> /// Creates a new virtual disk at the specified path. /// </summary> /// <param name="path">The name of the VMDK to create.</param> /// <param name="capacity">The desired capacity of the new disk</param> /// <param name="geometry">The desired geometry of the new disk, or <c>null</c> for default</param> /// <param name="type">The type of virtual disk to create</param> /// <param name="adapterType">The type of virtual disk adapter</param> /// <returns>The newly created disk image</returns> public static Disk Initialize(string path, long capacity, Geometry geometry, DiskCreateType type, DiskAdapterType adapterType) { return(new Disk(DiskImageFile.Initialize(path, capacity, geometry, type, adapterType), Ownership.Dispose)); }
/// <summary> /// Creates a new virtual disk at the specified path. /// </summary> /// <param name="path">The name of the VMDK to create.</param> /// <param name="parameters">The desired parameters for the new disk.</param> /// <returns>The newly created disk image</returns> public static Disk Initialize(string path, DiskParameters parameters) { return(new Disk(DiskImageFile.Initialize(path, parameters), Ownership.Dispose)); }
internal Disk(DiskImageFile file, Ownership ownsStream) { _files = new List<ThinkAway.Tuple<VirtualDiskLayer, Ownership>>(); _files.Add(new ThinkAway.Tuple<VirtualDiskLayer, Ownership>(file, ownsStream)); ResolveFileChain(); }
private static DescriptorFile CreateDifferencingDiskDescriptor(DiskCreateType type, DiskImageFile parent, string parentPath) { DescriptorFile baseDescriptor = new DescriptorFile(); baseDescriptor.ContentId = (uint)_rng.Next(); baseDescriptor.ParentContentId = parent.ContentId; baseDescriptor.ParentFileNameHint = parentPath; baseDescriptor.CreateType = type; return baseDescriptor; }
/// <summary> /// Creates a new virtual disk that is a linked clone of an existing disk. /// </summary> /// <param name="fileSystem">The file system to create the VMDK on</param> /// <param name="path">The path to the new disk</param> /// <param name="type">The type of the new disk</param> /// <param name="parent">The disk to clone</param> /// <returns>The new virtual disk</returns> public static DiskImageFile InitializeDifferencing(DiscFileSystem fileSystem, string path, DiskCreateType type, string parent) { if (type != DiskCreateType.MonolithicSparse && type != DiskCreateType.TwoGbMaxExtentSparse && type != DiskCreateType.VmfsSparse) { throw new ArgumentException("Differencing disks must be sparse", "type"); } string basePath = Utilities.GetDirectoryFromPath(path); FileLocator locator = new DiscFileLocator(fileSystem, basePath); FileLocator parentLocator = locator.GetRelativeLocator(Utilities.GetDirectoryFromPath(parent)); using (DiskImageFile parentFile = new DiskImageFile(parentLocator, Utilities.GetFileFromPath(parent), FileAccess.Read)) { DescriptorFile baseDescriptor = CreateDifferencingDiskDescriptor(type, parentFile, parent); return DoInitialize(locator, Utilities.GetFileFromPath(path), parentFile.Capacity, type, baseDescriptor); } }
/// <summary> /// Creates a new virtual disk that is a linked clone of an existing disk. /// </summary> /// <param name="path">The path to the new disk</param> /// <param name="type">The type of the new disk</param> /// <param name="parent">The disk to clone</param> /// <returns>The new virtual disk</returns> public static DiskImageFile InitializeDifferencing(string path, DiskCreateType type, string parent) { if (type != DiskCreateType.MonolithicSparse && type != DiskCreateType.TwoGbMaxExtentSparse && type != DiskCreateType.VmfsSparse) { throw new ArgumentException("Differencing disks must be sparse", "type"); } using (DiskImageFile parentFile = new DiskImageFile(parent, FileAccess.Read)) { DescriptorFile baseDescriptor = CreateDifferencingDiskDescriptor(type, parentFile, parent); FileLocator locator = new LocalFileLocator(Path.GetDirectoryName(path)); return DoInitialize(locator, Path.GetFileName(path), parentFile.Capacity, type, baseDescriptor); } }
private static DescriptorFile CreateDifferencingDiskDescriptor(DiskCreateType type, DiskImageFile parent, string parentPath) { DescriptorFile baseDescriptor = new DescriptorFile(); baseDescriptor.ContentId = (uint)_rng.Next(); baseDescriptor.ParentContentId = parent.ContentId; baseDescriptor.ParentFileNameHint = parentPath; baseDescriptor.CreateType = type; return(baseDescriptor); }