Implement multiple rq file support, add global logs_days parameter
This commit is contained in:
parent
5325eb6e00
commit
09450b6bd5
7
rq/neutron.yaml
Normal file
7
rq/neutron.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
files:
|
||||
__default:
|
||||
- '/etc/neutron'
|
||||
logs:
|
||||
__default:
|
||||
path: '/var/log'
|
||||
include: 'neutron'
|
13
rq/nova.yaml
Normal file
13
rq/nova.yaml
Normal 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)'
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -16,7 +16,7 @@
|
||||
# under the License.
|
||||
|
||||
project_name = 'timmy'
|
||||
version = '1.11.1'
|
||||
version = '1.12.0'
|
||||
|
||||
if __name__ == '__main__':
|
||||
exit(0)
|
||||
|
@ -325,8 +325,11 @@ class Node(object):
|
||||
re.search(item['exclude'], string)))
|
||||
|
||||
for item in self.logs:
|
||||
start_str = ''
|
||||
if 'start' in item:
|
||||
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]):
|
||||
@ -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,14 +561,21 @@ class NodeManager(object):
|
||||
else:
|
||||
dst[k][attr] = el[k]
|
||||
|
||||
dst = self.conf
|
||||
src = tools.load_yaml_file(self.conf['rqfile'])
|
||||
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
|
||||
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']:
|
||||
self.logger.critical('NodeManager: fuel_ip not set')
|
||||
|
Loading…
x
Reference in New Issue
Block a user