system-config/tools/check_clouds_yaml.py
Clark Boylan ffcd1791bf Cleanup nodepool builder clouds.yaml
We ended up running into a problem with nodepool built control plane
images (has to do with boot from volume not allowing us to delete images
that are in use by a nova instance). We have decided to clean this up
and go back to not doing this until we can do it more properly.

Note this isn't a revert because having a group for access to control
plane clouds does seem like a good idea in general and I believe there
have been changes we'd have to resolve in the clouds.yaml files anyway.

Depends-On: https://review.opendev.org/#/c/665012/
Change-Id: I5e72928ec2dec37afa9c8567eff30eb6e9c04f1d
2019-07-22 13:55:29 -07:00

59 lines
1.8 KiB
Python

#! /usr/bin/env python
# Copyright 2018 Red Hat
#
# 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 os
import openstack
import re
import sys
import tempfile
FILES_TO_CHECK = (
'playbooks/templates/clouds/nodepool_clouds.yaml.j2',
'playbooks/templates/clouds/bridge_all_clouds.yaml.j2',
'playbooks/templates/clouds/bridge_clouds.yaml.j2',
)
def check_files():
with tempfile.TemporaryDirectory() as tempdir:
for file in FILES_TO_CHECK:
# These are actually erb files that have templating in
# them, we just rewrite them with a string in there for
# the parser to read, as the <>'s can confuse yaml
# depending on how they're quoted in the file
temp = open(os.path.join(tempdir,
os.path.basename(file)), 'w')
in_file = open(file, 'r')
for line in in_file:
line = re.sub(r'{{.*}}', 'loremipsum', line)
temp.write(line)
temp.close()
try:
print("Checking parsing of %s" % file)
c = openstack.config.OpenStackConfig(config_files=[temp.name])
except Exception as e:
print("Error parsing : %s" % file)
print(e)
sys.exit(1)
def main():
check_files()
if __name__ == "__main__":
sys.exit(main())