/// <summary> /// Creates a new virtual drive and adds it to a virtual machine. /// </summary> /// <param name="machineName">The target virtual machine name.</param> /// <param name="drive">The new drive information.</param> public void AddVmDrive(string machineName, VirtualDrive drive) { if (isAdmin) { hypervClient.AddVmDrive(machineName: machineName, drive: drive); } else { var request = new GrpcAddVmDriveRequest(machineName: machineName, drive: drive.ToProto()); var reply = desktopService.AddVmDriveAsync(request).Result; reply.Error.EnsureSuccess(); } }
/// <inheritdoc/> public async Task <GrpcBaseReply> AddVmDriveAsync(GrpcAddVmDriveRequest request, CallContext context = default) { await SyncContext.Clear; try { hyperv.AddVmDrive( machineName: request.MachineName, drive: request.Drive.ToLocal()); return(new GrpcBaseReply()); } catch (Exception e) { return(new GrpcBaseReply(e)); } }