def test_install_tmpfilesd_lxd(self, mock_shutil, mock_subprocess):
     self.init_is_systemd.return_value = True
     self.group_exists.return_value = False
     self.user_exists.return_value = False
     nutils.install_tmpfilesd()
     mock_shutil.copy.assert_not_called()
     mock_subprocess.check_call.assert_not_called()
 def test_install_tmpfilesd_lxd(self, mock_shutil, mock_subprocess):
     self.init_is_systemd.return_value = True
     self.group_exists.return_value = False
     self.user_exists.return_value = False
     nutils.install_tmpfilesd()
     mock_shutil.copy.assert_not_called()
     mock_subprocess.check_call.assert_not_called()
Esempio n. 3
0
def config_changed():
    # if we are paused, delay doing any config changed hooks.
    # It is forced on the resume.
    if is_unit_paused_set():
        log("Unit is pause or upgrading. Skipping config_changed", "WARN")
        return

    install_packages()
    install_tmpfilesd()

    # NOTE(jamespage): purge any packages as a result of py3 switch
    #                  at rocky.
    packages_to_purge = determine_purge_packages()
    request_nova_compute_restart = False
    if packages_to_purge:
        purge_packages(packages_to_purge)
        request_nova_compute_restart = True

    sysctl_settings = config('sysctl')
    if not is_container() and sysctl_settings:
        create_sysctl(sysctl_settings,
                      '/etc/sysctl.d/50-openvswitch.conf')

    configure_ovs()
    CONFIGS.write_all()
    # NOTE(fnordahl): configure_sriov must be run after CONFIGS.write_all()
    # to allow us to enable boot time execution of init script
    configure_sriov()
    for rid in relation_ids('neutron-plugin'):
        neutron_plugin_joined(
            relation_id=rid,
            request_restart=request_nova_compute_restart)
def config_changed():
    # if we are paused, delay doing any config changed hooks.
    # It is forced on the resume.
    if is_unit_paused_set():
        log("Unit is pause or upgrading. Skipping config_changed", "WARN")
        return

    install_packages()
    install_tmpfilesd()

    # NOTE(jamespage): purge any packages as a result of py3 switch
    #                  at rocky.
    packages_to_purge = determine_purge_packages()
    request_nova_compute_restart = False
    if packages_to_purge:
        purge_packages(packages_to_purge)
        request_nova_compute_restart = True

    sysctl_settings = config('sysctl')
    if not is_container() and sysctl_settings:
        create_sysctl(sysctl_settings,
                      '/etc/sysctl.d/50-openvswitch.conf')

    configure_ovs()
    CONFIGS.write_all()
    # NOTE(fnordahl): configure_sriov must be run after CONFIGS.write_all()
    # to allow us to enable boot time execution of init script
    configure_sriov()
    for rid in relation_ids('neutron-plugin'):
        neutron_plugin_joined(
            relation_id=rid,
            request_restart=request_nova_compute_restart)
 def test_install_tmpfilesd_libvirt(self, mock_shutil, mock_subprocess):
     self.init_is_systemd.return_value = True
     self.group_exists.return_value = True
     self.user_exists.return_value = True
     nutils.install_tmpfilesd()
     mock_shutil.copy.assert_called_once()
     mock_subprocess.check_call.assert_called_once_with(
         ['systemd-tmpfiles', '--create'])
 def test_install_tmpfilesd_libvirt(self, mock_shutil, mock_subprocess):
     self.init_is_systemd.return_value = True
     self.group_exists.return_value = True
     self.user_exists.return_value = True
     nutils.install_tmpfilesd()
     mock_shutil.copy.assert_called_once()
     mock_subprocess.check_call.assert_called_once_with(
         ['systemd-tmpfiles', '--create']
     )
Esempio n. 7
0
def config_changed(check_deferred_restarts=True):
    configure_deferred_restarts(deferrable_services())
    # policy_rcd.remove_policy_file()
    # if we are paused, delay doing any config changed hooks.
    # It is forced on the resume.
    allowed, reason = is_hook_allowed(
        'config-changed', check_deferred_restarts=check_deferred_restarts)
    if not allowed:
        log(reason, "WARN")
        return

    install_packages()
    install_tmpfilesd()

    # NOTE(jamespage): purge any packages as a result of py3 switch
    #                  at rocky.
    packages_to_purge = determine_purge_packages()
    request_nova_compute_restart = False
    if packages_to_purge:
        purge_packages(packages_to_purge)
        request_nova_compute_restart = True

    sysctl_settings = config('sysctl')
    if not is_container() and sysctl_settings:
        create_sysctl(sysctl_settings, '/etc/sysctl.d/50-openvswitch.conf')

    # NOTE(fnordahl): It is important to write config to disk and perhaps
    # restart the openvswitch-swith service prior to attempting to do run-time
    # configuration of OVS as we may have to pass options to `ovs-ctl` for
    # `ovs-vswitchd` to run at all. LP: #1906280
    # TODO: make restart_on_change use contextlib.contextmanager
    @restart_on_change({
        cfg: services
        for cfg, services in restart_map().items() if cfg == OVS_DEFAULT
    })
    def _restart_before_runtime_config_when_required():
        CONFIGS.write_all()

    _restart_before_runtime_config_when_required()
    configure_ovs()

    for rid in relation_ids('neutron-plugin'):
        neutron_plugin_joined(relation_id=rid,
                              request_restart=request_nova_compute_restart)