Commit 4a8b186a authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Move functions from ssconf.py elsewhere

These functions will be used to access config values instead of using
ssconf.

Reviewed-by: iustinp
parent 856c67e1
......@@ -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.
......
......@@ -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
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment