qontract-reconcile 0.10.1rc709__py3-none-any.whl → 0.10.1rc711__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.1rc709
3
+ Version: 0.10.1rc711
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
@@ -235,6 +235,7 @@ reconcile/gql_definitions/common/ocm_environments.py,sha256=2Szg8VSIM4a9ZbjktDjS
235
235
  reconcile/gql_definitions/common/pagerduty_instances.py,sha256=qcbOSUNwmeRcBetJ2FktUu6Mn4CPE2iNoevt3fY_xig,1988
236
236
  reconcile/gql_definitions/common/pgp_reencryption_settings.py,sha256=NPLmO6J-zSu5B9QiYbDezLHY3TuOO9ihRBV-Zr84R9w,2259
237
237
  reconcile/gql_definitions/common/pipeline_providers.py,sha256=JJgmmghqLIwjKOdcWYHPnf4PDgAq4GF7046i0ozrqgI,9127
238
+ reconcile/gql_definitions/common/reserved_networks.py,sha256=yP9qSQCaSQcva-ZgTnZp09qH27ur5_qK080ToIs04MY,2560
238
239
  reconcile/gql_definitions/common/saas_files.py,sha256=B7HE_jV5ky8AFxOCleSg2RYDrtUaV99DYa2If8wyvHs,15926
239
240
  reconcile/gql_definitions/common/saas_target_namespaces.py,sha256=gcTU9jrsNq9-HX-oOkj-nEZKYFTRytDHLs4SpEs93aw,2755
240
241
  reconcile/gql_definitions/common/saasherder_settings.py,sha256=nqQLcMwYxLseqq0BEcVvmrpIj2eQq0h8XDSpLN6GGCw,1793
@@ -557,6 +558,7 @@ reconcile/typed_queries/namespaces.py,sha256=vItPrn7sfcHOix-VvkzQkf54_ljzI_ymyxh
557
558
  reconcile/typed_queries/namespaces_minimal.py,sha256=rUtqNQ0ORXXUTQfnpsMURymAJ4gYtE77V-Lb3LiJFEY,278
558
559
  reconcile/typed_queries/pagerduty_instances.py,sha256=QCHqEAakiH6eSob0Pnnn3IBd8Ga0zpEp1Z6Qu3v2uH4,733
559
560
  reconcile/typed_queries/repos.py,sha256=RKBsf7IDS6NsXTtXxJ9Ol9G3bxG9sr3vW9QQ2bahEHo,512
561
+ reconcile/typed_queries/reserved_networks.py,sha256=SWukbbEeW6acyP89v0DYd1WgbcBlUDuo-y3e27eN_vs,390
560
562
  reconcile/typed_queries/saas_files.py,sha256=4b6zhb5-y7HUyn9DDkJ9CRpvg7N-PnH6gtXtHyd-rzo,14136
561
563
  reconcile/typed_queries/slo_documents.py,sha256=x2dg0cnMET-ImARzhDg7Q81MA9Zlm9alH8Rp5XkVR6s,407
562
564
  reconcile/typed_queries/smtp.py,sha256=aSLglYa5bHKmlGwKkxq2RZqyMWuAf0a4S_mOuhDa084,542
@@ -744,7 +746,7 @@ tools/app_interface_metrics_exporter.py,sha256=zkwkxdAUAxjdc-pzx2_oJXG25fo0Fnyd5
744
746
  tools/app_interface_reporter.py,sha256=upA-J-n-HXHKVDINRuMR7vTt-iJvQORKUVi9D3leQto,17738
745
747
  tools/glitchtip_access_reporter.py,sha256=oPBnk_YoDuljU3v0FaChzOwwnk4vap1xEE67QEjzdqs,2948
746
748
  tools/glitchtip_access_revalidation.py,sha256=8kbBJk04mkq28kWoRDDkfCGIF3GRg3pJrFAh1sW0dbk,2821
747
- tools/qontract_cli.py,sha256=AdOUq_74y-s1nDbF6Yh0z1sTQ1r8yS3nPG9yP-slWfE,111846
749
+ tools/qontract_cli.py,sha256=blfKR_QxxnqxBWyX_x5V5cXEydnmM3v9Iy5gAIFrCIc,114530
748
750
  tools/sd_app_sre_alert_report.py,sha256=e9vAdyenUz2f5c8-z-5WY0wv-SJ9aePKDH2r4IwB6pc,5063
749
751
  tools/template_validation.py,sha256=-U-lTGeLaci8yWPEblCJeev2DOlY1jM9QOOh-O1zts8,3376
