Exemple #1
0
 public CommandLineOptionsValidator(CommandLineOptions commandLineOptions,
                                    RuntimeTokenParams runtimeTokenParams, VolumeOwnersStore volumeOwnersStore)
 {
     _commandLineOptions = commandLineOptions;
     _runtimeTokenParams = runtimeTokenParams;
     _volumeOwnersStore  = volumeOwnersStore;
 }
Exemple #2
0
 public LogMessageBuilder(RuntimeTokenParams runtimeTokenParams,
                          VolumeOwnersStore volumeOwnersStore,
                          VolumeAttributesStore volumeAttributesStore)
 {
     _runtimeTokenParams = runtimeTokenParams ??
                           throw new ArgumentNullException(nameof(runtimeTokenParams), Resources.TokenParamsNotSet);
     _volumeOwnersStore = volumeOwnersStore ??
                          throw new ArgumentNullException(nameof(volumeOwnersStore), Resources.VolumeOwnersStoreNotSet);
     _volumeAttributesStore = volumeAttributesStore ??
                              throw new ArgumentNullException(nameof(volumeAttributesStore), Resources.VolumeAttributesStoreNotSet);
 }
        public CommandHandlerBuilder(ILogger <RtAdmin> logger, RuntimeTokenParams runtimeTokenParams,
                                     PinsStorage pinsStorage, VolumeOwnersStore volumeOwnersStore, VolumeAttributesStore volumeAttributesStore,
                                     LogMessageBuilder logMessageBuilder)
        {
            _logger                = logger;
            _runtimeTokenParams    = runtimeTokenParams;
            _pinsStorage           = pinsStorage;
            _volumeOwnersStore     = volumeOwnersStore;
            _volumeAttributesStore = volumeAttributesStore;
            _logMessageBuilder     = logMessageBuilder;

            _commands      = new ConcurrentQueue <Action>();
            _prerequisites = new ConcurrentQueue <Action>();
        }
        public static IEnumerable <VolumeInfo> Create(
            VolumeOwnersStore volumeOwnersStore,
            VolumeAttributesStore volumeAttributesStore,
            IEnumerable <string> formatParams)
        {
            var formatParamsList = formatParams.ToList();

            if (formatParamsList.Count % _volumeParamsCount != 0)
            {
                throw new ArgumentException(Resources.FormatDriveInvalidCommandParamsCount);
            }

            for (var i = 0; i < formatParamsList.Count; i += _volumeParamsCount)
            {
                var volumeParams = formatParamsList.Skip(i).Take(_volumeParamsCount).ToList();

                if (!(uint.TryParse(volumeParams[0], out var volumeId)))
                {
                    throw new ArgumentException(Resources.VolumeInfoInvalidVolumeId);
                }

                if (!(uint.TryParse(volumeParams[1], out var volumeSize)))
                {
                    throw new ArgumentException(Resources.FormatDriveInvalidVolumeSize);
                }

                if (!volumeOwnersStore.TryGetOwnerId(volumeParams[2], out var owner))
                {
                    throw new ArgumentException(Resources.NewLocalPinInvalidOwnerId);
                }

                if (!volumeAttributesStore.TryGetAccessMode(volumeParams[3], out var accessMode))
                {
                    throw new ArgumentException(Resources.FormatDriveInvalidAccessMode);
                }

                yield return(new VolumeInfo
                {
                    Id = volumeId,
                    Size = volumeSize,
                    AccessMode = accessMode,
                    Owner = owner
                });
            }
        }