osism 0.20250824.1__py3-none-any.whl → 0.20250827.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/commands/apply.py +4 -0
- osism/commands/configuration.py +4 -0
- osism/commands/lock.py +91 -0
- osism/commands/manage.py +132 -6
- osism/commands/netbox.py +12 -0
- osism/commands/noset.py +7 -0
- osism/commands/reconciler.py +3 -0
- osism/commands/redfish.py +4 -0
- osism/commands/service.py +4 -0
- osism/commands/set.py +7 -0
- osism/commands/sonic.py +3 -0
- osism/commands/sync.py +7 -0
- osism/commands/validate.py +3 -0
- osism/commands/worker.py +4 -0
- osism/data/__init__.py +33 -0
- osism/tasks/ansible.py +3 -0
- osism/tasks/ceph.py +4 -0
- osism/tasks/conductor/__init__.py +10 -0
- osism/tasks/kolla.py +4 -0
- osism/tasks/kubernetes.py +4 -0
- osism/tasks/netbox.py +12 -0
- osism/tasks/openstack.py +265 -38
- osism/tasks/reconciler.py +3 -0
- osism/utils/__init__.py +81 -0
- {osism-0.20250824.1.dist-info → osism-0.20250827.0.dist-info}/METADATA +5 -5
- {osism-0.20250824.1.dist-info → osism-0.20250827.0.dist-info}/RECORD +32 -31
- {osism-0.20250824.1.dist-info → osism-0.20250827.0.dist-info}/entry_points.txt +4 -0
- osism-0.20250827.0.dist-info/licenses/AUTHORS +1 -0
- osism-0.20250827.0.dist-info/pbr.json +1 -0
- osism-0.20250824.1.dist-info/licenses/AUTHORS +0 -1
- osism-0.20250824.1.dist-info/pbr.json +0 -1
- {osism-0.20250824.1.dist-info → osism-0.20250827.0.dist-info}/WHEEL +0 -0
- {osism-0.20250824.1.dist-info → osism-0.20250827.0.dist-info}/licenses/LICENSE +0 -0
- {osism-0.20250824.1.dist-info → osism-0.20250827.0.dist-info}/top_level.txt +0 -0
osism/commands/apply.py
CHANGED
@@ -9,6 +9,7 @@ from cliff.command import Command
|
|
9
9
|
from loguru import logger
|
10
10
|
from tabulate import tabulate
|
11
11
|
|
12
|
+
from osism import utils
|
12
13
|
from osism.data import enums
|
13
14
|
from osism.data.playbooks import MAP_ROLE2ENVIRONMENT, MAP_ROLE2RUNTIME
|
14
15
|
from osism.tasks import ansible, ceph, kolla, kubernetes, handle_task
|
@@ -451,6 +452,9 @@ class Run(Command):
|
|
451
452
|
return rc
|
452
453
|
|
453
454
|
def take_action(self, parsed_args):
|
455
|
+
# Check if tasks are locked before proceeding
|
456
|
+
utils.check_task_lock_and_exit()
|
457
|
+
|
454
458
|
action = parsed_args.action
|
455
459
|
arguments = parsed_args.arguments
|
456
460
|
environment = parsed_args.environment
|
osism/commands/configuration.py
CHANGED
@@ -5,6 +5,7 @@ import argparse
|
|
5
5
|
from cliff.command import Command
|
6
6
|
from loguru import logger
|
7
7
|
|
8
|
+
from osism import utils
|
8
9
|
from osism.tasks import ansible, handle_task
|
9
10
|
|
10
11
|
|
@@ -17,6 +18,9 @@ class Sync(Command):
|
|
17
18
|
return parser
|
18
19
|
|
19
20
|
def take_action(self, parsed_args):
|
21
|
+
# Check if tasks are locked before proceeding
|
22
|
+
utils.check_task_lock_and_exit()
|
23
|
+
|
20
24
|
arguments = parsed_args.arguments
|
21
25
|
|
22
26
|
t = ansible.run.delay(
|
osism/commands/lock.py
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
from cliff.command import Command
|
4
|
+
from loguru import logger
|
5
|
+
|
6
|
+
from osism import utils
|
7
|
+
|
8
|
+
|
9
|
+
class Lock(Command):
|
10
|
+
"""Lock task execution to prevent new tasks from starting"""
|
11
|
+
|
12
|
+
def get_parser(self, prog_name):
|
13
|
+
parser = super(Lock, self).get_parser(prog_name)
|
14
|
+
parser.add_argument(
|
15
|
+
"--user",
|
16
|
+
help="User name to associate with the lock (defaults to dragon)",
|
17
|
+
)
|
18
|
+
parser.add_argument("--reason", help="Reason for locking tasks")
|
19
|
+
return parser
|
20
|
+
|
21
|
+
def take_action(self, parsed_args):
|
22
|
+
user = parsed_args.user or "dragon"
|
23
|
+
reason = parsed_args.reason
|
24
|
+
|
25
|
+
# Check if already locked
|
26
|
+
lock_info = utils.is_task_locked()
|
27
|
+
if lock_info and lock_info.get("locked"):
|
28
|
+
existing_user = lock_info.get("user", "unknown")
|
29
|
+
existing_timestamp = lock_info.get("timestamp", "unknown")
|
30
|
+
existing_reason = lock_info.get("reason")
|
31
|
+
logger.warning(
|
32
|
+
f"Tasks are already locked by {existing_user} at {existing_timestamp}"
|
33
|
+
)
|
34
|
+
if existing_reason:
|
35
|
+
logger.warning(f"Existing reason: {existing_reason}")
|
36
|
+
return
|
37
|
+
|
38
|
+
# Set the lock
|
39
|
+
if utils.set_task_lock(user, reason):
|
40
|
+
logger.info(f"Tasks locked by {user}")
|
41
|
+
if reason:
|
42
|
+
logger.info(f"Reason: {reason}")
|
43
|
+
logger.info("New tasks will be prevented from starting")
|
44
|
+
logger.info("Running tasks will continue normally")
|
45
|
+
logger.info("Use 'osism unlock' to remove the lock")
|
46
|
+
else:
|
47
|
+
logger.error("Failed to set task lock")
|
48
|
+
return 1
|
49
|
+
|
50
|
+
|
51
|
+
class Unlock(Command):
|
52
|
+
"""Unlock task execution to allow new tasks to start"""
|
53
|
+
|
54
|
+
def take_action(self, parsed_args):
|
55
|
+
# Check if currently locked
|
56
|
+
lock_info = utils.is_task_locked()
|
57
|
+
if not lock_info or not lock_info.get("locked"):
|
58
|
+
logger.info("Tasks are not currently locked")
|
59
|
+
return
|
60
|
+
|
61
|
+
existing_user = lock_info.get("user", "unknown")
|
62
|
+
existing_timestamp = lock_info.get("timestamp", "unknown")
|
63
|
+
existing_reason = lock_info.get("reason")
|
64
|
+
|
65
|
+
# Remove the lock
|
66
|
+
if utils.remove_task_lock():
|
67
|
+
logger.info(
|
68
|
+
f"Task lock removed (was set by {existing_user} at {existing_timestamp})"
|
69
|
+
)
|
70
|
+
if existing_reason:
|
71
|
+
logger.info(f"Previous reason: {existing_reason}")
|
72
|
+
logger.info("New tasks can now be started")
|
73
|
+
else:
|
74
|
+
logger.error("Failed to remove task lock")
|
75
|
+
return 1
|
76
|
+
|
77
|
+
|
78
|
+
class LockStatus(Command):
|
79
|
+
"""Show current task lock status"""
|
80
|
+
|
81
|
+
def take_action(self, parsed_args):
|
82
|
+
lock_info = utils.is_task_locked()
|
83
|
+
if lock_info and lock_info.get("locked"):
|
84
|
+
user = lock_info.get("user", "unknown")
|
85
|
+
timestamp = lock_info.get("timestamp", "unknown")
|
86
|
+
reason = lock_info.get("reason")
|
87
|
+
logger.info(f"Tasks are LOCKED by {user} at {timestamp}")
|
88
|
+
if reason:
|
89
|
+
logger.info(f"Reason: {reason}")
|
90
|
+
else:
|
91
|
+
logger.info("Tasks are UNLOCKED")
|
osism/commands/manage.py
CHANGED
@@ -9,10 +9,16 @@ from jinja2 import Template
|
|
9
9
|
from loguru import logger
|
10
10
|
import requests
|
11
11
|
|
12
|
-
from osism
|
12
|
+
from osism import utils
|
13
|
+
from osism.data import (
|
14
|
+
TEMPLATE_IMAGE_CLUSTERAPI,
|
15
|
+
TEMPLATE_IMAGE_OCTAVIA,
|
16
|
+
TEMPLATE_IMAGE_GARDENLINUX,
|
17
|
+
)
|
13
18
|
from osism.tasks import openstack, ansible, handle_task
|
14
19
|
|
15
20
|
SUPPORTED_CLUSTERAPI_K8S_IMAGES = ["1.31", "1.32", "1.33"]
|
21
|
+
SUPPORTED_GARDENLINUX_VERSIONS = {"1877.2": "2025-08-07"}
|
16
22
|
|
17
23
|
|
18
24
|
class ImageClusterapi(Command):
|
@@ -57,6 +63,9 @@ class ImageClusterapi(Command):
|
|
57
63
|
return parser
|
58
64
|
|
59
65
|
def take_action(self, parsed_args):
|
66
|
+
# Check if tasks are locked before proceeding
|
67
|
+
utils.check_task_lock_and_exit()
|
68
|
+
|
60
69
|
base_url = parsed_args.base_url
|
61
70
|
cloud = parsed_args.cloud
|
62
71
|
filter = parsed_args.filter
|
@@ -112,7 +121,112 @@ class ImageClusterapi(Command):
|
|
112
121
|
if parsed_args.dry_run:
|
113
122
|
args.append("--dry-run")
|
114
123
|
|
115
|
-
task_signature = openstack.image_manager.si(*args, configs=result)
|
124
|
+
task_signature = openstack.image_manager.si(*args, configs=result, cloud=cloud)
|
125
|
+
task = task_signature.apply_async()
|
126
|
+
if wait:
|
127
|
+
logger.info(
|
128
|
+
f"It takes a moment until task {task.task_id} (image-manager) has been started and output is visible here."
|
129
|
+
)
|
130
|
+
|
131
|
+
return handle_task(task, wait, format="script", timeout=3600)
|
132
|
+
|
133
|
+
|
134
|
+
class ImageGardenlinux(Command):
|
135
|
+
def get_parser(self, prog_name):
|
136
|
+
parser = super(ImageGardenlinux, self).get_parser(prog_name)
|
137
|
+
|
138
|
+
parser.add_argument(
|
139
|
+
"--no-wait",
|
140
|
+
default=False,
|
141
|
+
help="Do not wait until image management has been completed",
|
142
|
+
action="store_true",
|
143
|
+
)
|
144
|
+
parser.add_argument(
|
145
|
+
"--base-url",
|
146
|
+
type=str,
|
147
|
+
help="Base URL",
|
148
|
+
default="https://swift.services.a.regiocloud.tech/swift/v1/AUTH_b182637428444b9aa302bb8d5a5a418c/openstack-images/gardenlinux/",
|
149
|
+
)
|
150
|
+
parser.add_argument(
|
151
|
+
"--cloud",
|
152
|
+
type=str,
|
153
|
+
help="Cloud name in clouds.yaml (will be overruled by OS_AUTH_URL envvar)",
|
154
|
+
default="admin",
|
155
|
+
)
|
156
|
+
parser.add_argument(
|
157
|
+
"--dry-run",
|
158
|
+
action="store_true",
|
159
|
+
help="Do not perform any changes (--dry-run passed to openstack-image-manager)",
|
160
|
+
)
|
161
|
+
parser.add_argument(
|
162
|
+
"--tag",
|
163
|
+
type=str,
|
164
|
+
help="Name of the tag used to identify managed images (use openstack-image-manager's default if unset)",
|
165
|
+
default=None,
|
166
|
+
)
|
167
|
+
parser.add_argument(
|
168
|
+
"--filter",
|
169
|
+
type=str,
|
170
|
+
help="Filter the version to be managed (e.g. 1877.2)",
|
171
|
+
default=None,
|
172
|
+
)
|
173
|
+
return parser
|
174
|
+
|
175
|
+
def take_action(self, parsed_args):
|
176
|
+
# Check if tasks are locked before proceeding
|
177
|
+
utils.check_task_lock_and_exit()
|
178
|
+
|
179
|
+
base_url = parsed_args.base_url
|
180
|
+
cloud = parsed_args.cloud
|
181
|
+
filter = parsed_args.filter
|
182
|
+
tag = parsed_args.tag
|
183
|
+
wait = not parsed_args.no_wait
|
184
|
+
|
185
|
+
if filter:
|
186
|
+
# For filter, we need to handle it as a dict with placeholder build date
|
187
|
+
supported_gardenlinux_versions = {filter: "unknown"}
|
188
|
+
else:
|
189
|
+
supported_gardenlinux_versions = SUPPORTED_GARDENLINUX_VERSIONS
|
190
|
+
|
191
|
+
result = []
|
192
|
+
for version, build_date in supported_gardenlinux_versions.items():
|
193
|
+
# Garden Linux uses direct URL construction instead of fetching last files
|
194
|
+
url = urljoin(
|
195
|
+
base_url, f"{version}/openstack-gardener_prod-amd64-{version}.qcow2"
|
196
|
+
)
|
197
|
+
logger.info(f"url: {url}")
|
198
|
+
|
199
|
+
# Get checksum file
|
200
|
+
checksum_url = f"{url}.sha256"
|
201
|
+
logger.info(f"checksum_url: {checksum_url}")
|
202
|
+
response_checksum = requests.get(checksum_url)
|
203
|
+
checksum = response_checksum.text.strip().split()[0]
|
204
|
+
logger.info(f"checksum: {checksum}")
|
205
|
+
|
206
|
+
template = Template(TEMPLATE_IMAGE_GARDENLINUX)
|
207
|
+
result.extend(
|
208
|
+
[
|
209
|
+
template.render(
|
210
|
+
image_url=url,
|
211
|
+
image_checksum=f"sha256:{checksum}",
|
212
|
+
image_version=version,
|
213
|
+
image_builddate=build_date,
|
214
|
+
)
|
215
|
+
]
|
216
|
+
)
|
217
|
+
|
218
|
+
args = [
|
219
|
+
"--cloud",
|
220
|
+
cloud,
|
221
|
+
"--filter",
|
222
|
+
"garden-linux-image",
|
223
|
+
]
|
224
|
+
if tag is not None:
|
225
|
+
args.extend(["--tag", tag])
|
226
|
+
if parsed_args.dry_run:
|
227
|
+
args.append("--dry-run")
|
228
|
+
|
229
|
+
task_signature = openstack.image_manager.si(*args, configs=result, cloud=cloud)
|
116
230
|
task = task_signature.apply_async()
|
117
231
|
if wait:
|
118
232
|
logger.info(
|
@@ -147,6 +261,9 @@ class ImageOctavia(Command):
|
|
147
261
|
return parser
|
148
262
|
|
149
263
|
def take_action(self, parsed_args):
|
264
|
+
# Check if tasks are locked before proceeding
|
265
|
+
utils.check_task_lock_and_exit()
|
266
|
+
|
150
267
|
wait = not parsed_args.no_wait
|
151
268
|
cloud = parsed_args.cloud
|
152
269
|
base_url = parsed_args.base_url
|
@@ -189,7 +306,7 @@ class ImageOctavia(Command):
|
|
189
306
|
]
|
190
307
|
|
191
308
|
task_signature = openstack.image_manager.si(
|
192
|
-
*arguments, configs=result,
|
309
|
+
*arguments, configs=result, cloud=cloud
|
193
310
|
)
|
194
311
|
task = task_signature.apply_async()
|
195
312
|
if wait:
|
@@ -258,6 +375,9 @@ class Images(Command):
|
|
258
375
|
return parser
|
259
376
|
|
260
377
|
def take_action(self, parsed_args):
|
378
|
+
# Check if tasks are locked before proceeding
|
379
|
+
utils.check_task_lock_and_exit()
|
380
|
+
|
261
381
|
wait = not parsed_args.no_wait
|
262
382
|
|
263
383
|
arguments = []
|
@@ -283,7 +403,7 @@ class Images(Command):
|
|
283
403
|
else:
|
284
404
|
arguments.append("/etc/images")
|
285
405
|
|
286
|
-
task_signature = openstack.image_manager.si(*arguments)
|
406
|
+
task_signature = openstack.image_manager.si(*arguments, cloud=parsed_args.cloud)
|
287
407
|
task = task_signature.apply_async()
|
288
408
|
if wait:
|
289
409
|
logger.info(
|
@@ -315,7 +435,7 @@ class Flavors(Command):
|
|
315
435
|
"--name",
|
316
436
|
type=str,
|
317
437
|
help="Name of flavor definitions",
|
318
|
-
default="
|
438
|
+
default="local",
|
319
439
|
choices=["scs", "osism", "local", "url"],
|
320
440
|
)
|
321
441
|
parser.add_argument(
|
@@ -334,6 +454,9 @@ class Flavors(Command):
|
|
334
454
|
return parser
|
335
455
|
|
336
456
|
def take_action(self, parsed_args):
|
457
|
+
# Check if tasks are locked before proceeding
|
458
|
+
utils.check_task_lock_and_exit()
|
459
|
+
|
337
460
|
wait = not parsed_args.no_wait
|
338
461
|
cloud = parsed_args.cloud
|
339
462
|
name = parsed_args.name
|
@@ -352,7 +475,7 @@ class Flavors(Command):
|
|
352
475
|
arguments.append("--url")
|
353
476
|
arguments.append(url)
|
354
477
|
|
355
|
-
task_signature = openstack.flavor_manager.si(*arguments)
|
478
|
+
task_signature = openstack.flavor_manager.si(*arguments, cloud=cloud)
|
356
479
|
task = task_signature.apply_async()
|
357
480
|
if wait:
|
358
481
|
logger.info(
|
@@ -374,6 +497,9 @@ class Dnsmasq(Command):
|
|
374
497
|
return parser
|
375
498
|
|
376
499
|
def take_action(self, parsed_args):
|
500
|
+
# Check if tasks are locked before proceeding
|
501
|
+
utils.check_task_lock_and_exit()
|
502
|
+
|
377
503
|
wait = not parsed_args.no_wait
|
378
504
|
|
379
505
|
task_signature = ansible.run.si("infrastructure", "dnsmasq", [])
|
osism/commands/netbox.py
CHANGED
@@ -38,6 +38,9 @@ class Ironic(Command):
|
|
38
38
|
return parser
|
39
39
|
|
40
40
|
def take_action(self, parsed_args):
|
41
|
+
# Check if tasks are locked before proceeding
|
42
|
+
utils.check_task_lock_and_exit()
|
43
|
+
|
41
44
|
wait = not parsed_args.no_wait
|
42
45
|
task_timeout = parsed_args.task_timeout
|
43
46
|
node_name = parsed_args.node
|
@@ -87,6 +90,9 @@ class Sync(Command):
|
|
87
90
|
return parser
|
88
91
|
|
89
92
|
def take_action(self, parsed_args):
|
93
|
+
# Check if tasks are locked before proceeding
|
94
|
+
utils.check_task_lock_and_exit()
|
95
|
+
|
90
96
|
wait = not parsed_args.no_wait
|
91
97
|
|
92
98
|
task = conductor.sync_netbox.delay()
|
@@ -145,6 +151,9 @@ class Manage(Command):
|
|
145
151
|
return parser
|
146
152
|
|
147
153
|
def take_action(self, parsed_args):
|
154
|
+
# Check if tasks are locked before proceeding
|
155
|
+
utils.check_task_lock_and_exit()
|
156
|
+
|
148
157
|
wait = not parsed_args.no_wait
|
149
158
|
arguments = ["run"]
|
150
159
|
|
@@ -192,6 +201,9 @@ class Versions(Command):
|
|
192
201
|
return parser
|
193
202
|
|
194
203
|
def take_action(self, parsed_args):
|
204
|
+
# Check if tasks are locked before proceeding
|
205
|
+
utils.check_task_lock_and_exit()
|
206
|
+
|
195
207
|
task = netbox.ping.delay()
|
196
208
|
task.wait(timeout=None, interval=0.5)
|
197
209
|
result = task.get()
|
osism/commands/noset.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
from cliff.command import Command
|
4
4
|
from loguru import logger
|
5
5
|
|
6
|
+
from osism import utils
|
6
7
|
from osism.tasks import ansible
|
7
8
|
|
8
9
|
|
@@ -18,6 +19,9 @@ class NoMaintenance(Command):
|
|
18
19
|
return parser
|
19
20
|
|
20
21
|
def take_action(self, parsed_args):
|
22
|
+
# Check if tasks are locked before proceeding
|
23
|
+
utils.check_task_lock_and_exit()
|
24
|
+
|
21
25
|
host = parsed_args.host[0]
|
22
26
|
|
23
27
|
logger.info(f"Set no maintenance state on host {host}")
|
@@ -46,6 +50,9 @@ class NoBootstrap(Command):
|
|
46
50
|
return parser
|
47
51
|
|
48
52
|
def take_action(self, parsed_args):
|
53
|
+
# Check if tasks are locked before proceeding
|
54
|
+
utils.check_task_lock_and_exit()
|
55
|
+
|
49
56
|
host = parsed_args.host[0]
|
50
57
|
|
51
58
|
logger.info(f"Set not bootstrapped state on host {host}")
|
osism/commands/reconciler.py
CHANGED
@@ -47,6 +47,9 @@ class Sync(Command):
|
|
47
47
|
return parser
|
48
48
|
|
49
49
|
def take_action(self, parsed_args):
|
50
|
+
# Check if tasks are locked before proceeding
|
51
|
+
utils.check_task_lock_and_exit()
|
52
|
+
|
50
53
|
wait = not parsed_args.no_wait
|
51
54
|
task_timeout = parsed_args.task_timeout
|
52
55
|
flush_cache = parsed_args.flush_cache
|
osism/commands/redfish.py
CHANGED
@@ -5,6 +5,7 @@ from cliff.command import Command
|
|
5
5
|
from loguru import logger
|
6
6
|
from tabulate import tabulate
|
7
7
|
|
8
|
+
from osism import utils
|
8
9
|
from osism.tasks.conductor import get_redfish_resources
|
9
10
|
|
10
11
|
|
@@ -145,6 +146,9 @@ class List(Command):
|
|
145
146
|
return parser
|
146
147
|
|
147
148
|
def take_action(self, parsed_args):
|
149
|
+
# Check if tasks are locked before proceeding
|
150
|
+
utils.check_task_lock_and_exit()
|
151
|
+
|
148
152
|
hostname = parsed_args.hostname
|
149
153
|
resourcetype = parsed_args.resourcetype
|
150
154
|
output_format = parsed_args.format
|
osism/commands/service.py
CHANGED
@@ -7,6 +7,7 @@ from cliff.command import Command
|
|
7
7
|
from watchdog.observers.polling import PollingObserver
|
8
8
|
from watchdog.events import FileSystemEventHandler
|
9
9
|
|
10
|
+
from osism import utils
|
10
11
|
from osism.tasks import reconciler
|
11
12
|
|
12
13
|
|
@@ -17,6 +18,9 @@ class Run(Command):
|
|
17
18
|
return parser
|
18
19
|
|
19
20
|
def take_action(self, parsed_args):
|
21
|
+
# Check if tasks are locked before proceeding
|
22
|
+
utils.check_task_lock_and_exit()
|
23
|
+
|
20
24
|
service = parsed_args.type[0]
|
21
25
|
|
22
26
|
if service == "api":
|
osism/commands/set.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
from cliff.command import Command
|
4
4
|
from loguru import logger
|
5
5
|
|
6
|
+
from osism import utils
|
6
7
|
from osism.tasks import ansible
|
7
8
|
|
8
9
|
|
@@ -18,6 +19,9 @@ class Maintenance(Command):
|
|
18
19
|
return parser
|
19
20
|
|
20
21
|
def take_action(self, parsed_args):
|
22
|
+
# Check if tasks are locked before proceeding
|
23
|
+
utils.check_task_lock_and_exit()
|
24
|
+
|
21
25
|
host = parsed_args.host[0]
|
22
26
|
|
23
27
|
logger.info(f"Set maintenance state on host {host}")
|
@@ -46,6 +50,9 @@ class Bootstrap(Command):
|
|
46
50
|
return parser
|
47
51
|
|
48
52
|
def take_action(self, parsed_args):
|
53
|
+
# Check if tasks are locked before proceeding
|
54
|
+
utils.check_task_lock_and_exit()
|
55
|
+
|
49
56
|
host = parsed_args.host[0]
|
50
57
|
|
51
58
|
logger.info(f"Set bootstraped state on host {host}")
|
osism/commands/sonic.py
CHANGED
@@ -738,6 +738,9 @@ class Reset(SonicCommandBase):
|
|
738
738
|
return parser
|
739
739
|
|
740
740
|
def take_action(self, parsed_args):
|
741
|
+
# Check if tasks are locked before proceeding
|
742
|
+
utils.check_task_lock_and_exit()
|
743
|
+
|
741
744
|
hostname = parsed_args.hostname
|
742
745
|
force = parsed_args.force
|
743
746
|
|
osism/commands/sync.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
from cliff.command import Command
|
4
4
|
from loguru import logger
|
5
5
|
|
6
|
+
from osism import utils
|
6
7
|
from osism.tasks import ansible, conductor, handle_task
|
7
8
|
|
8
9
|
|
@@ -12,6 +13,9 @@ class Facts(Command):
|
|
12
13
|
return parser
|
13
14
|
|
14
15
|
def take_action(self, parsed_args):
|
16
|
+
# Check if tasks are locked before proceeding
|
17
|
+
utils.check_task_lock_and_exit()
|
18
|
+
|
15
19
|
arguments = []
|
16
20
|
t = ansible.run.delay(
|
17
21
|
"generic", "gather-facts", arguments, auto_release_time=3600
|
@@ -49,6 +53,9 @@ class Sonic(Command):
|
|
49
53
|
return parser
|
50
54
|
|
51
55
|
def take_action(self, parsed_args):
|
56
|
+
# Check if tasks are locked before proceeding
|
57
|
+
utils.check_task_lock_and_exit()
|
58
|
+
|
52
59
|
wait = not parsed_args.no_wait
|
53
60
|
device_name = parsed_args.device
|
54
61
|
show_diff = parsed_args.diff
|
osism/commands/validate.py
CHANGED
@@ -70,6 +70,9 @@ class Run(Command):
|
|
70
70
|
return 0
|
71
71
|
|
72
72
|
def take_action(self, parsed_args):
|
73
|
+
# Check if tasks are locked before proceeding
|
74
|
+
utils.check_task_lock_and_exit()
|
75
|
+
|
73
76
|
arguments = parsed_args.arguments
|
74
77
|
environment = parsed_args.environment
|
75
78
|
validator = parsed_args.validator[0]
|
osism/commands/worker.py
CHANGED
@@ -4,6 +4,7 @@ import multiprocessing
|
|
4
4
|
import subprocess
|
5
5
|
|
6
6
|
from cliff.command import Command
|
7
|
+
from osism import utils
|
7
8
|
|
8
9
|
|
9
10
|
class Run(Command):
|
@@ -25,6 +26,9 @@ class Run(Command):
|
|
25
26
|
return parser
|
26
27
|
|
27
28
|
def take_action(self, parsed_args):
|
29
|
+
# Check if tasks are locked before starting workers
|
30
|
+
utils.check_task_lock_and_exit()
|
31
|
+
|
28
32
|
queue = parsed_args.type[0]
|
29
33
|
number_of_workers = parsed_args.number_of_workers
|
30
34
|
|
osism/data/__init__.py
CHANGED
@@ -65,3 +65,36 @@ images:
|
|
65
65
|
build_date: {{ image_builddate }}
|
66
66
|
|
67
67
|
"""
|
68
|
+
|
69
|
+
TEMPLATE_IMAGE_GARDENLINUX = """---
|
70
|
+
images:
|
71
|
+
- name: garden-linux-image
|
72
|
+
enable: true
|
73
|
+
keep: true
|
74
|
+
separator: "-"
|
75
|
+
format: qcow2
|
76
|
+
login: garden
|
77
|
+
min_disk: 20
|
78
|
+
min_ram: 512
|
79
|
+
status: active
|
80
|
+
visibility: public
|
81
|
+
multi: false
|
82
|
+
meta:
|
83
|
+
architecture: x86_64
|
84
|
+
hw_disk_bus: scsi
|
85
|
+
hw_rng_model: virtio
|
86
|
+
hw_scsi_model: virtio-scsi
|
87
|
+
hw_watchdog_action: reset
|
88
|
+
hypervisor_type: qemu
|
89
|
+
os_distro: debian
|
90
|
+
replace_frequency: never
|
91
|
+
uuid_validity: none
|
92
|
+
provided_until: none
|
93
|
+
tags: []
|
94
|
+
versions:
|
95
|
+
- version: "{{ image_version }}"
|
96
|
+
url: "{{ image_url }}"
|
97
|
+
checksum: "{{ image_checksum }}"
|
98
|
+
build_date: {{ image_builddate }}
|
99
|
+
|
100
|
+
"""
|
osism/tasks/ansible.py
CHANGED
osism/tasks/ceph.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
from celery import Celery
|
4
4
|
|
5
|
+
from osism import utils
|
5
6
|
from osism.tasks import Config, run_ansible_in_environment
|
6
7
|
|
7
8
|
app = Celery("ceph")
|
@@ -15,6 +16,9 @@ def setup_periodic_tasks(sender, **kwargs):
|
|
15
16
|
|
16
17
|
@app.task(bind=True, name="osism.tasks.ceph.run")
|
17
18
|
def run(self, environment, playbook, arguments, publish=True, auto_release_time=3600):
|
19
|
+
# Check if tasks are locked before execution
|
20
|
+
utils.check_task_lock_and_exit()
|
21
|
+
|
18
22
|
return run_ansible_in_environment(
|
19
23
|
self.request.id,
|
20
24
|
"ceph-ansible",
|
@@ -5,6 +5,7 @@ from celery import Celery
|
|
5
5
|
from celery.signals import worker_process_init
|
6
6
|
from loguru import logger
|
7
7
|
|
8
|
+
from osism import utils
|
8
9
|
from osism.tasks import Config
|
9
10
|
from osism.tasks.conductor.config import get_configuration
|
10
11
|
from osism.tasks.conductor.ironic import sync_ironic as _sync_ironic
|
@@ -40,16 +41,25 @@ def get_ironic_parameters(self):
|
|
40
41
|
|
41
42
|
@app.task(bind=True, name="osism.tasks.conductor.sync_netbox")
|
42
43
|
def sync_netbox(self, force_update=False):
|
44
|
+
# Check if tasks are locked before execution
|
45
|
+
utils.check_task_lock_and_exit()
|
46
|
+
|
43
47
|
logger.info("Not implemented")
|
44
48
|
|
45
49
|
|
46
50
|
@app.task(bind=True, name="osism.tasks.conductor.sync_ironic")
|
47
51
|
def sync_ironic(self, node_name=None, force_update=False):
|
52
|
+
# Check if tasks are locked before execution
|
53
|
+
utils.check_task_lock_and_exit()
|
54
|
+
|
48
55
|
_sync_ironic(self.request.id, get_ironic_parameters, node_name, force_update)
|
49
56
|
|
50
57
|
|
51
58
|
@app.task(bind=True, name="osism.tasks.conductor.sync_sonic")
|
52
59
|
def sync_sonic(self, device_name=None, show_diff=True):
|
60
|
+
# Check if tasks are locked before execution
|
61
|
+
utils.check_task_lock_and_exit()
|
62
|
+
|
53
63
|
return _sync_sonic(device_name, self.request.id, show_diff)
|
54
64
|
|
55
65
|
|
osism/tasks/kolla.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
from celery import Celery
|
4
4
|
|
5
|
+
from osism import utils
|
5
6
|
from osism.tasks import Config, run_ansible_in_environment
|
6
7
|
|
7
8
|
app = Celery("kolla")
|
@@ -15,6 +16,9 @@ def setup_periodic_tasks(sender, **kwargs):
|
|
15
16
|
|
16
17
|
@app.task(bind=True, name="osism.tasks.kolla.run")
|
17
18
|
def run(self, environment, playbook, arguments, publish=True, auto_release_time=3600):
|
19
|
+
# Check if tasks are locked before execution
|
20
|
+
utils.check_task_lock_and_exit()
|
21
|
+
|
18
22
|
return run_ansible_in_environment(
|
19
23
|
self.request.id,
|
20
24
|
"kolla-ansible",
|
osism/tasks/kubernetes.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
from celery import Celery
|
4
4
|
|
5
|
+
from osism import utils
|
5
6
|
from osism.tasks import Config, run_ansible_in_environment
|
6
7
|
|
7
8
|
app = Celery("kubernetes")
|
@@ -15,6 +16,9 @@ def setup_periodic_tasks(sender, **kwargs):
|
|
15
16
|
|
16
17
|
@app.task(bind=True, name="osism.tasks.kubernetes.run")
|
17
18
|
def run(self, environment, playbook, arguments, publish=True, auto_release_time=3600):
|
19
|
+
# Check if tasks are locked before execution
|
20
|
+
utils.check_task_lock_and_exit()
|
21
|
+
|
18
22
|
return run_ansible_in_environment(
|
19
23
|
self.request.id,
|
20
24
|
"kubernetes",
|