Mike Kolesnik has uploaded a new change for review. Change subject: engine: Save gateway for host's active NIC ......................................................................
engine: Save gateway for host's active NIC The gateway should be saved not only for the NIC that has the management network, but also for the active NIC which the host communicated through so that we can use it for example when the management network is not provisioned on the host and we want to add it, such as when adding a new host. Change-Id: Ic4664e44880943b1b97559ef10f66aa82efad2fd Bug-Url: https://bugzilla.redhat.com/972615 Signed-off-by: Mike Kolesnik <mkole...@redhat.com> --- M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java 1 file changed, 17 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/70/16870/1 diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java index 627981c..9adfc8f 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java @@ -956,6 +956,7 @@ currVlans, networkVlans, network, + vds, net); } @@ -1075,7 +1076,7 @@ if (config != null && config.get("BONDING_OPTS") != null) { iface.setBondOptions(config.get("BONDING_OPTS").toString()); } - addBootProtocol(config, iface); + addBootProtocol(config, vds, iface); } } } @@ -1124,7 +1125,7 @@ } iStats.setVdsId(vds.getId()); - addBootProtocol((Map<String, Object>) vlan.get("cfg"), iface); + addBootProtocol((Map<String, Object>) vlan.get("cfg"), vds, iface); vds.getInterfaces().add(iface); } } @@ -1151,7 +1152,7 @@ iface.setName(entry.getKey()); iface.setVdsId(vds.getId()); - updateNetworkInterfaceDataFromHost(iface, (Map<String, Object>) entry.getValue()); + updateNetworkInterfaceDataFromHost(iface, vds, (Map<String, Object>) entry.getValue()); iStats.setVdsId(vds.getId()); vds.getInterfaces().add(iface); @@ -1167,7 +1168,8 @@ * @param nic * A key-value map of the interface properties and their value */ - private static void updateNetworkInterfaceDataFromHost(VdsNetworkInterface iface, Map<String, Object> nic) { + private static void updateNetworkInterfaceDataFromHost( + VdsNetworkInterface iface, VDS host, Map<String, Object> nic) { if (nic != null) { if (nic.get("speed") != null) { Object speed = nic.get("speed"); @@ -1183,7 +1185,7 @@ if (StringUtils.isNotBlank((String) nic.get(VdsProperties.MTU))) { iface.setMtu(Integer.parseInt((String) nic.get(VdsProperties.MTU))); } - addBootProtocol((Map<String, Object>) nic.get("cfg"), iface); + addBootProtocol((Map<String, Object>) nic.get("cfg"), host, iface); } } @@ -1205,6 +1207,7 @@ Map<String, Integer> currVlans, Map<String, Integer> networkVlans, Map<String, Object> network, + VDS host, Network net) { if (iface != null) { @@ -1223,11 +1226,11 @@ iface.setSubnet(net.getSubnet()); boolean bridgedNetwork = isBridgedNetwork(network); iface.setBridged(bridgedNetwork); - setGatewayIfManagementNetwork(iface, net.getGateway()); + setGatewayIfManagementNetwork(iface, host, net.getGateway()); if (bridgedNetwork) { Map<String, Object> networkConfig = (Map<String, Object>) network.get("cfg"); - addBootProtocol(networkConfig, iface); + addBootProtocol(networkConfig, host, iface); } } } @@ -1262,7 +1265,7 @@ } } - private static void addBootProtocol(Map<String, Object> cfg, VdsNetworkInterface iface) { + private static void addBootProtocol(Map<String, Object> cfg, VDS host, VdsNetworkInterface iface) { NetworkBootProtocol bootproto = NetworkBootProtocol.NONE; if (cfg != null) { @@ -1283,7 +1286,7 @@ if (bootproto == NetworkBootProtocol.STATIC_IP) { String gateway = (String) cfg.get(VdsProperties.GATEWAY); if (StringUtils.isNotEmpty(gateway)) { - setGatewayIfManagementNetwork(iface, gateway.toString()); + setGatewayIfManagementNetwork(iface, host, gateway.toString()); } } } @@ -1305,16 +1308,17 @@ } /** - * Store the gateway for management network only. If gateway was provided for non-management network, its value - * should be ignored + * Store the gateway for management network or the active interface only (could happen when there is no management + * network yet). If gateway was provided for non-management network, its value should be ignored. * * @param iface * the host network interface * @param gateway * the gateway value to be set */ - private static void setGatewayIfManagementNetwork(VdsNetworkInterface iface, String gateway) { - if (NetworkUtils.getEngineNetwork().equals(iface.getNetworkName())) { + private static void setGatewayIfManagementNetwork(VdsNetworkInterface iface, VDS host, String gateway) { + if (NetworkUtils.getEngineNetwork().equals(iface.getNetworkName()) + || iface.getName().equals(host.getActiveNic())) { iface.setGateway(gateway); } } -- To view, visit http://gerrit.ovirt.org/16870 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic4664e44880943b1b97559ef10f66aa82efad2fd Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Mike Kolesnik <mkole...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches