def test_db_joined_with_postgresql(self):
        self.is_relation_made.return_value = True

        with self.assertRaises(Exception) as context:
            hooks.db_joined()
        self.assertEqual(context.exception.message,
                         'Attempting to associate a mysql database when'
                         ' there is already associated a postgresql one')
    def test_db_joined_with_postgresql(self):
        self.is_relation_made.return_value = True

        with self.assertRaises(Exception) as context:
            hooks.db_joined()
        self.assertEqual(context.exception.message,
                         'Attempting to associate a mysql database when'
                         ' there is already associated a postgresql one')
 def test_db_joined(self):
     self.unit_get.return_value = 'nova.foohost.com'
     self.is_relation_made.return_value = False
     hooks.db_joined()
     self.relation_set.assert_called_with(nova_database='nova',
                                          nova_username='******',
                                          nova_hostname='nova.foohost.com')
     self.unit_get.assert_called_with('private-address')
 def test_db_joined(self):
     self.unit_get.return_value = 'nova.foohost.com'
     self.is_relation_made.return_value = False
     hooks.db_joined()
     self.relation_set.assert_called_with(nova_database='nova',
                                          nova_username='******',
                                          nova_hostname='nova.foohost.com')
     self.unit_get.assert_called_with('private-address')
Example #5
0
 def test_db_joined_spaces(self):
     self.get_relation_ip.return_value = '192.168.20.1'
     self.unit_get.return_value = 'nova.foohost.com'
     self.is_relation_made.return_value = False
     self.os_release.return_value = 'diablo'
     hooks.db_joined()
     self.relation_set.assert_called_with(nova_database='nova',
                                          nova_username='******',
                                          nova_hostname='192.168.20.1',
                                          relation_id=None)
Example #6
0
 def test_db_joined(self):
     self.get_relation_ip.return_value = '10.10.10.10'
     self.is_relation_made.return_value = False
     self.os_release.return_value = 'diablo'
     hooks.db_joined()
     self.relation_set.assert_called_with(nova_database='nova',
                                          nova_username='******',
                                          nova_hostname='10.10.10.10',
                                          relation_id=None)
     self.get_relation_ip.assert_called_with('shared-db', cidr_network=None)
Example #7
0
 def test_db_joined_spaces(self):
     self.network_get_primary_address.side_effect = None
     self.network_get_primary_address.return_value = '192.168.20.1'
     self.unit_get.return_value = 'nova.foohost.com'
     self.is_relation_made.return_value = False
     hooks.db_joined()
     self.relation_set.assert_called_with(nova_database='nova',
                                          nova_username='******',
                                          nova_hostname='192.168.20.1',
                                          relation_id=None)
     self.assertFalse(self.unit_get.called)
 def test_db_joined_spaces(self):
     self.network_get_primary_address.side_effect = None
     self.network_get_primary_address.return_value = '192.168.20.1'
     self.unit_get.return_value = 'nova.foohost.com'
     self.is_relation_made.return_value = False
     hooks.db_joined()
     self.relation_set.assert_called_with(nova_database='nova',
                                          nova_username='******',
                                          nova_hostname='192.168.20.1',
                                          relation_id=None)
     self.assertFalse(self.unit_get.called)
Example #9
0
    def test_db_joined_mitaka(self):
        self.get_relation_ip.return_value = '10.10.10.10'
        self.os_release.return_value = 'mitaka'
        self.is_relation_made.return_value = False
        hooks.db_joined()
        self.relation_set.assert_has_calls([
            call(nova_database='nova',
                 nova_username='******',
                 nova_hostname='10.10.10.10',
                 relation_id=None),
            call(novaapi_database='nova_api',
                 novaapi_username='******',
                 novaapi_hostname='10.10.10.10',
                 relation_id=None),
        ])

        self.get_relation_ip.assert_called_with('shared-db', cidr_network=None)
Example #10
0
    def test_db_joined_mitaka(self):
        self.unit_get.return_value = 'nova.foohost.com'
        self.os_release.return_value = 'mitaka'
        self.is_relation_made.return_value = False
        hooks.db_joined()
        self.relation_set.assert_has_calls([
            call(nova_database='nova',
                 nova_username='******',
                 nova_hostname='nova.foohost.com',
                 relation_id=None),
            call(novaapi_database='nova_api',
                 novaapi_username='******',
                 novaapi_hostname='nova.foohost.com',
                 relation_id=None),
        ])

        self.unit_get.assert_called_with('private-address')
    def test_db_joined_mitaka(self):
        self.unit_get.return_value = 'nova.foohost.com'
        self.os_release.return_value = 'mitaka'
        self.is_relation_made.return_value = False
        hooks.db_joined()
        self.relation_set.assert_has_calls([
            call(nova_database='nova',
                 nova_username='******',
                 nova_hostname='nova.foohost.com',
                 relation_id=None),
            call(novaapi_database='nova_api',
                 novaapi_username='******',
                 novaapi_hostname='nova.foohost.com',
                 relation_id=None),
        ])

        self.unit_get.assert_called_with('private-address')
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('nova-common', do_openstack_upgrade,
                                    CONFIGS)):
        [
            neutron_api_relation_joined(rid=rid, remote_restart=True)
            for rid in relation_ids('neutron-api')
        ]
        # NOTE(thedac): Force re-fire of shared-db joined hook
        # to ensure that nova_api database is setup if required.
        [db_joined(relation_id=r_id) for r_id in relation_ids('shared-db')]
        config_changed()