public Task Handle(AcceptedOperation <ConvergeVirtualMachineCommand> message)
        {
            var command = message.Command;
            var config  = command.Config;

            _operationId = command.OperationId;

            var chain =
                from normalizedVMConfig in Converge.NormalizeMachineConfig(config, _engine, ProgressMessage)
                from vmList in GetVmInfo(normalizedVMConfig.Id, _engine)
                from optionalVmInfo in EnsureUnique(vmList, normalizedVMConfig.Id)
                from storageSettings in DetectStorageSettings(optionalVmInfo)
                from vmConfig in ApplyStorageSettings(normalizedVMConfig, storageSettings, GetHostSettings())
                from vmInfoCreated in EnsureCreated(optionalVmInfo, vmConfig, storageSettings, _engine)
                from vmInfo in EnsureNameConsistent(vmInfoCreated, vmConfig, _engine)
                from _ in AttachToOperation(vmInfo, _bus, command.OperationId)
                from vmInfoConverged in ConvergeVm(vmInfo, vmConfig, storageSettings, _engine)
                select vmInfoConverged;

            return(chain.ToAsync().MatchAsync(
                       LeftAsync: HandleError,
                       RightAsync: vmInfo2 => _bus.Send(new OperationCompletedEvent
            {
                OperationId = command.OperationId,
            }).ToUnit()));
        }
        public Task Handle(AcceptedOperationTask <ConvergeVirtualMachineCommand> message)
        {
            var command = message.Command;
            var config  = command.Config;

            _operationId = command.OperationId;
            _taskId      = command.TaskId;

            var hostSettings = GetHostSettings();

            var chain =

                from normalizedVMConfig in Converge.NormalizeMachineConfig(config, _engine, ProgressMessage)
                from vmList in GetVmInfo(normalizedVMConfig.Id, _engine)
                from optionalVmInfo in EnsureUnique(vmList, normalizedVMConfig.Id)

                from currentStorageSettings in Storage.DetectVMStorageSettings(optionalVmInfo, hostSettings, ProgressMessage)
                from plannedStorageSettings in Storage.PlanVMStorageSettings(normalizedVMConfig, currentStorageSettings, hostSettings, GenerateId)

                from vmInfoCreated in EnsureCreated(optionalVmInfo, config, plannedStorageSettings, _engine)
                from _ in AttachToOperation(vmInfoCreated, _bus, command.OperationId)
                from vmInfo in EnsureNameConsistent(vmInfoCreated, config, _engine)

                from vmInfoConverged in ConvergeVm(vmInfo, config, plannedStorageSettings, hostSettings, _engine)
                select vmInfoConverged;

            return(chain.ToAsync().MatchAsync(
                       LeftAsync: HandleError,
                       RightAsync: async vmInfo2 =>
            {
                await ProgressMessage($"Virtual machine '{vmInfo2.Value.Name}' has been converged.").ConfigureAwait(false);

                return await _bus.Publish(OperationTaskStatusEvent.Completed(_operationId, _taskId))
                .ToUnit().ConfigureAwait(false);
            }));
        }