@@ -325,6 +325,7 @@ class TaskFailed(Exception): pass
325325
326326class ConfigTask :
327327 name = "generic config task"
328+ autoMode = False
328329 def __init__ (self ): pass
329330 def done (self ):
330331 """Returns true if the config task has already been done in the past, false if it hasn't"""
@@ -342,6 +343,10 @@ def run (self):
342343 else :
343344 for msg in it : stderr (msg )
344345 stderr ("Completed %s" % self .name )
346+ def setAutoMode (self , autoMode ):
347+ self .autoMode = autoMode
348+ def isAutoMode (self ):
349+ return self .autoMode
345350
346351
347352# ============== these are some configuration tasks ==================
@@ -551,7 +556,9 @@ def execute(self):
551556 raise TaskFailed ("Network reconfiguration failed" )
552557
553558 yield "We are going to restart network services now, to make the network changes take effect. Hit ENTER when you are ready."
554- raw_input ()
559+ if self .isAutoMode (): pass
560+ else :
561+ raw_input ()
555562
556563 # if we reach here, then if something goes wrong we should attempt to revert the runinng state
557564 # if not, then no point
@@ -900,7 +907,7 @@ def prompt_for_hostpods(zonespods):
900907
901908# this configures the agent
902909
903- def setup_agent_config (configfile ):
910+ def setup_agent_config (configfile , host , zone , pod ):
904911 stderr ("Examining Agent configuration" )
905912 fn = configfile
906913 text = file (fn ).read (- 1 )
@@ -912,23 +919,29 @@ def setup_agent_config(configfile):
912919 stderr ("Generating GUID for this Agent" )
913920 confopts ['guid' ] = uuidgen ().stdout .strip ()
914921
915- try : host = confopts ["host" ]
916- except KeyError : host = "localhost"
917- stderr ("Please enter the host name of the management server that this agent will connect to: (just hit ENTER to go with %s)" ,host )
918- newhost = raw_input ().strip ()
919- if newhost : host = newhost
922+ if host == None :
923+ try : host = confopts ["host" ]
924+ except KeyError : host = "localhost"
925+ stderr ("Please enter the host name of the management server that this agent will connect to: (just hit ENTER to go with %s)" ,host )
926+ newhost = raw_input ().strip ()
927+ if newhost : host = newhost
928+
920929 confopts ["host" ] = host
921930
922931 stderr ("Querying %s for zones and pods" ,host )
923932
924933 try :
925- x = list_zonespods (confopts ['host' ])
926- zoneandpod = prompt_for_hostpods (x )
927- if zoneandpod :
928- confopts ["zone" ],confopts ["pod" ] = zoneandpod
929- stderr ("You selected zone %s pod %s" ,confopts ["zone" ],confopts ["pod" ])
934+ if zone == None or pod == None :
935+ x = list_zonespods (confopts ['host' ])
936+ zoneandpod = prompt_for_hostpods (x )
937+ if zoneandpod :
938+ confopts ["zone" ],confopts ["pod" ] = zoneandpod
939+ stderr ("You selected zone %s pod %s" ,confopts ["zone" ],confopts ["pod" ])
940+ else :
941+ stderr ("Skipped -- using the previous zone %s pod %s" ,confopts ["zone" ],confopts ["pod" ])
930942 else :
931- stderr ("Skipped -- using the previous zone %s pod %s" ,confopts ["zone" ],confopts ["pod" ])
943+ confopts ["zone" ] = zone
944+ confopts ["pod" ] = pod
932945 except (urllib2 .URLError ,urllib2 .HTTPError ),e :
933946 stderr ("Query failed: %s. Defaulting to zone %s pod %s" ,confopts ["zone" ],confopts ["pod" ])
934947
@@ -940,7 +953,7 @@ def setup_agent_config(configfile):
940953 text = "\n " .join (lines )
941954 file (fn ,"w" ).write (text )
942955
943- def setup_consoleproxy_config (configfile ):
956+ def setup_consoleproxy_config (configfile , host , zone , pod ):
944957 stderr ("Examining Console Proxy configuration" )
945958 fn = configfile
946959 text = file (fn ).read (- 1 )
@@ -952,23 +965,28 @@ def setup_consoleproxy_config(configfile):
952965 stderr ("Generating GUID for this Console Proxy" )
953966 confopts ['guid' ] = uuidgen ().stdout .strip ()
954967
955- try : host = confopts ["host" ]
956- except KeyError : host = "localhost"
957- stderr ("Please enter the host name of the management server that this console-proxy will connect to: (just hit ENTER to go with %s)" ,host )
958- newhost = raw_input ().strip ()
959- if newhost : host = newhost
968+ if host == None :
969+ try : host = confopts ["host" ]
970+ except KeyError : host = "localhost"
971+ stderr ("Please enter the host name of the management server that this console-proxy will connect to: (just hit ENTER to go with %s)" ,host )
972+ newhost = raw_input ().strip ()
973+ if newhost : host = newhost
960974 confopts ["host" ] = host
961975
962976 stderr ("Querying %s for zones and pods" ,host )
963977
964978 try :
965- x = list_zonespods (confopts ['host' ])
966- zoneandpod = prompt_for_hostpods (x )
967- if zoneandpod :
968- confopts ["zone" ],confopts ["pod" ] = zoneandpod
969- stderr ("You selected zone %s pod %s" ,confopts ["zone" ],confopts ["pod" ])
979+ if zone == None or pod == None :
980+ x = list_zonespods (confopts ['host' ])
981+ zoneandpod = prompt_for_hostpods (x )
982+ if zoneandpod :
983+ confopts ["zone" ],confopts ["pod" ] = zoneandpod
984+ stderr ("You selected zone %s pod %s" ,confopts ["zone" ],confopts ["pod" ])
985+ else :
986+ stderr ("Skipped -- using the previous zone %s pod %s" ,confopts ["zone" ],confopts ["pod" ])
970987 else :
971- stderr ("Skipped -- using the previous zone %s pod %s" ,confopts ["zone" ],confopts ["pod" ])
988+ confopts ["zone" ] = zone
989+ confopts ["pod" ] = pod
972990 except (urllib2 .URLError ,urllib2 .HTTPError ),e :
973991 stderr ("Query failed: %s. Defaulting to zone %s pod %s" ,e ,confopts ["zone" ],confopts ["pod" ])
974992
0 commit comments