Modify the beparams constants
[ganeti-local] / lib / bootstrap.py
index 45cd260..580d5a0 100644 (file)
@@ -38,6 +38,7 @@ from ganeti import constants
 from ganeti import objects
 from ganeti import ssconf
 
+from ganeti.rpc import RpcRunner
 
 def _InitSSHSetup(node):
   """Setup the SSH configuration for the cluster.
@@ -127,8 +128,7 @@ def InitCluster(cluster_name, hypervisor_type, mac_prefix, def_bridge,
                                " range (%s). Please fix DNS or %s." %
                                (hostname.ip, constants.ETC_HOSTS))
 
-  if not utils.TcpPing(hostname.ip, constants.DEFAULT_NODED_PORT,
-                       source=constants.LOCALHOST_IP_ADDRESS):
+  if not utils.OwnIpAddress(hostname.ip):
     raise errors.OpPrereqError("Inconsistency: this host's name resolves"
                                " to %s,\nbut this ip address does not"
                                " belong to this host."
@@ -144,8 +144,7 @@ def InitCluster(cluster_name, hypervisor_type, mac_prefix, def_bridge,
     if not utils.IsValidIP(secondary_ip):
       raise errors.OpPrereqError("Invalid secondary ip given")
     if (secondary_ip != hostname.ip and
-        (not utils.TcpPing(secondary_ip, constants.DEFAULT_NODED_PORT,
-                           source=constants.LOCALHOST_IP_ADDRESS))):
+        not utils.OwnIpAddress(secondary_ip)):
       raise errors.OpPrereqError("You gave %s as secondary IP,"
                                  " but it does not belong to this host." %
                                  secondary_ip)
@@ -236,7 +235,7 @@ def InitCluster(cluster_name, hypervisor_type, mac_prefix, def_bridge,
 
   # start the master ip
   # TODO: Review rpc call from bootstrap
-  rpc.call_node_start_master(hostname.name, True)
+  RpcRunner.call_node_start_master(hostname.name, True)
 
 
 def InitConfig(version, cluster_config, master_node_config,
@@ -281,9 +280,9 @@ def FinalizeClusterDestroy(master):
   begun in cmdlib.LUDestroyOpcode.
 
   """
-  if not rpc.call_node_stop_master(master, True):
+  if not RpcRunner.call_node_stop_master(master, True):
     logging.warning("Could not disable the master role")
-  if not rpc.call_node_leave_cluster(master):
+  if not RpcRunner.call_node_leave_cluster(master):
     logging.warning("Could not shutdown the node daemon and cleanup the node")
 
 
@@ -365,7 +364,7 @@ def MasterFailover():
 
   logging.info("setting master to %s, old master: %s", new_master, old_master)
 
-  if not rpc.call_node_stop_master(old_master, True):
+  if not RpcRunner.call_node_stop_master(old_master, True):
     logging.error("could disable the master role on the old master"
                  " %s, please disable manually", old_master)
 
@@ -374,12 +373,12 @@ def MasterFailover():
 
   # Here we have a phase where no master should be running
 
-  if not rpc.call_upload_file(cfg.GetNodeList(),
-                              constants.CLUSTER_CONF_FILE):
+  if not RpcRunner.call_upload_file(cfg.GetNodeList(),
+                                    constants.CLUSTER_CONF_FILE):
     logging.error("could not distribute the new simple store master file"
                   " to the other nodes, please check.")
 
-  if not rpc.call_node_start_master(new_master, True):
+  if not RpcRunner.call_node_start_master(new_master, True):
     logging.error("could not start the master role on the new master"
                   " %s, please check", new_master)
     rcode = 1