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


Java HostRoute类代码示例

本文整理汇总了Java中org.onosproject.vtnrsc.HostRoute的典型用法代码示例。如果您正苦于以下问题:Java HostRoute类的具体用法?Java HostRoute怎么用?Java HostRoute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: activate

import org.onosproject.vtnrsc.HostRoute; //导入依赖的package包/类
@Activate
public void activate() {

    appId = coreService.registerApplication(VTNRSC_APP);

    subnetStore = storageService.<SubnetId, Subnet>consistentMapBuilder()
            .withName(SUBNET)
            .withApplicationId(appId)
            .withPurgeOnUninstall()
            .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
                                             Subnet.class,
                                             SubnetId.class,
                                             TenantNetworkId.class,
                                             TenantId.class,
                                             HostRoute.class,
                                             DefaultHostRoute.class,
                                             Subnet.Mode.class,
                                             AllocationPool.class,
                                             DefaultAllocationPool.class,
                                             DefaultSubnet.class,
                                             IpAddress.Version.class))
            .build().asJavaMap();

    log.info("Started");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:SubnetManager.java

示例2: jsonNodeToHostRoutes

import org.onosproject.vtnrsc.HostRoute; //导入依赖的package包/类
/**
 * Changes hostRoutes JsonNode to a collection of the hostRoutes.
 *
 * @param hostRoutes the hostRoutes json node
 * @return a collection of hostRoutes
 */
