~xianghui/charms/trusty/nova-cloud-controller/live_migration

« back to all changes in this revision

Viewing changes to hooks/nova_cc_utils.py

  • Committer: james.page at ubuntu
  • Date: 2015-06-09 09:59:06 UTC
  • mfrom: (143.1.18 nova-cloud-controller)
  • Revision ID: james.page@ubuntu.com-20150609095906-o300u1j0rtk92aem
Add support for leader-election

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
from charmhelpers.contrib.openstack.neutron import (
11
11
    network_manager, neutron_plugin_attribute)
12
12
 
13
 
from charmhelpers.contrib.hahelpers.cluster import eligible_leader
 
13
from charmhelpers.contrib.hahelpers.cluster import is_elected_leader
14
14
 
15
15
from charmhelpers.contrib.peerstorage import peer_store
16
16
 
53
53
    is_ipv6
54
54
)
55
55
 
 
56
from charmhelpers.core.decorators import (
 
57
    retry_on_exception,
 
58
)
 
59
 
56
60
import nova_cc_context
57
61
 
58
62
TEMPLATES = 'templates/'
544
548
        # NOTE(jamespage) default plugin switch to ml2@icehouse
545
549
        ml2_migration()
546
550
 
547
 
    if eligible_leader(CLUSTER_RES):
 
551
    if is_elected_leader(CLUSTER_RES):
548
552
        migrate_nova_database()
549
553
    [service_start(s) for s in services()]
550
554
 
575
579
    return 'cinder'
576
580
 
577
581
 
 
582
# NOTE(jamespage): Retry deals with sync issues during one-shot HA deploys.
 
583
#                  mysql might be restarting or suchlike.
 
584
@retry_on_exception(5, base_delay=3, exc_type=subprocess.CalledProcessError)
578
585
def migrate_nova_database():
579
586
    '''Runs nova-manage to initialize a new database or migrate existing'''
580
587
    log('Migrating the nova database.', level=INFO)
588
595
    cmd_all_services('start')
589
596
 
590
597
 
 
598
# NOTE(jamespage): Retry deals with sync issues during one-shot HA deploys.
 
599
#                  mysql might be restarting or suchlike.
 
600
@retry_on_exception(5, base_delay=3, exc_type=subprocess.CalledProcessError)
591
601
def migrate_neutron_database():
592
602
    '''Runs neutron-db-manage to init a new database or migrate existing'''
593
603
    log('Migrating the neutron database.', level=INFO)