How to use the taskcat._amiupdater.APIResultsData function in taskcat

To help you get started, we’ve selected a few taskcat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
def test_APIResults_greaterthan_comparison_standard(self):
        from taskcat._amiupdater import APIResultsData

        APIResultsData.custom_comparisons = False
        instance_args = {
            "codename": "foo",
            "ami_id": "ami-12345abcde",
            "creation_date": datetime(2010, 1, 23),
            "region": "us-east-1",
            "custom_comparisons": False,
        }
        a = APIResultsData(**instance_args)

        instance_args["ami_id"] = "ami-abcde12345"
        instance_args["creation_date"] = datetime(2012, 1, 23)
        b = APIResultsData(**instance_args)

        with self.assertRaises(TypeError):
            a > b
github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
def test_APIResults_greaterthan_comparison_standard(self):
        from taskcat._amiupdater import APIResultsData

        APIResultsData.custom_comparisons = False
        instance_args = {
            "codename": "foo",
            "ami_id": "ami-12345abcde",
            "creation_date": datetime(2010, 1, 23),
            "region": "us-east-1",
            "custom_comparisons": False,
        }
        a = APIResultsData(**instance_args)

        instance_args["ami_id"] = "ami-abcde12345"
        instance_args["creation_date"] = datetime(2012, 1, 23)
        b = APIResultsData(**instance_args)

        with self.assertRaises(TypeError):
            a > b
github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
def test_APIResults_greaterthan_comparison_custom(self):
        from taskcat._amiupdater import APIResultsData

        instance_args = {
            "codename": "foo",
            "ami_id": "ami-12345abcde",
            "creation_date": datetime(2012, 1, 23),
            "region": "us-east-1",
        }
        a = APIResultsData(**instance_args)

        instance_args["ami_id"] = "ami-abcde12345"
        instance_args["creation_date"] = datetime(2010, 1, 23)
        b = APIResultsData(**instance_args)

        self.assertTrue(a > b)
github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
def test_APIResults_lessthan_comparison_standard(self):
        from taskcat._amiupdater import APIResultsData

        instance_args = {
            "codename": "foo",
            "ami_id": "ami-12345abcde",
            "creation_date": datetime(2010, 1, 23),
            "region": "us-east-1",
            "custom_comparisons": False,
        }
        a = APIResultsData(**instance_args)

        instance_args["ami_id"] = "ami-abcde12345"
        instance_args["creation_date"] = datetime(2012, 1, 23)
        b = APIResultsData(**instance_args)

        with self.assertRaises(TypeError):
            a < b
github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
def test_APIResults_lessthan_comparison_standard(self):
        from taskcat._amiupdater import APIResultsData

        instance_args = {
            "codename": "foo",
            "ami_id": "ami-12345abcde",
            "creation_date": datetime(2010, 1, 23),
            "region": "us-east-1",
            "custom_comparisons": False,
        }
        a = APIResultsData(**instance_args)

        instance_args["ami_id"] = "ami-abcde12345"
        instance_args["creation_date"] = datetime(2012, 1, 23)
        b = APIResultsData(**instance_args)

        with self.assertRaises(TypeError):
            a < b
github aws-quickstart / taskcat / tests / test_amiupdater.py View on Github external
def test_APIResults_lessthan_comparison_custom(self):
        from taskcat._amiupdater import APIResultsData

        instance_args = {
            "codename": "foo",
            "ami_id": "ami-12345abcde",
            "creation_date": datetime(2010, 1, 23),
            "region": "us-east-1",
        }
        a = APIResultsData(**instance_args)

        instance_args["ami_id"] = "ami-abcde12345"
        instance_args["creation_date"] = datetime(2012, 1, 23)
        b = APIResultsData(**instance_args)

        self.assertTrue(a < b)
github aws-quickstart / taskcat / taskcat / _amiupdater.py View on Github external
def parse_api_results(cls):
        raw_ami_names = {}
        region_codename_result_list = []
        missing_results_list = []

        # For each RegionalCodename.
        #     Create a Dictionary like so:
        #     CODENAME
        #       - REGION_NAME
        #           [{RAW_API_RESULTS_1}, {RAW_API_RESULTS_2}, {RAW_API_RESULTS_N}]
        for rcn in RegionalCodename.objects():
            if rcn.cn in raw_ami_names.keys():
                raw_ami_names[rcn.cn][rcn.region] = [
                    APIResultsData(
                        rcn.cn,
                        x["ImageId"],
                        int(
                            datetime.datetime.strptime(
                                x["CreationDate"], "%Y-%m-%dT%H:%M:%S.%fZ"
                            ).timestamp()
                        ),
                        rcn.region,
                    )
                    for x in rcn.results
                ]
            else:
                raw_ami_names.update(
                    {
                        rcn.cn: {
                            rcn.region: [
github aws-quickstart / taskcat / taskcat / _amiupdater.py View on Github external
if len(results_list) == 0:
                    missing_results_list.append((codename, region))
                    continue
                latest_ami = sorted(results_list, reverse=True)[0]
                latest_ami.custom_comparisons = False
                region_codename_result_list.append(latest_ami)
        if missing_results_list:
            for code_reg in missing_results_list:
                LOG.error(
                    f"The following Codename / Region  had no results from the EC2 "
                    f"API. {code_reg}"
                )
            raise AMIUpdaterException(
                "One or more filters returns no results from the EC2 API."
            )
        APIResultsData.results = region_codename_result_list
github aws-quickstart / taskcat / taskcat / _amiupdater.py View on Github external
def reduce_api_results(raw_results):
    unsorted_results = []
    missing_results = []
    final_results = []
    result_state = {}

    for query_result in raw_results:
        if query_result["api_results"]:
            cn_api_results_data = [
                APIResultsData(
                    query_result["cn"],
                    x["ImageId"],
                    _image_timestamp(x["CreationDate"]),
                    query_result["region"],
                )
                for x in query_result["api_results"]
            ]
            unsorted_results = cn_api_results_data + unsorted_results
        else:
            missing_results.append(query_result)

    if missing_results:
        LOG.warning(
            "No results were available for the following CODENAME / Region combination"
        )