From 432e8e2f3a21139d6e1bb39b4a38448e2af0f902 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 27 Jan 2012 14:29:31 +0100
Subject: [PATCH] Add new spindle_count node parameter

Currently this is not handled by Ganeti, just recorded.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/constants.py                |  3 +++
 man/ganeti.rst                  | 11 +++++++++--
 test/ganeti.config_unittest.py  |  3 ++-
 test/ganeti.objects_unittest.py | 17 +++++++++++------
 4 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/lib/constants.py b/lib/constants.py
index a89e9b60b..f88233edb 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -973,9 +973,11 @@ IPOLICY_ALL_KEYS = (IPOLICY_ISPECS |
 
 # Node parameter names
 ND_OOB_PROGRAM = "oob_program"
+ND_SPINDLE_COUNT = "spindle_count"
 
 NDS_PARAMETER_TYPES = {
   ND_OOB_PROGRAM: VTYPE_MAYBE_STRING,
+  ND_SPINDLE_COUNT: VTYPE_INT,
   }
 
 NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
@@ -1817,6 +1819,7 @@ BEC_DEFAULTS = {
 
 NDC_DEFAULTS = {
   ND_OOB_PROGRAM: None,
+  ND_SPINDLE_COUNT: 1,
   }
 
 DISK_LD_DEFAULTS = {
diff --git a/man/ganeti.rst b/man/ganeti.rst
index a16ddc591..d0b76f3b5 100644
--- a/man/ganeti.rst
+++ b/man/ganeti.rst
@@ -99,8 +99,8 @@ vm_capable
 Node Parameters
 ~~~~~~~~~~~~~~~
 
-These parameters are node specific and can be preseeded on node-group
-and cluster level.
+The ``ndparams`` refer to node parameters. These can be set as defaults
+on cluster and node group levels, but they take effect for nodes only.
 
 Currently we support the following node parameters:
 
@@ -109,6 +109,13 @@ oob_program
     the `Ganeti Node OOB Management Framework <design-oob.rst>`_ design
     document.
 
+spindle_count
+    This should reflect the I/O performance of local attached storage
+    (e.g. for "file", "plain" and "drbd" disk templates). It doesn't
+    have to match the actual spindle count of (any eventual) mechanical
+    hard-drives, its meaning is site-local and just the relative values
+    matter.
+
 
 Hypervisor State Parameters
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/test/ganeti.config_unittest.py b/test/ganeti.config_unittest.py
index 9a3e27bcc..153a2fe29 100755
--- a/test/ganeti.config_unittest.py
+++ b/test/ganeti.config_unittest.py
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 #
 
-# Copyright (C) 2006, 2007, 2010, 2011 Google Inc.
+# Copyright (C) 2006, 2007, 2010, 2011, 2012 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -200,6 +200,7 @@ class TestConfigRunner(unittest.TestCase):
   def testGetNdParamsModifiedNode(self):
     my_ndparams = {
         constants.ND_OOB_PROGRAM: "/bin/node-oob",
+        constants.ND_SPINDLE_COUNT: 1,
         }
 
     cfg = self._get_object()
diff --git a/test/ganeti.objects_unittest.py b/test/ganeti.objects_unittest.py
index 0dad3813e..95978c5ce 100755
--- a/test/ganeti.objects_unittest.py
+++ b/test/ganeti.objects_unittest.py
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 #
 
-# Copyright (C) 2006, 2007, 2008, 2010 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2010, 2012 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -78,7 +78,8 @@ class TestClusterObject(unittest.TestCase):
         },
       }
     ndparams = {
-        constants.ND_OOB_PROGRAM: "/bin/cluster-oob"
+        constants.ND_OOB_PROGRAM: "/bin/cluster-oob",
+        constants.ND_SPINDLE_COUNT: 1
         }
 
     self.fake_cl = objects.Cluster(hvparams=hvparams, os_hvp=os_hvp,
@@ -161,7 +162,8 @@ class TestClusterObject(unittest.TestCase):
                              ndparams={},
                              group="testgroup")
     group_ndparams = {
-        constants.ND_OOB_PROGRAM: "/bin/group-oob"
+        constants.ND_OOB_PROGRAM: "/bin/group-oob",
+        constants.ND_SPINDLE_COUNT: 10,
         }
     fake_group = objects.NodeGroup(name="testgroup",
                                    ndparams=group_ndparams)
@@ -170,7 +172,8 @@ class TestClusterObject(unittest.TestCase):
 
   def testFillNdParamsNode(self):
     node_ndparams = {
-        constants.ND_OOB_PROGRAM: "/bin/node-oob"
+        constants.ND_OOB_PROGRAM: "/bin/node-oob",
+        constants.ND_SPINDLE_COUNT: 2,
         }
     fake_node = objects.Node(name="test",
                              ndparams=node_ndparams,
@@ -182,13 +185,15 @@ class TestClusterObject(unittest.TestCase):
 
   def testFillNdParamsAll(self):
     node_ndparams = {
-        constants.ND_OOB_PROGRAM: "/bin/node-oob"
+        constants.ND_OOB_PROGRAM: "/bin/node-oob",
+        constants.ND_SPINDLE_COUNT: 5,
         }
     fake_node = objects.Node(name="test",
                              ndparams=node_ndparams,
                              group="testgroup")
     group_ndparams = {
-        constants.ND_OOB_PROGRAM: "/bin/group-oob"
+        constants.ND_OOB_PROGRAM: "/bin/group-oob",
+        constants.ND_SPINDLE_COUNT: 4,
         }
     fake_group = objects.NodeGroup(name="testgroup",
                                    ndparams=group_ndparams)
-- 
GitLab