from ganeti import hypervisor
from ganeti import bdev
from ganeti import netutils
-from ganeti import backend
from ganeti import luxi
from ganeti import jstore
+from ganeti import pathutils
# ec_id for InitConfig's temporary reservation manager
permitted hosts and adds the hostkey to its own known hosts.
"""
- priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS)
+ priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.SSH_LOGIN_USER)
for name in priv_key, pub_key:
if os.path.exists(name):
new_confd_hmac_key, new_cds,
rapi_cert_pem=None, spice_cert_pem=None,
spice_cacert_pem=None, cds=None,
- nodecert_file=constants.NODED_CERT_FILE,
- rapicert_file=constants.RAPI_CERT_FILE,
- spicecert_file=constants.SPICE_CERT_FILE,
- spicecacert_file=constants.SPICE_CACERT_FILE,
- hmackey_file=constants.CONFD_HMAC_KEY,
- cds_file=constants.CLUSTER_DOMAIN_SECRET_FILE):
+ nodecert_file=pathutils.NODED_CERT_FILE,
+ rapicert_file=pathutils.RAPI_CERT_FILE,
+ spicecert_file=pathutils.SPICE_CERT_FILE,
+ spicecacert_file=pathutils.SPICE_CACERT_FILE,
+ hmackey_file=pathutils.CONFD_HMAC_KEY,
+ cds_file=pathutils.CLUSTER_DOMAIN_SECRET_FILE):
"""Updates the cluster certificates, keys and secrets.
@type new_cluster_cert: bool
# Generate cluster secrets
GenerateClusterCrypto(True, False, False, False, False)
- result = utils.RunCmd([constants.DAEMON_UTIL, "start", constants.NODED])
+ result = utils.RunCmd([pathutils.DAEMON_UTIL, "start", constants.NODED])
if result.failed:
raise errors.OpExecError("Could not start the node daemon, command %s"
" had exitcode %s and error %s" %
if ipcls.IsLoopback(hostname.ip):
raise errors.OpPrereqError("This host's IP (%s) resolves to a loopback"
" address. Please fix DNS or %s." %
- (hostname.ip, constants.ETC_HOSTS),
+ (hostname.ip, pathutils.ETC_HOSTS),
errors.ECODE_ENVIRON)
if not ipcls.Own(hostname.ip):
(master_netdev,
result.output.strip()), errors.ECODE_INVAL)
- dirs = [(constants.RUN_GANETI_DIR, constants.RUN_DIRS_MODE)]
+ dirs = [(pathutils.RUN_DIR, constants.RUN_DIRS_MODE)]
utils.EnsureDirs(dirs)
objects.UpgradeBeParams(beparams)
errors.ECODE_INVAL)
# set up ssh config and /etc/hosts
- sshline = utils.ReadFile(constants.SSH_HOST_RSA_PUB)
+ sshline = utils.ReadFile(pathutils.SSH_HOST_RSA_PUB)
sshkey = sshline.split(" ")[1]
if modify_etc_hosts:
)
InitConfig(constants.CONFIG_VERSION, cluster_config, master_node_config)
cfg = config.ConfigWriter(offline=True)
- ssh.WriteKnownHostsFile(cfg, constants.SSH_KNOWN_HOSTS_FILE)
+ ssh.WriteKnownHostsFile(cfg, pathutils.SSH_KNOWN_HOSTS_FILE)
cfg.Update(cfg.GetClusterInfo(), logging.error)
- backend.WriteSsconfFiles(cfg.GetSsconfValues())
+ ssconf.WriteSsconfFiles(cfg.GetSsconfValues())
# set up the inter-node password and certificate
_InitGanetiServerSetup(hostname.name)
logging.debug("Starting daemons")
- result = utils.RunCmd([constants.DAEMON_UTIL, "start-all"])
+ result = utils.RunCmd([pathutils.DAEMON_UTIL, "start-all"])
if result.failed:
raise errors.OpExecError("Could not start daemons, command %s"
" had exitcode %s and error %s" %
def InitConfig(version, cluster_config, master_node_config,
- cfg_file=constants.CLUSTER_CONF_FILE):
+ cfg_file=pathutils.CLUSTER_CONF_FILE):
"""Create the initial cluster configuration.
It will contain the current node, which will also be the master
nodegroups=nodegroups,
nodes=nodes,
instances={},
+ networks={},
serial_no=1,
ctime=now, mtime=now)
utils.WriteFile(cfg_file,
@param ssh_key_check: whether to do a strict key check
"""
- family = ssconf.SimpleStore().GetPrimaryIPFamily()
+ sstore = ssconf.SimpleStore()
+ family = sstore.GetPrimaryIPFamily()
sshrunner = ssh.SshRunner(cluster_name,
ipv6=(family == netutils.IP6Address.family))
- bind_address = constants.IP4_ADDRESS_ANY
- if family == netutils.IP6Address.family:
- bind_address = constants.IP6_ADDRESS_ANY
-
# set up inter-node password and certificate and restarts the node daemon
# and then connect with ssh to set password and start ganeti-noded
# note that all the below variables are sanitized at this point,
# either by being constants or by the checks above
- sshrunner.CopyFileToNode(node, constants.NODED_CERT_FILE)
- sshrunner.CopyFileToNode(node, constants.RAPI_CERT_FILE)
- sshrunner.CopyFileToNode(node, constants.SPICE_CERT_FILE)
- sshrunner.CopyFileToNode(node, constants.SPICE_CACERT_FILE)
- sshrunner.CopyFileToNode(node, constants.CONFD_HMAC_KEY)
- mycommand = ("%s stop-all; %s start %s -b %s" %
- (constants.DAEMON_UTIL, constants.DAEMON_UTIL, constants.NODED,
- utils.ShellQuote(bind_address)))
-
- result = sshrunner.Run(node, "root", mycommand, batch=False,
+ sshrunner.CopyFileToNode(node, pathutils.NODED_CERT_FILE)
+ sshrunner.CopyFileToNode(node, pathutils.RAPI_CERT_FILE)
+ sshrunner.CopyFileToNode(node, pathutils.SPICE_CERT_FILE)
+ sshrunner.CopyFileToNode(node, pathutils.SPICE_CACERT_FILE)
+ sshrunner.CopyFileToNode(node, pathutils.CONFD_HMAC_KEY)
+ for filename in sstore.GetFileList():
+ sshrunner.CopyFileToNode(node, filename)
+ mycommand = ("%s stop-all; %s start %s" %
+ (pathutils.DAEMON_UTIL, pathutils.DAEMON_UTIL, constants.NODED))
+
+ result = sshrunner.Run(node, constants.SSH_LOGIN_USER, mycommand, batch=False,
ask_key=ssh_key_check,
use_cluster_key=True,
strict_host_check=ssh_key_check)