750
752
  tools/cli_commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -762,8 +764,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
762
764
  tools/test/test_qontract_cli.py,sha256=UEwAW7PA_GIrbqzaLxpkCxbuVjEFLNvnVG-6VyoCGIc,4147
763
765
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
764
766
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
765
- qontract_reconcile-0.10.1rc709.dist-info/METADATA,sha256=LWgfuyiC1vMk_M3JnVI9i54gC6OTe2glD6StNzN4X5s,2382
766
- qontract_reconcile-0.10.1rc709.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
767
- qontract_reconcile-0.10.1rc709.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
768
- qontract_reconcile-0.10.1rc709.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
769
- qontract_reconcile-0.10.1rc709.dist-info/RECORD,,
767
+ qontract_reconcile-0.10.1rc711.dist-info/METADATA,sha256=C66Bft6HzT9sQVAcNyckeGBHPW2gAhwMv7dGVxGcF_Y,2382
768
+ qontract_reconcile-0.10.1rc711.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
769
+ qontract_reconcile-0.10.1rc711.dist-info/entry_points.txt,sha256=rIxI5zWtHNlfpDeq1a7pZXAPoqf7HG32KMTN3MeWK_8,429
770
+ qontract_reconcile-0.10.1rc711.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
771
+ qontract_reconcile-0.10.1rc711.dist-info/RECORD,,
@@ -0,0 +1,94 @@
1
+ """
2
+ Generated by qenerate plugin=pydantic_v1. DO NOT MODIFY MANUALLY!
3
+ """
4
+ from collections.abc import Callable # noqa: F401 # pylint: disable=W0611
5
+ from datetime import datetime # noqa: F401 # pylint: disable=W0611
6
+ from enum import Enum # noqa: F401 # pylint: disable=W0611
7
+ from typing import ( # noqa: F401 # pylint: disable=W0611
8
+ Any,
9
+ Optional,
10
+ Union,
11
+ )
12
+
13
+ from pydantic import ( # noqa: F401 # pylint: disable=W0611
14
+ BaseModel,
15
+ Extra,
16
+ Field,
17
+ Json,
18
+ )
19
+
20
+
21
+ DEFINITION = """
22
+ query ReservedNetworks {
23
+ networks: network_v1 {
24
+ name
25
+ networkAddress
26
+ parentNetwork {
27
+ networkAddress
28
+ }
29
+ inUseBy {
30
+ vpc {
31
+ account {
32
+ name
33
+ uid
34
+ consoleUrl
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ """
41
+
42
+
43
+ class ConfiguredBaseModel(BaseModel):
44
+ class Config:
45
+ smart_union=True
46
+ extra=Extra.forbid
47
+
48
+
49
+ class NetworkV1_NetworkV1(ConfiguredBaseModel):
50
+ network_address: str = Field(..., alias="networkAddress")
51
+
52
+
53
+ class AWSAccountV1(ConfiguredBaseModel):
54
+ name: str = Field(..., alias="name")
55
+ uid: str = Field(..., alias="uid")
56
+ console_url: str = Field(..., alias="consoleUrl")
57
+
58
+
59
+ class VPCRequestV1(ConfiguredBaseModel):
60
+ account: AWSAccountV1 = Field(..., alias="account")
61
+
62
+
63
+ class NetworkInUseByV1(ConfiguredBaseModel):
64
+ vpc: Optional[VPCRequestV1] = Field(..., alias="vpc")
65
+
66
+
67
+ class NetworkV1(ConfiguredBaseModel):
68
+ name: str = Field(..., alias="name")
69
+ network_address: str = Field(..., alias="networkAddress")
70
+ parent_network: Optional[NetworkV1_NetworkV1] = Field(..., alias="parentNetwork")
71
+ in_use_by: Optional[NetworkInUseByV1] = Field(..., alias="inUseBy")
72
+
73
+
74
+ class ReservedNetworksQueryData(ConfiguredBaseModel):
75
+ networks: Optional[list[NetworkV1]] = Field(..., alias="networks")
76
+
77
+
78
+ def query(query_func: Callable, **kwargs: Any) -> ReservedNetworksQueryData:
79
+ """
80
+ This is a convenience function which queries and parses the data into
81
+ concrete types. It should be compatible with most GQL clients.
82
+ You do not have to use it to consume the generated data classes.
83
+ Alternatively, you can also mime and alternate the behavior
84
+ of this function in the caller.
85
+
86
+ Parameters:
87
+ query_func (Callable): Function which queries your GQL Server
88
+ kwargs: optional arguments that will be passed to the query function
89
+
90
+ Returns:
91
+ ReservedNetworksQueryData: queried data parsed into generated classes
92
+ """
93
+ raw_data: dict[Any, Any] = query_func(DEFINITION, **kwargs)
94
+ return ReservedNetworksQueryData(**raw_data)
@@ -0,0 +1,14 @@
1
+ from typing import Optional
2
+
3
+ from reconcile.gql_definitions.common.reserved_networks import (
4
+ NetworkV1,
5
+ query,
6
+ )
7
+ from reconcile.utils import gql
8
+ from reconcile.utils.gql import GqlApi
9
+
10
+
11
+ def get_networks(gql_api: Optional[GqlApi] = None) -> list[NetworkV1]:
12
+ api = gql_api if gql_api else gql.get_api()
13
+ data = query(query_func=api.query)
14
+ return list(data.networks or [])
tools/qontract_cli.py CHANGED
@@ -974,6 +974,52 @@ def clusters_network(ctx, name):
974
974
  print_output(ctx.obj["options"], clusters, columns)
