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


Java IpAddress.valueOf方法代码示例

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


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

示例1: parseIpArrayToPrefix

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/** Ip address parser decoder.*/
public ExtPrefix.Builder parseIpArrayToPrefix(JsonNode array) {

    ExtPrefix.Builder resultBuilder = new DefaultExtPrefix.Builder();
    String ip;
    IpPrefix prefix;
    IpAddress ipAddr;

    Iterator<JsonNode> itr =  array.iterator();
    while (itr.hasNext()) {
        ip = itr.next().asText();
        ipAddr = IpAddress.valueOf(ip);
        prefix = IpPrefix.valueOf(ipAddr, 32);
        resultBuilder.setPrefix(prefix);
    }

    return resultBuilder;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:DecodeBgpFlowExtnCodecHelper.java

示例2: jsonNodeToAllowedAddressPair

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
 * Returns a Object of the currently known infrastructure virtualPort.
 *
 * @param allowedAddressPairs the allowedAddressPairs json node
 * @return a collection of allowedAddressPair
 */
public Collection<AllowedAddressPair> jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) {
    checkNotNull(allowedAddressPairs, JSON_NOT_NULL);
    ConcurrentMap<Integer, AllowedAddressPair> allowMaps = Maps
            .newConcurrentMap();
    int i = 0;
    for (JsonNode node : allowedAddressPairs) {
        IpAddress ip = IpAddress.valueOf(node.get("ip_address").asText());
        MacAddress mac = MacAddress.valueOf(node.get("mac_address")
                .asText());
        AllowedAddressPair allows = AllowedAddressPair
                .allowedAddressPair(ip, mac);
        allowMaps.put(i, allows);
        i++;
    }
    log.debug("The jsonNode of allowedAddressPairallow is {}"
            + allowedAddressPairs.toString());
    return Collections.unmodifiableCollection(allowMaps.values());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:VirtualPortWebResource.java

示例3: ControllerInfo

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
 * Information for contacting the controller, if some information
 * is not contained in the target string because it's optional
 * it's leaved as in the field declaration (default values).
 *
 * @param target column returned from ovsdb query
 */
public ControllerInfo(String target) {
    String[] data = target.split(":");
    this.type = data[0];
    Preconditions.checkArgument(!data[0].contains("unix"),
                                "Unable to create controller info " +
                                        "from {} because it's based " +
                                        "on unix sockets", target);
    if (data[0].startsWith("p")) {
        if (data.length >= 2) {
            this.port = Integer.parseInt(data[1]);
        }
        if (data.length == 3) {
            this.ip = IpAddress.valueOf(data[2]);
        }
    } else {
        this.ip = IpAddress.valueOf(data[1]);
        if (data.length == 3) {
            this.port = Integer.parseInt(data[2]);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:ControllerInfo.java

示例4: findLocalIp

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
private IpAddress findLocalIp(Collection<ControllerNode> controllerNodes) throws SocketException {
    Enumeration<NetworkInterface> interfaces =
            NetworkInterface.getNetworkInterfaces();
    while (interfaces.hasMoreElements()) {
        NetworkInterface iface = interfaces.nextElement();
        Enumeration<InetAddress> inetAddresses = iface.getInetAddresses();
        while (inetAddresses.hasMoreElements()) {
            IpAddress ip = IpAddress.valueOf(inetAddresses.nextElement());
            if (controllerNodes.stream()
                    .map(ControllerNode::ip)
                    .anyMatch(nodeIp -> ip.equals(nodeIp))) {
                return ip;
            }
        }
    }
    throw new IllegalStateException("Unable to determine local ip");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:ClusterMetadataManager.java

示例5: getDevicesAddresses

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
public Set<NetconfDeviceAddress> getDevicesAddresses() throws ConfigException {
    Set<NetconfDeviceAddress> devicesAddresses = Sets.newHashSet();

    try {
        for (JsonNode node : array) {
            String ip = node.path(IP).asText();
            IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip);
            int port = node.path(PORT).asInt(DEFAULT_TCP_PORT);
            String name = node.path(NAME).asText();
            String password = node.path(PASSWORD).asText();
            devicesAddresses.add(new NetconfDeviceAddress(ipAddr, port, name, password));

        }
    } catch (IllegalArgumentException e) {
        throw new ConfigException(CONFIG_VALUE_ERROR, e);
    }

    return devicesAddresses;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:NetconfProviderConfig.java

示例6: testDiffForScaleUp

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Test
public void testDiffForScaleUp() {
    PartitionId pid1 = PartitionId.from(1);
    NodeId nid1 = NodeId.nodeId("10.0.0.1");
    NodeId nid2 = NodeId.nodeId("10.0.0.2");
    ControllerNode n1 = new DefaultControllerNode(nid1, IpAddress.valueOf("10.0.0.1"), 9876);
    ControllerNode n2 = new DefaultControllerNode(nid2, IpAddress.valueOf("10.0.0.2"), 9876);
    Partition p1 = new DefaultPartition(pid1, ImmutableSet.of(nid1));
    Partition p12 = new DefaultPartition(pid1, ImmutableSet.of(nid1, nid2));
    ClusterMetadata md1 = new ClusterMetadata("foo", ImmutableSet.of(n1), ImmutableSet.of(p1));
    ClusterMetadata md12 = new ClusterMetadata("foo", ImmutableSet.of(n1, n2), ImmutableSet.of(p12));
    ClusterMetadataDiff diff = new ClusterMetadataDiff(md1, md12);
    assertEquals(diff.nodesAdded(), Sets.newHashSet(n2));
    assertTrue(diff.nodesRemoved().isEmpty());
    assertEquals(diff.partitionDiffs().size(), 1);
    assertEquals(diff.partitionDiffs().keySet(), Sets.newHashSet(pid1));
    PartitionDiff pdiff = diff.partitionDiffs().get(pid1);
    assertTrue(pdiff.hasChanged());
    assertFalse(pdiff.isAdded(nid1));
    assertTrue(pdiff.isAdded(nid2));
    assertFalse(pdiff.isRemoved(nid1));
    assertFalse(pdiff.isAdded(nid1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:ClusterMetadataDiffTest.java

示例7: validateBgpPeers

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
 * Validates the Bgp peer configuration.
 *
 * @return true if valid else false
 */
public boolean validateBgpPeers() {
    List<BgpPeerConfig> nodes;
    String connectMode;

    nodes = bgpPeer();
    for (int i = 0; i < nodes.size(); i++) {
        connectMode = nodes.get(i).connectMode();
        if ((IpAddress.valueOf(nodes.get(i).hostname()) == null) ||
                !validateRemoteAs(nodes.get(i).asNumber()) ||
                !validatePeerHoldTime(nodes.get(i).holdTime()) ||
                !(connectMode.equals(PEER_CONNECT_ACTIVE) || connectMode.equals(PEER_CONNECT_PASSIVE))) {
            return false;
        }
    }

    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:BgpAppConfig.java

示例8: testConstruction

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
 * Checks the construction of a DefaultFloatingIp object.
 */
@Test
public void testConstruction() {
    final TenantId tenantId = TenantId.tenantId(tenantIdStr);
    final TenantNetworkId networkId = TenantNetworkId
            .networkId(tenantNetworkId);
    final VirtualPortId portId = VirtualPortId.portId(virtualPortId);
    final RouterId routerId = RouterId.valueOf(routerIdStr);
    final FloatingIpId id = FloatingIpId.of(floatingIpIdStr1);
    final IpAddress floatingIpAddress = IpAddress.valueOf(floatingIpStr);
    final IpAddress fixedIpAddress = IpAddress.valueOf(fixedIpStr);

    FloatingIp fip = new DefaultFloatingIp(id, tenantId, networkId, portId,
                                           routerId, floatingIpAddress,
                                           fixedIpAddress,
                                           FloatingIp.Status.ACTIVE);
    assertThat(id, is(notNullValue()));
    assertThat(id, is(fip.id()));
    assertThat(tenantId, is(notNullValue()));
    assertThat(tenantId, is(fip.tenantId()));
    assertThat(networkId, is(notNullValue()));
    assertThat(networkId, is(fip.networkId()));
    assertThat(portId, is(notNullValue()));
    assertThat(portId, is(fip.portId()));
    assertThat(routerId, is(notNullValue()));
    assertThat(routerId, is(fip.routerId()));
    assertThat(floatingIpAddress, is(notNullValue()));
    assertThat(floatingIpAddress, is(fip.floatingIp()));
    assertThat(fixedIpAddress, is(notNullValue()));
    assertThat(fixedIpAddress, is(fip.fixedIp()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:DefaultFloatingIpTest.java

示例9: changeDeviceIdToNodeId

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) {
    String[] splits = deviceId.toString().split(":");
    if (splits == null || splits.length < 1) {
        return null;
    }
    IpAddress ipAddress = IpAddress.valueOf(splits[1]);
    return new OvsdbNodeId(ipAddress, 0);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:OvsdbTunnelConfig.java

示例10: decode

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Override
public ControllerNode decode(ObjectNode json, CodecContext context) {
    checkNotNull(json, "JSON cannot be null");
    String ip = json.path("ip").asText();
    return new DefaultControllerNode(new NodeId(json.path("id").asText(ip)),
                                     IpAddress.valueOf(ip),
                                     json.path("tcpPort").asInt(DEFAULT_PORT));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:ControllerNodeCodec.java

示例11: setUp

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    ctrl = new NetconfControllerImpl();
    ctrl.deviceFactory = new TestNetconfDeviceFactory();
    ctrl.cfgService = cfgService;
    ctrl.deviceService = deviceService;
    ctrl.deviceKeyService = deviceKeyService;

    //Creating mock devices
    deviceInfo1 = new NetconfDeviceInfo("device1", "001", IpAddress.valueOf(DEVICE_1_IP), DEVICE_1_PORT);
    deviceInfo2 = new NetconfDeviceInfo("device2", "002", IpAddress.valueOf(DEVICE_2_IP), DEVICE_2_PORT);
    badDeviceInfo3 = new NetconfDeviceInfo("device3", "003", IpAddress.valueOf(BAD_DEVICE_IP), BAD_DEVICE_PORT);
    deviceInfoIpV6 = new NetconfDeviceInfo("deviceIpv6", "004", IpAddress.valueOf(DEVICE_IPV6), IPV6_DEVICE_PORT);

    device1 = new TestNetconfDevice(deviceInfo1);
    deviceId1 = deviceInfo1.getDeviceId();
    device2 = new TestNetconfDevice(deviceInfo2);
    deviceId2 = deviceInfo2.getDeviceId();

    //Adding to the map for testing get device calls.
    Field field1 = ctrl.getClass().getDeclaredField("netconfDeviceMap");
    field1.setAccessible(true);
    reflectedDeviceMap = (Map<DeviceId, NetconfDevice>) field1.get(ctrl);
    reflectedDeviceMap.put(deviceId1, device1);
    reflectedDeviceMap.put(deviceId2, device2);

    //Creating mock events for testing NetconfDeviceOutputEventListener
    Field field2 = ctrl.getClass().getDeclaredField("downListener");
    field2.setAccessible(true);
    reflectedDownListener = (NetconfDeviceOutputEventListener) field2.get(ctrl);

    eventForDeviceInfo1 = new NetconfDeviceOutputEvent(NetconfDeviceOutputEvent.Type.DEVICE_NOTIFICATION, null,
                                                       null, Optional.of(1), deviceInfo1);
    eventForDeviceInfo2 = new NetconfDeviceOutputEvent(NetconfDeviceOutputEvent.Type.DEVICE_UNREGISTERED, null,
                                                       null, Optional.of(2), deviceInfo2);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:NetconfControllerImplTest.java

示例12: jsonNodeToAllocationPools

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
/**
 * Changes JsonNode alocPools to a collection of the alocPools.
 *
 * @param allocationPools the allocationPools JsonNode
 * @return a collection of allocationPools
 */
public Iterable<AllocationPool> jsonNodeToAllocationPools(JsonNode allocationPools) {
    checkNotNull(allocationPools, JSON_NOT_NULL);
    ConcurrentMap<Integer, AllocationPool> alocplMaps = Maps
            .newConcurrentMap();
    Integer i = 0;
    for (JsonNode node : allocationPools) {
        IpAddress startIp = IpAddress.valueOf(node.get("start").asText());
        IpAddress endIp = IpAddress.valueOf(node.get("end").asText());
        AllocationPool alocPls = new DefaultAllocationPool(startIp, endIp);
        alocplMaps.putIfAbsent(i, alocPls);
        i++;
    }
    return Collections.unmodifiableCollection(alocplMaps.values());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:SubnetWebResource.java

示例13: deserialize

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Override
public ControllerNode deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);
    NodeId nodeId = new NodeId(node.get(ID).textValue());
    IpAddress ip = IpAddress.valueOf(node.get(IP).textValue());
    int port = node.get(PORT).asInt();
    return new DefaultControllerNode(nodeId, ip, port);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:ConfigFileBasedClusterMetadataProvider.java

示例14: setChannel

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Override
public final void setChannel(Channel channel) {
    this.channel = channel;
    final SocketAddress address = channel.getRemoteAddress();
    if (address instanceof InetSocketAddress) {
        final InetSocketAddress inetAddress = (InetSocketAddress) address;
        final IpAddress ipAddress = IpAddress.valueOf(inetAddress.getAddress());
        if (ipAddress.isIp4()) {
            channelId = ipAddress.toString() + ':' + inetAddress.getPort();
        } else {
            channelId = '[' + ipAddress.toString() + "]:" + inetAddress.getPort();
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:AbstractOpenFlowSwitch.java

示例15: read

import org.onlab.packet.IpAddress; //导入方法依赖的package包/类
@Override
public IpAddress read(Kryo kryo, Input input, Class<IpAddress> type) {
    final int octLen = input.readInt();
    checkArgument(octLen <= IpAddress.INET6_BYTE_LENGTH);
    byte[] octs = new byte[octLen];
    input.readBytes(octs);
    // Use the address size to decide whether it is IPv4 or IPv6 address
    if (octLen == IpAddress.INET_BYTE_LENGTH) {
        return IpAddress.valueOf(IpAddress.Version.INET, octs);
    }
    if (octLen == IpAddress.INET6_BYTE_LENGTH) {
        return IpAddress.valueOf(IpAddress.Version.INET6, octs);
    }
    return null;    // Shouldn't be reached
}
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:IpAddressSerializer.java


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