+SSCONF_LOCK_TIMEOUT = 10
+
+RE_VALID_SSCONF_NAME = re.compile(r'^[-_a-z0-9]+$')
+
+
+class SimpleConfigReader(object):
+ """Simple class to read configuration file.
+
+ """
+ def __init__(self, file_name=constants.CLUSTER_CONF_FILE):
+ """Initializes this class.
+
+ @type file_name: string
+ @param file_name: Configuration file path
+
+ """
+ self._file_name = file_name
+ self._config_data = serializer.Load(utils.ReadFile(file_name))
+ # TODO: Error handling
+
+ def GetClusterName(self):
+ return self._config_data["cluster"]["cluster_name"]
+
+ def GetHostKey(self):
+ return self._config_data["cluster"]["rsahostkeypub"]
+
+ def GetMasterNode(self):
+ return self._config_data["cluster"]["master_node"]
+
+ def GetMasterIP(self):
+ return self._config_data["cluster"]["master_ip"]
+
+ def GetMasterNetdev(self):
+ return self._config_data["cluster"]["master_netdev"]
+
+ def GetFileStorageDir(self):
+ return self._config_data["cluster"]["file_storage_dir"]
+
+ def GetHypervisorType(self):
+ return self._config_data["cluster"]["hypervisor"]
+
+ def GetNodeList(self):
+ return self._config_data["nodes"].keys()
+
+ @classmethod
+ def FromDict(cls, val, cfg_file=constants.CLUSTER_CONF_FILE):
+ """Alternative construction from a dictionary.
+
+ """
+ obj = SimpleConfigReader.__new__(cls)
+ obj._config_data = val
+ obj._file_name = cfg_file
+ return obj
+
+
+class SimpleConfigWriter(SimpleConfigReader):
+ """Simple class to write configuration file.
+
+ """
+ def SetMasterNode(self, node):
+ """Change master node.
+
+ """
+ self._config_data["cluster"]["master_node"] = node
+
+ def Save(self):
+ """Writes configuration file.
+
+ Warning: Doesn't take care of locking or synchronizing with other
+ processes.
+
+ """
+ utils.WriteFile(self._file_name,
+ data=serializer.Dump(self._config_data),
+ mode=0600)
+
+
+class SimpleStore(object):