qontract-reconcile 0.10.2.dev201__py3-none-any.whl → 0.10.2.dev203__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qontract-reconcile
3
- Version: 0.10.2.dev201
3
+ Version: 0.10.2.dev203
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Project-URL: homepage, https://github.com/app-sre/qontract-reconcile
6
6
  Project-URL: repository, https://github.com/app-sre/qontract-reconcile
@@ -597,7 +597,7 @@ reconcile/unleash_feature_toggles/integration.py,sha256=nx7BhtzCsTfPbOp60vI5MkNw
597
597
  reconcile/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
598
598
  reconcile/utils/aggregated_list.py,sha256=_9UeaS1TWbJsGIESvXlzzK-omPI2lMMcCsoqc9LBclc,4022
599
599
  reconcile/utils/amtool.py,sha256=Ng5VVNCiPYEK67eDjIwfuuTLs5JsfltCwt6w5UfXbcY,2289
600
- reconcile/utils/aws_api.py,sha256=7G90_TaUNoUVH3tX3_G3U80m6wj9Hy_DDhiDYq0wyz0,80521
600
+ reconcile/utils/aws_api.py,sha256=Xrt4uukct0u5kkQBvl0azquF8JEbrb_aFtlBNEL2G2E,81488
601
601
  reconcile/utils/aws_helper.py,sha256=8PvDR17ntAGX3bBzlTIxDuENl2rkK-RECsNYKm2_DZw,2955
602
602
  reconcile/utils/batches.py,sha256=TtEm64a8lWhFuNbUVpFEmXVdU2Q0sTBrP_I0Cjbgh7g,320
603
603
  reconcile/utils/binary.py,sha256=lSIevhilMeoGMePPHD7A-pxe45LVpBT0LksecYbM-EA,2477
@@ -809,7 +809,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
809
809
  tools/saas_promotion_state/saas_promotion_state.py,sha256=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
810
810
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
811
811
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
812
- qontract_reconcile-0.10.2.dev201.dist-info/METADATA,sha256=3ouikri05CeE-k7JL5J2T38DzVrLe8SHWQkgeta4XRs,24555
813
- qontract_reconcile-0.10.2.dev201.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
814
- qontract_reconcile-0.10.2.dev201.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
815
- qontract_reconcile-0.10.2.dev201.dist-info/RECORD,,
812
+ qontract_reconcile-0.10.2.dev203.dist-info/METADATA,sha256=jLhZJ7x1qlr15Wil2EAOm2Aq2kAZBKMRm6RgIQhGAoM,24555
813
+ qontract_reconcile-0.10.2.dev203.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
814
+ qontract_reconcile-0.10.2.dev203.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
815
+ qontract_reconcile-0.10.2.dev203.dist-info/RECORD,,
@@ -42,6 +42,7 @@ if TYPE_CHECKING:
42
42
  FilterTypeDef,
43
43
  ImageTypeDef,
44
44
  LaunchPermissionModificationsTypeDef,
45
+ NetworkInterfaceTypeDef,
45
46
  RouteTableTypeDef,
46
47
  SubnetTypeDef,
47
48
  TagTypeDef,
@@ -52,6 +53,10 @@ if TYPE_CHECKING:
52
53
  )
53
54
  from mypy_boto3_ecr import ECRClient
54
55
  from mypy_boto3_elb import ElasticLoadBalancingClient
56
+ from mypy_boto3_elb.type_defs import (
57
+ LoadBalancerDescriptionTypeDef,
58
+ TagDescriptionTypeDef,
59
+ )
55
60
  from mypy_boto3_iam import IAMClient, IAMServiceResource
56
61
  from mypy_boto3_iam.type_defs import AccessKeyMetadataTypeDef
57
62
  from mypy_boto3_logs import CloudWatchLogsClient
@@ -92,7 +97,9 @@ else:
92
97
  TransitGatewayTypeDef
93
98
  ) = TransitGatewayVpcAttachmentTypeDef = UpgradeTargetTypeDef = (
94
99
  VpcEndpointTypeDef
95
- ) = VpcTypeDef = object
100
+ ) = VpcTypeDef = NetworkInterfaceTypeDef = LoadBalancerDescriptionTypeDef = (
101
+ TagDescriptionTypeDef
102
+ ) = object
96
103
 
97
104
 
98
105
  class InvalidResourceTypeError(Exception):
@@ -194,9 +201,9 @@ class AWSApi:
194
201
  self.get_vpc_route_tables = lru_cache()(self.get_vpc_route_tables) # type: ignore[method-assign]
195
202
  self.get_vpc_subnets = lru_cache()(self.get_vpc_subnets) # type: ignore[method-assign]
196
203
  self._get_vpc_endpoints = lru_cache()(self._get_vpc_endpoints) # type: ignore[method-assign]
197
- self.get_alb_network_interface_ips = lru_cache()( # type: ignore[method-assign]
198
- self.get_alb_network_interface_ips
199
- )
204
+ self.get_network_interfaces = lru_cache()(self.get_network_interfaces) # type: ignore[method-assign]
205
+ self.get_load_balancers = lru_cache()(self.get_load_balancers) # type: ignore[method-assign]
206
+ self.get_load_balancer_tags = lru_cache()(self.get_load_balancer_tags) # type: ignore[method-assign]
200
207
 
201
208
  if init_users:
202
209
  self.init_users()
@@ -1584,14 +1591,14 @@ class AWSApi:
1584
1591
  client_type="elb",
1585
1592
  )
1586
1593
  service_tag = {"Key": "kubernetes.io/service-name", "Value": service_name}
1587
- nis = ec2_client.describe_network_interfaces()["NetworkInterfaces"]
1588
- lbs = elb_client.describe_load_balancers()["LoadBalancerDescriptions"]
1594
+ nis = self.get_network_interfaces(ec2_client)
1595
+ lbs = self.get_load_balancers(elb_client)
1589
1596
  result_ips = set()
1590
1597
  for lb in lbs:
1591
1598
  lb_name = lb["LoadBalancerName"]
1592
- tag_descriptions = elb_client.describe_tags(LoadBalancerNames=[lb_name])[
1593
- "TagDescriptions"
1594
- ]
1599
+ tag_descriptions = self.get_load_balancer_tags(
1600
+ elb=elb_client, lb_name=lb_name
1601
+ )
1595
1602
  for td in tag_descriptions:
1596
1603
  tags = td["Tags"]
1597
1604
  if service_tag not in tags:
@@ -1609,6 +1616,22 @@ class AWSApi:
1609
1616
 
1610
1617
  return result_ips
1611
1618
 
1619
+ @staticmethod
1620
+ def get_network_interfaces(ec2: EC2Client) -> list[NetworkInterfaceTypeDef]:
1621
+ return ec2.describe_network_interfaces()["NetworkInterfaces"]
1622
+
1623
+ @staticmethod
1624
+ def get_load_balancers(
1625
+ elb: ElasticLoadBalancingClient,
1626
+ ) -> list[LoadBalancerDescriptionTypeDef]:
1627
+ return elb.describe_load_balancers()["LoadBalancerDescriptions"]
1628
+
1629
+ @staticmethod
1630
+ def get_load_balancer_tags(
1631
+ elb: ElasticLoadBalancingClient, lb_name: str
1632
+ ) -> list[TagDescriptionTypeDef]:
1633
+ return elb.describe_tags(LoadBalancerNames=[lb_name])["TagDescriptions"]
1634
+
1612
1635
  @staticmethod
1613
1636
  def get_vpc_default_sg_id(vpc_id: str, ec2: EC2Client) -> str | None:
1614
1637
  vpc_security_groups = ec2.describe_security_groups(