Exemplo n.º 1
0
def _setup_bridge(bridge, ip, netmask, gateway, resolver):
    '''
    Bridge the bond network with the KVM guests.

    Can work both with and without IP.

    '''
    content = """DEVICE=%s
TYPE=Bridge
ONBOOT=yes
USERCTL=no
DELAY=0
BOOTPROTO=none
""" % (bridge)

    if ip:
        broadcast = net.get_ip_class_c(ip) + ".255"
        network = net.get_ip_class_c(ip) + ".0"

        content = content + """IPADDR=%s
NETMASK=%s
NETWORK=%s
BROADCAST=%s""" % (ip, netmask, network, broadcast)

    if gateway:
        content += "\nGATEWAY=" + gateway

    if resolver:
        content += "\nDNS=" + resolver

    general.store_file("/etc/sysconfig/network-scripts/ifcfg-" + bridge, content)
Exemplo n.º 2
0
def setup_bond(bond, bridge):
    """
    Setup a bondX device.

    """
    app.print_verbose("Setup bonded device {0} for bridge {1}".format(
        bond, bridge))
    app.print_verbose(
        "Will use mode: active-backup or 1\n" +
        "- Sets an active-backup policy for fault tolerance. Transmissions are "
        +
        "received and sent out via the first available bonded slave interface. "
        +
        "Another bonded slave interface is only used if the active bonded slave "
        + "interface fails.")

    general.store_file(
        "/etc/sysconfig/network-scripts/ifcfg-" + bond, """# Generated by syco
DEVICE=%s
BRIDGE=%s
BONDING_OPTS="miimon=100 mode=active-backup"
ONBOOT=yes
USERCTL=no
ONPARENT=yes
BOOTPROTO=none
""" % (bond, bridge))
Exemplo n.º 3
0
def _setup_eth(eth, bond):
    '''
    Setup the eth interface to be included in a bond.

    '''
    filename = "/etc/sysconfig/network-scripts/ifcfg-" + eth
    mac = general.get_config_value(filename, "HWADDR")
    general.store_file(filename,
"""DEVICE="%s"
HWADDR=%s
MASTER=%s
SLAVE=yes
NM_CONTROLLED="no"
ONBOOT=yes
USERCTL=no
HOTPLUG=no
BOOTPROTO=none
""" % (eth, mac, bond))
Exemplo n.º 4
0
def _setup_bond(bond, bridge):
    """
    Setup a bondX device.

    Will use mode: active-backup or 1
    - Sets an active-backup policy for fault tolerance. Transmissions are
    received and sent out via the first available bonded slave interface.
    Another bonded slave interface is only used if the active bonded slave
    interface fails.

    """
    general.store_file("/etc/sysconfig/network-scripts/ifcfg-" + bond,
"""DEVICE=%s
BRIDGE=%s
BONDING_OPTS="miimon=100 mode=1"
ONBOOT=yes
USERCTL=no
ONPARENT=yes
BOOTPROTO=none
""" % (bond, bridge))
Exemplo n.º 5
0
def setup_eth(eth, bond):
    '''
    Setup the eth interface to be included in a bond.

    '''
    app.print_verbose(
        "Setup the eth interface {0} to be included in {1}.".format(eth, bond))
    filename = "/etc/sysconfig/network-scripts/ifcfg-" + eth
    mac = general.get_config_value(filename, "HWADDR")
    general.store_file(
        filename, """# Generated by syco
DEVICE="%s"
HWADDR=%s
MASTER=%s
SLAVE=yes
NM_CONTROLLED="no"
ONBOOT=yes
USERCTL=no
HOTPLUG=no
BOOTPROTO=none
""" % (eth, mac, bond))
Exemplo n.º 6
0
def setup_bridge(bridge, ip, netmask, gateway, resolver):
    '''
    Bridge the bond network with the KVM guests.

    Can work both with and without IP.

    For info on mcsnoop see:
        http://thread.gmane.org/gmane.linux.network/153338

    '''
    content = """# Generated by syco
DEVICE={0}
TYPE=Bridge
ONBOOT=yes
USERCTL=no
DELAY=0
BOOTPROTO=none
""".format(bridge)

    if ip:
        broadcast = net.get_broadcast_address(ip, netmask)
        network = net.get_network_address(ip, netmask)

        content = """{0}IPADDR={1}
NETMASK={2}
NETWORK={3}
BROADCAST={4}
BRIDGING_OPTS="setmcsnoop=0"
""".format(content, ip, netmask, network, broadcast)

    if gateway:
        content += "GATEWAY={0}\n".format(gateway)

    if resolver:
        content += "DNS={0}\n".format(resolver)

    general.store_file("/etc/sysconfig/network-scripts/ifcfg-" + bridge,
                       content)
Exemplo n.º 7
0
def setup_bridge(bridge, ip, netmask, gateway, resolver):
    '''
    Bridge the bond network with the KVM guests.

    Can work both with and without IP.

    For info on mcsnoop see:
        http://thread.gmane.org/gmane.linux.network/153338

    '''
    content = """# Generated by syco
DEVICE={0}
TYPE=Bridge
ONBOOT=yes
USERCTL=no
DELAY=0
BOOTPROTO=none
""".format(bridge)

    if ip:
        broadcast = net.get_broadcast_address(ip, netmask)
        network = net.get_network_address(ip, netmask)

        content =  """{0}IPADDR={1}
NETMASK={2}
NETWORK={3}
BROADCAST={4}
BRIDGING_OPTS="setmcsnoop=0"
""".format(content, ip, netmask, network, broadcast)

    if gateway:
        content += "GATEWAY={0}\n".format(gateway)

    if resolver:
        content += "DNS={0}\n".format(resolver)

    general.store_file("/etc/sysconfig/network-scripts/ifcfg-" + bridge, content)
Exemplo n.º 8
0
def setup_eth(eth, bond):
    '''
    Setup the eth interface to be included in a bond.

    '''
    app.print_verbose(
        "Setup the eth interface {0} to be included in {1}.".format(
            eth, bond
        )
    )
    filename = "/etc/sysconfig/network-scripts/ifcfg-" + eth
    mac = general.get_config_value(filename, "HWADDR")
    general.store_file(filename,
"""# Generated by syco
DEVICE="%s"
HWADDR=%s
MASTER=%s
SLAVE=yes
NM_CONTROLLED="no"
ONBOOT=yes
USERCTL=no
HOTPLUG=no
BOOTPROTO=none
""" % (eth, mac, bond))
Exemplo n.º 9
0
def setup_bond(bond, bridge):
    """
    Setup a bondX device.

    """
    app.print_verbose("Setup bonded device {0} for bridge {1}".format(bond, bridge))
    app.print_verbose(
        "Will use mode: active-backup or 1\n" +
        "- Sets an active-backup policy for fault tolerance. Transmissions are " +
        "received and sent out via the first available bonded slave interface. " +
        "Another bonded slave interface is only used if the active bonded slave " +
        "interface fails."
    )

    general.store_file("/etc/sysconfig/network-scripts/ifcfg-" + bond,
"""# Generated by syco
DEVICE=%s
BRIDGE=%s
BONDING_OPTS="miimon=100 mode=active-backup"
ONBOOT=yes
USERCTL=no
ONPARENT=yes
BOOTPROTO=none
""" % (bond, bridge))