本文整理汇总了Java中org.onosproject.net.Host类的典型用法代码示例。如果您正苦于以下问题:Java Host类的具体用法?Java Host怎么用?Java Host使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Host类属于org.onosproject.net包,在下文中一共展示了Host类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSingleHostByMacAndVlanFetch
import org.onosproject.net.Host; //导入依赖的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: complete
import org.onosproject.net.Host; //导入依赖的package包/类
@Override
public int complete(String buffer, int cursor, List<String> candidates) {
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
HostService service = AbstractShellCommand.get(HostService.class);
Iterator<Host> it = service.getHosts().iterator();
SortedSet<String> strings = delegate.getStrings();
while (it.hasNext()) {
strings.add(it.next().id().toString());
}
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(buffer, cursor, candidates);
}
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:HostIdCompleter.java
示例3: getLinkFlowCounts
import org.onosproject.net.Host; //导入依赖的package包/类
private Map<Link, Integer> getLinkFlowCounts(DeviceId deviceId) {
// get the flows for the device
List<FlowEntry> entries = new ArrayList<>();
for (FlowEntry flowEntry : servicesBundle.flowService()
.getFlowEntries(deviceId)) {
entries.add(flowEntry);
}
// get egress links from device, and include edge links
Set<Link> links = new HashSet<>(servicesBundle.linkService()
.getDeviceEgressLinks(deviceId));
Set<Host> hosts = servicesBundle.hostService().getConnectedHosts(deviceId);
if (hosts != null) {
for (Host host : hosts) {
links.add(createEdgeLink(host, false));
}
}
// compile flow counts per link
Map<Link, Integer> counts = new HashMap<>();
for (Link link : links) {
counts.put(link, getEgressFlows(link, entries));
}
return counts;
}
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:TrafficMonitor.java
示例4: forward
import org.onosproject.net.Host; //导入依赖的package包/类
@Override
public void forward(ConnectPoint outPort, Host subject, ByteBuffer packet) {
/*NodeId nodeId = mastershipService.getMasterFor(outPort.deviceId());
if (nodeId.equals(localNodeId)) {
if (delegate != null) {
delegate.emitResponse(outPort, packet);
}
} else {
log.info("Forwarding ARP response from {} to {}", subject.id(), outPort);
commService.unicast(new ArpResponseMessage(outPort, subject, packet.array()),
ARP_RESPONSE_MESSAGE, serializer::encode, nodeId);
}*/
//FIXME: Code above may be unnecessary and therefore cluster messaging
// and pendingMessages could be pruned as well.
delegate.emitResponse(outPort, packet);
}
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:DistributedProxyArpStore.java
示例5: getLinkFlowCounts
import org.onosproject.net.Host; //导入依赖的package包/类
private Map<Link, Integer> getLinkFlowCounts(DeviceId deviceId) {
// get the flows for the device
List<FlowEntry> entries = new ArrayList<>();
for (FlowEntry flowEntry : flowService.getFlowEntries(deviceId)) {
entries.add(flowEntry);
}
// get egress links from device, and include edge links
Set<Link> links = new HashSet<>(linkService.getDeviceEgressLinks(deviceId));
Set<Host> hosts = hostService.getConnectedHosts(deviceId);
if (hosts != null) {
for (Host host : hosts) {
links.add(createEdgeLink(host, false));
}
}
// compile flow counts per link
Map<Link, Integer> counts = new HashMap<>();
for (Link link : links) {
counts.put(link, getEgressFlows(link, entries));
}
return counts;
}
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:TopologyViewMessageHandlerBase.java
示例6: createHost
import org.onosproject.net.Host; //导入依赖的package包/类
/**
* Creates a default host connected at the given edge device and port. Note
* that an identifying hex character ("a" - "f") should be supplied. This
* will be included in the MAC address of the host (and equivalent value
* as last byte in IP address).
*
* @param device edge device
* @param port port number
* @param hexChar identifying hex character
* @return host connected at that location
*/
protected static Host createHost(Device device, int port, String hexChar) {
DeviceId deviceId = device.id();
String devNum = deviceId.toString().substring(1);
MacAddress mac = MacAddress.valueOf(HOST_MAC_PREFIX + devNum + hexChar);
HostId hostId = hostId(String.format("%s/-1", mac));
int ipByte = Integer.valueOf(hexChar, 16);
if (ipByte < 10 || ipByte > 15) {
throw new IllegalArgumentException("hexChar must be a-f");
}
HostLocation loc = new HostLocation(deviceId, portNumber(port), 0);
IpAddress ip = ip("10." + devNum + ".0." + ipByte);
return new DefaultHost(ProviderId.NONE, hostId, mac, VlanId.NONE,
loc, ImmutableSet.of(ip));
}
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:AbstractTopoModelTest.java
示例7: createHost
import org.onosproject.net.Host; //导入依赖的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
示例8: testForwardToHost
import org.onosproject.net.Host; //导入依赖的package包/类
/**
* Tests {@link ProxyArpManager#forward(Ethernet, ConnectPoint)} in the case where the
* destination host is known.
* Verifies the correct ARP request is sent out the correct port.
*/
@Test
public void testForwardToHost() {
Host host1 = new DefaultHost(PID, HID1, MAC1, VLAN1, LOC1,
Collections.singleton(IP1));
Host host2 = new DefaultHost(PID, HID2, MAC2, VLAN1, LOC2,
Collections.singleton(IP2));
expect(hostService.getHost(HID1)).andReturn(host1);
expect(hostService.getHost(HID2)).andReturn(host2);
replay(hostService);
replay(interfaceService);
Ethernet arpRequest = buildArp(ARP.OP_REPLY, VLAN1, MAC2, MAC1, IP2, IP1);
proxyArp.forward(arpRequest, LOC2);
assertEquals(1, packetService.packets.size());
OutboundPacket packet = packetService.packets.get(0);
verifyPacketOut(arpRequest, LOC1, packet);
}
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:ProxyArpManagerTest.java
示例9: setUpHostService
import org.onosproject.net.Host; //导入依赖的package包/类
/**
* Sets up the host service with details of some hosts.
*/
private void setUpHostService() {
hostService = createMock(HostService.class);
hostService.addListener(anyObject(HostListener.class));
expectLastCall().andDelegateTo(new TestHostService()).anyTimes();
Host host1 = createHost(MAC1, V4_NEXT_HOP1);
expectHost(host1);
Host host2 = createHost(MAC2, V4_NEXT_HOP2);
expectHost(host2);
Host host3 = createHost(MAC3, V6_NEXT_HOP1);
expectHost(host3);
Host host4 = createHost(MAC4, V6_NEXT_HOP2);
expectHost(host4);
replay(hostService);
}
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:RouteManagerTest.java
示例10: testConfiguredVlanOnInterfaces
import org.onosproject.net.Host; //导入依赖的package包/类
/**
* Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
* a vlan packet comes in from a port without interfaces configured. The destination
* host is not known for that IP address and there are some interfaces configured on
* the same vlan.
* It's expected to see the ARP request going out through ports with no interfaces
* configured, devices 4 and 5, port 1.
*
* Verifies the ARP request is flooded out the correct edge ports.
*/
@Test
public void testConfiguredVlanOnInterfaces() {
Host requestor = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(6),
Collections.singleton(IP1));
expect(hostService.getHostsByIp(IP2))
.andReturn(Collections.emptySet());
expect(interfaceService.getInterfacesByIp(IP1))
.andReturn(Collections.emptySet());
expect(hostService.getHost(HID1)).andReturn(requestor);
replay(hostService);
replay(interfaceService);
Ethernet arpRequest = buildArp(ARP.OP_REQUEST, VLAN1, MAC1, null, IP1, IP2);
proxyArp.reply(arpRequest, getLocation(6));
verifyFlood(arpRequest, configVlanCPoints);
}
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:ProxyArpManagerTest.java
示例11: generateIntents
import org.onosproject.net.Host; //导入依赖的package包/类
private Collection<Intent> generateIntents() {
List<Host> hosts = Lists.newArrayList(hostService.getHosts());
List<Intent> fullMesh = Lists.newArrayList();
for (int i = 0; i < hosts.size(); i++) {
for (int j = i + 1; j < hosts.size(); j++) {
fullMesh.add(HostToHostIntent.builder()
.appId(appId())
.one(hosts.get(i).id())
.two(hosts.get(j).id())
.build());
}
}
Collections.shuffle(fullMesh);
return fullMesh.subList(0, Math.min(count, fullMesh.size()));
}
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:RandomIntentCommand.java
示例12: forward
import org.onosproject.net.Host; //导入依赖的package包/类
@Override
public void forward(Ethernet eth, ConnectPoint inPort) {
checkPermission(PACKET_WRITE);
checkNotNull(eth, REQUEST_NULL);
Host h = hostService.getHost(hostId(eth.getDestinationMAC(),
vlanId(eth.getVlanID())));
if (h == null) {
flood(eth, inPort);
} else {
Host subject = hostService.getHost(hostId(eth.getSourceMAC(),
vlanId(eth.getVlanID())));
store.forward(h.location(), subject, ByteBuffer.wrap(eth.serialize()));
}
}
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:ProxyArpManager.java
示例13: findHosts
import org.onosproject.net.Host; //导入依赖的package包/类
private Set<String> findHosts(Set<String> ids) {
Set<String> unmatched = new HashSet<>();
Host host;
for (String id : ids) {
try {
host = hostService.getHost(hostId(id));
if (host != null) {
hosts.add(host);
} else {
unmatched.add(id);
}
} catch (Exception e) {
unmatched.add(id);
}
}
return unmatched;
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:NodeSelection.java
示例14: sendNorthSouthL3Flows
import org.onosproject.net.Host; //导入依赖的package包/类
private void sendNorthSouthL3Flows(DeviceId deviceId, FloatingIp floatingIp,
IpAddress dstVmGwIp,
MacAddress dstVmGwMac,
SegmentationId l3vni,
TenantNetwork vmNetwork,
VirtualPort vmPort, Host host,
Objective.Operation operation) {
l3ForwardService
.programRouteRules(deviceId, l3vni, floatingIp.fixedIp(),
vmNetwork.segmentationId(), dstVmGwMac,
vmPort.macAddress(), operation);
classifierService.programL3InPortClassifierRules(deviceId,
host.location().port(),
host.mac(), dstVmGwMac,
l3vni, operation);
classifierService.programArpClassifierRules(deviceId, host.location()
.port(), dstVmGwIp, vmNetwork.segmentationId(), operation);
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:VtnManager.java
示例15: modifyHostDetails
import org.onosproject.net.Host; //导入依赖的package包/类
@Override
public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
pp.title(MY_HOST_TITLE);
pp.removeAllProps();
PortPairService portPairService = AbstractShellCommand.get(PortPairService.class);
VirtualPortService virtualPortService = AbstractShellCommand.get(VirtualPortService.class);
HostService hostService = AbstractShellCommand.get(HostService.class);
Iterable<PortPair> portPairs = portPairService.getPortPairs();
for (PortPair portPair : portPairs) {
VirtualPort vPort = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress()));
MacAddress dstMacAddress = vPort.macAddress();
Host host = hostService.getHost(HostId.hostId(dstMacAddress));
if (hostId.toString().equals(host.id().toString())) {
pp.addProp("SF Name", portPair.name());
pp.addProp("SF Ip", vPort.fixedIps().iterator().next().ip());
}
}
pp.addProp("SF host Address", hostId.toString());
}
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:SfcwebUiTopovOverlay.java
示例16: getMacFromHostService
import org.onosproject.net.Host; //导入依赖的package包/类
/**
* Returns MAC address of a host with a given target IP address by asking to
* host service. It does not support overlapping IP.
*
* @param targetIp target ip
* @return mac address, or null if it fails to find the mac
*/
private MacAddress getMacFromHostService(IpAddress targetIp) {
checkNotNull(targetIp);
Host host = hostService.getHostsByIp(targetIp)
.stream()
.findFirst()
.orElse(null);
if (host != null) {
log.debug("Found MAC from host service for {}", targetIp.toString());
return host.mac();
} else {
return null;
}
}
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:OpenstackArpHandler.java
示例17: bindMacAddr
import org.onosproject.net.Host; //导入依赖的package包/类
private void bindMacAddr(Map.Entry<VlanId, ConnectPoint> e,
SetMultimap<VlanId, Pair<ConnectPoint,
MacAddress>> confHostPresentCPoint) {
VlanId vlanId = e.getKey();
ConnectPoint cp = e.getValue();
Set<Host> connectedHosts = hostService.getConnectedHosts(cp);
if (!connectedHosts.isEmpty()) {
connectedHosts.forEach(host -> {
if (host.vlan().equals(vlanId)) {
confHostPresentCPoint.put(vlanId, Pair.of(cp, host.mac()));
} else {
confHostPresentCPoint.put(vlanId, Pair.of(cp, null));
}
});
} else {
confHostPresentCPoint.put(vlanId, Pair.of(cp, null));
}
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:Vpls.java
示例18: testFourInterfacesThreeHostEventsSameVlan
import org.onosproject.net.Host; //导入依赖的package包/类
/**
* Checks the case in which six ports are configured with VLANs and
* initially no hosts are registered by the HostService. The first three
* ports have an interface configured on VLAN1, the other three have an
* interface configured on VLAN2. When the module starts up, three hosts -
* on device one, two and three - port 1 (both on VLAN1), are registered by
* the HostService and events are sent to the application. sp2mp intents
* are created for all interfaces configured and mp2sp intents are created
* only for the hosts attached.
* The number of intents expected is nine: six for VLAN1, three for VLAN2.
* Six sp2mp intents, three mp2sp intents. IPs are added on the first two
* hosts only to demonstrate it doesn't influence the number of intents
* created.
* An additional host is added on device seven, port one to demonstrate
* that, even if it's on the same VLAN of other interfaces configured in
* the system, it doesn't let the application generate intents, since it's
* not connected to the interface configured.
*/
@Test
public void testFourInterfacesThreeHostEventsSameVlan() {
vpls.activate();
Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(1),
Collections.singleton(IP1));
Host h2 = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(2),
Collections.singleton(IP2));
Host h3 = new DefaultHost(PID, HID3, MAC3, VLAN1, getLocation(3),
Collections.EMPTY_SET);
Host h7 = new DefaultHost(PID, HID7, MAC7, VLAN1, getLocation(7),
Collections.EMPTY_SET);
hostsAvailable.addAll(Sets.newHashSet(h1, h2, h3, h7));
hostsAvailable.forEach(host ->
hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host)));
List<Intent> expectedIntents = new ArrayList<>();
expectedIntents.addAll(generateVlanOneBrc());
expectedIntents.addAll(generateVlanOneUni());
expectedIntents.addAll(generateVlanTwoBrc());
checkIntents(expectedIntents);
}
开发者ID:shlee89,项目名称:athena,代码行数:43,代码来源:VplsTest.java
示例19: getHostById
import org.onosproject.net.Host; //导入依赖的package包/类
/**
* Get details of end-station host.
* Returns detailed properties of the specified end-station host.
*
* @param id host identifier
* @return 200 OK with detailed properties of the specified end-station host
* @onos.rsModel Host
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
public Response getHostById(@PathParam("id") String id) {
final Host host = nullIsNotFound(get(HostService.class).getHost(hostId(id)),
HOST_NOT_FOUND);
final ObjectNode root = codec(Host.class).encode(host, this);
return ok(root).build();
}
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:HostsWebResource.java
示例20: getHostByMacAndVlan
import org.onosproject.net.Host; //导入依赖的package包/类
/**
* Get details of end-station host with MAC/VLAN.
* Returns detailed properties of the specified end-station host.
*
* @param mac host MAC address
* @param vlan host VLAN identifier
* @return 200 OK with detailed properties of the specified end-station host
* @onos.rsModel Host
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{mac}/{vlan}")
public Response getHostByMacAndVlan(@PathParam("mac") String mac,
@PathParam("vlan") String vlan) {
final Host host = nullIsNotFound(get(HostService.class).getHost(hostId(mac + "/" + vlan)),
HOST_NOT_FOUND);
final ObjectNode root = codec(Host.class).encode(host, this);
return ok(root).build();
}
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:HostsWebResource.java
注:本文中的org.onosproject.net.Host类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论