public async Task <string> GetDiskUuidAsync(string filePath) { if (!_fileSystem.FileExists(filePath)) { throw new ArgumentException("File does not exist: " + filePath); } var result = await _runner.RunAsync(_config.VirtualBoxManagerApp, $"showhdinfo \"{filePath}\""); if (result.StandardOutput == null) { return(null); } var uuidLine = result.StandardOutput.First(line => line.StartsWith(UuidIdentifier)); if (uuidLine == null) { return(null); } var uuid = uuidLine.Replace(UuidIdentifier, string.Empty).Trim(); return(uuid); }
public async Task <IEnumerable <string> > GetDiskPathsAsync(string machineName) { var args = $"showvminfo {machineName} --machinereadable"; var result = await _runner.RunAsync(_config.VirtualBoxManagerApp, args); if (result == null || result.StandardOutput == null) { return(new string[] { }); } var pathLines = result.StandardOutput.Where(l => { var lower = l.ToLower(); bool isDiskPath = lower.Contains(".vmdk") || lower.Contains(".vhd"); return(isDiskPath && l.Contains("IDE Controller")); }); var pathes = pathLines.Select(l => l.Split('=')[1].Trim('"', ' ', '\t', '\r')); return(pathes); }