• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Device类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: printDevice

import org.onosproject.net.Device; //导入依赖的package包/类
private void printDevice(DeviceService deviceService,
                         DriverService driverService,
                         Device device) {
    super.printDevice(deviceService, device);
    if (!device.is(InterfaceConfig.class)) {
        // The relevant behavior is not supported by the device.
        print(ERROR_RESULT);
        return;
    }
    DriverHandler h = driverService.createHandler(device.id());
    InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class);

    List<DeviceInterfaceDescription> interfaces =
            interfaceConfig.getInterfaces(device.id());
    if (interfaces == null) {
        print(ERROR_RESULT);
    } else if (interfaces.isEmpty()) {
        print(NO_INTERFACES);
    } else {
        interfaces.forEach(this::printInterface);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:DeviceInterfacesListCommand.java


示例2: complete

import org.onosproject.net.Device; //导入依赖的package包/类
@Override
public int complete(String buffer, int cursor, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();

    // Fetch our service and feed it's offerings to the string completer
    DeviceService service = AbstractShellCommand.get(DeviceService.class);

    // Generate the device ID/port number identifiers
    for (Device device : service.getDevices()) {
        SortedSet<String> strings = delegate.getStrings();
        for (Port port : service.getPorts(device.id())) {
            if (!port.number().isLogical()) {
                strings.add(device.id().toString() + "/" + port.number());
            }
        }
    }

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(buffer, cursor, candidates);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:ConnectPointCompleter.java


示例3: getPortStatistics

import org.onosproject.net.Device; //导入依赖的package包/类
/**
 * Gets port statistics of all devices.
 * @onos.rsModel StatisticsPorts
 * @return 200 OK with JSON encoded array of port statistics
 */
@GET
@Path("ports")
@Produces(MediaType.APPLICATION_JSON)
public Response getPortStatistics() {
    final DeviceService service = get(DeviceService.class);
    final Iterable<Device> devices = service.getDevices();
    final ObjectNode root = mapper().createObjectNode();
    final ArrayNode rootArrayNode = root.putArray("statistics");
    for (final Device device : devices) {
        final ObjectNode deviceStatsNode = mapper().createObjectNode();
        deviceStatsNode.put("device", device.id().toString());
        final ArrayNode statisticsNode = deviceStatsNode.putArray("ports");
        final Iterable<PortStatistics> portStatsEntries = service.getPortStatistics(device.id());
        if (portStatsEntries != null) {
            for (final PortStatistics entry : portStatsEntries) {
                statisticsNode.add(codec(PortStatistics.class).encode(entry, this));
            }
        }
        rootArrayNode.add(deviceStatsNode);
    }

    return ok(root).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:StatisticsWebResource.java


示例4: encodeExtension

import org.onosproject.net.Device; //导入依赖的package包/类
/**
 * Encodes a extension instruction.
 *
 * @param result json node that the instruction attributes are added to
 */
private void encodeExtension(ObjectNode result) {
    final Instructions.ExtensionInstructionWrapper extensionInstruction =
            (Instructions.ExtensionInstructionWrapper) instruction;

    DeviceId deviceId = extensionInstruction.deviceId();

    ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
    DeviceService deviceService = serviceDirectory.get(DeviceService.class);
    Device device = deviceService.getDevice(deviceId);

    if (device.is(ExtensionTreatmentCodec.class)) {
        ExtensionTreatmentCodec treatmentCodec = device.as(ExtensionTreatmentCodec.class);
        ObjectNode node = treatmentCodec.encode(extensionInstruction.extensionInstruction(), context);
        result.set(InstructionCodec.EXTENSION, node);
    } else {
        log.warn("There is no codec to encode extension for device {}", deviceId.toString());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:EncodeInstructionCodecHelper.java


示例5: testDevicesSingle

import org.onosproject.net.Device; //导入依赖的package包/类
/**
 * Tests the result of a rest api GET for a single device.
 */
@Test
public void testDevicesSingle() {

    String deviceIdString = "testdevice";
    DeviceId deviceId = did(deviceIdString);
    Device device = device(deviceIdString);

    expect(mockDeviceService.getDevice(deviceId))
            .andReturn(device)
            .once();
    replay(mockDeviceService);

    WebTarget wt = target();
    String response = wt.path("devices/" + deviceId).request().get(String.class);
    JsonObject result = Json.parse(response).asObject();
    assertThat(result, matchesDevice(device));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:DevicesResourceTest.java


示例6: populateRow

import org.onosproject.net.Device; //导入依赖的package包/类
private void populateRow(TableModel.Row row, Device dev,
                         DeviceService ds, MastershipService ms) {
    DeviceId id = dev.id();
    boolean available = ds.isAvailable(id);
    String iconId = available ? ICON_ID_ONLINE : ICON_ID_OFFLINE;

    row.cell(ID, id)
        .cell(NAME, deviceName(dev))
        .cell(AVAILABLE, available)
        .cell(AVAILABLE_IID, iconId)
        .cell(TYPE_IID, getTypeIconId(dev))
        .cell(MFR, dev.manufacturer())
        .cell(HW, dev.hwVersion())
        .cell(SW, dev.swVersion())
        .cell(PROTOCOL, deviceProtocol(dev))
        .cell(NUM_PORTS, ds.getPorts(id).size())
        .cell(MASTER_ID, ms.getMasterFor(id));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:DeviceViewMessageHandler.java


示例7: processDeviceRemoved

import org.onosproject.net.Device; //导入依赖的package包/类
private void processDeviceRemoved(Device device) {
    nsNextObjStore.entrySet().stream()
            .filter(entry -> entry.getKey().deviceId().equals(device.id()))
            .forEach(entry -> {
                nsNextObjStore.remove(entry.getKey());
            });
    subnetNextObjStore.entrySet().stream()
            .filter(entry -> entry.getKey().deviceId().equals(device.id()))
            .forEach(entry -> {
                subnetNextObjStore.remove(entry.getKey());
            });
    portNextObjStore.entrySet().stream()
            .filter(entry -> entry.getKey().deviceId().equals(device.id()))
            .forEach(entry -> {
                portNextObjStore.remove(entry.getKey());
            });
    subnetVidStore.entrySet().stream()
            .filter(entry -> entry.getKey().deviceId().equals(device.id()))
            .forEach(entry -> {
                subnetVidStore.remove(entry.getKey());
            });
    groupHandlerMap.remove(device.id());
    defaultRoutingHandler.purgeEcmpGraph(device.id());
    mcastHandler.removeDevice(device.id());
    xConnectHandler.removeDevice(device.id());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:SegmentRoutingManager.java


示例8: decode

import org.onosproject.net.Device; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Note: ProviderId is not part of JSON representation.
 *       Returned object will have random ProviderId set.
 */
@Override
public Device decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    DeviceId id = deviceId(json.get(ID).asText());
    // TODO: add providerId to JSON if we need to recover them.
    ProviderId pid = new ProviderId(id.uri().getScheme(), "DeviceCodec");

    Type type = Type.valueOf(json.get(TYPE).asText());
    String mfr = json.get(MFR).asText();
    String hw = json.get(HW).asText();
    String sw = json.get(SW).asText();
    String serial = json.get(SERIAL).asText();
    ChassisId chassisId = new ChassisId(json.get(CHASSIS_ID).asText());
    Annotations annotations = extractAnnotations(json, context);

    return new DefaultDevice(pid, id, type, mfr, hw, sw, serial,
                             chassisId, annotations);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:DeviceCodec.java


示例9: execute

import org.onosproject.net.Device; //导入依赖的package包/类
@Override
protected void execute() {
    DeviceService deviceService = get(DeviceService.class);
    DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
    Device dev = deviceService.getDevice(DeviceId.deviceId(uri));
    if (dev == null) {
        print(" %s", "Device does not exist");
        return;
    }
    PortNumber pnum = PortNumber.portNumber(portNumber);
    Port p = deviceService.getPort(dev.id(), pnum);
    if (p == null) {
        print(" %s", "Port does not exist");
        return;
    }
    if (portState.equals("enable")) {
        deviceAdminService.changePortState(dev.id(), pnum, true);
    } else if (portState.equals("disable")) {
        deviceAdminService.changePortState(dev.id(), pnum, false);
    } else {
        print(" %s", "State must be enable or disable");
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:DevicePortStateCommand.java


示例10: cleanAllFlowRules

import org.onosproject.net.Device; //导入依赖的package包/类
private void cleanAllFlowRules() {
    Iterable<Device> deviceList = deviceService.getAvailableDevices();

    for (Device d : deviceList) {
        DeviceId id = d.id();
        log.trace("Searching for flow rules to remove from: " + id);
        for (FlowEntry r : flowRuleService.getFlowEntries(id)) {
            boolean match = false;
            for (Instruction i : r.treatment().allInstructions()) {
                if (i.type() == Instruction.Type.OUTPUT) {
                    OutputInstruction oi = (OutputInstruction) i;
                    // if the flow has matching src and dst
                    for (Criterion cr : r.selector().criteria()) {
                        if (cr.type() == Criterion.Type.ETH_DST || cr.type() == Criterion.Type.ETH_SRC) {
                                    match = true;
                        }
                    }
                }
            }
            if (match) {
                log.trace("Removed flow rule from device: " + id);
                flowRuleService.removeFlowRules((FlowRule) r);
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:SimpleLoadBalancer.java


示例11: populateDescription

import org.onosproject.net.Device; //导入依赖的package包/类
private DeviceDescription populateDescription(ISnmpSession session, Device device) {
    NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
                                                    session.getAddress().getHostAddress());
    try {
        session.walkDevice(networkDevice, Collections.singletonList(CLASS_REGISTRY.getClassToOidMap().get(
                System.class)));

        com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System systemTree =
                (com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System)
                        networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
                                com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class));
        if (systemTree != null) {
            String[] systemComponents = systemTree.getSysDescr().split(";");
            return new DefaultDeviceDescription(device.id().uri(), device.type(),
                                                systemComponents[0], systemComponents[2],
                                                systemComponents[3], UNKNOWN, device.chassisId(),
                                                (SparseAnnotations) device.annotations());
        }
    } catch (IOException ex) {
        throw new IllegalArgumentException("Error reading details for device." + session.getAddress(), ex);
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:Bti7000DeviceDescriptor.java


示例12: onOvsVanished

import org.onosproject.net.Device; //导入依赖的package包/类
@Override
public void onOvsVanished(Device device) {
    if (device == null) {
        log.error("The device is null");
        return;
    }
    if (!mastershipService.isLocalMaster(device.id())) {
        return;
    }
    // Remove Tunnel out flow rules
    applyTunnelOut(device, Objective.Operation.REMOVE);
    // apply L3 arp flows
    Iterable<RouterInterface> interfaces = routerInterfaceService
            .getRouterInterfaces();
    interfaces.forEach(routerInf -> {
        VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
        if (gwPort == null) {
            gwPort = VtnData.getPort(vPortStore, routerInf.portId());
        }
        applyL3ArpFlows(device.id(), gwPort, Objective.Operation.REMOVE);
    });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:VtnManager.java


示例13: routerAdded

import org.onosproject.net.Device; //导入依赖的package包/类
@Override
public void routerAdded(OspfRouter ospfRouter) {
    String routerId = ospfRouter.routerIp().toString();
    log.info("Added device {}", routerId);
    DeviceId deviceId = DeviceId.deviceId(OspfRouterId.uri(ospfRouter.routerIp()));
    Device.Type deviceType = Device.Type.ROUTER;
    //If our routerType is Dr or Bdr type is PSEUDO
    if (ospfRouter.isDr()) {
        deviceType = Device.Type.ROUTER;
    } else {
        deviceType = Device.Type.VIRTUAL;
    }
    //deviceId = DeviceId.deviceId(routerDetails);
    ChassisId cId = new ChassisId();
    DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();

    newBuilder.set(AnnotationKeys.TYPE, "l3");
    newBuilder.set("routerId", routerId);
    DeviceDescription description =
            new DefaultDeviceDescription(OspfRouterId.uri(ospfRouter.routerIp()),
                    deviceType, UNKNOWN, UNKNOWN, UNKNOWN,
                    UNKNOWN, cId, newBuilder.build());
    deviceProviderService.deviceConnected(deviceId, description);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:OspfTopologyProvider.java


示例14: markOffline

import org.onosproject.net.Device; //导入依赖的package包/类
@Override
public DeviceEvent markOffline(DeviceId deviceId) {
    Map<ProviderId, DeviceDescriptions> providerDescs
            = getOrCreateDeviceDescriptions(deviceId);

    // locking device
    synchronized (providerDescs) {
        Device device = devices.get(deviceId);
        if (device == null) {
            return null;
        }
        boolean removed = availableDevices.remove(deviceId);
        if (removed) {
            // TODO: broadcast ... DOWN only?
            return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device, null);
        }
        return null;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:SimpleDeviceStore.java


示例15: getLsrId

import org.onosproject.net.Device; //导入依赖的package包/类
/**
 * Retrieve lsr-id from device annotation.
 *
 * @param deviceId specific device id from which lsr-id needs to be retrieved
 * @return lsr-id of a device
 */
public String getLsrId(DeviceId deviceId) {
    checkNotNull(deviceId, DEVICE_ID_NULL);
    Device device = deviceService.getDevice(deviceId);
    if (device == null) {
        log.debug("Device is not available for device id {} in device service.", deviceId.toString());
        return null;
    }

    // Retrieve lsr-id from device
    if (device.annotations() == null) {
        log.debug("Device {} does not have annotation.", device.toString());
        return null;
    }

    String lsrId = device.annotations().value(LSR_ID);
    if (lsrId == null) {
        log.debug("The lsr-id of device {} is null.", device.toString());
        return null;
    }
    return lsrId;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:PceccSrTeBeHandler.java


示例16: updateDeviceTypeRule

import org.onosproject.net.Device; //导入依赖的package包/类
@Test
public void updateDeviceTypeRule() {
    Device.Type deviceType1 = Device.Type.ROADM;
    Device.Type deviceType2 = Device.Type.SWITCH;
    Set<Device.Type> deviceTypes = new HashSet<>();

    deviceTypes.add(deviceType1);
    cfg.deviceTypes(deviceTypes);

    configEvent(NetworkConfigEvent.Type.CONFIG_ADDED);

    deviceTypes.add(deviceType2);
    cfg.deviceTypes(deviceTypes);

    configEvent(NetworkConfigEvent.Type.CONFIG_UPDATED);

    assertAfter(EVENT_MS, () -> {
        assertTrue(provider.rules().getSuppressedDeviceType().contains(deviceType1));
        assertTrue(provider.rules().getSuppressedDeviceType().contains(deviceType2));
    });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:LldpLinkProviderTest.java


示例17: process

import org.onosproject.net.Device; //导入依赖的package包/类
@Override
public void process(long sid, ObjectNode payload) {
    String srcId = string(payload, SRCID);
    ElementId src = elementId(srcId);
    String dstId = string(payload, DSTID);
    ElementId dst = elementId(dstId);
    Device srcDevice = deviceService.getDevice((DeviceId) src);
    Device dstDevice = deviceService.getDevice((DeviceId) dst);

    TunnelEndPoint tunSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress
            .valueOf(srcDevice.annotations().value("lsrId")));
    TunnelEndPoint tunDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
            .valueOf(dstDevice.annotations().value("lsrId")));

    Collection<Tunnel> tunnelSet = tunnelService.queryTunnel(tunSrc, tunDst);
    ObjectNode result = objectNode();
    ArrayNode arrayNode = arrayNode();
    for (Tunnel tunnel : tunnelSet) {
        if (tunnel.type() == MPLS) {
            arrayNode.add(tunnel.tunnelId().toString());
        }
    }

    result.putArray(BUFFER_ARRAY).addAll(arrayNode);
    sendMessage(PCEWEB_SHOW_TUNNEL, sid, result);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:PceWebTopovMessageHandler.java


示例18: getDevice

import org.onosproject.net.Device; //导入依赖的package包/类
/**
 * Gets details of infrastructure device.
 * Returns details of the specified infrastructure device.
 *
 * @param id device identifier
 * @return 200 OK with a device
 * @onos.rsModel DeviceGet
 */
@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response getDevice(@PathParam("id") String id) {
    Device device = nullIsNotFound(get(DeviceService.class).getDevice(deviceId(id)),
                                   DEVICE_NOT_FOUND);
    return ok(codec(Device.class).encode(device, this)).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:DevicesWebResource.java


示例19: removeRule

import org.onosproject.net.Device; //导入依赖的package包/类
/**
 * Removes packet intercept flow rules from the device.
 *
 * @param device  the device to remove the rules deom
 * @param request the packet request
 */
private void removeRule(Device device, PacketRequest request) {
    if (!device.type().equals(Device.Type.SWITCH)) {
        return;
    }
    ForwardingObjective forwarding = createBuilder(request)
            .remove(new ObjectiveContext() {
                @Override
                public void onError(Objective objective, ObjectiveError error) {
                    log.warn("Failed to withdraw packet request {} from {}: {}",
                             request, device.id(), error);
                }
            });
    objectiveService.forward(device.id(), forwarding);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:PacketManager.java


示例20: getDevice

import org.onosproject.net.Device; //导入依赖的package包/类
@Override
public Device getDevice(DeviceId deviceId) {
    if (deviceId.equals(dev1.id())) {
        return dev1;
    } else {
        return dev2;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:NetworkConfigLinksProviderTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PluginCommandYamlParser类代码示例发布时间:2022-05-22
下一篇:
Java MultiTypeParameter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap