Exemplo n.º 1
0
    private void ProcessInstanceMissingTagsRequest(Ec2Request parms, bool isDryRun = false)
    {
        List <Ec2Instance> resultInstances = new List <Ec2Instance>();

        try
        {
            string profile;
            _config.AwsEnvironmentProfile.TryGetValue(parms.CloudEnvironment, out profile);
            List <Instance> instances = AwsServices.DescribeEc2Instances(null, parms.Region, profile);
            foreach (Instance instance in instances)
            {
                if (HasMissingTags(instance.Tags, parms.MissingTags))
                {
                    Ec2Instance mappedInstance = Mapper.Map <Instance, Ec2Instance>(instance);
                    resultInstances.Add(mappedInstance);
                }
            }
        }
        catch (Exception ex)
        {
            _response.Summary   = (isDryRun ? "Dry run has been completed. " : "") + ex.Message;
            _encounteredFailure = true;
        }

        _response.Ec2Instances = resultInstances;
        _response.Count        = resultInstances.Count;
    }
Exemplo n.º 2
0
    private void GetFilteredInstances(Ec2Request parms)
    {
        string profile;

        _config.AwsEnvironmentProfile.TryGetValue(parms.CloudEnvironment, out profile);
        List <Instance>    instances       = AwsServices.DescribeEc2Instances(parms.Filters, parms.Region, profile);
        List <Ec2Instance> resultInstances = Mapper.Map <List <Instance>, List <Ec2Instance> >(instances);

        _response.Ec2Instances = resultInstances;
        _response.Count        = resultInstances.Count;
    }