private async Task <QTask> CreateRangeTaskAsync(CreateConfiguration config, QarnotSDK.Connection connect, CancellationToken ct = default(CancellationToken)) { AdvancedRanges range = new AdvancedRanges(config.Range); if (!string.IsNullOrEmpty(config.JobUuidOrShortname)) { QarnotSDK.QJob job; if (Guid.TryParse(config.JobUuidOrShortname, out var jobUuid)) { job = await connect.RetrieveJobByUuidAsync(config.JobUuidOrShortname, ct); } else { job = await connect.RetrieveJobByShortnameAsync(config.JobUuidOrShortname, ct); } return(new QarnotSDK.QTask(connect, config.Name, job, range, config.Shortname)); } else if (!string.IsNullOrEmpty(config.PoolUuidOrShortname)) { QarnotSDK.QPool pool; if (Guid.TryParse(config.PoolUuidOrShortname, out var poolUuid)) { pool = new QarnotSDK.QPool(connect, poolUuid); } else { pool = await connect.RetrievePoolByShortnameAsync(config.PoolUuidOrShortname, ct); } return(new QarnotSDK.QTask(connect, config.Name, pool, range, config.Shortname, config.WaitForPoolResourcesSynchronization)); } return(new QarnotSDK.QTask(connect, config.Name, config.Profile, range, config.Shortname)); }
private QPool CreatePool(CreateConfiguration config, QarnotSDK.Connection connect, CancellationToken ct) { QarnotSDK.QPool pool = new QarnotSDK.QPool(connect, config.Name, config.Profile, config.InstanceCount, config.Shortname, config.TasksDefaultWaitForPoolResourcesSynchronization); pool.SetTags(config.Tags.ToArray()); pool.Resources = this.Tools.CreateResources(config.Resources, connect, ct); foreach (var item in this.Tools.CreateConstants(config.Constants)) { pool.SetConstant(item.Key, item.Value); } foreach (var item in this.Tools.CreateConstraints(config.Constraints)) { pool.SetConstraint(item.Key, item.Value); } foreach (var item in this.Tools.CreateLabels(config.Labels)) { pool.SetLabel(item.Key, item.Value); } pool.IsElastic = config.IsElastic; pool.ElasticMinimumTotalNodes = config.ElasticMinimumTotalNodes == default(int) ? pool.ElasticMinimumTotalNodes : config.ElasticMinimumTotalNodes; pool.ElasticMaximumTotalNodes = config.ElasticMaximumTotalNodes == default(int) ? pool.ElasticMaximumTotalNodes : config.ElasticMaximumTotalNodes; pool.ElasticMinimumIdlingNodes = config.ElasticMinimumIdlingNodes == default(int) ? pool.ElasticMinimumIdlingNodes : config.ElasticMinimumIdlingNodes; pool.ElasticResizePeriod = config.ElasticResizePeriod == default(int) ? pool.ElasticResizePeriod : config.ElasticResizePeriod; pool.ElasticResizeFactor = config.ElasticResizeFactor == default(int) ? pool.ElasticResizeFactor : config.ElasticResizeFactor; pool.ElasticMinimumIdlingTime = config.ElasticMinimumIdlingTime == default(int) ? pool.ElasticMinimumIdlingTime : config.ElasticMinimumIdlingTime; CLILogs.Info("create pool"); return(pool); }
public async override Task <CommandValues.GenericInfoCommandValue> Create(IConfiguration iconfig, QarnotSDK.Connection connect, CancellationToken ct) { CreateConfiguration config = iconfig as CreateConfiguration; QJob job = await this.CreateJobAsync(config, connect, ct); await this.LaunchJobAsync(job, ct); return(this.PrintJobInformation(job)); }
public async override Task <CommandValues.GenericInfoCommandValue> Create(IConfiguration iconfig, QarnotSDK.Connection connect, CancellationToken ct) { CreateConfiguration config = iconfig as CreateConfiguration; QarnotSDK.QPool pool = this.CreatePool(config, connect, ct); await this.LaunchPoolAsync(pool, ct); return(this.PrintPoolInformation(pool)); }
public async override Task <CommandValues.GenericInfoCommandValue> Create(IConfiguration iconfig, QarnotSDK.Connection connect, CancellationToken ct) { CreateConfiguration config = iconfig as CreateConfiguration; QTask task = await this.CreateTask(config, connect, ct); await this.LaunchTaskAsync(task, ct); await this.LaunchPostSubmitTaskMethodsAsync(task, config, ct); return(this.PrintTaskInformation(task)); }
private async Task <QTask> LaunchPostSubmitTaskMethodsAsync(QTask task, CreateConfiguration config, CancellationToken ct) { if (config.SnapshotPeriodicSec > 0) { task.SnapshotWhitelist = config.Whitelist; task.SnapshotBlacklist = config.Blacklist; await task.SnapshotPeriodicAsync(config.SnapshotPeriodicSec, cancellationToken : ct); } return(task); }
private async Task <QTask> CreateTask(CreateConfiguration config, QarnotSDK.Connection connect, CancellationToken ct) { QarnotSDK.QTask task = null; if (config.InstanceCount > 0) { task = await this.CreateInstanceTaskAsync(config, connect); } else { task = await this.CreateRangeTaskAsync(config, connect); } task.SetTags(config.Tags.ToArray()); task.Resources = this.Tools.CreateResources(config.Resources, connect, ct); task.Results = this.Tools.CreateResult(config.Result, connect, ct); this.Tools.CreateConstants(config.Constants).ToList().ForEach(item => task.SetConstant(item.Key, item.Value)); foreach (var item in this.Tools.CreateConstraints(config.Constraints)) { task.SetConstraint(item.Key, item.Value); } foreach (var item in this.Tools.CreateLabels(config.Labels)) { task.SetLabel(item.Key, item.Value); } task.SetTaskDependencies(config.Dependents.Select(id => new Guid(id)).ToArray()); task.ResultsWhitelist = config.Whitelist; task.ResultsBlacklist = config.Blacklist; if (config.MaxRetriesPerInstance.HasValue) { task.MaxRetriesPerInstance = config.MaxRetriesPerInstance.Value; } if (config.ExportApiAndStorageCredentialsInEnvironment.HasValue) { task.Privileges.ExportApiAndStorageCredentialsInEnvironment = config.ExportApiAndStorageCredentialsInEnvironment.Value; } if (config.DefaultResourcesCacheTTLSec.HasValue) { task.DefaultResourcesCacheTTLSec = config.DefaultResourcesCacheTTLSec.Value; } CLILogs.Info("create task"); return(task); }
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.JobUuid = option.Job ?? config.JobUuid; config.PoolUuid = option.Pool ?? config.PoolUuid; 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.WaitForPoolResourcesSynchronization = option.WaitForPoolResourcesSynchronization ?? config.WaitForPoolResourcesSynchronization; if (elasticOption != null) { config.ElasticMinimumTotalNodes = elasticOption.ElasticMinimumTotalNodes; config.ElasticMaximumTotalNodes = elasticOption.ElasticMaximumTotalNodes; config.ElasticMinimumIdlingNodes = elasticOption.ElasticMinimumIdlingNodes; config.ElasticResizePeriod = elasticOption.ElasticResizePeriod; config.ElasticResizeFactor = elasticOption.ElasticResizeFactor; config.ElasticMinimumIdlingTime = elasticOption.ElasticMinimumIdlingTime; } return(config); }
public static bool CheckJob(IConfiguration config) { if (config is CreateConfiguration && ((CreateConfiguration)config).Type == ConfigType.Job) { CreateConfiguration createConfig = (CreateConfiguration)config; if (string.IsNullOrWhiteSpace(createConfig.Name)) { return(false); } } return(true); }
public static bool CheckPool(IConfiguration config) { if (config is CreateConfiguration && ((CreateConfiguration)config).Type == ConfigType.Pool) { CreateConfiguration createConfig = (CreateConfiguration)config; if (string.IsNullOrEmpty(createConfig.Name) || string.IsNullOrEmpty(createConfig.Profile) || (createConfig.InstanceCount == 0 && !createConfig.IsElastic)) { return(false); } } return(true); }
public static bool CheckTask(IConfiguration config) { if (config is CreateConfiguration && ((CreateConfiguration)config).Type == ConfigType.Task) { CreateConfiguration createConfig = (CreateConfiguration)config; if (string.IsNullOrEmpty(createConfig.Name) || (string.IsNullOrEmpty(createConfig.Profile) && string.IsNullOrEmpty(createConfig.PoolUuidOrShortname) && string.IsNullOrEmpty(createConfig.JobUuidOrShortname)) || (createConfig.InstanceCount == 0 && string.IsNullOrEmpty(createConfig.Range)) || (createConfig.InstanceCount != 0 && !string.IsNullOrEmpty(createConfig.Range))) { return(false); } } return(true); }
private async Task <QTask> CreateInstanceTaskAsync(CreateConfiguration config, QarnotSDK.Connection connect, CancellationToken ct = default(CancellationToken)) { if (!string.IsNullOrEmpty(config.JobUuid)) { QarnotSDK.QJob job = await connect.RetrieveJobByUuidAsync(config.JobUuid, ct); return(new QarnotSDK.QTask(connect, config.Name, job, config.InstanceCount, config.Shortname)); } else if (!string.IsNullOrEmpty(config.PoolUuid)) { QarnotSDK.QPool pool = new QarnotSDK.QPool(connect, new Guid(config.PoolUuid)); return(new QarnotSDK.QTask(connect, config.Name, pool, config.InstanceCount, config.Shortname, config.WaitForPoolResourcesSynchronization)); } return(new QarnotSDK.QTask(connect, config.Name, config.Profile, config.InstanceCount, config.Shortname)); }
private QPool CreatePool(CreateConfiguration config, QarnotSDK.Connection connect, CancellationToken ct) { QarnotSDK.QPool pool = new QarnotSDK.QPool(connect, config.Name, config.Profile, config.InstanceCount, config.Shortname, config.TasksDefaultWaitForPoolResourcesSynchronization); pool.SetTags(config.Tags.ToArray()); pool.Resources = this.Tools.CreateResources(config.Resources, connect, ct); foreach (var item in this.Tools.CreateConstants(config.Constants)) { pool.SetConstant(item.Key, item.Value); } foreach (var item in this.Tools.CreateConstraints(config.Constraints)) { pool.SetConstraint(item.Key, item.Value); } foreach (var item in this.Tools.CreateLabels(config.Labels)) { pool.SetLabel(item.Key, item.Value); } pool.IsElastic = config.IsElastic; pool.ElasticMinimumTotalSlots = config.ElasticMinimumTotalSlots == default(int) ? pool.ElasticMinimumTotalSlots : config.ElasticMinimumTotalSlots; pool.ElasticMaximumTotalSlots = config.ElasticMaximumTotalSlots == default(int) ? pool.ElasticMaximumTotalSlots : config.ElasticMaximumTotalSlots; pool.ElasticMinimumIdlingSlots = config.ElasticMinimumIdlingSlots == default(int) ? pool.ElasticMinimumIdlingSlots : config.ElasticMinimumIdlingSlots; pool.ElasticResizePeriod = config.ElasticResizePeriod == default(int) ? pool.ElasticResizePeriod : config.ElasticResizePeriod; pool.ElasticResizeFactor = config.ElasticResizeFactor == default(int) ? pool.ElasticResizeFactor : config.ElasticResizeFactor; pool.ElasticMinimumIdlingTime = config.ElasticMinimumIdlingTime == default(int) ? pool.ElasticMinimumIdlingTime : config.ElasticMinimumIdlingTime; if (config.ExportApiAndStorageCredentialsInEnvironment.HasValue) { pool.Privileges.ExportApiAndStorageCredentialsInEnvironment = config.ExportApiAndStorageCredentialsInEnvironment.Value; } if (config.DefaultResourcesCacheTTLSec.HasValue) { pool.DefaultResourcesCacheTTLSec = config.DefaultResourcesCacheTTLSec.Value; } CLILogs.Info("create pool"); return(pool); }
private async Task <QJob> CreateJobAsync(CreateConfiguration config, QarnotSDK.Connection connect, CancellationToken ct) { CLILogs.Info("create job"); QPool pool = null; if (!string.IsNullOrEmpty(config.PoolUuidOrShortname)) { pool = await connect.RetrievePoolByUuidAsync(config.PoolUuidOrShortname, ct); } QJob job = new QJob(connect, config.Name, pool, config.Shortname, config.IsDependents); if (config.MaximumWallTime.HasValue && config.MaximumWallTime.Value != default(TimeSpan)) { job.MaximumWallTime = config.MaximumWallTime.Value; } return(job); }
private async Task <QTask> CreateTask(CreateConfiguration config, QarnotSDK.Connection connect, CancellationToken ct) { QarnotSDK.QTask task = null; if (config.InstanceCount > 0) { task = await this.CreateInstanceTaskAsync(config, connect); } else { task = await this.CreateRangeTaskAsync(config, connect); } task.SetTags(config.Tags.ToArray()); task.Resources = this.Tools.CreateResources(config.Resources, connect, ct); task.Results = this.Tools.CreateResult(config.Result, connect, ct); this.Tools.CreateConstants(config.Constants).ToList().ForEach(item => task.SetConstant(item.Key, item.Value)); foreach (var item in this.Tools.CreateConstraints(config.Constraints)) { task.SetConstraint(item.Key, item.Value); } foreach (var item in this.Tools.CreateLabels(config.Labels)) { task.SetLabel(item.Key, item.Value); } task.SetTaskDependencies(config.Dependents.Select(id => new Guid(id)).ToArray()); task.ResultsWhitelist = config.Whitelist; task.ResultsBlacklist = config.Blacklist; CLILogs.Info("create task"); return(task); }