Commit bc696589 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

gnt-backup: Don't show confusing message w/o target node



“gnt-backup export” requires the target node. Until now, the master
daemon would complain that the “parameter
'OP_BACKUP_EXPORT.target_node' fails validation”. With this patch,
an additional check is done in the client program.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarManuel Franceschini <livewire@google.com>
parent 85b3901b
...@@ -204,6 +204,8 @@ def RunExportImportTests(instance, pnode): ...@@ -204,6 +204,8 @@ def RunExportImportTests(instance, pnode):
""" """
if qa_config.TestEnabled('instance-export'): if qa_config.TestEnabled('instance-export'):
RunTest(qa_instance.TestInstanceExportNoTarget, instance)
expnode = qa_config.AcquireNode(exclude=pnode) expnode = qa_config.AcquireNode(exclude=pnode)
try: try:
name = RunTest(qa_instance.TestInstanceExport, instance, expnode) name = RunTest(qa_instance.TestInstanceExport, instance, expnode)
......
...@@ -280,7 +280,7 @@ def TestReplaceDisks(instance, pnode, snode, othernode): ...@@ -280,7 +280,7 @@ def TestReplaceDisks(instance, pnode, snode, othernode):
def TestInstanceExport(instance, node): def TestInstanceExport(instance, node):
"""gnt-backup export""" """gnt-backup export -n ..."""
master = qa_config.GetMasterNode() master = qa_config.GetMasterNode()
cmd = ['gnt-backup', 'export', '-n', node['primary'], instance['name']] cmd = ['gnt-backup', 'export', '-n', node['primary'], instance['name']]
...@@ -300,6 +300,15 @@ def TestInstanceExportWithRemove(instance, node): ...@@ -300,6 +300,15 @@ def TestInstanceExportWithRemove(instance, node):
utils.ShellQuoteArgs(cmd)).wait(), 0) utils.ShellQuoteArgs(cmd)).wait(), 0)
def TestInstanceExportNoTarget(instance):
"""gnt-backup export (without target node, should fail)"""
master = qa_config.GetMasterNode()
cmd = ["gnt-backup", "export", instance["name"]]
AssertNotEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
def TestInstanceImport(node, newinst, expnode, name): def TestInstanceImport(node, newinst, expnode, name):
"""gnt-backup import""" """gnt-backup import"""
master = qa_config.GetMasterNode() master = qa_config.GetMasterNode()
......
...@@ -31,6 +31,7 @@ import sys ...@@ -31,6 +31,7 @@ import sys
from ganeti.cli import * from ganeti.cli import *
from ganeti import opcodes from ganeti import opcodes
from ganeti import constants from ganeti import constants
from ganeti import errors
_VALUE_TRUE = "true" _VALUE_TRUE = "true"
...@@ -73,6 +74,9 @@ def ExportInstance(opts, args): ...@@ -73,6 +74,9 @@ def ExportInstance(opts, args):
""" """
ignore_remove_failures = opts.ignore_remove_failures ignore_remove_failures = opts.ignore_remove_failures
if not opts.node:
raise errors.OpPrereqError("Target node must be specified")
op = opcodes.OpExportInstance(instance_name=args[0], op = opcodes.OpExportInstance(instance_name=args[0],
target_node=opts.node, target_node=opts.node,
shutdown=opts.shutdown, shutdown=opts.shutdown,
......
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