コード例 #1
0
    def test_restart_map_stein(self):
        self.enable_memcache.return_value = True
        self.config.side_effect = None
        self.service_name.return_value = 'glance'
        self.os_release.return_value = 'stein'

        ex_map = OrderedDict([
            (utils.GLANCE_API_CONF, ['glance-api']),
            (utils.GLANCE_SWIFT_CONF, ['glance-api']),
            (utils.ceph_config_file(), ['glance-api']),
            (utils.HAPROXY_CONF, ['haproxy']),
            (utils.HTTPS_APACHE_CONF, ['apache2']),
            (utils.HTTPS_APACHE_24_CONF, ['apache2']),
            (utils.MEMCACHED_CONF, ['memcached']),
            (utils.GLANCE_POLICY_FILE, ['glance-api']),
        ])
        self.assertEqual(ex_map, utils.restart_map())
        self.enable_memcache.return_value = False
        del ex_map[utils.MEMCACHED_CONF]
        self.assertEqual(ex_map, utils.restart_map())
コード例 #2
0
    def test_restart_map_stein(self):
        self.enable_memcache.return_value = True
        self.config.side_effect = None
        self.service_name.return_value = 'glance'
        self.os_release.return_value = 'stein'

        ex_map = OrderedDict([
            (utils.GLANCE_API_CONF, ['glance-api']),
            (utils.GLANCE_SWIFT_CONF, ['glance-api']),
            (utils.ceph_config_file(), ['glance-api']),
            (utils.HAPROXY_CONF, ['haproxy']),
            (utils.HTTPS_APACHE_CONF, ['apache2']),
            (utils.HTTPS_APACHE_24_CONF, ['apache2']),
            (utils.MEMCACHED_CONF, ['memcached']),
            (utils.GLANCE_POLICY_FILE, ['glance-api']),
        ])
        self.assertEqual(ex_map, utils.restart_map())
        self.enable_memcache.return_value = False
        del ex_map[utils.MEMCACHED_CONF]
        self.assertEqual(ex_map, utils.restart_map())
コード例 #3
0
 def test_restart_map(self):
     ex_map = OrderedDict([
         (utils.GLANCE_REGISTRY_CONF, ['glance-registry']),
         (utils.GLANCE_API_CONF, ['glance-api']),
         (utils.GLANCE_API_PASTE_INI, ['glance-api']),
         (utils.GLANCE_REGISTRY_PASTE_INI, ['glance-registry']),
         (utils.CEPH_CONF, ['glance-api', 'glance-registry']),
         (utils.HAPROXY_CONF, ['haproxy']),
         (utils.HTTPS_APACHE_CONF, ['apache2']),
         (utils.HTTPS_APACHE_24_CONF, ['apache2'])
     ])
     self.assertEquals(ex_map, utils.restart_map())
コード例 #4
0

@hooks.hook('pgsql-db-relation-joined')
def pgsql_db_joined():
    if is_relation_made('shared-db'):
        # raise error
        e = ('Attempting to associate a postgresql database when'
             ' there is already associated a mysql one')
        juju_log(e, level=ERROR)
        raise Exception(e)

    relation_set(database=config('database'))


@hooks.hook('shared-db-relation-changed')
@restart_on_change(restart_map())
def db_changed():
    rel = os_release('glance-common')

    if 'shared-db' not in CONFIGS.complete_contexts():
        juju_log('shared-db relation incomplete. Peer not ready?')
        return

    CONFIGS.write(GLANCE_REGISTRY_CONF)
    # since folsom, a db connection setting in glance-api.conf is required.
    if rel != "essex":
        CONFIGS.write(GLANCE_API_CONF)

    if is_elected_leader(CLUSTER_RES):
        # Bugs 1353135 & 1187508. Dbs can appear to be ready before the units
        # acl entry has been added. So, if the db supports passing a list of
コード例 #5
0

@hooks.hook('pgsql-db-relation-joined')
def pgsql_db_joined():
    if is_relation_made('shared-db'):
        # raise error
        e = ('Attempting to associate a postgresql database when'
             ' there is already associated a mysql one')
        juju_log(e, level=ERROR)
        raise Exception(e)

    relation_set(database=config('database'))


@hooks.hook('shared-db-relation-changed')
@restart_on_change(restart_map())
def db_changed():
    rel = os_release('glance-common')

    if 'shared-db' not in CONFIGS.complete_contexts():
        juju_log('shared-db relation incomplete. Peer not ready?')
        return

    CONFIGS.write(GLANCE_REGISTRY_CONF)
    # since folsom, a db connection setting in glance-api.conf is required.
    if rel != "essex":
        CONFIGS.write(GLANCE_API_CONF)

    if is_elected_leader(CLUSTER_RES):
        # Bugs 1353135 & 1187508. Dbs can appear to be ready before the units
        # acl entry has been added. So, if the db supports passing a list of
コード例 #6
0
    apt_update()
    apt_install(PACKAGES)

    for service in SERVICES:
        service_stop(service)


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


@hooks.hook('shared-db-relation-changed')
@restart_on_change(restart_map())
def db_changed():
    rel = get_os_codename_package("glance-common")

    if 'shared-db' not in CONFIGS.complete_contexts():
        juju_log('shared-db relation incomplete. Peer not ready?')
        return

    CONFIGS.write(GLANCE_REGISTRY_CONF)
    # since folsom, a db connection setting in glance-api.conf is required.
    if rel != "essex":
        CONFIGS.write(GLANCE_API_CONF)

    if eligible_leader(CLUSTER_RES):
        if rel == "essex":
            status = call(['glance-manage', 'db_version'])