Java Code Examples for org.onosproject.net.Host#configured()

The following examples show how to use org.onosproject.net.Host#configured() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenstackSwitchingHostProviderTest.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void addLocationToHost(HostId hostId, HostLocation location) {
    Host oldHost = hostMap.get(hostId);

    Set<HostLocation> newHostlocations = oldHost.locations();
    newHostlocations.add(location);

    Host newHost = new DefaultHost(oldHost.providerId(),
            oldHost.id(),
            oldHost.mac(),
            oldHost.vlan(),
            newHostlocations,
            oldHost.ipAddresses(),
            oldHost.innerVlan(),
            oldHost.tpid(),
            oldHost.configured(),
            oldHost.annotations());

    hostMap.put(hostId, newHost);
}
 
Example 2
Source File: HostsWebResource.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and adds new host based on given data and returns its host ID.
 *
 * @param node JsonNode containing host information
 * @return host ID of new host created
 */
private HostId parseHost(JsonNode node) {
    Host host = codec(Host.class).decode((ObjectNode) node, HostsWebResource.this);

    HostId hostId = host.id();
    DefaultHostDescription desc = new DefaultHostDescription(
            host.mac(), host.vlan(), host.locations(), host.ipAddresses(), host.innerVlan(),
            host.tpid(), host.configured(), (SparseAnnotations) host.annotations());
    hostProviderService.hostDetected(hostId, desc, false);

    return hostId;
}
 
Example 3
Source File: BasicHostOperator.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a description of the given host.
 *
 * @param host the host
 * @return a description of the host
 */
public static HostDescription descriptionOf(Host host) {
    checkNotNull(host, "Must supply a non-null Host");
    return new DefaultHostDescription(host.mac(), host.vlan(), host.locations(),
                                      host.ipAddresses(), host.configured(),
                                      (SparseAnnotations) host.annotations());
}
 
Example 4
Source File: DefaultHostProbe.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs DefaultHostProbe with given retry.
 *
 * @param host host to be probed
 * @param connectPoint location to be verified
 * @param probeMac source MAC address of the probe
 * @param mode probe mode
 * @param retry number of retry
 */
DefaultHostProbe(Host host, ConnectPoint connectPoint, ProbeMode mode, MacAddress probeMac, int retry) {
    super(host.providerId(), host.id(), host.mac(), host.vlan(), host.locations(), host.ipAddresses(),
            host.configured());

    this.connectPoint = connectPoint;
    this.mode = mode;
    this.probeMac = probeMac;
    this.retry = retry;
}
 
Example 5
Source File: HostManager.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public void hostDetected(HostId hostId, HostDescription initialHostDescription, boolean replaceIps) {
    HostDescription hostDescription = initialHostDescription;
    checkNotNull(hostId, HOST_ID_NULL);
    checkValidity();
    hostDescription = validateHost(hostDescription, hostId);

    if (!allowDuplicateIps) {
        removeDuplicates(hostId, hostDescription);
    }

    BasicHostConfig cfg = networkConfigService.getConfig(hostId, BasicHostConfig.class);
    if (!isAllowed(cfg)) {
        log.warn("Host {} is not allowed to be added into the contol domain", hostId);
        return;
    }

    hostDescription = BasicHostOperator.combine(cfg, initialHostDescription);
    HostAnnotationConfig annoConfig = networkConfigService.getConfig(hostId, HostAnnotationConfig.class);
    if (annoConfig != null) {
        hostDescription = hostAnnotationOperator.combine(hostId, hostDescription, Optional.of(annoConfig));
    }

    if (!hostMoveTrackerEnabled) {
        store.createOrUpdateHost(provider().id(), hostId,
                hostDescription, replaceIps);
    } else if (!shouldBlock(hostId, hostDescription.locations())) {
        log.debug("Host move is allowed for host with Id: {} ", hostId);
        store.createOrUpdateHost(provider().id(), hostId,
                hostDescription, replaceIps);
    } else {
        log.info("Host move is NOT allowed for host with Id: {} , removing from host store ", hostId);
    }

    if (monitorHosts) {
        hostDescription.ipAddress().forEach(ip -> {
            monitor.addMonitoringFor(ip);
        });
    }

    // Greedy learning of IPv6 host. We have to disable the greedy
    // learning of configured hosts. Validate hosts each time will
    // overwrite the learnt information with the configured information.
    if (greedyLearningIpv6) {
        // Auto-generation of the IPv6 link local address
        // using the mac address
        Ip6Address targetIp6Address = Ip6Address.valueOf(
                getLinkLocalAddress(hostId.mac().toBytes())
        );
        // If we already know this guy we don't need to do other
        if (!hostDescription.ipAddress().contains(targetIp6Address)) {
            Host host = store.getHost(hostId);
            // Configured host, skip it.
            if (host != null && host.configured()) {
                return;
            }
            // Host does not exist in the store or the target is not known
            if ((host == null || !host.ipAddresses().contains(targetIp6Address))) {
                // Use DAD to probe if interface MAC is not specified
                MacAddress probeMac = interfaceService.getInterfacesByPort(hostDescription.location())
                        .stream().map(Interface::mac).findFirst().orElse(MacAddress.ONOS);
                Ip6Address probeIp = !probeMac.equals(MacAddress.ONOS) ?
                        Ip6Address.valueOf(getLinkLocalAddress(probeMac.toBytes())) :
                        Ip6Address.ZERO;
                // We send a probe using the monitoring service
                monitor.sendProbe(
                        hostDescription.location(),
                        targetIp6Address,
                        probeIp,
                        probeMac,
                        hostId.vlanId()
                );
            }
        }
    }
}
 
Example 6
Source File: HostManager.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Providers should only be able to remove a host that is provided by itself,
 * or a host that is not configured.
 */
private boolean allowedToChange(HostId hostId) {
    Host host = store.getHost(hostId);
    return host == null || !host.configured() || host.providerId().equals(provider().id());
}