Exemplo n.º 1
0
        /// <summary>
        /// Create a new virtual disk.
        /// </summary>
        /// <param name="type">The type of disk to create (see <see cref="SupportedDiskTypes"/>)</param>
        /// <param name="variant">The variant of the type to create (see <see cref="GetSupportedDiskVariants"/>)</param>
        /// <param name="path">The path (or URI) for the disk to create</param>
        /// <param name="capacity">The capacity of the new disk</param>
        /// <param name="geometry">The geometry of the new disk (or null).</param>
        /// <param name="user">The user identity to use when accessing the <c>path</c> (or null)</param>
        /// <param name="password">The password to use when accessing the <c>path</c> (or null)</param>
        /// <param name="parameters">Untyped parameters controlling the creation process (TBD)</param>
        /// <returns>The newly created disk</returns>
        public static VirtualDisk CreateDisk(string type, string variant, string path, long capacity, Geometry geometry, string user, string password, Dictionary <string, string> parameters)
        {
            VirtualDiskParameters diskParams = new VirtualDiskParameters()
            {
                AdapterType = GenericDiskAdapterType.Scsi,
                Capacity    = capacity,
                Geometry    = geometry,
            };

            if (parameters != null)
            {
                foreach (var key in parameters.Keys)
                {
                    diskParams.ExtendedParameters[key] = parameters[key];
                }
            }

            return(CreateDisk(type, variant, path, diskParams, user, password));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new virtual disk, possibly within an existing disk.
        /// </summary>
        /// <param name="fileSystem">The file system to create the disk on</param>
        /// <param name="type">The type of disk to create (see <see cref="SupportedDiskTypes"/>)</param>
        /// <param name="variant">The variant of the type to create (see <see cref="GetSupportedDiskVariants"/>)</param>
        /// <param name="path">The path (or URI) for the disk to create</param>
        /// <param name="capacity">The capacity of the new disk</param>
        /// <param name="geometry">The geometry of the new disk (or null).</param>
        /// <param name="parameters">Untyped parameters controlling the creation process (TBD)</param>
        /// <returns>The newly created disk</returns>
        public static VirtualDisk CreateDisk(DiscFileSystem fileSystem, string type, string variant, string path, long capacity, Geometry geometry, Dictionary <string, string> parameters)
        {
            VirtualDiskFactory factory = TypeMap[type];

            VirtualDiskParameters diskParams = new VirtualDiskParameters()
            {
                AdapterType = GenericDiskAdapterType.Scsi,
                Capacity    = capacity,
                Geometry    = geometry,
            };

            if (parameters != null)
            {
                foreach (var key in parameters.Keys)
                {
                    diskParams.ExtendedParameters[key] = parameters[key];
                }
            }

            return(factory.CreateDisk(new DiscFileLocator(fileSystem, Utilities.GetDirectoryFromPath(path)), variant.ToLowerInvariant(), Utilities.GetFileFromPath(path), diskParams));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a new virtual disk.
        /// </summary>
        /// <param name="type">The type of disk to create (see <see cref="SupportedDiskTypes"/>)</param>
        /// <param name="variant">The variant of the type to create (see <see cref="GetSupportedDiskVariants"/>)</param>
        /// <param name="path">The path (or URI) for the disk to create</param>
        /// <param name="diskParameters">Parameters controlling the capacity, geometry, etc of the new disk.</param>
        /// <param name="user">The user identity to use when accessing the <c>path</c> (or null)</param>
        /// <param name="password">The password to use when accessing the <c>path</c> (or null)</param>
        /// <returns>The newly created disk</returns>
        public static VirtualDisk CreateDisk(string type, string variant, string path, VirtualDiskParameters diskParameters, string user, string password)
        {
            Uri uri = PathToUri(path);
            VirtualDisk result = null;

            Type transportType;
            if (!DiskTransports.TryGetValue(uri.Scheme.ToUpperInvariant(), out transportType))
            {
                throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, "Unable to parse path '{0}'", path), path);
            }

            VirtualDiskTransport transport = (VirtualDiskTransport)Activator.CreateInstance(transportType);

            try
            {
                transport.Connect(uri, user, password);

                if (transport.IsRawDisk)
                {
                    result = transport.OpenDisk(FileAccess.ReadWrite);
                }
                else
                {
                    VirtualDiskFactory factory = TypeMap[type];

                    result = factory.CreateDisk(transport.GetFileLocator(), variant.ToLowerInvariant(), Utilities.GetFileFromPath(path), diskParameters);
                }

                if (result != null)
                {
                    result._transport = transport;
                    transport = null;
                }

                return result;
            }
            finally
            {
                if (transport != null)
                {
                    transport.Dispose();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a new virtual disk.
        /// </summary>
        /// <param name="type">The type of disk to create (see <see cref="SupportedDiskTypes"/>)</param>
        /// <param name="variant">The variant of the type to create (see <see cref="GetSupportedDiskVariants"/>)</param>
        /// <param name="path">The path (or URI) for the disk to create</param>
        /// <param name="capacity">The capacity of the new disk</param>
        /// <param name="geometry">The geometry of the new disk (or null).</param>
        /// <param name="user">The user identity to use when accessing the <c>path</c> (or null)</param>
        /// <param name="password">The password to use when accessing the <c>path</c> (or null)</param>
        /// <param name="parameters">Untyped parameters controlling the creation process (TBD)</param>
        /// <returns>The newly created disk</returns>
        public static VirtualDisk CreateDisk(string type, string variant, string path, long capacity, Geometry geometry, string user, string password, Dictionary<string, string> parameters)
        {
            VirtualDiskParameters diskParams = new VirtualDiskParameters()
            {
                AdapterType = GenericDiskAdapterType.Scsi,
                Capacity = capacity,
                Geometry = geometry,
            };

            if (parameters != null)
            {
                foreach (var key in parameters.Keys)
                {
                    diskParams.ExtendedParameters[key] = parameters[key];
                }
            }

            return CreateDisk(type, variant, path, diskParams, user, password);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create a new virtual disk, possibly within an existing disk.
        /// </summary>
        /// <param name="fileSystem">The file system to create the disk on</param>
        /// <param name="type">The type of disk to create (see <see cref="SupportedDiskTypes"/>)</param>
        /// <param name="variant">The variant of the type to create (see <see cref="GetSupportedDiskVariants"/>)</param>
        /// <param name="path">The path (or URI) for the disk to create</param>
        /// <param name="capacity">The capacity of the new disk</param>
        /// <param name="geometry">The geometry of the new disk (or null).</param>
        /// <param name="parameters">Untyped parameters controlling the creation process (TBD)</param>
        /// <returns>The newly created disk</returns>
        public static VirtualDisk CreateDisk(DiscFileSystem fileSystem, string type, string variant, string path, long capacity, Geometry geometry, Dictionary<string, string> parameters)
        {
            VirtualDiskFactory factory = TypeMap[type];

            VirtualDiskParameters diskParams = new VirtualDiskParameters()
            {
                AdapterType = GenericDiskAdapterType.Scsi,
                Capacity = capacity,
                Geometry = geometry,
            };

            if (parameters != null)
            {
                foreach (var key in parameters.Keys)
                {
                    diskParams.ExtendedParameters[key] = parameters[key];
                }
            }

            return factory.CreateDisk(new DiscFileLocator(fileSystem, Utilities.GetDirectoryFromPath(path)), variant.ToLowerInvariant(), Utilities.GetFileFromPath(path), diskParams);
        }
 public abstract VirtualDisk CreateDisk(FileLocator locator, string variant, string path, VirtualDiskParameters diskParameters);
Exemplo n.º 7
0
        /// <summary>
        /// Create a new virtual disk.
        /// </summary>
        /// <param name="type">The type of disk to create (see <see cref="SupportedDiskTypes"/>)</param>
        /// <param name="variant">The variant of the type to create (see <see cref="GetSupportedDiskVariants"/>)</param>
        /// <param name="path">The path (or URI) for the disk to create</param>
        /// <param name="diskParameters">Parameters controlling the capacity, geometry, etc of the new disk.</param>
        /// <param name="user">The user identity to use when accessing the <c>path</c> (or null)</param>
        /// <param name="password">The password to use when accessing the <c>path</c> (or null)</param>
        /// <returns>The newly created disk</returns>
        public static VirtualDisk CreateDisk(string type, string variant, string path, VirtualDiskParameters diskParameters, string user, string password)
        {
            Uri         uri    = PathToUri(path);
            VirtualDisk result = null;

            Type transportType;

            if (!DiskTransports.TryGetValue(uri.Scheme.ToUpperInvariant(), out transportType))
            {
                throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, "Unable to parse path '{0}'", path), path);
            }

            VirtualDiskTransport transport = (VirtualDiskTransport)Activator.CreateInstance(transportType);

            try
            {
                transport.Connect(uri, user, password);

                if (transport.IsRawDisk)
                {
                    result = transport.OpenDisk(FileAccess.ReadWrite);
                }
                else
                {
                    VirtualDiskFactory factory = TypeMap[type];

                    result = factory.CreateDisk(transport.GetFileLocator(), variant.ToLowerInvariant(), Utilities.GetFileFromPath(path), diskParameters);
                }

                if (result != null)
                {
                    result._transport = transport;
                    transport         = null;
                }

                return(result);
            }
            finally
            {
                if (transport != null)
                {
                    transport.Dispose();
                }
            }
        }
Exemplo n.º 8
0
 public abstract VirtualDisk CreateDisk(FileLocator locator, string variant, string path, VirtualDiskParameters diskParameters);