Revision ac156ecd lib/cmdlib/instance.py
b/lib/cmdlib/instance.py | ||
---|---|---|
849 | 849 |
# build the full file storage dir path |
850 | 850 |
joinargs = [] |
851 | 851 |
|
852 |
if self.op.disk_template in (constants.DT_SHARED_FILE, |
|
853 |
constants.DT_GLUSTER): |
|
854 |
get_fsd_fn = self.cfg.GetSharedFileStorageDir |
|
855 |
else: |
|
856 |
get_fsd_fn = self.cfg.GetFileStorageDir |
|
852 |
cfg_storage = None |
|
853 |
if self.op.disk_template == constants.DT_FILE: |
|
854 |
cfg_storage = self.cfg.GetFileStorageDir() |
|
855 |
elif self.op.disk_template == constants.DT_SHARED_FILE: |
|
856 |
cfg_storage = self.cfg.GetSharedFileStorageDir() |
|
857 |
elif self.op.disk_template == constants.DT_GLUSTER: |
|
858 |
cfg_storage = self.cfg.GetGlusterStorageDir() |
|
859 |
|
|
860 |
if not cfg_storage: |
|
861 |
raise errors.OpPrereqError( |
|
862 |
"Cluster file storage dir for {tpl} storage type not defined".format( |
|
863 |
tpl=repr(self.op.disk_template) |
|
864 |
), |
|
865 |
errors.ECODE_STATE |
|
866 |
) |
|
857 | 867 |
|
858 |
cfg_storagedir = get_fsd_fn() |
|
859 |
if not cfg_storagedir: |
|
860 |
raise errors.OpPrereqError("Cluster file storage dir not defined", |
|
861 |
errors.ECODE_STATE) |
|
862 |
joinargs.append(cfg_storagedir) |
|
868 |
joinargs.append(cfg_storage) |
|
863 | 869 |
|
864 | 870 |
if self.op.file_storage_dir is not None: |
865 | 871 |
joinargs.append(self.op.file_storage_dir) |
866 | 872 |
|
867 |
joinargs.append(self.op.instance_name) |
|
873 |
if self.op.disk_template != constants.DT_GLUSTER: |
|
874 |
joinargs.append(self.op.instance_name) |
|
868 | 875 |
|
869 |
# pylint: disable=W0142 |
|
870 |
self.instance_file_storage_dir = utils.PathJoin(*joinargs) |
|
876 |
if len(joinargs) > 1: |
|
877 |
# pylint: disable=W0142 |
|
878 |
self.instance_file_storage_dir = utils.PathJoin(*joinargs) |
|
879 |
else: |
|
880 |
self.instance_file_storage_dir = joinargs[0] |
|
871 | 881 |
|
872 | 882 |
def CheckPrereq(self): # pylint: disable=R0914 |
873 | 883 |
"""Check prerequisites. |
Also available in: Unified diff