Implement multiple rq file support, add global logs_days parameter

This commit is contained in:
f3flight 2016-08-02 11:10:41 +00:00
parent 5325eb6e00
commit 09450b6bd5
6 changed files with 49 additions and 14 deletions

7
rq/neutron.yaml Normal file
View File

@ -0,0 +1,7 @@
files:
__default:
- '/etc/neutron'
logs:
__default:
path: '/var/log'
include: 'neutron'

13
rq/nova.yaml Normal file
View File

@ -0,0 +1,13 @@
files:
__default:
- '/etc/nova'
- '/etc/libvirt'
scripts:
controller:
- nova-list
- nova-service-list
- nova-usage-list
logs:
__default:
path: '/var/log'
include: '(nova|libvirt|qemu)'

View File

@ -98,7 +98,7 @@ def parse_args():
' these parameters. Values except path can be'
' skipped by passing empty strings. Example: -L'
' "/var/mylogs/" "" "exclude-string"'))
parser.add_argument('--rqfile', metavar='PATH',
parser.add_argument('--rqfile', metavar='PATH', action='append',
help=('Path to an rqfile in yaml format, overrides'
' default.'))
parser.add_argument('-l', '--logs',
@ -206,6 +206,7 @@ def main(argv=None):
conf['rqfile'] = args.rqfile
if args.days:
conf['logs'][0]['start'] = args.days
conf['logs_days'] = args.days
if args.logs_no_default:
conf['logs'] = []
args.logs = True

View File

@ -61,8 +61,8 @@ def load_conf(filename):
conf['files'] = []
conf['filelists'] = []
conf['logs'] = [{'path': '/var/log',
'exclude': '\.[^12]\.gz$|\.\d{2,}\.gz$',
'start': '30'}]
'exclude': '\.[^12]\.gz$|\.\d{2,}\.gz$'}]
conf['logs_days'] = 30
'''Shell mode - only run what was specified via command line.
Skip actionable conf fields (see timmy/nodes.py -> Node.conf_actionable);
Skip rqfile import;

View File

@ -16,7 +16,7 @@
# under the License.
project_name = 'timmy'
version = '1.11.1'
version = '1.12.0'
if __name__ == '__main__':
exit(0)

View File

@ -325,9 +325,12 @@ class Node(object):
re.search(item['exclude'], string)))
for item in self.logs:
start_str = ''
if 'start' in item:
start = item['start']
start_str = None
if 'start' in item or hasattr(self,'logs_days'):
if hasattr(self, 'logs_days') and 'start' not in item:
start = self.logs_days
else:
start = item['start']
if any([type(start) is str and re.match(r'-?\d+', start),
type(start) is int]):
days = abs(int(str(start)))
@ -535,7 +538,11 @@ class NodeManager(object):
dst[k] = {}
if d in el[k]:
if k == attr:
dst[k] = el[k][d]
if k in Node.conf_appendable:
dst[k] = w_list(dst[k])
dst[k] += w_list(el[k][d])
else:
dst[k] = w_list(el[k][d])
elif k.startswith(p) or k.startswith(once_p):
dst[k][d] = {attr: el[k][d]}
else:
@ -554,13 +561,20 @@ class NodeManager(object):
else:
dst[k][attr] = el[k]
def merge_rq(rqfile, dst):
src = tools.load_yaml_file(rqfile)
p = Node.conf_match_prefix
once_p = Node.conf_once_prefix + p
d = Node.conf_default_key
for attr in src:
r_sub(attr, src, attr, d, p, once_p, dst)
dst = self.conf
src = tools.load_yaml_file(self.conf['rqfile'])
p = Node.conf_match_prefix
once_p = Node.conf_once_prefix + p
d = Node.conf_default_key
for attr in src:
r_sub(attr, src, attr, d, p, once_p, dst)
if type(self.conf['rqfile']) is list:
for rqfile in self.conf['rqfile']:
merge_rq(rqfile, dst)
else:
merge_rq(self.conf['rqfile'], dst)
def fuel_init(self):
if not self.conf['fuel_ip']: