diff --git a/lib/config.py b/lib/config.py index 5315c5bd16df631cfc1ce2681d069e25b3f86c10..4031373630231a0193c4f34c8b4a5a8c10f640a2 100644 --- a/lib/config.py +++ b/lib/config.py @@ -471,6 +471,69 @@ class ConfigWriter: if name == instance: del self._temporary_drbds[key] + @locking.ssynchronized(_config_lock, shared=1) + def GetConfigVersion(self): + """Get the configuration version. + + @return: Config version + + """ + return self._config_data.version + + @locking.ssynchronized(_config_lock, shared=1) + def GetClusterName(self): + """Get cluster name. + + @return: Cluster name + + """ + self._OpenConfig() + return self._config_data.cluster.cluster_name + + @locking.ssynchronized(_config_lock, shared=1) + def GetMasterNode(self): + """Get the hostname of the master node for this cluster. + + @return: Master hostname + + """ + self._OpenConfig() + return self._config_data.cluster.master_node + + @locking.ssynchronized(_config_lock, shared=1) + def GetMasterIP(self): + """Get the IP of the master node for this cluster. + + @return: Master IP + + """ + self._OpenConfig() + return self._config_data.cluster.master_ip + + @locking.ssynchronized(_config_lock, shared=1) + def GetMasterNetdev(self): + """Get the master network device for this cluster. + + """ + self._OpenConfig() + return self._config_data.cluster.master_netdev + + @locking.ssynchronized(_config_lock, shared=1) + def GetFileStorageDir(self): + """Get the file storage dir for this cluster. + + """ + self._OpenConfig() + return self._config_data.cluster.file_storage_dir + + @locking.ssynchronized(_config_lock, shared=1) + def GetHypervisorType(self): + """Get the hypervisor type for this cluster. + + """ + self._OpenConfig() + return self._config_data.cluster.hypervisor + @locking.ssynchronized(_config_lock, shared=1) def GetHostKey(self): """Return the rsa hostkey from the config. diff --git a/lib/constants.py b/lib/constants.py index c5bf7d6bbf01b7f1bda94e2bca55c56f49fbac75..424fbb5b065ec9135b7f8b10fa8b781fcce633e1 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -92,6 +92,7 @@ CLUSTER_CONF_FILE = DATA_DIR + "/config.data" SSL_CERT_FILE = DATA_DIR + "/server.pem" WATCHER_STATEFILE = DATA_DIR + "/watcher.data" SSH_KNOWN_HOSTS_FILE = DATA_DIR + "/known_hosts" +CLUSTER_PASSWORD_FILE = DATA_DIR + "/ssconf_node_pass" QUEUE_DIR = DATA_DIR + "/queue" ETC_HOSTS = "/etc/hosts" DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR diff --git a/lib/utils.py b/lib/utils.py index d73ee36a09cd2b00d4d327de9d2106d6fa166f2b..f389bee57c287fa8f683bed499b68333ff5ecaac 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -1231,6 +1231,29 @@ def MergeTime(timetuple): return float(seconds) + (float(microseconds) * 0.000001) +def GetNodeDaemonPort(): + """Get the node daemon port for this cluster. + + Note that this routine does not read a ganeti-specific file, but + instead uses socket.getservbyname to allow pre-customization of + this parameter outside of Ganeti. + + """ + try: + port = socket.getservbyname("ganeti-noded", "tcp") + except socket.error: + port = constants.DEFAULT_NODED_PORT + + return port + + +def GetNodeDaemonPassword(): + """Get the node password for the cluster. + + """ + return ReadFile(constants.CLUSTER_PASSWORD_FILE) + + def LockedMethod(fn): """Synchronized object access decorator.