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


Java Device类代码示例

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


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


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