560 |
560 |
_CheckOSVariant(result.payload, os_name)
|
561 |
561 |
|
562 |
562 |
|
|
563 |
def _RequireFileStorage():
|
|
564 |
"""Checks that file storage is enabled.
|
|
565 |
|
|
566 |
@raise errors.OpPrereqError: when file storage is disabled
|
|
567 |
|
|
568 |
"""
|
|
569 |
if not constants.ENABLE_FILE_STORAGE:
|
|
570 |
raise errors.OpPrereqError("File storage disabled at configure time",
|
|
571 |
errors.ECODE_INVAL)
|
|
572 |
|
|
573 |
|
563 |
574 |
def _CheckDiskTemplate(template):
|
564 |
575 |
"""Ensure a given disk template is valid.
|
565 |
576 |
|
... | ... | |
568 |
579 |
msg = ("Invalid disk template name '%s', valid templates are: %s" %
|
569 |
580 |
(template, utils.CommaJoin(constants.DISK_TEMPLATES)))
|
570 |
581 |
raise errors.OpPrereqError(msg, errors.ECODE_INVAL)
|
571 |
|
if template == constants.DT_FILE and not constants.ENABLE_FILE_STORAGE:
|
572 |
|
raise errors.OpPrereqError("File storage disabled at configure time",
|
|
582 |
if template == constants.DT_FILE:
|
|
583 |
_RequireFileStorage()
|
|
584 |
|
|
585 |
|
|
586 |
def _CheckStorageType(storage_type):
|
|
587 |
"""Ensure a given storage type is valid.
|
|
588 |
|
|
589 |
"""
|
|
590 |
if storage_type not in constants.VALID_STORAGE_TYPES:
|
|
591 |
raise errors.OpPrereqError("Unknown storage type: %s" % storage_type,
|
573 |
592 |
errors.ECODE_INVAL)
|
|
593 |
if storage_type == constants.ST_FILE:
|
|
594 |
_RequireFileStorage()
|
|
595 |
|
574 |
596 |
|
575 |
597 |
|
576 |
598 |
def _CheckInstanceDown(lu, instance, reason):
|
... | ... | |
3079 |
3101 |
REQ_BGL = False
|
3080 |
3102 |
_FIELDS_STATIC = utils.FieldSet(constants.SF_NODE)
|
3081 |
3103 |
|
3082 |
|
def ExpandNames(self):
|
3083 |
|
storage_type = self.op.storage_type
|
3084 |
|
|
3085 |
|
if storage_type not in constants.VALID_STORAGE_TYPES:
|
3086 |
|
raise errors.OpPrereqError("Unknown storage type: %s" % storage_type,
|
3087 |
|
errors.ECODE_INVAL)
|
|
3104 |
def CheckArguments(self):
|
|
3105 |
_CheckStorageType(self.op.storage_type)
|
3088 |
3106 |
|
3089 |
3107 |
_CheckOutputFields(static=self._FIELDS_STATIC,
|
3090 |
3108 |
dynamic=utils.FieldSet(*constants.VALID_STORAGE_FIELDS),
|
3091 |
3109 |
selected=self.op.output_fields)
|
3092 |
3110 |
|
|
3111 |
def ExpandNames(self):
|
3093 |
3112 |
self.needed_locks = {}
|
3094 |
3113 |
self.share_locks[locking.LEVEL_NODE] = 1
|
3095 |
3114 |
|
... | ... | |
3178 |
3197 |
def CheckArguments(self):
|
3179 |
3198 |
self.opnode_name = _ExpandNodeName(self.cfg, self.op.node_name)
|
3180 |
3199 |
|
3181 |
|
storage_type = self.op.storage_type
|
3182 |
|
if storage_type not in constants.VALID_STORAGE_TYPES:
|
3183 |
|
raise errors.OpPrereqError("Unknown storage type: %s" % storage_type,
|
3184 |
|
errors.ECODE_INVAL)
|
|
3200 |
_CheckStorageType(self.op.storage_type)
|
3185 |
3201 |
|
3186 |
3202 |
def ExpandNames(self):
|
3187 |
3203 |
self.needed_locks = {
|
... | ... | |
5808 |
5824 |
if len(secondary_nodes) != 0:
|
5809 |
5825 |
raise errors.ProgrammerError("Wrong template configuration")
|
5810 |
5826 |
|
|
5827 |
_RequireFileStorage()
|
|
5828 |
|
5811 |
5829 |
for idx, disk in enumerate(disk_info):
|
5812 |
5830 |
disk_index = idx + base_index
|
5813 |
5831 |
disk_dev = objects.Disk(dev_type=constants.LD_FILE, size=disk["size"],
|
... | ... | |
6629 |
6647 |
else:
|
6630 |
6648 |
network_port = None
|
6631 |
6649 |
|
6632 |
|
##if self.op.vnc_bind_address is None:
|
6633 |
|
## self.op.vnc_bind_address = constants.VNC_DEFAULT_BIND_ADDRESS
|
|
6650 |
if constants.ENABLE_FILE_STORAGE:
|
|
6651 |
# this is needed because os.path.join does not accept None arguments
|
|
6652 |
if self.op.file_storage_dir is None:
|
|
6653 |
string_file_storage_dir = ""
|
|
6654 |
else:
|
|
6655 |
string_file_storage_dir = self.op.file_storage_dir
|
6634 |
6656 |
|
6635 |
|
# this is needed because os.path.join does not accept None arguments
|
6636 |
|
if self.op.file_storage_dir is None:
|
6637 |
|
string_file_storage_dir = ""
|
|
6657 |
# build the full file storage dir path
|
|
6658 |
file_storage_dir = utils.PathJoin(self.cfg.GetFileStorageDir(),
|
|
6659 |
string_file_storage_dir, instance)
|
6638 |
6660 |
else:
|
6639 |
|
string_file_storage_dir = self.op.file_storage_dir
|
6640 |
|
|
6641 |
|
# build the full file storage dir path
|
6642 |
|
file_storage_dir = utils.PathJoin(self.cfg.GetFileStorageDir(),
|
6643 |
|
string_file_storage_dir, instance)
|
|
6661 |
file_storage_dir = ""
|
6644 |
6662 |
|
6645 |
6663 |
|
6646 |
6664 |
disks = _GenerateDiskTemplate(self,
|
... | ... | |
7660 |
7678 |
def CheckArguments(self):
|
7661 |
7679 |
self.op.node_name = _ExpandNodeName(self.cfg, self.op.node_name)
|
7662 |
7680 |
|
|
7681 |
_CheckStorageType(self.op.storage_type)
|
|
7682 |
|
7663 |
7683 |
def ExpandNames(self):
|
7664 |
7684 |
self.needed_locks = {
|
7665 |
7685 |
locking.LEVEL_NODE: [self.op.node_name],
|