Search in sources :

Example 1 with SwitchType

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);
    }
}
Also used : SwitchType(org.ovirt.engine.core.common.network.SwitchType) DefaultSwitchType(org.ovirt.engine.core.common.network.DefaultSwitchType) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Example 2 with SwitchType

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;
}
Also used : SwitchType(org.ovirt.engine.core.common.network.SwitchType) HostSetupNetworksVdsCommandParameters(org.ovirt.engine.core.common.vdscommands.HostSetupNetworksVdsCommandParameters) HostNetwork(org.ovirt.engine.core.common.vdscommands.HostNetwork)

Example 3 with SwitchType

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);
            }
        }
    }
}
Also used : RpmVersion(org.ovirt.engine.core.compat.RpmVersion) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) VdsNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics) Matcher(java.util.regex.Matcher) EnumUtils(org.ovirt.engine.core.common.utils.EnumUtils) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) Map(java.util.Map) VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmJob(org.ovirt.engine.core.common.businessentities.VmJob) Path(java.nio.file.Path) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) NameServer(org.ovirt.engine.core.common.businessentities.network.NameServer) Set(java.util.Set) CpuStatistics(org.ovirt.engine.core.common.businessentities.CpuStatistics) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) VmGuestAgentInterface(org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface) AutoNumaBalanceStatus(org.ovirt.engine.core.common.businessentities.AutoNumaBalanceStatus) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) Stream(java.util.stream.Stream) VDSDomainsData(org.ovirt.engine.core.common.businessentities.VDSDomainsData) Injector(org.ovirt.engine.core.di.Injector) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) NetworkCommonUtils(org.ovirt.engine.core.common.utils.NetworkCommonUtils) VmExitStatus(org.ovirt.engine.core.common.businessentities.VmExitStatus) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) BondMode(org.ovirt.engine.core.common.businessentities.network.BondMode) SessionState(org.ovirt.engine.core.common.businessentities.SessionState) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) NetworkStatisticsBuilder(org.ovirt.engine.core.vdsbroker.NetworkStatisticsBuilder) OsType(org.ovirt.engine.core.common.businessentities.OsType) SimpleDateFormat(java.text.SimpleDateFormat) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) NetworkUtils(org.ovirt.engine.core.utils.NetworkUtils) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) VmBlockJob(org.ovirt.engine.core.common.businessentities.VmBlockJob) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) LinkedHashSet(java.util.LinkedHashSet) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) VM(org.ovirt.engine.core.common.businessentities.VM) LeaseStatus(org.ovirt.engine.core.common.businessentities.LeaseStatus) NetworkInterface(org.ovirt.engine.core.common.businessentities.network.NetworkInterface) Paths(java.nio.file.Paths) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmJobType(org.ovirt.engine.core.common.businessentities.VmJobType) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) InterfaceStatus(org.ovirt.engine.core.common.businessentities.network.InterfaceStatus) Date(java.util.Date) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType) DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic) LoggerFactory(org.slf4j.LoggerFactory) VdsTransparentHugePagesState(org.ovirt.engine.core.common.businessentities.VdsTransparentHugePagesState) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) InterfaceByAddressPredicate(org.ovirt.engine.core.utils.network.predicate.InterfaceByAddressPredicate) SwitchType(org.ovirt.engine.core.common.network.SwitchType) KdumpStatus(org.ovirt.engine.core.common.businessentities.KdumpStatus) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) ParseException(java.text.ParseException) Version(org.ovirt.engine.core.compat.Version) DateFormat(java.text.DateFormat) VdsInterfaceType(org.ovirt.engine.core.common.businessentities.network.VdsInterfaceType) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) VmPauseStatus(org.ovirt.engine.core.common.businessentities.VmPauseStatus) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) Predicate(java.util.function.Predicate) ManagementNetworkUtil(org.ovirt.engine.core.bll.network.cluster.ManagementNetworkUtil) Ipv4BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) IpAddressPredicate(org.ovirt.engine.core.utils.network.predicate.IpAddressPredicate) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Entry(java.util.Map.Entry) AuditLogType(org.ovirt.engine.core.common.AuditLogType) Pattern(java.util.regex.Pattern) NumaUtils(org.ovirt.engine.core.utils.NumaUtils) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VmBalloonInfo(org.ovirt.engine.core.common.businessentities.VmBalloonInfo) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Entities(org.ovirt.engine.core.common.businessentities.Entities) HashMap(java.util.HashMap) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) DbFacade(org.ovirt.engine.core.dal.dbbroker.DbFacade) SizeConverter(org.ovirt.engine.core.common.utils.SizeConverter) VmBlockJobType(org.ovirt.engine.core.common.businessentities.VmBlockJobType) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) Config(org.ovirt.engine.core.common.config.Config) VmJobState(org.ovirt.engine.core.common.businessentities.VmJobState) Logger(org.slf4j.Logger) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) DecimalFormat(java.text.DecimalFormat) GuestContainer(org.ovirt.engine.core.common.businessentities.GuestContainer) V2VJobInfo(org.ovirt.engine.core.common.businessentities.V2VJobInfo) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) VmExitReason(org.ovirt.engine.core.common.businessentities.VmExitReason) SerializationFactory(org.ovirt.engine.core.utils.SerializationFactory) NetworkStatistics(org.ovirt.engine.core.common.businessentities.network.NetworkStatistics) Comparator(java.util.Comparator) NumaNodeStatistics(org.ovirt.engine.core.common.businessentities.NumaNodeStatistics) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) SwitchType(org.ovirt.engine.core.common.network.SwitchType) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

SwitchType (org.ovirt.engine.core.common.network.SwitchType)2 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 DateFormat (java.text.DateFormat)1 DecimalFormat (java.text.DecimalFormat)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 Set (java.util.Set)1 TimeUnit (java.util.concurrent.TimeUnit)1