def neutron_plugin_joined(relation_id=None, request_restart=False): secret = None if not is_container(): if enable_local_dhcp(): install_packages() else: pkgs = deepcopy(DHCP_PACKAGES) # NOTE: only purge metadata packages if dvr is not # in use as this will remove the l3 agent # see https://pad.lv/1515008 if not use_dvr(): # NOTE(fnordahl) do not remove ``haproxy``, the principal # charm may have use for it. LP: #1832739 pkgs.extend(set(METADATA_PACKAGES)-set(['haproxy'])) purge_packages(pkgs) secret = get_shared_secret() if enable_nova_metadata() else None rel_data = { 'metadata-shared-secret': secret, } host_info = os_context.HostInfoContext()() if use_fqdn_hint() and host_info.get('host_fqdn'): rel_data.update({'host': host_info['host_fqdn']}) if request_restart: rel_data['restart-nonce'] = str(uuid.uuid4()) relation_set(relation_id=relation_id, **rel_data)
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_packages(self, _determine_packages): self.os_release.return_value = 'mitaka' _determine_packages.return_value = 'randompkg' nutils.install_packages() self.apt_update.assert_called_with() self.apt_install.assert_called_with(self.filter_installed_packages(), fatal=True)
def neutron_plugin_api_changed(): packages_to_purge = [] if use_dvr(): install_packages() # per 17.08 release notes L3HA + DVR is a Newton+ feature _os_release = os_release('neutron-common', base='icehouse') if (use_l3ha() and CompareOpenStackReleases(_os_release) >= 'newton'): install_l3ha_packages() # NOTE(hopem): don't uninstall keepalived if not using l3ha since that # results in neutron-l3-agent also being uninstalled (see LP 1819499). else: packages_to_purge = deepcopy(DVR_PACKAGES) packages_to_purge.extend(L3HA_PACKAGES) if packages_to_purge: purge_packages(packages_to_purge) # 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: service for cfg, service 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() # If dvr setting has changed, need to pass that on for rid in relation_ids('neutron-plugin'): neutron_plugin_joined(relation_id=rid)
def test_install_packages(self, _determine_packages): self.os_release.return_value = 'mitaka' self.lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'} _determine_packages.return_value = 'randompkg' nutils.install_packages() self.apt_update.assert_called_with() self.apt_install.assert_called_with(self.filter_installed_packages(), fatal=True) self.modprobe.assert_not_called()
def test_install_packages_container(self, _determine_packages): self.os_release.return_value = 'mitaka' self.is_container.return_value = True _determine_packages.return_value = 'randompkg' nutils.install_packages() self.apt_update.assert_called_with() self.apt_install.assert_called_with(self.filter_installed_packages(), fatal=True) self.modprobe.assert_not_called()
def neutron_plugin_joined(relation_id=None): if enable_local_dhcp(): install_packages() else: purge_packages(DHCP_PACKAGES) secret = get_shared_secret() if enable_nova_metadata() else None rel_data = { 'metadata-shared-secret': secret, } relation_set(relation_id=relation_id, **rel_data)
def neutron_plugin_api_changed(): if use_dvr(): install_packages() else: purge_packages(DVR_PACKAGES) configure_ovs() CONFIGS.write_all() # If dvr setting has changed, need to pass that on for rid in relation_ids('neutron-plugin'): neutron_plugin_joined(relation_id=rid)
def config_changed(): install_packages() 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)
def install(): install_packages() # Start migration to agent registration with FQDNs for newly installed # units with OpenStack release Stein or newer. release = os_release('neutron-common') if CompareOpenStackReleases(release) >= 'stein': db = kv() db.set(USE_FQDN_KEY, True) db.flush()
def config_changed(): install_packages() if git_install_requested(): if config_value_changed('openstack-origin-git'): git_install(config('openstack-origin-git')) configure_ovs() CONFIGS.write_all() for rid in relation_ids('zeromq-configuration'): zeromq_configuration_relation_joined(rid) for rid in relation_ids('neutron-plugin'): neutron_plugin_joined(relation_id=rid)
def test_install_packages_ovs_firewall(self, _determine_packages): self.os_release.return_value = 'mitaka' _determine_packages.return_value = 'randompkg' self.is_container.return_value = False self.test_config.set('firewall-driver', 'openvswitch') nutils.install_packages() self.apt_update.assert_called_with() self.apt_install.assert_called_with(self.filter_installed_packages(), fatal=True) self.modprobe.assert_has_calls( [call('nf_conntrack_ipv4', True), call('nf_conntrack_ipv6', True)])
def test_install_packages_dkms_needed(self, _determine_packages): _determine_packages.return_value = 'randompkg' self.determine_dkms_package.return_value = \ ['openvswitch-datapath-dkms'] self.headers_package.return_value = 'linux-headers-foobar' nutils.install_packages() self.apt_update.assert_called_with() self.apt_install.assert_has_calls([ call(['linux-headers-foobar', 'openvswitch-datapath-dkms'], fatal=True), call(self.filter_installed_packages(), fatal=True), ])
def test_install_packages_dkms_needed(self, _determine_packages): _determine_packages.return_value = 'randompkg' self.determine_dkms_package.return_value = \ ['openvswitch-datapath-dkms'] self.headers_package.return_value = 'linux-headers-foobar' nutils.install_packages() self.apt_update.assert_called_with() self.apt_install.assert_has_calls([ call(['linux-headers-foobar', 'openvswitch-datapath-dkms'], fatal=True), call(self.filter_installed_packages()), ])
def test_install_packages_dkms_needed(self, _determine_packages): self.os_release.return_value = 'mitaka' self.lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'} _determine_packages.return_value = 'randompkg' self.determine_dkms_package.return_value = \ ['openvswitch-datapath-dkms'] self.headers_package.return_value = 'linux-headers-foobar' nutils.install_packages() self.apt_update.assert_called_with() self.apt_install.assert_has_calls([ call(['linux-headers-foobar', 'openvswitch-datapath-dkms'], fatal=True), call(self.filter_installed_packages(), fatal=True), ])
def test_install_packages_ovs_fw_newer_kernel(self, _determine_packages): self.os_release.return_value = 'mitaka' _determine_packages.return_value = 'randompkg' self.is_container.return_value = False self.test_config.set('firewall-driver', 'openvswitch') self.modprobe.side_effect = [ subprocess.CalledProcessError(0, ""), None ] nutils.install_packages() self.apt_update.assert_called_with() self.apt_install.assert_called_with(self.filter_installed_packages(), fatal=True) self.modprobe.assert_has_calls( [call('nf_conntrack_ipv4', True), call('nf_conntrack', True)])
def neutron_plugin_joined(relation_id=None): if enable_local_dhcp(): install_packages() else: pkgs = deepcopy(DHCP_PACKAGES) # NOTE: only purge metadata packages if dvr is not # in use as this will remove the l3 agent # see https://pad.lv/1515008 if not use_dvr(): pkgs.extend(METADATA_PACKAGES) purge_packages(pkgs) secret = get_shared_secret() if enable_nova_metadata() else None rel_data = { 'metadata-shared-secret': secret, } relation_set(relation_id=relation_id, **rel_data)
def test_install_packages_hwoffload(self, _determine_packages, _enable_hw_offload, _use_hw_offload): self.os_release.return_value = 'stein' self.lsb_release.return_value = {'DISTRIB_CODENAME': 'bionic'} _determine_packages.return_value = 'randompkg' _use_hw_offload.return_value = True self.determine_dkms_package.return_value = \ ['openvswitch-datapath-dkms'] self.headers_package.return_value = 'linux-headers-foobar' nutils.install_packages() self.apt_update.assert_called_with() self.apt_install.assert_has_calls([ call(['linux-headers-foobar', 'openvswitch-datapath-dkms'], fatal=True), call(self.filter_installed_packages(), fatal=True), ]) _enable_hw_offload.assert_called_once_with()
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)
def neutron_plugin_api_changed(): packages_to_purge = [] if use_dvr(): install_packages() # per 17.08 release notes L3HA + DVR is a Newton+ feature _os_release = os_release('neutron-common', base='icehouse') if (use_l3ha() and CompareOpenStackReleases(_os_release) >= 'newton'): install_l3ha_packages() # NOTE(hopem): don't uninstall keepalived if not using l3ha since that # results in neutron-l3-agent also being uninstalled (see LP 1819499). else: packages_to_purge = deepcopy(DVR_PACKAGES) packages_to_purge.extend(L3HA_PACKAGES) if packages_to_purge: purge_packages(packages_to_purge) configure_ovs() CONFIGS.write_all() # If dvr setting has changed, need to pass that on for rid in relation_ids('neutron-plugin'): neutron_plugin_joined(relation_id=rid)
def install(): install_packages() git_install(config('openstack-origin-git'))
def test_install_packages(self, _determine_packages): _determine_packages.return_value = 'randompkg' nutils.install_packages() self.apt_update.assert_called_with() self.apt_install.assert_called_with(self.filter_installed_packages())
def install(): install_packages()