~1chb1n/charms/trusty/cinder/15.10-stable-flip-tests-helper-syncs

« back to all changes in this revision

Viewing changes to hooks/cinder_hooks.py

  • Committer: James Page
  • Date: 2015-10-22 13:19:13 UTC
  • Revision ID: james.page@ubuntu.com-20151022131913-02u2l9s2fa0xtbio
Tags: 15.10
15.10 Charm release

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    setup_ipv6,
28
28
    check_db_initialised,
29
29
    filesystem_mounted,
 
30
    REQUIRED_INTERFACES,
 
31
    check_optional_relations,
30
32
)
31
33
 
32
34
from charmhelpers.core.hookenv import (
42
44
    unit_get,
43
45
    log,
44
46
    ERROR,
 
47
    status_set,
45
48
)
46
49
 
47
50
from charmhelpers.fetch import (
63
66
    openstack_upgrade_available,
64
67
    sync_db_with_multi_ipv6_addresses,
65
68
    os_release,
 
69
    set_os_workload_status,
66
70
)
67
71
 
68
72
from charmhelpers.contrib.storage.linux.ceph import (
99
103
CONFIGS = register_configs()
100
104
 
101
105
 
102
 
@hooks.hook('install')
 
106
@hooks.hook('install.real')
103
107
def install():
 
108
    status_set('maintenance', 'Executing pre-install')
104
109
    execd_preinstall()
105
110
    conf = config()
106
111
    src = conf['openstack-origin']
109
114
        src = 'cloud:precise-folsom'
110
115
    configure_installation_source(src)
111
116
 
 
117
    status_set('maintenance', 'Installing apt packages')
112
118
    apt_update()
113
119
    apt_install(determine_packages(), fatal=True)
114
120
 
 
121
    status_set('maintenance', 'Git install')
115
122
    git_install(config('openstack-origin-git'))
116
123
 
117
124
 
121
128
    conf = config()
122
129
 
123
130
    if conf['prefer-ipv6']:
 
131
        status_set('maintenance', 'configuring ipv6')
124
132
        setup_ipv6()
125
133
        sync_db_with_multi_ipv6_addresses(config('database'),
126
134
                                          config('database-user'))
131
139
 
132
140
    if (service_enabled('volume') and
133
141
            conf['block-device'] not in [None, 'None', 'none']):
 
142
        status_set('maintenance', 'Configuring lvm storage')
134
143
        block_devices = conf['block-device'].split()
135
144
        configure_lvm_storage(block_devices,
136
145
                              conf['volume-group'],
140
149
 
141
150
    if git_install_requested():
142
151
        if config_value_changed('openstack-origin-git'):
 
152
            status_set('maintenance', 'Running Git install')
143
153
            git_install(config('openstack-origin-git'))
144
 
    else:
 
154
    elif not config('action-managed-upgrade'):
145
155
        if openstack_upgrade_available('cinder-common'):
 
156
            status_set('maintenance', 'Running openstack upgrade')
146
157
            do_openstack_upgrade(configs=CONFIGS)
147
158
            # NOTE(jamespage) tell any storage-backends we just upgraded
148
159
            for rid in relation_ids('storage-backend'):
149
160
                relation_set(relation_id=rid,
150
161
                             upgrade_nonce=uuid.uuid4())
 
162
            # NOTE(hopem) tell any backup-backends we just upgraded
 
163
            for rid in relation_ids('backup-backend'):
 
164
                relation_set(relation_id=rid,
 
165
                             upgrade_nonce=uuid.uuid4())
 
166
 
 
167
    # overwrite config is not in conf file. so We can't use restart_on_change
 
168
    if config_value_changed('overwrite'):
 
169
        service_restart('cinder-volume')
151
170
 
152
171
    CONFIGS.write_all()
153
172
    configure_https()
508
527
    CONFIGS.write(CINDER_CONF)
509
528
 
510
529
 
 
530
@hooks.hook('backup-backend-relation-changed')
 
531
@hooks.hook('backup-backend-relation-broken')
 
532
@restart_on_change(restart_map())
 
533
def backup_backend():
 
534
    CONFIGS.write(CINDER_CONF)
 
535
 
 
536
 
511
537
@hooks.hook('nrpe-external-master-relation-joined',
512
538
            'nrpe-external-master-relation-changed')
513
539
def update_nrpe_config():
527
553
        hooks.execute(sys.argv)
528
554
    except UnregisteredHookError as e:
529
555
        juju_log('Unknown hook {} - skipping.'.format(e))
 
556
    set_os_workload_status(CONFIGS, REQUIRED_INTERFACES,
 
557
                           charm_func=check_optional_relations)