Commit 62c9ec92 authored by Iustin Pop's avatar Iustin Pop
Browse files change to get cluster name from master

Currently there are three function in backend that need the cluster name
in order to instantiate an SshRunner. The patch changes these to get the
cluster name from the master in the rpc call; once the multi-hypervisor
change is implemented, then very few places in which we need the SCR
remain in the backend.

Reviewed-by: killerfoxi, imsnah
parent 3d3a04bc
......@@ -236,7 +236,8 @@ class NodeDaemonRequestHandler(http.HTTPRequestHandler):
disk = objects.Disk.FromDict(params[0])
dest_node = params[1]
instance = objects.Instance.FromDict(params[2])
return backend.ExportSnapshot(disk, dest_node, instance)
cluster_name = params[3]
return backend.ExportSnapshot(disk, dest_node, instance, cluster_name)
def perspective_finalize_export(params):
......@@ -333,10 +334,10 @@ class NodeDaemonRequestHandler(http.HTTPRequestHandler):
"""Run the import function of an OS onto a given instance.
inst_s, os_disk, swap_disk, src_node, src_image = params
inst_s, os_disk, swap_disk, src_node, src_image, cluster_name = params
inst = objects.Instance.FromDict(inst_s)
return backend.ImportOSIntoInstance(inst, os_disk, swap_disk,
src_node, src_image)
src_node, src_image, cluster_name)
def perspective_instance_shutdown(params):
......@@ -425,7 +426,7 @@ class NodeDaemonRequestHandler(http.HTTPRequestHandler):
"""Run a verify sequence on this node.
return backend.VerifyNode(params[0])
return backend.VerifyNode(params[0], params[1])
def perspective_node_start_master(params):
......@@ -48,8 +48,8 @@ def _GetConfig():
return ssconf.SimpleConfigReader()
def _GetSshRunner():
return ssh.SshRunner(_GetConfig().GetClusterName())
def _GetSshRunner(cluster_name):
return ssh.SshRunner(cluster_name)
def _CleanDirectory(path, exclude=[]):
......@@ -264,7 +264,7 @@ def GetNodeInfo(vgname):
return outputarray
def VerifyNode(what):
def VerifyNode(what, cluster_name):
"""Verify the status of the local node.
......@@ -294,7 +294,7 @@ def VerifyNode(what):
result['nodelist'] = {}
for node in what['nodelist']:
success, message = _GetSshRunner().VerifyNodeHostname(node)
success, message = _GetSshRunner(cluster_name).VerifyNodeHostname(node)
if not success:
result['nodelist'][node] = message
if 'node-net-test' in what:
......@@ -1295,7 +1295,7 @@ def SnapshotBlockDevice(disk):
(disk.unique_id, disk.dev_type))
def ExportSnapshot(disk, dest_node, instance):
def ExportSnapshot(disk, dest_node, instance, cluster_name):
"""Export a block device snapshot to a remote node.
......@@ -1336,8 +1336,9 @@ def ExportSnapshot(disk, dest_node, instance):
destcmd = utils.BuildShellCmd("mkdir -p %s && cat > %s/%s",
destdir, destdir, destfile)
remotecmd = _GetSshRunner().BuildCmd(dest_node, constants.GANETI_RUNAS,
remotecmd = _GetSshRunner(cluster_name).BuildCmd(dest_node,
# all commands have been checked, so we're safe to combine them
command = '|'.join([expcmd, comprcmd, utils.ShellQuoteArgs(remotecmd)])
......@@ -1436,7 +1437,8 @@ def ExportInfo(dest):
return config
def ImportOSIntoInstance(instance, os_disk, swap_disk, src_node, src_image):
def ImportOSIntoInstance(instance, os_disk, swap_disk, src_node, src_image,
"""Import an os image into an instance.
......@@ -1482,8 +1484,9 @@ def ImportOSIntoInstance(instance, os_disk, swap_disk, src_node, src_image):
os.mkdir(constants.LOG_OS_DIR, 0750)
destcmd = utils.BuildShellCmd('cat %s', src_image)
remotecmd = _GetSshRunner().BuildCmd(src_node, constants.GANETI_RUNAS,
remotecmd = _GetSshRunner(cluster_name).BuildCmd(src_node,
comprcmd = "gunzip"
impcmd = utils.BuildShellCmd("(cd %s; %s -i %s -b %s -s %s &>%s)",
......@@ -748,7 +748,8 @@ class LUVerifyCluster(LogicalUnit):
'node-net-test': [(, node.primary_ip, node.secondary_ip)
for node in nodeinfo]
all_nvinfo = rpc.call_node_verify(nodelist, node_verify_param)
all_nvinfo = rpc.call_node_verify(nodelist, node_verify_param,
all_rversion = rpc.call_version(nodelist)
all_ninfo = rpc.call_node_info(nodelist, self.cfg.GetVGName())
......@@ -1777,7 +1778,8 @@ class LUAddNode(LogicalUnit):
# TODO: do a node-net-test as well?
result = rpc.call_node_verify(node_verify_list, node_verify_param)
result = rpc.call_node_verify(node_verify_list, node_verify_param,
for verifier in node_verify_list:
if not result[verifier]:
raise errors.OpExecError("Cannot communicate with %s's node daemon"
......@@ -3581,8 +3583,9 @@ class LUCreateInstance(LogicalUnit):
feedback_fn("* running the instance OS import scripts...")
src_node = self.op.src_node
src_image = self.src_image
cluster_name = self.cfg.GetClusterName()
if not rpc.call_instance_os_import(pnode_name, iobj, "sda", "sdb",
src_node, src_image):
src_node, src_image, cluster_name):
raise errors.OpExecError("Could not import os for instance"
" %s on node %s" %
(instance, pnode_name))
......@@ -4830,8 +4833,10 @@ class LUExportInstance(LogicalUnit):
# TODO: check for size
cluster_name = self.cfg.GetClusterName()
for dev in snap_disks:
if not rpc.call_snapshot_export(src_node, dev,, instance):
if not rpc.call_snapshot_export(src_node, dev,,
instance, cluster_name):
logger.Error("could not export block device %s from node %s to node %s"
% (dev.logical_id[1], src_node,
if not rpc.call_blockdev_remove(src_node, dev):
......@@ -346,13 +346,13 @@ def call_node_add(node, dsa, dsapub, rsa, rsapub, ssh, sshpub):
return c.getresult().get(node, False)
def call_node_verify(node_list, checkdict):
def call_node_verify(node_list, checkdict, cluster_name):
"""Request verification of given parameters.
This is a multi-node call.
c = Client("node_verify", [checkdict])
c = Client("node_verify", [checkdict, cluster_name])
return c.getresult()
......@@ -652,13 +652,13 @@ def call_blockdev_snapshot(node, cf_bdev):
return c.getresult().get(node, False)
def call_snapshot_export(node, snap_bdev, dest_node, instance):
def call_snapshot_export(node, snap_bdev, dest_node, instance, cluster_name):
"""Request the export of a given snapshot.
This is a single-node call.
params = [snap_bdev.ToDict(), dest_node, instance.ToDict()]
params = [snap_bdev.ToDict(), dest_node, instance.ToDict(), cluster_name]
c = Client("snapshot_export", params)
......@@ -698,13 +698,14 @@ def call_export_info(node, path):
return objects.SerializableConfigParser.Loads(str(result))
def call_instance_os_import(node, inst, osdev, swapdev, src_node, src_image):
def call_instance_os_import(node, inst, osdev, swapdev,
src_node, src_image, cluster_name):
"""Request the import of a backup into an instance.
This is a single-node call.
params = [inst.ToDict(), osdev, swapdev, src_node, src_image]
params = [inst.ToDict(), osdev, swapdev, src_node, src_image, cluster_name]
c = Client("instance_os_import", params)
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