def test_creates_restart_map_only_api(self, service_enabled):
     '''It creates correct restart map with only api enabled'''
     service_enabled.side_effect = self.svc_enabled
     self.test_config.set('enabled-services', 'api')
     ex_map = OrderedDict([
         ('/etc/cinder/cinder.conf', ['cinder-api', 'haproxy']),
         ('/etc/cinder/api-paste.ini', ['cinder-api']),
         ('/etc/haproxy/haproxy.cfg', ['haproxy']),
         ('/etc/apache2/sites-available/openstack_https_frontend',
          ['apache2']),
         ('/etc/apache2/sites-available/openstack_https_frontend.conf',
          ['apache2']),
     ])
     self.assertEquals(cinder_utils.restart_map(), ex_map)
 def test_creates_restart_map_all_enabled(self):
     '''It creates correct restart map when all services enabled'''
     ex_map = OrderedDict([
         ('/etc/cinder/cinder.conf', ['cinder-api', 'cinder-volume',
                                      'cinder-scheduler', 'haproxy']),
         ('/etc/cinder/api-paste.ini', ['cinder-api']),
         ('/etc/ceph/ceph.conf', ['cinder-volume']),
         ('/etc/haproxy/haproxy.cfg', ['haproxy']),
         ('/etc/apache2/sites-available/openstack_https_frontend',
          ['apache2']),
         ('/etc/apache2/sites-available/openstack_https_frontend.conf',
          ['apache2']),
     ])
     self.assertEquals(cinder_utils.restart_map(), ex_map)
 def test_restart_map(self, resource_map):
     resource_map.return_value = OrderedDict([
         ('/etc/testfile1.conf', {
             'hook_contexts': ['dummyctxt1', 'dummyctxt2'],
             'services': ['svc1'],
         }),
         ('/etc/testfile2.conf', {
             'hook_contexts': ['dummyctxt1', 'dummyctxt3'],
             'services': [],
         }),
     ])
     ex_map = OrderedDict([
         ('/etc/testfile1.conf', ['svc1']),
     ])
     self.assertEqual(cinder_utils.restart_map(), ex_map)
 def test_creates_restart_map_no_api(self, service_enabled):
     '''It creates correct restart map with api disabled'''
     service_enabled.side_effect = self.svc_enabled
     self.test_config.set('enabled-services', 'scheduler,volume')
     ex_map = OrderedDict([
         ('/etc/cinder/cinder.conf', ['cinder-volume', 'cinder-scheduler',
                                      'haproxy']),
         ('/etc/ceph/ceph.conf', ['cinder-volume']),
         ('/etc/haproxy/haproxy.cfg', ['haproxy']),
         ('/etc/apache2/sites-available/openstack_https_frontend',
          ['apache2']),
         ('/etc/apache2/sites-available/openstack_https_frontend.conf',
          ['apache2']),
     ])
     self.assertEquals(cinder_utils.restart_map(), ex_map)
Exemple #5
0
    src = conf['openstack-origin']
    if (lsb_release()['DISTRIB_CODENAME'] == 'precise' and
            src == 'distro'):
        src = 'cloud:precise-folsom'
    configure_installation_source(src)

    status_set('maintenance', 'Installing apt packages')
    apt_update()
    apt_install(determine_packages(), fatal=True)

    status_set('maintenance', 'Git install')
    git_install(config('openstack-origin-git'))


@hooks.hook('config-changed')
@restart_on_change(restart_map(), stopstart=True)
@harden()
def config_changed():
    conf = config()

    if conf['prefer-ipv6']:
        status_set('maintenance', 'configuring ipv6')
        setup_ipv6()
        sync_db_with_multi_ipv6_addresses(config('database'),
                                          config('database-user'))

    e_mountpoint = config('ephemeral-unmount')
    if e_mountpoint and filesystem_mounted(e_mountpoint):
        umount(e_mountpoint)

    if (service_enabled('volume') and
    configure_installation_source(src)
    apt_update()
    apt_install(determine_packages(), fatal=True)

    if (service_enabled('volume') and
       conf['block-device'] not in [None, 'None', 'none']):
        bdev = ensure_block_device(conf['block-device'])
        juju_log('Located valid block device: %s' % bdev)
        if conf['overwrite'] in ['true', 'True', True]:
            juju_log('Ensuring block device is clean: %s' % bdev)
            clean_storage(bdev)
        prepare_lvm_storage(bdev, conf['volume-group'])


@hooks.hook('config-changed')
@restart_on_change(restart_map())
def config_changed():
    if openstack_upgrade_available('cinder-common'):
        do_openstack_upgrade(configs=CONFIGS)
    CONFIGS.write_all()
    configure_https()


@hooks.hook('shared-db-relation-joined')
def db_joined():
    conf = config()
    relation_set(database=conf['database'], username=conf['database-user'],
                 hostname=unit_get('private-address'))


@hooks.hook('shared-db-relation-changed')