Modify utils.TcpPing to make source address optional
[ganeti-local] / lib / ssconf.py
index fd41974..a860203 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#
 #
 
 # Copyright (C) 2006, 2007 Google Inc.
@@ -57,7 +57,12 @@ class SimpleStore:
   _SS_FILEPREFIX = "ssconf_"
   SS_HYPERVISOR = "hypervisor"
   SS_NODED_PASS = "node_pass"
-  _VALID_KEYS = (SS_HYPERVISOR, SS_NODED_PASS,)
+  SS_MASTER_NODE = "master_node"
+  SS_MASTER_IP = "master_ip"
+  SS_MASTER_NETDEV = "master_netdev"
+  SS_CLUSTER_NAME = "cluster_name"
+  _VALID_KEYS = (SS_HYPERVISOR, SS_NODED_PASS, SS_MASTER_NODE, SS_MASTER_IP,
+                 SS_MASTER_NETDEV, SS_CLUSTER_NAME)
   _MAX_SIZE = 4096
 
   def __init__(self, cfg_location=None):
@@ -72,8 +77,8 @@ class SimpleStore:
 
     """
     if key not in self._VALID_KEYS:
-      raise errors.ProgrammerError, ("Invalid key requested from SSConf: '%s'"
-                                     % str(key))
+      raise errors.ProgrammerError("Invalid key requested from SSConf: '%s'"
+                                   % str(key))
 
     filename = self._cfg_dir + '/' + self._SS_FILEPREFIX + key
     return filename
@@ -96,8 +101,8 @@ class SimpleStore:
       finally:
         fh.close()
     except EnvironmentError, err:
-      raise errors.ConfigurationError, ("Can't read from the ssconf file:"
-                                        " '%s'" % str(err))
+      raise errors.ConfigurationError("Can't read from the ssconf file:"
+                                      " '%s'" % str(err))
     self._cache[key] = data
     return data
 
@@ -128,6 +133,30 @@ class SimpleStore:
     """
     return self._ReadFile(self.SS_NODED_PASS)
 
+  def GetMasterNode(self):
+    """Get the hostname of the master node for this cluster.
+
+    """
+    return self._ReadFile(self.SS_MASTER_NODE)
+
+  def GetMasterIP(self):
+    """Get the IP of the master node for this cluster.
+
+    """
+    return self._ReadFile(self.SS_MASTER_IP)
+
+  def GetMasterNetdev(self):
+    """Get the netdev to which we'll add the master ip.
+
+    """
+    return self._ReadFile(self.SS_MASTER_NETDEV)
+
+  def GetClusterName(self):
+    """Get the cluster name.
+
+    """
+    return self._ReadFile(self.SS_CLUSTER_NAME)
+
   def SetKey(self, key, value):
     """Set the value of a key.