On 09.04.2012 [22:14:32 -0700], Nishanth Aravamudan wrote:
> Hi Lucas,
> 
> On 10.04.2012 [01:59:38 -0300], Lucas Meneghel Rodrigues wrote:
> > On Mon, 2012-04-09 at 19:22 -0700, Nishanth Aravamudan wrote:
> > > Recent Cobbler (as of 741faeafc4782ee66d7d1934a29b107602f1ebe9 in the
> > > Cobbler git tree) only writes dhcpd.conf entries for netboot-enabled
> > > systems. When we mark a system as netboot_enabled, therefore, we need to
> > > also ensure dhcpd is synchronized, and there is a new API for this
> > > purpose.
> > >     
> > > Signed-off-by: Nishanth Aravamudan <n...@us.ibm.com>
> > > 
> > > diff --git a/server/hosts/install_server.py 
> > > b/server/hosts/install_server.py
> > > index 5eb4ae3..2c70766 100644
> > > --- a/server/hosts/install_server.py
> > > +++ b/server/hosts/install_server.py
> > > @@ -97,6 +97,14 @@ class CobblerInterface(object):
> > >              # reinstalled)
> > >              self.server.modify_system(system_handle, 'netboot_enabled', 
> > > 'True',
> > >                                        self.token)
> > > +            try:
> > > +                # Cobbler only generates the DHCP configuration for 
> > > netboot enabled
> > > +                # machines, so we need to synchronize the dhcpd file 
> > > after changing
> > > +                # the value above
> > > +                self.server.sync_dhcp(self.token)
> > > +            except Exception:
> > 
> > ^ Ok, this could be rewritten as:
> > 
> >     except xmlrpclib.Fault, err:
> >             logging.error("DHCP reload failed, error code: %s, error 
> > string: %s", err.faultCode, err.faultString)
> > 
> > To make sure you ignore 'unknown remote method' error strings and not
> > other errors, you could do some verification of the faultString and act
> > accordingly.
> 
> Thanks for the feedback here and on IRC. I will update the patch in the
> morning.

How does this look?

server/install_host: synchronize dhcp after setting netboot_enabled
    
Recent Cobbler (as of 741faeafc4782ee66d7d1934a29b107602f1ebe9 in the
Cobbler git tree) only writes dhcpd.conf entries for netboot-enabled
systems. When we mark a system as netboot_enabled, therefore, we need to
also ensure dhcpd is synchronized, and there is a new API for this
purpose.
    
Signed-off-by: Nishanth Aravamudan <n...@us.ibm.com>

---
v2: be more specific in the exception handler and only handle the
unknown method Fault

diff --git a/server/hosts/install_server.py b/server/hosts/install_server.py
index 5eb4ae3..5d96bb9 100644
--- a/server/hosts/install_server.py
+++ b/server/hosts/install_server.py
@@ -97,6 +97,16 @@ class CobblerInterface(object):
             # reinstalled)
             self.server.modify_system(system_handle, 'netboot_enabled', 'True',
                                       self.token)
+            try:
+                # Cobbler only generates the DHCP configuration for netboot 
enabled
+                # machines, so we need to synchronize the dhcpd file after 
changing
+                # the value above
+                self.server.sync_dhcp(self.token)
+            except xmlrpclib.Fault, err:
+                # older Cobbler will not recognize the above command
+                if not "unknown remote method" in err.faultString:
+                    logging.error("DHCP sync failed, error code: %s, error 
string: %s",
+                                  err.faultCode, err.faultString)
             # Now, let's just restart the machine (machine has to have
             # power management data properly set up).
             self.server.save_system(system_handle, self.token)

-- 
Nishanth Aravamudan <n...@us.ibm.com>
IBM Linux Technology Center

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to