Version specific install of packages enabled
This commit is contained in:
parent
84d3e09c0c
commit
5d8e7c4e1b
|
@ -11,3 +11,8 @@ options:
|
|||
default: null
|
||||
type: string
|
||||
description: Provide the respective keys of the install sources
|
||||
plumgrid-build:
|
||||
default: 'latest'
|
||||
type: string
|
||||
description: |
|
||||
Provide the build version of PLUMgrid packages that needs to be installed
|
||||
|
|
|
@ -42,7 +42,9 @@ def install():
|
|||
'''
|
||||
configure_sources()
|
||||
apt_update()
|
||||
apt_install(determine_packages(), options=['--force-yes'], fatal=True)
|
||||
pkgs = determine_packages()
|
||||
for pkg in pkgs:
|
||||
apt_install(pkg, options=['--force-yes'], fatal=True)
|
||||
ensure_files()
|
||||
|
||||
|
||||
|
@ -55,7 +57,9 @@ def config_changed():
|
|||
stop()
|
||||
configure_sources()
|
||||
apt_update()
|
||||
apt_install(determine_packages(), options=['--force-yes'], fatal=True)
|
||||
pkgs = determine_packages()
|
||||
for pkg in pkgs:
|
||||
apt_install(pkg, options=['--force-yes'], fatal=True)
|
||||
ensure_files()
|
||||
CONFIGS.write_all()
|
||||
|
||||
|
|
|
@ -8,7 +8,12 @@ from copy import deepcopy
|
|||
import os
|
||||
from charmhelpers.contrib.openstack import templating
|
||||
from charmhelpers.contrib.python.packages import pip_install
|
||||
|
||||
from charmhelpers.fetch import (
|
||||
apt_cache
|
||||
)
|
||||
from charmhelpers.core.hookenv import (
|
||||
config,
|
||||
)
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
os_release,
|
||||
)
|
||||
|
@ -43,7 +48,21 @@ def determine_packages():
|
|||
Returns list of packages required to be installed alongside neutron to
|
||||
enable PLUMgrid in Openstack.
|
||||
'''
|
||||
return list(set(PG_PACKAGES))
|
||||
pkgs = []
|
||||
tag = config('plumgrid-build')
|
||||
for pkg in PG_PACKAGES:
|
||||
if tag == 'latest':
|
||||
pkgs.append(pkg)
|
||||
else:
|
||||
if tag in [i.ver_str for i in apt_cache()[pkg].version_list]:
|
||||
pkgs.append('%s=%s' % (pkg, tag))
|
||||
else:
|
||||
error_msg = \
|
||||
"Build version '%s' for package '%s' not available" \
|
||||
% (tag, pkg)
|
||||
raise ValueError(error_msg)
|
||||
# return list(set(PG_PACKAGES))
|
||||
return pkgs
|
||||
|
||||
|
||||
def resource_map():
|
||||
|
|
|
@ -24,6 +24,7 @@ TO_PATCH = [
|
|||
'CONFIGS',
|
||||
'ensure_files',
|
||||
'stop',
|
||||
'determine_packages',
|
||||
]
|
||||
NEUTRON_CONF_DIR = "/etc/neutron"
|
||||
|
||||
|
@ -42,6 +43,7 @@ class NeutronPGHooksTests(CharmTestCase):
|
|||
|
||||
def test_install_hook(self):
|
||||
_pkgs = ['plumgrid-pythonlib']
|
||||
self.determine_packages.return_value = [_pkgs]
|
||||
self._call_hook('install')
|
||||
self.configure_sources.assert_called_with()
|
||||
self.apt_update.assert_called_with()
|
||||
|
@ -53,6 +55,7 @@ class NeutronPGHooksTests(CharmTestCase):
|
|||
|
||||
def test_config_changed_hook(self):
|
||||
_pkgs = ['plumgrid-pythonlib']
|
||||
self.determine_packages.return_value = [_pkgs]
|
||||
self._call_hook('config-changed')
|
||||
self.stop.assert_called_with()
|
||||
self.configure_sources.assert_called_with()
|
||||
|
@ -75,7 +78,8 @@ class NeutronPGHooksTests(CharmTestCase):
|
|||
self.CONFIGS.write_all.assert_called_with()
|
||||
|
||||
def test_stop(self):
|
||||
_pkgs = 'plumgrid-pythonlib'
|
||||
_pkgs = ['plumgrid-pythonlib']
|
||||
self.determine_packages.return_value = [_pkgs]
|
||||
self._call_hook('stop')
|
||||
self.apt_purge.assert_has_calls([
|
||||
call(_pkgs, fatal=False)
|
||||
|
|
|
@ -36,11 +36,6 @@ class TestNeutronPGUtils(CharmTestCase):
|
|||
# Reset cached cache
|
||||
hookenv.cache = {}
|
||||
|
||||
def test_determine_packages(self):
|
||||
pkg_list = nutils.determine_packages()
|
||||
expect = ['plumgrid-pythonlib']
|
||||
self.assertItemsEqual(pkg_list, expect)
|
||||
|
||||
def test_register_configs(self):
|
||||
class _mock_OSConfigRenderer():
|
||||
def __init__(self, templates_dir=None, openstack_release=None):
|
||||
|
|
Loading…
Reference in New Issue