Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 58535 Details for
Bug 92063
A rewrite of dialogfe to use the GLIGen library.
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
netfe.py.2.patch
netfe.py.2.patch (text/plain), 10.58 KB, created by
Christopher Hotchkiss
on 2005-05-09 17:58:31 UTC
(
hide
)
Description:
netfe.py.2.patch
Filename:
MIME Type:
Creator:
Christopher Hotchkiss
Created:
2005-05-09 17:58:31 UTC
Size:
10.58 KB
patch
obsolete
>Index: netfe.py >=================================================================== >RCS file: /var/cvsroot/gentoo/src/installer/src/fe/net/client/netfe.py,v >retrieving revision 1.1 >diff -a -u -r1.1 netfe.py >--- netfe.py 2 May 2005 15:11:30 -0000 1.1 >+++ netfe.py 10 May 2005 00:52:31 -0000 >@@ -1,28 +1,63 @@ > #!/usr/bin/python > """ >-The sole point of this script is to kick off a GLIInstall. This script requires the 'netbe.py' configured and setup on the local net in order to run. No other dependancies are required for this script. >+The sole point of this script is to kick off a GLIInstall. This script requires the 'netbe.py' configured and setup on the local net in order to run. Also the network should up and running when this script is invoked. No other dependancies are required for this script. > Script steps: >- 1. Bring up network with dhcp or use udp broadcast to grab the client config file. >+ 1. Assume the network is up and running > 2. Send a UDP request to the broadcast address. >- 3. The server will check the ip making the request and sent it the location of the server >+ 3. Server will respond. > 4. The client will connect to the server using XMLRPC and request a GLIClientConfig and a InstallProfile > 5. Next the client will start the install, logging all events to the server >+ >+Note: If the install server does not have a clientconf or installprofile we will allow the user to generate one and upload it. > """ > import sys, time, socket >-sys.path.append("../..") >+sys.path.append("../../..") > import GLIException > import GLIInstallProfile > import GLIClientConfiguration > import GLIClientController > import GLIUtility >+import xmlrpclib >+import dialog >+from GLIGen import GLIGenCF,GLIGenIP >+ >+DLG_OK = 0 >+DLG_YES = 0 >+DLG_CANCEL = 1 >+DLG_NO = 1 >+DLG_ESC = 2 >+DLG_ERROR = 3 >+DLG_EXTRA = 4 >+DLG_HELP = 5 >+ >+class CFDialog(GLIGenCF): >+ def __init__(self): >+ GLIGenCF.__init__(self) >+ if self._d.yesno("We are unable to find a Client Configuration for you. Would you like to generate one instead?") == self._DLG_YES: >+ self._set_arch_template() >+ self._set_logfile() >+ self._set_root_mount_point() >+ self._set_client_networking() >+ self._set_livecd_password() >+ self._set_enable_ssh() >+ self._set_client_kernel_modules() >+ else: >+ raise GLIException('NetFeError', 'fatal', 'UserGen.__init__', "Unable to find or generate a CLient Configuration.") >+class IPDialog(GLIGenIP): >+ def __init__(self): >+ if self._d.yesno("We are unable to find an Install Profile for you. Would you like to generate one instead?") == self._DLG_YES: >+ GLIGenIP.__init__(self) >+ else: >+ raise GLIException('NetFeError', 'fatal', 'UserGen.__init__', "Unable to find or generate a Install Profile.") > > def udp_broadcast(message, bw_addr, port): > #Setup the socket for broadcast. > s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) > s.bind(('', 0)) > s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) >- >- retry_max = 10 >+ s.settimeout(15) >+ >+ retry_max = 3 > count = 0 > response = "" > >@@ -33,86 +68,98 @@ > if response: > break > if count >= retry_max: >- raise GLIException("NoBroadcastServer", 'fatal', 'udp_broadcast',"Was unable to find a network broadcast server.") >+ raise GLIException("NetFeError", 'fatal', 'udp_broadcast',"Was unable to find a network broadcast server.") > time.sleep(2) > return response, str(fromaddr[0]), str(fromaddr[1]) > >-def setup_network(main_port): >+def find_macip(): >+ device = None >+ device_name = 'eth' >+ for num in range(5): >+ if GLIUtility.is_eth_device(device_name + str(num)): >+ device = GLIUtility.get_eth_info(num) >+ break >+ else: >+ raise GLIException("NetFeError", 'fatal', 'setup_network',"Was unable to find a network inferface.") >+ return device[0], device[1] >+ >+def find_server(main_port): > discovery_port = main_port - 1 > device = None >- device_name = "" >+ device_name = 'eth' > for num in range(5): >- device = GLIUtility.get_eth_info(num) >- if device: >- device_name = 'eth' + str(num) >+ if GLIUtility.is_eth_device(device_name + str(num)): >+ device = GLIUtility.get_eth_info(num) > break > else: >- raise GLIException("NoInterfaceError", 'fatal', 'setup_network',"Was unable to find a network inferface.") >+ raise GLIException("NetFeError", 'fatal', 'setup_network',"Was unable to find a network inferface.") > >- #First try to come up as a dhcp client. This is the preferred way of starting the network. >- if device: >- status = GLIUtility.spawn("dhcpcd -n " + device_name, quiet=True) >+ response, server_ip, server_port = udp_broadcast("GLIAutoInstall", device[3], discovery_port) >+ return server_ip >+ >+def ask_server(d): >+ code, uri = d.inputbox("We were unable to autodiscover the server. Plaese enter the uri of the server:") >+ if code != DLG_OK: >+ raise GLIException("Unable to connect to a server.") >+ #Removed until GLIUtility.is_uri supports port numbers >+ #elif not GLIUtility.is_uri(uri): >+ # d.msgbox("You must pass a valid uri.") > else: >- status = GLIUtility.spawn("dhcpcd -n", quiet=True) >+ return uri > >- #If dhcp couldn't start we will try to use UDP broadcast to the server. Then we will pull the >- #config file and setup whatever networking is defined for us. >- if not GLIUtility.exitsuccess(status): >- GLIUtility.set_ip(device_name, '0.0.0.0', '255.255.255.255', '0.0.0.0') >- >- #Grab the config from the server. Pass it the MAC address so the server can identify you. >- #as well as the broadcast address and port you want to check on. >- response, server_ip, port = udp_broadcast("GLI CC " + device[0], device[3], discovery_port) >- if response == "GLI CC not found!": >- raise GLIException("GLIMissingConfig","The server does not have a GLICLientConfiguration for you. Check with the server admin.") >- else: >- #Write the Client Config to a temp file, so it can be read in and parsed >- file = open("/tmp/gli.conf","w") >- file.write(response) >- file.close() >- >- #Instanciate a ClientController and tell it to setup the network >- client_config = GLIClientConfiguration.GLIClientConfiguration() >- client_config.parse("/tmp/gli.conf") >- cc = GLIClientController.GLIClientController(client_config) >- cc.configure_networking() >- response, server_ip, server_port = udp_broadcast("PING", device[3], discovery_port) >- return server_ip >- >- > if __name__ == '__main__': > main_port = 12345 > >- #First things first check for network existance and setup the network; the server ip will be returned >- server_ip = setup_network(main_port) >- local_ip = socket.gethostbyname(socket.gethostname()) >+ d = dialog.Dialog() >+ d.setBackgroundTitle("Gentoo Linux Installer") >+ d.infobox("Welcome to The Gentoo Linux Installer. This is a TESTING release. If your system dies a horrible, horrible death, don't come crying to us (okay, you can cry to klieber).", height=10, width=50, title="Welcome") >+ time.sleep(2) > >- #Next setup the RPC Client >- server = ServerProxy("http://" + server_ip + ":" + main_port) >+ #First the client's mac and ip address >+ local_mac, local_ip = find_macip() > >- #Grab the Client Configuration and Install Profile >- client_config = "" >- install_profile = "" >+ d.infobox("We are now attempting to autodiscover the install server. If this fails you will be asked for the server's uri.") >+ time.sleep(1) > try: >- client_config = server.get_client_config(local_ip) >- install_profile = server.get_install_profile(local_ip) >- except Error, v: >- raise GLIException("GLIMissingConfig", v ) >+ server_ip = find_server(main_port) >+ if server_ip == local_ip: >+ server_ip = '127.0.0.1' >+ server_uri = "http://" + server_ip + ":" + str(main_port) >+ except: >+ server_uri = ask_server(d) >+ >+ #Next setup the RPC Client >+ server = xmlrpclib.ServerProxy(server_uri) >+ >+ #If we cant find the configuration files, start the dialog fe and generate them. >+ d.infobox("We are now going to get the Client Configuration from the server.") >+ client_config = server.get_client_config(local_mac) >+ if not GLIUtility.is_realstring(client_config): >+ clco = CFDialog() >+ client_config = clco.serialize() >+ server.set_client_config(local_mac, client_config) >+ >+ d.infobox("We are now going to get the Install Profile from the server.") >+ install_profile = server.get_install_profile(local_mac) >+ if not GLIUtility.is_realstring(install_profile): >+ ip = IPDialog() >+ install_profile = ip.serialize() >+ server.set_install_profile(local_mac, install_profile) > > #Write out the client_config and install_profile >- file = open("/tmp/gli.conf","w") >- file.write(client_config) >- file.close() >- >- file = open("/tmp/ins_prof.xml","w") >- file.write(install_profile) >- file.close() >+ r_file = open("/tmp/cli_conf.xml","w") >+ r_file.write(client_config) >+ r_file.close() >+ >+ r_file = open("/tmp/ins_prof.xml","w") >+ r_file.write(install_profile) >+ r_file.close() > > #Instanciate the GLI engine >- client_conf = GLIClientConfiguration.GLIClientConfiguration() >+ client_conf = GLIClientConfiguration.ClientConfiguration() > client_conf.parse("/tmp/gli.conf") > client_conf.set_interactive(None, True, None) >- install_prof = GLIInstallProfile.GLIInstallProfile() >+ install_prof = GLIInstallProfile.InstallProfile() > install_prof.parse("/tmp/ins_prof.xml") > cc = GLIClientController.GLIClientController(client_conf,install_prof) > >@@ -121,27 +168,33 @@ > > #Begin the main engine > cc.start_install() >+ d.gauge_start("Installation Started!", title="Installation progress") > num_steps_completed = 1 > while 1: > notification = cc.getNotification() > if notification == None: > time.sleep(1) > continue >- type = notification.get_type() >- data = notification.get_data() >- if type == "exception": >- server.log_event(local_ip, "Exception: " + data) >- elif type == "int": >- if data == GLIClientController.NEXT_STEP_READY: >+ type_r = notification.get_type() >+ data_r = notification.get_data() >+ if type_r == "exception": >+ server.log_event(local_ip, "Exception: " + data_r) >+ print data_r >+ elif type_r == "int": >+ if data_r == GLIClientController.NEXT_STEP_READY: > next_step_waiting = False > next_step = cc.get_next_step_info() > num_steps = cc.get_num_steps() >+ i = (num_steps_completed*100)/num_steps >+ d.gauge_update(i, "On step %d of %d. Current step: %s" % (num_steps_completed, num_steps, next_step), update_text=1) > server.log_event(local_ip, "On step " + num_steps_completed + " of " + num_steps + ". Current step: " + next_step) > num_steps_completed += 1 > if cc.has_more_steps(): > cc.next_step() > continue >- if data == GLIClientController.INSTALL_DONE: >+ if data_r == GLIClientController.INSTALL_DONE: > server.log_event(local_ip, "Install completed!") >+ d.gauge_update(100, "Install completed!", update_text=1) >+ d.gauge_stop() > print "Install done!" > sys.exit(0) >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 92063
:
58534
| 58535 |
58536