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.
Files changed (61) hide show
  1. osi_dump/__init__.py +0 -0
  2. osi_dump/__main__.py +4 -0
  3. osi_dump/batch_handler/__init__.py +5 -0
  4. osi_dump/batch_handler/floating_ip_batch_handler.py +57 -0
  5. osi_dump/batch_handler/hypervisor_batch_handler.py +55 -0
  6. osi_dump/batch_handler/instance_batch_handler.py +54 -0
  7. osi_dump/batch_handler/project_batch_handler.py +51 -0
  8. osi_dump/batch_handler/volume_batch_handler.py +45 -0
  9. osi_dump/cli.py +156 -0
  10. osi_dump/exporter/__init__.py +0 -0
  11. osi_dump/exporter/floating_ip/__init__.py +0 -0
  12. osi_dump/exporter/floating_ip/excel_floating_ip_exporter.py +30 -0
  13. osi_dump/exporter/floating_ip/floating_ip_exporter.py +7 -0
  14. osi_dump/exporter/hypervisor/__init__.py +0 -0
  15. osi_dump/exporter/hypervisor/excel_hypervisor_exporter.py +30 -0
  16. osi_dump/exporter/hypervisor/hypervisor_exporter.py +7 -0
  17. osi_dump/exporter/instance/__init__.py +0 -0
  18. osi_dump/exporter/instance/excel_instance_exporter.py +29 -0
  19. osi_dump/exporter/instance/instance_exporter.py +7 -0
  20. osi_dump/exporter/project/__init__.py +0 -0
  21. osi_dump/exporter/project/excel_project_exporter.py +30 -0
  22. osi_dump/exporter/project/project_exporter.py +7 -0
  23. osi_dump/exporter/volume/__init__.py +0 -0
  24. osi_dump/exporter/volume/excel_volume_exporter.py +29 -0
  25. osi_dump/exporter/volume/volume_exporter.py +7 -0
  26. osi_dump/importer/floating_ip/__init__.py +0 -0
  27. osi_dump/importer/floating_ip/floating_ip_importer.py +9 -0
  28. osi_dump/importer/floating_ip/openstack_floating_ip_importer.py +68 -0
  29. osi_dump/importer/hypervisor/__init__.py +0 -0
  30. osi_dump/importer/hypervisor/hypervisor_importer.py +9 -0
  31. osi_dump/importer/hypervisor/openstack_hypervisor_importer.py +79 -0
  32. osi_dump/importer/instance/__init__.py +0 -0
  33. osi_dump/importer/instance/instance_importer.py +9 -0
  34. osi_dump/importer/instance/openstack_instance_importer.py +107 -0
  35. osi_dump/importer/project/__init__.py +0 -0
  36. osi_dump/importer/project/openstack_project_importer.py +60 -0
  37. osi_dump/importer/project/project_importer.py +9 -0
  38. osi_dump/importer/volume/__init__.py +0 -0
  39. osi_dump/importer/volume/openstack_volume_importer.py +64 -0
  40. osi_dump/importer/volume/volume_importer.py +9 -0
  41. osi_dump/model/__init__.py +0 -0
  42. osi_dump/model/authentication_info.py +12 -0
  43. osi_dump/model/floating_ip.py +24 -0
  44. osi_dump/model/hypervisor.py +12 -0
  45. osi_dump/model/instance.py +20 -0
  46. osi_dump/model/project.py +13 -0
  47. osi_dump/model/volume.py +21 -0
  48. osi_dump/os_connection/__init__.py +0 -0
  49. osi_dump/os_connection/get_connections.py +67 -0
  50. osi_dump/util/__init__.py +6 -0
  51. osi_dump/util/create_file.py +11 -0
  52. osi_dump/util/excel_autosize_column.py +39 -0
  53. osi_dump/util/excel_sort_sheet.py +35 -0
  54. osi_dump/util/export_data_excel.py +36 -0
  55. osi_dump/util/extract_hostname.py +5 -0
  56. osi_dump/util/validate_dir_path.py +20 -0
  57. osi_dump-0.1.dist-info/METADATA +39 -0
  58. osi_dump-0.1.dist-info/RECORD +61 -0
  59. osi_dump-0.1.dist-info/WHEEL +5 -0
  60. osi_dump-0.1.dist-info/entry_points.txt +2 -0
  61. osi_dump-0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,35 @@
