protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _translation = new CommandLineEnumSwitch <GeometryTranslation>("t", "translation", "mode", GeometryTranslation.Auto, "Indicates the geometry adjustment to apply.  Set this parameter to match the translation configured in the BIOS of the machine that will boot from the disk - auto should work in most cases for modern BIOS.");
            _volumes     = new CommandLineMultiParameter("volume", "Volumes to clone.  The volumes should all be on the same disk.", false);
            _destDisk    = new CommandLineParameter("out_file", "Path to the output disk image.", false);

            parser.AddSwitch(_translation);
            parser.AddMultiParameter(_volumes);
            parser.AddParameter(_destDisk);

            return(StandardSwitches.OutputFormatAndAdapterType);
        }
Beispiel #2
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _inFile      = FileOrUriParameter("in_file", "Path to the source disk.", false);
            _outFile     = FileOrUriParameter("out_file", "Path to the output disk.", false);
            _translation = new CommandLineEnumSwitch <GeometryTranslation>("t", "translation", "mode", GeometryTranslation.None, "Indicates the geometry adjustment to apply for bootable disks.  Set this parameter to match the translation configured in the BIOS of the machine that will boot from the disk - auto should work in most cases for modern BIOS.");
            _wipe        = new CommandLineSwitch("w", "wipe", null, "Write zero's to all unused parts of the disk.  This option only makes sense when converting to an iSCSI LUN which may be dirty.");

            parser.AddParameter(_inFile);
            parser.AddParameter(_outFile);
            parser.AddSwitch(_translation);
            parser.AddSwitch(_wipe);

            return(StandardSwitches.OutputFormatAndAdapterType | StandardSwitches.UserAndPassword);
        }
Beispiel #3
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _inFile = FileOrUriParameter("in_file", "Path to the source disk.", false);
            _outFile = FileOrUriParameter("out_file", "Path to the output disk.", false);
            _translation = new CommandLineEnumSwitch<GeometryTranslation>("t", "translation", "mode", GeometryTranslation.None, "Indicates the geometry adjustment to apply for bootable disks.  Set this parameter to match the translation configured in the BIOS of the machine that will boot from the disk - auto should work in most cases for modern BIOS.");
            _wipe = new CommandLineSwitch("w", "wipe", null, "Write zero's to all unused parts of the disk.  This option only makes sense when converting to an iSCSI LUN which may be dirty.");

            parser.AddParameter(_inFile);
            parser.AddParameter(_outFile);
            parser.AddSwitch(_translation);
            parser.AddSwitch(_wipe);

            return StandardSwitches.OutputFormatAndAdapterType | StandardSwitches.UserAndPassword;
        }
