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

« back to all changes in this revision

Viewing changes to actions/git_reinstall.py

  • Committer: Liam Young
  • Date: 2014-06-18 10:36:43 UTC
  • Revision ID: liam.young@canonical.com-20140618103643-j0vgz5vz300fz1ag
Added hooks unit tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
import sys
3
 
import traceback
4
 
 
5
 
sys.path.append('hooks/')
6
 
 
7
 
from charmhelpers.contrib.openstack.utils import (
8
 
    git_install_requested,
9
 
)
10
 
 
11
 
from charmhelpers.core.hookenv import (
12
 
    action_set,
13
 
    action_fail,
14
 
    config,
15
 
)
16
 
 
17
 
from neutron_api_utils import (
18
 
    git_install,
19
 
)
20
 
 
21
 
from neutron_api_hooks import (
22
 
    config_changed,
23
 
)
24
 
 
25
 
 
26
 
def git_reinstall():
27
 
    """Reinstall from source and restart services.
28
 
 
29
 
    If the openstack-origin-git config option was used to install openstack
30
 
    from source git repositories, then this action can be used to reinstall
31
 
    from updated git repositories, followed by a restart of services."""
32
 
    if not git_install_requested():
33
 
        action_fail('openstack-origin-git is not configured')
34
 
        return
35
 
 
36
 
    try:
37
 
        git_install(config('openstack-origin-git'))
38
 
        config_changed()
39
 
    except:
40
 
        action_set({'traceback': traceback.format_exc()})
41
 
        action_fail('git-reinstall resulted in an unexpected error')
42
 
 
43
 
 
44
 
if __name__ == '__main__':
45
 
    git_reinstall()