975
975
 
976
976
 
977
+ @get.command()
978
+ @click.pass_context
979
+ def network_reservations(ctx) -> None:
980
+ from reconcile.typed_queries.reserved_networks import get_networks
981
+
982
+ columns = [
983
+ "name",
984
+ "network Address",
985
+ "parent Network",
986
+ "Account Name",
987
+ "Account UID",
988
+ "Console Login URL",
989
+ ]
990
+ network_table = []
991
+
992
+ def md_link(url) -> str:
993
+ if ctx.obj["options"]["output"] == "md":
994
+ return f"[{url}]({url})"
995
+ else:
996
+ return url
997
+
998
+ for network in get_networks():
999
+ parentAddress = "none"
1000
+ if network.parent_network:
1001
+ parentAddress = network.parent_network.network_address
1002
+ if network.in_use_by and network.in_use_by.vpc:
1003
+ network_table.append({
1004
+ "name": network.name,
1005
+ "network Address": network.network_address,
1006
+ "parent Network": parentAddress,
1007
+ "Account Name": network.in_use_by.vpc.account.name,
1008
+ "Account UID": network.in_use_by.vpc.account.uid,
1009
+ "Console Login URL": md_link(network.in_use_by.vpc.account.console_url),
1010
+ })
1011
+ else:
1012
+ network_table.append({
1013
+ "name": network.name,
1014
+ "network Address": network.network_address,
1015
+ "parent Network": parentAddress,
1016
+ "Account Name": "Unclaimed network",
1017
+ "Account UID": "Unclaimed network",
1018
+ "Console Login URL": "Unclaimed network",
1019
+ })
1020
+ print_output(ctx.obj["options"], network_table, columns)
1021
+
1022
+
977
1023
  @get.command()
978
1024
  @click.pass_context
979
1025
  def cidr_blocks(ctx) -> None:
@@ -2521,6 +2567,42 @@ def cost_report(ctx):
2521
2567
  print(command.execute())
2522
2568
 
2523
2569
 
2570
+ @get.command()
2571
+ @click.pass_context
2572
+ def osd_component_versions(ctx):
2573
+ osd_environments = [
2574
+ e["name"] for e in queries.get_environments() if e["product"]["name"] == "OSDv4"
2575
+ ]
2576
+ data = []
2577
+ saas_files = get_saas_files()
2578
+ for sf in saas_files:
2579
+ for rt in sf.resource_templates:
2580
+ for t in rt.targets:
2581
+ if t.namespace.environment.name not in osd_environments:
2582
+ continue
2583
+ item = {
2584
+ "environment": t.namespace.environment.name,
2585
+ "namespace": t.namespace.name,
2586
+ "cluster": t.namespace.cluster.name,
2587
+ "app": sf.app.name,
2588
+ "saas_file": sf.name,
2589
+ "resource_template": rt.name,
2590
+ "ref": f"[{t.ref}]({rt.url}/blob/{t.ref}{rt.path})",
2591
+ }
2592
+ data.append(item)
2593
+
2594
+ columns = [
2595
+ "environment",
2596
+ "namespace",
2597
+ "cluster",
2598
+ "app",
2599
+ "saas_file",
2600
+ "resource_template",
2601
+ "ref",
2602
+ ]
2603
+ print_output(ctx.obj["options"], data, columns)
2604
+
2605
+
2524
2606
  @root.group(name="set")
2525
2607
  @output
2526
2608
  @click.pass_context