Пример #1
0
 def test_merge_dicts_more_complex(self):
     dikt1 = {"key": ["value"]}
     dikt3 = {"key": ["value2"], "k": ["v"]}
     expected_2 = {"key": ["value", "value2"], "k": ["v"]}
     merge2 = merge_dicts(dikt1, dikt3)
     for k, v in expected_2.items():
         self.assertEqual(sorted(merge2[k]), sorted(v))
Пример #2
0
class OCPAzureTagQueryHandler(AzureTagQueryHandler, OCPTagQueryHandler):
    """Handles tag queries and responses for OCP-on-Azure."""

    provider = Provider.OCP_AZURE
    data_sources = [{
        "db_table": OCPAzureTagsSummary,
        "db_column_period": "cost_entry_bill__billing_period"
    }]
    SUPPORTED_FILTERS = AzureTagQueryHandler.SUPPORTED_FILTERS + OCPTagQueryHandler.SUPPORTED_FILTERS
    FILTER_MAP = merge_dicts(AzureTagQueryHandler.FILTER_MAP,
                             OCPTagQueryHandler.FILTER_MAP)

    def __init__(self, parameters):
        """Establish Azure report query handler.

        Args:
            parameters    (QueryParameters): parameter object for query

        """
        self._mapper = OCPAzureProviderMap(provider=self.provider,
                                           report_type=parameters.report_type)
        if "enabled" in self.SUPPORTED_FILTERS:
            self.SUPPORTED_FILTERS.remove("enabled")
        if "enabled" in self.FILTER_MAP.keys():
            del self.FILTER_MAP["enabled"]
        # super() needs to be called after _mapper is set
        super().__init__(parameters)
Пример #3
0
 def test_merge_dicts_simple(self):
     dikt1 = {"key": ["value"]}
     dikt2 = {"k": ["v"]}
     expected_1 = {"key": ["value"], "k": ["v"]}
     merge1 = merge_dicts(dikt1, dikt2)
     for k, v in expected_1.items():
         self.assertEqual(sorted(merge1[k]), sorted(v))
Пример #4
0
class OCPAWSTagQueryHandler(AWSTagQueryHandler, OCPTagQueryHandler):
    """Handles tag queries and responses for OCP-on-AWS."""

    provider = Provider.OCP_AWS
    data_sources = [{
        "db_table": OCPAWSTagsSummary,
        "db_column_period": "cost_entry_bill__billing_period"
    }]
    SUPPORTED_FILTERS = AWSTagQueryHandler.SUPPORTED_FILTERS + OCPTagQueryHandler.SUPPORTED_FILTERS
    FILTER_MAP = merge_dicts(AWSTagQueryHandler.FILTER_MAP,
                             OCPTagQueryHandler.FILTER_MAP)
    # override cluster since we are getting it from a different table and field(s)
    FILTER_MAP["cluster"] = [
        {
            "field": "cluster_id",
            "operation": "icontains",
            "composition_key": "cluster_filter"
        },
        {
            "field": "cluster_alias",
            "operation": "icontains",
            "composition_key": "cluster_filter"
        },
    ]

    def __init__(self, parameters):
        """Establish AWS report query handler.

        Args:
            parameters    (QueryParameters): parameter object for query

        """
        self._mapper = OCPAWSProviderMap(provider=self.provider,
                                         report_type=parameters.report_type)
        if "enabled" in self.SUPPORTED_FILTERS:
            self.SUPPORTED_FILTERS.remove("enabled")
        if "enabled" in self.FILTER_MAP.keys():
            del self.FILTER_MAP["enabled"]

        # super() needs to be called after _mapper is set
        super().__init__(parameters)