public override async Task <PromotionRequirementStatus> GetStatusAsync(PromotionContext context)
        {
            var entity = InfrastructureEntity.Create(serverName: this.Server, roleName: this.Role);

            if (entity == null)
            {
                return(new PromotionRequirementStatus(PromotionRequirementState.NotApplicable, "A server or role must be specified to determine drift status."));
            }

            var credentials = ResourceCredentials.Create <InedoProductCredentials>(this.CredentialName);

            var client = OtterClient.Create(credentials.Host, credentials.ApiKey);

            try
            {
                await client.TriggerConfigurationCheckAsync(entity).ConfigureAwait(false);

                await Task.Delay(2 * 1000).ConfigureAwait(false);

                var config = await client.GetConfigurationStatusAsync(entity).ConfigureAwait(false);

                if (string.Equals(config.Status, this.Status.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    return(new PromotionRequirementStatus(PromotionRequirementState.Met, $"{entity} status is {config.Status}."));
                }
                else
                {
                    return(new PromotionRequirementStatus(PromotionRequirementState.NotMet, $"{entity} status is {config.Status}, must be {this.Status.ToString().ToLowerInvariant()}."));
                }
            }
            catch (OtterException ex)
            {
                return(new PromotionRequirementStatus(PromotionRequirementState.NotMet, ex.FullMessage));
            }
        }
示例#2
0
        public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config)
        {
            string credentialName = config["CredentialName"];

            if (string.IsNullOrEmpty(credentialName))
            {
                return(Enumerable.Empty <string>());
            }

            var credentials = ResourceCredentials.Create <OtterCredentials>(credentialName);

            var client  = new OtterClient(credentials.Host, credentials.ApiKey);
            var servers = await client.EnumerateInfrastructureAsync(InfrastructureEntity.Environment).ConfigureAwait(false);

            return(servers);
        }
示例#3
0
        public async Task <IEnumerable <string> > GetSuggestionsAsync(IComponentConfiguration config)
        {
            string credentialName = config["CredentialName"];

            if (string.IsNullOrEmpty(credentialName))
            {
                return(Enumerable.Empty <string>());
            }

            var credentials = ResourceCredentials.Create <InedoProductCredentials>(credentialName);

            var client = OtterClient.Create(credentials.Host, credentials.ApiKey);
            var roles  = await client.EnumerateInfrastructureAsync(InfrastructureEntity.Role).ConfigureAwait(false);

            return(roles);
        }