osi-dump 0.1.3.3.4.2__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.
- osi_dump/__main__.py +4 -4
- osi_dump/api/keystone.py +70 -70
- osi_dump/api/neutron.py +65 -65
- osi_dump/api/octavia.py +94 -94
- osi_dump/api/placement.py +41 -41
- osi_dump/batch_handler/__init__.py +6 -5
- osi_dump/batch_handler/external_port_batch_handler.py +55 -55
- osi_dump/batch_handler/flavor_batch_handler.py +51 -51
- osi_dump/batch_handler/floating_ip_batch_handler.py +57 -57
- osi_dump/batch_handler/hypervisor_batch_handler.py +55 -55
- osi_dump/batch_handler/image_batch_handler.py +51 -51
- osi_dump/batch_handler/instance_batch_handler.py +46 -54
- osi_dump/batch_handler/load_balancer_batch_handler.py +59 -59
- osi_dump/batch_handler/network_batch_handler.py +51 -51
- osi_dump/batch_handler/project_batch_handler.py +51 -51
- osi_dump/batch_handler/role_assignment_batch_handler.py +38 -61
- osi_dump/batch_handler/router_batch_handler.py +49 -49
- osi_dump/batch_handler/security_group_batch_handler.py +37 -0
- osi_dump/batch_handler/volume_batch_handler.py +45 -45
- osi_dump/cli.py +267 -257
- osi_dump/exporter/external_port/excel_external_port_exporter.py +34 -34
- osi_dump/exporter/external_port/external_port_exporter.py +7 -7
- osi_dump/exporter/flavor/excel_flavor_exporter.py +30 -30
- osi_dump/exporter/flavor/flavor_exporter.py +7 -7
- osi_dump/exporter/floating_ip/excel_floating_ip_exporter.py +30 -30
- osi_dump/exporter/floating_ip/floating_ip_exporter.py +7 -7
- osi_dump/exporter/hypervisor/excel_hypervisor_exporter.py +32 -32
- osi_dump/exporter/hypervisor/hypervisor_exporter.py +7 -7
- osi_dump/exporter/image/excel_image_exporter.py +28 -28
- osi_dump/exporter/image/image_exporter.py +7 -7
- osi_dump/exporter/instance/excel_instance_exporter.py +29 -29
- osi_dump/exporter/instance/instance_exporter.py +8 -7
- osi_dump/exporter/load_balancer/excel_load_balancer_exporter.py +36 -36
- osi_dump/exporter/load_balancer/load_balancer_exporter.py +7 -7
- osi_dump/exporter/network/excel_network_exporter.py +32 -32
- osi_dump/exporter/network/network_exporter.py +7 -7
- osi_dump/exporter/project/excel_project_exporter.py +30 -30
- osi_dump/exporter/project/project_exporter.py +7 -7
- osi_dump/exporter/role_assignment/excel_role_assignment_exporter.py +43 -35
- osi_dump/exporter/role_assignment/role_assignment_exporter.py +7 -7
- osi_dump/exporter/router/excel_router_exporter.py +30 -30
- osi_dump/exporter/router/router_exporter.py +7 -7
- osi_dump/exporter/security_group/excel_security_group_exporter.py +35 -0
- osi_dump/exporter/security_group/security_group_exporter.py +8 -0
- osi_dump/exporter/volume/excel_volume_exporter.py +29 -29
- osi_dump/exporter/volume/volume_exporter.py +7 -7
- osi_dump/importer/external_port/external_port_importer.py +9 -9
- osi_dump/importer/external_port/openstack_external_port_importer.py +177 -177
- osi_dump/importer/flavor/flavor_importer.py +9 -9
- osi_dump/importer/flavor/openstack_flavor_importer.py +64 -64
- osi_dump/importer/floating_ip/floating_ip_importer.py +9 -9
- osi_dump/importer/floating_ip/openstack_floating_ip_importer.py +68 -68
- osi_dump/importer/hypervisor/hypervisor_importer.py +9 -9
- osi_dump/importer/hypervisor/openstack_hypervisor_importer.py +137 -137
- osi_dump/importer/image/image_importer.py +9 -9
- osi_dump/importer/image/openstack_image_importer.py +81 -81
- osi_dump/importer/instance/instance_importer.py +8 -9
- osi_dump/importer/instance/openstack_instance_importer.py +136 -136
- osi_dump/importer/load_balancer/load_balancer_importer.py +9 -9
- osi_dump/importer/load_balancer/openstack_load_balancer_importer.py +113 -113
- osi_dump/importer/network/network_importer.py +9 -9
- osi_dump/importer/network/openstack_network_importer.py +93 -93
- osi_dump/importer/project/openstack_project_importer.py +141 -141
- osi_dump/importer/project/project_importer.py +9 -9
- osi_dump/importer/role_assignment/openstack_role_assignment_importer.py +117 -141
- osi_dump/importer/role_assignment/role_assignment_importer.py +16 -9
- osi_dump/importer/router/openstack_router_importer.py +87 -87
- osi_dump/importer/router/router_importer.py +9 -9
- osi_dump/importer/security_group/openstack_security_group_importer.py +54 -0
- osi_dump/importer/security_group/security_group_importer.py +8 -0
- osi_dump/importer/volume/openstack_volume_importer.py +81 -81
- osi_dump/importer/volume/volume_importer.py +9 -9
- osi_dump/model/authentication_info.py +15 -15
- osi_dump/model/external_port.py +30 -30
- osi_dump/model/flavor.py +20 -20
- osi_dump/model/floating_ip.py +24 -24
- osi_dump/model/hypervisor.py +24 -24
- osi_dump/model/image.py +27 -27
- osi_dump/model/instance.py +29 -29
- osi_dump/model/load_balancer.py +26 -26
- osi_dump/model/network.py +25 -25
- osi_dump/model/project.py +33 -33
- osi_dump/model/role_assignment.py +30 -21
- osi_dump/model/router.py +23 -23
- osi_dump/model/security_group.py +22 -0
- osi_dump/model/volume.py +25 -25
- osi_dump/os_connection/get_connections.py +67 -67
- osi_dump/util/__init__.py +7 -7
- osi_dump/util/create_file.py +11 -11
- osi_dump/util/excel_autosize_column.py +39 -39
- osi_dump/util/excel_sort_sheet.py +35 -35
- osi_dump/util/export_data_excel.py +36 -36
- osi_dump/util/extract_hostname.py +5 -5
- osi_dump/util/openstack_util.py +48 -48
- osi_dump/util/panda_excel.py +26 -26
- osi_dump/util/validate_dir_path.py +20 -20
- {osi_dump-0.1.3.3.4.2.dist-info → osi_dump-0.1.4.dist-info}/METADATA +40 -40
- osi_dump-0.1.4.dist-info/RECORD +130 -0
- {osi_dump-0.1.3.3.4.2.dist-info → osi_dump-0.1.4.dist-info}/WHEEL +1 -1
- osi_dump-0.1.3.3.4.2.dist-info/RECORD +0 -124
- {osi_dump-0.1.3.3.4.2.dist-info → osi_dump-0.1.4.dist-info}/entry_points.txt +0 -0
- {osi_dump-0.1.3.3.4.2.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.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
[
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
),
|
236
|
-
]
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
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}")
|