Revision 4b97f902 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
1036 | 1036 |
# Special case for file storage |
1037 | 1037 |
if storage_type == constants.ST_FILE: |
1038 | 1038 |
# storage.FileStorage wants a list of storage directories |
1039 |
return [[cfg.GetFileStorageDir()]] |
|
1039 |
return [[cfg.GetFileStorageDir(), cfg.GetSharedFileStorageDir()]]
|
|
1040 | 1040 |
|
1041 | 1041 |
return [] |
1042 | 1042 |
|
... | ... | |
4696 | 4696 |
"volume_group_name": cluster.volume_group_name, |
4697 | 4697 |
"drbd_usermode_helper": cluster.drbd_usermode_helper, |
4698 | 4698 |
"file_storage_dir": cluster.file_storage_dir, |
4699 |
"shared_file_storage_dir": cluster.shared_file_storage_dir, |
|
4699 | 4700 |
"maintain_node_health": cluster.maintain_node_health, |
4700 | 4701 |
"ctime": cluster.ctime, |
4701 | 4702 |
"mtime": cluster.mtime, |
... | ... | |
5542 | 5543 |
old_name = inst.name |
5543 | 5544 |
|
5544 | 5545 |
rename_file_storage = False |
5545 |
if (inst.disk_template == constants.DT_FILE and
|
|
5546 |
if (inst.disk_template in (constants.DT_FILE, constants.DT_SHARED_FILE) and
|
|
5546 | 5547 |
self.op.new_name != inst.name): |
5547 | 5548 |
old_file_storage_dir = os.path.dirname(inst.disks[0].logical_id[1]) |
5548 | 5549 |
rename_file_storage = True |
... | ... | |
6635 | 6636 |
disk_index)), |
6636 | 6637 |
mode=disk["mode"]) |
6637 | 6638 |
disks.append(disk_dev) |
6639 |
elif template_name == constants.DT_SHARED_FILE: |
|
6640 |
if len(secondary_nodes) != 0: |
|
6641 |
raise errors.ProgrammerError("Wrong template configuration") |
|
6642 |
|
|
6643 |
opcodes.RequireSharedFileStorage() |
|
6644 |
|
|
6645 |
for idx, disk in enumerate(disk_info): |
|
6646 |
disk_index = idx + base_index |
|
6647 |
disk_dev = objects.Disk(dev_type=constants.LD_FILE, size=disk["size"], |
|
6648 |
iv_name="disk/%d" % disk_index, |
|
6649 |
logical_id=(file_driver, |
|
6650 |
"%s/disk%d" % (file_storage_dir, |
|
6651 |
disk_index)), |
|
6652 |
mode=disk["mode"]) |
|
6653 |
disks.append(disk_dev) |
|
6638 | 6654 |
else: |
6639 | 6655 |
raise errors.ProgrammerError("Invalid disk template '%s'" % template_name) |
6640 | 6656 |
return disks |
... | ... | |
6744 | 6760 |
pnode = target_node |
6745 | 6761 |
all_nodes = [pnode] |
6746 | 6762 |
|
6747 |
if instance.disk_template == constants.DT_FILE:
|
|
6763 |
if instance.disk_template in (constants.DT_FILE, constants.DT_SHARED_FILE):
|
|
6748 | 6764 |
file_storage_dir = os.path.dirname(instance.disks[0].logical_id[1]) |
6749 | 6765 |
result = lu.rpc.call_file_storage_dir_create(pnode, file_storage_dir) |
6750 | 6766 |
|
... | ... | |
6834 | 6850 |
# 128 MB are added for drbd metadata for each disk |
6835 | 6851 |
constants.DT_DRBD8: _compute(disks, 128), |
6836 | 6852 |
constants.DT_FILE: {}, |
6853 |
constants.DT_SHARED_FILE: {}, |
|
6837 | 6854 |
} |
6838 | 6855 |
|
6839 | 6856 |
if disk_template not in req_size_dict: |
... | ... | |
6854 | 6871 |
# 128 MB are added for drbd metadata for each disk |
6855 | 6872 |
constants.DT_DRBD8: sum(d["size"] + 128 for d in disks), |
6856 | 6873 |
constants.DT_FILE: None, |
6874 |
constants.DT_SHARED_FILE: 0, |
|
6857 | 6875 |
} |
6858 | 6876 |
|
6859 | 6877 |
if disk_template not in req_size_dict: |
... | ... | |
7657 | 7675 |
else: |
7658 | 7676 |
network_port = None |
7659 | 7677 |
|
7660 |
if constants.ENABLE_FILE_STORAGE: |
|
7678 |
if constants.ENABLE_FILE_STORAGE or constants.ENABLE_SHARED_FILE_STORAGE:
|
|
7661 | 7679 |
# this is needed because os.path.join does not accept None arguments |
7662 | 7680 |
if self.op.file_storage_dir is None: |
7663 | 7681 |
string_file_storage_dir = "" |
... | ... | |
7665 | 7683 |
string_file_storage_dir = self.op.file_storage_dir |
7666 | 7684 |
|
7667 | 7685 |
# build the full file storage dir path |
7668 |
file_storage_dir = utils.PathJoin(self.cfg.GetFileStorageDir(), |
|
7686 |
if self.op.disk_template == constants.DT_SHARED_FILE: |
|
7687 |
get_fsd_fn = self.cfg.GetSharedFileStorageDir |
|
7688 |
else: |
|
7689 |
get_fsd_fn = self.cfg.GetFileStorageDir |
|
7690 |
|
|
7691 |
file_storage_dir = utils.PathJoin(get_fsd_fn(), |
|
7669 | 7692 |
string_file_storage_dir, instance) |
7670 | 7693 |
else: |
7671 | 7694 |
file_storage_dir = "" |
... | ... | |
8811 | 8834 |
|
8812 | 8835 |
self.disk = instance.FindDisk(self.op.disk) |
8813 | 8836 |
|
8814 |
if instance.disk_template != constants.DT_FILE: |
|
8815 |
# TODO: check the free disk space for file, when that feature |
|
8816 |
# will be supported |
|
8837 |
if instance.disk_template not in (constants.DT_FILE, |
|
8838 |
constants.DT_SHARED_FILE): |
|
8839 |
# TODO: check the free disk space for file, when that feature will be |
|
8840 |
# supported |
|
8817 | 8841 |
_CheckNodesFreeDiskPerVG(self, nodenames, |
8818 | 8842 |
self.disk.ComputeGrowth(self.op.amount)) |
8819 | 8843 |
|
... | ... | |
9554 | 9578 |
result.append(("disk/%d" % device_idx, "remove")) |
9555 | 9579 |
elif disk_op == constants.DDM_ADD: |
9556 | 9580 |
# add a new disk |
9557 |
if instance.disk_template == constants.DT_FILE: |
|
9581 |
if instance.disk_template in (constants.DT_FILE, |
|
9582 |
constants.DT_SHARED_FILE): |
|
9558 | 9583 |
file_driver, file_path = instance.disks[0].logical_id |
9559 | 9584 |
file_path = os.path.dirname(file_path) |
9560 | 9585 |
else: |
Also available in: Unified diff