[node-devel] [PATCH] Add network configure in emergency shell

Mike Burns mburns at redhat.com
Tue Jan 3 13:31:11 UTC 2012


Thought I replied to this already, but I can't find the reply, so I'll
reply again.

On Thu, 2011-12-22 at 14:41 +0800, Eli Qiao wrote:
> 
> 
> 于 2011年12月21日 22:41, Mike Burns 写道: 
> > Thanks for the patch.
> > 
> > Just so you're aware, the normal process for patch submissions is to
> > post patches to gerrit:
> > 
> > http://ovirt.org/wiki/Working_with_oVirt_Gerrit
> > 
> > It looks like you're working off a rather old version.  The
> > autoinstall_failed function was moved to ovirt-functions back in
> > September.
> > 
> > The current repo is at:  
> > Gitweb: http://gerrit.ovirt.org/gitweb?p=ovirt-node.git
> > giturl: http://gerrit.ovirt.org/p/ovirt-node.git
> > 
> > The actual commit that moved the function is here:
> > 
> > http://gerrit.ovirt.org/gitweb?p=ovirt-node.git;a=commit;h=a6f000ae812ee1ee4d762ba1f6c807968ac13170
> > 
> > 
> > Some initial comments on you're patch are below:
> > 
> > On Wed, 2011-12-21 at 15:47 +0800, taget at linux.vnet.ibm.com wrote:
> > > From: jimmy <taget at 163.com>
> > > 
> > > This patch is to configure networking before dropping in to emergency shell.
> > > By doing this, user can using ssh to connect host server.
> > > 
> > > Signed-off-by: Eli <taget at vnet.linux.ibm.com>
> > > ---
> > >  ovirt-firstboot |    3 +++
> > >  1 files changed, 3 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/scripts/virt-firstboot b/scripts/ovirt-firstboot
> > > index ef0a071..48f31e6 100755
> > > --- a/scripts/ovirt-firstboot
> > > +++ b/scripts/ovirt-firstboot
> > > @@ -36,6 +36,9 @@ trap 'exit $?' 1 2 13 15
> > >  autoinstall_failed(){
> > >      log "Automatic installation failed. Please review console messages."
> > >      log "Press Enter to drop to emergency shell."
> > > +    /usr/libexec/ovirt-config-networking AUTO
> > Since changed to use python scripts instead of bash.  This should be
> > calling the network_auto function in network.py.  You can see how this
> > is called in ovirt-auto-install.py
> > 
> > > +    log "Configure root password : "
> > > +    /usr/bin/passwd
> > This will set the root password, but ssh password authentication is
> > disabled by default, so you need to enable that too.
> > 
> > > read < /dev/console
> > >      bash < /dev/console
> > >  }
> > 
> > The overall concept of being able to ssh in when auto-installation fails
> > is good, but it's not solved completely here.  Assuming I understand
> > correctly, you're looking to be able to start the installation process
> > and then ssh in to debug it if/when it fails.  You're current patch
> > doesn't remove the need for console access since you need to be able to
> > type the password anyway to set it.
> > 
> > My recommendation would be to:
> > 
> > 1.  get the updated repo
> > 2.  work in ovirt-auto-install.py to configure networking in the else
> > condition
> > 3.  use existing means to set passwords and ssh password authentication
> >         you can set root password with rootpw commandline option
> >         you can set admin password with adminpw commandline option
> >         you can enable ssh password auth with ssh_pwauth option
> >         These options are documented in ovirt-early where they're
> >         parsed.
> > 
> hi Mike,
> I don't think add network configure and enable ssh password in the
> else condition is a good way , cause if so , the code is duplicated
> and ugly.
> 
> 
> So , can we just configure networking and enable ssh password before
> we call storage_auto() ? By doing this , we could access the host even
> the automatic installation failed.
> like this :
> 

We can't run the network configuration before storage configuration.
Network config does some persisting that requires that we have
persistent storage.  If the persistent storage does not exist, then the
networking config will get lost after a reboot.  In the case of a
failure in the storage configuration, we just want the networking up and
running so that it can be debugged.  The duplication of code in this
case is minimal since it is simply a function call.  

We also can't just pull the networking piece out and call it after
everything else since other parts of the auto-installation process
depend on networking.

The right solution may be to break up the ovirt_auto_install.py script
and do something like:

storage_auto
  check for failure

run networking regardless of storage status
  check for failure

if either storage or networking failed, don't run anything else

if they didn't fail, run other automated setup and check for errors on
each

exit successfully if all steps passed, otherwise fail



> in scripts/ovirt-auto-install.py
> ....
> import os
> import sys
> from ovirtnode.ovirtfunctions import *
> from ovirtnode.storage import *
> from ovirtnode.install import *
> from ovirtnode.network import *
> from ovirtnode.log import *
> from ovirtnode.kdump import *
> from ovirtnode.snmp import *
> from ovirt_config_setup.collectd import *
> 
> # store /etc/shadow if adminpw/rootpw are set, handled already in
> ovirt-early
>     file = open("/proc/cmdline")
>     args = file.read()
>     if "adminpw" in args or "rootpw" in args:
>         print "Storing /etc/shadow"
>         ovirt_store_config("/etc/passwd")
>         ovirt_store_config("/etc/shadow")
>     file.close()
>     # network configuration
>     print "Configuring Network"
>     if OVIRT_VARS["OVIRT_BOOTIF"] != "":
>         network_auto()
> 
>     if OVIRT_VARS.has_key("OVIRT_HOSTNAME"):
>         system("hostname %s" % OVIRT_VARS["OVIRT_HOSTNAME"])
>     #set ssh_passwd_auth
>     if OVIRT_VARS.has_key("OVIRT_SSH_PWAUTH"):
>         if self.ssh_passwd_status.value() == 1:
> 
> augtool("set","/files/etc/ssh/sshd_config/PasswordAuthentication",
> "yes")
>         elif self.ssh_passwd_status.value() == 0:
> 
> augtool("set","/files/etc/ssh/sshd_config/PasswordAuthentication",
> "no")
> print "Performing automatic disk partitioning"
> if storage_auto():
>     # iscsi handled in install.py
>     print "Configuring Logging"
>     logging_auto()
>     print "Configuring Collectd"
>     collectd_auto()
>     install = Install()
>     print "Configuring KDump"
>     kdump_auto()
>     print "Configuring SNMP"
>     snmp_auto()
>     ... ...
> else 
>     print "Automatic installation failed. Please
> review /tmp/ovirt.log"
>     sys.exit(1)
> 
> -- 
> best regards
> eli
> _______________________________________________
> node-devel mailing list
> node-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/node-devel





More information about the node-devel mailing list