use of org.ovirt.engine.core.common.network.SwitchType in project ovirt-engine by oVirt.
the class ClusterOperationCommandBase method setDefaultSwitchTypeIfNeeded.
protected void setDefaultSwitchTypeIfNeeded() {
Cluster cluster = getCluster();
if (!cluster.isSetRequiredSwitchType()) {
SwitchType defaultSwitchType = DefaultSwitchType.getDefaultSwitchType(cluster.getCompatibilityVersion());
cluster.setRequiredSwitchTypeForCluster(defaultSwitchType);
}
}
use of org.ovirt.engine.core.common.network.SwitchType in project ovirt-engine by oVirt.
the class HostSetupNetworksCommand method createSetupNetworksParameters.
private HostSetupNetworksVdsCommandParameters createSetupNetworksParameters(int timeout) {
SwitchType clusterSwitchType = getCluster().getRequiredSwitchTypeForCluster();
List<HostNetwork> networksToConfigure = calculateNetworksToConfigure();
final HostSetupNetworksVdsCommandParameters hostCmdParams = new HostSetupNetworksVdsCommandParameters(getVds(), networksToConfigure, getAllNetworksToRemove(), getParameters().getCreateOrUpdateBonds(), getRemovedBondNames(), clusterSwitchType);
hostCmdParams.setRollbackOnFailure(getParameters().rollbackOnFailure());
hostCmdParams.setConnectivityTimeout(timeout);
hostCmdParams.setManagementNetworkChanged(isManagementNetworkChanged(networksToConfigure));
return hostCmdParams;
}
use of org.ovirt.engine.core.common.network.SwitchType in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method addHostNetworksAndUpdateInterfaces.
private static void addHostNetworksAndUpdateInterfaces(VDS host, Map<String, String> vdsmNameMap, Map<String, Object> struct) {
Map<String, Map<String, Object>> bridges = (Map<String, Map<String, Object>>) struct.get(VdsProperties.NETWORK_BRIDGES);
final String hostActiveNicName = findActiveNicName(host, bridges);
host.setActiveNic(hostActiveNicName);
// Networks collection (name point to list of nics or bonds)
Map<String, Map<String, Object>> networks = (Map<String, Map<String, Object>>) struct.get(VdsProperties.NETWORKS);
Map<String, VdsNetworkInterface> vdsInterfaces = Entities.entitiesByName(host.getInterfaces());
if (networks != null) {
host.getNetworkNames().clear();
for (Entry<String, Map<String, Object>> entry : networks.entrySet()) {
Map<String, Object> networkProperties = entry.getValue();
String vdsmName = entry.getKey();
String networkName = vdsmNameMap.containsKey(vdsmName) ? vdsmNameMap.get(vdsmName) : vdsmName;
if (networkProperties != null) {
String interfaceName = (String) networkProperties.get(VdsProperties.INTERFACE);
Map<String, Object> bridgeProperties = (bridges == null) ? null : bridges.get(interfaceName);
boolean bridgedNetwork = isBridgedNetwork(networkProperties);
SwitchType switchType = getSwitchType(host.getSupportedClusterVersionsSet().stream().filter(v -> Version.getLast().compareTo(v) >= 0).max(Comparator.naturalOrder()).orElse(Version.getLowest()), networkProperties);
HostNetworkQos qos = new HostNetworkQosMapper(networkProperties).deserialize();
/**
* TODO: remove overly-defensive code in 4.0 - IP address, subnet, gateway and boot protocol should
* only be extracted for bridged networks and from bridge entries (not network entries)
*/
Map<String, Object> effectiveProperties = (bridgedNetwork && bridgeProperties != null) ? bridgeProperties : networkProperties;
String v4addr = extractAddress(effectiveProperties);
String v4Subnet = extractSubnet(effectiveProperties);
String v4gateway = (String) effectiveProperties.get(VdsProperties.GLOBAL_GATEWAY);
boolean v4DefaultRoute = assignBoolValue(effectiveProperties, VdsProperties.IPV4_DEFAULT_ROUTE);
final String rawIpv6Address = getIpv6Address(effectiveProperties);
String v6Addr = extractIpv6Address(rawIpv6Address);
Integer v6Prefix = extractIpv6Prefix(rawIpv6Address);
String v6gateway = (String) effectiveProperties.get(VdsProperties.IPV6_GLOBAL_GATEWAY);
List<VdsNetworkInterface> interfaces = findNetworkInterfaces(vdsInterfaces, interfaceName, bridgeProperties);
for (VdsNetworkInterface iface : interfaces) {
iface.setNetworkName(networkName);
iface.setIpv4Address(v4addr);
iface.setIpv4Subnet(v4Subnet);
iface.setIpv4DefaultRoute(v4DefaultRoute);
iface.setIpv6Address(v6Addr);
iface.setIpv6Prefix(v6Prefix);
iface.setBridged(bridgedNetwork);
iface.setReportedSwitchType(switchType);
iface.setQos(qos);
// set the management ip
if (getManagementNetworkUtil().isManagementNetwork(iface.getNetworkName(), host.getClusterId())) {
iface.setType(iface.getType() | VdsInterfaceType.MANAGEMENT.getValue());
}
if (StringUtils.isNotEmpty(v4gateway)) {
iface.setIpv4Gateway(v4gateway);
}
if (StringUtils.isNotEmpty(v6gateway)) {
iface.setIpv6Gateway(v6gateway);
}
if (bridgedNetwork) {
addBootProtocol(effectiveProperties, iface);
}
}
host.getNetworkNames().add(networkName);
reportInvalidInterfacesForNetwork(interfaces, networkName, host);
}
}
}
}
Aggregations