~openstack-charmers-archive/charms/trusty/neutron-gateway/trunk

« back to all changes in this revision

Viewing changes to hooks/neutron_hooks.py

  • Committer: James Page
  • Date: 2015-10-22 13:23:58 UTC
  • Revision ID: james.page@ubuntu.com-20151022132358-qin1nvlnqn4aezaz
Tags: 15.10
15.10 Charm release

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
    relation_set,
11
11
    relation_ids,
12
12
    unit_get,
13
 
    Hooks, UnregisteredHookError
 
13
    Hooks,
 
14
    UnregisteredHookError,
 
15
    status_set,
14
16
)
15
17
from charmhelpers.fetch import (
16
18
    apt_update,
34
36
    configure_installation_source,
35
37
    openstack_upgrade_available,
36
38
    os_requires_version,
 
39
    set_os_workload_status,
37
40
)
38
41
from charmhelpers.payload.execd import execd_preinstall
39
42
from charmhelpers.core.sysctl import create as create_sysctl
64
67
    reassign_agent_resources,
65
68
    stop_neutron_ha_monitor_daemon,
66
69
    use_l3ha,
 
70
    REQUIRED_INTERFACES,
 
71
    check_optional_relations,
67
72
)
68
73
 
69
74
hooks = Hooks()
70
75
CONFIGS = register_configs()
71
76
 
72
77
 
73
 
@hooks.hook('install')
 
78
@hooks.hook('install.real')
74
79
def install():
 
80
    status_set('maintenance', 'Executing pre-install')
75
81
    execd_preinstall()
76
82
    src = config('openstack-origin')
77
83
    if (lsb_release()['DISTRIB_CODENAME'] == 'precise' and
78
84
            src == 'distro'):
79
85
        src = 'cloud:precise-folsom'
80
86
    configure_installation_source(src)
 
87
    status_set('maintenance', 'Installing apt packages')
81
88
    apt_update(fatal=True)
82
89
    apt_install('python-six', fatal=True)  # Force upgrade
83
90
    if valid_plugin():
85
92
                    fatal=True)
86
93
        apt_install(filter_installed_packages(get_packages()),
87
94
                    fatal=True)
 
95
        status_set('maintenance', 'Git install')
88
96
        git_install(config('openstack-origin-git'))
89
97
    else:
90
 
        log('Please provide a valid plugin config', level=ERROR)
 
98
        message = 'Please provide a valid plugin config'
 
99
        log(message, level=ERROR)
 
100
        status_set('blocked', message)
91
101
        sys.exit(1)
92
102
 
93
103
    # Legacy HA for Icehouse
100
110
    global CONFIGS
101
111
    if git_install_requested():
102
112
        if config_value_changed('openstack-origin-git'):
 
113
            status_set('maintenance', 'Running Git install')
103
114
            git_install(config('openstack-origin-git'))
104
115
            CONFIGS.write_all()
105
 
    else:
 
116
 
 
117
    elif not config('action-managed-upgrade'):
106
118
        if openstack_upgrade_available(get_common_package()):
107
 
            do_openstack_upgrade()
108
 
            CONFIGS.write_all()
 
119
            status_set('maintenance', 'Running openstack upgrade')
 
120
            do_openstack_upgrade(CONFIGS)
109
121
 
110
122
    update_nrpe_config()
111
123
 
128
140
        CONFIGS.write_all()
129
141
        configure_ovs()
130
142
    else:
131
 
        log('Please provide a valid plugin config', level=ERROR)
 
143
        message = 'Please provide a valid plugin config'
 
144
        log(message, level=ERROR)
 
145
        status_set('blocked', message)
132
146
        sys.exit(1)
133
147
    if config('plugin') == 'n1kv':
134
148
        if not git_install_requested():
135
149
            if config('enable-l3-agent'):
 
150
                status_set('maintenance', 'Installing apt packages')
136
151
                apt_install(filter_installed_packages('neutron-l3-agent'))
137
152
            else:
138
153
                apt_purge('neutron-l3-agent')
343
358
        hooks.execute(sys.argv)
344
359
    except UnregisteredHookError as e:
345
360
        log('Unknown hook {} - skipping.'.format(e))
 
361
    set_os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
362
                           charm_func=check_optional_relations)