osism 0.20250914.0__py3-none-any.whl → 0.20251003.0__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.
osism/data/__init__.py CHANGED
@@ -23,6 +23,7 @@ images:
23
23
  replace_frequency: quarterly
24
24
  uuid_validity: last-1
25
25
  provided_until: none
26
+ os_purpose: network
26
27
  tags:
27
28
  - amphora
28
29
  versions:
@@ -57,6 +58,7 @@ images:
57
58
  replace_frequency: never
58
59
  uuid_validity: none
59
60
  provided_until: none
61
+ os_purpose: k8snode
60
62
  tags: []
61
63
  versions:
62
64
  - version: "v{{ image_version }}"
@@ -90,6 +92,7 @@ images:
90
92
  replace_frequency: never
91
93
  uuid_validity: none
92
94
  provided_until: none
95
+ os_purpose: k8snode
93
96
  tags: []
94
97
  versions:
95
98
  - version: "{{ image_version }}"
osism/tasks/__init__.py CHANGED
@@ -1,8 +1,13 @@
1
1
  # SPDX-License-Identifier: Apache-2.0
2
2
 
3
+ import fcntl
4
+ import json
3
5
  import os
4
6
  import re
5
7
  import subprocess
8
+ import yaml
9
+ from datetime import datetime, timezone
10
+ from pathlib import Path
6
11
 
7
12
  from loguru import logger
8
13
 
@@ -30,6 +35,103 @@ class Config:
30
35
  }
31
36
 
32
37
 
