1151 |
1151 |
"""
|
1152 |
1152 |
# FIXME: This only works because there is only one parameter that can be
|
1153 |
1153 |
# changed or removed.
|
1154 |
|
if not self.op.vg_name:
|
|
1154 |
if self.op.vg_name is not None and not self.op.vg_name:
|
1155 |
1155 |
instances = self.cfg.GetAllInstancesInfo().values()
|
1156 |
1156 |
for inst in instances:
|
1157 |
1157 |
for disk in inst.disks:
|
... | ... | |
1159 |
1159 |
raise errors.OpPrereqError("Cannot disable lvm storage while"
|
1160 |
1160 |
" lvm-based instances exist")
|
1161 |
1161 |
|
|
1162 |
node_list = self.acquired_locks[locking.LEVEL_NODE]
|
|
1163 |
|
1162 |
1164 |
# if vg_name not None, checks given volume group on all nodes
|
1163 |
1165 |
if self.op.vg_name:
|
1164 |
|
node_list = self.acquired_locks[locking.LEVEL_NODE]
|
1165 |
1166 |
vglist = self.rpc.call_vg_list(node_list)
|
1166 |
1167 |
for node in node_list:
|
1167 |
1168 |
vgstatus = utils.CheckVolumeGroupSize(vglist[node], self.op.vg_name,
|
... | ... | |
1170 |
1171 |
raise errors.OpPrereqError("Error on node '%s': %s" %
|
1171 |
1172 |
(node, vgstatus))
|
1172 |
1173 |
|
|
1174 |
self.cluster = cluster = self.cfg.GetClusterInfo()
|
|
1175 |
# beparams changes do not need validation (we can't validate?),
|
|
1176 |
# but we still process here
|
|
1177 |
if self.op.beparams:
|
|
1178 |
self.new_beparams = cluster.FillDict(
|
|
1179 |
cluster.beparams[constants.BEGR_DEFAULT], self.op.beparams)
|
|
1180 |
|
|
1181 |
# hypervisor list/parameters
|
|
1182 |
self.new_hvparams = cluster.FillDict(cluster.hvparams, {})
|
|
1183 |
if self.op.hvparams:
|
|
1184 |
if not isinstance(self.op.hvparams, dict):
|
|
1185 |
raise errors.OpPrereqError("Invalid 'hvparams' parameter on input")
|
|
1186 |
for hv_name, hv_dict in self.op.hvparams.items():
|
|
1187 |
if hv_name not in self.new_hvparams:
|
|
1188 |
self.new_hvparams[hv_name] = hv_dict
|
|
1189 |
else:
|
|
1190 |
self.new_hvparams[hv_name].update(hv_dict)
|
|
1191 |
|
|
1192 |
if self.op.enabled_hypervisors is not None:
|
|
1193 |
self.hv_list = self.op.enabled_hypervisors
|
|
1194 |
else:
|
|
1195 |
self.hv_list = cluster.enabled_hypervisors
|
|
1196 |
|
|
1197 |
if self.op.hvparams or self.op.enabled_hypervisors is not None:
|
|
1198 |
# either the enabled list has changed, or the parameters have, validate
|
|
1199 |
for hv_name, hv_params in self.new_hvparams.items():
|
|
1200 |
if ((self.op.hvparams and hv_name in self.op.hvparams) or
|
|
1201 |
(self.op.enabled_hypervisors and
|
|
1202 |
hv_name in self.op.enabled_hypervisors)):
|
|
1203 |
# either this is a new hypervisor, or its parameters have changed
|
|
1204 |
hv_class = hypervisor.GetHypervisor(hv_name)
|
|
1205 |
hv_class.CheckParameterSyntax(hv_params)
|
|
1206 |
_CheckHVParams(self, node_list, hv_name, hv_params)
|
|
1207 |
|
1173 |
1208 |
def Exec(self, feedback_fn):
|
1174 |
1209 |
"""Change the parameters of the cluster.
|
1175 |
1210 |
|
1176 |
1211 |
"""
|
1177 |
|
if self.op.vg_name != self.cfg.GetVGName():
|
1178 |
|
self.cfg.SetVGName(self.op.vg_name)
|
1179 |
|
else:
|
1180 |
|
feedback_fn("Cluster LVM configuration already in desired"
|
1181 |
|
" state, not changing")
|
|
1212 |
if self.op.vg_name is not None:
|
|
1213 |
if self.op.vg_name != self.cfg.GetVGName():
|
|
1214 |
self.cfg.SetVGName(self.op.vg_name)
|
|
1215 |
else:
|
|
1216 |
feedback_fn("Cluster LVM configuration already in desired"
|
|
1217 |
" state, not changing")
|
|
1218 |
if self.op.hvparams:
|
|
1219 |
self.cluster.hvparams = self.new_hvparams
|
|
1220 |
if self.op.enabled_hypervisors is not None:
|
|
1221 |
self.cluster.enabled_hypervisors = self.op.enabled_hypervisors
|
|
1222 |
if self.op.beparams:
|
|
1223 |
self.cluster.beparams[constants.BEGR_DEFAULT] = self.new_beparams
|
|
1224 |
self.cfg.Update(self.cluster)
|
1182 |
1225 |
|
1183 |
1226 |
|
1184 |
1227 |
def _WaitForSync(lu, instance, oneshot=False, unlock=False):
|