public Iterable<HostRoute> jsonNodeToHostRoutes(JsonNode hostRoutes) {
    checkNotNull(hostRoutes, JSON_NOT_NULL);
    ConcurrentMap<Integer, HostRoute> hostRouteMaps = Maps
            .newConcurrentMap();
    Integer i = 0;
    for (JsonNode node : hostRoutes) {
        IpAddress nexthop = IpAddress.valueOf(node.get("nexthop").asText());
        IpPrefix destination = IpPrefix.valueOf(node.get("destination")
                .asText());
        HostRoute hostRoute = new DefaultHostRoute(nexthop, destination);
        hostRouteMaps.putIfAbsent(i, hostRoute);
        i++;
    }
    return Collections.unmodifiableCollection(hostRouteMaps.values());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:SubnetWebResource.java

示例3: encode

import org.onosproject.vtnrsc.HostRoute; //导入依赖的package包/类
@Override
public ObjectNode encode(HostRoute hostRoute, CodecContext context) {
    checkNotNull(hostRoute, "HostRoute cannot be null");
    ObjectNode result = context.mapper().createObjectNode()
            .put("nexthop", hostRoute.nexthop().toString())
            .put("destination", hostRoute.destination().toString());
    return result;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:HostRoutesCodec.java

示例4: createDummySubnet

import org.onosproject.vtnrsc.HostRoute; //导入依赖的package包/类
/**
 * Creates dummy gluon subnet to the VTN.
 *
 * @param tenantId the base port tenant ID
 */
public void createDummySubnet(TenantId tenantId) {
    String id = "22222222-2222-2222-2222-222222222222";
    String subnetName = "GluonSubnet";
    String cidr = "0.0.0.0/0";
    String gatewayIp = "0.0.0.0";
    Set<HostRoute> hostRoutes = Sets.newHashSet();
    TenantNetworkId tenantNetworkId = null;
    Set<AllocationPool> allocationPools = Sets.newHashSet();
    Iterable<TenantNetwork> networks
            = tenantNetworkService.getNetworks();

    for (TenantNetwork tenantNetwork : networks) {
        if (tenantNetwork.name().equals("GluonNetwork")) {
            tenantNetworkId = tenantNetwork.id();
            break;
        }
    }
    Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
                                      tenantNetworkId,
                                      tenantId, IpAddress.Version.INET,
                                      IpPrefix.valueOf(cidr),
                                      IpAddress.valueOf(gatewayIp),
                                      false, false, hostRoutes,
                                      null,
                                      null,
                                      allocationPools);

    Set<Subnet> subnetsSet = Sets.newHashSet(subnet);
    subnetService.createSubnets(subnetsSet);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:36,代码来源:VpnPortManager.java

示例5: changeJsonToSubs

import org.onosproject.vtnrsc.HostRoute; //导入依赖的package包/类
/**
 * Returns a collection of subnets from subnetNodes.
 *
 * @param subnetNodes the subnet json node
 * @return subnets a collection of subnets
 */
public Iterable<Subnet> changeJsonToSubs(JsonNode subnetNodes) {
    checkNotNull(subnetNodes, JSON_NOT_NULL);
    Map<SubnetId, Subnet> subMap = new HashMap<>();
    for (JsonNode subnetNode : subnetNodes) {
        if (!subnetNode.hasNonNull("id")) {
            return null;
        }
        SubnetId id = SubnetId.subnetId(subnetNode.get("id").asText());
        String subnetName = subnetNode.get("name").asText();
        TenantId tenantId = TenantId
                .tenantId(subnetNode.get("tenant_id").asText());
        TenantNetworkId networkId = TenantNetworkId
                .networkId(subnetNode.get("network_id").asText());
        String version = subnetNode.get("ip_version").asText();
        Version ipVersion;
        switch (version) {
        case "4":
            ipVersion = Version.INET;
            break;
        case "6":
            ipVersion = Version.INET;
            break;
        default:
            throw new IllegalArgumentException("ipVersion should be 4 or 6.");
        }
        IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText());
        IpAddress gatewayIp = IpAddress
                .valueOf(subnetNode.get("gateway_ip").asText());
        Boolean dhcpEnabled = subnetNode.get("enable_dhcp").asBoolean();
        Boolean shared = subnetNode.get("shared").asBoolean();
        JsonNode hostRoutes = subnetNode.get("host_routes");
        Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
        JsonNode allocationPools = subnetNode.get("allocation_pools");
        Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
        Mode ipV6AddressMode = Mode
                .valueOf(subnetNode.get("ipv6_address_mode").asText());
        Mode ipV6RaMode = Mode
                .valueOf(subnetNode.get("ipv6_ra_mode").asText());
        Subnet subnet = new DefaultSubnet(id, subnetName, networkId,
                                          tenantId, ipVersion, cidr,
                                          gatewayIp, dhcpEnabled, shared,
                                          Sets.newHashSet(hostRoutesIt), ipV6AddressMode,
                                          ipV6RaMode, Sets.newHashSet(allocationPoolsIt));
        subMap.put(id, subnet);
    }
    return Collections.unmodifiableCollection(subMap.values());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:54,代码来源:SubnetWebResource.java

示例6: changeJsonToSub

import org.onosproject.vtnrsc.HostRoute; //导入依赖的package包/类
/**
 * Returns a collection of subnets from subnetNodes.
 *
 * @param subnetNodes the subnet json node
 * @return subnets a collection of subnets
 */
public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) {
    checkNotNull(subnetNodes, JSON_NOT_NULL);
    checkArgument(subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean");
    checkArgument(subnetNodes.get("shared").isBoolean(), "shared should be boolean");
    Map<SubnetId, Subnet> subMap = new HashMap<>();
    if (!subnetNodes.hasNonNull("id")) {
        return null;
    }
    SubnetId id = SubnetId.subnetId(subnetNodes.get("id").asText());
    String subnetName = subnetNodes.get("name").asText();
    TenantId tenantId = TenantId
            .tenantId(subnetNodes.get("tenant_id").asText());
    TenantNetworkId networkId = TenantNetworkId
            .networkId(subnetNodes.get("network_id").asText());
    String version = subnetNodes.get("ip_version").asText();
    Version ipVersion;
    switch (version) {
    case "4":
        ipVersion = Version.INET;
        break;
    case "6":
        ipVersion = Version.INET;
        break;
    default:
        throw new IllegalArgumentException("ipVersion should be 4 or 6.");
    }

    IpPrefix cidr = IpPrefix.valueOf(subnetNodes.get("cidr").asText());
    IpAddress gatewayIp = IpAddress
            .valueOf(subnetNodes.get("gateway_ip").asText());
    Boolean dhcpEnabled = subnetNodes.get("enable_dhcp").asBoolean();
    Boolean shared = subnetNodes.get("shared").asBoolean();
    JsonNode hostRoutes = subnetNodes.get("host_routes");
    Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
    JsonNode allocationPools = subnetNodes.get("allocation_pools");
    Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);

    Mode ipV6AddressMode = getMode(subnetNodes.get("ipv6_address_mode")
            .asText());
    Mode ipV6RaMode = getMode(subnetNodes.get("ipv6_ra_mode").asText());

    Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId,
                                      ipVersion, cidr, gatewayIp,
                                      dhcpEnabled, shared, Sets.newHashSet(hostRoutesIt),
                                      ipV6AddressMode, ipV6RaMode,
                                      Sets.newHashSet(allocationPoolsIt));
    subMap.put(id, subnet);
    return Collections.unmodifiableCollection(subMap.values());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:56,代码来源:SubnetWebResource.java


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