Upgrade Openstack release if available

If there is a new release of the aodh packages available due
to the user changing the 'openstack-origin' option then upgrade
the packages.

Change-Id: Ib3add07c19768a88ec074e0e485e7b77f7a2f87d
Closes-Bug: 1632760
This commit is contained in:
Liam Young 2016-10-12 16:36:44 +00:00
parent 2eab39672c
commit 7d4d259117
3 changed files with 23 additions and 0 deletions

View File

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import collections
import os import os
import subprocess import subprocess
@ -95,6 +96,15 @@ class AodhCharm(charms_openstack.charm.HAOpenStackCharm):
# NOTE: review this seems odd as not doing anything off piste here # NOTE: review this seems odd as not doing anything off piste here
adapters_class = AodhAdapters adapters_class = AodhAdapters
release_pkg = 'aodh-common'
package_codenames = {
'aodh-common': collections.OrderedDict([
('2', 'mitaka'),
('3', 'newton'),
('4', 'ocata'),
]),
}
def __init__(self, release=None, **kwargs): def __init__(self, release=None, **kwargs):
"""Custom initialiser for class """Custom initialiser for class
If no release is passed, then the charm determines the release from the If no release is passed, then the charm determines the release from the
@ -171,6 +181,15 @@ def configure_ssl():
AodhCharm.singleton.configure_ssl() AodhCharm.singleton.configure_ssl()
def upgrade_if_available(interfaces_list):
"""Just call the AodhCharm.singleton.upgrade_if_available() command to
update OpenStack package if upgrade is available
@returns: None
"""
AodhCharm.singleton.upgrade_if_available(interfaces_list)
# TODO: drop once charm switches to apache+mod_wsgi # TODO: drop once charm switches to apache+mod_wsgi
def reload_and_restart(): def reload_and_restart():
"""Reload systemd and restart aodh-api when override file changes """Reload systemd and restart aodh-api when override file changes

View File

@ -71,6 +71,7 @@ def render(*args):
@reactive.when_not('cluster.available') @reactive.when_not('cluster.available')
@reactive.when(*MINIMAL_INTERFACES) @reactive.when(*MINIMAL_INTERFACES)
def render_unclustered(*args): def render_unclustered(*args):
aodh.upgrade_if_available(args)
aodh.configure_ssl() aodh.configure_ssl()
render(*args) render(*args)
@ -79,6 +80,7 @@ def render_unclustered(*args):
@reactive.when('cluster.available', @reactive.when('cluster.available',
*MINIMAL_INTERFACES) *MINIMAL_INTERFACES)
def render_clustered(*args): def render_clustered(*args):
aodh.upgrade_if_available(args)
render(*args) render(*args)

View File

@ -168,7 +168,9 @@ class TestAodhHandlers(unittest.TestCase):
self.patch(handlers.aodh, 'render_configs') self.patch(handlers.aodh, 'render_configs')
self.patch(handlers.aodh, 'assess_status') self.patch(handlers.aodh, 'assess_status')
self.patch(handlers.aodh, 'configure_ssl') self.patch(handlers.aodh, 'configure_ssl')
self.patch(handlers.aodh, 'upgrade_if_available')
handlers.render_unclustered('arg1', 'arg2') handlers.render_unclustered('arg1', 'arg2')
self.render_configs.assert_called_once_with(('arg1', 'arg2', )) self.render_configs.assert_called_once_with(('arg1', 'arg2', ))
self.assess_status.assert_called_once() self.assess_status.assert_called_once()
self.configure_ssl.assert_called_once() self.configure_ssl.assert_called_once()
self.upgrade_if_available.assert_called_once_with(('arg1', 'arg2', ))