예제 #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)
예제 #2
0
파일: test_net.py 프로젝트: Nemie/syco
 def test_general(self):
     self.assertEqual(net.get_all_interfaces(), {'sit0': None, 'lo': '127.0.0.1', 'eth0': '10.100.100.231'})
     self.assertEqual(net.get_interface_ip("eth0"), "10.100.100.231")
     self.assertEqual(net.get_lan_ip(), "10.100.100.231")
     self.assertEqual(net.reverse_ip("1.2.3.4"), "4.3.2.1")
     self.assertEqual(net.get_ip_class_c("1.2.3.4"), "1.2.3")
     self.assertEqual(net.num_of_eth_interfaces(), 1)
     self.assertEqual(net.get_hostname(), "fo-tp-dalitst")
예제 #3
0
 def test_general(self):
     self.assertEqual(net.get_all_interfaces(), {
         'sit0': None,
         'lo': '127.0.0.1',
         'eth0': '10.100.100.231'
     })
     self.assertEqual(net.get_interface_ip("eth0"), "10.100.100.231")
     self.assertEqual(net.get_lan_ip(), "10.100.100.231")
     self.assertEqual(net.reverse_ip("1.2.3.4"), "4.3.2.1")
     self.assertEqual(net.get_ip_class_c("1.2.3.4"), "1.2.3")
     self.assertEqual(net.num_of_eth_interfaces(), 1)
     self.assertEqual(net.get_hostname(), "fo-tp-dalitst")
예제 #4
0
def install_dhcp(args):
    '''
    Install a dhcp server on the current server.

    '''
    app.print_verbose("Install DHCP-Server version: %d" % SCRIPT_VERSION)
    version_obj = version.Version("InstallDHCPServer", SCRIPT_VERSION)
    version_obj.check_executed()

    general.shell_exec("yum -y install dhcp")
    general.shell_exec("/sbin/chkconfig dhcpd on")
    shutil.copyfile(app.SYCO_PATH + "/var/dhcp/dhcp3.conf", "/etc/dhcp/dhcpd.conf")
    general.set_config_property("/etc/dhcp/dhcpd.conf", "\$\{IP\}", net.get_ip_class_c(net.get_lan_ip()))
    general.set_config_property("/etc/sysconfig/dhcpd", ".*DHCPDARGS.*", "DHCPDARGS=%s" % get_back_interface())
    general.shell_exec("service dhcpd restart")

    version_obj.mark_executed()
예제 #5
0
파일: installDHCP.py 프로젝트: Nemie/syco
def install_dhcp(args):
    """
    Install a dhcp server on the current server.

    """
    app.print_verbose("Install DHCP-Server version: %d" % SCRIPT_VERSION)
    version_obj = version.Version("InstallDHCPServer", SCRIPT_VERSION)
    version_obj.check_executed()

    general.shell_exec("yum -y install dhcp")
    general.shell_exec("/sbin/chkconfig dhcpd on")
    shutil.copyfile(app.SYCO_PATH + "/var/dhcp/dhcp3.conf", "/etc/dhcp/dhcpd.conf")
    general.set_config_property("/etc/dhcp/dhcpd.conf", "\$\{IP\}", net.get_ip_class_c(net.get_lan_ip()))
    general.set_config_property("/etc/sysconfig/dhcpd", ".*DHCPDARGS.*", "DHCPDARGS=%s" % get_back_interface())
    general.shell_exec("service dhcpd restart")

    version_obj.mark_executed()