示例#1
0
        /// <summary>
        /// Creates a new virtual disk at the specified path.
        /// </summary>
        /// <param name="fileLocator">The object used to locate / create the component files.</param>
        /// <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>
        internal static DiskImageFile Initialize(FileLocator fileLocator, string path, DiskParameters parameters)
        {
            if (parameters.Capacity <= 0)
            {
                throw new ArgumentException("Capacity must be greater than zero", "parameters");
            }

            Geometry geometry = parameters.Geometry ?? DefaultGeometry(parameters.Capacity);

            Geometry biosGeometry;

            if (parameters.BiosGeometry != null)
            {
                biosGeometry = parameters.BiosGeometry;
            }
            else
            {
                biosGeometry = Geometry.MakeBiosSafe(geometry, parameters.Capacity);
            }


            DiskAdapterType adapterType = (parameters.AdapterType == DiskAdapterType.None) ? DiskAdapterType.LsiLogicScsi : parameters.AdapterType;
            DiskCreateType  createType  = (parameters.CreateType == DiskCreateType.None) ? DiskCreateType.MonolithicSparse : parameters.CreateType;

            DescriptorFile baseDescriptor = CreateSimpleDiskDescriptor(geometry, biosGeometry, createType, adapterType);

            return(DoInitialize(fileLocator, path, parameters.Capacity, createType, baseDescriptor));
        }
示例#2
0
        /// <summary>
        /// Creates a new virtual disk at the specified path.
        /// </summary>
        /// <param name="fileSystem">The file system to create the VMDK on.</param>
        /// <param name="path">The name of the VMDK to create.</param>
        /// <param name="capacity">The desired capacity of the new disk.</param>
        /// <param name="createType">The type of virtual disk to create.</param>
        /// <param name="adapterType">The type of disk adapter used with the disk.</param>
        /// <returns>The newly created disk image.</returns>
        public static DiskImageFile Initialize(DiscFileSystem fileSystem, string path, long capacity,
                                               DiskCreateType createType, DiskAdapterType adapterType)
        {
            DiskParameters diskParams = new DiskParameters();

            diskParams.Capacity    = capacity;
            diskParams.CreateType  = createType;
            diskParams.AdapterType = adapterType;

            return(Initialize(fileSystem, path, diskParams));
        }
示例#3
0
        /// <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="createType">The type of virtual disk to create.</param>
        /// <param name="adapterType">The type of disk adapter used with the disk.</param>
        /// <returns>The newly created disk image.</returns>
        public static DiskImageFile Initialize(string path, long capacity, Geometry geometry, DiskCreateType createType,
                                               DiskAdapterType adapterType)
        {
            DiskParameters diskParams = new DiskParameters();

            diskParams.Capacity    = capacity;
            diskParams.Geometry    = geometry;
            diskParams.CreateType  = createType;
            diskParams.AdapterType = adapterType;

            return(Initialize(path, diskParams));
        }
示例#4
0
        private static string FormatAdapterType(DiskAdapterType value)
        {
            switch (value)
            {
            case DiskAdapterType.Ide:
                return("ide");

            case DiskAdapterType.BusLogicScsi:
                return("buslogic");

            case DiskAdapterType.LsiLogicScsi:
                return("lsilogic");

            case DiskAdapterType.LegacyEsx:
                return("legacyESX");

            default:
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unknown type: {0}", value), "value");
            }
        }
示例#5
0
 /// <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="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, DiskCreateType type, DiskAdapterType adapterType)
 {
     return(Initialize(path, capacity, null, type, adapterType));
 }
