Example #1
0
            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));
            }
Example #2
0
        public async Task <List <QarnotSDK.QPool> > RetrieveAsync(IConfiguration configuration, QarnotSDK.Connection connection, CancellationToken ct)
        {
            DefaultRunConfiguration config = configuration as DefaultRunConfiguration;

            QarnotSDK.QPool pool     = null;
            List <QPool>    listPool = null;

            if (!string.IsNullOrEmpty(config.Name))
            {
                CLILogs.Debug("Retrieve QPools by Shortname : " + config.Name);
                pool = await connection.RetrievePoolByShortnameAsync(config.Name, cancellationToken : ct);
            }
            else if (!string.IsNullOrEmpty(config.Id))
            {
                CLILogs.Debug("Retrieve QPool by Uuid : " + config.Id);
                pool = await connection.RetrievePoolByUuidAsync(config.Id, cancellationToken : ct);
            }
            else if (config.Tags != null && config.Tags.Count > 0)
            {
                if (config.TagsIntersect)
                {
                    CLILogs.Debug("Retrieve QPools by Tags Intersect : " + config.Tags.ToString());
                    var poolTagFilter = new QDataDetail <QPool>();
                    var filterList    = config.Tags.Select(tag => QFilter <QPool> .Contains(t => t.Tags, tag));
                    listPool = await connection.RetrievePoolsAsync(poolTagFilter, cancellationToken : ct);
                }
                else
                {
                    CLILogs.Debug("Retrieve QPools by Tags : " + config.Tags.ToString());
                    listPool = await connection.RetrievePoolsByTagsAsync(config.Tags, cancellationToken : ct);
                }
            }
            else
            {
                CLILogs.Debug("Retrieve all the QPools");
                listPool = await connection.RetrievePoolsAsync(cancellationToken : ct);
            }

            return(listPool ?? new List <QPool>()
            {
                pool
            });
        }