osi-dump 0.1.3.3.4.3__py3-none-any.whl → 0.1.4__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.
Files changed (102) hide show
  1. osi_dump/__main__.py +4 -4
  2. osi_dump/api/keystone.py +70 -70
  3. osi_dump/api/neutron.py +65 -65
  4. osi_dump/api/octavia.py +94 -94
  5. osi_dump/api/placement.py +41 -41
  6. osi_dump/batch_handler/__init__.py +6 -5
  7. osi_dump/batch_handler/external_port_batch_handler.py +55 -55
  8. osi_dump/batch_handler/flavor_batch_handler.py +51 -51
  9. osi_dump/batch_handler/floating_ip_batch_handler.py +57 -57
  10. osi_dump/batch_handler/hypervisor_batch_handler.py +55 -55
  11. osi_dump/batch_handler/image_batch_handler.py +51 -51
  12. osi_dump/batch_handler/instance_batch_handler.py +46 -54
  13. osi_dump/batch_handler/load_balancer_batch_handler.py +59 -59
  14. osi_dump/batch_handler/network_batch_handler.py +51 -51
  15. osi_dump/batch_handler/project_batch_handler.py +51 -51
  16. osi_dump/batch_handler/role_assignment_batch_handler.py +38 -61
  17. osi_dump/batch_handler/router_batch_handler.py +49 -49
  18. osi_dump/batch_handler/security_group_batch_handler.py +37 -0
  19. osi_dump/batch_handler/volume_batch_handler.py +45 -45
  20. osi_dump/cli.py +267 -257
  21. osi_dump/exporter/external_port/excel_external_port_exporter.py +34 -34
  22. osi_dump/exporter/external_port/external_port_exporter.py +7 -7
  23. osi_dump/exporter/flavor/excel_flavor_exporter.py +30 -30
  24. osi_dump/exporter/flavor/flavor_exporter.py +7 -7
  25. osi_dump/exporter/floating_ip/excel_floating_ip_exporter.py +30 -30
  26. osi_dump/exporter/floating_ip/floating_ip_exporter.py +7 -7
  27. osi_dump/exporter/hypervisor/excel_hypervisor_exporter.py +32 -32
  28. osi_dump/exporter/hypervisor/hypervisor_exporter.py +7 -7
  29. osi_dump/exporter/image/excel_image_exporter.py +28 -28
  30. osi_dump/exporter/image/image_exporter.py +7 -7
  31. osi_dump/exporter/instance/excel_instance_exporter.py +29 -29
  32. osi_dump/exporter/instance/instance_exporter.py +8 -7
  33. osi_dump/exporter/load_balancer/excel_load_balancer_exporter.py +36 -36
  34. osi_dump/exporter/load_balancer/load_balancer_exporter.py +7 -7
  35. osi_dump/exporter/network/excel_network_exporter.py +32 -32
  36. osi_dump/exporter/network/network_exporter.py +7 -7
  37. osi_dump/exporter/project/excel_project_exporter.py +30 -30
  38. osi_dump/exporter/project/project_exporter.py +7 -7
  39. osi_dump/exporter/role_assignment/excel_role_assignment_exporter.py +43 -35
  40. osi_dump/exporter/role_assignment/role_assignment_exporter.py +7 -7
  41. osi_dump/exporter/router/excel_router_exporter.py +30 -30
  42. osi_dump/exporter/router/router_exporter.py +7 -7
  43. osi_dump/exporter/security_group/excel_security_group_exporter.py +35 -0
  44. osi_dump/exporter/security_group/security_group_exporter.py +8 -0
  45. osi_dump/exporter/volume/excel_volume_exporter.py +29 -29
  46. osi_dump/exporter/volume/volume_exporter.py +7 -7
  47. osi_dump/importer/external_port/external_port_importer.py +9 -9
  48. osi_dump/importer/external_port/openstack_external_port_importer.py +177 -177
  49. osi_dump/importer/flavor/flavor_importer.py +9 -9
  50. osi_dump/importer/flavor/openstack_flavor_importer.py +64 -64
  51. osi_dump/importer/floating_ip/floating_ip_importer.py +9 -9
  52. osi_dump/importer/floating_ip/openstack_floating_ip_importer.py +68 -68
  53. osi_dump/importer/hypervisor/hypervisor_importer.py +9 -9
  54. osi_dump/importer/hypervisor/openstack_hypervisor_importer.py +137 -137
  55. osi_dump/importer/image/image_importer.py +9 -9
  56. osi_dump/importer/image/openstack_image_importer.py +81 -81
  57. osi_dump/importer/instance/instance_importer.py +8 -9
  58. osi_dump/importer/instance/openstack_instance_importer.py +136 -136
  59. osi_dump/importer/load_balancer/load_balancer_importer.py +9 -9
  60. osi_dump/importer/load_balancer/openstack_load_balancer_importer.py +113 -113
  61. osi_dump/importer/network/network_importer.py +9 -9
  62. osi_dump/importer/network/openstack_network_importer.py +93 -93
  63. osi_dump/importer/project/openstack_project_importer.py +141 -141
  64. osi_dump/importer/project/project_importer.py +9 -9
  65. osi_dump/importer/role_assignment/openstack_role_assignment_importer.py +117 -147
  66. osi_dump/importer/role_assignment/role_assignment_importer.py +16 -9
  67. osi_dump/importer/router/openstack_router_importer.py +87 -87
  68. osi_dump/importer/router/router_importer.py +9 -9
  69. osi_dump/importer/security_group/openstack_security_group_importer.py +54 -0
  70. osi_dump/importer/security_group/security_group_importer.py +8 -0
  71. osi_dump/importer/volume/openstack_volume_importer.py +81 -81
  72. osi_dump/importer/volume/volume_importer.py +9 -9
  73. osi_dump/model/authentication_info.py +15 -15
  74. osi_dump/model/external_port.py +30 -30
  75. osi_dump/model/flavor.py +20 -20
  76. osi_dump/model/floating_ip.py +24 -24
  77. osi_dump/model/hypervisor.py +24 -24
  78. osi_dump/model/image.py +27 -27
  79. osi_dump/model/instance.py +29 -29
  80. osi_dump/model/load_balancer.py +26 -26
  81. osi_dump/model/network.py +25 -25
  82. osi_dump/model/project.py +33 -33
  83. osi_dump/model/role_assignment.py +30 -23
  84. osi_dump/model/router.py +23 -23
  85. osi_dump/model/security_group.py +22 -0
  86. osi_dump/model/volume.py +25 -25
  87. osi_dump/os_connection/get_connections.py +67 -67
  88. osi_dump/util/__init__.py +7 -7
  89. osi_dump/util/create_file.py +11 -11
  90. osi_dump/util/excel_autosize_column.py +39 -39
  91. osi_dump/util/excel_sort_sheet.py +35 -35
  92. osi_dump/util/export_data_excel.py +36 -36
  93. osi_dump/util/extract_hostname.py +5 -5
  94. osi_dump/util/openstack_util.py +48 -48
  95. osi_dump/util/panda_excel.py +26 -26
  96. osi_dump/util/validate_dir_path.py +20 -20
  97. {osi_dump-0.1.3.3.4.3.dist-info → osi_dump-0.1.4.dist-info}/METADATA +40 -40
  98. osi_dump-0.1.4.dist-info/RECORD +130 -0
  99. osi_dump-0.1.3.3.4.3.dist-info/RECORD +0 -124
  100. {osi_dump-0.1.3.3.4.3.dist-info → osi_dump-0.1.4.dist-info}/WHEEL +0 -0
  101. {osi_dump-0.1.3.3.4.3.dist-info → osi_dump-0.1.4.dist-info}/entry_points.txt +0 -0
  102. {osi_dump-0.1.3.3.4.3.dist-info → osi_dump-0.1.4.dist-info}/top_level.txt +0 -0
