Revision dff5f600 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
6165 | 6165 |
|
6166 | 6166 |
""" |
6167 | 6167 |
REQ_BGL = False |
6168 |
_FIELDS_DYNAMIC = utils.FieldSet() |
|
6169 |
_FIELDS_STATIC = utils.FieldSet("cluster_name", "master_node", "drain_flag", |
|
6170 |
"watcher_pause", "volume_group_name") |
|
6171 | 6168 |
|
6172 | 6169 |
def CheckArguments(self): |
6173 |
_CheckOutputFields(static=self._FIELDS_STATIC, |
|
6174 |
dynamic=self._FIELDS_DYNAMIC, |
|
6175 |
selected=self.op.output_fields) |
|
6170 |
self.cq = _ClusterQuery(None, self.op.output_fields, False) |
|
6176 | 6171 |
|
6177 | 6172 |
def ExpandNames(self): |
6178 |
self.needed_locks = {} |
|
6173 |
self.cq.ExpandNames(self) |
|
6174 |
|
|
6175 |
def DeclareLocks(self, level): |
|
6176 |
self.cq.DeclareLocks(self, level) |
|
6179 | 6177 |
|
6180 | 6178 |
def Exec(self, feedback_fn): |
6181 |
"""Dump a representation of the cluster config to the standard output. |
|
6182 |
|
|
6183 |
""" |
|
6184 |
values = [] |
|
6185 |
for field in self.op.output_fields: |
|
6186 |
if field == "cluster_name": |
|
6187 |
entry = self.cfg.GetClusterName() |
|
6188 |
elif field == "master_node": |
|
6189 |
entry = self.cfg.GetMasterNode() |
|
6190 |
elif field == "drain_flag": |
|
6191 |
entry = os.path.exists(constants.JOB_QUEUE_DRAIN_FILE) |
|
6192 |
elif field == "watcher_pause": |
|
6193 |
entry = utils.ReadWatcherPauseFile(constants.WATCHER_PAUSEFILE) |
|
6194 |
elif field == "volume_group_name": |
|
6195 |
entry = self.cfg.GetVGName() |
|
6196 |
else: |
|
6197 |
raise errors.ParameterError(field) |
|
6198 |
values.append(entry) |
|
6199 |
return values |
|
6179 |
result = self.cq.OldStyleQuery(self) |
|
6180 |
|
|
6181 |
assert len(result) == 1 |
|
6182 |
|
|
6183 |
return result[0] |
|
6184 |
|
|
6185 |
|
|
6186 |
class _ClusterQuery(_QueryBase): |
|
6187 |
FIELDS = query.CLUSTER_FIELDS |
|
6188 |
|
|
6189 |
#: Do not sort (there is only one item) |
|
6190 |
SORT_FIELD = None |
|
6191 |
|
|
6192 |
def ExpandNames(self, lu): |
|
6193 |
lu.needed_locks = {} |
|
6194 |
|
|
6195 |
# The following variables interact with _QueryBase._GetNames |
|
6196 |
self.wanted = locking.ALL_SET |
|
6197 |
self.do_locking = self.use_locking |
|
6198 |
|
|
6199 |
if self.do_locking: |
|
6200 |
raise errors.OpPrereqError("Can not use locking for cluster queries", |
|
6201 |
errors.ECODE_INVAL) |
|
6202 |
|
|
6203 |
def DeclareLocks(self, lu, level): |
|
6204 |
pass |
|
6205 |
|
|
6206 |
def _GetQueryData(self, lu): |
|
6207 |
"""Computes the list of nodes and their attributes. |
|
6208 |
|
|
6209 |
""" |
|
6210 |
# Locking is not used |
|
6211 |
assert not (compat.any(lu.glm.is_owned(level) |
|
6212 |
for level in locking.LEVELS |
|
6213 |
if level != locking.LEVEL_CLUSTER) or |
|
6214 |
self.do_locking or self.use_locking) |
|
6215 |
|
|
6216 |
if query.CQ_CONFIG in self.requested_data: |
|
6217 |
cluster = lu.cfg.GetClusterInfo() |
|
6218 |
else: |
|
6219 |
cluster = NotImplemented |
|
6220 |
|
|
6221 |
if query.CQ_QUEUE_DRAINED in self.requested_data: |
|
6222 |
drain_flag = os.path.exists(constants.JOB_QUEUE_DRAIN_FILE) |
|
6223 |
else: |
|
6224 |
drain_flag = NotImplemented |
|
6225 |
|
|
6226 |
if query.CQ_WATCHER_PAUSE in self.requested_data: |
|
6227 |
watcher_pause = utils.ReadWatcherPauseFile(constants.WATCHER_PAUSEFILE) |
|
6228 |
else: |
|
6229 |
watcher_pause = NotImplemented |
|
6230 |
|
|
6231 |
return query.ClusterQueryData(cluster, drain_flag, watcher_pause) |
|
6200 | 6232 |
|
6201 | 6233 |
|
6202 | 6234 |
class LUInstanceActivateDisks(NoHooksLU): |
... | ... | |
13080 | 13112 |
|
13081 | 13113 |
""" |
13082 | 13114 |
# Locking is not used |
13115 |
# TODO |
|
13083 | 13116 |
assert not (compat.any(lu.glm.is_owned(level) |
13084 | 13117 |
for level in locking.LEVELS |
13085 | 13118 |
if level != locking.LEVEL_CLUSTER) or |
... | ... | |
15214 | 15247 |
|
15215 | 15248 |
#: Query type implementations |
15216 | 15249 |
_QUERY_IMPL = { |
15250 |
constants.QR_CLUSTER: _ClusterQuery, |
|
15217 | 15251 |
constants.QR_INSTANCE: _InstanceQuery, |
15218 | 15252 |
constants.QR_NODE: _NodeQuery, |
15219 | 15253 |
constants.QR_GROUP: _GroupQuery, |
Also available in: Unified diff