1
+ import logging
2
+
3
+ from openpyxl import load_workbook
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+
8
+ def excel_sort_sheet(file_path):
9
+ """
10
+ Sorts sheets in an Excel workbook alphabetically and saves the workbook.
11
+
12
+ Args:
13
+ file_path (str): The path to the Excel file to be sorted.
14
+ """
15
+ try:
16
+ # Load the existing workbook
17
+ workbook = load_workbook(file_path)
18
+
19
+ # Get the current sheet names
20
+ sheet_names = workbook.sheetnames
21
+
22
+ # Sort sheet names alphabetically
23
+ sorted_sheet_names = sorted(sheet_names)
24
+
25
+ # Reorder sheets in the workbook
26
+ for index, sheet_name in enumerate(sorted_sheet_names):
27
+ sheet = workbook[sheet_name]
28
+ workbook._sheets.remove(sheet) # Remove the sheet from its current position
29
+ workbook._sheets.insert(index, sheet) # Insert it at the new position
30
+
31
+ # Save the workbook with the sheets reordered
32
+ workbook.save(file_path)
33
+
34
+ except Exception as e:
35
+ logger.warning(f"Error in sorting sheet: {e}")
@@ -0,0 +1,36 @@
1
+ import logging
2
+
3
+ import os
4
+
5
+ import pandas as pd
6
+
7
+ from openpyxl import load_workbook
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+ BOOTSTRAP_SHEET = "sheet1"
12
+
13
+
14
+ def export_data_excel(file_path: str, sheet_name: str, df: pd.DataFrame):
15
+
16
+ if not os.path.exists(file_path):
17
+ with pd.ExcelWriter(path=file_path, engine="openpyxl") as writer:
18
+ empty_df = pd.DataFrame()
19
+
20
+ empty_df.to_excel(writer, sheet_name=BOOTSTRAP_SHEET, index=False)
21
+
22
+ try:
23
+ with pd.ExcelWriter(
24
+ path=file_path, engine="openpyxl", mode="a", if_sheet_exists="replace"
25
+ ) as writer:
26
+
27
+ df.to_excel(writer, sheet_name=sheet_name, index=False)
28
+
29
+ except Exception as e:
30
+ logger.warning(e)
31
+
32
+ workbook = load_workbook(file_path)
33
+
34
+ if BOOTSTRAP_SHEET in workbook.sheetnames:
35
+ del workbook[BOOTSTRAP_SHEET]
36
+ workbook.save(file_path)
@@ -0,0 +1,5 @@
1
+ from urllib.parse import urlparse
2
+
3
+
4
+ def extract_hostname(link: str) -> str:
5
+ return urlparse(link).hostname
@@ -0,0 +1,20 @@
1
+ import os
2
+
3
+
4
+ def validate_dir_path(file_path: str):
5
+ """
6
+ Extracts the directory path from a file path and checks if it is valid.
7
+
8
+ Args:
9
+ file_path (str): The file path to extract the directory from.
10
+
11
+ Returns:
12
+ str: The directory path if it exists, otherwise an appropriate message.
13
+ """
14
+ # Extract the directory path
15
+ dir_path = os.path.dirname(file_path)
16
+
17
+ if not dir_path:
18
+ return True
19
+ # Check if the directory exists
20
+ return os.path.exists(dir_path)
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.1
2
+ Name: osi-dump
3
+ Version: 0.1
4
+ Summary: OpenStack instances information dump tool
5
+ Author: TVKain
6
+ License: Apache-2.0
7
+ Classifier: License :: OSI Approved :: Apache Software License
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: typer
11
+ Requires-Dist: openstacksdk
12
+ Requires-Dist: pydantic
13
+ Requires-Dist: pandas
14
+ Requires-Dist: openpyxl
15
+ Provides-Extra: test
16
+ Requires-Dist: pytest ; extra == 'test'
17
+
18
+ # OpenStack Information Dump
19
+
20
+ ## Set up
21
+
22
+ Create virtual environment
23
+
24
+ ```
25
+ python3 -m venv venv
26
+ ```
27
+
28
+ Install packages
29
+
30
+ ```
31
+ pip install .
32
+ ```
33
+
34
+ ## Execute
35
+
36
+ ```
37
+ Usage: osi-dump [OPTIONS] FILE_PATH [OUTPUT_PATH]
38
+ ```
39
+
@@ -0,0 +1,61 @@
1
+ osi_dump/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ osi_dump/__main__.py,sha256=fCVTLFipB-P0872_4j7iOJNNosOMBj3YdHr8TH_fhRY,71
3
+ osi_dump/cli.py,sha256=cTOQA_thCt1ON5eQ-gTA_hFUSN5uPgFPDoOttpyuTNg,3605
4
+ osi_dump/batch_handler/__init__.py,sha256=wsiE42GCjbKgXBzpiahWEDF_-IXCKzr6PyrLn0oEKSc,288
5
+ osi_dump/batch_handler/floating_ip_batch_handler.py,sha256=bEkT4BRi85qir-a1i7eEI_arA0LENq1gD6xHj8IdXu0,1771
6
+ osi_dump/batch_handler/hypervisor_batch_handler.py,sha256=vkv6SAx1arPNVvFJ6RyvbJjC2F2Hes9km7dwhL4NJDY,1755
7
+ osi_dump/batch_handler/instance_batch_handler.py,sha256=tiHAdhH76BT9-ymnTmTr962cMUTqpPpAQyPSePKEgSM,1761
8
+ osi_dump/batch_handler/project_batch_handler.py,sha256=uMHx_s-Z4tO1MBah5X-T5d6tLr0qUJuPIR_7RHJ64ck,1626
9
+ osi_dump/batch_handler/volume_batch_handler.py,sha256=UAU34FZD8XkJkmlr4Idk4NgFBzjD52PxekJDgV1ekG0,1569
10
+ osi_dump/exporter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ osi_dump/exporter/floating_ip/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ osi_dump/exporter/floating_ip/excel_floating_ip_exporter.py,sha256=Bn1yZTvZ8dP3EhVHW-Pr4O9TC2Cz2RbJaz_vRE66xTQ,975
13
+ osi_dump/exporter/floating_ip/floating_ip_exporter.py,sha256=5qh4xS6m1Gfu2N3WcfkEu6U38qtc6oLWAsnNhSwXTCo,169
14
+ osi_dump/exporter/hypervisor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ osi_dump/exporter/hypervisor/excel_hypervisor_exporter.py,sha256=VhZoVjqCky5Sxvx0R9kxj-7O4tLTaPZKVqxyvqe1YLY,964
16
+ osi_dump/exporter/hypervisor/hypervisor_exporter.py,sha256=HS3U-M-iv-ixNLfkGoaGdjdgHXXTBAjgtWQ_OhVY2xQ,167
17
+ osi_dump/exporter/instance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ osi_dump/exporter/instance/excel_instance_exporter.py,sha256=8WTv3RDOdUkumyWzwUK4KAZCnnq9P2yKi5TC091I9fs,931
19
+ osi_dump/exporter/instance/instance_exporter.py,sha256=5CuKKvTa5S2_Ds7fap6tle4go9pOFmQ5VEf6O7tjwBo,161
20
+ osi_dump/exporter/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ osi_dump/exporter/project/excel_project_exporter.py,sha256=2U3Tvn_Bk4xEQk3Tmh-oj5WXAG1bfxI6m7WVPF1upQw,916
22
+ osi_dump/exporter/project/project_exporter.py,sha256=q3VAmtmBP4iq9YEW9Eescm3vjAVM4Ev3BDjzkGz9Pgo,158
23
+ osi_dump/exporter/volume/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ osi_dump/exporter/volume/excel_volume_exporter.py,sha256=BhesTGXMQF3BAwHgJMYfnxFgHxZo7TKPePG8q9T8ONI,865
25
+ osi_dump/exporter/volume/volume_exporter.py,sha256=YoPvytC0ctWeWwVcG6pb0XwkF4N0QcGAoUHa3QldkEg,155
26
+ osi_dump/importer/floating_ip/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ osi_dump/importer/floating_ip/floating_ip_importer.py,sha256=2_lCZYF-r2dgdL4YzwsJPudDLbRBsSPi7Wt4jS0INiI,208
28
+ osi_dump/importer/floating_ip/openstack_floating_ip_importer.py,sha256=xuALHyiyb4LdRgFN0hZvOx0pImKpGsLUtPWW_1q52gc,2286
29
+ osi_dump/importer/hypervisor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
+ osi_dump/importer/hypervisor/hypervisor_importer.py,sha256=JuoJBltqFYhH-Ql9TLUPHX2YurS0JFV7Augrc6bDJ5Q,206
31
+ osi_dump/importer/hypervisor/openstack_hypervisor_importer.py,sha256=9Y-OsjfOzCKi_DijlHeMv9sgsD_oWB_YXW_lDtVeahM,2567
32
+ osi_dump/importer/instance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
+ osi_dump/importer/instance/instance_importer.py,sha256=TaaPgEFVVMRT3mSXrzQkSaSIBPBwwANpEaWCgRsgImc,196
34
+ osi_dump/importer/instance/openstack_instance_importer.py,sha256=h1a-ToU1Hd4KARQTRqS8T6-2QK5eLfgKxz1DTHiBEEw,3475
35
+ osi_dump/importer/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
+ osi_dump/importer/project/openstack_project_importer.py,sha256=wdNJTTEhsvhnW6Wn0xLx8nAoJOhtiG9-6jGB0WnnYVU,1837
37
+ osi_dump/importer/project/project_importer.py,sha256=jwEvxteFbSwyWMV8hKAtf5Lo2bZysWkQ1L_NVUE8XOQ,191
38
+ osi_dump/importer/volume/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
+ osi_dump/importer/volume/openstack_volume_importer.py,sha256=q8vDPAr9LviJLTWfjAhQU8nKu5mt66pIras2uiexA9k,1937
40
+ osi_dump/importer/volume/volume_importer.py,sha256=tmDTE9L9vtl75GR79blSxa_MVsRU6LDCbR0yJk0xKwo,186
41
+ osi_dump/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
+ osi_dump/model/authentication_info.py,sha256=02kXxtILfjh8t45_-bPM8rtyRk2cQcJK6l2d1bPih7k,257
43
+ osi_dump/model/floating_ip.py,sha256=CRJufC5ZaxxcbGvdot7Af-sO8uyKbyQK9zHljfBnyFA,427
44
+ osi_dump/model/hypervisor.py,sha256=L3FKY57HiI55-AgxNPXVT55BgkJUDwPFYIfzLprJ2VE,244
45
+ osi_dump/model/instance.py,sha256=flNywojuBj7ZyFTnWvl2rpvzL3Ju-QtuUY69DSPfPs8,464
46
+ osi_dump/model/project.py,sha256=vh3qhR5JpQ6yxvGK9CXiJ9-HoyyYGAggKF56AEEg-tE,289
47
+ osi_dump/model/volume.py,sha256=unb2dy7dIDi3-D6WKJAhmnPsn_DI27GZJsZCrDBh89M,335
48
+ osi_dump/os_connection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
+ osi_dump/os_connection/get_connections.py,sha256=_CiKot2GgQDOAJ33goN9mcwaGYQCqzCOitntz9cf3-c,1793
50
+ osi_dump/util/__init__.py,sha256=GvhYTETVePJAsp0LfseMGtuRFWbbCc2xox-QSGQA3Us,286
51
+ osi_dump/util/create_file.py,sha256=hcEspFD0VZDtXCaG5QtMkV37GsbAHATdxYlClTszVK8,242
52
+ osi_dump/util/excel_autosize_column.py,sha256=zzQ6uXkQhHAqVn9fUAgNjoCH_HiNEC9Dcj4OBqHd6rw,1102
53
+ osi_dump/util/excel_sort_sheet.py,sha256=o4jXtP1ZFYtAGzkAP5S8Tym4h-SEoFBAI3j24y-24UM,1047
54
+ osi_dump/util/export_data_excel.py,sha256=VYSxDBZ7dgSbTj3n_8RRPqe183tILNh6wJW-UnFvJUU,882
55
+ osi_dump/util/extract_hostname.py,sha256=IpdklGHevmtRu67xeSRE_5n2mvWGI1sDsnJwExo_AR0,111
56
+ osi_dump/util/validate_dir_path.py,sha256=pL_OrY8JnNwk3vj6Zp6bsZtgHXhszSGRoqIt-1G5S90,507
57
+ osi_dump-0.1.dist-info/METADATA,sha256=GkknVw2jANEDf5MeFYq1OX7i7i2DdpueFVu4UFq9S44,660
58
+ osi_dump-0.1.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
59
+ osi_dump-0.1.dist-info/entry_points.txt,sha256=ozm5sIBtXzLv6_FiUe26v1BgA3_xUReGLPhKQKZ56wQ,46
60
+ osi_dump-0.1.dist-info/top_level.txt,sha256=OtAAwmJfcoPvlw_Cemo_H1aXIGV_7w0O2941KQt6faQ,9
61
+ osi_dump-0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (72.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ osi-dump = osi_dump.cli:app
@@ -0,0 +1 @@
1
+ osi_dump