38
+ def get_container_version(worker):
39
+ """Read container version from YAML version file.
40
+
41
+ Args:
42
+ worker: The runtime container name (osism-ansible, kolla-ansible, ceph-ansible, osism-kubernetes)
43
+
44
+ Returns:
45
+ str: The container version, "latest" if empty, or "unknown" if not found
46
+
47
+ Examples:
48
+ >>> get_container_version("osism-ansible")
49
+ "7.0.5a"
50
+ >>> get_container_version("kolla-ansible")
51
+ "18.1.0"
52
+ >>> get_container_version("osism-kubernetes")
53
+ "1.29.0"
54
+
55
+ Note:
56
+ If the version parameter in the YAML file is an empty string (""),
57
+ the function returns "latest" as the default value.
58
+ """
59
+ version_file = Path(f"/interface/versions/{worker}.yml")
60
+
61
+ try:
62
+ if not version_file.exists():
63
+ logger.debug(f"Version file not found: {version_file}")
64
+ return "unknown"
65
+
66
+ with open(version_file, "r") as f:
67
+ version_data = yaml.safe_load(f)
68
+
69
+ # Convert worker name to version parameter name
70
+ # osism-ansible -> osism_ansible_version
71
+ # kolla-ansible -> kolla_ansible_version
72
+ # ceph-ansible -> ceph_ansible_version
73
+ version_key = f"{worker.replace('-', '_')}_version"
74
+
75
+ version = version_data.get(version_key, "unknown")
76
+
77
+ # If version is empty string, use "latest" as default
78
+ if version == "":
79
+ version = "latest"
80
+ logger.debug(f"Version parameter empty for {worker}, using 'latest'")
81
+
82
+ logger.debug(f"Read version {version} for {worker} from {version_file}")
83
+ return version
84
+
85
+ except Exception as e:
86
+ logger.warning(f"Failed to read version from {version_file}: {e}")
87
+ return "unknown"
88
+
89
+
90
+ def log_play_execution(
91
+ request_id, worker, environment, role, hosts=None, result="started"
92
+ ):
93
+ """Log Ansible play execution to central tracking file.
94
+
95
+ Args:
96
+ request_id: The Celery task request ID for correlation
97
+ worker: The runtime container (osism-ansible, kolla-ansible, ceph-ansible, osism-kubernetes)
98
+ environment: The environment parameter
99
+ role: The playbook/role that was executed
100
+ hosts: List of hosts the play was executed against (default: empty list)
101
+ result: Execution result - "started", "success", or "failure"
102
+ """
103
+ log_file = Path("/share/ansible-execution-history.json")
104
+
105
+ # Get runtime version from YAML version file
106
+ runtime_version = get_container_version(worker)
107
+
108
+ execution_record = {
109
+ "timestamp": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
110
+ "request_id": request_id,
111
+ "worker": worker,
112
+ "worker_version": runtime_version,
113
+ "environment": environment,
114
+ "role": role,
115
+ "hosts": hosts if isinstance(hosts, list) else [],
116
+ "result": result,
117
+ }
118
+
119
+ try:
120
+ # Create directory if it doesn't exist
121
+ log_file.parent.mkdir(parents=True, exist_ok=True)
122
+
123
+ # Append with file locking for thread safety
124
+ with open(log_file, "a") as f:
125
+ fcntl.flock(f.fileno(), fcntl.LOCK_EX)
126
+ try:
127
+ f.write(json.dumps(execution_record) + "\n")
128
+ finally:
129
+ fcntl.flock(f.fileno(), fcntl.LOCK_UN)
130
+ except Exception as e:
131
+ # Log warning but don't fail the execution
132
+ logger.warning(f"Failed to log play execution to {log_file}: {e}")
133
+
134
+
33
135
  def run_ansible_in_environment(
34
136
  request_id,
35
137
  worker,
@@ -73,6 +175,16 @@ def run_ansible_in_environment(
73
175
  if ansible_vault_password:
74
176
  env["VAULT"] = "/ansible-vault.py"
75
177
 
178
+ # Log play execution start
179
+ log_play_execution(
180
+ request_id=request_id,
181
+ worker=worker,
182
+ environment=environment,
183
+ role=role,
184
+ hosts=None, # Host extraction would require inventory parsing
185
+ result="started",
186
+ )
187
+
76
188
  # NOTE: Consider arguments in the future
77
189
  if locking:
78
190
  lock = utils.create_redlock(
@@ -110,8 +222,8 @@ def run_ansible_in_environment(
110
222
  env=env,
111
223
  )
112
224
 
113
- # execute roles from kubernetes
114
- elif worker == "kubernetes":
225
+ # execute roles from osism-kubernetes
226
+ elif worker == "osism-kubernetes":
115
227
  if locking:
116
228
  lock.acquire()
117
229
 
@@ -163,6 +275,16 @@ def run_ansible_in_environment(
163
275
 
164
276
  rc = p.wait(timeout=60)
165
277
 
278
+ # Log play execution result
279
+ log_play_execution(
280
+ request_id=request_id,
281
+ worker=worker,
282
+ environment=environment,
283
+ role=role,
284
+ hosts=None, # Host extraction would require inventory parsing
285
+ result="success" if rc == 0 else "failure",
286
+ )
287
+
166
288
  if publish:
167
289
  utils.finish_task_output(request_id, rc=rc)
168
290
 
osism/tasks/kubernetes.py CHANGED
@@ -21,7 +21,7 @@ def run(self, environment, playbook, arguments, publish=True, auto_release_time=
21
21
 
22
22
  return run_ansible_in_environment(
23
23
  self.request.id,
24
- "kubernetes",
24
+ "osism-kubernetes",
25
25
  environment,
26
26
  playbook,
27
27
  arguments,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osism
3
- Version: 0.20250914.0
3
+ Version: 0.20251003.0
4
4
  Summary: OSISM manager interface
5
5
  Home-page: https://github.com/osism/python-osism
6
6
  Author: OSISM GmbH
@@ -25,14 +25,14 @@ License-File: AUTHORS
25
25
  Requires-Dist: ClusterShell==1.9.3
26
26
  Requires-Dist: GitPython==3.1.45
27
27
  Requires-Dist: Jinja2==3.1.6
28
- Requires-Dist: PyYAML==6.0.2
28
+ Requires-Dist: PyYAML==6.0.3
29
29
  Requires-Dist: ara==1.7.3
30
30
  Requires-Dist: celery[redis]==5.5.3
31
31
  Requires-Dist: cliff==4.11.0
32
32
  Requires-Dist: deepdiff==8.6.1
33
33
  Requires-Dist: docker==7.1.0
34
34
  Requires-Dist: dtrack-auditor==1.5.0
35
- Requires-Dist: fastapi==0.116.1
35
+ Requires-Dist: fastapi==0.118.0
36
36
  Requires-Dist: flower==2.0.1
37
37
  Requires-Dist: hiredis==3.2.1
38
38
  Requires-Dist: jc==1.25.5
@@ -42,18 +42,18 @@ Requires-Dist: kubernetes==33.1.0
42
42
  Requires-Dist: loguru==0.7.3
43
43
  Requires-Dist: nbcli==0.10.0.dev2
44
44
  Requires-Dist: openstacksdk==4.7.1
45
- Requires-Dist: paramiko==3.5.1
45
+ Requires-Dist: paramiko==4.0.0
46
46
  Requires-Dist: pottery==3.0.1
47
47
  Requires-Dist: prompt-toolkit==3.0.52
48
48
  Requires-Dist: pynetbox==7.5.0
49
49
  Requires-Dist: pytest-testinfra==10.2.2
50
50
  Requires-Dist: python-dateutil==2.9.0.post0
51
51
  Requires-Dist: setuptools==80.9.0
52
- Requires-Dist: sqlmodel==0.0.24
52
+ Requires-Dist: sqlmodel==0.0.25
53
53
  Requires-Dist: sushy==5.7.1
54
54
  Requires-Dist: tabulate==0.9.0
55
55
  Requires-Dist: transitions==0.9.3
56
- Requires-Dist: uvicorn[standard]==0.35.0
56
+ Requires-Dist: uvicorn[standard]==0.37.0
57
57
  Requires-Dist: validators==0.35.0
58
58
  Requires-Dist: watchdog==6.0.0
59
59
  Requires-Dist: websockets==15.0.1
@@ -31,19 +31,19 @@ osism/commands/vault.py,sha256=llaqNN8UH8t8cCu2KmdaURvprA4zeG6izCen_W7ulPs,2029
31
31
  osism/commands/volume.py,sha256=l6oAk__dFM8KKdLTWOvuSiI7tLh9wAPZp8hwmYF-NX0,6595
32
32
  osism/commands/wait.py,sha256=2Ncx63M0AFq4fq40VZVClf1LS-WHetD8iC_mG2dY_Cw,5275
33
33
  osism/commands/worker.py,sha256=S8EBBVHSP6qQ4nek5fPclxdeHtjY4AFQF43YK0Kyly4,1777
34
- osism/data/__init__.py,sha256=7nhKIh5lATHCVO34En60dmM9WXclucRO59ylMp_1gks,2232
34
+ osism/data/__init__.py,sha256=biSDzdL9QvXjbRpXROVKaNToHzDe74kqCITYRhic444,2310
35
35
  osism/data/enums.py,sha256=gItIjOK6xWuOZSkMxpMdYLRyt4ezyhzkqA7BGiah2o0,10030
36
36
  osism/data/playbooks.py,sha256=M3T3ajV-8Lt-orsRO3jAoukhaoYFr4EZ2dzYXQjt1kg,728
37
37
  osism/services/__init__.py,sha256=bG7Ffen4LvQtgnYPFEpFccsWs81t4zqqeqn9ZeirH6E,38
38
38
  osism/services/event_bridge.py,sha256=roV90o9UgTnwoVbXnPR3muBk04IriVYCO_fewZ46Mq8,12016
39
39
  osism/services/listener.py,sha256=O8Xq5fEEVoNFIgFPE7GqfVqx6C4QkdWhUPUGzODFnws,14211
40
40
  osism/services/websocket_manager.py,sha256=F147kWOg8PAvbVG4aVYQVtK4mFMfPVtHxxYJXaqiAjg,11051
41
- osism/tasks/__init__.py,sha256=iAUs-ttUMw1nZElL631sT1ke29RvTjQjlhWPl_kGrEw,9003
41
+ osism/tasks/__init__.py,sha256=l-tzKk4QxRCD8PxNhHS6SdNgDa2Ilr10HZc3FN5HZH4,13089
42
42
  osism/tasks/ansible.py,sha256=wAeFqyY8EavySpOIBSgWwK3HcGXWPZCIVOaSss5irCM,1387
43
43
  osism/tasks/ceph.py,sha256=Zo-92rzbJ9NDH9dbKi_JPWwekO3cYTdbmwAGSwr5l0w,726
44
44
  osism/tasks/conductor.py,sha256=WBLsoPtr0iGUzRGERs0Xt7CMYrnHQVEwNV9qXBssI3s,274
45
45
  osism/tasks/kolla.py,sha256=1p0SZBTYpUvIg09czwUmnMh6LIBhleB6O1WSX1mkmJo,729
46
- osism/tasks/kubernetes.py,sha256=hrzzDPM0Vx0_KWNxQwsQG54y1v0s2goFYJIMriX0Gh4,736
46
+ osism/tasks/kubernetes.py,sha256=LyFKjtByQryNl67ZgKjnr-csEODDqYf3LvjURf_qhK0,742
47
47
  osism/tasks/netbox.py,sha256=FjEGQUZDzAVqA9cc3eQqaPv5-hPj3iI9lEc9SkuDO7M,6278
48
48
  osism/tasks/openstack.py,sha256=c5PyVlSzn69Xw-nFgUf1cX3a3E_STSCNrIectiDzqPI,14871
49
49
  osism/tasks/reconciler.py,sha256=vlPdOr7nbqggfVMSNez-JHZmKw8L7YmqKQnLF7TOXuQ,2045
@@ -65,11 +65,11 @@ osism/tasks/conductor/sonic/interface.py,sha256=M876LHdFqGxUfTizzDusdzvCkDI0vCgq
65
65
  osism/tasks/conductor/sonic/sync.py,sha256=fpgsQVwq6Hb7eeDHhLkAqx5BkaK3Ce_m_WvmWEsJyOo,9182
66
66
  osism/utils/__init__.py,sha256=IEr0sR1HKg-QI_u84fs4gMldC6-EPSxvMBh2zMGu5dU,9939
67
67
  osism/utils/ssh.py,sha256=nxeEgwjJWvQCybKDp-NelMeWyODCYpaXFCBchAv4-bg,8691
68
- osism-0.20250914.0.dist-info/licenses/AUTHORS,sha256=EKFIR9F27AvoEXp1cA6FkGbjEOFt4Rcbipr5RJc7jSs,64
69
- osism-0.20250914.0.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
70
- osism-0.20250914.0.dist-info/METADATA,sha256=kQZkqrP9vB1jK4uyDlxDJiPI1udkU8QkxKi5kbziamA,2971
71
- osism-0.20250914.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
72
- osism-0.20250914.0.dist-info/entry_points.txt,sha256=W45YQ7MJ7BCAPZXl3F6d2FSi6An0moZQbzLn_BwGnRE,4618
73
- osism-0.20250914.0.dist-info/pbr.json,sha256=jVkYbaHIR5V7eupVx4WFWlCoxsLsuX3ePqLHSwmGLtI,47
74
- osism-0.20250914.0.dist-info/top_level.txt,sha256=8L8dsI9hcaGHsdnR4k_LN9EM78EhwrXRFHyAryPXZtY,6
75
- osism-0.20250914.0.dist-info/RECORD,,
68
+ osism-0.20251003.0.dist-info/licenses/AUTHORS,sha256=oWotd63qsnNR945QLJP9mEXaXNtCMaesfo8ZNuLjwpU,39
69
+ osism-0.20251003.0.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
70
+ osism-0.20251003.0.dist-info/METADATA,sha256=Km5pxS6evxg2a_I6MBDbX5PA8BZbRweyt4fWtSgP85M,2971
71
+ osism-0.20251003.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
72
+ osism-0.20251003.0.dist-info/entry_points.txt,sha256=W45YQ7MJ7BCAPZXl3F6d2FSi6An0moZQbzLn_BwGnRE,4618
73
+ osism-0.20251003.0.dist-info/pbr.json,sha256=OKB9yQU8MRrWVMUvBfcaJlhCTJLe5o6nxgVl2sh5qxQ,47
74
+ osism-0.20251003.0.dist-info/top_level.txt,sha256=8L8dsI9hcaGHsdnR4k_LN9EM78EhwrXRFHyAryPXZtY,6
75
+ osism-0.20251003.0.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ Christian Berendt <berendt@osism.tech>
@@ -0,0 +1 @@
1
+ {"git_version": "fc7b5e0", "is_release": false}
@@ -1 +0,0 @@
1
- renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@@ -1 +0,0 @@
1
- {"git_version": "10a12ce", "is_release": false}