def test_register_configs_apache24(self, exists):
     exists.return_value = True
     self.get_os_codename_package.return_value = 'grizzly'
     self.relation_ids.return_value = False
     configs = cinder_utils.register_configs()
     calls = []
     for conf in [cinder_utils.CINDER_API_CONF,
                  cinder_utils.CINDER_CONF,
                  cinder_utils.APACHE_SITE_24_CONF,
                  cinder_utils.HAPROXY_CONF]:
         calls.append(
             call(conf,
                  cinder_utils.CONFIG_FILES[conf]['hook_contexts'])
         )
     configs.register.assert_has_calls(calls, any_order=True)
Esempio n. 2
0
 def test_register_configs(self, resource_map):
     resource_map.return_value = OrderedDict([
         ('/etc/testfile1.conf', {
             'contexts': ['dummyctxt1', 'dummyctxt2'],
             'services': ['svc1'],
         }),
         ('/etc/testfile2.conf', {
             'contexts': ['dummyctxt1', 'dummyctxt3'],
             'services': [],
         }),
     ])
     configs = cinder_utils.register_configs()
     calls = [
         call('/etc/testfile1.conf', ['dummyctxt1', 'dummyctxt2']),
         call('/etc/testfile2.conf', ['dummyctxt1', 'dummyctxt3']),
     ]
     configs.register.assert_has_calls(calls)
 def test_register_configs(self, resource_map):
     resource_map.return_value = OrderedDict([
         ('/etc/testfile1.conf', {
             'contexts': ['dummyctxt1', 'dummyctxt2'],
             'services': ['svc1'],
         }),
         ('/etc/testfile2.conf', {
             'contexts': ['dummyctxt1', 'dummyctxt3'],
             'services': [],
         }),
     ])
     configs = cinder_utils.register_configs()
     calls = [
         call('/etc/testfile1.conf', ['dummyctxt1', 'dummyctxt2']),
         call('/etc/testfile2.conf', ['dummyctxt1', 'dummyctxt3']),
     ]
     configs.register.assert_has_calls(calls)
 def test_register_configs_ceph(self, exists):
     exists.return_value = True
     self.get_os_codename_package.return_value = 'grizzly'
     self.relation_ids.return_value = ['ceph:0']
     configs = cinder_utils.register_configs()
     calls = []
     for conf in [cinder_utils.ceph_config_file()]:
         calls.append(
             call(conf, cinder_utils.CONFIG_FILES[conf]['hook_contexts']))
     configs.register.assert_has_calls(calls, any_order=True)
     self.mkdir.assert_has_calls([
         call(os.path.dirname(cinder_utils.ceph_config_file())),
         call(os.path.dirname(cinder_utils.CEPH_CONF))
     ])
     self.install_alternative.assert_called_with(
         os.path.basename(cinder_utils.CEPH_CONF), cinder_utils.CEPH_CONF,
         cinder_utils.ceph_config_file())
 def test_register_configs_ceph(self, exists, isdir, mkdir):
     exists.return_value = False
     isdir.return_value = False
     self.get_os_codename_package.return_value = 'grizzly'
     self.relation_ids.return_value = ['ceph:0']
     configs = cinder_utils.register_configs()
     calls = []
     for conf in [cinder_utils.CINDER_API_CONF,
                  cinder_utils.CINDER_CONF,
                  cinder_utils.APACHE_SITE_CONF,
                  cinder_utils.HAPROXY_CONF,
                  cinder_utils.CEPH_CONF]:
         calls.append(
             call(conf,
                  cinder_utils.CONFIG_FILES[conf]['hook_contexts'])
         )
     configs.register.assert_has_calls(calls, any_order=True)
     self.assertTrue(mkdir.called)
 def test_register_configs_ceph(self, exists):
     exists.return_value = True
     self.get_os_codename_package.return_value = 'grizzly'
     self.relation_ids.return_value = ['ceph:0']
     configs = cinder_utils.register_configs()
     calls = []
     for conf in [cinder_utils.ceph_config_file()]:
         calls.append(
             call(conf,
                  cinder_utils.CONFIG_FILES[conf]['hook_contexts'])
         )
     configs.register.assert_has_calls(calls, any_order=True)
     self.mkdir.assert_has_calls([
         call(os.path.dirname(cinder_utils.ceph_config_file())),
         call(os.path.dirname(cinder_utils.CEPH_CONF))
     ])
     self.install_alternative.assert_called_with(
         os.path.basename(cinder_utils.CEPH_CONF),
         cinder_utils.CEPH_CONF, cinder_utils.ceph_config_file()
     )
