public async Task <List <QarnotSDK.QJob> > RetrieveAsync(IConfiguration configuration, QarnotSDK.Connection connection, CancellationToken ct) { DefaultRunConfiguration config = configuration as DefaultRunConfiguration; QarnotSDK.QJob job = null; List <QJob> listJob = null; if (!string.IsNullOrEmpty(config.Name)) { CLILogs.Debug("Retrieve QJobs by name : " + config.Name); QDataDetail <QJob> level = new QDataDetail <QJob>() { Filter = QFilter <QJob> .Eq(t => t.Name, config.Name), }; listJob = await connection.RetrieveJobsAsync(level, cancellationToken : ct); } else if (!string.IsNullOrEmpty(config.Id)) { CLILogs.Debug("Retrieve QJob by Uuid : " + config.Id); job = await connection.RetrieveJobByUuidAsync(config.Id, cancellationToken : ct); } else { CLILogs.Debug("Retrieve all the QJobs"); listJob = await connection.RetrieveJobsAsync(cancellationToken : ct); } return(listJob ?? new List <QJob>() { job }); }
public virtual Task <CommandValues.UserInformationCommandValue> ExecuteAsync(UserInformation apiSettings, IConfiguration iconfig, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("print Account info"); CommandValues.UserInformationCommandValue objToPrint = InfoObj.CreateObj(apiSettings) as CommandValues.UserInformationCommandValue; objToPrint.AccountInformation["Email"] = apiSettings.Email; objToPrint.AccountInformation["MaxInstances"] = apiSettings.MaxInstances.ToString(); objToPrint.AccountInformation["Quota Bucket Number"] = apiSettings.BucketCount.ToString() + "/" + apiSettings.MaxBucket.ToString(); if (iconfig.HumanReadable) { objToPrint.AccountInformation["Quota Bytes Bucket"] = BytesFormat.ConvertToHumanReadable(apiSettings.UsedQuotaBytesBucket) + "/" + BytesFormat.ConvertToHumanReadable(apiSettings.QuotaBytesBucket); } else { objToPrint.AccountInformation["Quota Bytes Bucket"] = apiSettings.UsedQuotaBytesBucket.ToString() + "/" + apiSettings.QuotaBytesBucket.ToString(); } objToPrint.AccountInformation["Quota Task Count"] = apiSettings.TaskCount.ToString() + "/" + apiSettings.MaxTask.ToString(); objToPrint.AccountInformation["Quota Running Task"] = apiSettings.RunningTaskCount.ToString() + "/" + apiSettings.MaxRunningTask.ToString(); objToPrint.AccountInformation["Quota Total Pool"] = apiSettings.PoolCount.ToString() + "/" + apiSettings.MaxPool.ToString(); objToPrint.AccountInformation["Quota Running Pool"] = apiSettings.RunningPoolCount.ToString() + "/" + apiSettings.MaxRunningPool.ToString(); objToPrint.AccountInformation["Quota Running Instances"] = apiSettings.RunningInstanceCount.ToString() + "/" + apiSettings.MaxInstances.ToString(); objToPrint.AccountInformation["Quota Running Cores"] = apiSettings.RunningCoreCount.ToString(); return(Task.FromResult(objToPrint)); }
public virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QBucket bucket, IConfiguration iconfig, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("Command Bucket : Upload"); BucketConfiguration config = iconfig as BucketConfiguration; List <Task> listOfTask = new List <Task>(); if (!config.ApiConnection.DisableBucketPathsSanitization && (PathSanitization.IsThePathInvalid(config.RemoteRelativePath))) { return(new CommandValues.GenericInfoCommandValue() { Uuid = bucket.Shortname, Message = "Upload failed. Invalid remote path", }); } if (!string.IsNullOrEmpty(config.String)) { CLILogs.Debug("Command Bucket : Upload String "); CLILogs.Debug(config.StringPath); await bucket.UploadStringAsync(config.String, config.StringPath, cancellationToken : ct); } listOfTask.AddRange(config.LocalPathFiles.Select(localFile => bucket.UploadFileAsync(localFile, config.RemoteRelativePath, cancellationToken: ct))); listOfTask.AddRange(config.LocalPathFolders.Select(localFolder => bucket.UploadFolderAsync(localFolder, config.RemoteRelativePath, cancellationToken: ct))); await Task.WhenAll(listOfTask); return(new CommandValues.GenericInfoCommandValue() { Uuid = bucket.Shortname, Message = "Bucket Upload", }); }
public virtual Task <T2> ExecuteAsync(T1 obj, IConfiguration iconfig = null, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("print list"); T2 objToPrint = ListObj.CreateObj(obj) as T2; return(Task.FromResult(objToPrint)); }
public Connection CreateConnection(IConfiguration config) { if (config == null) { throw new ArgumentNullException(); } string apiUri = config?.ApiConnection?.ApiUri == null ? "https://api.qarnot.com" : config?.ApiConnection?.ApiUri; HttpClientHandler client = getClientHandler(config); var enableSanitization = !(config?.ApiConnection?.DisableBucketPathsSanitization ?? false); if (enableSanitization) { CLILogs.Info("Bucket path sanitization is enabled (default). Use --no-sanitize-bucket-paths argument to disable."); } return(new Connection( apiUri, config?.ApiConnection?.StorageUri, config?.ApiConnection?.Token, client, forceStoragePathStyle: config?.ApiConnection?.ForcePathStyle ?? false, sanitizeBucketPaths: enableSanitization, showBucketWarnings: false) // the cli will display custom warnings { StorageAccessKey = config?.ApiConnection?.AccountEmail, S3HttpClientFactory = config?.ApiConnection?.StorageUnsafeSsl ?? false ? new UnsafeS3HttpClientFactory() : null }); }
public async Task <QarnotSDK.QBucket> RetrieveAsync(IConfiguration configuration, QarnotSDK.Connection connection, CancellationToken ct) { BucketConfiguration config = configuration as BucketConfiguration; CLILogs.Debug("Retrieve QBucket by Name : " + config.Name); return(await connection.RetrieveBucketAsync(config.Name, ct)); }
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); }
private void PrintInformationFiles(string path, APIConnectionInformation connectionInformation) { string lines = $"Configuration on the file '{path}'"; CLILogs.Info(lines); CLILogs.Info(connectionInformation.ToString()); }
public virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QBucket bucket, IConfiguration iconfig, CancellationToken ct = default(CancellationToken)) { BucketConfiguration config = iconfig as BucketConfiguration; if (bucket == default) { var message = "Removal failed. Bucket not found"; throw new System.Exception(message); } if (!config.ApiConnection.DisableBucketPathsSanitization && (config.RemoteRelativePaths.Any(remoteFile => PathSanitization.IsThePathInvalid(remoteFile)))) { var message = "Removal failed. Invalid remote path(s)"; throw new System.Exception(message); } CLILogs.Debug("Command Bucket : Remove entities " + string.Join(", ", config.RemoteRelativePaths)); string returnString = "Bucket delete paths : " + string.Join(", ", config.RemoteRelativePaths); await config.RemoteRelativePaths.ParallelForEachAsync(bucket.DeleteEntryAsync, 10, ct : ct); return(new CommandValues.GenericInfoCommandValue() { Uuid = bucket.Shortname, Message = returnString, }); }
public virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QPool pool, IConfiguration iconfig, CancellationToken ct = default(CancellationToken)) { PoolSetElasticSettingsConfiguration config = iconfig as PoolSetElasticSettingsConfiguration; CLILogs.Debug("Command pool : Pool name " + pool?.Name ?? config?.Name); CLILogs.Debug("Command pool : Set Pool Elastic info"); if (pool == default) { var message = "Elastic settings update failed. Pool not found"; throw new System.Exception(message); } 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; await pool.CommitAsync(ct); return(new CommandValues.GenericInfoCommandValue() { Uuid = pool.Uuid.ToString(), Message = "Pool set ", }); }
public virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QTask task, IConfiguration iconfig = null, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("Command Task : Wait"); var config = iconfig as StdConfiguration; bool end = false; while (end == false) { if (config.Stdout) { var stdmessage = await task.FreshStdoutAsync(ct); if (!string.IsNullOrEmpty(stdmessage)) { CLILogs.Info("Stdout:" + Environment.NewLine + stdmessage.Replace("\\n", Environment.NewLine)); } } if (config.Stderr) { var stdmessage = await task.FreshStderrAsync(ct); if (!string.IsNullOrEmpty(stdmessage)) { CLILogs.Info("Stderr:" + Environment.NewLine + stdmessage.Replace("\\n", Environment.NewLine)); } } end = await task.WaitAsync(taskTimeoutSeconds : 2, ct : ct); } var info = new CommandValues.GenericInfoCommandValue(); info.Uuid = task.Uuid.ToString(); info.Message = "Task Wait end status : " + task.State; return(info); }
public virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QBucket bucket, IConfiguration iconfig, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("Command Bucket : SyncFrom"); BucketConfiguration config = iconfig as BucketConfiguration; if (bucket == default) { var message = "Synchronization failed. Bucket not found"; throw new System.Exception(message); } string localFolderPath = config.LocalPathGet; bool donTDelete = config.DeleteFiles; string remoteFolderRelativePath = config.RemoteRelativePath; if (!config.ApiConnection.DisableBucketPathsSanitization && (PathSanitization.IsThePathInvalid(remoteFolderRelativePath))) { var message = "Synchronization failed. Invalid remote path"; throw new System.Exception(message); } CLILogs.Debug("Local path : " + localFolderPath); await bucket.SyncRemoteToLocalAsync(localFolderPath, ct, donTDelete, remoteFolderRelativePath); return(new CommandValues.GenericInfoCommandValue() { Uuid = bucket.Shortname, Message = "Bucket sync to " + localFolderPath, }); }
public virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QTask task, IConfiguration iconfig = null, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("Command Task : Snapshot Task"); var config = iconfig as SnapshotConfiguration; if (task == default) { var message = "Snapshot failed. Task not found"; throw new System.Exception(message); } task.SnapshotWhitelist = config.Whitelist; task.SnapshotBlacklist = config.Blacklist; if (config.SnapshotPeriodicSec > 0) { await task.TriggerPeriodicSnapshotAsync(config.SnapshotPeriodicSec, config.Whitelist, config.Blacklist, cancellationToken : ct); } else { await task.TriggerSnapshotAsync(config.Whitelist, config.Blacklist, cancellationToken : ct); } return(new CommandValues.GenericInfoCommandValue() { Uuid = task.Uuid.ToString(), Message = "Task Snapshot", }); }
public static bool IsThePathInvalid(string path) { var directorySeparators = new[] { '/', '\\' }; var willBeSanitized = false; if (path != default) { foreach (var separator in directorySeparators) { if (path.Contains(String.Format("{0}{0}", separator))) { CLILogs.Warn($"Bucket path should not contain duplicated slashes ('{String.Format("{0}{0}",separator)}')"); willBeSanitized = true; } if (path.StartsWith(separator.ToString())) { CLILogs.Warn($"Bucket path should not start with a slash ('{separator}')"); willBeSanitized = true; } } if (willBeSanitized) { CLILogs.Warn("The path {path} is invalid. Fix the path by removing the extra sparators or use the argument --no-sanitize-bucket-paths if you are sure about the path"); } } return(willBeSanitized); }
public virtual async Task <CommandValues.BucketInfoCommandValue> ExecuteAsync(QBucket bucket, IConfiguration iconfig, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("Command Bucket : Info"); await bucket.UpdateAsync(ct); BucketConfiguration config = iconfig as BucketConfiguration; List <string> folderList = new List <string>(); string folder = config.RemoteRelativePath ?? ""; if (!config.ApiConnection.DisableBucketPathsSanitization && (PathSanitization.IsThePathInvalid(folder))) { return(null); } folderList = await ExtractBucketFilesInfoFromBucket(bucket, folder, ct, iconfig.HumanReadable); return(new CommandValues.BucketInfoCommandValue() { Shortname = bucket.Shortname, TotalFileCount = bucket.FileCount.ToString(), TotalUsedSpaceBytes = iconfig.HumanReadable ? this.ConvertBytes.ConvertToHumanReadable(bucket.UsedSpaceBytes, 2) : bucket.UsedSpaceBytes.ToString(), BucketFilesDetail = folderList, }); }
public virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QBucket bucket, IConfiguration iconfig, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("Command Bucket : SyncTo"); BucketConfiguration config = iconfig as BucketConfiguration; string localFolderPath = config.LocalPathGet; bool donTDelete = config.DeleteFiles; string remoteFolderRelativePath = config.RemoteRelativePath; if (!config.ApiConnection.DisableBucketPathsSanitization && (PathSanitization.IsThePathInvalid(remoteFolderRelativePath))) { return(new CommandValues.GenericInfoCommandValue() { Uuid = bucket.Shortname, Message = "Synchronization failed. Invalid remote path", }); } CLILogs.Debug("Local path : " + localFolderPath); await bucket.SyncLocalToRemoteAsync(localFolderPath, ct, donTDelete, remoteFolderRelativePath); return(new CommandValues.GenericInfoCommandValue() { Uuid = bucket.Shortname, Message = localFolderPath + "send to Bucket", }); }
/// <summary> /// Set The connection Information to the computer. /// </summary> /// <param name="iconfig">Configuration Object.</param> public void SaveSettings(IConfiguration iconfig) { CLILogs.Debug("Set the config value"); string path = this.GetPath((LocalSetUpConfiguration)iconfig); this.SetConfigInformation(path, iconfig); }
public static void CreateOneLogger(CLILogs.LogsLevel level) { if (Verbose <= level && level < LogsLevel.NoVerbose) { Logs[level] = Printer.PrinterFactory.Factory(level, !NoColor); CLILogs.Debug("Verbose set " + Enum.GetName(typeof(LogsLevel), level)); } }
public static void IConfiguration(IConfiguration config) { var jd = new FormatterFactory.JsonFormatter(); CLILogs.Debug("Config format"); CLILogs.Debug("Type " + Enum.GetName(typeof(ConfigType), config.Type)); CLILogs.Debug("Command " + Enum.GetName(typeof(CommandApi), config.Command)); CLILogs.Debug(jd.Format(config)); }
public static void DebugException(Exception ex) { CLILogs.Debug("InnerException : " + ex?.InnerException?.ToString()); CLILogs.Debug("StackTrace : " + ex?.StackTrace); CLILogs.Debug("Source : " + ex?.Source); CLILogs.Debug("Data : " + ex?.Data.ToString()); CLILogs.Debug("TargetSite : " + ex?.TargetSite?.ToString()); CLILogs.Error(ex?.Message); }
public IConfiguration Parse(string[] argv) { string firstWord = (argv.Length > 0) ? argv[0] : string.Empty; IConfiguration result = this.ParseSubCommand(firstWord, argv); CLILogs.CreateLoggers(); return(result); }
/// <summary> /// Print the CommandLine help. /// </summary> /// <param name="parser">Parser used (CommandLine).</param> /// <param name="errs">Error list.</param> /// <param name="argv">argv list.</param> /// <typeparam name="T">The generic type parameter: Object to parser to get the usage.</typeparam> /// <returns>String usage.</returns> public string PrintHelp <T>(CommandLine.ParserResult <T> parser, System.Collections.Generic.IEnumerable <CommandLine.Error> errs, string[] argv) { // create logs if not already created CLILogs.CreateLoggers(); string helpText = PrintHelpErrorUsage(parser); ParseException ex = new ParseException(); // check if a "help" flag is used if (argv.Length > 1 && argv[1] == "help") { CLILogs.Usage(PrintHelpUsage(parser)); throw new ParseHelpException(); } if (errs == null) { CLILogs.Usage(helpText); throw ex; } if (errs.Any(x => x.Tag == CommandLine.ErrorType.VersionRequestedError)) { helpText = PrintHelpVersion(parser); ex = new ParseVersionException(); } else if (errs.Any(x => x.Tag == CommandLine.ErrorType.HelpRequestedError)) { helpText = PrintHelpUsage(parser); ex = new ParseHelpException(); } else if (errs.Any(x => x.Tag == CommandLine.ErrorType.HelpVerbRequestedError)) { helpText = PrintHelpVerbUsage(parser); ex = new ParseHelpException(); } else if (errs.Any(x => x.Tag == CommandLine.ErrorType.NoVerbSelectedError || x.Tag == CommandLine.ErrorType.BadVerbSelectedError)) { helpText = PrintHelpErrorVerbUsage(parser); string errorList = string.Empty; errs.ToList().ForEach(e => errorList += e.ToString()); ex = new ParseException(errorList); CLILogs.Debug("Parsing error : " + errorList); } else { string errorList = string.Empty; errs.ToList().ForEach(e => errorList += e.ToString()); ex = new ParseException(errorList); CLILogs.Debug("Parsing error : " + errorList); } CLILogs.Usage(helpText); throw ex; }
public virtual Task <T2> ExecuteAsync(T1 obj, IConfiguration iconfig = null, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("print info"); if (objectTransformer != null) { objectTransformer.Transform(obj); } return(Task.FromResult <T2>(obj)); }
public virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QPool pool, IConfiguration iconfig = null, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("Command pool : delete"); await pool.DeleteAsync(ct); return(new CommandValues.GenericInfoCommandValue() { Uuid = pool.Uuid.ToString(), Message = "Pool delete ", }); }
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 virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QTask task, IConfiguration iconfig = null, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("Command Task : Delete"); await task.DeleteAsync(cancellationToken : ct); return(new CommandValues.GenericInfoCommandValue() { Uuid = task.Uuid.ToString(), Message = "Task delete ", }); }
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 virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QJob job, IConfiguration iconfig = null, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("command job : delete"); await job.DeleteAsync(cancellationToken : ct); return(new CommandValues.GenericInfoCommandValue() { Uuid = job.Uuid.ToString(), Message = "Job delete ", }); }
public void ConfigGetVerboseOptions(Options.IVerboseOptions option) { if (option.Verbose) { CLILogs.ChangeVerboseLevel(1); } else if (option.Quiet) { CLILogs.ChangeVerboseLevel(5); } }
public virtual async Task <CommandValues.GenericInfoCommandValue> ExecuteAsync(QBucket bucket, IConfiguration iconfig = null, CancellationToken ct = default(CancellationToken)) { CLILogs.Debug("Command Bucket : Delete"); await bucket.DeleteAsync(ct); return(new CommandValues.GenericInfoCommandValue() { Uuid = bucket.Shortname, Message = "Bucket deleted", }); }