Update GrowDisk docstring
[ganeti-local] / lib / ssconf.py
index c1ef096..babd148 100644 (file)
@@ -152,6 +152,9 @@ class SimpleConfigReader(object):
   def GetMasterNetdev(self):
     return self._config_data["cluster"]["master_netdev"]
 
+  def GetMasterNetmask(self):
+    return self._config_data["cluster"]["master_netmask"]
+
   def GetFileStorageDir(self):
     return self._config_data["cluster"]["file_storage_dir"]
 
@@ -280,6 +283,7 @@ class SimpleStore(object):
     constants.SS_MASTER_CANDIDATES_IPS,
     constants.SS_MASTER_IP,
     constants.SS_MASTER_NETDEV,
+    constants.SS_MASTER_NETMASK,
     constants.SS_MASTER_NODE,
     constants.SS_NODE_LIST,
     constants.SS_NODE_PRIMARY_IPS,
@@ -349,7 +353,8 @@ class SimpleStore(object):
         if len(value) > self._MAX_SIZE:
           raise errors.ConfigurationError("ssconf file %s above maximum size" %
                                           name)
-        utils.WriteFile(self.KeyToFilename(name), data=value, mode=0444)
+        utils.WriteFile(self.KeyToFilename(name), data=value,
+                        mode=constants.SS_FILE_PERMS)
     finally:
       ssconf_lock.Unlock()
 
@@ -407,6 +412,17 @@ class SimpleStore(object):
     """
     return self._ReadFile(constants.SS_MASTER_NETDEV)
 
+  def GetMasterNetmask(self):
+    """Get the master netmask.
+
+    """
+    try:
+      return self._ReadFile(constants.SS_MASTER_NETMASK)
+    except errors.ConfigurationError:
+      family = self.GetPrimaryIPFamily()
+      ipcls = netutils.IPAddress.GetClassFromIpFamily(family)
+      return ipcls.iplen
+
   def GetMasterNode(self):
     """Get the hostname of the master node for this cluster.