Пример #1
0
        public CreateConfiguration ConvertGenericCreationOption(ConfigType type, Options.ICreateOptions option)
        {
            ConfigGetGlobalOptions(option);
            CreateConfiguration config = new CreateConfiguration(type, CommandApi.Create);

            if (!string.IsNullOrEmpty(option.FileConf))
            {
                try
                {
                    config = this.ReadConfigurationFile <CreateConfiguration>(option.FileConf, type, CommandApi.Create);
                }
                catch (System.IO.FileNotFoundException ex)
                {
                    CLILogs.Error(ex.Message);
                }
            }

            GetDefaultOptions(config, option);
            ConfigPrintInformation(option, type, "create");

            config.Name                = option.Name ?? config.Name;
            config.Shortname           = option.Shortname ?? config.Shortname;
            config.Range               = option.Range ?? config.Range;
            config.Profile             = option.Profile ?? config.Profile;
            config.Tags                = option.Tags?.ToList().Count > 0 ? option.Tags?.ToList() : config.Tags;
            config.Constants           = option.Constants?.ToList().Count > 0 ? option.Constants?.ToList() : config.Constants;
            config.Constraints         = option.Constraints?.ToList().Count > 0 ? option.Constraints?.ToList() : config.Constraints;
            config.Labels              = (option.Labels?.Any() ?? false) ? option.Labels.ToList() : config.Labels;
            config.Resources           = option.Resources?.ToList().Count > 0 ? option.Resources?.ToList() : config.Resources;
            config.InstanceCount       = option.InstanceCount > 0 ? option.InstanceCount : config.InstanceCount;
            config.JobUuidOrShortname  = option.Job ?? config.JobUuidOrShortname;
            config.PoolUuidOrShortname = option.Pool ?? config.PoolUuidOrShortname;
            config.IsElastic           = option.IsElastic ? option.IsElastic : config.IsElastic;
            config.IsDependents        = option.IsDependents ? option.IsDependents : config.IsDependents;
            config.Result              = option.Result ?? config.Result;
            config.Dependents          = option.Dependents?.ToList().Count > 0 ? option.Dependents?.ToList() : config.Dependents;
            Options.IElasticityOptions elasticOption = option as Options.IElasticityOptions;
            var MaximumWallTime = string.IsNullOrEmpty(option.MaximumWallTime) ? config.MaximumWallTime : (TimeSpan?)ParseTimeSpanString(option.MaximumWallTime);

            config.MaximumWallTime = MaximumWallTime == default(TimeSpan) ? null : MaximumWallTime;
            config.TasksDefaultWaitForPoolResourcesSynchronization = option.TasksDefaultWaitForPoolResourcesSynchronization ?? config.TasksDefaultWaitForPoolResourcesSynchronization;
            config.MaxRetriesPerInstance = option.MaxRetriesPerInstance ?? config.MaxRetriesPerInstance;
            config.WaitForPoolResourcesSynchronization = option.WaitForPoolResourcesSynchronization ?? config.WaitForPoolResourcesSynchronization;
            config.DefaultResourcesCacheTTLSec         = option.DefaultResourcesCacheTTLSec ?? config.DefaultResourcesCacheTTLSec;
            if (elasticOption != null)
            {
                config.ElasticMinimumTotalSlots  = elasticOption.ElasticMinimumTotalSlots;
                config.ElasticMaximumTotalSlots  = elasticOption.ElasticMaximumTotalSlots;
                config.ElasticMinimumIdlingSlots = elasticOption.ElasticMinimumIdlingSlots;
                config.ElasticResizePeriod       = elasticOption.ElasticResizePeriod;
                config.ElasticResizeFactor       = elasticOption.ElasticResizeFactor;
                config.ElasticMinimumIdlingTime  = elasticOption.ElasticMinimumIdlingTime;
            }

            Options.IPrivilegesOptions privilegesOption = option as Options.IPrivilegesOptions;
            if (privilegesOption != null)
            {
                ConvertPrivilegesOption(config, privilegesOption);
            }

            return(config);
        }
Пример #2
0
 public IPrivilegesConfiguration ConvertPrivilegesOption(IPrivilegesConfiguration config, Options.IPrivilegesOptions option)
 {
     config.ExportApiAndStorageCredentialsInEnvironment = option.ExportApiAndStorageCredentialsInEnvironment ?? config.ExportApiAndStorageCredentialsInEnvironment;
     return(config);
 }