IP pool related objects, opcodes and constants
[ganeti-local] / lib / bootstrap.py
index 1c6c5f6..0944fb7 100644 (file)
@@ -41,7 +41,6 @@ from ganeti import serializer
 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
@@ -61,7 +60,7 @@ def _InitSSHSetup():
   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):
@@ -330,7 +329,7 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
   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):
@@ -549,7 +548,7 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
   cfg = config.ConfigWriter(offline=True)
   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)
@@ -604,6 +603,7 @@ def InitConfig(version, cluster_config, master_node_config,
                                    nodegroups=nodegroups,
                                    nodes=nodes,
                                    instances={},
+                                   networks={},
                                    serial_no=1,
                                    ctime=now, mtime=now)
   utils.WriteFile(cfg_file,
@@ -656,14 +656,11 @@ def SetupNodeDaemon(cluster_name, node, ssh_key_check):
   @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,
@@ -673,11 +670,12 @@ def SetupNodeDaemon(cluster_name, node, ssh_key_check):
   sshrunner.CopyFileToNode(node, pathutils.SPICE_CERT_FILE)
   sshrunner.CopyFileToNode(node, pathutils.SPICE_CACERT_FILE)
   sshrunner.CopyFileToNode(node, pathutils.CONFD_HMAC_KEY)
-  mycommand = ("%s stop-all; %s start %s -b %s" %
-               (pathutils.DAEMON_UTIL, pathutils.DAEMON_UTIL, constants.NODED,
-                utils.ShellQuote(bind_address)))
+  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, "root", mycommand, batch=False,
+  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)