~felipe-alfaro-gmail/charms/xenial/neutron-api/trunk

« back to all changes in this revision

Viewing changes to actions/git_reinstall.py

  • Committer: Felipe Alfaro Solana
  • Date: 2017-04-05 19:45:40 UTC
  • Revision ID: felipe.alfaro@gmail.com-20170405194540-85i0nhnp98ipob0y
Neutron API charm.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
#
 
3
# Copyright 2016 Canonical Ltd
 
4
#
 
5
# Licensed under the Apache License, Version 2.0 (the "License");
 
6
# you may not use this file except in compliance with the License.
 
7
# You may obtain a copy of the License at
 
8
#
 
9
#  http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
# Unless required by applicable law or agreed to in writing, software
 
12
# distributed under the License is distributed on an "AS IS" BASIS,
 
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
# See the License for the specific language governing permissions and
 
15
# limitations under the License.
 
16
 
 
17
import sys
 
18
import traceback
 
19
 
 
20
sys.path.append('hooks/')
 
21
 
 
22
from charmhelpers.contrib.openstack.utils import (
 
23
    git_install_requested,
 
24
)
 
25
 
 
26
from charmhelpers.core.hookenv import (
 
27
    action_set,
 
28
    action_fail,
 
29
    config,
 
30
)
 
31
 
 
32
from neutron_api_utils import (
 
33
    git_install,
 
34
)
 
35
 
 
36
from neutron_api_hooks import (
 
37
    config_changed,
 
38
)
 
39
 
 
40
 
 
41
def git_reinstall():
 
42
    """Reinstall from source and restart services.
 
43
 
 
44
    If the openstack-origin-git config option was used to install openstack
 
45
    from source git repositories, then this action can be used to reinstall
 
46
    from updated git repositories, followed by a restart of services."""
 
47
    if not git_install_requested():
 
48
        action_fail('openstack-origin-git is not configured')
 
49
        return
 
50
 
 
51
    try:
 
52
        git_install(config('openstack-origin-git'))
 
53
        config_changed()
 
54
    except:
 
55
        action_set({'traceback': traceback.format_exc()})
 
56
        action_fail('git-reinstall resulted in an unexpected error')
 
57
 
 
58
 
 
59
if __name__ == '__main__':
 
60
    git_reinstall()