4 # Copyright (C) 2013 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 """QA tests for networks.
29 from qa_utils import AssertCommand
32 def GetNonexistentNetworks(count):
33 """Gets network names which shouldn't exist on the cluster.
35 @param count: Number of networks to get
39 return qa_utils.GetNonexistentEntityNames(count, "networks", "network")
42 def TestNetworkAddRemove():
43 """gnt-network add/remove"""
44 (network1, network2) = GetNonexistentNetworks(2)
46 # Add some networks of different sizes.
47 # Note: Using RFC5737 addresses.
48 AssertCommand(["gnt-network", "add", "--network", "192.0.2.0/30", network1])
49 AssertCommand(["gnt-network", "add", "--network", "198.51.100.0/24",
51 # Try to add a network with an existing name.
52 AssertCommand(["gnt-network", "add", "--network", "203.0.133.0/24", network2],
55 AssertCommand(["gnt-network", "remove", network1])
56 AssertCommand(["gnt-network", "remove", network2])
59 def TestNetworkConnect():
60 """gnt-network connect/disconnect"""
61 (group1, ) = qa_utils.GetNonexistentGroups(1)
62 (network1, ) = GetNonexistentNetworks(1)
64 default_mode = "bridged"
65 default_link = "xen-br0"
66 nicparams = qa_config.get("default-nicparams")
68 mode = nicparams.get("mode", default_mode)
69 link = nicparams.get("link", default_link)
74 AssertCommand(["gnt-group", "add", group1])
75 AssertCommand(["gnt-network", "add", "--network", "192.0.2.0/24", network1])
77 AssertCommand(["gnt-network", "connect", network1, mode, link, group1])
78 AssertCommand(["gnt-network", "disconnect", network1, group1])
80 AssertCommand(["gnt-group", "remove", group1])
81 AssertCommand(["gnt-network", "remove", network1])