X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/a47f574c23d9148fb64baed9339b76a3a5b3b607..3eaa6e1d6e1bf3b845d66b2343253f8e170cadd2:/qa/qa_tags.py diff --git a/qa/qa_tags.py b/qa/qa_tags.py index 7cccced..7480b16 100644 --- a/qa/qa_tags.py +++ b/qa/qa_tags.py @@ -1,3 +1,6 @@ +# +# + # Copyright (C) 2007 Google Inc. # # This program is free software; you can redistribute it and/or modify @@ -20,14 +23,11 @@ """ -from ganeti import utils from ganeti import constants -import qa_config -import qa_utils import qa_rapi -from qa_utils import AssertEqual, StartSSH +from qa_utils import AssertCommand _TEMP_TAG_NAMES = ["TEMP-Ganeti-QA-Tag%d" % i for i in range(3)] @@ -37,6 +37,8 @@ _KIND_TO_COMMAND = { constants.TAG_CLUSTER: "gnt-cluster", constants.TAG_NODE: "gnt-node", constants.TAG_INSTANCE: "gnt-instance", + constants.TAG_NODEGROUP: "gnt-group", + constants.TAG_NETWORK: "gnt-network", } @@ -44,8 +46,6 @@ def _TestTags(kind, name): """Generic function for add-tags. """ - master = qa_config.GetMasterNode() - def cmdfn(subcmd): cmd = [_KIND_TO_COMMAND[kind], subcmd] @@ -54,39 +54,38 @@ def _TestTags(kind, name): return cmd - cmd = cmdfn('add-tags') + _TEMP_TAG_NAMES - AssertEqual(StartSSH(master['primary'], - utils.ShellQuoteArgs(cmd)).wait(), 0) - - cmd = cmdfn('list-tags') - AssertEqual(StartSSH(master['primary'], - utils.ShellQuoteArgs(cmd)).wait(), 0) - - cmd = ['gnt-cluster', 'search-tags', _TEMP_TAG_RE] - AssertEqual(StartSSH(master['primary'], - utils.ShellQuoteArgs(cmd)).wait(), 0) + for cmd in [ + cmdfn("add-tags") + _TEMP_TAG_NAMES, + cmdfn("list-tags"), + ["gnt-cluster", "search-tags", _TEMP_TAG_RE], + cmdfn("remove-tags") + _TEMP_TAG_NAMES, + ]: + AssertCommand(cmd) if qa_rapi.Enabled(): qa_rapi.TestTags(kind, name, _TEMP_TAG_NAMES) - cmd = cmdfn('remove-tags') + _TEMP_TAG_NAMES - AssertEqual(StartSSH(master['primary'], - utils.ShellQuoteArgs(cmd)).wait(), 0) - -@qa_utils.DefineHook('tags-cluster') def TestClusterTags(): """gnt-cluster tags""" _TestTags(constants.TAG_CLUSTER, "") -@qa_utils.DefineHook('tags-node') def TestNodeTags(node): """gnt-node tags""" - _TestTags(constants.TAG_NODE, node["primary"]) + _TestTags(constants.TAG_NODE, node.primary) + + +def TestGroupTags(group): + """gnt-group tags""" + _TestTags(constants.TAG_NODEGROUP, group) -@qa_utils.DefineHook('tags-instance') def TestInstanceTags(instance): """gnt-instance tags""" - _TestTags(constants.TAG_INSTANCE, instance["name"]) + _TestTags(constants.TAG_INSTANCE, instance.name) + + +def TestNetworkTags(network): + """gnt-network tags""" + _TestTags(constants.TAG_NETWORK, network)