Revision 5d640672 qa/qa_daemon.py

b/qa/qa_daemon.py
21 21
"""
22 22

  
23 23
import time
24
import subprocess
25 24

  
26 25
from ganeti import utils
27 26
from ganeti import constants
......
33 32
from qa_utils import AssertEqual, StartSSH
34 33

  
35 34

  
36
def _ResolveInstanceName(instance):
37
  """Gets the full Xen name of an instance.
38

  
39
  """
40
  master = qa_config.GetMasterNode()
41

  
42
  info_cmd = utils.ShellQuoteArgs(['gnt-instance', 'info', instance['name']])
43
  sed_cmd = utils.ShellQuoteArgs(['sed', '-n', '-e', 's/^Instance name: *//p'])
44

  
45
  cmd = '%s | %s' % (info_cmd, sed_cmd)
46
  ssh_cmd = qa_utils.GetSSHCommand(master['primary'], cmd)
47
  p = subprocess.Popen(ssh_cmd, shell=False, stdout=subprocess.PIPE)
48
  AssertEqual(p.wait(), 0)
49

  
50
  return p.stdout.read().strip()
51

  
52

  
53 35
def _InstanceRunning(node, name):
54 36
  """Checks whether an instance is running.
55 37

  
......
72 54
  master = qa_config.GetMasterNode()
73 55

  
74 56
  cmd = ['xm', 'shutdown', name]
75
  AssertEqual(StartSSH(master['primary'],
57
  AssertEqual(StartSSH(node['primary'],
76 58
                       utils.ShellQuoteArgs(cmd)).wait(), 0)
77 59

  
78 60
  # Wait up to a minute
......
102 84
  Note: takes up to 6 minutes to complete.
103 85
  """
104 86
  master = qa_config.GetMasterNode()
105
  inst_name = _ResolveInstanceName(instance)
87
  inst_name = qa_utils.ResolveInstanceName(instance)
106 88

  
107 89
  _ResetWatcherDaemon(node)
108 90
  _XmShutdownInstance(node, inst_name)
......
129 111
  Note: takes at least 35 minutes to complete.
130 112
  """
131 113
  master = qa_config.GetMasterNode()
132
  inst_name = _ResolveInstanceName(instance)
114
  inst_name = qa_utils.ResolveInstanceName(instance)
133 115

  
134 116
  _ResetWatcherDaemon(node)
135 117
  _XmShutdownInstance(node, inst_name)

Also available in: Unified diff