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'
|
' these parameters. Values except path can be'
|
||||||
' skipped by passing empty strings. Example: -L'
|
' skipped by passing empty strings. Example: -L'
|
||||||
' "/var/mylogs/" "" "exclude-string"'))
|
' "/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'
|
help=('Path to an rqfile in yaml format, overrides'
|
||||||
' default.'))
|
' default.'))
|
||||||
parser.add_argument('-l', '--logs',
|
parser.add_argument('-l', '--logs',
|
||||||
@ -206,6 +206,7 @@ def main(argv=None):
|
|||||||
conf['rqfile'] = args.rqfile
|
conf['rqfile'] = args.rqfile
|
||||||
if args.days:
|
if args.days:
|
||||||
conf['logs'][0]['start'] = args.days
|
conf['logs'][0]['start'] = args.days
|
||||||
|
conf['logs_days'] = args.days
|
||||||
if args.logs_no_default:
|
if args.logs_no_default:
|
||||||
conf['logs'] = []
|
conf['logs'] = []
|
||||||
args.logs = True
|
args.logs = True
|
||||||
|
@ -61,8 +61,8 @@ def load_conf(filename):
|
|||||||
conf['files'] = []
|
conf['files'] = []
|
||||||
conf['filelists'] = []
|
conf['filelists'] = []
|
||||||
conf['logs'] = [{'path': '/var/log',
|
conf['logs'] = [{'path': '/var/log',
|
||||||
'exclude': '\.[^12]\.gz$|\.\d{2,}\.gz$',
|
'exclude': '\.[^12]\.gz$|\.\d{2,}\.gz$'}]
|
||||||
'start': '30'}]
|
conf['logs_days'] = 30
|
||||||
'''Shell mode - only run what was specified via command line.
|
'''Shell mode - only run what was specified via command line.
|
||||||
Skip actionable conf fields (see timmy/nodes.py -> Node.conf_actionable);
|
Skip actionable conf fields (see timmy/nodes.py -> Node.conf_actionable);
|
||||||
Skip rqfile import;
|
Skip rqfile import;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
project_name = 'timmy'
|
project_name = 'timmy'
|
||||||
version = '1.11.1'
|
version = '1.12.0'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
exit(0)
|
exit(0)
|
||||||
|
@ -325,9 +325,12 @@ class Node(object):
|
|||||||
re.search(item['exclude'], string)))
|
re.search(item['exclude'], string)))
|
||||||
|
|
||||||
for item in self.logs:
|
for item in self.logs:
|
||||||
start_str = ''
|
start_str = None
|
||||||
if 'start' in item:
|
if 'start' in item or hasattr(self,'logs_days'):
|
||||||
start = item['start']
|
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),
|
if any([type(start) is str and re.match(r'-?\d+', start),
|
||||||
type(start) is int]):
|
type(start) is int]):
|
||||||
days = abs(int(str(start)))
|
days = abs(int(str(start)))
|
||||||
@ -535,7 +538,11 @@ class NodeManager(object):
|
|||||||
dst[k] = {}
|
dst[k] = {}
|
||||||
if d in el[k]:
|
if d in el[k]:
|
||||||
if k == attr:
|
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):
|
elif k.startswith(p) or k.startswith(once_p):
|
||||||
dst[k][d] = {attr: el[k][d]}
|
dst[k][d] = {attr: el[k][d]}
|
||||||
else:
|
else:
|
||||||
@ -554,13 +561,20 @@ class NodeManager(object):
|
|||||||
else:
|
else:
|
||||||
dst[k][attr] = el[k]
|
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
|
dst = self.conf
|
||||||
src = tools.load_yaml_file(self.conf['rqfile'])
|
if type(self.conf['rqfile']) is list:
|
||||||
p = Node.conf_match_prefix
|
for rqfile in self.conf['rqfile']:
|
||||||
once_p = Node.conf_once_prefix + p
|
merge_rq(rqfile, dst)
|
||||||
d = Node.conf_default_key
|
else:
|
||||||
for attr in src:
|
merge_rq(self.conf['rqfile'], dst)
|
||||||
r_sub(attr, src, attr, d, p, once_p, dst)
|
|
||||||
|
|
||||||
def fuel_init(self):
|
def fuel_init(self):
|
||||||
if not self.conf['fuel_ip']:
|
if not self.conf['fuel_ip']:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user