osi-dump 0.1.3.3.2.6__py3-none-any.whl → 0.1.3.3.2.8__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.
@@ -50,12 +50,15 @@ class OpenStackImageImporter(ImageImporter):
50
50
 
51
51
  def _get_image_info(self, os_image: OSImage) -> Image:
52
52
 
53
- properties: dict = os_image.properties
54
-
55
- properties.pop("owner_specified.openstack.md5", None)
56
- properties.pop("owner_specified.openstack.sha256", None)
57
- properties.pop("owner_specified.openstack.object", None)
58
- properties.pop("stores", None)
53
+ try:
54
+ properties: dict = os_image.properties
55
+
56
+ properties.pop("owner_specified.openstack.md5", None)
57
+ properties.pop("owner_specified.openstack.sha256", None)
58
+ properties.pop("owner_specified.openstack.object", None)
59
+ properties.pop("stores", None)
60
+ except Exception as e:
61
+ logger.warn(f"properties for {os_image.id} is None")
59
62
 
60
63
  image = Image(
61
64
  image_id=os_image.id,
@@ -15,13 +15,28 @@ from osi_dump.api.keystone import get_role_assignments
15
15
  logger = logging.getLogger(__name__)
16
16
 
17
17
 
18
- class OpenStackRoleAssignmentImporter(RoleAssignmentImporter):
19
- user_names = {}
20
- role_names = {}
21
-
22
-
18
+ class OpenStackRoleAssignmentImporter(RoleAssignmentImporter):
23
19
  def __init__(self, connection: Connection):
24
20
  self.connection = connection
21
+
22
+ self.users = {}
23
+ self.roles = {}
24
+
25
+ def _get_users(self):
26
+ os_users = self.connection.identity.users()
27
+
28
+ for os_user in os_users:
29
+ print(os_user)
30
+ self.users[os_user.id] = os_user.name
31
+
32
+ def _get_roles(self):
33
+ os_roles = self.connection.identity.roles()
34
+
35
+ for os_role in os_roles:
36
+
37
+ print(os_role)
38
+ self.roles[os_role.id] = os_role.name
39
+
25
40
 
26
41
  def import_role_assignments(self) -> list[RoleAssignment]:
27
42
  """Import role_assignments information from Openstack
@@ -36,11 +51,22 @@ class OpenStackRoleAssignmentImporter(RoleAssignmentImporter):
36
51
  logger.info(
37
52
  f"Importing role_assignments for {self.connection.auth['auth_url']}"
38
53
  )
54
+
55
+ try:
56
+ self._get_users()
57
+ except Exception as e:
58
+ logger.info(f"Getting user list failed {e}")
59
+
60
+ try:
61
+ self._get_roles()
62
+ except Exception as e:
63
+ logger.info(f"Getting role list failed {e}")
39
64
 
40
65
  try:
41
66
  osrole_assignments: list[OSRoleAssignment] = list(
42
67
  self.connection.identity.role_assignments()
43
68
  )
69
+
44
70
  except Exception as e:
45
71
  raise Exception(
46
72
  f"Can not fetch role_assignments for {self.connection.auth['auth_url']} {e}"
@@ -81,25 +107,12 @@ class OpenStackRoleAssignmentImporter(RoleAssignmentImporter):
81
107
  role_name = None
82
108
 
83
109
  try:
84
- if user_id in OpenStackRoleAssignmentImporter.user_names:
85
- user_name = OpenStackRoleAssignmentImporter.user_names[user_id]
86
- else:
87
- user_name = self.connection.identity.get_user(
88
- role_assignment.user["id"]
89
- ).name
90
- OpenStackRoleAssignmentImporter.user_names[user_id] = user_name
110
+ user_name = self.users[user_id]
91
111
  except Exception as e:
92
112
  logger.warning(f"Can not get user name: {e}")
93
113
 
94
114
  try:
95
- if role_id in OpenStackRoleAssignmentImporter.role_names:
96
- role_name = OpenStackRoleAssignmentImporter.role_names[role_id]
97
- else:
98
- role_name = self.connection.identity.get_role(
99
- role_assignment.role["id"]
100
- ).name
101
- OpenStackRoleAssignmentImporter.role_names[role_id] = role_name
102
-
115
+ role_name = self.roles[role_id]
103
116
  except Exception as e:
104
117
  logger.warning(f"Can not get role name: {e}")
105
118
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: osi-dump
3
- Version: 0.1.3.3.2.6
3
+ Version: 0.1.3.3.2.8
4
4
  Summary: OpenStack information dump tool
5
5
  Author: TVKain
6
6
  License: Apache-2.0
@@ -66,7 +66,7 @@ osi_dump/importer/hypervisor/hypervisor_importer.py,sha256=JuoJBltqFYhH-Ql9TLUPH
66
66
  osi_dump/importer/hypervisor/openstack_hypervisor_importer.py,sha256=lVxVGWKNlNAPhEHC_nWg9cxIGz8Lv6AVQXwIgQsWnP0,3923
67
67
  osi_dump/importer/image/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
68
68
  osi_dump/importer/image/image_importer.py,sha256=6zwAMnS58S2HGwARwebqf4VE9IBQBv5Ot6nmcn9H4fY,181
69
- osi_dump/importer/image/openstack_image_importer.py,sha256=ffc13qnIGu07OXnIPaKiVxGdufep82RfQoKqLb1bwHc,2455
69
+ osi_dump/importer/image/openstack_image_importer.py,sha256=dqQAsNDPljTDN82YPEjBbPDjvLOCtad_hgRWhIpCWXw,2585
70
70
  osi_dump/importer/instance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
71
  osi_dump/importer/instance/instance_importer.py,sha256=TaaPgEFVVMRT3mSXrzQkSaSIBPBwwANpEaWCgRsgImc,196
72
72
  osi_dump/importer/instance/openstack_instance_importer.py,sha256=D-Q9AIN81g2GW-SRWpKxBeagxvJvhN_AumSt5WGQrEc,4244
@@ -77,7 +77,7 @@ osi_dump/importer/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
77
77
  osi_dump/importer/project/openstack_project_importer.py,sha256=ylcm3jEFqh4gW8vhzhIaBq5v4A-PV3BaaogC8uHlSkg,3295
78
78
  osi_dump/importer/project/project_importer.py,sha256=jwEvxteFbSwyWMV8hKAtf5Lo2bZysWkQ1L_NVUE8XOQ,191
79
79
  osi_dump/importer/role_assignment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
80
- osi_dump/importer/role_assignment/openstack_role_assignment_importer.py,sha256=i_3fx86y_UotOkQ9I9oLiXQ3UlXtokYxW4XreodAIW0,3678
80
+ osi_dump/importer/role_assignment/openstack_role_assignment_importer.py,sha256=iJYSY8VWNZ8K7xz8wotGOqbvS5fjJsA6WQcmyPLh3mU,3720
81
81
  osi_dump/importer/role_assignment/role_assignment_importer.py,sha256=Faorx0qsgdXjv5y2t-7obpV3wFfbmByx_-8b9yBr7L8,228
82
82
  osi_dump/importer/router/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
83
  osi_dump/importer/router/openstack_router_importer.py,sha256=T_Wr45nJrCcp2OOdRawmdQkNBDzczA-3DPx9dlewd4g,2781
@@ -109,8 +109,8 @@ osi_dump/util/extract_hostname.py,sha256=IpdklGHevmtRu67xeSRE_5n2mvWGI1sDsnJwExo
109
109
  osi_dump/util/openstack_util.py,sha256=_o8LiRmQKtxQ8hU3rbrMNwIAxt0-aWD2rjq-NvVdK9E,1299
110
110
  osi_dump/util/panda_excel.py,sha256=owr8AffIxqN3yY8kIv55Ox4j2dRz7kXZvSZFZeft8dw,734
111
111
  osi_dump/util/validate_dir_path.py,sha256=pL_OrY8JnNwk3vj6Zp6bsZtgHXhszSGRoqIt-1G5S90,507
112
- osi_dump-0.1.3.3.2.6.dist-info/METADATA,sha256=YP_-NefdJ8q6kpPwWq5d752llU6lf5SMQ9PERl2Pzus,679
113
- osi_dump-0.1.3.3.2.6.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
114
- osi_dump-0.1.3.3.2.6.dist-info/entry_points.txt,sha256=ozm5sIBtXzLv6_FiUe26v1BgA3_xUReGLPhKQKZ56wQ,46
115
- osi_dump-0.1.3.3.2.6.dist-info/top_level.txt,sha256=OtAAwmJfcoPvlw_Cemo_H1aXIGV_7w0O2941KQt6faQ,9
116
- osi_dump-0.1.3.3.2.6.dist-info/RECORD,,
112
+ osi_dump-0.1.3.3.2.8.dist-info/METADATA,sha256=NWKgobveDL7jT3LbI4NVIH4Ui3lleOP9yMXKN9tjnyg,679
113
+ osi_dump-0.1.3.3.2.8.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
114
+ osi_dump-0.1.3.3.2.8.dist-info/entry_points.txt,sha256=ozm5sIBtXzLv6_FiUe26v1BgA3_xUReGLPhKQKZ56wQ,46
115
+ osi_dump-0.1.3.3.2.8.dist-info/top_level.txt,sha256=OtAAwmJfcoPvlw_Cemo_H1aXIGV_7w0O2941KQt6faQ,9
116
+ osi_dump-0.1.3.3.2.8.dist-info/RECORD,,