Revision 7c577910 lib/cmdlib/cluster.py
b/lib/cmdlib/cluster.py | ||
---|---|---|
851 | 851 |
CheckIpolicyVsDiskTemplates(cluster.ipolicy, |
852 | 852 |
enabled_disk_templates) |
853 | 853 |
|
854 |
def CheckPrereq(self):
|
|
855 |
"""Check prerequisites.
|
|
854 |
def _CheckDrbdHelper(self, node_uuids):
|
|
855 |
"""Check the DRBD usermode helper.
|
|
856 | 856 |
|
857 |
This checks whether the given params don't conflict and
|
|
858 |
if the given volume group is valid.
|
|
857 |
@type node_uuids: list of strings
|
|
858 |
@param node_uuids: a list of nodes' UUIDs
|
|
859 | 859 |
|
860 | 860 |
""" |
861 | 861 |
if self.op.drbd_helper is not None and not self.op.drbd_helper: |
... | ... | |
864 | 864 |
" drbd-based instances exist", |
865 | 865 |
errors.ECODE_INVAL) |
866 | 866 |
|
867 |
if self.op.drbd_helper: |
|
868 |
# checks given drbd helper on all nodes |
|
869 |
helpers = self.rpc.call_drbd_helper(node_uuids) |
|
870 |
for (_, ninfo) in self.cfg.GetMultiNodeInfo(node_uuids): |
|
871 |
if ninfo.offline: |
|
872 |
self.LogInfo("Not checking drbd helper on offline node %s", |
|
873 |
ninfo.name) |
|
874 |
continue |
|
875 |
msg = helpers[ninfo.uuid].fail_msg |
|
876 |
if msg: |
|
877 |
raise errors.OpPrereqError("Error checking drbd helper on node" |
|
878 |
" '%s': %s" % (ninfo.name, msg), |
|
879 |
errors.ECODE_ENVIRON) |
|
880 |
node_helper = helpers[ninfo.uuid].payload |
|
881 |
if node_helper != self.op.drbd_helper: |
|
882 |
raise errors.OpPrereqError("Error on node '%s': drbd helper is %s" % |
|
883 |
(ninfo.name, node_helper), |
|
884 |
errors.ECODE_ENVIRON) |
|
885 |
|
|
886 |
def CheckPrereq(self): |
|
887 |
"""Check prerequisites. |
|
888 |
|
|
889 |
This checks whether the given params don't conflict and |
|
890 |
if the given volume group is valid. |
|
891 |
|
|
892 |
""" |
|
867 | 893 |
node_uuids = self.owned_locks(locking.LEVEL_NODE) |
868 | 894 |
self.cluster = cluster = self.cfg.GetClusterInfo() |
869 | 895 |
|
... | ... | |
886 | 912 |
self.LogWarning, self.op.shared_file_storage_dir, |
887 | 913 |
enabled_disk_templates) |
888 | 914 |
|
889 |
if self.op.drbd_helper: |
|
890 |
# checks given drbd helper on all nodes |
|
891 |
helpers = self.rpc.call_drbd_helper(node_uuids) |
|
892 |
for (_, ninfo) in self.cfg.GetMultiNodeInfo(node_uuids): |
|
893 |
if ninfo.offline: |
|
894 |
self.LogInfo("Not checking drbd helper on offline node %s", |
|
895 |
ninfo.name) |
|
896 |
continue |
|
897 |
msg = helpers[ninfo.uuid].fail_msg |
|
898 |
if msg: |
|
899 |
raise errors.OpPrereqError("Error checking drbd helper on node" |
|
900 |
" '%s': %s" % (ninfo.name, msg), |
|
901 |
errors.ECODE_ENVIRON) |
|
902 |
node_helper = helpers[ninfo.uuid].payload |
|
903 |
if node_helper != self.op.drbd_helper: |
|
904 |
raise errors.OpPrereqError("Error on node '%s': drbd helper is %s" % |
|
905 |
(ninfo.name, node_helper), |
|
906 |
errors.ECODE_ENVIRON) |
|
915 |
self._CheckDrbdHelper(node_uuids) |
|
907 | 916 |
|
908 | 917 |
# validate params changes |
909 | 918 |
if self.op.beparams: |
... | ... | |
1111 | 1120 |
else: |
1112 | 1121 |
self.cluster.file_storage_dir = self.op.file_storage_dir |
1113 | 1122 |
|
1114 |
def Exec(self, feedback_fn):
|
|
1115 |
"""Change the parameters of the cluster.
|
|
1123 |
def _SetDrbdHelper(self, feedback_fn):
|
|
1124 |
"""Set the DRBD usermode helper.
|
|
1116 | 1125 |
|
1117 | 1126 |
""" |
1118 |
if self.op.enabled_disk_templates: |
|
1119 |
self.cluster.enabled_disk_templates = \ |
|
1120 |
list(set(self.op.enabled_disk_templates)) |
|
1121 |
|
|
1122 |
self._SetVgName(feedback_fn) |
|
1123 |
self._SetFileStorageDir(feedback_fn) |
|
1124 |
|
|
1125 | 1127 |
if self.op.drbd_helper is not None: |
1126 | 1128 |
if not constants.DT_DRBD8 in self.cluster.enabled_disk_templates: |
1127 | 1129 |
feedback_fn("Note that you specified a drbd user helper, but did not" |
... | ... | |
1134 | 1136 |
else: |
1135 | 1137 |
feedback_fn("Cluster DRBD helper already in desired state," |
1136 | 1138 |
" not changing") |
1139 |
|
|
1140 |
def Exec(self, feedback_fn): |
|
1141 |
"""Change the parameters of the cluster. |
|
1142 |
|
|
1143 |
""" |
|
1144 |
if self.op.enabled_disk_templates: |
|
1145 |
self.cluster.enabled_disk_templates = \ |
|
1146 |
list(set(self.op.enabled_disk_templates)) |
|
1147 |
|
|
1148 |
self._SetVgName(feedback_fn) |
|
1149 |
self._SetFileStorageDir(feedback_fn) |
|
1150 |
self._SetDrbdHelper(feedback_fn) |
|
1151 |
|
|
1137 | 1152 |
if self.op.hvparams: |
1138 | 1153 |
self.cluster.hvparams = self.new_hvparams |
1139 | 1154 |
if self.op.os_hvp: |
Also available in: Unified diff