osi-dump 0.1__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/__init__.py +0 -0
- osi_dump/__main__.py +4 -0
- osi_dump/batch_handler/__init__.py +5 -0
- osi_dump/batch_handler/floating_ip_batch_handler.py +57 -0
- osi_dump/batch_handler/hypervisor_batch_handler.py +55 -0
- osi_dump/batch_handler/instance_batch_handler.py +54 -0
- osi_dump/batch_handler/project_batch_handler.py +51 -0
- osi_dump/batch_handler/volume_batch_handler.py +45 -0
- osi_dump/cli.py +156 -0
- osi_dump/exporter/__init__.py +0 -0
- osi_dump/exporter/floating_ip/__init__.py +0 -0
- osi_dump/exporter/floating_ip/excel_floating_ip_exporter.py +30 -0
- osi_dump/exporter/floating_ip/floating_ip_exporter.py +7 -0
- osi_dump/exporter/hypervisor/__init__.py +0 -0
- osi_dump/exporter/hypervisor/excel_hypervisor_exporter.py +30 -0
- osi_dump/exporter/hypervisor/hypervisor_exporter.py +7 -0
- osi_dump/exporter/instance/__init__.py +0 -0
- osi_dump/exporter/instance/excel_instance_exporter.py +29 -0
- osi_dump/exporter/instance/instance_exporter.py +7 -0
- osi_dump/exporter/project/__init__.py +0 -0
- osi_dump/exporter/project/excel_project_exporter.py +30 -0
- osi_dump/exporter/project/project_exporter.py +7 -0
- osi_dump/exporter/volume/__init__.py +0 -0
- osi_dump/exporter/volume/excel_volume_exporter.py +29 -0
- osi_dump/exporter/volume/volume_exporter.py +7 -0
- osi_dump/importer/floating_ip/__init__.py +0 -0
- osi_dump/importer/floating_ip/floating_ip_importer.py +9 -0
- osi_dump/importer/floating_ip/openstack_floating_ip_importer.py +68 -0
- osi_dump/importer/hypervisor/__init__.py +0 -0
- osi_dump/importer/hypervisor/hypervisor_importer.py +9 -0
- osi_dump/importer/hypervisor/openstack_hypervisor_importer.py +79 -0
- osi_dump/importer/instance/__init__.py +0 -0
- osi_dump/importer/instance/instance_importer.py +9 -0
- osi_dump/importer/instance/openstack_instance_importer.py +107 -0
- osi_dump/importer/project/__init__.py +0 -0
- osi_dump/importer/project/openstack_project_importer.py +60 -0
- osi_dump/importer/project/project_importer.py +9 -0
- osi_dump/importer/volume/__init__.py +0 -0
- osi_dump/importer/volume/openstack_volume_importer.py +64 -0
- osi_dump/importer/volume/volume_importer.py +9 -0
- osi_dump/model/__init__.py +0 -0
- osi_dump/model/authentication_info.py +12 -0
- osi_dump/model/floating_ip.py +24 -0
- osi_dump/model/hypervisor.py +12 -0
- osi_dump/model/instance.py +20 -0
- osi_dump/model/project.py +13 -0
- osi_dump/model/volume.py +21 -0
- osi_dump/os_connection/__init__.py +0 -0
- osi_dump/os_connection/get_connections.py +67 -0
- osi_dump/util/__init__.py +6 -0
- osi_dump/util/create_file.py +11 -0
- osi_dump/util/excel_autosize_column.py +39 -0
- osi_dump/util/excel_sort_sheet.py +35 -0
- osi_dump/util/export_data_excel.py +36 -0
- osi_dump/util/extract_hostname.py +5 -0
- osi_dump/util/validate_dir_path.py +20 -0
- osi_dump-0.1.dist-info/METADATA +39 -0
- osi_dump-0.1.dist-info/RECORD +61 -0
- osi_dump-0.1.dist-info/WHEEL +5 -0
- osi_dump-0.1.dist-info/entry_points.txt +2 -0
- osi_dump-0.1.dist-info/top_level.txt +1 -0
osi_dump/__init__.py
ADDED
File without changes
|
osi_dump/__main__.py
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
from .instance_batch_handler import InstanceBatchHandler
|
2
|
+
from .project_batch_handler import ProjectBatchHandler
|
3
|
+
from .hypervisor_batch_handler import HypervisorBatchHandler
|
4
|
+
from .floating_ip_batch_handler import FloatingIPBatchHandler
|
5
|
+
from .volume_batch_handler import VolumeBatchHandler
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from openstack.connection import Connection
|
4
|
+
|
5
|
+
from osi_dump.exporter.floating_ip.floating_ip_exporter import FloatingIPExporter
|
6
|
+
from osi_dump.exporter.floating_ip.excel_floating_ip_exporter import (
|
7
|
+
ExcelFloatingIPExporter,
|
8
|
+
)
|
9
|
+
|
10
|
+
from osi_dump.importer.floating_ip.floating_ip_importer import FloatingIPImporter
|
11
|
+
from osi_dump.importer.floating_ip.openstack_floating_ip_importer import (
|
12
|
+
OpenStackFloatingIPImporter,
|
13
|
+
)
|
14
|
+
|
15
|
+
|
16
|
+
from osi_dump import util
|
17
|
+
|
18
|
+
logger = logging.getLogger(__name__)
|
19
|
+
|
20
|
+
|
21
|
+
class FloatingIPBatchHandler:
|
22
|
+
def __init__(self):
|
23
|
+
self._importer_exporter_list: list[
|
24
|
+
tuple[FloatingIPImporter, FloatingIPExporter]
|
25
|
+
] = []
|
26
|
+
|
27
|
+
def add_importer_exporter_from_openstack_connections(
|
28
|
+
self, connections: list[Connection], output_file: str
|
29
|
+
):
|
30
|
+
for connection in connections:
|
31
|
+
importer = OpenStackFloatingIPImporter(connection)
|
32
|
+
|
33
|
+
sheet_name = (
|
34
|
+
f"{util.extract_hostname(connection.auth['auth_url'])}-floating-ip"
|
35
|
+
)
|
36
|
+
exporter = ExcelFloatingIPExporter(
|
37
|
+
sheet_name=sheet_name, output_file=output_file
|
38
|
+
)
|
39
|
+
|
40
|
+
self.add_importer_exporter(importer=importer, exporter=exporter)
|
41
|
+
|
42
|
+
def add_importer_exporter(
|
43
|
+
self, importer: FloatingIPImporter, exporter: FloatingIPExporter
|
44
|
+
):
|
45
|
+
self._importer_exporter_list.append((importer, exporter))
|
46
|
+
|
47
|
+
def process(self):
|
48
|
+
|
49
|
+
for importer, exporter in self._importer_exporter_list:
|
50
|
+
try:
|
51
|
+
|
52
|
+
floating_ips = importer.import_floating_ips()
|
53
|
+
|
54
|
+
exporter.export_floating_ips(floating_ips=floating_ips)
|
55
|
+
except Exception as e:
|
56
|
+
logger.warning(e)
|
57
|
+
logger.warning("Skipping...")
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from openstack.connection import Connection
|
4
|
+
|
5
|
+
from osi_dump.exporter.hypervisor.hypervisor_exporter import HypervisorExporter
|
6
|
+
from osi_dump.exporter.hypervisor.excel_hypervisor_exporter import (
|
7
|
+
ExcelHypervisorExporter,
|
8
|
+
)
|
9
|
+
|
10
|
+
from osi_dump.importer.hypervisor.hypervisor_importer import HypervisorImporter
|
11
|
+
from osi_dump.importer.hypervisor.openstack_hypervisor_importer import (
|
12
|
+
OpenStackHypervisorImporter,
|
13
|
+
)
|
14
|
+
|
15
|
+
|
16
|
+
from osi_dump import util
|
17
|
+
|
18
|
+
logger = logging.getLogger(__name__)
|
19
|
+
|
20
|
+
|
21
|
+
class HypervisorBatchHandler:
|
22
|
+
def __init__(self):
|
23
|
+
self._importer_exporter_list: list[
|
24
|
+
tuple[HypervisorImporter, HypervisorExporter]
|
25
|
+
] = []
|
26
|
+
|
27
|
+
def add_importer_exporter_from_openstack_connections(
|
28
|
+
self, connections: list[Connection], output_file: str
|
29
|
+
):
|
30
|
+
for connection in connections:
|
31
|
+
importer = OpenStackHypervisorImporter(connection)
|
32
|
+
|
33
|
+
sheet_name = (
|
34
|
+
f"{util.extract_hostname(connection.auth['auth_url'])}-hypervisor"
|
35
|
+
)
|
36
|
+
exporter = ExcelHypervisorExporter(
|
37
|
+
sheet_name=sheet_name, output_file=output_file
|
38
|
+
)
|
39
|
+
|
40
|
+
self.add_importer_exporter(importer=importer, exporter=exporter)
|
41
|
+
|
42
|
+
def add_importer_exporter(
|
43
|
+
self, importer: HypervisorImporter, exporter: HypervisorExporter
|
44
|
+
):
|
45
|
+
self._importer_exporter_list.append((importer, exporter))
|
46
|
+
|
47
|
+
def process(self):
|
48
|
+
for importer, exporter in self._importer_exporter_list:
|
49
|
+
try:
|
50
|
+
hypervisors = importer.import_hypervisors()
|
51
|
+
|
52
|
+
exporter.export_hypervisors(hypervisors=hypervisors)
|
53
|
+
except Exception as e:
|
54
|
+
logger.warning(e)
|
55
|
+
logger.warning("Skipping...")
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from openstack.connection import Connection
|
4
|
+
|
5
|
+
from osi_dump.exporter.instance.excel_instance_exporter import ExcelInstanceExporter
|
6
|
+
from osi_dump.exporter.instance.instance_exporter import InstanceExporter
|
7
|
+
from osi_dump.importer.instance.instance_importer import InstanceImporter
|
8
|
+
from osi_dump.importer.instance.openstack_instance_importer import (
|
9
|
+
OpenStackInstanceImporter,
|
10
|
+
)
|
11
|
+
|
12
|
+
|
13
|
+
from osi_dump import util
|
14
|
+
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
17
|
+
|
18
|
+
class InstanceBatchHandler:
|
19
|
+
def __init__(self):
|
20
|
+
self._importer_exporter_list: list[
|
21
|
+
tuple[InstanceImporter, InstanceExporter]
|
22
|
+
] = []
|
23
|
+
|
24
|
+
def add_importer_exporter_from_openstack_connections(
|
25
|
+
self, connections: list[Connection], output_file: str
|
26
|
+
):
|
27
|
+
for connection in connections:
|
28
|
+
instance_importer = OpenStackInstanceImporter(connection)
|
29
|
+
|
30
|
+
sheet_name = (
|
31
|
+
f"{util.extract_hostname(connection.auth['auth_url'])}-instance"
|
32
|
+
)
|
33
|
+
instance_exporter = ExcelInstanceExporter(
|
34
|
+
sheet_name=sheet_name, output_file=output_file
|
35
|
+
)
|
36
|
+
|
37
|
+
self.add_importer_exporter(
|
38
|
+
importer=instance_importer, exporter=instance_exporter
|
39
|
+
)
|
40
|
+
|
41
|
+
def add_importer_exporter(
|
42
|
+
self, importer: InstanceImporter, exporter: InstanceExporter
|
43
|
+
):
|
44
|
+
self._importer_exporter_list.append((importer, exporter))
|
45
|
+
|
46
|
+
def process(self):
|
47
|
+
for importer, exporter in self._importer_exporter_list:
|
48
|
+
try:
|
49
|
+
instances = importer.import_instances()
|
50
|
+
|
51
|
+
exporter.export_instances(instances=instances)
|
52
|
+
except Exception as e:
|
53
|
+
logger.warning(e)
|
54
|
+
logger.warning("Skipping...")
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from openstack.connection import Connection
|
4
|
+
|
5
|
+
from osi_dump.exporter.project.project_exporter import (
|
6
|
+
ProjectExporter,
|
7
|
+
)
|
8
|
+
from osi_dump.exporter.project.excel_project_exporter import ExcelProjectExporter
|
9
|
+
|
10
|
+
from osi_dump.importer.project.project_importer import ProjectImporter
|
11
|
+
from osi_dump.importer.project.openstack_project_importer import (
|
12
|
+
OpenStackProjectImporter,
|
13
|
+
)
|
14
|
+
|
15
|
+
|
16
|
+
from osi_dump import util
|
17
|
+
|
18
|
+
logger = logging.getLogger(__name__)
|
19
|
+
|
20
|
+
|
21
|
+
class ProjectBatchHandler:
|
22
|
+
def __init__(self):
|
23
|
+
self._importer_exporter_list: list[tuple[ProjectImporter, ProjectExporter]] = []
|
24
|
+
|
25
|
+
def add_importer_exporter_from_openstack_connections(
|
26
|
+
self, connections: list[Connection], output_file: str
|
27
|
+
):
|
28
|
+
for connection in connections:
|
29
|
+
importer = OpenStackProjectImporter(connection)
|
30
|
+
|
31
|
+
sheet_name = f"{util.extract_hostname(connection.auth['auth_url'])}-project"
|
32
|
+
exporter = ExcelProjectExporter(
|
33
|
+
sheet_name=sheet_name, output_file=output_file
|
34
|
+
)
|
35
|
+
|
36
|
+
self.add_importer_exporter(importer=importer, exporter=exporter)
|
37
|
+
|
38
|
+
def add_importer_exporter(
|
39
|
+
self, importer: ProjectImporter, exporter: ProjectExporter
|
40
|
+
):
|
41
|
+
self._importer_exporter_list.append((importer, exporter))
|
42
|
+
|
43
|
+
def process(self):
|
44
|
+
for importer, exporter in self._importer_exporter_list:
|
45
|
+
try:
|
46
|
+
projects = importer.import_projects()
|
47
|
+
|
48
|
+
exporter.export_projects(projects=projects)
|
49
|
+
except Exception as e:
|
50
|
+
logger.warning(e)
|
51
|
+
logger.warning("Skipping...")
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from openstack.connection import Connection
|
4
|
+
|
5
|
+
|
6
|
+
from osi_dump.exporter.volume.excel_volume_exporter import ExcelVolumeExporter
|
7
|
+
from osi_dump.exporter.volume.volume_exporter import VolumeExporter
|
8
|
+
|
9
|
+
|
10
|
+
from osi_dump import util
|
11
|
+
from osi_dump.importer.volume.openstack_volume_importer import OpenStackVolumeImporter
|
12
|
+
from osi_dump.importer.volume.volume_importer import VolumeImporter
|
13
|
+
|
14
|
+
logger = logging.getLogger(__name__)
|
15
|
+
|
16
|
+
|
17
|
+
class VolumeBatchHandler:
|
18
|
+
def __init__(self):
|
19
|
+
self._importer_exporter_list: list[tuple[VolumeImporter, VolumeExporter]] = []
|
20
|
+
|
21
|
+
def add_importer_exporter_from_openstack_connections(
|
22
|
+
self, connections: list[Connection], output_file: str
|
23
|
+
):
|
24
|
+
for connection in connections:
|
25
|
+
importer = OpenStackVolumeImporter(connection)
|
26
|
+
|
27
|
+
sheet_name = f"{util.extract_hostname(connection.auth['auth_url'])}-volume"
|
28
|
+
exporter = ExcelVolumeExporter(
|
29
|
+
sheet_name=sheet_name, output_file=output_file
|
30
|
+
)
|
31
|
+
|
32
|
+
self.add_importer_exporter(importer=importer, exporter=exporter)
|
33
|
+
|
34
|
+
def add_importer_exporter(self, importer: VolumeImporter, exporter: VolumeExporter):
|
35
|
+
self._importer_exporter_list.append((importer, exporter))
|
36
|
+
|
37
|
+
def process(self):
|
38
|
+
for importer, exporter in self._importer_exporter_list:
|
39
|
+
try:
|
40
|
+
volumes = importer.import_volumes()
|
41
|
+
|
42
|
+
exporter.export_volumes(volumes=volumes)
|
43
|
+
except Exception as e:
|
44
|
+
logger.warning(e)
|
45
|
+
logger.warning("Skipping...")
|
osi_dump/cli.py
ADDED
@@ -0,0 +1,156 @@
|
|
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
|
+
app = typer.Typer()
|
12
|
+
|
13
|
+
|
14
|
+
from osi_dump.batch_handler.volume_batch_handler import VolumeBatchHandler
|
15
|
+
from osi_dump.os_connection.get_connections import get_connections
|
16
|
+
|
17
|
+
|
18
|
+
from osi_dump.batch_handler import (
|
19
|
+
InstanceBatchHandler,
|
20
|
+
ProjectBatchHandler,
|
21
|
+
HypervisorBatchHandler,
|
22
|
+
FloatingIPBatchHandler,
|
23
|
+
)
|
24
|
+
|
25
|
+
|
26
|
+
from osi_dump import util
|
27
|
+
|
28
|
+
|
29
|
+
def _instance(connections, output_path: str):
|
30
|
+
instance_batch_handler = InstanceBatchHandler()
|
31
|
+
|
32
|
+
instance_batch_handler.add_importer_exporter_from_openstack_connections(
|
33
|
+
connections, output_file=output_path
|
34
|
+
)
|
35
|
+
|
36
|
+
instance_batch_handler.process()
|
37
|
+
|
38
|
+
|
39
|
+
def _floating_ip(connections, output_path: str):
|
40
|
+
floating_ip_batch_handler = FloatingIPBatchHandler()
|
41
|
+
|
42
|
+
floating_ip_batch_handler.add_importer_exporter_from_openstack_connections(
|
43
|
+
connections, output_file=output_path
|
44
|
+
)
|
45
|
+
|
46
|
+
floating_ip_batch_handler.process()
|
47
|
+
|
48
|
+
|
49
|
+
def _volume(connections, output_path: str):
|
50
|
+
volume_batch_handler = VolumeBatchHandler()
|
51
|
+
|
52
|
+
volume_batch_handler.add_importer_exporter_from_openstack_connections(
|
53
|
+
connections, output_file=output_path
|
54
|
+
)
|
55
|
+
|
56
|
+
volume_batch_handler.process()
|
57
|
+
|
58
|
+
|
59
|
+
def _project(connections, output_path: str):
|
60
|
+
project_batch_handler = ProjectBatchHandler()
|
61
|
+
|
62
|
+
project_batch_handler.add_importer_exporter_from_openstack_connections(
|
63
|
+
connections, output_file=output_path
|
64
|
+
)
|
65
|
+
|
66
|
+
project_batch_handler.process()
|
67
|
+
|
68
|
+
|
69
|
+
def _hypervisor(connections, output_path: str):
|
70
|
+
hypervisor_batch_handler = HypervisorBatchHandler()
|
71
|
+
|
72
|
+
hypervisor_batch_handler.add_importer_exporter_from_openstack_connections(
|
73
|
+
connections, output_file=output_path
|
74
|
+
)
|
75
|
+
|
76
|
+
hypervisor_batch_handler.process()
|
77
|
+
|
78
|
+
|
79
|
+
def inner_main(file_path: str, output_path: str):
|
80
|
+
|
81
|
+
logger = logging.getLogger(__name__)
|
82
|
+
|
83
|
+
connections = get_connections(file_path=file_path)
|
84
|
+
|
85
|
+
_instance(connections=connections, output_path=output_path)
|
86
|
+
|
87
|
+
_floating_ip(connections=connections, output_path=output_path)
|
88
|
+
|
89
|
+
_volume(connections=connections, output_path=output_path)
|
90
|
+
|
91
|
+
_hypervisor(connections=connections, output_path=output_path)
|
92
|
+
|
93
|
+
_project(connections=connections, output_path=output_path)
|
94
|
+
|
95
|
+
util.excel_autosize_column(output_path)
|
96
|
+
|
97
|
+
util.excel_sort_sheet(output_path)
|
98
|
+
|
99
|
+
logger.info(
|
100
|
+
f"Exported OpenStack information to file: {os.path.abspath(output_path)}"
|
101
|
+
)
|
102
|
+
|
103
|
+
|
104
|
+
def main(
|
105
|
+
file_path: Annotated[
|
106
|
+
Path,
|
107
|
+
typer.Argument(
|
108
|
+
help=(
|
109
|
+
"""
|
110
|
+
Path of the file containing OpenStack authentication information.
|
111
|
+
|
112
|
+
The expected JSON file format is as follows:
|
113
|
+
|
114
|
+
\b
|
115
|
+
[
|
116
|
+
{
|
117
|
+
"auth_url": "string",
|
118
|
+
"project_name": "string",
|
119
|
+
"username": "string",
|
120
|
+
"password": "string",
|
121
|
+
"user_domain_name": "string",
|
122
|
+
"project_domain_name": "string"
|
123
|
+
}
|
124
|
+
]
|
125
|
+
"""
|
126
|
+
)
|
127
|
+
),
|
128
|
+
],
|
129
|
+
output_path: Annotated[
|
130
|
+
Path,
|
131
|
+
typer.Argument(
|
132
|
+
help="""
|
133
|
+
\b
|
134
|
+
Path of the output file, will override if file already exists
|
135
|
+
|
136
|
+
"""
|
137
|
+
),
|
138
|
+
] = "output.xlsx",
|
139
|
+
):
|
140
|
+
logging.basicConfig(
|
141
|
+
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
|
142
|
+
)
|
143
|
+
|
144
|
+
logger = logging.getLogger(__name__)
|
145
|
+
|
146
|
+
if util.validate_dir_path(file_path=output_path) is False:
|
147
|
+
logger.error(f"Invalid path: {output_path}, folder does not exist.")
|
148
|
+
raise typer.Exit(1)
|
149
|
+
|
150
|
+
inner_main(file_path=file_path, output_path=output_path)
|
151
|
+
|
152
|
+
|
153
|
+
app.command()(main)
|
154
|
+
|
155
|
+
if __name__ == "__main__":
|
156
|
+
app()
|
File without changes
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from openpyxl import load_workbook
|
4
|
+
import pandas as pd
|
5
|
+
|
6
|
+
|
7
|
+
from osi_dump.exporter.floating_ip.floating_ip_exporter import FloatingIPExporter
|
8
|
+
|
9
|
+
from osi_dump.model.floating_ip import FloatingIP
|
10
|
+
|
11
|
+
from osi_dump import util
|
12
|
+
|
13
|
+
logger = logging.getLogger(__name__)
|
14
|
+
|
15
|
+
|
16
|
+
class ExcelFloatingIPExporter(FloatingIPExporter):
|
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_floating_ips(self, floating_ips: list[FloatingIP]):
|
22
|
+
df = pd.DataFrame([floating_ip.model_dump() for floating_ip in floating_ips])
|
23
|
+
|
24
|
+
logger.info(f"Exporting floating ips 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 floating ips for {self.sheet_name}")
|
29
|
+
except Exception as e:
|
30
|
+
logger.warning(f"Exporting floating ips for {self.sheet_name} error: {e}")
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from openpyxl import load_workbook
|
4
|
+
import pandas as pd
|
5
|
+
|
6
|
+
|
7
|
+
from osi_dump.exporter.hypervisor.hypervisor_exporter import HypervisorExporter
|
8
|
+
|
9
|
+
from osi_dump.model.hypervisor import Hypervisor
|
10
|
+
|
11
|
+
from osi_dump import util
|
12
|
+
|
13
|
+
logger = logging.getLogger(__name__)
|
14
|
+
|
15
|
+
|
16
|
+
class ExcelHypervisorExporter(HypervisorExporter):
|
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_hypervisors(self, hypervisors: list[Hypervisor]):
|
22
|
+
df = pd.DataFrame([hypervisor.model_dump() for hypervisor in hypervisors])
|
23
|
+
|
24
|
+
logger.info(f"Exporting hypervisors 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 hypervisors for {self.sheet_name}")
|
29
|
+
except Exception as e:
|
30
|
+
logger.warning(f"Exporting hypervisors for {self.sheet_name} error: {e}")
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
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.instance.instance_exporter import InstanceExporter
|
9
|
+
|
10
|
+
from osi_dump.model.instance import Instance
|
11
|
+
|
12
|
+
logger = logging.getLogger(__name__)
|
13
|
+
|
14
|
+
|
15
|
+
class ExcelInstanceExporter(InstanceExporter):
|
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_instances(self, instances: list[Instance]):
|
21
|
+
df = pd.DataFrame([instance.model_dump() for instance in instances])
|
22
|
+
|
23
|
+
logger.info(f"Exporting instances for {self.sheet_name}")
|
24
|
+
try:
|
25
|
+
util.export_data_excel(self.output_file, sheet_name=self.sheet_name, df=df)
|
26
|
+
|
27
|
+
logger.info(f"Exported instances for {self.sheet_name}")
|
28
|
+
except Exception as e:
|
29
|
+
logger.warning(f"Exporting instances for {self.sheet_name} error: {e}")
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
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.project.project_exporter import ProjectExporter
|
9
|
+
|
10
|
+
from osi_dump.model.project import Project
|
11
|
+
|
12
|
+
logger = logging.getLogger(__name__)
|
13
|
+
|
14
|
+
|
15
|
+
class ExcelProjectExporter(ProjectExporter):
|
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_projects(self, projects: list[Project]):
|
21
|
+
|
22
|
+
df = pd.DataFrame([project.model_dump() for project in projects])
|
23
|
+
|
24
|
+
logger.info(f"Exporting projects 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 projects for {self.sheet_name}")
|
29
|
+
except Exception as e:
|
30
|
+
logger.warning(f"Exporting projects for {self.sheet_name} error: {e}")
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import pandas as pd
|
2
|
+
|
3
|
+
import logging
|
4
|
+
|
5
|
+
|
6
|
+
from osi_dump import util
|
7
|
+
|
8
|
+
from osi_dump.exporter.volume.volume_exporter import VolumeExporter
|
9
|
+
|
10
|
+
from osi_dump.model.volume import Volume
|
11
|
+
|
12
|
+
logger = logging.getLogger(__name__)
|
13
|
+
|
14
|
+
|
15
|
+
class ExcelVolumeExporter(VolumeExporter):
|
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_volumes(self, volumes: list[Volume]):
|
21
|
+
df = pd.DataFrame([volume.model_dump() for volume in volumes])
|
22
|
+
|
23
|
+
logger.info(f"Exporting volumes for {self.sheet_name}")
|
24
|
+
try:
|
25
|
+
util.export_data_excel(self.output_file, sheet_name=self.sheet_name, df=df)
|
26
|
+
|
27
|
+
logger.info(f"Exported volumes for {self.sheet_name}")
|
28
|
+
except Exception as e:
|
29
|
+
logger.warning(f"Exporting volumes for {self.sheet_name} error: {e}")
|
File without changes
|