Revision 912737ba lib/client/gnt_cluster.py
b/lib/client/gnt_cluster.py | ||
---|---|---|
62 | 62 |
_EPO_REACHABLE_TIMEOUT = 15 * 60 # 15 minutes |
63 | 63 |
|
64 | 64 |
|
65 |
def _CheckNoLvmStorageOptDeprecated(opts): |
|
66 |
"""Checks if the legacy option '--no-lvm-storage' is used. |
|
67 |
|
|
68 |
""" |
|
69 |
if not opts.lvm_storage: |
|
70 |
ToStderr("The option --no-lvm-storage is no longer supported. If you want" |
|
71 |
" to disable lvm-based storage cluster-wide, use the option" |
|
72 |
" --enabled-disk-templates to disable all of these lvm-base disk " |
|
73 |
" templates: %s" % |
|
74 |
utils.CommaJoin(utils.GetLvmDiskTemplates())) |
|
75 |
return 1 |
|
76 |
|
|
77 |
|
|
65 | 78 |
@UsesRPC |
66 | 79 |
def InitCluster(opts, args): |
67 | 80 |
"""Initialize the cluster. |
... | ... | |
74 | 87 |
@return: the desired exit code |
75 | 88 |
|
76 | 89 |
""" |
77 |
if not opts.lvm_storage and opts.vg_name: |
|
78 |
ToStderr("Options --no-lvm-storage and --vg-name conflict.") |
|
90 |
if _CheckNoLvmStorageOptDeprecated(opts): |
|
79 | 91 |
return 1 |
92 |
enabled_disk_templates = opts.enabled_disk_templates |
|
93 |
if enabled_disk_templates: |
|
94 |
enabled_disk_templates = enabled_disk_templates.split(",") |
|
95 |
else: |
|
96 |
enabled_disk_templates = list(constants.DEFAULT_ENABLED_DISK_TEMPLATES) |
|
80 | 97 |
|
81 |
vg_name = opts.vg_name |
|
82 |
if opts.lvm_storage and not opts.vg_name: |
|
83 |
vg_name = constants.DEFAULT_VG |
|
98 |
vg_name = None |
|
99 |
if opts.vg_name is not None: |
|
100 |
vg_name = opts.vg_name |
|
101 |
if vg_name: |
|
102 |
if not utils.IsLvmEnabled(enabled_disk_templates): |
|
103 |
ToStdout("You specified a volume group with --vg-name, but you did not" |
|
104 |
" enable any disk template that uses lvm.") |
|
105 |
else: |
|
106 |
if utils.IsLvmEnabled(enabled_disk_templates): |
|
107 |
ToStderr("LVM disk templates are enabled, but vg name not set.") |
|
108 |
return 1 |
|
109 |
else: |
|
110 |
if utils.IsLvmEnabled(enabled_disk_templates): |
|
111 |
vg_name = constants.DEFAULT_VG |
|
84 | 112 |
|
85 | 113 |
if not opts.drbd_storage and opts.drbd_helper: |
86 | 114 |
ToStderr("Options --no-drbd-storage and --drbd-usermode-helper conflict.") |
... | ... | |
193 | 221 |
|
194 | 222 |
hv_state = dict(opts.hv_state) |
195 | 223 |
|
196 |
enabled_disk_templates = opts.enabled_disk_templates |
|
197 |
if enabled_disk_templates: |
|
198 |
enabled_disk_templates = enabled_disk_templates.split(",") |
|
199 |
else: |
|
200 |
enabled_disk_templates = list(constants.DEFAULT_ENABLED_DISK_TEMPLATES) |
|
201 |
|
|
202 | 224 |
bootstrap.InitCluster(cluster_name=args[0], |
203 | 225 |
secondary_ip=opts.secondary_ip, |
204 | 226 |
vg_name=vg_name, |
... | ... | |
945 | 967 |
@return: the desired exit code |
946 | 968 |
|
947 | 969 |
""" |
948 |
if not (not opts.lvm_storage or opts.vg_name or |
|
949 |
not opts.drbd_storage or opts.drbd_helper or |
|
970 |
if not (opts.vg_name is not None or opts.drbd_helper or |
|
950 | 971 |
opts.enabled_hypervisors or opts.hvparams or |
951 | 972 |
opts.beparams or opts.nicparams or |
952 | 973 |
opts.ndparams or opts.diskparams or |
... | ... | |
975 | 996 |
ToStderr("Please give at least one of the parameters.") |
976 | 997 |
return 1 |
977 | 998 |
|
978 |
vg_name = opts.vg_name |
|
979 |
if not opts.lvm_storage and opts.vg_name: |
|
980 |
ToStderr("Options --no-lvm-storage and --vg-name conflict.") |
|
999 |
if _CheckNoLvmStorageOptDeprecated(opts): |
|
981 | 1000 |
return 1 |
982 | 1001 |
|
983 |
if not opts.lvm_storage: |
|
984 |
vg_name = "" |
|
1002 |
enabled_disk_templates = None |
|
1003 |
if opts.enabled_disk_templates: |
|
1004 |
enabled_disk_templates = opts.enabled_disk_templates.split(",") |
|
1005 |
|
|
1006 |
# consistency between vg name and enabled disk templates |
|
1007 |
vg_name = None |
|
1008 |
if opts.vg_name is not None: |
|
1009 |
vg_name = opts.vg_name |
|
1010 |
if enabled_disk_templates: |
|
1011 |
if vg_name and not utils.IsLvmEnabled(enabled_disk_templates): |
|
1012 |
ToStdout("You specified a volume group with --vg-name, but you did not" |
|
1013 |
" enable any of the following lvm-based disk templates: %s" % |
|
1014 |
utils.CommaJoin(utils.GetLvmDiskTemplates())) |
|
985 | 1015 |
|
986 | 1016 |
drbd_helper = opts.drbd_helper |
987 | 1017 |
if not opts.drbd_storage and opts.drbd_helper: |
... | ... | |
995 | 1025 |
if hvlist is not None: |
996 | 1026 |
hvlist = hvlist.split(",") |
997 | 1027 |
|
998 |
enabled_disk_templates = opts.enabled_disk_templates |
|
999 |
if enabled_disk_templates: |
|
1000 |
enabled_disk_templates = enabled_disk_templates.split(",") |
|
1001 |
|
|
1002 | 1028 |
# a list of (name, dict) we can pass directly to dict() (or []) |
1003 | 1029 |
hvparams = dict(opts.hvparams) |
1004 | 1030 |
for hv_params in hvparams.values(): |
Also available in: Unified diff