示例#1
0
    def setup_class(cls):
        """
            This method is called once when the class is first instanciated. It
            sets up the testing conditions, while saving the current configuration.
        """
        Test.setup_class()

        cls.test_path = cls.results_path+cls.date+"/TestBonding/"
        if not isdir(cls.test_path):
            makedirs(cls.test_path)

        # Get /etc/network/interfaces md5sum for comparison
        cls.firstMD5_interfaces = cls.md5sum("/etc/network/interfaces")

        # Get and save our netconfig
        netconfig = cls.client.call("network","getNetconfig")
        cls.orig = deepcopy(netconfig)
        netcfg = deserialize(netconfig)

        # Let's configure for our test
        eth1 = netcfg.getInterfaceBySystemName('eth1')
        eth2 = netcfg.getInterfaceBySystemName('eth2')

        netcfg_bondings = set(netcfg.bondings)
        for bonding in netcfg_bondings:
            if eth1 in bonding.ethernets:
                netcfg.removeInterface(bonding)
                break
        netcfg.removeInterface(eth1)

        netcfg_bondings = set(netcfg.bondings)
        for bonding in netcfg_bondings:
            if eth2 in bonding.ethernets:
                netcfg.removeInterface(bonding)
                break
        netcfg.removeInterface(eth2)

        bond0 = netcfg.createBonding('bond0', set((eth1, eth2)))

        # Give an IPv4 configuration to our bonding
        net = NetRW(
                "James",
                IP("192.168.242.0/24"),
                service_ip_addrs=set(IP("192.168.242.1"),)
                )

        bond0.addNet(net)
        serialized = netcfg.serialize()

        # Let's apply the new configuration
        cls.takeNuconfWriteRole()
        cls.client.call("network", "setNetconfig",
                        serialized, "created a bonding")
        cls.apply_nuconf()

        # Fetch the system name of the bonding we've just created
        netconfig = cls.client.call("network", "getNetconfig")
        netcfg = deserialize(netconfig)
        bond_interface = netcfg.getInterfaceByUserLabel('bond0')
        cls.bond_sys_name = bond_interface.getSystem_name()
示例#2
0
    def setup_class(cls):
        """
            This method is called once when the class is first instanciated. It
            sets up the testing conditions, while saving the current configuration.
        """
        Test.setup_class()

        cls.test_path = cls.results_path+cls.date+"/TestBondingVlan/"
        if not isdir(cls.test_path):
            makedirs(cls.test_path)

        # Get and save our netconfig
        netconfig = cls.client.call("network","getNetconfig")
        cls.orig = deepcopy(netconfig)
        netcfg = deserialize(netconfig)

        # Let's configure for our test
        cls.eth1 = netcfg.getInterfaceBySystemName('eth1')

        netcfg_bondings = set(netcfg.bondings)
        for bonding in netcfg_bondings:
            if cls.eth1 in bonding.ethernets:
                netcfg.removeInterface(bonding)
                break
        netcfg.removeInterface(cls.eth1)

        # Let's add a few vlans
        cls.vlans = []
        for id in range(1,2):
            myvlan = netcfg.createVlan(cls.eth1, "vlan%s" % id, id)
            net = NetRW(
                    "my_net%s" % id,
                    IP("192.168.10%s.0/24" % id),
                    service_ip_addrs=set(IP("192.168.10%s.1" % id),)
                    )
            myvlan.addNet(net)
            my_syst_name = myvlan.getSystem_name()
            cls.vlans.append(my_syst_name)

        # We're gonna reuse this config in our tests
        cls.test_netcfg = netcfg

        # Let's apply the new configuration
        serialized = netcfg.serialize()
        cls.takeNuconfWriteRole()
        cls.client.call("network", "setNetconfig",
                        serialized, "added 2 vlans")
        cls.apply_nuconf()

        # Fetch the system name of the bonding we've just created
        netconfig = cls.client.call("network", "getNetconfig")
        netcfg = deserialize(netconfig)
示例#3
0
def configure_simple_ethernet(blob, serialized, ifaces, netconf):
    """
        Conf should be like :
        ifaces = ('eth2',)
        netconf = {"name"      : "NAME",
                   "network"   : IP("192.168.2.0/24"),
                   "service"   : set(IP("192.168.2.1"),)}
    """
    # Check input
    check_ifaces(ifaces)
    check_netconf(netconf)

    # Let's configure
    netcfg = deserialize(serialized)

    eth1 = netcfg.getInterfaceBySystemName(netconf["iface"])
    netcfg_bondings = set(netcfg.bondings)
    for bonding in netcfg_bondings:
        if eth1 in bonding.ethernets:
            netcfg.removeInterface(bonding)
            break
    netcfg.removeInterface(eth1)

    net = NetRW(
                netconf["name"],
                netconf["network"],
                service_ip_addrs = netconf["service"]
               )
    eth1.addNet(net)

    return (netcfg.serialize(), net)
