本文整理汇总了Java中org.onosproject.net.HostLocation类的典型用法代码示例。如果您正苦于以下问题:Java HostLocation类的具体用法?Java HostLocation怎么用?Java HostLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HostLocation类属于org.onosproject.net包,在下文中一共展示了HostLocation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSingleHostByMacAndVlanFetch
import org.onosproject.net.HostLocation; //导入依赖的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.HostLocation; //导入依赖的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.HostLocation; //导入依赖的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: updateHost
import org.onosproject.net.HostLocation; //导入依赖的package包/类
private void updateHost(UiHost uiHost, Host h) {
UiLink existing = uiTopology.findLink(uiHost.edgeLinkId());
EdgeLink currentElink = synthesizeLink(h);
UiLinkId currentElinkId = uiLinkId(currentElink);
if (existing != null) {
if (!currentElinkId.equals(existing.id())) {
// edge link has changed
insertNewUiLink(currentElinkId, currentElink);
uiHost.setEdgeLinkId(currentElinkId);
uiTopology.remove(existing);
}
} else {
// no previously existing edge link
insertNewUiLink(currentElinkId, currentElink);
uiHost.setEdgeLinkId(currentElinkId);
}
HostLocation hloc = h.location();
uiHost.setLocation(hloc.deviceId(), hloc.port());
}
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:ModelCache.java
示例5: createHost
import org.onosproject.net.HostLocation; //导入依赖的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
示例6: discoverHost
import org.onosproject.net.HostLocation; //导入依赖的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
示例7: createHost
import org.onosproject.net.HostLocation; //导入依赖的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: encode
import org.onosproject.net.HostLocation; //导入依赖的package包/类
@Override
public ObjectNode encode(Host host, CodecContext context) {
checkNotNull(host, "Host cannot be null");
final JsonCodec<HostLocation> locationCodec =
context.codec(HostLocation.class);
final ObjectNode result = context.mapper().createObjectNode()
.put("id", host.id().toString())
.put("mac", host.mac().toString())
.put("vlan", host.vlan().toString());
final ArrayNode jsonIpAddresses = result.putArray("ipAddresses");
for (final IpAddress ipAddress : host.ipAddresses()) {
jsonIpAddresses.add(ipAddress.toString());
}
result.set("ipAddresses", jsonIpAddresses);
result.set("location", locationCodec.encode(host.location(), context));
return annotate(result, host, context);
}
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:HostCodec.java
示例9: testRemoveIp
import org.onosproject.net.HostLocation; //导入依赖的package包/类
/**
* Tests the removeIp method call.
*/
@Test
public void testRemoveIp() {
Set<IpAddress> ips = new HashSet<>();
ips.add(IP1);
ips.add(IP2);
HostDescription description = new DefaultHostDescription(HOSTID.mac(),
HOSTID.vlanId(),
HostLocation.NONE,
ips);
ecXHostStore.createOrUpdateHost(PID, HOSTID, description, false);
ecXHostStore.removeIp(HOSTID, IP1);
Host host = ecXHostStore.getHost(HOSTID);
assertFalse(host.ipAddresses().contains(IP1));
assertTrue(host.ipAddresses().contains(IP2));
}
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:DistributedHostStoreTest.java
示例10: addAccessAgentInstance
import org.onosproject.net.HostLocation; //导入依赖的package包/类
private void addAccessAgentInstance(ConnectPoint connectPoint) {
AccessAgentData agent = cordConfig.getAccessAgent(connectPoint.deviceId()).get();
DefaultAnnotations.Builder annotations = DefaultAnnotations.builder()
.set(Instance.NETWORK_TYPE, ACCESS_AGENT.name())
.set(Instance.NETWORK_ID, NOT_APPLICABLE)
.set(Instance.PORT_ID, NOT_APPLICABLE)
.set(Instance.CREATE_TIME, String.valueOf(System.currentTimeMillis()));
HostDescription hostDesc = new DefaultHostDescription(
agent.getAgentMac(),
VlanId.NONE,
new HostLocation(connectPoint, System.currentTimeMillis()),
Sets.newHashSet(),
annotations.build());
HostId hostId = HostId.hostId(agent.getAgentMac());
hostProvider.hostDetected(hostId, hostDesc, false);
}
开发者ID:opencord,项目名称:vtn,代码行数:19,代码来源:InstanceManager.java
示例11: parseHost
import org.onosproject.net.HostLocation; //导入依赖的package包/类
private void parseHost(HostProviderService hps, JsonNode node) {
MacAddress mac = MacAddress.valueOf(get(node, "mac"));
VlanId vlanId = VlanId.vlanId(node.get("vlan").shortValue());
HostId hostId = HostId.hostId(mac, vlanId);
SparseAnnotations annotations = annotations(node.get("annotations"));
HostLocation location = new HostLocation(connectPoint(get(node, "location")), 0);
String[] ipStrings = get(node, "ip").split(",");
Set<IpAddress> ips = new HashSet<>();
for (String ip : ipStrings) {
ips.add(IpAddress.valueOf(ip.trim()));
}
DefaultHostDescription desc =
new DefaultHostDescription(mac, vlanId, location, ips, annotations);
hps.hostDetected(hostId, desc);
}
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:18,代码来源:ConfigProvider.java
示例12: testSingleHostByIdFetch
import org.onosproject.net.HostLocation; //导入依赖的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);
WebResource rs = resource();
String response = rs.path("hosts/00:00:11:00:00:01%2F1").get(String.class);
final JsonObject result = JsonObject.readFrom(response);
assertThat(result, matchesHost(host1));
}
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:26,代码来源:HostResourceTest.java
示例13: testSingleHostByMacAndVlanFetch
import org.onosproject.net.HostLocation; //导入依赖的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);
WebResource rs = resource();
String response = rs.path("hosts/00:00:11:00:00:01/1").get(String.class);
final JsonObject result = JsonObject.readFrom(response);
assertThat(result, matchesHost(host1));
}
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:26,代码来源:HostResourceTest.java
示例14: updateHost
import org.onosproject.net.HostLocation; //导入依赖的package包/类
private void updateHost(UiHost uiHost, Host h) {
UiEdgeLink existing = uiTopology.findEdgeLink(uiHost.edgeLinkId());
// TODO: review - do we need EdgeLink now that we are creating from id only?
EdgeLink currentElink = synthesizeLink(h);
UiLinkId currentElinkId = uiLinkId(currentElink);
if (existing != null) {
if (!currentElinkId.equals(existing.id())) {
// edge link has changed
insertNewUiEdgeLink(currentElinkId);
uiHost.setEdgeLinkId(currentElinkId);
uiTopology.remove(existing);
}
} else {
// no previously existing edge link
insertNewUiEdgeLink(currentElinkId);
uiHost.setEdgeLinkId(currentElinkId);
}
HostLocation hloc = h.location();
uiHost.setLocation(hloc.deviceId(), hloc.port());
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:27,代码来源:ModelCache.java
示例15: populateHosts
import org.onosproject.net.HostLocation; //导入依赖的package包/类
private static void populateHosts() {
ip1 = IpAddress.valueOf("10.1.1.1");
IpAddress ip2 = IpAddress.valueOf("10.1.1.2");
IpAddress ip3 = IpAddress.valueOf("10.1.1.3");
mac1 = MacAddress.valueOf("67:11:23:45:87:11");
MacAddress mac2 = MacAddress.valueOf("67:11:23:45:87:12");
MacAddress mac3 = MacAddress.valueOf("67:11:23:45:87:13");
id1 = HostId.hostId(mac1);
HostId id2 = HostId.hostId(mac2);
HostId id3 = HostId.hostId(mac3);
deviceId = DeviceId.deviceId("test");
c1 = new ConnectPoint(deviceId, PortNumber.portNumber(101));
HostLocation hostLocation1 = new HostLocation(deviceId, PortNumber.portNumber(101), 0);
HostLocation hostLocation2 = new HostLocation(deviceId, PortNumber.portNumber(102), 0);
HostLocation hostLocation3 = new HostLocation(deviceId, PortNumber.portNumber(103), 0);
h1 = new DefaultHost(ProviderId.NONE, id1, mac1, VlanId.NONE,
hostLocation1, ImmutableSet.of(ip1));
allHosts.add(h1);
allHosts.add(new DefaultHost(ProviderId.NONE, id2, mac2, VlanId.NONE,
hostLocation2, ImmutableSet.of(ip2)));
allHosts.add(new DefaultHost(ProviderId.NONE, id3, mac3, VlanId.NONE,
hostLocation3, ImmutableSet.of(ip3)));
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:GrpcNbHostServiceTest.java
示例16: addHost
import org.onosproject.net.HostLocation; //导入依赖的package包/类
@Override
public VirtualHost addHost(NetworkId networkId, HostId hostId, MacAddress mac,
VlanId vlan, HostLocation location, Set<IpAddress> ips) {
checkState(networkExists(networkId), "The network has not been added.");
checkState(virtualPortExists(networkId, location.deviceId(), location.port()),
"The virtual port has not been created.");
Set<HostId> hostIdSet = networkIdHostIdSetMap.get(networkId);
if (hostIdSet == null) {
hostIdSet = new HashSet<>();
}
VirtualHost virtualhost = new DefaultVirtualHost(networkId, hostId, mac, vlan, location, ips);
//TODO update both maps in one transaction.
hostIdVirtualHostMap.put(hostId, virtualhost);
hostIdSet.add(hostId);
networkIdHostIdSetMap.put(networkId, hostIdSet);
return virtualhost;
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:18,代码来源:DistributedVirtualNetworkStore.java
示例17: execute
import org.onosproject.net.HostLocation; //导入依赖的package包/类
@Override
protected void execute() {
VirtualNetworkAdminService service = get(VirtualNetworkAdminService.class);
Set<IpAddress> hostIps = new HashSet<>();
if (hostIpStrings != null) {
Arrays.stream(hostIpStrings).forEach(s -> hostIps.add(IpAddress.valueOf(s)));
}
HostLocation hostLocation = new HostLocation(DeviceId.deviceId(hostLocationDeviceId),
PortNumber.portNumber(hostLocationPortNumber),
System.currentTimeMillis());
MacAddress macAddress = MacAddress.valueOf(mac);
VlanId vlanId = VlanId.vlanId(vlan);
service.createVirtualHost(NetworkId.networkId(networkId),
HostId.hostId(macAddress, vlanId), macAddress, vlanId,
hostLocation, hostIps);
print("Virtual host successfully created.");
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:19,代码来源:VirtualHostCreateCommand.java
示例18: writeRequestDhcpRecord
import org.onosproject.net.HostLocation; //导入依赖的package包/类
/**
* Writes DHCP record to the store according to the request DHCP packet (Discover, Request).
*
* @param location the location which DHCP packet comes from
* @param ethernet the DHCP packet
* @param dhcpPayload the DHCP payload
*/
private void writeRequestDhcpRecord(ConnectPoint location,
Ethernet ethernet,
DHCP dhcpPayload) {
VlanId vlanId = VlanId.vlanId(ethernet.getVlanID());
MacAddress macAddress = MacAddress.valueOf(dhcpPayload.getClientHardwareAddress());
HostId hostId = HostId.hostId(macAddress, vlanId);
DhcpRecord record = dhcpRelayStore.getDhcpRecord(hostId).orElse(null);
if (record == null) {
record = new DhcpRecord(HostId.hostId(macAddress, vlanId));
} else {
record = record.clone();
}
record.addLocation(new HostLocation(location, System.currentTimeMillis()));
record.ip4Status(dhcpPayload.getPacketType());
record.setDirectlyConnected(directlyConnected(dhcpPayload));
if (!directlyConnected(dhcpPayload)) {
// Update gateway mac address if the host is not directly connected
record.nextHop(ethernet.getSourceMAC());
}
record.updateLastSeen();
dhcpRelayStore.updateDhcpRecord(HostId.hostId(macAddress, vlanId), record);
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:30,代码来源:Dhcp4HandlerImpl.java
示例19: testDhcp4DualHome
import org.onosproject.net.HostLocation; //导入依赖的package包/类
@Test
public void testDhcp4DualHome() {
PacketContext packetContext =
new TestDhcpAckPacketContext(CLIENT_DH_CP, CLIENT_MAC, CLIENT_VLAN,
INTERFACE_IP.ipAddress().getIp4Address(),
false);
reset(manager.hostService);
expect(manager.hostService.getHost(CLIENT_HOST_ID)).andReturn(EXISTS_HOST).anyTimes();
Capture<HostDescription> capturedHostDesc = newCapture();
mockHostProviderService.hostDetected(eq(CLIENT_HOST_ID), capture(capturedHostDesc), eq(false));
replay(mockHostProviderService, manager.hostService);
packetService.processPacket(packetContext);
verify(mockHostProviderService);
HostDescription hostDesc = capturedHostDesc.getValue();
Set<HostLocation> hostLocations = hostDesc.locations();
assertEquals(2, hostLocations.size());
assertTrue(hostLocations.contains(CLIENT_LOCATION));
assertTrue(hostLocations.contains(CLIENT_DH_LOCATION));
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:21,代码来源:DhcpRelayManagerTest.java
示例20: processHostMovedEvent
import org.onosproject.net.HostLocation; //导入依赖的package包/类
void processHostMovedEvent(HostEvent event) {
MacAddress hostMac = event.subject().mac();
VlanId hostVlanId = event.subject().vlan();
Set<HostLocation> prevLocations = event.prevSubject().locations();
Set<IpAddress> prevIps = event.prevSubject().ipAddresses();
Set<HostLocation> newLocations = event.subject().locations();
Set<IpAddress> newIps = event.subject().ipAddresses();
// FIXME: Delay event handling a little bit to wait for the previous redirection flows to be completed
// The permanent solution would be introducing CompletableFuture and wait for it
if (prevLocations.size() == 1 && newLocations.size() == 2) {
log.debug("Delay event handling when host {}/{} moves from 1 to 2 locations", hostMac, hostVlanId);
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
executorService.schedule(() ->
processHostMoved(hostMac, hostVlanId, prevLocations, prevIps, newLocations, newIps),
HOST_MOVED_DELAY_MS, TimeUnit.MILLISECONDS);
} else {
processHostMoved(hostMac, hostVlanId, prevLocations, prevIps, newLocations, newIps);
}
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:21,代码来源:HostHandler.java
注:本文中的org.onosproject.net.HostLocation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论