Merge "Create the neutron-sanity-check validations"
This commit is contained in:
commit
a09ef43474
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import subprocess
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from os import path
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(argument_spec=dict(
|
||||
configs=dict(required=True, type='list'),
|
||||
))
|
||||
|
||||
# Input configurations as a list
|
||||
i_config = module.params.get('configs')
|
||||
|
||||
# Arguments as a list contianing only existing files/dirs
|
||||
o_config = []
|
||||
|
||||
# Create arguments
|
||||
o_config.append('neutron-sanity-check')
|
||||
o_config.append("--nodnsmasq_version")
|
||||
|
||||
for c in i_config:
|
||||
if path.isfile(c):
|
||||
o_config.append('--config-file')
|
||||
o_config.append(c)
|
||||
elif path.isdir(c):
|
||||
o_config.append('--config-dir')
|
||||
o_config.append(c)
|
||||
|
||||
# Execute neutron-sanity-check, fetch stdout, stderr
|
||||
# neutron-sanity-check --nodnsmasq_version $ARGS
|
||||
process = subprocess.Popen(o_config, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
|
||||
# Filter warnings and errors - neutron-sanity-checks puts it all to stderr
|
||||
output = stderr.split('\n')
|
||||
o_warnings = []
|
||||
o_errors = ""
|
||||
for line in output:
|
||||
if 'WARNING' in line:
|
||||
o_warnings.append(line.split('WARNING')[1])
|
||||
elif 'ERROR' in line:
|
||||
o_errors += line.split('ERROR')[1] + "\n"
|
||||
|
||||
# Based on stdout and stderr, exit module
|
||||
if o_errors:
|
||||
module.fail_json(msg=o_errors, warnings=o_warnings, changed=True)
|
||||
else:
|
||||
module.exit_json(warnings=o_warnings, changed=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
- hosts: controller
|
||||
vars:
|
||||
metadata:
|
||||
name: Neutron Sanity Check
|
||||
description: >
|
||||
Run `neutron-sanity-check` on the controller nodes to find out
|
||||
potential issues with Neutron's configuration.
|
||||
|
||||
The tool expects all the configuration files that are passed
|
||||
to the Neutron services.
|
||||
|
||||
groups:
|
||||
- post-deployment
|
||||
|
||||
# The list of Neutron configuration files and directories that
|
||||
# will be passed to the Neutron services. The order is important
|
||||
# here: the values in later files take precedence.
|
||||
configs:
|
||||
- /etc/neutron/neutron.conf
|
||||
- /usr/share/neutron/neutron-dist.conf
|
||||
- /etc/neutron/metadata_agent.ini
|
||||
- /etc/neutron/metering_agent.ini
|
||||
- /etc/neutron/dhcp_agent.ini
|
||||
- /etc/neutron/plugins/ml2/openvswitch_agent.ini
|
||||
- /etc/neutron/conf.d/ml2_conf_cisco.ini
|
||||
- /etc/neutron/conf.d/cisco_cfg_agent.ini
|
||||
- /etc/neutron/conf.d/cisco_router_plugin.ini
|
||||
- /usr/share/neutron/l3_agent
|
||||
- /etc/neutron/conf.d/common
|
||||
- /etc/neutron/conf.d/neutron-l3-agent
|
||||
- /usr/share/neutron/neutron-lbaas-dist.conf
|
||||
- /etc/neutron/lbaas_agent.ini
|
||||
- /etc/neutron/conf.d/neutron-lbaas-agent
|
||||
- /etc/neutron/conf.d/neutron-lbaasv2-agent
|
||||
- /etc/neutron/conf.d/neutron-metadata-agent
|
||||
- /etc/neutron/conf.d/neutron-metering-agent
|
||||
- /etc/neutron/conf.d/neutron-netns-cleanup
|
||||
- /etc/neutron/conf.d/neutron-openvswitch-agent
|
||||
- /etc/neutron/conf.d/neutron-ovs-cleanup
|
||||
- /etc/neutron/conf.d/neutron-bsn-agent
|
||||
- /etc/neutron/conf.d/neutron-cisco-cfg-agent
|
||||
- /etc/neutron/conf.d/neutron-dhcp-agent
|
||||
|
||||
tasks:
|
||||
- name: Run neutron-sanity-check
|
||||
become: true
|
||||
neutron_sanity_check: configs={{ configs }}
|
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
- hosts: undercloud
|
||||
vars:
|
||||
metadata:
|
||||
name: Undercloud Neutron Sanity Check
|
||||
description: >
|
||||
Run `neutron-sanity-check` on the undercloud node to find out
|
||||
potential issues with Neutron's configuration.
|
||||
|
||||
The tool expects all the configuration files that are passed
|
||||
to the Neutron services.
|
||||
|
||||
groups:
|
||||
- pre-introspection
|
||||
|
||||
# The list of Neutron configuration files and directories that
|
||||
# will be passed to the Neutron services. The order is important
|
||||
# here: the values in later files take precedence.
|
||||
configs:
|
||||
- /etc/neutron/neutron.conf
|
||||
- /usr/share/neutron/neutron-dist.conf
|
||||
- /etc/neutron/metadata_agent.ini
|
||||
- /etc/neutron/metering_agent.ini
|
||||
- /etc/neutron/dhcp_agent.ini
|
||||
- /etc/neutron/plugins/ml2/openvswitch_agent.ini
|
||||
- /etc/neutron/conf.d/ml2_conf_cisco.ini
|
||||
- /etc/neutron/conf.d/cisco_cfg_agent.ini
|
||||
- /etc/neutron/conf.d/cisco_router_plugin.ini
|
||||
- /usr/share/neutron/l3_agent
|
||||
- /etc/neutron/conf.d/common
|
||||
- /etc/neutron/conf.d/neutron-l3-agent
|
||||
- /usr/share/neutron/neutron-lbaas-dist.conf
|
||||
- /etc/neutron/lbaas_agent.ini
|
||||
- /etc/neutron/conf.d/neutron-lbaas-agent
|
||||
- /etc/neutron/conf.d/neutron-lbaasv2-agent
|
||||
- /etc/neutron/conf.d/neutron-metadata-agent
|
||||
- /etc/neutron/conf.d/neutron-metering-agent
|
||||
- /etc/neutron/conf.d/neutron-netns-cleanup
|
||||
- /etc/neutron/conf.d/neutron-openvswitch-agent
|
||||
- /etc/neutron/conf.d/neutron-ovs-cleanup
|
||||
- /etc/neutron/conf.d/neutron-bsn-agent
|
||||
- /etc/neutron/conf.d/neutron-cisco-cfg-agent
|
||||
- /etc/neutron/conf.d/neutron-dhcp-agent
|
||||
|
||||
tasks:
|
||||
- name: Run neutron-sanity-check
|
||||
become: true
|
||||
neutron_sanity_check: configs={{ configs }}
|
Loading…
Reference in New Issue