Beispiel #4
0
        protected override StandardSwitches DefineCommandLine(CommandLineParser parser)
        {
            _translation = new CommandLineEnumSwitch<GeometryTranslation>("t", "translation", "mode", GeometryTranslation.Auto,"Indicates the geometry adjustment to apply.  Set this parameter to match the translation configured in the BIOS of the machine that will boot from the disk - auto should work in most cases for modern BIOS.");
            _volumes = new CommandLineMultiParameter("volume", "Volumes to clone.  The volumes should all be on the same disk.", false);
            _destDisk = new CommandLineParameter("out_file", "Path to the output disk image.", false);

            parser.AddSwitch(_translation);
            parser.AddMultiParameter(_volumes);
            parser.AddParameter(_destDisk);

            return StandardSwitches.OutputFormatAndAdapterType;
        }
        protected void Run(string[] args)
        {
            _parser = new CommandLineParser(ExeName);

            StandardSwitches stdSwitches = DefineCommandLine(_parser);

            if ((stdSwitches & StandardSwitches.OutputFormatAndAdapterType) != 0)
            {
                _outFormatSwitch = OutputFormatSwitch();
                _adapterTypeSwitch = new CommandLineEnumSwitch<GenericDiskAdapterType>("a", "adaptortype", "type", GenericDiskAdapterType.Ide, "Some disk formats encode the disk type (IDE or SCSI) into the disk image, this parameter specifies the type of adaptor to encode.");

                _parser.AddSwitch(_outFormatSwitch);
                _parser.AddSwitch(_adapterTypeSwitch);
            }

            if ((stdSwitches & StandardSwitches.DiskSize) != 0)
            {
                _diskSizeSwitch = new CommandLineSwitch("sz", "size", "size", "The size of the output disk.  Use B, KB, MB, GB to specify units (units default to bytes if not specified).");
                _parser.AddSwitch(_diskSizeSwitch);
            }

            if ((stdSwitches & StandardSwitches.FileNameEncoding) != 0)
            {
                _filenameEncodingSwitch = new CommandLineSwitch(new string[]{"ne"}, "nameencoding", "encoding", "The encoding used for filenames in the file system (aka the codepage), e.g. UTF-8 or IBM437.  This is ignored for file systems have fixed/defined encodings.");
                _parser.AddSwitch(_filenameEncodingSwitch);
            }

            if ((stdSwitches & StandardSwitches.PartitionOrVolume) != 0)
            {
                _partitionSwitch = new CommandLineSwitch("p", "partition", "num", "The number of the partition to inspect, in the range 0-n.  If not specified, 0 (the first partition) is the default.");
                _volumeIdSwitch = new CommandLineSwitch("v", "volume", "id", "The volume id of the volume to access, use the VolInfo tool to discover this id.  If specified, the partition parameter is ignored.");

                _parser.AddSwitch(_partitionSwitch);
                _parser.AddSwitch(_volumeIdSwitch);
            }

            if ((stdSwitches & StandardSwitches.UserAndPassword) != 0)
            {
                _userNameSwitch = new CommandLineSwitch("u", "user", "user_name", "If using an iSCSI source or target, optionally use this parameter to specify the user name to authenticate with.  If this parameter is specified without a password, you will be prompted to supply the password.");
                _parser.AddSwitch(_userNameSwitch);
                _passwordSwitch = new CommandLineSwitch("pw", "password", "secret", "If using an iSCSI source or target, optionally use this parameter to specify the password to authenticate with.");
                _parser.AddSwitch(_passwordSwitch);
            }

            if ((stdSwitches & StandardSwitches.Verbose) != 0)
            {
                _verboseSwitch = new CommandLineSwitch("v", "verbose", null, "Show detailed information.");
                _parser.AddSwitch(_verboseSwitch);
            }

            _helpSwitch = new CommandLineSwitch(new string[] { "h", "?" }, "help", null, "Show this help.");
            _parser.AddSwitch(_helpSwitch);
            _quietSwitch = new CommandLineSwitch("q", "quiet", null, "Run quietly.");
            _parser.AddSwitch(_quietSwitch);
            _timeSwitch = new CommandLineSwitch("time", null, "Times how long this program takes to execute.");
            _parser.AddSwitch(_timeSwitch);

            bool parseResult = _parser.Parse(args);

            if (!_quietSwitch.IsPresent)
            {
                DisplayHeader();
            }

            if (_helpSwitch.IsPresent || !parseResult)
            {
                DisplayHelp();
                return;
            }

            if ((stdSwitches & StandardSwitches.OutputFormatAndAdapterType) != 0)
            {
                if (_outFormatSwitch.IsPresent)
                {
                    string[] typeAndVariant = _outFormatSwitch.Value.Split(new char[] { '-' }, 2);
                    _outputDiskType = typeAndVariant[0];
                    _outputDiskVariant = (typeAndVariant.Length > 1) ? typeAndVariant[1] : "";
                }
                else
                {
                    DisplayHelp();
                    return;
                }

                if (_adapterTypeSwitch.IsPresent)
                {
                    _adapterType = _adapterTypeSwitch.EnumValue;
                }
                else
                {
                    _adapterType = GenericDiskAdapterType.Ide;
                }
            }

            if ((stdSwitches & StandardSwitches.DiskSize) != 0)
            {
                if (_diskSizeSwitch.IsPresent && !Utilities.TryParseDiskSize(_diskSizeSwitch.Value, out _diskSize))
                {
                    DisplayHelp();
                    return;
                }
            }

            if ((stdSwitches & StandardSwitches.PartitionOrVolume) != 0)
            {
                _partition = -1;
                if (_partitionSwitch.IsPresent && !int.TryParse(_partitionSwitch.Value, out _partition))
                {
                    DisplayHelp();
                    return;
                }

                _volumeId = _volumeIdSwitch.IsPresent ? _volumeIdSwitch.Value : null;
            }

            if ((stdSwitches & StandardSwitches.UserAndPassword) != 0)
            {
                _userName = null;

                if (_userNameSwitch.IsPresent)
                {
                    _userName = _userNameSwitch.Value;

                    if (_passwordSwitch.IsPresent)
                    {
                        _password = _passwordSwitch.Value;
                    }
                    else
                    {
                        _password = Utilities.PromptForPassword();
                    }
                }
            }

            if (_timeSwitch.IsPresent)
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();
                DoRun();
                stopWatch.Stop();

                Console.WriteLine();
                Console.WriteLine("Time taken: {0}", stopWatch.Elapsed);
            }
            else
            {
                DoRun();
            }
        }