~openstack-charmers-next/charms/precise/nova-compute/trunk

« back to all changes in this revision

Viewing changes to hooks/nova_compute_hooks.py

  • Committer: Gerrit Code Review
  • Author(s): Jenkins
  • Date: 2016-04-06 06:43:55 UTC
  • mfrom: (211.1.1 trunk)
  • Revision ID: review@openstack.org-20160406064355-hhfnwzmint2jmju2
Merge "Enhanced pause/resume for maintenance mode"

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    status_set,
18
18
)
19
19
from charmhelpers.core.host import (
20
 
    restart_on_change,
21
20
    service_restart,
22
21
)
23
22
from charmhelpers.core.strutils import (
36
35
    git_install_requested,
37
36
    openstack_upgrade_available,
38
37
    os_requires_version,
39
 
    set_os_workload_status,
 
38
    is_unit_paused_set,
 
39
    pausable_restart_on_change as restart_on_change,
40
40
)
41
41
 
42
42
from charmhelpers.contrib.storage.linux.ceph import (
71
71
    assert_charm_supports_ipv6,
72
72
    manage_ovs,
73
73
    install_hugepages,
74
 
    REQUIRED_INTERFACES,
75
 
    check_optional_relations,
76
74
    get_hugepage_number,
 
75
    assess_status,
77
76
)
78
77
 
79
78
from charmhelpers.contrib.network.ip import (
287
286
    status_set('maintenance', 'Installing apt packages')
288
287
    apt_install(filter_installed_packages(['ceph-common']), fatal=True)
289
288
    # Bug 1427660
290
 
    service_restart('libvirt-bin')
 
289
    if not is_unit_paused_set():
 
290
        service_restart('libvirt-bin')
291
291
 
292
292
 
293
293
def get_ceph_request():
325
325
        if is_request_complete(get_ceph_request()):
326
326
            log('Request complete')
327
327
            # Ensure that nova-compute is restarted since only now can we
328
 
            # guarantee that ceph resources are ready.
329
 
            service_restart('nova-compute')
 
328
            # guarantee that ceph resources are ready, but only if not paused.
 
329
            if not is_unit_paused_set():
 
330
                service_restart('nova-compute')
330
331
        else:
331
332
            send_request_if_needed(get_ceph_request())
332
333
 
428
429
    if nonce and db.get('lxd-nonce') != nonce:
429
430
        db.set('lxd-nonce', nonce)
430
431
        configure_lxd(user='nova')
431
 
        service_restart('nova-compute')
 
432
        if not is_unit_paused_set():
 
433
            service_restart('nova-compute')
432
434
 
433
435
 
434
436
@hooks.hook('nova-designate-relation-changed')
448
450
        hooks.execute(sys.argv)
449
451
    except UnregisteredHookError as e:
450
452
        log('Unknown hook {} - skipping.'.format(e))
451
 
    set_os_workload_status(CONFIGS, REQUIRED_INTERFACES,
452
 
                           charm_func=check_optional_relations)
 
453
    assess_status(CONFIGS)
453
454
 
454
455
 
455
456
if __name__ == '__main__':