def upgrade_non_base_services(juju_status=None, switch=None):
    if not juju_status:
        juju_status = get_juju_status()
    # Upgrade the rest
    for svc in juju_status['applications']:
        if svc not in BASE_CHARMS:
            charm_name = charm_to_charm_name(
                juju_status['applications'][svc]['charm'])
            upgrade_service(svc, charm_name=charm_name, switch=switch)
    model.wait_for_agent_status(status='executing')
    if not model.get_relation_id('rabbitmq-server',
                                 'ceilometer-agent',
                                 remote_interface_name='amqp'):
        logging.info("Adding rabbitmq-server ceilometer-agent relation")
        model.add_relation('ceilometer-agent', 'amqp', 'rabbitmq-server:amqp')
        model.wait_for_agent_status(status='executing')
    if not model.get_relation_id('memcached',
                                 'nova-cloud-controller',
                                 remote_interface_name='memcache'):
        logging.info("Adding nova-cloud-controller memcached relation")
        model.add_relation('memcached', 'nova-cloud-controller',
                           'nova-cloud-controller:memcache')
        model.wait_for_agent_status(status='executing')
    logging.info("Waiting for units to be idle")
    model.block_until_all_units_idle()
Ejemplo n.º 2
0
def get_relation_from_unit(entity, remote_entity, remote_interface_name):
    """Get relation data passed between two units.

    Get relation data for relation with `remote_interface_name` between
    `entity` and `remote_entity` from the perspective of `entity`.

    `entity` and `remote_entity` may refer to either a application or a
    specific unit. If application name is given first unit is found in model.

    :param entity: Application or unit to get relation data from
    :type entity: str
    :param remote_entity: Application or Unit in the other end of the relation
                          we want to query
    :type remote_entity: str
    :param remote_interface_name: Name of interface to query on remote end of
                                  relation
    :type remote_interface_name: str
    :returns: dict with relation data
    :rtype: dict
    :raises: model.CommandRunFailed
    """
    application = entity.split('/')[0]
    remote_application = remote_entity.split('/')[0]
    rid = model.get_relation_id(application,
                                remote_application,
                                remote_interface_name=remote_interface_name)
    (unit, remote_unit) = _get_unit_names([entity, remote_entity])
    cmd = 'relation-get --format=yaml -r "{}" - "{}"'.format(rid, remote_unit)
    result = model.run_on_unit(unit, cmd)
    if result and int(result.get('Code')) == 0:
        return yaml.safe_load(result.get('Stdout'))
    else:
        raise model.CommandRunFailed(cmd, result)
Ejemplo n.º 3
0
 def test_get_relation_id_interface(self):
     self.patch_object(model, 'get_juju_model', return_value='mname')
     self.patch_object(model, 'Model')
     self.Model.return_value = self.Model_mock
     self.assertEqual(
         model.get_relation_id('app',
                               'app',
                               remote_interface_name='interface'), 51)
Ejemplo n.º 4
0
 def setUpClass(cls):
     """Run class setup for running openstack dashboard charm tests."""
     super(OpenStackDashboardTests, cls).setUpClass()
     cls.application = 'openstack-dashboard'
     cls.use_https = False
     vault_relation = zaza_model.get_relation_id(
         cls.application,
         'vault',
         remote_interface_name='certificates')
     if vault_relation:
         cls.use_https = True
Ejemplo n.º 5
0
    def use_https(self):
        """Whether dashboard is using https.

        :returns: Whether dashboard is using https
        :rtype: boolean
        """
        use_https = False
        vault_relation = zaza_model.get_relation_id(
            self.application, 'vault', remote_interface_name='certificates')
        if vault_relation:
            use_https = True
        return use_https
Ejemplo n.º 6
0
 def test_check_pool_types(self):
     """Check type of pools created for clients."""
     app_pools = [
         ('glance', 'glance'),
         ('nova-compute', 'nova'),
         ('cinder-ceph', 'cinder-ceph')]
     runtime_pool_details = zaza_ceph.get_ceph_pool_details()
     for app, pool_name in app_pools:
         try:
             app_config = zaza_model.get_application_config(app)
         except KeyError:
             logging.info(
                 'Skipping pool check of %s, application %s not present',
                 pool_name,
                 app)
             continue
         rel_id = zaza_model.get_relation_id(
             app,
             'ceph-mon',
             remote_interface_name='client')
         if not rel_id:
             logging.info(
                 'Skipping pool check of %s, ceph relation not present',
                 app)
             continue
         juju_pool_config = app_config.get('pool-type')
         if juju_pool_config:
             expected_pool_type = juju_pool_config['value']
         else:
             # If the pool-type option is absent assume the default of
             # replicated.
             expected_pool_type = zaza_ceph.REPLICATED_POOL_TYPE
         for pool_config in runtime_pool_details:
             if pool_config['pool_name'] == pool_name:
                 logging.info('Checking {} is {}'.format(
                     pool_name,
                     expected_pool_type))
                 expected_pool_code = -1
                 if expected_pool_type == zaza_ceph.REPLICATED_POOL_TYPE:
                     expected_pool_code = zaza_ceph.REPLICATED_POOL_CODE
                 elif expected_pool_type == zaza_ceph.ERASURE_POOL_TYPE:
                     expected_pool_code = zaza_ceph.ERASURE_POOL_CODE
                 self.assertEqual(
                     pool_config['type'],
                     expected_pool_code)
                 break
         else:
             raise CephPoolConfig(
                 "Failed to find config for {}".format(pool_name))
Ejemplo n.º 7
0
 def test_get_relation_id(self):
     self.patch_object(model, 'get_juju_model', return_value='mname')
     self.patch_object(model, 'Model')
     self.Model.return_value = self.Model_mock
     self.assertEqual(model.get_relation_id('app', 'app'), 42)