示例#1
0
        public VirtualMachine Import(string filePath, string newMachineName)
        {
            if (string.IsNullOrWhiteSpace(newMachineName))
            {
                throw new ArgumentNullException(nameof(newMachineName));
            }
            if (!_fileSystem.FileExists(filePath))
            {
                throw new ArgumentException("File doesn't exist: " + filePath);
            }

            _runner.RunAndWait(
                _config.VirtualBoxManagerApp,
                $"import \"{filePath}\" --vsys 0 --vmname {newMachineName}");

            var vm = _vmFactory.CreateFromName(newMachineName);

            return(vm);
        }