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

QA: Add configuration options for static MAC address



In some QA environments static MAC addresses must be used.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent c1513c7f
......@@ -45,10 +45,16 @@
"instances": [
{
"name": "xen-test-inst1"
"name": "xen-test-inst1",
"# Static MAC address": null,
"#nic.mac/0": "AA:00:00:11:11:11"
},
{
"name": "xen-test-inst2"
"name": "xen-test-inst2",
"# Static MAC address": null,
"#nic.mac/0": "AA:00:00:22:22:22"
}
],
......
#
#
# Copyright (C) 2007, 2011 Google Inc.
# Copyright (C) 2007, 2011, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -154,6 +154,13 @@ def GetInstanceCheckScript():
return cfg.get(_INSTANCE_CHECK_KEY, None)
def GetInstanceNicMac(inst, default=None):
"""Returns MAC address for instance's network interface.
"""
return inst.get("nic.mac/0", default)
def GetMasterNode():
return cfg["nodes"][0]
......
......@@ -42,7 +42,7 @@ def _GetDiskStatePath(disk):
return "/sys/block/%s/device/state" % disk
def _GetGenericAddParameters():
def _GetGenericAddParameters(inst):
params = ["-B"]
params.append("%s=%s,%s=%s" % (constants.BE_MINMEM,
qa_config.get(constants.BE_MINMEM),
......@@ -50,6 +50,12 @@ def _GetGenericAddParameters():
qa_config.get(constants.BE_MAXMEM)))
for idx, size in enumerate(qa_config.get("disk")):
params.extend(["--disk", "%s:size=%s" % (idx, size)])
# Set static MAC address if configured
nic0_mac = qa_config.GetInstanceNicMac(inst)
if nic0_mac:
params.extend(["--net", "0:mac=%s" % nic0_mac])
return params
......@@ -60,7 +66,7 @@ def _DiskTest(node, disk_template):
"--os-type=%s" % qa_config.get("os"),
"--disk-template=%s" % disk_template,
"--node=%s" % node] +
_GetGenericAddParameters())
_GetGenericAddParameters(instance))
cmd.append(instance["name"])
AssertCommand(cmd)
......@@ -412,11 +418,10 @@ def TestInstanceImport(newinst, node, expnode, name):
cmd = (["gnt-backup", "import",
"--disk-template=plain",
"--no-ip-check",
"--net", "0:mac=generate",
"--src-node=%s" % expnode["primary"],
"--src-dir=%s/%s" % (constants.EXPORT_DIR, name),
"--node=%s" % node["primary"]] +
_GetGenericAddParameters())
_GetGenericAddParameters(newinst))
cmd.append(newinst["name"])
AssertCommand(cmd)
......
......@@ -553,7 +553,11 @@ def TestRapiInstanceAdd(node, use_client):
try:
disk_sizes = [utils.ParseUnit(size) for size in qa_config.get("disk")]
disks = [{"size": size} for size in disk_sizes]
nics = [{}]
nic0_mac = qa_config.GetInstanceNicMac(instance,
default=constants.VALUE_GENERATE)
nics = [{
constants.INIC_MAC: nic0_mac,
}]
beparams = {
constants.BE_MAXMEM: utils.ParseUnit(qa_config.get(constants.BE_MAXMEM)),
......
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