osi_dump/cli.py CHANGED
@@ -1,257 +1,267 @@
1
- import logging
2
-
3
- import os
4
-
5
- from pathlib import Path
6
-
7
- import typer
8
-
9
- from typing_extensions import Annotated
10
-
11
- from osi_dump.batch_handler.external_port_batch_handler import ExternalPortBatchHandler
12
- from osi_dump.batch_handler.load_balancer_batch_handler import LoadBalancerBatchHandler
13
- from osi_dump.batch_handler.role_assignment_batch_handler import (
14
- RoleAssignmentBatchHandler,
15
- )
16
- from osi_dump.batch_handler.router_batch_handler import RouterBatchHandler
17
-
18
- app = typer.Typer()
19
-
20
-
21
- from osi_dump.batch_handler.flavor_batch_handler import FlavorBatchHandler
22
- from osi_dump.batch_handler.network_batch_handler import NetworkBatchHandler
23
-
24
- from osi_dump.batch_handler.image_batch_handler import ImageBatchHandler
25
- from osi_dump.batch_handler.volume_batch_handler import VolumeBatchHandler
26
- from osi_dump.os_connection.get_connections import get_connections
27
-
28
-
29
- from osi_dump.batch_handler import (
30
- InstanceBatchHandler,
31
- ProjectBatchHandler,
32
- HypervisorBatchHandler,
33
- FloatingIPBatchHandler,
34
- )
35
-
36
-
37
- from osi_dump.importer.external_port.openstack_external_port_importer import (
38
- OpenStackExternalPortImporter,
39
- )
40
-
41
-
42
- from osi_dump import util
43
-
44
-
45
- def _instance(connections, output_path: str):
46
- instance_batch_handler = InstanceBatchHandler()
47
-
48
- instance_batch_handler.add_importer_exporter_from_openstack_connections(
49
- connections, output_file=output_path
50
- )
51
-
52
- instance_batch_handler.process()
53
-
54
-
55
- def _floating_ip(connections, output_path: str):
56
- floating_ip_batch_handler = FloatingIPBatchHandler()
57
-
58
- floating_ip_batch_handler.add_importer_exporter_from_openstack_connections(
59
- connections, output_file=output_path
60
- )
61
-
62
- floating_ip_batch_handler.process()
63
-
64
-
65
- def _volume(connections, output_path: str):
66
- volume_batch_handler = VolumeBatchHandler()
67
-
68
- volume_batch_handler.add_importer_exporter_from_openstack_connections(
69
- connections, output_file=output_path
70
- )
71
-
72
- volume_batch_handler.process()
73
-
74
-
75
- def _project(connections, output_path: str):
76
- project_batch_handler = ProjectBatchHandler()
77
-
78
- project_batch_handler.add_importer_exporter_from_openstack_connections(
79
- connections, output_file=output_path
80
- )
81
-
82
- project_batch_handler.process()
83
-
84
-
85
- def _hypervisor(connections, output_path: str):
86
- hypervisor_batch_handler = HypervisorBatchHandler()
87
-
88
- hypervisor_batch_handler.add_importer_exporter_from_openstack_connections(
89
- connections, output_file=output_path
90
- )
91
-
92
- hypervisor_batch_handler.process()
93
-
94
-
95
- def _image(connections, output_path: str):
96
- image_batch_handler = ImageBatchHandler()
97
-
98
- image_batch_handler.add_importer_exporter_from_openstack_connections(
99
- connections, output_file=output_path
100
- )
101
-
102
- image_batch_handler.process()
103
-
104
-
105
- def _flavor(connections, output_path: str):
106
- flavor_batch_handler = FlavorBatchHandler()
107
-
108
- flavor_batch_handler.add_importer_exporter_from_openstack_connections(
109
- connections, output_file=output_path
110
- )
111
-
112
- flavor_batch_handler.process()
113
-
114
-
115
- def _role_assignment(connections, output_path: str):
116
- _role_assignment_batch_handler = RoleAssignmentBatchHandler()
117
-
118
- _role_assignment_batch_handler.add_importer_exporter_from_openstack_connections(
119
- connections, output_file=output_path
120
- )
121
-
122
- _role_assignment_batch_handler.process()
123
-
124
-
125
- def _load_balancer(connections, output_path: str):
126
- _load_balancer_batch_handler = LoadBalancerBatchHandler()
127
-
128
- _load_balancer_batch_handler.add_importer_exporter_from_openstack_connections(
129
- connections, output_file=output_path
130
- )
131
-
132
- _load_balancer_batch_handler.process()
133
-
134
-
135
- def _router(connections, output_path: str):
136
- _router_batch_handler = RouterBatchHandler()
137
-
138
- _router_batch_handler.add_importer_exporter_from_openstack_connections(
139
- connections, output_file=output_path
140
- )
141
-
142
- _router_batch_handler.process()
143
-
144
-
145
- def _external_port(connections, output_path: str):
146
- _external_batch_handler = ExternalPortBatchHandler()
147
-
148
- _external_batch_handler.add_importer_exporter_from_openstack_connections(
149
- connections, output_file=output_path
150
- )
151
-
152
- _external_batch_handler.process()
153
-
154
- def _network(connections, output_path: str):
155
- _network_batch_handler = NetworkBatchHandler()
156
-
157
- _network_batch_handler.add_importer_exporter_from_openstack_connections(
158
- connections, output_file=output_path
159
- )
160
-
161
- _network_batch_handler.process()
162
-
163
- def inner_main(file_path: str, output_path: str):
164
-
165
- logger = logging.getLogger(__name__)
166
-
167
- connections = get_connections(file_path=file_path)
168
-
169
- _instance(connections=connections, output_path=output_path)
170
-
171
- _floating_ip(connections=connections, output_path=output_path)
172
-
173
- _volume(connections=connections, output_path=output_path)
174
-
175
- _hypervisor(connections=connections, output_path=output_path)
176
-
177
- _project(connections=connections, output_path=output_path)
178
-
179
- _image(connections=connections, output_path=output_path)
180
-
181
- _flavor(connections=connections, output_path=output_path)
182
-
183
- _role_assignment(connections=connections, output_path=output_path)
184
-
185
- _load_balancer(connections=connections, output_path=output_path)
186
-
187
- _router(connections=connections, output_path=output_path)
188
-
189
- _external_port(connections=connections, output_path=output_path)
190
-
191
- _network(connections=connections, output_path=output_path)
192
-
193
- util.excel_autosize_column(output_path)
194
-
195
- util.excel_sort_sheet(output_path)
196
-
197
- logger.info(
198
- f"Exported OpenStack information to file: {os.path.abspath(output_path)}"
199
- )
200
-
201
-
202
- def main(
203
- file_path: Annotated[
204
- Path,
205
- typer.Argument(
206
- help=(
207
- """
208
- Path of the file containing OpenStack authentication information.
209
-
210
- The expected JSON file format is as follows:
211
-
212
- \b
213
- [
214
- {
215
- "auth_url": "string",
216
- "project_name": "string",
217
- "username": "string",
218
- "password": "string",
219
- "user_domain_name": "string",
220
- "project_domain_name": "string"
221
- }
222
- ]
223
- """
224
- )
225
- ),
226
- ],
227
- output_path: Annotated[
228
- Path,
229
- typer.Argument(
230
- help="""
231
- \b
232
- Path of the output file, will override if file already exists
233
-
234
- """
235
- ),
236
- ] = "output.xlsx",
237
- ):
238
- logging.basicConfig(
239
- level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
240
- )
241
-
242
- # Suppress pool limit warning will investigate later
243
- logging.getLogger("urllib3").propagate = False
244
-
245
- logger = logging.getLogger(__name__)
246
-
247
- if util.validate_dir_path(file_path=output_path) is False:
248
- logger.error(f"Invalid path: {output_path}, folder does not exist.")
249
- raise typer.Exit(1)
250
-
251
- inner_main(file_path=file_path, output_path=output_path)
252
-
253
-
254
- app.command()(main)
255
-
256
- if __name__ == "__main__":
257
- app()
1
+ import logging
2
+
3
+ import os
4
+
5
+ from pathlib import Path
6
+
7
+ import typer
8
+
9
+ from typing_extensions import Annotated
10
+
11
+ from osi_dump.batch_handler.external_port_batch_handler import ExternalPortBatchHandler
12
+ from osi_dump.batch_handler.load_balancer_batch_handler import LoadBalancerBatchHandler
13
+ from osi_dump.batch_handler.role_assignment_batch_handler import (
14
+ RoleAssignmentBatchHandler,
15
+ )
16
+ from osi_dump.batch_handler.router_batch_handler import RouterBatchHandler
17
+
18
+ app = typer.Typer()
19
+
20
+
21
+ from osi_dump.batch_handler.flavor_batch_handler import FlavorBatchHandler
22
+ from osi_dump.batch_handler.network_batch_handler import NetworkBatchHandler
23
+
24
+ from osi_dump.batch_handler.image_batch_handler import ImageBatchHandler
25
+ from osi_dump.batch_handler.volume_batch_handler import VolumeBatchHandler
26
+ from osi_dump.batch_handler.security_group_batch_handler import SecurityGroupBatchHandler
27
+ from osi_dump.os_connection.get_connections import get_connections
28
+
29
+
30
+ from osi_dump.batch_handler import (
31
+ InstanceBatchHandler,
32
+ ProjectBatchHandler,
33
+ HypervisorBatchHandler,
34
+ FloatingIPBatchHandler,
35
+ )
36
+
37
+
38
+ from osi_dump.importer.external_port.openstack_external_port_importer import (
39
+ OpenStackExternalPortImporter,
40
+ )
41
+
42
+
43
+ from osi_dump import util
44
+
45
+
46
+ def _instance(connections, output_path: str):
47
+ instance_batch_handler = InstanceBatchHandler()
48
+
49
+ instance_batch_handler.add_importer_exporter_from_openstack_connections(
50
+ connections, output_file=output_path
51
+ )
52
+
53
+ instance_batch_handler.process()
54
+
55
+
56
+ def _floating_ip(connections, output_path: str):
57
+ floating_ip_batch_handler = FloatingIPBatchHandler()
58
+
59
+ floating_ip_batch_handler.add_importer_exporter_from_openstack_connections(
60
+ connections, output_file=output_path
61
+ )
62
+
63
+ floating_ip_batch_handler.process()
64
+
65
+
66
+ def _volume(connections, output_path: str):
67
+ volume_batch_handler = VolumeBatchHandler()
68
+
69
+ volume_batch_handler.add_importer_exporter_from_openstack_connections(
70
+ connections, output_file=output_path
71
+ )
72
+
73
+ volume_batch_handler.process()
74
+
75
+
76
+ def _project(connections, output_path: str):
77
+ project_batch_handler = ProjectBatchHandler()
78
+
79
+ project_batch_handler.add_importer_exporter_from_openstack_connections(
80
+ connections, output_file=output_path
81
+ )
82
+
83
+ project_batch_handler.process()
84
+
85
+
86
+ def _hypervisor(connections, output_path: str):
87
+ hypervisor_batch_handler = HypervisorBatchHandler()
88
+
89
+ hypervisor_batch_handler.add_importer_exporter_from_openstack_connections(
90
+ connections, output_file=output_path
91
+ )
92
+
93
+ hypervisor_batch_handler.process()
94
+
95
+
96
+ def _image(connections, output_path: str):
97
+ image_batch_handler = ImageBatchHandler()
98
+
99
+ image_batch_handler.add_importer_exporter_from_openstack_connections(
100
+ connections, output_file=output_path
101
+ )
102
+
103
+ image_batch_handler.process()
104
+
105
+
106
+ def _flavor(connections, output_path: str):
107
+ flavor_batch_handler = FlavorBatchHandler()
108
+
109
+ flavor_batch_handler.add_importer_exporter_from_openstack_connections(
110
+ connections, output_file=output_path
111
+ )
112
+
113
+ flavor_batch_handler.process()
114
+
115
+
116
+ def _role_assignment(connections, output_path: str):
117
+ _role_assignment_batch_handler = RoleAssignmentBatchHandler()
118
+
119
+ _role_assignment_batch_handler.add_importer_exporter_from_openstack_connections(
120
+ connections, output_file=output_path
121
+ )
122
+
123
+ _role_assignment_batch_handler.process()
124
+
125
+
126
+ def _load_balancer(connections, output_path: str):
127
+ _load_balancer_batch_handler = LoadBalancerBatchHandler()
128
+
129
+ _load_balancer_batch_handler.add_importer_exporter_from_openstack_connections(
130
+ connections, output_file=output_path
131
+ )
132
+
133
+ _load_balancer_batch_handler.process()
134
+
135
+
136
+ def _router(connections, output_path: str):
137
+ _router_batch_handler = RouterBatchHandler()
138
+
139
+ _router_batch_handler.add_importer_exporter_from_openstack_connections(
140
+ connections, output_file=output_path
141
+ )
142
+
143
+ _router_batch_handler.process()
144
+
145
+
146
+ def _external_port(connections, output_path: str):
147
+ _external_batch_handler = ExternalPortBatchHandler()
148
+
149
+ _external_batch_handler.add_importer_exporter_from_openstack_connections(
150
+ connections, output_file=output_path
151
+ )
152
+
153
+ _external_batch_handler.process()
154
+
155
+ def _network(connections, output_path: str):
156
+ _network_batch_handler = NetworkBatchHandler()
157
+
158
+ _network_batch_handler.add_importer_exporter_from_openstack_connections(
159
+ connections, output_file=output_path
160
+ )
161
+
162
+ _network_batch_handler.process()
163
+
164
+ def inner_main(file_path: str, output_path: str):
165
+
166
+ logger = logging.getLogger(__name__)
167
+
168
+ connections = get_connections(file_path=file_path)
169
+
170
+ _instance(connections=connections, output_path=output_path)
171
+
172
+ _floating_ip(connections=connections, output_path=output_path)
173
+
174
+ _volume(connections=connections, output_path=output_path)
175
+
176
+ _hypervisor(connections=connections, output_path=output_path)
177
+
178
+ _project(connections=connections, output_path=output_path)
179
+
180
+ _image(connections=connections, output_path=output_path)
181
+
182
+ _flavor(connections=connections, output_path=output_path)
183
+
184
+ _role_assignment(connections=connections, output_path=output_path)
185
+
186
+ _load_balancer(connections=connections, output_path=output_path)
187
+
188
+ _router(connections=connections, output_path=output_path)
189
+
190
+ _external_port(connections=connections, output_path=output_path)
191
+
192
+ _network(connections=connections, output_path=output_path)
193
+
194
+ _security_group(connections=connections, output_path=output_path)
195
+
196
+ util.excel_autosize_column(output_path)
197
+
198
+ util.excel_sort_sheet(output_path)
199
+
200
+ logger.info(
201
+ f"Exported OpenStack information to file: {os.path.abspath(output_path)}"
202
+ )
203
+
204
+ def _security_group(connections, output_path: str):
205
+ sec_group_batch_handler = SecurityGroupBatchHandler()
206
+ sec_group_batch_handler.add_importer_exporter_from_openstack_connections(
207
+ connections, output_file=output_path
208
+ )
209
+ sec_group_batch_handler.process()
210
+
211
+
212
+ def main(
213
+ file_path: Annotated[
214
+ Path,
215
+ typer.Argument(
216
+ help=(
217
+ """
218
+ Path of the file containing OpenStack authentication information.
219
+
220
+ The expected JSON file format is as follows:
221
+
222
+ \b
223
+ [
224
+ {
225
+ "auth_url": "string",
226
+ "project_name": "string",
227
+ "username": "string",
228
+ "password": "string",
229
+ "user_domain_name": "string",
230
+ "project_domain_name": "string"
231
+ }
232
+ ]
233
+ """
234
+ )
235
+ ),
236
+ ],
237
+ output_path: Annotated[
238
+ Path,
239
+ typer.Argument(
240
+ help="""
241
+ \b
242
+ Path of the output file, will override if file already exists
243
+
244
+ """
245
+ ),
246
+ ] = "output.xlsx",
247
+ ):
248
+ logging.basicConfig(
249
+ level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
250
+ )
251
+
252
+ # Suppress pool limit warning will investigate later
253
+ logging.getLogger("urllib3").propagate = False
254
+
255
+ logger = logging.getLogger(__name__)
256
+
257
+ if util.validate_dir_path(file_path=output_path) is False:
258
+ logger.error(f"Invalid path: {output_path}, folder does not exist.")
259
+ raise typer.Exit(1)
260
+
261
+ inner_main(file_path=file_path, output_path=output_path)
262
+
263
+
264
+ app.command()(main)
265
+
266
+ if __name__ == "__main__":
267
+ app()
@@ -1,34 +1,34 @@
1
- import pandas as pd
2
-
3
- import logging
4
-
5
- from openpyxl import load_workbook
6
-
7
- from osi_dump import util
8
- from osi_dump.exporter.external_port.external_port_exporter import ExternalPortExporter
9
-
10
- from osi_dump.model.external_port import ExternalPort
11
-
12
- logger = logging.getLogger(__name__)
13
-
14
-
15
- class ExcelExternalPortExporter(ExternalPortExporter):
16
- def __init__(self, sheet_name: str, output_file: str):
17
- self.sheet_name = sheet_name
18
- self.output_file = output_file
19
-
20
- def export_external_ports(self, external_ports: list[ExternalPort]):
21
-
22
- df = pd.DataFrame(
23
- [external_port.model_dump() for external_port in external_ports]
24
- )
25
-
26
- df = util.panda_excel.expand_list_column(df, "allowed_address_pairs")
27
-
28
- logger.info(f"Exporting external_ports for {self.sheet_name}")
29
- try:
30
- util.export_data_excel(self.output_file, sheet_name=self.sheet_name, df=df)
31
-
32
- logger.info(f"Exported external_ports for {self.sheet_name}")
33
- except Exception as e:
34
- logger.warning(f"Exporting external_ports for {self.sheet_name} error: {e}")
1
+ import pandas as pd
2
+
3
+ import logging
4
+
5
+ from openpyxl import load_workbook
6
+
7
+ from osi_dump import util
8
+ from osi_dump.exporter.external_port.external_port_exporter import ExternalPortExporter
9
+
10
+ from osi_dump.model.external_port import ExternalPort
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ class ExcelExternalPortExporter(ExternalPortExporter):
16
+ def __init__(self, sheet_name: str, output_file: str):
17
+ self.sheet_name = sheet_name
18
+ self.output_file = output_file
19
+
20
+ def export_external_ports(self, external_ports: list[ExternalPort]):
21
+
22
+ df = pd.DataFrame(
23
+ [external_port.model_dump() for external_port in external_ports]
24
+ )
25
+
26
+ df = util.panda_excel.expand_list_column(df, "allowed_address_pairs")
27
+
28
+ logger.info(f"Exporting external_ports for {self.sheet_name}")
29
+ try:
30
+ util.export_data_excel(self.output_file, sheet_name=self.sheet_name, df=df)
31
+
32
+ logger.info(f"Exported external_ports for {self.sheet_name}")
33
+ except Exception as e:
34
+ logger.warning(f"Exporting external_ports for {self.sheet_name} error: {e}")
@@ -1,7 +1,7 @@
1
- from abc import ABC, abstractmethod
2
-
3
-
4
- class ExternalPortExporter(ABC):
5
- @abstractmethod
6
- def export_external_ports(self, projects, output_file: str):
7
- pass
1
+ from abc import ABC, abstractmethod
2
+
3
+
4
+ class ExternalPortExporter(ABC):
5
+ @abstractmethod
6
+ def export_external_ports(self, projects, output_file: str):
7
+ pass
@@ -1,30 +1,30 @@
1
- import logging
2
-
3
-
4
- import pandas as pd
5
-
6
-
7
- from osi_dump.exporter.flavor.flavor_exporter import FlavorExporter
8
-
9
- from osi_dump.model.flavor import Flavor
10
-
11
- from osi_dump import util
12
-
13
- logger = logging.getLogger(__name__)
14
-
15
-
16
- class ExcelFlavorExporter(FlavorExporter):
17
- def __init__(self, sheet_name: str, output_file: str):
18
- self.sheet_name = sheet_name
19
- self.output_file = output_file
20
-
21
- def export_flavors(self, flavors: list[Flavor]):
22
- df = pd.json_normalize([flavor.model_dump() for flavor in flavors])
23
-
24
- logger.info(f"Exporting flavors for {self.sheet_name}")
25
- try:
26
- util.export_data_excel(self.output_file, sheet_name=self.sheet_name, df=df)
27
-
28
- logger.info(f"Exported flavors for {self.sheet_name}")
29
- except Exception as e:
30
- logger.warning(f"Exporting flavors for {self.sheet_name} error: {e}")
1
+ import logging
2
+
3
+
4
+ import pandas as pd
5
+
6
+
7
+ from osi_dump.exporter.flavor.flavor_exporter import FlavorExporter
8
+
9
+ from osi_dump.model.flavor import Flavor
10
+
11
+ from osi_dump import util
12
+
13
+ logger = logging.getLogger(__name__)
14
+
15
+
16
+ class ExcelFlavorExporter(FlavorExporter):
17
+ def __init__(self, sheet_name: str, output_file: str):
18
+ self.sheet_name = sheet_name
19
+ self.output_file = output_file
20
+
21
+ def export_flavors(self, flavors: list[Flavor]):
22
+ df = pd.json_normalize([flavor.model_dump() for flavor in flavors])
23
+
24
+ logger.info(f"Exporting flavors for {self.sheet_name}")
25
+ try:
26
+ util.export_data_excel(self.output_file, sheet_name=self.sheet_name, df=df)
27
+
28
+ logger.info(f"Exported flavors for {self.sheet_name}")
29
+ except Exception as e:
30
+ logger.warning(f"Exporting flavors for {self.sheet_name} error: {e}")