qontract-reconcile 0.10.1rc723__py3-none-any.whl → 0.10.1rc724__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.1
2
2
  Name: qontract-reconcile
3
- Version: 0.10.1rc723
3
+ Version: 0.10.1rc724
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Home-page: https://github.com/app-sre/qontract-reconcile
6
6
  Author: Red Hat App-SRE Team
@@ -746,7 +746,7 @@ tools/app_interface_metrics_exporter.py,sha256=zkwkxdAUAxjdc-pzx2_oJXG25fo0Fnyd5
746
746
  tools/app_interface_reporter.py,sha256=upA-J-n-HXHKVDINRuMR7vTt-iJvQORKUVi9D3leQto,17738
747
747
  tools/glitchtip_access_reporter.py,sha256=oPBnk_YoDuljU3v0FaChzOwwnk4vap1xEE67QEjzdqs,2948
748
748
  tools/glitchtip_access_revalidation.py,sha256=8kbBJk04mkq28kWoRDDkfCGIF3GRg3pJrFAh1sW0dbk,2821
749
- tools/qontract_cli.py,sha256=blfKR_QxxnqxBWyX_x5V5cXEydnmM3v9Iy5gAIFrCIc,114530
749
+ tools/qontract_cli.py,sha256=vm1uti_uMmPKiDE2gP_VXqoURqrq5YmIFZhQU6u3p2U,115670
750
750
  tools/sd_app_sre_alert_report.py,sha256=e9vAdyenUz2f5c8-z-5WY0wv-SJ9aePKDH2r4IwB6pc,5063
751
751
  tools/template_validation.py,sha256=-U-lTGeLaci8yWPEblCJeev2DOlY1jM9QOOh-O1zts8,3376
752
752
  tools/cli_commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -764,8 +764,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
764
764
  tools/test/test_qontract_cli.py,sha256=UEwAW7PA_GIrbqzaLxpkCxbuVjEFLNvnVG-6VyoCGIc,4147
765
765
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
766
766
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
767
- qontract_reconcile-0.10.1rc723.dist-info/METADATA,sha256=lx9z1uiO5ZTe9qO_d0fm1X86mxSU2fABbcxCL9Jmv8g,2382
768
- qontract_reconcile-0.10.1rc723.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
769
- qontract_reconcile-0.10.1rc723.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
770
- qontract_reconcile-0.10.1rc723.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
771
- qontract_reconcile-0.10.1rc723.dist-info/RECORD,,
767
+ qontract_reconcile-0.10.1rc724.dist-info/METADATA,sha256=PjfsZ0NRyqqevEEofVjYp6lI20qIJHsKyRc6CHZTA7A,2382
768
+ qontract_reconcile-0.10.1rc724.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
769
+ qontract_reconcile-0.10.1rc724.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
770
+ qontract_reconcile-0.10.1rc724.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
771
+ qontract_reconcile-0.10.1rc724.dist-info/RECORD,,
tools/qontract_cli.py CHANGED
@@ -1021,8 +1021,20 @@ def network_reservations(ctx) -> None:
1021
1021
 
1022
1022
 
1023
1023
  @get.command()
1024
+ @click.option(
1025
+ "--for-cluster",
1026
+ help="If it is for getting cidr block for a cluster.",
1027
+ type=bool,
1028
+ default=False,
1029
+ )
1030
+ @click.option(
1031
+ "--mask",
1032
+ help="Mask for the latest available CIDR block for AWS resources. A decimal number between 1~32.",
1033
+ type=int,
1034
+ default=24,
1035
+ )
1024
1036
  @click.pass_context
1025
- def cidr_blocks(ctx) -> None:
1037
+ def cidr_blocks(ctx, for_cluster: int, mask: int) -> None:
1026
1038
  import ipaddress
1027
1039
 
1028
1040
  from reconcile.typed_queries.aws_vpcs import get_aws_vpcs
@@ -1070,8 +1082,29 @@ def cidr_blocks(ctx) -> None:
1070
1082
 
1071
1083
  cidrs.sort(key=lambda item: ipaddress.ip_network(item["cidr"]))
1072
1084
 
1073
- ctx.obj["options"]["sort"] = False
1074
- print_output(ctx.obj["options"], cidrs, columns)
1085
+ if for_cluster:
1086
+ latest_cluster_cidr = next(
1087
+ (item for item in reversed(cidrs) if item["type"] == "cluster"),
1088
+ None,
1089
+ )
1090
+
1091
+ if not latest_cluster_cidr:
1092
+ print("ERROR: Unable to find any existing cluster CIDR block.")
1093
+ sys.exit(1)
1094
+
1095
+ avail_addr = ipaddress.ip_address(latest_cluster_cidr["to"]) + 1
1096
+
1097
+ print(f"INFO: Latest available network address: {str(avail_addr)}")
1098
+ try:
1099
+ result_cidr_block = str(ipaddress.ip_network((avail_addr, mask)))
1100
+ except ValueError:
1101
+ print(f"ERROR: Invalid CIDR Mask {mask} Provided.")
1102
+ sys.exit(1)
1103
+ print(f"INFO: You are reserving {str(2 ** (32 - mask))} network addresses.")
1104
+ print(f"\nYou can use: {str(result_cidr_block)}")
1105
+ else:
1106
+ ctx.obj["options"]["sort"] = False
1107
+ print_output(ctx.obj["options"], cidrs, columns)
1075
1108
 
1076
1109
 
1077
1110
  def ocm_aws_infrastructure_access_switch_role_links_data() -> list[dict]: