Beispiel #1
0
        /// <summary>
        /// Inserts an ISO file as the DVD/CD for a virtual machine, ejecting any
        /// existing disc.
        /// </summary>
        /// <param name="machineName">The machine name.</param>
        /// <param name="isoPath">Path to the ISO file.</param>
        public void InsertVmDvd(string machineName, string isoPath)
        {
            if (isAdmin)
            {
                hypervClient.InsertVmDvd(machineName: machineName, isoPath: isoPath);
            }
            else
            {
                var request = new GrpcInsertVmDvdRequest(machineName: machineName, isoPath: isoPath);
                var reply   = desktopService.InsertVmDvdAsync(request).Result;

                reply.Error.EnsureSuccess();
            }
        }
Beispiel #2
0
        /// <inheritdoc/>
        public async Task <GrpcBaseReply> InsertVmDvdAsync(GrpcInsertVmDvdRequest request, CallContext context = default)
        {
            await SyncContext.Clear;

            try
            {
                hyperv.InsertVmDvd(machineName: request.MachineName, isoPath: request.IsoPath);

                return(new GrpcBaseReply());
            }
            catch (Exception e)
            {
                return(new GrpcBaseReply(e));
            }
        }