/[gli]/branches/overhaul/src/GLIUtility.py
Gentoo

Diff of /branches/overhaul/src/GLIUtility.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1749 Revision 1750
945 status = spawn('/etc/init.d/portmap start') #, display_on_tty8=True) 945 status = spawn('/etc/init.d/portmap start') #, display_on_tty8=True)
946 if not exitsuccess(status): 946 if not exitsuccess(status):
947 return False 947 return False
948 else: 948 else:
949 return True 949 return True
950
951
952# Configures networking as specified in the GLIClientConfiguration object
953def configure_networking(interface, network_type="dhcp", ip_address=None, broadcast=None, netmask=None, gateway=None, dnsservers=None, dhcp_options=None, http_proxy=None, ftp_proxy=None, rsync_proxy=None):
954 #if self._configuration.get_verbose(): self._logger.log("DEBUG: beginning of configure_networking()")
955 # Do networking setup right here.
956 if network_type != None:
957 if network_type == "null" or network_type == "none":
958 # don't do anything, it's not our problem if the user specifies this.
959 return
960 elif network_type == "dhcp":
961 #if self._configuration.get_verbose(): self._logger.log("DEBUG: configure_networking(): DHCP selected")
962 # Run dhcpcd.
963 if interface and not dhcp_options:
964 # if self._configuration.get_verbose(): self._logger.log("DEBUG: configure_networking(): running '/sbin/dhcpcd -n " + interface + "'")
965 status = spawn("/sbin/dhcpcd -t 15 -n " + interface)
966 elif interface and dhcp_options:
967 # if self._configuration.get_verbose(): self._logger.log("DEBUG: configure_networking(): running '/sbin/dhcpcd " + dhcp_options + " " + interface + "'")
968 status = spawn("/sbin/dhcpcd -t 15 " + dhcp_options + " " + interface)
969 else:
970 # if self._configuration.get_verbose(): self._logger.log("DEBUG: configure_networking(): running '/sbin/dhcpcd -n'")
971 status = spawn("/sbin/dhcpcd -t 15 -n")
972 # if self._configuration.get_verbose(): self._logger.log("DEBUG: configure_networking(): call to /sbin/dhcpcd complete")
973
974 if not exitsuccess(status):
975 raise GLIException("DHCPError", 'fatal', 'configure_networking', "Failed to get a dhcp address for " + interface + ".")
976
977 elif network_type == "static":
978 #if self._configuration.get_verbose(): self._logger.log("DEBUG: configure_networking(): setting static IP")
979 # Configure the network from the settings they gave.
980 if not set_ip(interface, ip_address, broadcast, netmask):
981 raise GLIException("SetIPError", 'fatal', 'configure_networking', "Could not set the IP address!")
982
983 if not set_default_route(gateway):
984 raise GLIException("DefaultRouteError", 'fatal','configure_networking', "Could not set the default route!")
985
986 if dns_servers:
987 try:
988 resolv_conf = open("/etc/resolv.conf", "w")
989 for dns_server in dns_servers:
990 resolv_conf.write("nameserver " + dns_server + "\n")
991 resolv_conf.close()
992 except:
993 raise GLIException("DNSServerError", 'fatal','configure_networking', "Could not set the DNS servers!")
994
995 #if self._configuration.get_verbose(): self._logger.log("DEBUG: configure_networking(): done setting static IP")
996
997 #Set proxies
998 #if self._configuration.get_verbose(): self._logger.log("DEBUG: beginning of set_proxys()")
999 if ftp_proxy != "":
1000 os.environ['ftp_proxy'] = ftp_proxy
1001
1002 if http_proxy != "":
1003 os.environ['http_proxy'] = http_proxy
1004
1005 if rsync_proxy != "":
1006 os.environ['RSYNC_PROXY'] = rsync_proxy
1007 #if self._configuration.get_verbose(): self._logger.log("DEBUG: end of set_proxys()")
1008
1009 #Test the connection to make sure everything worked.
1010 if ping("www.gentoo.org"):
1011 return True
1012 else:
1013 return False

Legend:
Removed from v.1749  
changed lines
  Added in v.1750

  ViewVC Help
Powered by ViewVC 1.1.20