From 8a147bba1bad0e82416ab9d5cf81b9173fed8ac8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ren=C3=A9=20Nussbaumer?= Date: Fri, 30 Mar 2012 14:58:52 +0200 Subject: [PATCH 1/1] config: Adding convenience method for disk parameters MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: René Nussbaumer Reviewed-by: Iustin Pop --- lib/config.py | 13 +++++++++++++ lib/objects.py | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/config.py b/lib/config.py index c0711a1..3e0b471 100644 --- a/lib/config.py +++ b/lib/config.py @@ -232,6 +232,19 @@ class ConfigWriter: return self._config_data.cluster.FillND(node, nodegroup) @locking.ssynchronized(_config_lock, shared=1) + def GetInstanceDiskParams(self, instance): + """Get the disk params populated with inherit chain. + + @type instance: L{objects.Instance} + @param instance: The instance we want to know the params for + @return: A dict with the filled in disk params + + """ + node = self._UnlockedGetNodeInfo(instance.primary_node) + nodegroup = self._UnlockedGetNodeGroup(node.group) + return self._config_data.cluster.SimpleFillDP(nodegroup.diskparams) + + @locking.ssynchronized(_config_lock, shared=1) def GenerateMAC(self, ec_id): """Generate a MAC for an instance. diff --git a/lib/objects.py b/lib/objects.py index 77b2b99..b9ecc31 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -1610,6 +1610,15 @@ class Cluster(TaggableObject): obj.tcpudp_port_pool = set(obj.tcpudp_port_pool) return obj + def SimpleFillDP(self, diskparams): + """Fill a given diskparams dict with cluster defaults. + + @param diskparams: The diskparams + @return: The defaults dict + + """ + return FillDiskParams(self.diskparams, diskparams) + def GetHVDefaults(self, hypervisor, os_name=None, skip_keys=None): """Get the default hypervisor parameters for the cluster. -- 1.7.10.4