~ionutbalutoiu/charms/trusty/neutron-api/next

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python
import sys
import traceback

sys.path.append('hooks/')

from charmhelpers.contrib.openstack.utils import (
    git_install_requested,
)

from charmhelpers.core.hookenv import (
    action_set,
    action_fail,
    config,
)

from neutron_api_utils import (
    git_install,
)

from neutron_api_hooks import (
    config_changed,
)


def git_reinstall():
    """Reinstall from source and restart services.

    If the openstack-origin-git config option was used to install openstack
    from source git repositories, then this action can be used to reinstall
    from updated git repositories, followed by a restart of services."""
    if not git_install_requested():
        action_fail('openstack-origin-git is not configured')
        return

    try:
        git_install(config('openstack-origin-git'))
        config_changed()
    except:
        action_set({'traceback': traceback.format_exc()})
        action_fail('git-reinstall resulted in an unexpected error')


if __name__ == '__main__':
    git_reinstall()