Skip to content

Instantly share code, notes, and snippets.

@goneri
Last active May 4, 2018 18:01
Show Gist options
  • Save goneri/e375b62d6e7b6e3621bceb40b768def1 to your computer and use it in GitHub Desktop.
Save goneri/e375b62d6e7b6e3621bceb40b768def1 to your computer and use it in GitHub Desktop.
convert os-net-config template to the new format (OSP10 to OSP13)
#!/bin/env python
import argparse
import yaml
parser = argparse.ArgumentParser()
parser.add_argument('old_template', type=open, help='The old NIC template')
ns = parser.parse_args()
data = yaml.load(ns.old_template.read())
osnetcfgimpt = data['resources']['OsNetConfigImpl']
osnetcfgimpt['type'] = 'OS::Heat::SoftwareConfig'
osnetcfgimpt['properties']['group'] = 'script'
old_config = osnetcfgimpt['properties']['config']['os_net_config']['network_config']
osnetcfgimpt['properties']['config'] = {
'str_replace': {
'template': {
'get_file': '/usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh'},
'params': {
'$network_config': {
'network_config': old_config}}}}
print(yaml.dump(data, Dumper=yaml.CDumper))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment