8827 |
8827 |
|
8828 |
8828 |
def ExpandNames(self):
|
8829 |
8829 |
self.needed_locks = {}
|
8830 |
|
self.share_locks = dict.fromkeys(locking.LEVELS, 1)
|
8831 |
8830 |
|
8832 |
|
if self.op.instances:
|
8833 |
|
self.wanted_names = []
|
8834 |
|
for name in self.op.instances:
|
8835 |
|
full_name = _ExpandInstanceName(self.cfg, name)
|
8836 |
|
self.wanted_names.append(full_name)
|
8837 |
|
self.needed_locks[locking.LEVEL_INSTANCE] = self.wanted_names
|
|
8831 |
# Use locking if requested or when non-static information is wanted
|
|
8832 |
if not (self.op.static or self.op.use_locking):
|
|
8833 |
self.LogWarning("Non-static data requested, locks need to be acquired")
|
|
8834 |
self.op.use_locking = True
|
|
8835 |
|
|
8836 |
if self.op.instances or not self.op.use_locking:
|
|
8837 |
# Expand instance names right here
|
|
8838 |
self.wanted_names = _GetWantedInstances(self, self.op.instances)
|
8838 |
8839 |
else:
|
|
8840 |
# Will use acquired locks
|
8839 |
8841 |
self.wanted_names = None
|
8840 |
|
self.needed_locks[locking.LEVEL_INSTANCE] = locking.ALL_SET
|
8841 |
8842 |
|
8842 |
|
self.needed_locks[locking.LEVEL_NODE] = []
|
8843 |
|
self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_REPLACE
|
|
8843 |
if self.op.use_locking:
|
|
8844 |
self.share_locks = dict.fromkeys(locking.LEVELS, 1)
|
|
8845 |
|
|
8846 |
if self.wanted_names is None:
|
|
8847 |
self.needed_locks[locking.LEVEL_INSTANCE] = locking.ALL_SET
|
|
8848 |
else:
|
|
8849 |
self.needed_locks[locking.LEVEL_INSTANCE] = self.wanted_names
|
|
8850 |
|
|
8851 |
self.needed_locks[locking.LEVEL_NODE] = []
|
|
8852 |
self.share_locks = dict.fromkeys(locking.LEVELS, 1)
|
|
8853 |
self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_REPLACE
|
8844 |
8854 |
|
8845 |
8855 |
def DeclareLocks(self, level):
|
8846 |
|
if level == locking.LEVEL_NODE:
|
|
8856 |
if self.op.use_locking and level == locking.LEVEL_NODE:
|
8847 |
8857 |
self._LockInstancesNodes()
|
8848 |
8858 |
|
8849 |
8859 |
def CheckPrereq(self):
|
... | ... | |
8853 |
8863 |
|
8854 |
8864 |
"""
|
8855 |
8865 |
if self.wanted_names is None:
|
|
8866 |
assert self.op.use_locking, "Locking was not used"
|
8856 |
8867 |
self.wanted_names = self.acquired_locks[locking.LEVEL_INSTANCE]
|
8857 |
8868 |
|
8858 |
|
self.wanted_instances = [self.cfg.GetInstanceInfo(name) for name
|
8859 |
|
in self.wanted_names]
|
|
8869 |
self.wanted_instances = [self.cfg.GetInstanceInfo(name)
|
|
8870 |
for name in self.wanted_names]
|
8860 |
8871 |
|
8861 |
8872 |
def _ComputeBlockdevStatus(self, node, instance_name, dev):
|
8862 |
8873 |
"""Returns the status of a block device
|
... | ... | |
8902 |
8913 |
else:
|
8903 |
8914 |
dev_children = []
|
8904 |
8915 |
|
8905 |
|
data = {
|
|
8916 |
return {
|
8906 |
8917 |
"iv_name": dev.iv_name,
|
8907 |
8918 |
"dev_type": dev.dev_type,
|
8908 |
8919 |
"logical_id": dev.logical_id,
|
... | ... | |
8914 |
8925 |
"size": dev.size,
|
8915 |
8926 |
}
|
8916 |
8927 |
|
8917 |
|
return data
|
8918 |
|
|
8919 |
8928 |
def Exec(self, feedback_fn):
|
8920 |
8929 |
"""Gather and return data"""
|
8921 |
8930 |
result = {}
|
... | ... | |
8943 |
8952 |
disks = [self._ComputeDiskStatus(instance, None, device)
|
8944 |
8953 |
for device in instance.disks]
|
8945 |
8954 |
|
8946 |
|
idict = {
|
|
8955 |
result[instance.name] = {
|
8947 |
8956 |
"name": instance.name,
|
8948 |
8957 |
"config_state": config_state,
|
8949 |
8958 |
"run_state": remote_state,
|
... | ... | |
8968 |
8977 |
"uuid": instance.uuid,
|
8969 |
8978 |
}
|
8970 |
8979 |
|
8971 |
|
result[instance.name] = idict
|
8972 |
|
|
8973 |
8980 |
return result
|
8974 |
8981 |
|
8975 |
8982 |
|