aboutsummaryrefslogtreecommitdiffstats
path: root/requirements.txt
blob: 62ce629e264a987b87d078789cf60a8b32d6e2ea (plain)
1
2
3
4
5
6
7
8
9
10
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr>=1.6 # Apache-2.0
Babel>=1.3 # BSD
cliff!=1.16.0,!=1.17.0,>=1.15.0 # Apache-2.0
PyYAML>=3.1.0 # MIT
python-dateutil>=2.4.2 # BSD
six>=1.9.0 # MIT
tosca-parser>=0.4.0 # Apache-2.0 
ric.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
##############################################################################
# Copyright (c) 2016 Dan Radez (Red Hat)
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

from apex.common.constants import (
    EXTERNAL_NETWORK,
    STORAGE_NETWORK,
    ADMIN_NETWORK,
)

from apex.network_settings import (
    NetworkSettings,
    NetworkSettingsException,
)

from nose.tools import (
    assert_equal,
    assert_is_instance,
    assert_raises
)

files_dir = '../config/network/'


class TestNetworkSettings(object):
    @classmethod
    def setup_class(klass):
        """This method is run once for each class before any tests are run"""

    @classmethod
    def teardown_class(klass):
        """This method is run once for each class _after_ all tests are run"""

    def setUp(self):
        """This method is run once before _each_ test method is executed"""

    def teardown(self):
        """This method is run once after _each_ test method is executed"""

    def test_init(self):
        assert_is_instance(
            NetworkSettings(files_dir+'network_settings.yaml'),
            NetworkSettings)

    def test_init_vlans(self):
        assert_is_instance(
            NetworkSettings(files_dir+'network_settings_vlans.yaml'),
            NetworkSettings)

# TODO, v6 test is stuck
    # def test_init_v6(self):
    #     assert_is_instance(
    #         NetworkSettings(files_dir+'network_settings_v6.yaml', True),
    #         NetworkSettings)

    def test_init_admin_disabled_or_missing(self):
        ns = NetworkSettings(files_dir+'network_settings.yaml')
        # remove admin, apex section will re-add it
        ns['networks'].pop('admin', None)
        assert_raises(NetworkSettingsException, NetworkSettings, ns)
        # remove admin and apex
        ns.pop('apex', None)
        ns['networks'].pop('admin', None)
        assert_raises(NetworkSettingsException, NetworkSettings, ns)

    def test_init_collapse_storage(self):
        ns = NetworkSettings(files_dir+'network_settings.yaml')
        # remove storage
        ns['networks'].pop('storage', None)
        assert_is_instance(NetworkSettings(ns), NetworkSettings)

    def test_init_missing_dns_domain(self):
        ns = NetworkSettings(files_dir+'network_settings.yaml')
        # remove storage
        ns.pop('dns-domain', None)
        assert_is_instance(NetworkSettings(ns), NetworkSettings)

    def test_dump_bash(self):
        ns = NetworkSettings('../config/network/network_settings.yaml')
        assert_equal(ns.dump_bash(), None)
        assert_equal(ns.dump_bash(path='/dev/null'), None)

    def test_get_network_settings(self):
        ns = NetworkSettings('../config/network/network_settings.yaml')
        assert_is_instance(ns, NetworkSettings)
        for role in ['controller', 'compute']:
            nic_index = 1
            print(ns.nics)
            for network in ns.enabled_network_list:
                nic = 'nic' + str(nic_index)
                assert_equal(ns.nics[role][network], nic)
                nic_index += 1

    def test_get_enabled_networks(self):
        ns = NetworkSettings('../config/network/network_settings.yaml')
        assert_is_instance(ns.enabled_network_list, list)

    def test_invalid_nic_members(self):
        ns = NetworkSettings(files_dir+'network_settings.yaml')
        storage_net_nicmap = ns['networks'][STORAGE_NETWORK]['nic_mapping']
        # set duplicate nic
        storage_net_nicmap['compute']['members'][0] = 'nic1'
        assert_raises(NetworkSettingsException, NetworkSettings, ns)
        # remove nic members
        storage_net_nicmap['compute']['members'] = []
        assert_raises(NetworkSettingsException, NetworkSettings, ns)

    def test_missing_vlan(self):
        ns = NetworkSettings(files_dir+'network_settings.yaml')
        storage_net_nicmap = ns['networks'][STORAGE_NETWORK]['nic_mapping']
        # remove vlan from storage net
        storage_net_nicmap['compute'].pop('vlan', None)
        assert_is_instance(NetworkSettings(ns), NetworkSettings)

# TODO
# need to manipulate interfaces some how
# maybe for ip_utils to return something to pass this
#    def test_admin_auto_detect(self):
#        ns = NetworkSettings(files_dir+'network_settings.yaml')
#        # remove cidr to force autodetection
#        ns['networks'][ADMIN_NETWORK].pop('cidr', None)
#        assert_is_instance(NetworkSettings(ns), NetworkSettings)

    def test_admin_fail_auto_detect(self):
        ns = NetworkSettings(files_dir+'network_settings.yaml')
        # remove cidr and installer_vm to fail autodetect
        ns['networks'][ADMIN_NETWORK].pop('cidr', None)
        ns['networks'][ADMIN_NETWORK].pop('installer_vm', None)
        assert_raises(NetworkSettingsException, NetworkSettings, ns)

    def test_exception(self):
        e = NetworkSettingsException("test")
        print(e)
        assert_is_instance(e, NetworkSettingsException)

    def test_config_ip(self):
        ns = NetworkSettings(files_dir+'network_settings.yaml')
        # set the provisioner ip to None to force _gen_ip to generate one
        ns['networks'][ADMIN_NETWORK]['installer_vm']['ip'] = None
        ns['networks'][EXTERNAL_NETWORK][0]['installer_vm']['ip'] = None
        # Now rebuild network settings object and check for repopulated values
        ns = NetworkSettings(ns)
        assert_equal(ns['networks'][ADMIN_NETWORK]['installer_vm']['ip'],
                     '192.0.2.1')
        assert_equal(ns['networks'][EXTERNAL_NETWORK][0]['installer_vm']['ip'],
                     '192.168.37.1')

    def test_config_gateway(self):
        ns = NetworkSettings(files_dir+'network_settings.yaml')
        # set the gateway ip to None to force _config_gateway to generate one
        ns['networks'][EXTERNAL_NETWORK][0]['gateway'] = None
        # Now rebuild network settings object and check for a repopulated value
        ns = NetworkSettings(ns)
        assert_equal(ns['networks'][EXTERNAL_NETWORK][0]['gateway'],
                     '192.168.37.1')