osi-dump 0.1.3.3__py3-none-any.whl → 0.1.3.3.2__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.
- osi_dump/api/keystone.py +30 -0
- osi_dump/importer/role_assignment/openstack_role_assignment_importer.py +12 -14
- {osi_dump-0.1.3.3.dist-info → osi_dump-0.1.3.3.2.dist-info}/METADATA +1 -1
- {osi_dump-0.1.3.3.dist-info → osi_dump-0.1.3.3.2.dist-info}/RECORD +7 -6
- {osi_dump-0.1.3.3.dist-info → osi_dump-0.1.3.3.2.dist-info}/WHEEL +0 -0
- {osi_dump-0.1.3.3.dist-info → osi_dump-0.1.3.3.2.dist-info}/entry_points.txt +0 -0
- {osi_dump-0.1.3.3.dist-info → osi_dump-0.1.3.3.2.dist-info}/top_level.txt +0 -0
osi_dump/api/keystone.py
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from openstack.connection import Connection
|
4
|
+
from openstack.identity.v3.service import Service
|
5
|
+
from openstack.load_balancer.v2.load_balancer import LoadBalancer
|
6
|
+
|
7
|
+
import osi_dump.util.openstack_util as os_util
|
8
|
+
|
9
|
+
logger = logging.getLogger(__name__)
|
10
|
+
|
11
|
+
|
12
|
+
def get_role_assignments(connection: Connection):
|
13
|
+
keystone_endpoints = os_util.get_endpoints(
|
14
|
+
connection=connection, service_type="identity", interface="public"
|
15
|
+
)
|
16
|
+
|
17
|
+
for endpoint in keystone_endpoints:
|
18
|
+
try:
|
19
|
+
url = f"{endpoint}/v3/role_assignments?include_names"
|
20
|
+
response = connection.session.get(url)
|
21
|
+
if response.status_code == 200:
|
22
|
+
break
|
23
|
+
except Exception as e:
|
24
|
+
logger.info(e)
|
25
|
+
|
26
|
+
if response is None:
|
27
|
+
return []
|
28
|
+
|
29
|
+
return response.json()['role_assignments']
|
30
|
+
|
@@ -10,6 +10,8 @@ from osi_dump.importer.role_assignment.role_assignment_importer import (
|
|
10
10
|
)
|
11
11
|
from osi_dump.model.role_assignment import RoleAssignment
|
12
12
|
|
13
|
+
from osi_dump.api.keystone import get_role_assignments
|
14
|
+
|
13
15
|
logger = logging.getLogger(__name__)
|
14
16
|
|
15
17
|
|
@@ -32,16 +34,16 @@ class OpenStackRoleAssignmentImporter(RoleAssignmentImporter):
|
|
32
34
|
)
|
33
35
|
|
34
36
|
try:
|
35
|
-
osrole_assignments
|
36
|
-
|
37
|
-
|
37
|
+
osrole_assignments = get_role_assignments(self.connection)
|
38
|
+
|
39
|
+
|
38
40
|
except Exception as e:
|
39
41
|
raise Exception(
|
40
42
|
f"Can not fetch role_assignments for {self.connection.auth['auth_url']}"
|
41
43
|
) from e
|
42
44
|
|
43
45
|
role_assignments: list[RoleAssignment] = []
|
44
|
-
|
46
|
+
|
45
47
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
46
48
|
futures = [
|
47
49
|
executor.submit(self._get_role_assignment_info, role_assignment)
|
@@ -62,30 +64,26 @@ class OpenStackRoleAssignmentImporter(RoleAssignmentImporter):
|
|
62
64
|
role_id = None
|
63
65
|
|
64
66
|
try:
|
65
|
-
user_id = role_assignment
|
67
|
+
user_id = role_assignment["user"]["id"]
|
66
68
|
except Exception as e:
|
67
69
|
logger.warning(f"Can not get user id: {e}")
|
68
70
|
|
69
71
|
try:
|
70
|
-
role_id = role_assignment
|
72
|
+
role_id = role_assignment["role"]["id"]
|
71
73
|
except Exception as e:
|
72
74
|
logger.warning(f"Can not get role id: {e}")
|
73
75
|
|
74
76
|
user_name = None
|
75
77
|
role_name = None
|
76
78
|
|
77
|
-
try:
|
78
|
-
role_name =
|
79
|
-
role_assignment.role["id"]
|
80
|
-
).name
|
79
|
+
try:
|
80
|
+
role_name = role_assignment['role']['name']
|
81
81
|
|
82
82
|
except Exception as e:
|
83
83
|
logger.warning(f"Can not get role name: {e}")
|
84
84
|
|
85
85
|
try:
|
86
|
-
user_name =
|
87
|
-
role_assignment.user["id"]
|
88
|
-
).name
|
86
|
+
user_name = role_assignment['user']['name']
|
89
87
|
except Exception as e:
|
90
88
|
logger.warning(f"Can not get user name: {e}")
|
91
89
|
|
@@ -94,7 +92,7 @@ class OpenStackRoleAssignmentImporter(RoleAssignmentImporter):
|
|
94
92
|
user_name=user_name,
|
95
93
|
role_id=role_id,
|
96
94
|
role_name=role_name,
|
97
|
-
scope=role_assignment
|
95
|
+
scope=role_assignment['scope'],
|
98
96
|
)
|
99
97
|
|
100
98
|
return role_assignment_ret
|
@@ -2,6 +2,7 @@ osi_dump/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
osi_dump/__main__.py,sha256=fCVTLFipB-P0872_4j7iOJNNosOMBj3YdHr8TH_fhRY,71
|
3
3
|
osi_dump/cli.py,sha256=vLijmcrWieCVK4cSLN2sK9ltWlercw9Zg6yBEvZtPkg,6379
|
4
4
|
osi_dump/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
osi_dump/api/keystone.py,sha256=QDFhfdG3z78e-y1i2cL-Zdg_cY6tIII81XLsEFpQZpE,853
|
5
6
|
osi_dump/api/neutron.py,sha256=pag_d6MsxA1gOUit4bvVUaTiTrPqLJjwz9KU_QSpxwM,1788
|
6
7
|
osi_dump/api/octavia.py,sha256=Cgzz9Pf26YFETqbXSXYSHUA_PWDy_3V4zPm0RZ8QKBo,1905
|
7
8
|
osi_dump/api/placement.py,sha256=yoWzg39b8nK2E1nrxDhLxLsa7FcBTw57gfy8b5F5ijc,1096
|
@@ -76,7 +77,7 @@ osi_dump/importer/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
76
77
|
osi_dump/importer/project/openstack_project_importer.py,sha256=ylcm3jEFqh4gW8vhzhIaBq5v4A-PV3BaaogC8uHlSkg,3295
|
77
78
|
osi_dump/importer/project/project_importer.py,sha256=jwEvxteFbSwyWMV8hKAtf5Lo2bZysWkQ1L_NVUE8XOQ,191
|
78
79
|
osi_dump/importer/role_assignment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
79
|
-
osi_dump/importer/role_assignment/openstack_role_assignment_importer.py,sha256=
|
80
|
+
osi_dump/importer/role_assignment/openstack_role_assignment_importer.py,sha256=1NdIuVSiaLX9kEiQOLYKdavN_qVt7ZxUk-EIVT1lNFI,2897
|
80
81
|
osi_dump/importer/role_assignment/role_assignment_importer.py,sha256=Faorx0qsgdXjv5y2t-7obpV3wFfbmByx_-8b9yBr7L8,228
|
81
82
|
osi_dump/importer/router/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
82
83
|
osi_dump/importer/router/openstack_router_importer.py,sha256=T_Wr45nJrCcp2OOdRawmdQkNBDzczA-3DPx9dlewd4g,2781
|
@@ -108,8 +109,8 @@ osi_dump/util/extract_hostname.py,sha256=IpdklGHevmtRu67xeSRE_5n2mvWGI1sDsnJwExo
|
|
108
109
|
osi_dump/util/openstack_util.py,sha256=_o8LiRmQKtxQ8hU3rbrMNwIAxt0-aWD2rjq-NvVdK9E,1299
|
109
110
|
osi_dump/util/panda_excel.py,sha256=owr8AffIxqN3yY8kIv55Ox4j2dRz7kXZvSZFZeft8dw,734
|
110
111
|
osi_dump/util/validate_dir_path.py,sha256=pL_OrY8JnNwk3vj6Zp6bsZtgHXhszSGRoqIt-1G5S90,507
|
111
|
-
osi_dump-0.1.3.3.dist-info/METADATA,sha256
|
112
|
-
osi_dump-0.1.3.3.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
113
|
-
osi_dump-0.1.3.3.dist-info/entry_points.txt,sha256=ozm5sIBtXzLv6_FiUe26v1BgA3_xUReGLPhKQKZ56wQ,46
|
114
|
-
osi_dump-0.1.3.3.dist-info/top_level.txt,sha256=OtAAwmJfcoPvlw_Cemo_H1aXIGV_7w0O2941KQt6faQ,9
|
115
|
-
osi_dump-0.1.3.3.dist-info/RECORD,,
|
112
|
+
osi_dump-0.1.3.3.2.dist-info/METADATA,sha256=9yV1F85CtUcdyv0lCAF05hdIi7ePM25so8BELdwB58o,677
|
113
|
+
osi_dump-0.1.3.3.2.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
114
|
+
osi_dump-0.1.3.3.2.dist-info/entry_points.txt,sha256=ozm5sIBtXzLv6_FiUe26v1BgA3_xUReGLPhKQKZ56wQ,46
|
115
|
+
osi_dump-0.1.3.3.2.dist-info/top_level.txt,sha256=OtAAwmJfcoPvlw_Cemo_H1aXIGV_7w0O2941KQt6faQ,9
|
116
|
+
osi_dump-0.1.3.3.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|