Revision 9d276e93 lib/opcodes.py
b/lib/opcodes.py | ||
---|---|---|
326 | 326 |
}) |
327 | 327 |
|
328 | 328 |
|
329 |
def RequireFileStorage(): |
|
330 |
"""Checks that file storage is enabled. |
|
331 |
|
|
332 |
While it doesn't really fit into this module, L{utils} was deemed too large |
|
333 |
of a dependency to be imported for just one or two functions. |
|
334 |
|
|
335 |
@raise errors.OpPrereqError: when file storage is disabled |
|
336 |
|
|
337 |
""" |
|
338 |
if not constants.ENABLE_FILE_STORAGE: |
|
339 |
raise errors.OpPrereqError("File storage disabled at configure time", |
|
340 |
errors.ECODE_INVAL) |
|
341 |
|
|
342 |
|
|
343 | 329 |
def RequireSharedFileStorage(): |
344 | 330 |
"""Checks that shared file storage is enabled. |
345 | 331 |
|
... | ... | |
354 | 340 |
" configure time", errors.ECODE_INVAL) |
355 | 341 |
|
356 | 342 |
|
357 |
@ht.WithDesc("CheckFileStorage") |
|
358 |
def _CheckFileStorage(value): |
|
359 |
"""Ensures file storage is enabled if used. |
|
360 |
|
|
361 |
""" |
|
362 |
if value == constants.DT_FILE: |
|
363 |
RequireFileStorage() |
|
364 |
elif value == constants.DT_SHARED_FILE: |
|
365 |
RequireSharedFileStorage() |
|
366 |
return True |
|
367 |
|
|
368 |
|
|
369 | 343 |
def _BuildDiskTemplateCheck(accept_none): |
370 | 344 |
"""Builds check for disk template. |
371 | 345 |
|
... | ... | |
379 | 353 |
if accept_none: |
380 | 354 |
template_check = ht.TMaybe(template_check) |
381 | 355 |
|
382 |
return ht.TAnd(template_check, _CheckFileStorage)
|
|
356 |
return template_check
|
|
383 | 357 |
|
384 | 358 |
|
385 | 359 |
def _CheckStorageType(storage_type): |
... | ... | |
389 | 363 |
if storage_type not in constants.VALID_STORAGE_TYPES: |
390 | 364 |
raise errors.OpPrereqError("Unknown storage type: %s" % storage_type, |
391 | 365 |
errors.ECODE_INVAL) |
392 |
if storage_type == constants.ST_FILE: |
|
393 |
# TODO: What about shared file storage? |
|
394 |
RequireFileStorage() |
|
395 | 366 |
return True |
396 | 367 |
|
397 | 368 |
|
Also available in: Unified diff