cartography 0.102.0rc1__py3-none-any.whl → 0.103.0rc1__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.
Potentially problematic release.
This version of cartography might be problematic. Click here for more details.
- cartography/__main__.py +1 -2
- cartography/_version.py +2 -2
- cartography/cli.py +302 -253
- cartography/client/core/tx.py +39 -18
- cartography/config.py +4 -0
- cartography/driftdetect/__main__.py +1 -2
- cartography/driftdetect/add_shortcut.py +10 -2
- cartography/driftdetect/cli.py +71 -75
- cartography/driftdetect/detect_deviations.py +7 -3
- cartography/driftdetect/get_states.py +20 -8
- cartography/driftdetect/model.py +5 -5
- cartography/driftdetect/serializers.py +8 -6
- cartography/driftdetect/storage.py +2 -2
- cartography/graph/cleanupbuilder.py +35 -15
- cartography/graph/job.py +46 -17
- cartography/graph/querybuilder.py +165 -80
- cartography/graph/statement.py +35 -26
- cartography/intel/analysis.py +4 -1
- cartography/intel/aws/__init__.py +114 -55
- cartography/intel/aws/apigateway.py +134 -63
- cartography/intel/aws/cloudtrail.py +127 -0
- cartography/intel/aws/config.py +56 -20
- cartography/intel/aws/dynamodb.py +108 -40
- cartography/intel/aws/ec2/__init__.py +2 -2
- cartography/intel/aws/ec2/auto_scaling_groups.py +181 -78
- cartography/intel/aws/ec2/elastic_ip_addresses.py +41 -13
- cartography/intel/aws/ec2/images.py +49 -20
- cartography/intel/aws/ec2/instances.py +234 -136
- cartography/intel/aws/ec2/internet_gateways.py +40 -11
- cartography/intel/aws/ec2/key_pairs.py +44 -20
- cartography/intel/aws/ec2/launch_templates.py +101 -59
- cartography/intel/aws/ec2/load_balancer_v2s.py +104 -39
- cartography/intel/aws/ec2/load_balancers.py +82 -42
- cartography/intel/aws/ec2/network_acls.py +89 -65
- cartography/intel/aws/ec2/network_interfaces.py +146 -87
- cartography/intel/aws/ec2/reserved_instances.py +45 -16
- cartography/intel/aws/ec2/route_tables.py +327 -0
- cartography/intel/aws/ec2/security_groups.py +71 -21
- cartography/intel/aws/ec2/snapshots.py +61 -22
- cartography/intel/aws/ec2/subnets.py +54 -18
- cartography/intel/aws/ec2/tgw.py +100 -34
- cartography/intel/aws/ec2/util.py +1 -1
- cartography/intel/aws/ec2/volumes.py +69 -41
- cartography/intel/aws/ec2/vpc.py +37 -12
- cartography/intel/aws/ec2/vpc_peerings.py +83 -24
- cartography/intel/aws/ecr.py +88 -32
- cartography/intel/aws/ecs.py +83 -47
- cartography/intel/aws/eks.py +55 -29
- cartography/intel/aws/elasticache.py +42 -18
- cartography/intel/aws/elasticsearch.py +57 -20
- cartography/intel/aws/emr.py +61 -23
- cartography/intel/aws/iam.py +401 -145
- cartography/intel/aws/iam_instance_profiles.py +22 -22
- cartography/intel/aws/identitycenter.py +71 -37
- cartography/intel/aws/inspector.py +159 -89
- cartography/intel/aws/kms.py +92 -38
- cartography/intel/aws/lambda_function.py +103 -34
- cartography/intel/aws/organizations.py +30 -10
- cartography/intel/aws/permission_relationships.py +133 -51
- cartography/intel/aws/rds.py +249 -85
- cartography/intel/aws/redshift.py +107 -46
- cartography/intel/aws/resourcegroupstaggingapi.py +120 -66
- cartography/intel/aws/resources.py +53 -44
- cartography/intel/aws/route53.py +108 -61
- cartography/intel/aws/s3.py +168 -83
- cartography/intel/aws/s3accountpublicaccessblock.py +157 -0
- cartography/intel/aws/secretsmanager.py +24 -12
- cartography/intel/aws/securityhub.py +20 -9
- cartography/intel/aws/sns.py +166 -0
- cartography/intel/aws/sqs.py +60 -28
- cartography/intel/aws/ssm.py +70 -30
- cartography/intel/aws/util/arns.py +7 -7
- cartography/intel/aws/util/common.py +31 -4
- cartography/intel/azure/__init__.py +78 -19
- cartography/intel/azure/compute.py +101 -27
- cartography/intel/azure/cosmosdb.py +496 -170
- cartography/intel/azure/sql.py +296 -105
- cartography/intel/azure/storage.py +322 -113
- cartography/intel/azure/subscription.py +39 -23
- cartography/intel/azure/tenant.py +13 -4
- cartography/intel/azure/util/credentials.py +95 -55
- cartography/intel/bigfix/__init__.py +2 -2
- cartography/intel/bigfix/computers.py +93 -65
- cartography/intel/create_indexes.py +3 -2
- cartography/intel/crowdstrike/__init__.py +11 -9
- cartography/intel/crowdstrike/endpoints.py +5 -1
- cartography/intel/crowdstrike/spotlight.py +8 -3
- cartography/intel/cve/__init__.py +46 -13
- cartography/intel/cve/feed.py +48 -12
- cartography/intel/digitalocean/__init__.py +22 -13
- cartography/intel/digitalocean/compute.py +75 -108
- cartography/intel/digitalocean/management.py +44 -80
- cartography/intel/digitalocean/platform.py +48 -43
- cartography/intel/dns.py +36 -10
- cartography/intel/duo/__init__.py +21 -16
- cartography/intel/duo/api_host.py +14 -9
- cartography/intel/duo/endpoints.py +50 -45
- cartography/intel/duo/groups.py +18 -14
- cartography/intel/duo/phones.py +37 -34
- cartography/intel/duo/tokens.py +26 -23
- cartography/intel/duo/users.py +54 -50
- cartography/intel/duo/web_authn_credentials.py +30 -25
- cartography/intel/entra/__init__.py +25 -7
- cartography/intel/entra/ou.py +112 -0
- cartography/intel/entra/users.py +69 -63
- cartography/intel/gcp/__init__.py +185 -49
- cartography/intel/gcp/compute.py +418 -231
- cartography/intel/gcp/crm.py +96 -43
- cartography/intel/gcp/dns.py +60 -19
- cartography/intel/gcp/gke.py +72 -38
- cartography/intel/gcp/iam.py +61 -41
- cartography/intel/gcp/storage.py +84 -55
- cartography/intel/github/__init__.py +13 -11
- cartography/intel/github/repos.py +270 -137
- cartography/intel/github/teams.py +170 -88
- cartography/intel/github/users.py +70 -39
- cartography/intel/github/util.py +36 -34
- cartography/intel/gsuite/__init__.py +47 -26
- cartography/intel/gsuite/api.py +73 -30
- cartography/intel/jamf/__init__.py +19 -1
- cartography/intel/jamf/computers.py +30 -7
- cartography/intel/jamf/util.py +7 -2
- cartography/intel/kandji/__init__.py +6 -3
- cartography/intel/kandji/devices.py +14 -8
- cartography/intel/kubernetes/namespaces.py +7 -4
- cartography/intel/kubernetes/pods.py +7 -4
- cartography/intel/kubernetes/services.py +8 -4
- cartography/intel/lastpass/__init__.py +2 -2
- cartography/intel/lastpass/users.py +23 -12
- cartography/intel/oci/__init__.py +44 -11
- cartography/intel/oci/iam.py +134 -38
- cartography/intel/oci/organizations.py +13 -6
- cartography/intel/oci/utils.py +43 -20
- cartography/intel/okta/__init__.py +66 -15
- cartography/intel/okta/applications.py +42 -20
- cartography/intel/okta/awssaml.py +93 -33
- cartography/intel/okta/factors.py +16 -4
- cartography/intel/okta/groups.py +56 -29
- cartography/intel/okta/organization.py +5 -1
- cartography/intel/okta/origins.py +6 -2
- cartography/intel/okta/roles.py +15 -5
- cartography/intel/okta/users.py +20 -8
- cartography/intel/okta/utils.py +6 -4
- cartography/intel/pagerduty/__init__.py +8 -7
- cartography/intel/pagerduty/escalation_policies.py +18 -6
- cartography/intel/pagerduty/schedules.py +12 -4
- cartography/intel/pagerduty/services.py +11 -4
- cartography/intel/pagerduty/teams.py +8 -3
- cartography/intel/pagerduty/users.py +3 -1
- cartography/intel/pagerduty/vendors.py +3 -1
- cartography/intel/semgrep/__init__.py +24 -6
- cartography/intel/semgrep/dependencies.py +50 -28
- cartography/intel/semgrep/deployment.py +3 -1
- cartography/intel/semgrep/findings.py +42 -18
- cartography/intel/snipeit/__init__.py +17 -3
- cartography/intel/snipeit/asset.py +12 -6
- cartography/intel/snipeit/user.py +8 -5
- cartography/intel/snipeit/util.py +9 -4
- cartography/models/aws/apigateway.py +21 -17
- cartography/models/aws/apigatewaycertificate.py +28 -22
- cartography/models/aws/apigatewayresource.py +28 -20
- cartography/models/aws/apigatewaystage.py +33 -25
- cartography/models/aws/cloudtrail/__init__.py +0 -0
- cartography/models/aws/cloudtrail/trail.py +61 -0
- cartography/models/aws/dynamodb/gsi.py +30 -22
- cartography/models/aws/dynamodb/tables.py +25 -17
- cartography/models/aws/ec2/auto_scaling_groups.py +102 -82
- cartography/models/aws/ec2/images.py +36 -34
- cartography/models/aws/ec2/instances.py +51 -45
- cartography/models/aws/ec2/keypair.py +21 -16
- cartography/models/aws/ec2/keypair_instance.py +28 -21
- cartography/models/aws/ec2/launch_configurations.py +30 -26
- cartography/models/aws/ec2/launch_template_versions.py +48 -38
- cartography/models/aws/ec2/launch_templates.py +21 -17
- cartography/models/aws/ec2/load_balancer_listeners.py +27 -23
- cartography/models/aws/ec2/load_balancers.py +47 -37
- cartography/models/aws/ec2/network_acl_rules.py +38 -30
- cartography/models/aws/ec2/network_acls.py +38 -29
- cartography/models/aws/ec2/networkinterface_instance.py +52 -39
- cartography/models/aws/ec2/networkinterfaces.py +53 -37
- cartography/models/aws/ec2/privateip_networkinterface.py +32 -22
- cartography/models/aws/ec2/reservations.py +18 -14
- cartography/models/aws/ec2/route_table_associations.py +97 -0
- cartography/models/aws/ec2/route_tables.py +128 -0
- cartography/models/aws/ec2/routes.py +85 -0
- cartography/models/aws/ec2/securitygroup_instance.py +29 -20
- cartography/models/aws/ec2/securitygroup_networkinterface.py +24 -15
- cartography/models/aws/ec2/subnet_instance.py +24 -19
- cartography/models/aws/ec2/subnet_networkinterface.py +40 -31
- cartography/models/aws/ec2/volumes.py +47 -40
- cartography/models/aws/eks/clusters.py +23 -21
- cartography/models/aws/emr.py +32 -30
- cartography/models/aws/iam/instanceprofile.py +33 -24
- cartography/models/aws/identitycenter/awsidentitycenter.py +18 -14
- cartography/models/aws/identitycenter/awspermissionset.py +37 -29
- cartography/models/aws/identitycenter/awsssouser.py +23 -21
- cartography/models/aws/inspector/findings.py +77 -65
- cartography/models/aws/inspector/packages.py +35 -29
- cartography/models/aws/s3/__init__.py +0 -0
- cartography/models/aws/s3/account_public_access_block.py +51 -0
- cartography/models/aws/sns/__init__.py +0 -0
- cartography/models/aws/sns/topic.py +50 -0
- cartography/models/aws/ssm/instance_information.py +51 -39
- cartography/models/aws/ssm/instance_patch.py +32 -26
- cartography/models/bigfix/bigfix_computer.py +42 -38
- cartography/models/bigfix/bigfix_root.py +3 -3
- cartography/models/core/common.py +12 -10
- cartography/models/core/nodes.py +5 -2
- cartography/models/core/relationships.py +14 -6
- cartography/models/crowdstrike/hosts.py +37 -35
- cartography/models/cve/cve.py +34 -32
- cartography/models/cve/cve_feed.py +6 -6
- cartography/models/digitalocean/__init__.py +0 -0
- cartography/models/digitalocean/account.py +21 -0
- cartography/models/digitalocean/droplet.py +56 -0
- cartography/models/digitalocean/project.py +48 -0
- cartography/models/duo/api_host.py +3 -3
- cartography/models/duo/endpoint.py +43 -41
- cartography/models/duo/group.py +14 -14
- cartography/models/duo/phone.py +27 -27
- cartography/models/duo/token.py +16 -16
- cartography/models/duo/user.py +46 -44
- cartography/models/duo/web_authn_credential.py +27 -19
- cartography/models/entra/ou.py +48 -0
- cartography/models/entra/tenant.py +24 -18
- cartography/models/entra/user.py +64 -48
- cartography/models/gcp/iam.py +23 -23
- cartography/models/github/orgs.py +5 -4
- cartography/models/github/teams.py +37 -31
- cartography/models/github/users.py +34 -23
- cartography/models/kandji/device.py +22 -16
- cartography/models/kandji/tenant.py +6 -4
- cartography/models/lastpass/tenant.py +3 -3
- cartography/models/lastpass/user.py +32 -28
- cartography/models/semgrep/dependencies.py +36 -24
- cartography/models/semgrep/deployment.py +5 -5
- cartography/models/semgrep/findings.py +58 -42
- cartography/models/semgrep/locations.py +27 -21
- cartography/models/snipeit/asset.py +30 -21
- cartography/models/snipeit/tenant.py +6 -4
- cartography/models/snipeit/user.py +19 -12
- cartography/stats.py +3 -3
- cartography/sync.py +107 -31
- cartography/util.py +84 -62
- {cartography-0.102.0rc1.dist-info → cartography-0.103.0rc1.dist-info}/METADATA +3 -14
- cartography-0.103.0rc1.dist-info/RECORD +396 -0
- {cartography-0.102.0rc1.dist-info → cartography-0.103.0rc1.dist-info}/WHEEL +1 -1
- cartography-0.102.0rc1.dist-info/RECORD +0 -377
- {cartography-0.102.0rc1.dist-info → cartography-0.103.0rc1.dist-info}/entry_points.txt +0 -0
- {cartography-0.102.0rc1.dist-info → cartography-0.103.0rc1.dist-info}/licenses/LICENSE +0 -0
- {cartography-0.102.0rc1.dist-info → cartography-0.103.0rc1.dist-info}/top_level.txt +0 -0
|
@@ -11,15 +11,19 @@ from azure.core.exceptions import HttpResponseError
|
|
|
11
11
|
from azure.core.exceptions import ResourceNotFoundError
|
|
12
12
|
from azure.mgmt.storage import StorageManagementClient
|
|
13
13
|
|
|
14
|
-
from .util.credentials import Credentials
|
|
15
14
|
from cartography.util import run_cleanup_job
|
|
16
15
|
from cartography.util import timeit
|
|
17
16
|
|
|
17
|
+
from .util.credentials import Credentials
|
|
18
|
+
|
|
18
19
|
logger = logging.getLogger(__name__)
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
@timeit
|
|
22
|
-
def get_client(
|
|
23
|
+
def get_client(
|
|
24
|
+
credentials: Credentials,
|
|
25
|
+
subscription_id: str,
|
|
26
|
+
) -> StorageManagementClient:
|
|
23
27
|
"""
|
|
24
28
|
Getting the Azure Storage client
|
|
25
29
|
"""
|
|
@@ -28,17 +32,24 @@ def get_client(credentials: Credentials, subscription_id: str) -> StorageManagem
|
|
|
28
32
|
|
|
29
33
|
|
|
30
34
|
@timeit
|
|
31
|
-
def get_storage_account_list(
|
|
35
|
+
def get_storage_account_list(
|
|
36
|
+
credentials: Credentials,
|
|
37
|
+
subscription_id: str,
|
|
38
|
+
) -> List[Dict]:
|
|
32
39
|
"""
|
|
33
40
|
Getting the list of storage accounts
|
|
34
41
|
"""
|
|
35
42
|
try:
|
|
36
43
|
client = get_client(credentials, subscription_id)
|
|
37
|
-
storage_account_list = list(
|
|
44
|
+
storage_account_list = list(
|
|
45
|
+
map(lambda x: x.as_dict(), client.storage_accounts.list()),
|
|
46
|
+
)
|
|
38
47
|
|
|
39
48
|
# ClientAuthenticationError and ResourceNotFoundError are subclasses under HttpResponseError
|
|
40
49
|
except ClientAuthenticationError as e:
|
|
41
|
-
logger.warning(
|
|
50
|
+
logger.warning(
|
|
51
|
+
f"Client Authentication Error while retrieving storage accounts - {e}",
|
|
52
|
+
)
|
|
42
53
|
return []
|
|
43
54
|
except ResourceNotFoundError as e:
|
|
44
55
|
logger.warning(f"Storage Account not found error - {e}")
|
|
@@ -48,16 +59,18 @@ def get_storage_account_list(credentials: Credentials, subscription_id: str) ->
|
|
|
48
59
|
return []
|
|
49
60
|
|
|
50
61
|
for storage_account in storage_account_list:
|
|
51
|
-
x = storage_account[
|
|
52
|
-
storage_account[
|
|
62
|
+
x = storage_account["id"].split("/")
|
|
63
|
+
storage_account["resourceGroup"] = x[x.index("resourceGroups") + 1]
|
|
53
64
|
|
|
54
65
|
return storage_account_list
|
|
55
66
|
|
|
56
67
|
|
|
57
68
|
@timeit
|
|
58
69
|
def load_storage_account_data(
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
neo4j_session: neo4j.Session,
|
|
71
|
+
subscription_id: str,
|
|
72
|
+
storage_account_list: List[Dict],
|
|
73
|
+
azure_update_tag: int,
|
|
61
74
|
) -> None:
|
|
62
75
|
"""
|
|
63
76
|
Ingest Storage Account details into neo4j.
|
|
@@ -96,43 +109,73 @@ def load_storage_account_data(
|
|
|
96
109
|
|
|
97
110
|
@timeit
|
|
98
111
|
def sync_storage_account_details(
|
|
99
|
-
|
|
100
|
-
|
|
112
|
+
neo4j_session: neo4j.Session,
|
|
113
|
+
credentials: Credentials,
|
|
114
|
+
subscription_id: str,
|
|
115
|
+
storage_account_list: List[Dict],
|
|
116
|
+
sync_tag: int,
|
|
101
117
|
) -> None:
|
|
102
|
-
details = get_storage_account_details(
|
|
103
|
-
|
|
118
|
+
details = get_storage_account_details(
|
|
119
|
+
credentials,
|
|
120
|
+
subscription_id,
|
|
121
|
+
storage_account_list,
|
|
122
|
+
)
|
|
123
|
+
load_storage_account_details(
|
|
124
|
+
neo4j_session,
|
|
125
|
+
credentials,
|
|
126
|
+
subscription_id,
|
|
127
|
+
details,
|
|
128
|
+
sync_tag,
|
|
129
|
+
)
|
|
104
130
|
|
|
105
131
|
|
|
106
132
|
@timeit
|
|
107
133
|
def get_storage_account_details(
|
|
108
|
-
|
|
134
|
+
credentials: Credentials,
|
|
135
|
+
subscription_id: str,
|
|
136
|
+
storage_account_list: List[Dict],
|
|
109
137
|
) -> Generator[Any, Any, Any]:
|
|
110
138
|
"""
|
|
111
139
|
Iterates over all Storage Accounts to get the different storage services.
|
|
112
140
|
"""
|
|
113
141
|
for storage_account in storage_account_list:
|
|
114
|
-
queue_services = get_queue_services(
|
|
115
|
-
|
|
142
|
+
queue_services = get_queue_services(
|
|
143
|
+
credentials,
|
|
144
|
+
subscription_id,
|
|
145
|
+
storage_account,
|
|
146
|
+
)
|
|
147
|
+
table_services = get_table_services(
|
|
148
|
+
credentials,
|
|
149
|
+
subscription_id,
|
|
150
|
+
storage_account,
|
|
151
|
+
)
|
|
116
152
|
file_services = get_file_services(credentials, subscription_id, storage_account)
|
|
117
153
|
blob_services = get_blob_services(credentials, subscription_id, storage_account)
|
|
118
|
-
yield storage_account[
|
|
119
|
-
|
|
154
|
+
yield storage_account["id"], storage_account["name"], storage_account[
|
|
155
|
+
"resourceGroup"
|
|
120
156
|
], queue_services, table_services, file_services, blob_services
|
|
121
157
|
|
|
122
158
|
|
|
123
159
|
@timeit
|
|
124
|
-
def get_queue_services(
|
|
160
|
+
def get_queue_services(
|
|
161
|
+
credentials: Credentials,
|
|
162
|
+
subscription_id: str,
|
|
163
|
+
storage_account: Dict,
|
|
164
|
+
) -> List[Dict]:
|
|
125
165
|
"""
|
|
126
166
|
Gets the list of queue services.
|
|
127
167
|
"""
|
|
128
168
|
try:
|
|
129
169
|
client = get_client(credentials, subscription_id)
|
|
130
170
|
queue_service_list = client.queue_services.list(
|
|
131
|
-
storage_account[
|
|
132
|
-
|
|
171
|
+
storage_account["resourceGroup"],
|
|
172
|
+
storage_account["name"],
|
|
173
|
+
).as_dict()["value"]
|
|
133
174
|
|
|
134
175
|
except ClientAuthenticationError as e:
|
|
135
|
-
logger.warning(
|
|
176
|
+
logger.warning(
|
|
177
|
+
f"Client Authentication Error while retrieving queue services - {e}",
|
|
178
|
+
)
|
|
136
179
|
return []
|
|
137
180
|
except ResourceNotFoundError as e:
|
|
138
181
|
logger.warning(f"Queue services resource not found error - {e}")
|
|
@@ -145,18 +188,25 @@ def get_queue_services(credentials: Credentials, subscription_id: str, storage_a
|
|
|
145
188
|
|
|
146
189
|
|
|
147
190
|
@timeit
|
|
148
|
-
def get_table_services(
|
|
191
|
+
def get_table_services(
|
|
192
|
+
credentials: Credentials,
|
|
193
|
+
subscription_id: str,
|
|
194
|
+
storage_account: Dict,
|
|
195
|
+
) -> List[Dict]:
|
|
149
196
|
"""
|
|
150
197
|
Gets the list of table services.
|
|
151
198
|
"""
|
|
152
199
|
try:
|
|
153
200
|
client = get_client(credentials, subscription_id)
|
|
154
201
|
table_service_list = client.table_services.list(
|
|
155
|
-
storage_account[
|
|
156
|
-
|
|
202
|
+
storage_account["resourceGroup"],
|
|
203
|
+
storage_account["name"],
|
|
204
|
+
).as_dict()["value"]
|
|
157
205
|
|
|
158
206
|
except ClientAuthenticationError as e:
|
|
159
|
-
logger.warning(
|
|
207
|
+
logger.warning(
|
|
208
|
+
f"Client Authentication Error while retrieving table services - {e}",
|
|
209
|
+
)
|
|
160
210
|
return []
|
|
161
211
|
except ResourceNotFoundError as e:
|
|
162
212
|
logger.warning(f"Table services resource not found error - {e}")
|
|
@@ -169,18 +219,25 @@ def get_table_services(credentials: Credentials, subscription_id: str, storage_a
|
|
|
169
219
|
|
|
170
220
|
|
|
171
221
|
@timeit
|
|
172
|
-
def get_file_services(
|
|
222
|
+
def get_file_services(
|
|
223
|
+
credentials: Credentials,
|
|
224
|
+
subscription_id: str,
|
|
225
|
+
storage_account: Dict,
|
|
226
|
+
) -> List[Dict]:
|
|
173
227
|
"""
|
|
174
228
|
Gets the list of file services.
|
|
175
229
|
"""
|
|
176
230
|
try:
|
|
177
231
|
client = get_client(credentials, subscription_id)
|
|
178
232
|
file_service_list = client.file_services.list(
|
|
179
|
-
storage_account[
|
|
180
|
-
|
|
233
|
+
storage_account["resourceGroup"],
|
|
234
|
+
storage_account["name"],
|
|
235
|
+
).as_dict()["value"]
|
|
181
236
|
|
|
182
237
|
except ClientAuthenticationError as e:
|
|
183
|
-
logger.warning(
|
|
238
|
+
logger.warning(
|
|
239
|
+
f"Client Authentication Error while retrieving file services - {e}",
|
|
240
|
+
)
|
|
184
241
|
return []
|
|
185
242
|
except ResourceNotFoundError as e:
|
|
186
243
|
logger.warning(f"File services resource not found error - {e}")
|
|
@@ -193,7 +250,11 @@ def get_file_services(credentials: Credentials, subscription_id: str, storage_ac
|
|
|
193
250
|
|
|
194
251
|
|
|
195
252
|
@timeit
|
|
196
|
-
def get_blob_services(
|
|
253
|
+
def get_blob_services(
|
|
254
|
+
credentials: Credentials,
|
|
255
|
+
subscription_id: str,
|
|
256
|
+
storage_account: Dict,
|
|
257
|
+
) -> List[Dict]:
|
|
197
258
|
"""
|
|
198
259
|
Gets the list of blob services.
|
|
199
260
|
"""
|
|
@@ -201,15 +262,18 @@ def get_blob_services(credentials: Credentials, subscription_id: str, storage_ac
|
|
|
201
262
|
client = get_client(credentials, subscription_id)
|
|
202
263
|
blob_service_list = list(
|
|
203
264
|
map(
|
|
204
|
-
lambda x: x.as_dict(),
|
|
205
|
-
|
|
206
|
-
storage_account[
|
|
265
|
+
lambda x: x.as_dict(),
|
|
266
|
+
client.blob_services.list(
|
|
267
|
+
storage_account["resourceGroup"],
|
|
268
|
+
storage_account["name"],
|
|
207
269
|
),
|
|
208
270
|
),
|
|
209
271
|
)
|
|
210
272
|
|
|
211
273
|
except ClientAuthenticationError as e:
|
|
212
|
-
logger.warning(
|
|
274
|
+
logger.warning(
|
|
275
|
+
f"Client Authentication Error while retrieving blob services - {e}",
|
|
276
|
+
)
|
|
213
277
|
return []
|
|
214
278
|
except ResourceNotFoundError as e:
|
|
215
279
|
logger.warning(f"Blob services resource not found error - {e}")
|
|
@@ -223,8 +287,11 @@ def get_blob_services(credentials: Credentials, subscription_id: str, storage_ac
|
|
|
223
287
|
|
|
224
288
|
@timeit
|
|
225
289
|
def load_storage_account_details(
|
|
226
|
-
|
|
227
|
-
|
|
290
|
+
neo4j_session: neo4j.Session,
|
|
291
|
+
credentials: Credentials,
|
|
292
|
+
subscription_id: str,
|
|
293
|
+
details: List[Tuple[Any, Any, Any, Any, Any, Any, Any]],
|
|
294
|
+
update_tag: int,
|
|
228
295
|
) -> None:
|
|
229
296
|
"""
|
|
230
297
|
Create dictionaries for every Azure storage service so we can import them in a single query
|
|
@@ -234,33 +301,41 @@ def load_storage_account_details(
|
|
|
234
301
|
file_services: List[Dict] = []
|
|
235
302
|
blob_services: List[Dict] = []
|
|
236
303
|
|
|
237
|
-
for
|
|
304
|
+
for (
|
|
305
|
+
account_id,
|
|
306
|
+
name,
|
|
307
|
+
resourceGroup,
|
|
308
|
+
queue_service,
|
|
309
|
+
table_service,
|
|
310
|
+
file_service,
|
|
311
|
+
blob_service,
|
|
312
|
+
) in details:
|
|
238
313
|
if len(queue_service) > 0:
|
|
239
314
|
for service in queue_service:
|
|
240
|
-
service[
|
|
241
|
-
service[
|
|
242
|
-
service[
|
|
315
|
+
service["storage_account_name"] = name
|
|
316
|
+
service["storage_account_id"] = account_id
|
|
317
|
+
service["resource_group_name"] = resourceGroup
|
|
243
318
|
queue_services.extend(queue_service)
|
|
244
319
|
|
|
245
320
|
if len(table_service) > 0:
|
|
246
321
|
for service in table_service:
|
|
247
|
-
service[
|
|
248
|
-
service[
|
|
249
|
-
service[
|
|
322
|
+
service["storage_account_name"] = name
|
|
323
|
+
service["storage_account_id"] = account_id
|
|
324
|
+
service["resource_group_name"] = resourceGroup
|
|
250
325
|
table_services.extend(table_service)
|
|
251
326
|
|
|
252
327
|
if len(file_service) > 0:
|
|
253
328
|
for service in file_service:
|
|
254
|
-
service[
|
|
255
|
-
service[
|
|
256
|
-
service[
|
|
329
|
+
service["storage_account_name"] = name
|
|
330
|
+
service["storage_account_id"] = account_id
|
|
331
|
+
service["resource_group_name"] = resourceGroup
|
|
257
332
|
file_services.extend(file_service)
|
|
258
333
|
|
|
259
334
|
if len(blob_service) > 0:
|
|
260
335
|
for service in blob_service:
|
|
261
|
-
service[
|
|
262
|
-
service[
|
|
263
|
-
service[
|
|
336
|
+
service["storage_account_name"] = name
|
|
337
|
+
service["storage_account_id"] = account_id
|
|
338
|
+
service["resource_group_name"] = resourceGroup
|
|
264
339
|
blob_services.extend(blob_service)
|
|
265
340
|
|
|
266
341
|
_load_queue_services(neo4j_session, queue_services, update_tag)
|
|
@@ -268,15 +343,41 @@ def load_storage_account_details(
|
|
|
268
343
|
_load_file_services(neo4j_session, file_services, update_tag)
|
|
269
344
|
_load_blob_services(neo4j_session, blob_services, update_tag)
|
|
270
345
|
|
|
271
|
-
sync_queue_services_details(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
346
|
+
sync_queue_services_details(
|
|
347
|
+
neo4j_session,
|
|
348
|
+
credentials,
|
|
349
|
+
subscription_id,
|
|
350
|
+
queue_services,
|
|
351
|
+
update_tag,
|
|
352
|
+
)
|
|
353
|
+
sync_table_services_details(
|
|
354
|
+
neo4j_session,
|
|
355
|
+
credentials,
|
|
356
|
+
subscription_id,
|
|
357
|
+
table_services,
|
|
358
|
+
update_tag,
|
|
359
|
+
)
|
|
360
|
+
sync_file_services_details(
|
|
361
|
+
neo4j_session,
|
|
362
|
+
credentials,
|
|
363
|
+
subscription_id,
|
|
364
|
+
file_services,
|
|
365
|
+
update_tag,
|
|
366
|
+
)
|
|
367
|
+
sync_blob_services_details(
|
|
368
|
+
neo4j_session,
|
|
369
|
+
credentials,
|
|
370
|
+
subscription_id,
|
|
371
|
+
blob_services,
|
|
372
|
+
update_tag,
|
|
373
|
+
)
|
|
275
374
|
|
|
276
375
|
|
|
277
376
|
@timeit
|
|
278
377
|
def _load_queue_services(
|
|
279
|
-
|
|
378
|
+
neo4j_session: neo4j.Session,
|
|
379
|
+
queue_services: List[Dict],
|
|
380
|
+
update_tag: int,
|
|
280
381
|
) -> None:
|
|
281
382
|
"""
|
|
282
383
|
Ingest Queue Service details into neo4j.
|
|
@@ -303,7 +404,9 @@ def _load_queue_services(
|
|
|
303
404
|
|
|
304
405
|
@timeit
|
|
305
406
|
def _load_table_services(
|
|
306
|
-
|
|
407
|
+
neo4j_session: neo4j.Session,
|
|
408
|
+
table_services: List[Dict],
|
|
409
|
+
update_tag: int,
|
|
307
410
|
) -> None:
|
|
308
411
|
"""
|
|
309
412
|
Ingest Table Service details into neo4j.
|
|
@@ -330,7 +433,9 @@ def _load_table_services(
|
|
|
330
433
|
|
|
331
434
|
@timeit
|
|
332
435
|
def _load_file_services(
|
|
333
|
-
|
|
436
|
+
neo4j_session: neo4j.Session,
|
|
437
|
+
file_services: List[Dict],
|
|
438
|
+
update_tag: int,
|
|
334
439
|
) -> None:
|
|
335
440
|
"""
|
|
336
441
|
Ingest File Service details into neo4j.
|
|
@@ -357,7 +462,9 @@ def _load_file_services(
|
|
|
357
462
|
|
|
358
463
|
@timeit
|
|
359
464
|
def _load_blob_services(
|
|
360
|
-
|
|
465
|
+
neo4j_session: neo4j.Session,
|
|
466
|
+
blob_services: List[Dict],
|
|
467
|
+
update_tag: int,
|
|
361
468
|
) -> None:
|
|
362
469
|
"""
|
|
363
470
|
Ingest Blob Service details into neo4j.
|
|
@@ -384,27 +491,40 @@ def _load_blob_services(
|
|
|
384
491
|
|
|
385
492
|
@timeit
|
|
386
493
|
def sync_queue_services_details(
|
|
387
|
-
|
|
388
|
-
|
|
494
|
+
neo4j_session: neo4j.Session,
|
|
495
|
+
credentials: Credentials,
|
|
496
|
+
subscription_id: str,
|
|
497
|
+
queue_services: List[Dict],
|
|
498
|
+
update_tag: int,
|
|
389
499
|
) -> None:
|
|
390
|
-
queue_services_details = get_queue_services_details(
|
|
500
|
+
queue_services_details = get_queue_services_details(
|
|
501
|
+
credentials,
|
|
502
|
+
subscription_id,
|
|
503
|
+
queue_services,
|
|
504
|
+
)
|
|
391
505
|
load_queue_services_details(neo4j_session, queue_services_details, update_tag)
|
|
392
506
|
|
|
393
507
|
|
|
394
508
|
@timeit
|
|
395
509
|
def get_queue_services_details(
|
|
396
|
-
|
|
510
|
+
credentials: Credentials,
|
|
511
|
+
subscription_id: str,
|
|
512
|
+
queue_services: List[Dict],
|
|
397
513
|
) -> Generator[Any, Any, Any]:
|
|
398
514
|
"""
|
|
399
515
|
Returning the queues with their respective queue service id.
|
|
400
516
|
"""
|
|
401
517
|
for queue_service in queue_services:
|
|
402
518
|
queues = get_queues(credentials, subscription_id, queue_service)
|
|
403
|
-
yield queue_service[
|
|
519
|
+
yield queue_service["id"], queues
|
|
404
520
|
|
|
405
521
|
|
|
406
522
|
@timeit
|
|
407
|
-
def get_queues(
|
|
523
|
+
def get_queues(
|
|
524
|
+
credentials: Credentials,
|
|
525
|
+
subscription_id: str,
|
|
526
|
+
queue_service: Dict,
|
|
527
|
+
) -> List[Dict]:
|
|
408
528
|
"""
|
|
409
529
|
Getting the queues from the queue service.
|
|
410
530
|
"""
|
|
@@ -412,9 +532,10 @@ def get_queues(credentials: Credentials, subscription_id: str, queue_service: Di
|
|
|
412
532
|
client = get_client(credentials, subscription_id)
|
|
413
533
|
queues = list(
|
|
414
534
|
map(
|
|
415
|
-
lambda x: x.as_dict(),
|
|
416
|
-
|
|
417
|
-
queue_service[
|
|
535
|
+
lambda x: x.as_dict(),
|
|
536
|
+
client.queue.list(
|
|
537
|
+
queue_service["resource_group_name"],
|
|
538
|
+
queue_service["storage_account_name"],
|
|
418
539
|
),
|
|
419
540
|
),
|
|
420
541
|
)
|
|
@@ -434,7 +555,9 @@ def get_queues(credentials: Credentials, subscription_id: str, queue_service: Di
|
|
|
434
555
|
|
|
435
556
|
@timeit
|
|
436
557
|
def load_queue_services_details(
|
|
437
|
-
|
|
558
|
+
neo4j_session: neo4j.Session,
|
|
559
|
+
details: List[Tuple[Any, Any]],
|
|
560
|
+
update_tag: int,
|
|
438
561
|
) -> None:
|
|
439
562
|
"""
|
|
440
563
|
Create dictionary for the queue so we can import them in a single query
|
|
@@ -444,14 +567,18 @@ def load_queue_services_details(
|
|
|
444
567
|
for queue_service_id, queue in details:
|
|
445
568
|
if len(queue) > 0:
|
|
446
569
|
for q in queue:
|
|
447
|
-
q[
|
|
570
|
+
q["service_id"] = queue_service_id
|
|
448
571
|
queues.extend(queue)
|
|
449
572
|
|
|
450
573
|
_load_queues(neo4j_session, queues, update_tag)
|
|
451
574
|
|
|
452
575
|
|
|
453
576
|
@timeit
|
|
454
|
-
def _load_queues(
|
|
577
|
+
def _load_queues(
|
|
578
|
+
neo4j_session: neo4j.Session,
|
|
579
|
+
queues: List[Dict],
|
|
580
|
+
update_tag: int,
|
|
581
|
+
) -> None:
|
|
455
582
|
"""
|
|
456
583
|
Ingest Queue details into neo4j.
|
|
457
584
|
"""
|
|
@@ -477,27 +604,40 @@ def _load_queues(neo4j_session: neo4j.Session, queues: List[Dict], update_tag: i
|
|
|
477
604
|
|
|
478
605
|
@timeit
|
|
479
606
|
def sync_table_services_details(
|
|
480
|
-
|
|
481
|
-
|
|
607
|
+
neo4j_session: neo4j.Session,
|
|
608
|
+
credentials: Credentials,
|
|
609
|
+
subscription_id: str,
|
|
610
|
+
table_services: List[Dict],
|
|
611
|
+
update_tag: int,
|
|
482
612
|
) -> None:
|
|
483
|
-
table_services_details = get_table_services_details(
|
|
613
|
+
table_services_details = get_table_services_details(
|
|
614
|
+
credentials,
|
|
615
|
+
subscription_id,
|
|
616
|
+
table_services,
|
|
617
|
+
)
|
|
484
618
|
load_table_services_details(neo4j_session, table_services_details, update_tag)
|
|
485
619
|
|
|
486
620
|
|
|
487
621
|
@timeit
|
|
488
622
|
def get_table_services_details(
|
|
489
|
-
|
|
623
|
+
credentials: Credentials,
|
|
624
|
+
subscription_id: str,
|
|
625
|
+
table_services: List[Dict],
|
|
490
626
|
) -> Generator[Any, Any, Any]:
|
|
491
627
|
"""
|
|
492
628
|
Returning the tables with their respective table service id.
|
|
493
629
|
"""
|
|
494
630
|
for table_service in table_services:
|
|
495
631
|
tables = get_tables(credentials, subscription_id, table_service)
|
|
496
|
-
yield table_service[
|
|
632
|
+
yield table_service["id"], tables
|
|
497
633
|
|
|
498
634
|
|
|
499
635
|
@timeit
|
|
500
|
-
def get_tables(
|
|
636
|
+
def get_tables(
|
|
637
|
+
credentials: Credentials,
|
|
638
|
+
subscription_id: str,
|
|
639
|
+
table_service: Dict,
|
|
640
|
+
) -> List[Dict]:
|
|
501
641
|
"""
|
|
502
642
|
Getting the tables from the table service.
|
|
503
643
|
"""
|
|
@@ -505,9 +645,10 @@ def get_tables(credentials: Credentials, subscription_id: str, table_service: Di
|
|
|
505
645
|
client = get_client(credentials, subscription_id)
|
|
506
646
|
tables = list(
|
|
507
647
|
map(
|
|
508
|
-
lambda x: x.as_dict(),
|
|
509
|
-
|
|
510
|
-
table_service[
|
|
648
|
+
lambda x: x.as_dict(),
|
|
649
|
+
client.table.list(
|
|
650
|
+
table_service["resource_group_name"],
|
|
651
|
+
table_service["storage_account_name"],
|
|
511
652
|
),
|
|
512
653
|
),
|
|
513
654
|
)
|
|
@@ -527,7 +668,9 @@ def get_tables(credentials: Credentials, subscription_id: str, table_service: Di
|
|
|
527
668
|
|
|
528
669
|
@timeit
|
|
529
670
|
def load_table_services_details(
|
|
530
|
-
|
|
671
|
+
neo4j_session: neo4j.Session,
|
|
672
|
+
details: List[Tuple[Any, Any]],
|
|
673
|
+
update_tag: int,
|
|
531
674
|
) -> None:
|
|
532
675
|
"""
|
|
533
676
|
Create dictionary for the table so we can import them in a single query
|
|
@@ -537,14 +680,18 @@ def load_table_services_details(
|
|
|
537
680
|
for table_service_id, table in details:
|
|
538
681
|
if len(table) > 0:
|
|
539
682
|
for t in table:
|
|
540
|
-
t[
|
|
683
|
+
t["service_id"] = table_service_id
|
|
541
684
|
tables.extend(table)
|
|
542
685
|
|
|
543
686
|
_load_tables(neo4j_session, tables, update_tag)
|
|
544
687
|
|
|
545
688
|
|
|
546
689
|
@timeit
|
|
547
|
-
def _load_tables(
|
|
690
|
+
def _load_tables(
|
|
691
|
+
neo4j_session: neo4j.Session,
|
|
692
|
+
tables: List[Dict],
|
|
693
|
+
update_tag: int,
|
|
694
|
+
) -> None:
|
|
548
695
|
"""
|
|
549
696
|
Ingest Table details into neo4j.
|
|
550
697
|
"""
|
|
@@ -571,27 +718,40 @@ def _load_tables(neo4j_session: neo4j.Session, tables: List[Dict], update_tag: i
|
|
|
571
718
|
|
|
572
719
|
@timeit
|
|
573
720
|
def sync_file_services_details(
|
|
574
|
-
|
|
575
|
-
|
|
721
|
+
neo4j_session: neo4j.Session,
|
|
722
|
+
credentials: Credentials,
|
|
723
|
+
subscription_id: str,
|
|
724
|
+
file_services: List[Dict],
|
|
725
|
+
update_tag: int,
|
|
576
726
|
) -> None:
|
|
577
|
-
file_services_details = get_file_services_details(
|
|
727
|
+
file_services_details = get_file_services_details(
|
|
728
|
+
credentials,
|
|
729
|
+
subscription_id,
|
|
730
|
+
file_services,
|
|
731
|
+
)
|
|
578
732
|
load_file_services_details(neo4j_session, file_services_details, update_tag)
|
|
579
733
|
|
|
580
734
|
|
|
581
735
|
@timeit
|
|
582
736
|
def get_file_services_details(
|
|
583
|
-
|
|
737
|
+
credentials: Credentials,
|
|
738
|
+
subscription_id: str,
|
|
739
|
+
file_services: List[Dict],
|
|
584
740
|
) -> Generator[Any, Any, Any]:
|
|
585
741
|
"""
|
|
586
742
|
Returning the shares with their respective file service id.
|
|
587
743
|
"""
|
|
588
744
|
for file_service in file_services:
|
|
589
745
|
shares = get_shares(credentials, subscription_id, file_service)
|
|
590
|
-
yield file_service[
|
|
746
|
+
yield file_service["id"], shares
|
|
591
747
|
|
|
592
748
|
|
|
593
749
|
@timeit
|
|
594
|
-
def get_shares(
|
|
750
|
+
def get_shares(
|
|
751
|
+
credentials: Credentials,
|
|
752
|
+
subscription_id: str,
|
|
753
|
+
file_service: Dict,
|
|
754
|
+
) -> List[Dict]:
|
|
595
755
|
"""
|
|
596
756
|
Getting the shares from the file service.
|
|
597
757
|
"""
|
|
@@ -599,9 +759,10 @@ def get_shares(credentials: Credentials, subscription_id: str, file_service: Dic
|
|
|
599
759
|
client = get_client(credentials, subscription_id)
|
|
600
760
|
shares = list(
|
|
601
761
|
map(
|
|
602
|
-
lambda x: x.as_dict(),
|
|
603
|
-
|
|
604
|
-
file_service[
|
|
762
|
+
lambda x: x.as_dict(),
|
|
763
|
+
client.file_shares.list(
|
|
764
|
+
file_service["resource_group_name"],
|
|
765
|
+
file_service["storage_account_name"],
|
|
605
766
|
),
|
|
606
767
|
),
|
|
607
768
|
)
|
|
@@ -621,7 +782,9 @@ def get_shares(credentials: Credentials, subscription_id: str, file_service: Dic
|
|
|
621
782
|
|
|
622
783
|
@timeit
|
|
623
784
|
def load_file_services_details(
|
|
624
|
-
|
|
785
|
+
neo4j_session: neo4j.Session,
|
|
786
|
+
details: List[Tuple[Any, Any]],
|
|
787
|
+
update_tag: int,
|
|
625
788
|
) -> None:
|
|
626
789
|
"""
|
|
627
790
|
Create dictionary for the shares so we can import them in a single query
|
|
@@ -631,14 +794,18 @@ def load_file_services_details(
|
|
|
631
794
|
for file_service_id, share in details:
|
|
632
795
|
if len(share) > 0:
|
|
633
796
|
for s in share:
|
|
634
|
-
s[
|
|
797
|
+
s["service_id"] = file_service_id
|
|
635
798
|
shares.extend(share)
|
|
636
799
|
|
|
637
800
|
_load_shares(neo4j_session, shares, update_tag)
|
|
638
801
|
|
|
639
802
|
|
|
640
803
|
@timeit
|
|
641
|
-
def _load_shares(
|
|
804
|
+
def _load_shares(
|
|
805
|
+
neo4j_session: neo4j.Session,
|
|
806
|
+
shares: List[Dict],
|
|
807
|
+
update_tag: int,
|
|
808
|
+
) -> None:
|
|
642
809
|
"""
|
|
643
810
|
Ingest Share details into neo4j.
|
|
644
811
|
"""
|
|
@@ -675,27 +842,44 @@ def _load_shares(neo4j_session: neo4j.Session, shares: List[Dict], update_tag: i
|
|
|
675
842
|
|
|
676
843
|
@timeit
|
|
677
844
|
def sync_blob_services_details(
|
|
678
|
-
|
|
679
|
-
|
|
845
|
+
neo4j_session: neo4j.Session,
|
|
846
|
+
credentials: Credentials,
|
|
847
|
+
subscription_id: str,
|
|
848
|
+
blob_services: List[Dict],
|
|
849
|
+
update_tag: int,
|
|
680
850
|
) -> None:
|
|
681
|
-
blob_services_details = get_blob_services_details(
|
|
851
|
+
blob_services_details = get_blob_services_details(
|
|
852
|
+
credentials,
|
|
853
|
+
subscription_id,
|
|
854
|
+
blob_services,
|
|
855
|
+
)
|
|
682
856
|
load_blob_services_details(neo4j_session, blob_services_details, update_tag)
|
|
683
857
|
|
|
684
858
|
|
|
685
859
|
@timeit
|
|
686
860
|
def get_blob_services_details(
|
|
687
|
-
|
|
861
|
+
credentials: Credentials,
|
|
862
|
+
subscription_id: str,
|
|
863
|
+
blob_services: List[Dict],
|
|
688
864
|
) -> Generator[Any, Any, Any]:
|
|
689
865
|
"""
|
|
690
866
|
Returning the blob containers with their respective blob service id.
|
|
691
867
|
"""
|
|
692
868
|
for blob_service in blob_services:
|
|
693
|
-
blob_containers = get_blob_containers(
|
|
694
|
-
|
|
869
|
+
blob_containers = get_blob_containers(
|
|
870
|
+
credentials,
|
|
871
|
+
subscription_id,
|
|
872
|
+
blob_service,
|
|
873
|
+
)
|
|
874
|
+
yield blob_service["id"], blob_containers
|
|
695
875
|
|
|
696
876
|
|
|
697
877
|
@timeit
|
|
698
|
-
def get_blob_containers(
|
|
878
|
+
def get_blob_containers(
|
|
879
|
+
credentials: Credentials,
|
|
880
|
+
subscription_id: str,
|
|
881
|
+
blob_service: Dict,
|
|
882
|
+
) -> List[Dict]:
|
|
699
883
|
"""
|
|
700
884
|
Getting the blob containers from the blob service.
|
|
701
885
|
"""
|
|
@@ -705,14 +889,16 @@ def get_blob_containers(credentials: Credentials, subscription_id: str, blob_ser
|
|
|
705
889
|
map(
|
|
706
890
|
lambda x: x.as_dict(),
|
|
707
891
|
client.blob_containers.list(
|
|
708
|
-
blob_service[
|
|
709
|
-
blob_service[
|
|
892
|
+
blob_service["resource_group_name"],
|
|
893
|
+
blob_service["storage_account_name"],
|
|
710
894
|
),
|
|
711
895
|
),
|
|
712
896
|
)
|
|
713
897
|
|
|
714
898
|
except ClientAuthenticationError as e:
|
|
715
|
-
logger.warning(
|
|
899
|
+
logger.warning(
|
|
900
|
+
f"Client Authentication Error while retrieving blob containers - {e}",
|
|
901
|
+
)
|
|
716
902
|
return []
|
|
717
903
|
except ResourceNotFoundError as e:
|
|
718
904
|
logger.warning(f"Blob containers resource not found error - {e}")
|
|
@@ -726,7 +912,9 @@ def get_blob_containers(credentials: Credentials, subscription_id: str, blob_ser
|
|
|
726
912
|
|
|
727
913
|
@timeit
|
|
728
914
|
def load_blob_services_details(
|
|
729
|
-
|
|
915
|
+
neo4j_session: neo4j.Session,
|
|
916
|
+
details: List[Tuple[Any, Any]],
|
|
917
|
+
update_tag: int,
|
|
730
918
|
) -> None:
|
|
731
919
|
"""
|
|
732
920
|
Create dictionary for the blob containers so we can import them in a single query
|
|
@@ -736,7 +924,7 @@ def load_blob_services_details(
|
|
|
736
924
|
for blob_service_id, container in details:
|
|
737
925
|
if len(container) > 0:
|
|
738
926
|
for c in container:
|
|
739
|
-
c[
|
|
927
|
+
c["service_id"] = blob_service_id
|
|
740
928
|
blob_containers.extend(container)
|
|
741
929
|
|
|
742
930
|
_load_blob_containers(neo4j_session, blob_containers, update_tag)
|
|
@@ -744,7 +932,9 @@ def load_blob_services_details(
|
|
|
744
932
|
|
|
745
933
|
@timeit
|
|
746
934
|
def _load_blob_containers(
|
|
747
|
-
|
|
935
|
+
neo4j_session: neo4j.Session,
|
|
936
|
+
blob_containers: List[Dict],
|
|
937
|
+
update_tag: int,
|
|
748
938
|
) -> None:
|
|
749
939
|
"""
|
|
750
940
|
Ingest Blob Container details into neo4j.
|
|
@@ -783,18 +973,37 @@ def _load_blob_containers(
|
|
|
783
973
|
|
|
784
974
|
@timeit
|
|
785
975
|
def cleanup_azure_storage_accounts(
|
|
786
|
-
|
|
976
|
+
neo4j_session: neo4j.Session,
|
|
977
|
+
common_job_parameters: Dict,
|
|
787
978
|
) -> None:
|
|
788
|
-
run_cleanup_job(
|
|
979
|
+
run_cleanup_job(
|
|
980
|
+
"azure_storage_account_cleanup.json",
|
|
981
|
+
neo4j_session,
|
|
982
|
+
common_job_parameters,
|
|
983
|
+
)
|
|
789
984
|
|
|
790
985
|
|
|
791
986
|
@timeit
|
|
792
987
|
def sync(
|
|
793
|
-
|
|
794
|
-
|
|
988
|
+
neo4j_session: neo4j.Session,
|
|
989
|
+
credentials: Credentials,
|
|
990
|
+
subscription_id: str,
|
|
991
|
+
sync_tag: int,
|
|
992
|
+
common_job_parameters: Dict,
|
|
795
993
|
) -> None:
|
|
796
994
|
logger.info("Syncing Azure Storage for subscription '%s'.", subscription_id)
|
|
797
995
|
storage_account_list = get_storage_account_list(credentials, subscription_id)
|
|
798
|
-
load_storage_account_data(
|
|
799
|
-
|
|
996
|
+
load_storage_account_data(
|
|
997
|
+
neo4j_session,
|
|
998
|
+
subscription_id,
|
|
999
|
+
storage_account_list,
|
|
1000
|
+
sync_tag,
|
|
1001
|
+
)
|
|
1002
|
+
sync_storage_account_details(
|
|
1003
|
+
neo4j_session,
|
|
1004
|
+
credentials,
|
|
1005
|
+
subscription_id,
|
|
1006
|
+
storage_account_list,
|
|
1007
|
+
sync_tag,
|
|
1008
|
+
)
|
|
800
1009
|
cleanup_azure_storage_accounts(neo4j_session, common_job_parameters)
|