def test_ceph_changed_with_key_and_relation_data(self, configs,
                                                     service_name,
                                                     create_libvirt_secret,
                                                     _handle_ceph_request):
        configs.complete_contexts = MagicMock()
        configs.complete_contexts.return_value = ['ceph']
        self.ensure_ceph_keyring.return_value = True
        configs.write = MagicMock()
        service_name.return_value = 'nova-compute'
        key = {'data': 'key'}
        self.relation_get.return_value = key

        hooks.ceph_changed()
        ex = [
            call('/var/lib/charm/nova-compute/ceph.conf'),
            call('/etc/ceph/secret.xml'),
            call('/etc/nova/nova.conf'),
        ]
        self.assertEqual(ex, configs.write.call_args_list)
        create_libvirt_secret.assert_called_once_with(
            secret_file='/etc/ceph/secret.xml',
            key=key,
            secret_uuid=hooks.CEPH_SECRET_UUID)
        # confirm exception is caught
        _handle_ceph_request.side_effect = ValueError
        hooks.ceph_changed()
        self.log.assert_called_once()
예제 #2
0
    def test_ceph_changed_with_key_and_relation_data(self, configs,
                                                     service_name,
                                                     is_broker_action_done,
                                                     mark_broker_action_done):
        self.test_config.set('libvirt-image-backend', 'rbd')
        self.is_request_complete.return_value = True
        self.assert_libvirt_rbd_imagebackend_allowed.return_value = True
        configs.complete_contexts = MagicMock()
        configs.complete_contexts.return_value = ['ceph']
        configs.write = MagicMock()
        service_name.return_value = 'nova-compute'
        self.ensure_ceph_keyring.return_value = True
        is_broker_action_done.return_value = False
        hooks.ceph_changed()
        self.assertTrue(mark_broker_action_done.called)
        ex = [
            call('/var/lib/charm/nova-compute/ceph.conf'),
            call('/etc/ceph/secret.xml'),
            call('/etc/nova/nova.conf'),
        ]
        self.assertEqual(ex, configs.write.call_args_list)
        self.service_restart.assert_called_with('nova-compute')

        is_broker_action_done.return_value = True
        mark_broker_action_done.reset_mock()
        hooks.ceph_changed()
        self.assertFalse(mark_broker_action_done.called)
 def test_ceph_changed_no_keyring(self, configs):
     configs.complete_contexts = MagicMock()
     configs.complete_contexts.return_value = ['ceph']
     self.ensure_ceph_keyring.return_value = False
     hooks.ceph_changed()
     self.log.assert_called_with(
         'Could not create ceph keyring: peer not ready?')
예제 #4
0
 def test_ceph_changed_missing_relation_data(self, configs):
     configs.complete_contexts = MagicMock()
     configs.complete_contexts.return_value = []
     hooks.ceph_changed()
     self.log.assert_called_with(
         'ceph relation incomplete. Peer not ready?'
     )
 def test_ceph_changed_missing_relation_data(self, configs):
     configs.complete_contexts = MagicMock()
     configs.complete_contexts.return_value = []
     hooks.ceph_changed()
     self.log.assert_called_with(
         'ceph relation incomplete. Peer not ready?'
     )
 def test_ceph_changed_no_keyring(self, configs):
     configs.complete_contexts = MagicMock()
     configs.complete_contexts.return_value = ['ceph']
     self.ensure_ceph_keyring.return_value = False
     hooks.ceph_changed()
     self.log.assert_called_with(
         'Could not create ceph keyring: peer not ready?'
     )
 def test_ceph_changed_with_key_and_relation_data(self, configs,
                                                  service_name):
     configs.complete_contexts = MagicMock()
     configs.complete_contexts.return_value = ['ceph']
     configs.write = MagicMock()
     service_name.return_value = 'nova-compute'
     self.ensure_ceph_keyring.return_value = True
     hooks.ceph_changed()
     ex = [
         call('/var/lib/charm/nova-compute/ceph.conf'),
         call('/etc/ceph/secret.xml'),
         call('/etc/nova/nova.conf'),
     ]
     self.assertEquals(ex, configs.write.call_args_list)
 def test_ceph_changed_with_key_and_relation_data(self, configs,
                                                  service_name):
     self.test_config.set('libvirt-image-backend', 'rbd')
     self.is_request_complete.return_value = True
     self.assert_libvirt_imagebackend_allowed.return_value = True
     configs.complete_contexts = MagicMock()
     configs.complete_contexts.return_value = ['ceph']
     configs.write = MagicMock()
     service_name.return_value = 'nova-compute'
     self.ensure_ceph_keyring.return_value = True
     hooks.ceph_changed()
     ex = [
         call('/var/lib/charm/nova-compute/ceph.conf'),
         call('/etc/ceph/secret.xml'),
         call('/etc/nova/nova.conf'),
     ]
     self.assertEquals(ex, configs.write.call_args_list)
     self.service_restart.assert_called_with('nova-compute')