Files
fuel-qa/fuelweb_test/helpers/multiple_networks_hacks.py
Maksim Strukov 51e0a0573c Deploy multirack environment with shared networks
Refactor tests for multiple cluster networks feature so
all tests use fuel-devops environment which has 3 nodegroups,
shared L2 network and it's defined using template. Also allow
tests to configure networks for more than 1 custom nodegroup.
Add additional check for shared storage network (Ceph health).
Create new test case for adding new nodegroup to operational
environment.

Co-Authored-By: Artem Panchenko <apanchenko@mirantis.com>

Closes-Bug: #1521316
Implements blueprint test-nodegroup-add
Implements blueprint test-nodegroups-share-networks
Change-Id: I066248a7b96a6f16b1e24763892234fe48803983
(cherry picked from commit 41405c6415)
2016-01-18 11:37:36 +00:00

88 lines
3.6 KiB
Python

# Copyright 2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# TODO(apanchenko): This file contains hacks (e.g. configuring of dhcp-server
# or firewall on master node) which are used for testing multiple cluster
# networks feature:
# https://blueprints.launchpad.net/fuel/+spec/multiple-cluster-networks
# This code should be removed from tests as soon as automatic cobbler
# configuring for non-default admin (PXE) networks is implemented in Fuel
from proboscis.asserts import assert_equal
from fuelweb_test import logwrap
from fuelweb_test.helpers.ssh_manager import SSHManager
@logwrap
def configure_second_admin_dhcp(ip, interface):
dhcp_conf_file = '/etc/cobbler/dnsmasq.template'
docker_start_file = '/usr/local/bin/start.sh'
cmd = ("dockerctl shell cobbler sed "
"'0,/^interface.*/s//\\0\\ninterface={0}/' -i {1};"
"dockerctl shell cobbler sed \"/^puppet apply/a "
"sed '/^interface/a interface={0}' -i {1}\" -i {2};"
"dockerctl shell cobbler cobbler sync").format(interface,
dhcp_conf_file,
docker_start_file)
result = SSHManager().execute(
ip=ip,
cmd=cmd
)
assert_equal(result['exit_code'], 0, ('Failed to add second admin '
'network to DHCP server: {0}').format(result))
@logwrap
def configure_second_admin_firewall(ip, network, netmask, interface,
master_ip):
# Allow input/forwarding for nodes from the second admin network and
# enable source NAT for UDP (tftp) and HTTP (proxy server) traffic
# on master node
rules = [
('-I INPUT -i {0} -m comment --comment "input from admin network" '
'-j ACCEPT').format(interface),
('-t nat -I POSTROUTING -s {0}/{1} -o e+ -m comment --comment '
'"004 forward_admin_net2" -j MASQUERADE').
format(network, netmask),
("-t nat -I POSTROUTING -o {0} -d {1}/{2} -p udp -m addrtype "
"--src-type LOCAL -j SNAT --to-source {3}").format(interface,
network, netmask,
master_ip),
("-t nat -I POSTROUTING -d {0}/{1} -p tcp --dport 8888 -j SNAT "
"--to-source {2}").format(network, netmask, master_ip),
('-I FORWARD -i {0} -m comment --comment '
'"forward custom admin net" -j ACCEPT').format(interface)
]
for rule in rules:
cmd = 'iptables {0}'.format(rule)
result = SSHManager().execute(
ip=ip,
cmd=cmd
)
assert_equal(result['exit_code'], 0,
('Failed to add firewall rule for admin net on'
' master node: {0}, {1}').format(rule, result))
# Save new firewall configuration
cmd = 'service iptables save'
result = SSHManager().execute(
ip=ip,
cmd=cmd
)
assert_equal(result['exit_code'], 0,
('Failed to save firewall configuration on master node:'
' {0}').format(result))