示例#4
0
def configure_bonding(serialized, ifaces, netconf):
    """
        Conf should be like :
        ifaces = ('eth1', 'eth2')
        netconf = {"name"      : "NAME",
                   "network"   : IP("192.168.2.0/24"),
                   "service"   : set(IP("192.168.2.1"),)}
    """
    # Check input
    check_ifaces(ifaces)
    check_netconf(netconf)

    # Let's configure
    netcfg = deserialize(serialized)

    eth1 = netcfg.getInterfaceBySystemName(ifaces[0])
    eth2 = netcfg.getInterfaceBySystemName(ifaces[1])

    netcfg_bondings = set(netcfg.bondings)
    for bonding in netcfg_bondings:
        if eth1 in bonding.ethernets:
            netcfg.removeInterface(bonding)
            break
    netcfg.removeInterface(eth1)

    netcfg_bondings = set(netcfg.bondings)
    for bonding in netcfg_bondings:
        if eth2 in bonding.ethernets:
            netcfg.removeInterface(bonding)
            break
    netcfg.removeInterface(eth2)

    bond0 = netcfg.createBonding('bond0', set((eth1, eth2)))

    # Give an IPv4 configuration to our bonding
    net = NetRW(
                netconf["name"],
                netconf["network"],
                service_ip_addrs = netconf["service"]
               )

    bond0.addNet(net)

    return (netcfg.serialize(), net)
    def setup_class(cls):
        """
            This method is called once when the class is first instanciated. It
            sets up the testing conditions, while saving the current configuration.
        """
        Test.setup_class()

        cls.test_path = cls.results_path + cls.date + "/" + cls.__name__ + "/"
        if not isdir(cls.test_path):
            makedirs(cls.test_path)

        # We save the configuration to restore it later
        serialized = cls.client.call("network", "getNetconfig")
        cls.orig = deepcopy(serialized)

        for i in serialized["ethernets"]:
            # Remove every route
            if serialized["ethernets"][i]["routes"] != {}:
                serialized["ethernets"][i]["routes"] = {}

        netcfg = deserialize(serialized)

        eth1 = netcfg.getInterfaceBySystemName("eth1")
        netcfg_bondings = set(netcfg.bondings)
        for bonding in netcfg_bondings:
            if eth1 in bonding.ethernets:
                netcfg.removeInterface(bonding)
                break

        netcfg.removeInterface(eth1)
        net = NetRW("Test", IP(cls.network_test["local_net"]), service_ip_addrs=set(IP(cls.network_test["local_ip"])))
        eth1.addNet(net)
        my_route = RouteRW(IP(cls.network_test["routed_net"]), IP(cls.network_test["gateway"]))
        eth1.addRoute(my_route)

        # In order to check that /etc/network/interfaces does change :
        cls.firstMD5_interfaces = cls.md5sum("/etc/network/interfaces")

        # We apply the network configuration
        serialized = netcfg.serialize()
        cls.takeNuconfWriteRole()
        cls.client.call("network", "setNetconfig", serialized, "pas de message")
        cls.apply_nuconf()
示例#6
0
    def configure_network(cls, serialized):
        """
            Custom network configuration
        """
        netcfg = deserialize(serialized)

        eth1 = netcfg.getInterfaceBySystemName(cls.test_network["iface"])
        netcfg_bondings = set(netcfg.bondings)
        for bonding in netcfg_bondings:
            if eth1 in bonding.ethernets:
                netcfg.removeInterface(bonding)
                break
        netcfg.removeInterface(eth1)

        net = NetRW(
                    cls.test_network["name"],
                    cls.test_network["network"],
                    primary_ip_addrs = cls.test_network["primary"],
                    secondary_ip_addrs = cls.test_network["secondary"],
                    service_ip_addrs = cls.test_network["service"]
                    )
        eth1.addNet(net)

        return netcfg.serialize()
示例#7
0
    def setup_class(cls):
        Test.setup_class()

        cls.test_path = cls.results_path+cls.date+"/TestHA/"
        if not isdir(cls.test_path):
            makedirs(cls.test_path)

        #################################### Configuration of the secondary
        # Check that the EW has a license
        cls.checkAndUploadLicense(Test.cluster_ha["secondary"])

        # Connect to the other nucentral
        cls.other_client = cls.createClient(host=Test.cluster_ha["secondary"])

        # Let's synchronize our watches
        cls.client.call('ntp',
                        'setNtpConfig',
                        {
                            'ntpservers': u'172.16.0.1',
                            'isFrozen': False
                        },
                        u'message')
        cls.client.call('ntp', 'syncTime')

        # Let's configure the HA on the secondary
        cls.other_client.call('ha',
                              'configureHA',
                              cls.secondary_ha_configuration,
                              u'message')

        cls.other_client.call('config','apply')
        cls.other_client.logout()
        ###################################################################

        ###################################### Configuration of the primary
        # Check that the EW has a license
        cls.checkAndUploadLicense(Test.cluster_ha["secondary"])

        # Connect to the localhost nucentral
        cls.client = cls.createClient()

        # We apply an configuration prior the HA configuration & join to
        # see if it will be replicated
        for call in cls.prior_configuration:
            cls.client.call(*call)

        # Save original configuration
        serialized = cls.client.call('network','getNetconfig')
        cls.orig=deepcopy(serialized)
        netcfg = deserialize(serialized)

        # Let's synchronize our watches
        cls.client.call('ntp',
                        'setNtpConfig',
                        {
                            'ntpservers': u'172.16.0.1',
                            'isFrozen': False
                        },
                        u'message')
        cls.client.call('ntp', 'syncTime')

        # Configure the network according to the input script
        serialized = cls.configure_network(serialized)

        # Configure the HA on the primary
        cls.client.call('ha',
                        'configureHA',
                        cls.primary_ha_configuration,
                        u'message')

        cls.client.call("network","setNetconfig",serialized, "none")
        cls.client.call("config","apply")
        ###################################################################

        ############################################################## Join
        # Fetch and save some of the configurations for comparison purposes
        cls.config=deepcopy(cls.client.call("config","get"))