Adding plumgrid db manage command in order to register changes between neutron and pg

This commit is contained in:
Hassaan Pasha 2016-03-28 19:01:24 +02:00
parent 885d0337f2
commit a27550c360
2 changed files with 12 additions and 1 deletions

View File

@ -30,6 +30,7 @@ from neutron_plumgrid_utils import (
register_configs,
restart_map,
ensure_files,
migrate_neutron_db,
)
hooks = Hooks()
@ -47,6 +48,7 @@ def install():
for pkg in pkgs:
apt_install(pkg, options=['--force-yes'], fatal=True)
ensure_files()
migrate_neutron_db()
@hooks.hook('config-changed')

View File

@ -17,7 +17,7 @@ from charmhelpers.core.hookenv import (
from charmhelpers.contrib.openstack.utils import (
os_release,
)
import subprocess
import neutron_plumgrid_context
TEMPLATES = 'templates/'
@ -124,3 +124,12 @@ def install_networking_plumgrid():
package_version = config('networking-plumgrid-version')
package_name = 'networking-plumgrid==%s' % package_version
pip_install(package_name, fatal=True)
def migrate_neutron_db():
release = os_release('neutron-common', base='kilo')
if release == 'liberty':
cmd = ['neutron-db-manage', 'upgrade', 'head']
elif release == 'kilo':
cmd = ['plumgrid-db-manage', 'upgrade', 'head']
subprocess.check_output(cmd)