コード例 #1
0
def simulate_compute_host_failure(unit_name, model_name):
    """Simulate compute node failure from a masakari and nova POV.

    Masakari uses corosync/pacemaker to detect failure and nova check
    nova-compute. Shutting down these services causes masakari and nova to
    mark them as down.

    :param unit_name: Juju name of unit (app/n)
    :type unit_name: str
    :param model_name: Name of model unit_name resides in.
    :type model_name: str
    """
    logging.info('Simulating failure of compute node {}'.format(unit_name))
    _svc_set_systemd_restart_mode(unit_name, 'pacemaker_remote', 'no',
                                  model_name)
    _svc_control(unit_name, 'stop', ['corosync', 'nova-compute'], model_name)
    compute_app = unit_name.split('/')[0]
    release_pair = openstack_utils.get_current_os_release_pair(
        application=compute_app)
    if (openstack_utils.get_os_release(release_pair=release_pair) >=
            openstack_utils.get_os_release('focal_ussuri')):
        pacemaker_proc = '/usr/sbin/pacemaker-remoted'
    else:
        pacemaker_proc = '/usr/sbin/pacemaker_remoted'
    logging.info('Sending {} a SIGTERM'.format(pacemaker_proc))
    zaza.model.run_on_unit(unit_name,
                           'pkill -9 -f {}'.format(pacemaker_proc),
                           model_name=model_name)
コード例 #2
0
 def setUpClass(cls):
     """Run class setup for OVN charm operation tests."""
     super(BaseCharmOperationTest, cls).setUpClass()
     cls.services = ['NotImplemented']  # This must be overridden
     cls.current_release = openstack_utils.get_os_release(
         openstack_utils.get_current_os_release_pair(
             cls.release_application or cls.application_name))
コード例 #3
0
 def setUpClass(cls):
     """Perform class one time initialization."""
     super(BlueStoreCompressionCharmOperation, cls).setUpClass()
     cls.current_release = zaza_openstack.get_os_release(
         zaza_openstack.get_current_os_release_pair(
             application='ceph-mon'))
     cls.bionic_rocky = zaza_openstack.get_os_release('bionic_rocky')
コード例 #4
0
    def test_get_current_openstack_release_pair(self):
        self.patch(
            'zaza.openstack.utilities.openstack.get_current_os_versions',
            new_callable=mock.MagicMock(),
            name='_get_os_version')
        self.patch(
            'zaza.openstack.utilities.juju.get_machines_for_application',
            new_callable=mock.MagicMock(),
            name='_get_machines')
        self.patch('zaza.openstack.utilities.juju.get_machine_series',
                   new_callable=mock.MagicMock(),
                   name='_get_machine_series')

        # No machine returned
        self._get_machines.return_value = []
        with self.assertRaises(exceptions.ApplicationNotFound):
            openstack_utils.get_current_os_release_pair()

        # No series returned
        self._get_machines.return_value = ['6']
        self._get_machine_series.return_value = None
        with self.assertRaises(exceptions.SeriesNotFound):
            openstack_utils.get_current_os_release_pair()

        # No OS Version returned
        self._get_machine_series.return_value = 'xenial'
        self._get_os_version.return_value = {}
        with self.assertRaises(exceptions.OSVersionNotFound):
            openstack_utils.get_current_os_release_pair()

        # Normal scenario, argument passed
        self._get_os_version.return_value = {'keystone': 'mitaka'}
        expected = 'xenial_mitaka'
        result = openstack_utils.get_current_os_release_pair('keystone')
        self.assertEqual(expected, result)

        # Normal scenario, default value used
        self._get_os_version.return_value = {'keystone': 'mitaka'}
        expected = 'xenial_mitaka'
        result = openstack_utils.get_current_os_release_pair()
        self.assertEqual(expected, result)
コード例 #5
0
 def setUpClass(cls):
     """Run class setup for OVN migration tests."""
     super(OVSOVNMigrationTest, cls).setUpClass()
     cls.current_release = openstack_utils.get_os_release(
         openstack_utils.get_current_os_release_pair())