Exemplo n.º 1
0
def test_interfaces_ipv4_addresses():

    from fabtools.network import interfaces
    from fabtools.network import address

    for interface in interfaces():
        ipv4_address = address(interface)
        assert is_valid_ipv4_address(ipv4_address)
Exemplo n.º 2
0
def install():
    """
    Before use it, must do
    apt-get install sudo
    adduser username sudo
    add new network card
    dhclient eth1
    """

    # Management card address
    mgtmacaddress = 'a6:88:fe:f0:d5:2d'
    vswitchname = "vswitch0"
    vswitchport = "eth0"

    # Check if we use the management interface
    (user, ip) = env.host_string.split("@")
    ismanagement = False
    print network
    for interface in network.interfaces():
        if interface != 'lo':
            if network.mac(interface) == mgtmacaddress:
                ismanagement = True
                break

    # Require docker
    require_docker()

    if not ismanagement:
        raise Exception(
            'Please use the management network card with %(mgtmacaddress)s MAC address'
            % locals())

    # Configure networks
    require.file('/etc/network/interfaces', source='interfaces', use_sudo=True)
    service.reload('networking')

    # Add open vSwitch
    bridges = ovswitch.bridges()
    if vswitchname not in bridges:
        ovswitch.add_bridge(vswitchname)
        ovswitch.add_port2bridge(vswitchport, vswitchname)
        print(red("Plese reboot your system"))
Exemplo n.º 3
0
def install():
    """
    Before use it, must do
    apt-get install sudo
    adduser username sudo
    add new network card
    dhclient eth1
    """

    # Management card address
    mgtmacaddress = 'a6:88:fe:f0:d5:2d'
    vswitchname = "vswitch0"
    vswitchport = "eth0"

    # Check if we use the management interface
    (user, ip) = env.host_string.split("@")
    ismanagement = False
    print network
    for interface in network.interfaces():
        if interface != 'lo':
            if network.mac(interface) == mgtmacaddress:
                ismanagement = True
                break

    # Require docker
    require_docker()

    if not ismanagement:
        raise Exception('Please use the management network card with %(mgtmacaddress)s MAC address' % locals())

    # Configure networks
    require.file('/etc/network/interfaces', source='interfaces', use_sudo=True)
    service.reload('networking')

    # Add open vSwitch
    bridges = ovswitch.bridges()
    if vswitchname not in bridges:
        ovswitch.add_bridge(vswitchname)
        ovswitch.add_port2bridge(vswitchport,vswitchname)
        print(red("Plese reboot your system"))
Exemplo n.º 4
0
def test_loopback_interface_exists():
    from fabtools.network import interfaces
    assert 'lo' in interfaces()