Revision b07afbb3 qa/qa_instance.py

b/qa/qa_instance.py
86 86
def _GetInstanceInfo(instance):
87 87
  """Return information about the actual state of an instance.
88 88

  
89
  The pieces of information returned are:
90
    - "nodes": instance nodes, a list of strings
91
    - "volumes": instance volume IDs, a list of strings
92
  @type instance: dictionary
93
  @param instance: the instance
94
  @return: dictionary
89
  @type instance: string
90
  @param instance: the instance name
91
  @return: a dictionary with two keys:
92
      - "nodes": instance nodes, a list of strings
93
      - "volumes": instance volume IDs, a list of strings
95 94

  
96 95
  """
97 96
  master = qa_config.GetMasterNode()
98
  infocmd = utils.ShellQuoteArgs(["gnt-instance", "info", instance["name"]])
97
  infocmd = utils.ShellQuoteArgs(["gnt-instance", "info", instance])
99 98
  info_out = qa_utils.GetCommandOutput(master["primary"], infocmd)
100 99
  re_node = re.compile(r"^\s+-\s+(?:primary|secondaries):\s+(\S.+)$")
101 100
  node_elem = r"([^,()]+)(?:\s+\([^)]+\))?"
......
134 133
  @param instance: the instance
135 134

  
136 135
  """
137
  info = _GetInstanceInfo(instance)
136
  info = _GetInstanceInfo(instance["name"])
138 137
  vols = info["volumes"]
139 138
  for node in info["nodes"]:
140 139
    AssertCommand(["lvremove", "-f"] + vols, node=node)
......
270 269
  finally:
271 270
    qa_utils.RemoveFromEtcHosts(["meeeeh-not-exists", rename_target])
272 271

  
272
  # Check instance volume tags correctly updated
273
  # FIXME: this is LVM specific!
274
  info = _GetInstanceInfo(rename_source)
275
  tags_cmd = ("lvs -o tags --noheadings %s | grep " %
276
              (" ".join(info["volumes"]), ))
277

  
273 278
  # and now rename instance to rename_target...
274 279
  AssertCommand(["gnt-instance", "rename", rename_source, rename_target])
275 280
  _CheckSsconfInstanceList(rename_target)
276 281
  qa_utils.RunInstanceCheck(rename_source, False)
277 282
  qa_utils.RunInstanceCheck(rename_target, False)
278 283

  
284
  # NOTE: tags might not be the exactly as the instance name, due to
285
  # charset restrictions; hence the test might be flaky
286
  if rename_source != rename_target:
287
    for node in info["nodes"]:
288
      AssertCommand(tags_cmd + rename_source, node=node, fail=True)
289
      AssertCommand(tags_cmd + rename_target, node=node, fail=False)
290

  
279 291
  # and back
280 292
  AssertCommand(["gnt-instance", "rename", rename_target, rename_source])
281 293
  _CheckSsconfInstanceList(rename_source)
282 294
  qa_utils.RunInstanceCheck(rename_target, False)
283 295

  
296
  if rename_source != rename_target:
297
    for node in info["nodes"]:
298
      AssertCommand(tags_cmd + rename_source, node=node, fail=False)
299
      AssertCommand(tags_cmd + rename_target, node=node, fail=True)
300

  
284 301

  
285 302
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
286 303
def TestInstanceFailover(instance):

Also available in: Unified diff