Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ansible: Reconfigure OVN during host upgrade
Reconfigure OVN on host when the upgrade process
updates OvS/OVN version from 2.11 to >=2.15.

Change-Id: I5f3d8d37ca8df2b557087a91038fe447454999c1
Bug-Url: https://bugzilla.redhat.com/1940824
Signed-off-by: Ales Musil <amusil@redhat.com>
  • Loading branch information
almusil authored and mwperina committed Sep 3, 2021
1 parent 4e146a0 commit 77bccdb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 1 deletion.
Expand Up @@ -10,6 +10,7 @@

import org.apache.commons.lang.StringUtils;
import org.ovirt.engine.core.bll.CertificationValidityChecker;
import org.ovirt.engine.core.bll.network.cluster.NetworkHelper;
import org.ovirt.engine.core.common.AuditLogType;
import org.ovirt.engine.core.common.HostUpgradeManagerResult;
import org.ovirt.engine.core.common.businessentities.Cluster;
Expand All @@ -29,6 +30,7 @@
import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl;
import org.ovirt.engine.core.dao.ClusterDao;
import org.ovirt.engine.core.utils.EngineLocalConfig;
import org.ovirt.engine.core.utils.NetworkUtils;
import org.ovirt.engine.core.utils.PKIResources;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -54,6 +56,9 @@ public class HostUpgradeManager implements UpdateAvailable, Updateable {
@Inject
private ClusterDao clusterDao;

@Inject
private NetworkHelper networkHelper;

@Override
public HostUpgradeManagerResult checkForUpdates(final VDS host) {
AnsibleReturnValue ansibleReturnValue = null;
Expand Down Expand Up @@ -182,6 +187,20 @@ Config.<Integer> getValue(ConfigValues.SignCertTimeoutInSeconds))
PKIResources.getQemuCaCertificate()
.toString(PKIResources.Format.OPENSSH_PUBKEY)
.replace("\n", ""))
.variable("host_deploy_origin_type", Config.getValue(ConfigValues.OriginType));
.variable("host_deploy_origin_type", Config.getValue(ConfigValues.OriginType))
.variable("host_deploy_ovn_central", getOvnCentral(cluster))
.variable("host_deploy_ovn_tunneling_interface", NetworkUtils.getHostIp(host));
}

private String getOvnCentral(Cluster cluster) {
var provider = networkHelper.getOvirtProviderOvn(cluster.getDefaultNetworkProviderId());
if (provider == null) {
return null;
}
String ovnCentral = NetworkUtils.getIpAddress(provider.getUrl());
if (ovnCentral == null) {
throw new RuntimeException(String.format("Failed to extract OVN central IP from %1$s", provider.getUrl()));
}
return ovnCentral;
}
}
1 change: 1 addition & 0 deletions ovirt-engine.spec.in
Expand Up @@ -1294,6 +1294,7 @@ fi
%{engine_data}/ansible-runner-service-project/project/replace-gluster.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-enroll-certificate.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-fix-encrypted-migrations.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-reconfigure-ovn.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-remove.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-upgrade.yml
%{engine_data}/ansible-runner-service-project/project/ovirt-host-check-upgrade.yml
Expand Down
@@ -0,0 +1,16 @@
- name: Fetch installed packages
package_facts:
manager: auto

- name: Check version of ovirt-openvswitch after upgrade
set_fact:
ovirt_openvswitch_post: "{{ ansible_facts.packages['ovirt-openvswitch'] | first }}"

- name: Reconfigure OVN for oVirt
command: >
vdsm-tool ovn-config {{ ovn_central }} {{ ovn_tunneling_interface }}
when:
- ovirt_openvswitch_pre.version is version('2.11', '==')
- ovirt_openvswitch_post.version is version('2.15', '>=')
- ovn_central is defined
- ovn_central | ipaddr
Expand Up @@ -73,3 +73,4 @@

post_tasks:
- include: ovirt-host-remove-yum-conf.yml
- include: ovirt-host-reconfigure-ovn.yml
Expand Up @@ -40,3 +40,8 @@ ovirt_ovn_ca_file: 'ovn/ca-cert.pem'
# VDSM private key variables:
ovirt_vdsm_key_size: 2048
ovirt_vdsm_key_type: rsa

# OVN
ovn_central: "{{ host_deploy_ovn_central | default(omit) }}"
ovn_tunneling_interface: "{{ host_deploy_ovn_tunneling_interface | default('ovirtmgmt') }}"
check_ovs_version: true
Expand Up @@ -26,3 +26,11 @@
- name: Detect if host is a prebuilt image
set_fact:
node_host: "{{ not node_presence.changed }}"

- name: Check version of ovirt-openvswitch before upgrade
set_fact:
ovirt_openvswitch_pre: "{{ ansible_facts.packages['ovirt-openvswitch'] | first }}"
when:
- check_ovs_version is defined
- check_ovs_version | bool
- ovirt_openvswitch_pre is not defined

0 comments on commit 77bccdb

Please sign in to comment.