The 'Cluster.install_image' param holds the location of the image to
be used for the safe installation instances.

Signed-off-by: Jose A. Lopes <[email protected]>
---
 lib/client/gnt_cluster.py      |  1 +
 lib/config.py                  | 20 ++++++++++++++++++++
 lib/objects.py                 |  4 ++++
 src/Ganeti/Objects.hs          |  1 +
 src/Ganeti/Query/Server.hs     |  1 +
 test/hs/Test/Ganeti/OpCodes.hs |  1 +
 test/py/cfgupgrade_unittest.py |  1 +
 tools/cfgupgrade               |  5 +++++
 8 files changed, 34 insertions(+)

diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py
index f6e38f0..ceb56cf 100644
--- a/lib/client/gnt_cluster.py
+++ b/lib/client/gnt_cluster.py
@@ -552,6 +552,7 @@ def ShowClusterConfig(opts, args):
        utils.CommaJoin(pathutils.ES_SEARCH_PATH)),
       ("enabled disk templates",
        utils.CommaJoin(result["enabled_disk_templates"])),
+      ("install image", result["install_image"]),
       ("instance communication network",
        result["instance_communication_network"]),
       ("zeroing image", result["zeroing_image"]),
diff --git a/lib/config.py b/lib/config.py
index 83cf872..a88ca1c 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -1653,6 +1653,26 @@ class ConfigWriter(object):
     return result
 
   @_ConfigSync(shared=1)
+  def GetInstallImage(self):
+    """Get the install image location
+
+    @rtype: string
+    @return: location of the install image
+
+    """
+    return self._ConfigData().cluster.install_image
+
+  @_ConfigSync()
+  def SetInstallImage(self, install_image):
+    """Set the install image location
+
+    @type install_image: string
+    @param install_image: location of the install image
+
+    """
+    self._ConfigData().cluster.install_image = install_image
+
+  @_ConfigSync(shared=1)
   def GetInstanceCommunicationNetwork(self):
     """Get cluster instance communication network
 
diff --git a/lib/objects.py b/lib/objects.py
index 57fa988..4584517 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -1588,6 +1588,7 @@ class Cluster(TaggableObject):
     "enabled_disk_templates",
     "candidate_certs",
     "max_running_jobs",
+    "install_image",
     "instance_communication_network",
     "zeroing_image"
     ] + _TIMESTAMPS + _UUID
@@ -1727,6 +1728,9 @@ class Cluster(TaggableObject):
     if self.instance_communication_network is None:
       self.instance_communication_network = ""
 
+    if self.install_image is None:
+      self.install_image = ""
+
   @property
   def primary_hypervisor(self):
     """The first hypervisor is the primary.
diff --git a/src/Ganeti/Objects.hs b/src/Ganeti/Objects.hs
index c022d15..9e3df1e 100644
--- a/src/Ganeti/Objects.hs
+++ b/src/Ganeti/Objects.hs
@@ -718,6 +718,7 @@ $(buildObject "Cluster" "cluster" $
   , simpleField "enabled_disk_templates"         [t| [DiskTemplate]         |]
   , simpleField "candidate_certs"                [t| CandidateCertificates  |]
   , simpleField "max_running_jobs"               [t| Int                    |]
+  , simpleField "install_image"                  [t| String                 |]
   , simpleField "instance_communication_network" [t| String                 |]
   , simpleField "zeroing_image"                  [t| String                 |]
  ]
diff --git a/src/Ganeti/Query/Server.hs b/src/Ganeti/Query/Server.hs
index b1e470a..922c16e 100644
--- a/src/Ganeti/Query/Server.hs
+++ b/src/Ganeti/Query/Server.hs
@@ -170,6 +170,7 @@ handleCall _ _ cdata QueryClusterInfo =
             , ("hidden_os", showJSON $ clusterHiddenOs cluster)
             , ("blacklisted_os", showJSON $ clusterBlacklistedOs cluster)
             , ("enabled_disk_templates", showJSON diskTemplates)
+            , ("install_image", showJSON $ clusterInstallImage cluster)
             , ("instance_communication_network",
                showJSON (clusterInstanceCommunicationNetwork cluster))
             , ("zeroing_image", showJSON $ clusterZeroingImage cluster)
diff --git a/test/hs/Test/Ganeti/OpCodes.hs b/test/hs/Test/Ganeti/OpCodes.hs
index da791ad..cf8b2df 100644
--- a/test/hs/Test/Ganeti/OpCodes.hs
+++ b/test/hs/Test/Ganeti/OpCodes.hs
@@ -208,6 +208,7 @@ instance Arbitrary OpCodes.OpCode where
           <*> genMaybe genName             -- file_storage_dir
           <*> genMaybe genName             -- shared_file_storage_dir
           <*> genMaybe genName             -- gluster_file_storage_dir
+          <*> arbitrary                    -- install_image
           <*> arbitrary                    -- instance_communication_network
           <*> arbitrary                    -- zeroing_image
       "OP_CLUSTER_REDIST_CONF" -> pure OpCodes.OpClusterRedistConf
diff --git a/test/py/cfgupgrade_unittest.py b/test/py/cfgupgrade_unittest.py
index 1b48d2b..d6dfb12 100755
--- a/test/py/cfgupgrade_unittest.py
+++ b/test/py/cfgupgrade_unittest.py
@@ -48,6 +48,7 @@ def GetMinimalConfig():
       "default_iallocator_params": {},
       "ndparams": {},
       "candidate_certs": {},
+      "install_image": "",
       "instance_communication_network": "",
       "zeroing_image": "",
     },
diff --git a/tools/cfgupgrade b/tools/cfgupgrade
index 9c3574d..7d78ab9 100755
--- a/tools/cfgupgrade
+++ b/tools/cfgupgrade
@@ -154,6 +154,8 @@ def UpgradeCluster(config_data):
     cluster["candidate_certs"] = {}
   cluster["instance_communication_network"] = \
     cluster.get("instance_communication_network", "")
+  cluster["install_image"] = \
+    cluster.get("install_image", "")
   cluster["zeroing_image"] = \
     cluster.get("zeroing_image", "")
 
@@ -452,6 +454,9 @@ def DowngradeCluster(config_data):
   if "instance_communication_network" in cluster:
     del cluster["instance_communication_network"]
 
+  if "install_image" in cluster:
+    del cluster["install_image"]
+
   if "zeroing_image" in cluster:
     del cluster["zeroing_image"]
 
-- 
1.9.1.423.g4596e3a

Reply via email to