Esempio n. 7
0
def openstack_upgrade():
    """Upgrade packages to config-set Openstack version.

    If the charm was installed from source we cannot upgrade it.
    For backwards compatibility a config flag must be set for this
    code to run, otherwise a full service level upgrade will fire
    on config-changed."""

    if (do_action_openstack_upgrade('cinder-common',
                                    do_openstack_upgrade,
                                    configs=None)):
        # tell any storage-backends we just upgraded
        for rid in relation_ids('storage-backend'):
            relation_set(relation_id=rid,
                         upgrade_nonce=uuid.uuid4())

        # Force reload to get any chances resulting from upgrade.
        # See LP 1726527.
        cinder_hooks.CONFIGS = register_configs()
        cinder_hooks.config_changed()
def openstack_upgrade():
    """Upgrade packages to config-set Openstack version.

    If the charm was installed from source we cannot upgrade it.
    For backwards compatibility a config flag must be set for this
    code to run, otherwise a full service level upgrade will fire
    on config-changed."""

    if (do_action_openstack_upgrade('cinder-common',
                                    do_openstack_upgrade,
                                    configs=None)):
        # tell any storage-backends we just upgraded
        for rid in relation_ids('storage-backend'):
            relation_set(relation_id=rid,
                         upgrade_nonce=uuid.uuid4())

        # Force reload to get any chances resulting from upgrade.
        # See LP 1726527.
        cinder_hooks.CONFIGS = register_configs()
        # If we are paused, resume LP Bug #1824545
        if is_unit_paused_set():
            resume_unit_helper(cinder_hooks.register_configs())
        cinder_hooks.config_changed()
Esempio n. 9
0
    get_certificate_request,
    process_certificates,
)
from charmhelpers.contrib.openstack.context import ADDRESS_TYPES

from charmhelpers.contrib.charmsupport import nrpe
from charmhelpers.contrib.hardening.harden import harden

from charmhelpers.contrib.openstack.policyd import (
    maybe_do_policyd_overrides,
    maybe_do_policyd_overrides_on_config_changed,
)

hooks = Hooks()

CONFIGS = register_configs()


@hooks.hook('install.real')
@harden()
def install():
    status_set('maintenance', 'Executing pre-install')
    execd_preinstall()
    conf = config()
    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')
Esempio n. 10
0
    get_address_in_network,
    get_ipv6_addr,
    is_ipv6
)
from charmhelpers.contrib.openstack.ip import (
    canonical_url,
    PUBLIC, INTERNAL, ADMIN
)
from charmhelpers.contrib.openstack.context import ADDRESS_TYPES

from charmhelpers.contrib.charmsupport import nrpe
from charmhelpers.contrib.hardening.harden import harden

hooks = Hooks()

CONFIGS = register_configs()


@hooks.hook('install.real')
@harden()
def install():
    status_set('maintenance', 'Executing pre-install')
    execd_preinstall()
    conf = config()
    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')
Esempio n. 11
0
def resume(args):
    """Resume the Ceilometer services.
    @raises Exception should the service fail to start."""
    resume_unit_helper(register_configs())
Esempio n. 12
0
def pause(args):
    """Pause the Ceilometer services.
    @raises Exception should the service fail to stop.
    """
    pause_unit_helper(register_configs())
Esempio n. 13
0
def resume(args):
    """Resume the Ceilometer services.
    @raises Exception should the service fail to start."""
    resume_unit_helper(register_configs())
Esempio n. 14
0
def pause(args):
    """Pause the Ceilometer services.
    @raises Exception should the service fail to stop.
    """
    pause_unit_helper(register_configs())