示例#6
0
 internal static DescriptorFile CreateSimpleDiskDescriptor(Geometry geometry, Geometry biosGeometery, DiskCreateType createType, DiskAdapterType adapterType)
 {
     DescriptorFile baseDescriptor = new DescriptorFile();
     baseDescriptor.DiskGeometry = geometry;
     baseDescriptor.BiosGeometry = biosGeometery;
     baseDescriptor.ContentId = (uint)_rng.Next();
     baseDescriptor.CreateType = createType;
     baseDescriptor.UniqueId = Guid.NewGuid();
     baseDescriptor.HardwareVersion = "4";
     baseDescriptor.AdapterType = adapterType;
     return baseDescriptor;
 }
示例#7
0
        /// <summary>
        /// Creates a new virtual disk at the specified path.
        /// </summary>
        /// <param name="fileSystem">The file system to create the VMDK on</param>
        /// <param name="path">The name of the VMDK to create.</param>
        /// <param name="capacity">The desired capacity of the new disk</param>
        /// <param name="createType">The type of virtual disk to create</param>
        /// <param name="adapterType">The type of disk adapter used with the disk</param>
        /// <returns>The newly created disk image</returns>
        public static DiskImageFile Initialize(DiscFileSystem fileSystem, string path, long capacity, DiskCreateType createType, DiskAdapterType adapterType)
        {
            DiskParameters diskParams = new DiskParameters();
            diskParams.Capacity = capacity;
            diskParams.CreateType = createType;
            diskParams.AdapterType = adapterType;

            return Initialize(fileSystem, path, diskParams);
        }
示例#8
0
        /// <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="createType">The type of virtual disk to create</param>
        /// <param name="adapterType">The type of disk adapter used with the disk</param>
        /// <returns>The newly created disk image</returns>
        public static DiskImageFile Initialize(string path, long capacity, Geometry geometry, DiskCreateType createType, DiskAdapterType adapterType)
        {
            DiskParameters diskParams = new DiskParameters();
            diskParams.Capacity = capacity;
            diskParams.Geometry = geometry;
            diskParams.CreateType = createType;
            diskParams.AdapterType = adapterType;

            return Initialize(path, diskParams);
        }
示例#9
0
 private static string FormatAdapterType(DiskAdapterType value)
 {
     switch (value)
     {
         case DiskAdapterType.Ide:
             return "ide";
         case DiskAdapterType.BusLogicScsi:
             return "buslogic";
         case DiskAdapterType.LsiLogicScsi:
             return "lsilogic";
         case DiskAdapterType.LegacyEsx:
             return "legacyESX";
         default:
             throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unknown type: {0}", value), "value");
     }
 }
示例#10
0
        internal static DescriptorFile CreateSimpleDiskDescriptor(Geometry geometry, Geometry biosGeometery, DiskCreateType createType, DiskAdapterType adapterType)
        {
            DescriptorFile baseDescriptor = new DescriptorFile();

            baseDescriptor.DiskGeometry    = geometry;
            baseDescriptor.BiosGeometry    = biosGeometery;
            baseDescriptor.ContentId       = (uint)_rng.Next();
            baseDescriptor.CreateType      = createType;
            baseDescriptor.UniqueId        = Guid.NewGuid();
            baseDescriptor.HardwareVersion = "4";
            baseDescriptor.AdapterType     = adapterType;
            return(baseDescriptor);
        }
示例#11
0
 /// <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);
 }
示例#12
0
 /// <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);
 }
示例#13
0
 /// <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="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, DiskCreateType type, DiskAdapterType adapterType)
 {
     return Initialize(path, capacity, null, type, adapterType);
 }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the DiskBuilder class.
 /// </summary>
 public DiskBuilder()
 {
     _diskType    = DiskCreateType.Vmfs;
     _adapterType = DiskAdapterType.LsiLogicScsi;
 }
示例#15
0
 /// <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));
 }
示例#16
0
 /// <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));
 }
示例#17
0
 /// <summary>
 /// Initializes a new instance of the DiskBuilder class.
 /// </summary>
 public DiskBuilder()
 {
     _diskType = DiskCreateType.Vmfs;
     _adapterType = DiskAdapterType.LsiLogicScsi;
 }