From 6c74c3e3df2a064c09337dc271da928d5d3c9523 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Thu, 27 Jun 2013 09:31:40 -0500 Subject: Chkconfig: Use get_bootstatus The get_bootstatus method has the correct logic to get the desired result when bootstatus is unset. Signed-off-by: Sol Jerome --- src/lib/Bcfg2/Client/Tools/Chkconfig.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lib/Bcfg2/Client') diff --git a/src/lib/Bcfg2/Client/Tools/Chkconfig.py b/src/lib/Bcfg2/Client/Tools/Chkconfig.py index 156f76159..ac874c94c 100644 --- a/src/lib/Bcfg2/Client/Tools/Chkconfig.py +++ b/src/lib/Bcfg2/Client/Tools/Chkconfig.py @@ -85,16 +85,16 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool): """Install Service entry.""" self.cmd.run("/sbin/chkconfig --add %s" % (entry.get('name'))) self.logger.info("Installing Service %s" % (entry.get('name'))) - bootstatus = entry.get('bootstatus') + bootstatus = self.get_bootstatus(entry) if bootstatus is not None: if bootstatus == 'on': # make sure service is enabled on boot bootcmd = '/sbin/chkconfig %s %s --level 0123456' % \ - (entry.get('name'), entry.get('bootstatus')) + (entry.get('name'), bootstatus) elif bootstatus == 'off': # make sure service is disabled on boot bootcmd = '/sbin/chkconfig %s %s' % (entry.get('name'), - entry.get('bootstatus')) + bootstatus) bootcmdrv = self.cmd.run(bootcmd).success if self.setup['servicemode'] == 'disabled': # 'disabled' means we don't attempt to modify running svcs -- cgit v1.2.3-1-g7c22 From aed992e317378569abfdc75e0da195e56445db19 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 28 Jun 2013 23:47:27 +0200 Subject: Revert "Avoid use of lxml-only getparent()" This reverts commit 38f55b6257ce51b1cf65ecb3d980d7528c1b53ff. --- src/lib/Bcfg2/Client/Frame.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/lib/Bcfg2/Client') diff --git a/src/lib/Bcfg2/Client/Frame.py b/src/lib/Bcfg2/Client/Frame.py index 6bef77081..edbc9f055 100644 --- a/src/lib/Bcfg2/Client/Frame.py +++ b/src/lib/Bcfg2/Client/Frame.py @@ -207,7 +207,12 @@ class Frame(object): # take care of important entries first if not self.dryrun: - for parent in self.config.findall(".//Path/.."): + for cfile in self.config.findall(".//Path"): + if (cfile.get('name') not in self.__important__ or + cfile.get('type') != 'file' or + cfile not in self.whitelist): + continue + parent = cfile.getparent() if ((parent.tag == "Bundle" and ((self.setup['bundle'] and parent.get("name") not in self.setup['bundle']) or @@ -216,15 +221,9 @@ class Frame(object): (parent.tag == "Independent" and (self.setup['bundle'] or self.setup['skipindep']))): continue - for cfile in parent.findall("./Path"): - if (cfile.get('name') not in self.__important__ or - cfile.get('type') != 'file' or - cfile not in self.whitelist): - continue - tools = [t for t in self.tools - if t.handlesEntry(cfile) and t.canVerify(cfile)] - if not tools: - continue + tools = [t for t in self.tools + if t.handlesEntry(cfile) and t.canVerify(cfile)] + if tools: if (self.setup['interactive'] and not self.promptFilter("Install %s: %s? (y/N):", [cfile])): self.whitelist.remove(cfile) -- cgit v1.2.3-1-g7c22 From c715a661fece0e2e561d4d62a27e9bdac212c54a Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 28 Jun 2013 23:48:45 +0200 Subject: Client/Frame: avoid use of lxml-only getparent() getparent is not supported by xml.etree so try to emulate it with a generated parent_map. This is the only possibility, because xml.etree does not store references to the parent elements. --- src/lib/Bcfg2/Client/Frame.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib/Bcfg2/Client') diff --git a/src/lib/Bcfg2/Client/Frame.py b/src/lib/Bcfg2/Client/Frame.py index edbc9f055..3254da9e9 100644 --- a/src/lib/Bcfg2/Client/Frame.py +++ b/src/lib/Bcfg2/Client/Frame.py @@ -207,12 +207,15 @@ class Frame(object): # take care of important entries first if not self.dryrun: + parent_map = dict((c, p) + for p in self.config.getiterator() + for c in p) for cfile in self.config.findall(".//Path"): if (cfile.get('name') not in self.__important__ or cfile.get('type') != 'file' or cfile not in self.whitelist): continue - parent = cfile.getparent() + parent = parent_map[cfile] if ((parent.tag == "Bundle" and ((self.setup['bundle'] and parent.get("name") not in self.setup['bundle']) or -- cgit v1.2.3-1-g7c22 From 2519c6dbbd49b06042b4f21f10c6fecfbf7e5230 Mon Sep 17 00:00:00 2001 From: Michael Fenn Date: Mon, 1 Jul 2013 16:08:59 -0400 Subject: New approach, just create nwe directories with mode 0755 regardless --- src/lib/Bcfg2/Client/Tools/POSIX/base.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/lib/Bcfg2/Client') diff --git a/src/lib/Bcfg2/Client/Tools/POSIX/base.py b/src/lib/Bcfg2/Client/Tools/POSIX/base.py index 16fe0acb5..3778569a6 100644 --- a/src/lib/Bcfg2/Client/Tools/POSIX/base.py +++ b/src/lib/Bcfg2/Client/Tools/POSIX/base.py @@ -706,16 +706,10 @@ class POSIXTool(Bcfg2.Client.Tools.Tool): (path, err)) rv = False - # we need to make sure that we give +x to everyone who needs - # it. E.g., if the file that's been distributed is 0600, we - # can't make the parent directories 0600 also; that'd be - # pretty useless. They need to be 0700. + # set auto-created directories to mode 755, if you need + # something else, you should specify it in your config tmpentry = copy.deepcopy(entry) - newmode = int(entry.get('mode'), 8) - for i in range(0, 3): - if newmode & (6 * pow(8, i)): - newmode |= 1 * pow(8, i) - tmpentry.set('mode', oct_mode(newmode)) + tmpentry.set('mode', '0755') for acl in tmpentry.findall('ACL'): acl.set('perms', oct_mode(self._norm_acl_perms(acl.get('perms')) | -- cgit v1.2.3-1-g7c22 From 7ff54957090ddbc788f415dccb3e3c20ea1a301e Mon Sep 17 00:00:00 2001 From: Michael Fenn Date: Tue, 2 Jul 2013 15:04:12 -0400 Subject: Chkconfig: give --list option to chkconfig rather than sending it on stdin --- src/lib/Bcfg2/Client/Tools/Chkconfig.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/Bcfg2/Client') diff --git a/src/lib/Bcfg2/Client/Tools/Chkconfig.py b/src/lib/Bcfg2/Client/Tools/Chkconfig.py index ac874c94c..edcc86b85 100644 --- a/src/lib/Bcfg2/Client/Tools/Chkconfig.py +++ b/src/lib/Bcfg2/Client/Tools/Chkconfig.py @@ -116,8 +116,8 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool): def FindExtra(self): """Locate extra chkconfig Services.""" allsrv = [line.split()[0] - for line in self.cmd.run("/sbin/chkconfig", - "--list").stdout.splitlines() + for line in + self.cmd.run("/sbin/chkconfig --list").stdout.splitlines() if ":on" in line] self.logger.debug('Found active services:') self.logger.debug(allsrv) -- cgit v1.2.3-1-g7c22 From a0f20bdde06ccb7be85f59e1b8fbf57e1c492e64 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Tue, 2 Jul 2013 15:55:55 -0500 Subject: RcUpdate: Use get_bootstatus Signed-off-by: Sol Jerome --- src/lib/Bcfg2/Client/Tools/RcUpdate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/Bcfg2/Client') diff --git a/src/lib/Bcfg2/Client/Tools/RcUpdate.py b/src/lib/Bcfg2/Client/Tools/RcUpdate.py index 8e9626521..e0c913dcd 100644 --- a/src/lib/Bcfg2/Client/Tools/RcUpdate.py +++ b/src/lib/Bcfg2/Client/Tools/RcUpdate.py @@ -89,7 +89,7 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): def InstallService(self, entry): """Install Service entry.""" self.logger.info('Installing Service %s' % entry.get('name')) - bootstatus = entry.get('bootstatus') + bootstatus = self.get_bootstatus(entry) if bootstatus is not None: if bootstatus == 'on': # make sure service is enabled on boot -- cgit v1.2.3-1-g7c22