当前位置: 首页>>代码示例>>Java>>正文


Java HostId.hostId方法代码示例

本文整理汇总了Java中org.onosproject.net.HostId.hostId方法的典型用法代码示例。如果您正苦于以下问题:Java HostId.hostId方法的具体用法?Java HostId.hostId怎么用?Java HostId.hostId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.onosproject.net.HostId的用法示例。


在下文中一共展示了HostId.hostId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSingleHostByMacAndVlanFetch

import org.onosproject.net.HostId; //导入方法依赖的package包/类
/**
 * Tests fetch of one host by mac and vlan.
 */
@Test
public void testSingleHostByMacAndVlanFetch() {
    final ProviderId pid = new ProviderId("of", "foo");
    final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
    final Set<IpAddress> ips1 = ImmutableSet.of(IpAddress.valueOf("1111:1111:1111:1::"));
    final Host host1 =
            new DefaultHost(pid, HostId.hostId(mac1), valueOf(1), vlanId((short) 1),
                    new HostLocation(DeviceId.deviceId("1"), portNumber(11), 1),
                    ips1);

    hosts.add(host1);

    expect(mockHostService.getHost(HostId.hostId("00:00:11:00:00:01/1")))
            .andReturn(host1)
            .anyTimes();
    replay(mockHostService);

    WebTarget wt = target();
    String response = wt.path("hosts/00:00:11:00:00:01/1").request().get(String.class);
    final JsonObject result = Json.parse(response).asObject();
    assertThat(result, matchesHost(host1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:HostResourceTest.java

示例2: parseHost

import org.onosproject.net.HostId; //导入方法依赖的package包/类
/**
 * 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) {
    MacAddress mac = MacAddress.valueOf(node.get("mac").asText());
    VlanId vlanId = VlanId.vlanId((short) node.get("vlan").asInt(VlanId.UNTAGGED));
    JsonNode locationNode = node.get("location");
    String deviceAndPort = locationNode.get("elementId").asText() + "/" +
            locationNode.get("port").asText();
    HostLocation hostLocation = new HostLocation(ConnectPoint.deviceConnectPoint(deviceAndPort), 0);

    Iterator<JsonNode> ipStrings = node.get("ipAddresses").elements();
    Set<IpAddress> ips = new HashSet<>();
    while (ipStrings.hasNext()) {
        ips.add(IpAddress.valueOf(ipStrings.next().asText()));
    }

    // try to remove elements from json node after reading them
    SparseAnnotations annotations = annotations(removeElements(node, REMOVAL_KEYS));
    // Update host inventory

    HostId hostId = HostId.hostId(mac, vlanId);
    DefaultHostDescription desc = new DefaultHostDescription(mac, vlanId, hostLocation, ips, annotations);
    hostProviderService.hostDetected(hostId, desc, false);
    return hostId;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:HostsWebResource.java

示例3: testSingleHostByIdFetch

import org.onosproject.net.HostId; //导入方法依赖的package包/类
/**
 * Tests fetch of one host by Id.
 */
@Test
public void testSingleHostByIdFetch() {
    final ProviderId pid = new ProviderId("of", "foo");
    final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
    final Set<IpAddress> ips1 = ImmutableSet.of(IpAddress.valueOf("1111:1111:1111:1::"));
    final Host host1 =
            new DefaultHost(pid, HostId.hostId(mac1), valueOf(1), vlanId((short) 1),
                    new HostLocation(DeviceId.deviceId("1"), portNumber(11), 1),
                    ips1);

    hosts.add(host1);

    expect(mockHostService.getHost(HostId.hostId("00:00:11:00:00:01/1")))
            .andReturn(host1)
            .anyTimes();
    replay(mockHostService);

    WebTarget wt = target();
    String response = wt.path("hosts/00:00:11:00:00:01%2F1").request().get(String.class);
    final JsonObject result = Json.parse(response).asObject();
    assertThat(result, matchesHost(host1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:HostResourceTest.java

示例4: execute

import org.onosproject.net.HostId; //导入方法依赖的package包/类
@Override
protected void execute() {
    IntentService service = get(IntentService.class);

    HostId oneId = HostId.hostId(one);
    HostId twoId = HostId.hostId(two);

    TrafficSelector selector = buildTrafficSelector();
    TrafficTreatment treatment = buildTrafficTreatment();
    List<Constraint> constraints = buildConstraints();

    HostToHostIntent intent = HostToHostIntent.builder()
            .appId(appId())
            .key(key())
            .one(oneId)
            .two(twoId)
            .selector(selector)
            .treatment(treatment)
            .constraints(constraints)
            .priority(priority())
            .build();
    service.submit(intent);
    print("Host to Host intent submitted:\n%s", intent.toString());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:AddHostToHostIntentCommand.java

示例5: discoverHost

import org.onosproject.net.HostId; //导入方法依赖的package包/类
/**
 * Integrates hosts learned through DHCP into topology.
 * @param context context of the incoming message
 * @param ipAssigned IP Address assigned to the host by DHCP Manager
 */
private void discoverHost(PacketContext context, Ip4Address ipAssigned) {
    if (!allowHostDiscovery) {
        // host discovery is not allowed, do nothing
        return;
    }

    Ethernet packet = context.inPacket().parsed();
    MacAddress mac = packet.getSourceMAC();
    VlanId vlanId = VlanId.vlanId(packet.getVlanID());
    HostLocation hostLocation = new HostLocation(context.inPacket().receivedFrom(), 0);

    Set<IpAddress> ips = new HashSet<>();
    ips.add(ipAssigned);

    HostId hostId = HostId.hostId(mac, vlanId);
    DefaultHostDescription desc = new DefaultHostDescription(mac, vlanId, hostLocation, ips);

    log.info("Discovered host {}", desc);
    hostProviderService.hostDetected(hostId, desc, false);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:DhcpManager.java

示例6: createHost

import org.onosproject.net.HostId; //导入方法依赖的package包/类
private Host createHost() {
    MacAddress mac = MacAddress.valueOf("00:00:11:00:00:01");
    VlanId vlan = VlanId.vlanId((short) 10);
    HostLocation loc = new HostLocation(
                DeviceId.deviceId("of:foo"),
                PortNumber.portNumber(100),
                123L
            );
    Set<IpAddress> ipset = Sets.newHashSet(
                IpAddress.valueOf("10.0.0.1"),
                IpAddress.valueOf("10.0.0.2")
            );
    HostId hid = HostId.hostId(mac, vlan);

    return new DefaultHost(
            new ProviderId("of", "foo"), hid, mac, vlan, loc, ipset);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:HostEventTest.java

示例7: removeStaticIP

import org.onosproject.net.HostId; //导入方法依赖的package包/类
@Override
public boolean removeStaticIP(MacAddress macID) {
    HostId host = HostId.hostId(macID);
    if (allocationMap.containsKey(host)) {
        IpAssignment assignment = allocationMap.get(host).value();

        if (assignment.assignmentStatus().equals(Option_RangeNotEnforced)) {
            allocationMap.remove(host);
            return true;
        }

        Ip4Address freeIP = assignment.ipAddress();
        if (assignment.leasePeriod() < 0) {
            allocationMap.remove(host);
            if (ipWithinRange(freeIP)) {
                freeIPPool.add(freeIP);
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:DistributedDhcpStore.java

示例8: decode

import org.onosproject.net.HostId; //导入方法依赖的package包/类
@Override
public ConnectPoint decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    ElementId elementId;
    if (json.has(ELEMENT_DEVICE)) {
        elementId = DeviceId.deviceId(json.get(ELEMENT_DEVICE).asText());
    } else if (json.has(ELEMENT_HOST)) {
        elementId = HostId.hostId(json.get(ELEMENT_HOST).asText());
    } else {
        // invalid JSON
        return null;
    }
    PortNumber portNumber = portNumber(json.get(PORT).asText());
    return new ConnectPoint(elementId, portNumber);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:ConnectPointCodec.java

示例9: handleArpRequest

import org.onosproject.net.HostId; //导入方法依赖的package包/类
private void handleArpRequest(DeviceId deviceId, ConnectPoint inPort, Ethernet payload) {
    ARP arpRequest = (ARP) payload.getPayload();
    VlanId vlanId = VlanId.vlanId(payload.getVlanID());
    HostId targetHostId = HostId.hostId(MacAddress.valueOf(
                                        arpRequest.getTargetHardwareAddress()),
                                        vlanId);

    // ARP request for router. Send ARP reply.
    if (isArpForRouter(deviceId, arpRequest)) {
        Ip4Address targetAddress = Ip4Address.valueOf(arpRequest.getTargetProtocolAddress());
        sendArpResponse(arpRequest, config.getRouterMacForAGatewayIp(targetAddress), vlanId);
    } else {
        Host targetHost = srManager.hostService.getHost(targetHostId);
        // ARP request for known hosts. Send proxy ARP reply on behalf of the target.
        if (targetHost != null) {
            removeVlanAndForward(payload, targetHost.location());
        // ARP request for unknown host in the subnet. Flood in the subnet.
        } else {
            removeVlanAndFlood(payload, inPort);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:ArpHandler.java

示例10: updateForMode

import org.onosproject.net.HostId; //导入方法依赖的package包/类
private void updateForMode(String id) {
    log.debug("host service: {}", hostService);
    log.debug("device service: {}", deviceService);

    try {
        HostId hid = HostId.hostId(id);
        log.debug("host id {}", hid);
        elementOfNote = hostService.getHost(hid);
        log.debug("host element {}", elementOfNote);

    } catch (Exception e) {
        try {
            DeviceId did = DeviceId.deviceId(id);
            log.debug("device id {}", did);
            elementOfNote = deviceService.getDevice(did);
            log.debug("device element {}", elementOfNote);

        } catch (Exception e2) {
            log.debug("Unable to process ID [{}]", id);
            elementOfNote = null;
        }
    }

    switch (currentMode) {
        case MOUSE:
            sendMouseData();
            break;

        case LINK:
            sendLinkData();
            break;

        default:
            break;
    }

}
 
开发者ID:shlee89,项目名称:athena,代码行数:38,代码来源:AppUiTopovMessageHandler.java

示例11: elementId

import org.onosproject.net.HostId; //导入方法依赖的package包/类
private ElementId elementId(String id) {
    try {
        return DeviceId.deviceId(id);
    } catch (IllegalArgumentException e) {
        return HostId.hostId(id);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:PathPainterTopovMessageHandler.java

示例12: onVirtualPortDeleted

import org.onosproject.net.HostId; //导入方法依赖的package包/类
public void onVirtualPortDeleted(VtnRscEventFeedback l3Feedback) {
    VirtualPort vPort = l3Feedback.virtualPort();
    HostId hostId = HostId.hostId(vPort.macAddress());
    BasicHostConfig basicHostConfig = networkConfigService.addConfig(hostId,
                                                                     BasicHostConfig.class);
    Set<IpAddress> ips = hostService.getHost(hostId).ipAddresses();
    for (FixedIp fixedIp : vPort.fixedIps()) {
        ips.remove(fixedIp.ip());
    }
    basicHostConfig.setIps(ips).apply();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:VtnManager.java

示例13: handleArpReply

import org.onosproject.net.HostId; //导入方法依赖的package包/类
private void handleArpReply(DeviceId deviceId, ConnectPoint inPort, Ethernet payload) {
    ARP arpReply = (ARP) payload.getPayload();
    VlanId vlanId = VlanId.vlanId(payload.getVlanID());
    HostId targetHostId = HostId.hostId(MacAddress.valueOf(
                                        arpReply.getTargetHardwareAddress()),
                                        vlanId);

    // ARP reply for router. Process all pending IP packets.
    if (isArpForRouter(deviceId, arpReply)) {
        Ip4Address hostIpAddress = Ip4Address.valueOf(arpReply.getSenderProtocolAddress());
        srManager.ipHandler.forwardPackets(deviceId, hostIpAddress);
    } else {
        Host targetHost = srManager.hostService.getHost(targetHostId);
        // ARP reply for known hosts. Forward to the host.
        if (targetHost != null) {
            removeVlanAndForward(payload, targetHost.location());
        // ARP reply for unknown host, Flood in the subnet.
        } else {
            // Don't flood to non-edge ports
            if (vlanId.equals(
                    VlanId.vlanId(SegmentRoutingManager.ASSIGNED_VLAN_NO_SUBNET))) {
                return;
            }
            removeVlanAndFlood(payload, inPort);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:ArpHandler.java

示例14: sendArpResponse

import org.onosproject.net.HostId; //导入方法依赖的package包/类
private void sendArpResponse(ARP arpRequest, MacAddress targetMac, VlanId vlanId) {
    ARP arpReply = new ARP();
    arpReply.setHardwareType(ARP.HW_TYPE_ETHERNET)
            .setProtocolType(ARP.PROTO_TYPE_IP)
            .setHardwareAddressLength(
                    (byte) Ethernet.DATALAYER_ADDRESS_LENGTH)
            .setProtocolAddressLength((byte) Ip4Address.BYTE_LENGTH)
            .setOpCode(ARP.OP_REPLY)
            .setSenderHardwareAddress(targetMac.toBytes())
            .setSenderProtocolAddress(arpRequest.getTargetProtocolAddress())
            .setTargetHardwareAddress(arpRequest.getSenderHardwareAddress())
            .setTargetProtocolAddress(arpRequest.getSenderProtocolAddress());

    Ethernet eth = new Ethernet();
    eth.setDestinationMACAddress(arpRequest.getSenderHardwareAddress())
            .setSourceMACAddress(targetMac.toBytes())
            .setEtherType(Ethernet.TYPE_ARP).setPayload(arpReply);

    MacAddress hostMac = MacAddress.valueOf(arpReply.getTargetHardwareAddress());
    HostId dstId = HostId.hostId(hostMac, vlanId);
    Host dst = srManager.hostService.getHost(dstId);
    if (dst == null) {
        log.warn("Cannot send ARP response to host {}", dstId);
        return;
    }

    TrafficTreatment treatment = DefaultTrafficTreatment.builder().
            setOutput(dst.location().port()).build();
    OutboundPacket packet = new DefaultOutboundPacket(dst.location().deviceId(),
            treatment, ByteBuffer.wrap(eth.serialize()));

    srManager.packetService.emit(packet);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:ArpHandler.java

示例15: createHost

import org.onosproject.net.HostId; //导入方法依赖的package包/类
private Host createHost(MacAddress macAddress, ConnectPoint location) {
    return new DefaultHost(
            new ProviderId("host", "org.onosproject.segmentrouting"),
            HostId.hostId(macAddress),
            macAddress,
            VlanId.NONE,
            new HostLocation(location, System.currentTimeMillis()),
            ImmutableSet.of());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:CordConfigHandler.java


注:本文中的org.onosproject.net.HostId.hostId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。