Revision def6577f lib/config.py
b/lib/config.py | ||
---|---|---|
1805 | 1805 |
for node_name in nodes_fn(inst) |
1806 | 1806 |
if self._UnlockedGetNodeInfo(node_name).group == uuid) |
1807 | 1807 |
|
1808 |
def _UnlockedGetHvparamsString(self, hvname): |
|
1809 |
"""Return the string representation of the list of hyervisor parameters of |
|
1810 |
the given hypervisor. |
|
1811 |
|
|
1812 |
@see: C{GetHvparams} |
|
1813 |
|
|
1814 |
""" |
|
1815 |
result = "" |
|
1816 |
hvparams = self._config_data.cluster.hvparams[hvname] |
|
1817 |
for key in hvparams: |
|
1818 |
result += "%s=%s\n" % (key, hvparams[key]) |
|
1819 |
return result |
|
1820 |
|
|
1821 |
@locking.ssynchronized(_config_lock, shared=1) |
|
1822 |
def GetHvparamsString(self, hvname): |
|
1823 |
"""Return the hypervisor parameters of the given hypervisor. |
|
1824 |
|
|
1825 |
@type hvname: string |
|
1826 |
@param hvname: name of a hypervisor |
|
1827 |
@rtype: string |
|
1828 |
@return: string containing key-value-pairs, one pair on each line; |
|
1829 |
format: KEY=VALUE |
|
1830 |
|
|
1831 |
""" |
|
1832 |
return self._UnlockedGetHvparamsString(hvname) |
|
1833 |
|
|
1808 | 1834 |
def _UnlockedGetNodeList(self): |
1809 | 1835 |
"""Return the list of nodes which are in the configuration. |
1810 | 1836 |
|
... | ... | |
2282 | 2308 |
|
2283 | 2309 |
self._last_cluster_serial = self._config_data.cluster.serial_no |
2284 | 2310 |
|
2311 |
def _GetAllHvparamsStrings(self, hypervisors): |
|
2312 |
"""Get the hvparams of all given hypervisors from the config. |
|
2313 |
|
|
2314 |
@type hypervisors: list of string |
|
2315 |
@param hypervisors: list of hypervisor names |
|
2316 |
@rtype: dict of strings |
|
2317 |
@returns: dictionary mapping the hypervisor name to a string representation |
|
2318 |
of the hypervisor's hvparams |
|
2319 |
|
|
2320 |
""" |
|
2321 |
hvparams = {} |
|
2322 |
for hv in hypervisors: |
|
2323 |
hvparams[hv] = self._UnlockedGetHvparamsString(hv) |
|
2324 |
return hvparams |
|
2325 |
|
|
2326 |
@staticmethod |
|
2327 |
def _ExtendByAllHvparamsStrings(ssconf_values, all_hvparams): |
|
2328 |
"""Extends the ssconf_values dictionary by hvparams. |
|
2329 |
|
|
2330 |
@type ssconf_values: dict of strings |
|
2331 |
@param ssconf_values: dictionary mapping ssconf_keys to strings |
|
2332 |
representing the content of ssconf files |
|
2333 |
@type all_hvparams: dict of strings |
|
2334 |
@param all_hvparams: dictionary mapping hypervisor names to a string |
|
2335 |
representation of their hvparams |
|
2336 |
@rtype: same as ssconf_values |
|
2337 |
@returns: the ssconf_values dictionary extended by hvparams |
|
2338 |
|
|
2339 |
""" |
|
2340 |
for hv in all_hvparams: |
|
2341 |
ssconf_key = constants.SS_HVPARAMS_PREF + hv |
|
2342 |
ssconf_values[ssconf_key] = all_hvparams[hv] |
|
2343 |
return ssconf_values |
|
2344 |
|
|
2285 | 2345 |
def _UnlockedGetSsconfValues(self): |
2286 | 2346 |
"""Return the values needed by ssconf. |
2287 | 2347 |
|
... | ... | |
2313 | 2373 |
cluster_tags = fn(cluster.GetTags()) |
2314 | 2374 |
|
2315 | 2375 |
hypervisor_list = fn(cluster.enabled_hypervisors) |
2376 |
all_hvparams = self._GetAllHvparamsStrings(constants.HYPER_TYPES) |
|
2316 | 2377 |
|
2317 | 2378 |
uid_pool = uidpool.FormatUidPool(cluster.uid_pool, separator="\n") |
2318 | 2379 |
|
... | ... | |
2348 | 2409 |
constants.SS_NODEGROUPS: nodegroups_data, |
2349 | 2410 |
constants.SS_NETWORKS: networks_data, |
2350 | 2411 |
} |
2412 |
ssconf_values = self._ExtendByAllHvparamsStrings(ssconf_values, |
|
2413 |
all_hvparams) |
|
2351 | 2414 |
bad_values = [(k, v) for k, v in ssconf_values.items() |
2352 | 2415 |
if not isinstance(v, (str, basestring))] |
2353 | 2416 |
if bad_values: |
Also available in: Unified diff