Search in sources :

Example 6 with BasicDeviceConfig

use of org.onosproject.net.config.basics.BasicDeviceConfig in project onos by opennetworkinglab.

the class PiPipeconfManager method checkMissingMergedDriver.

private void checkMissingMergedDriver(DeviceId deviceId) {
    final PiPipeconfId pipeconfId = pipeconfMappingStore.getPipeconfId(deviceId);
    final BasicDeviceConfig cfg = cfgService.getConfig(deviceId, BasicDeviceConfig.class);
    if (pipeconfId == null) {
        // No pipeconf associated.
        return;
    }
    if (cfg == null || cfg.driver() == null) {
        log.warn("Missing basic device config or driver key in netcfg for " + "{}, which is odd since it has a " + "pipeconf associated ({})", deviceId, pipeconfId);
        return;
    }
    final String baseDriverName = cfg.driver();
    final String mergedDriverName = mergedDriverName(baseDriverName, pipeconfId);
    if (driverExists(mergedDriverName) || missingMergedDrivers.contains(mergedDriverName)) {
        // Not missing, or already aware of it missing.
        return;
    }
    log.info("Detected missing merged driver: {}", mergedDriverName);
    missingMergedDrivers.add(mergedDriverName);
    // Attempt building the driver now if all pieces are present.
    // If not, either a driver or pipeconf event will re-trigger
    // the process.
    attemptDriverMerge(mergedDriverName);
}
Also used : PiPipeconfId(org.onosproject.net.pi.model.PiPipeconfId) HexString(org.onlab.util.HexString) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig)

Example 7 with BasicDeviceConfig

use of org.onosproject.net.config.basics.BasicDeviceConfig in project onos by opennetworkinglab.

the class CreateNullDevice method doExecute.

@Override
protected void doExecute() {
    NullProviders service = get(NullProviders.class);
    NetworkConfigService cfgService = get(NetworkConfigService.class);
    TopologySimulator simulator = service.currentSimulator();
    if (!validateSimulator(simulator) || !validateLocType(locType)) {
        return;
    }
    CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
    DeviceId deviceId = id == null ? sim.nextDeviceId() : DeviceId.deviceId(id);
    BasicDeviceConfig cfg = cfgService.addConfig(deviceId, BasicDeviceConfig.class);
    cfg.name(name);
    setUiCoordinates(cfg, locType, latOrY, longOrX);
    Tools.delay(10);
    sim.createDevice(deviceId, name, Device.Type.valueOf(type.toUpperCase()), hw, sw, portCount);
}
Also used : CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) TopologySimulator(org.onosproject.provider.nil.TopologySimulator) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DeviceId(org.onosproject.net.DeviceId) NullProviders(org.onosproject.provider.nil.NullProviders) CustomTopologySimulator(org.onosproject.provider.nil.CustomTopologySimulator) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig)

Example 8 with BasicDeviceConfig

use of org.onosproject.net.config.basics.BasicDeviceConfig in project onos by opennetworkinglab.

the class TopologyViewMessageHandlerBase method deviceMessage.

// Produces a device event message to the client.
protected ObjectNode deviceMessage(DeviceEvent event) {
    Device device = event.subject();
    String uiType = device.annotations().value(AnnotationKeys.UI_TYPE);
    String driverName = device.annotations().value(DRIVER);
    Driver driver = driverName == null ? null : services.driver().getDriver(driverName);
    String devType = uiType != null ? uiType : (driver != null ? driver.getProperty(AnnotationKeys.UI_TYPE) : null);
    if (devType == null) {
        devType = device.type().toString().toLowerCase();
    }
    String name = device.annotations().value(AnnotationKeys.NAME);
    name = isNullOrEmpty(name) ? device.id().toString() : name;
    ObjectNode payload = objectNode().put("id", device.id().toString()).put("type", devType).put("online", services.device().isAvailable(device.id())).put("master", master(device.id()));
    payload.set("labels", labels("", name, device.id().toString()));
    payload.set("props", props(device.annotations()));
    BasicDeviceConfig cfg = get(NetworkConfigService.class).getConfig(device.id(), BasicDeviceConfig.class);
    if (!addLocation(cfg, payload)) {
        addMetaUi(device.id().toString(), payload);
    }
    String type = DEVICE_EVENT.get(event.type());
    return JsonUtils.envelope(type, payload);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) Device(org.onosproject.net.Device) Driver(org.onosproject.net.driver.Driver) TopoUtils.compactLinkString(org.onosproject.ui.topo.TopoUtils.compactLinkString) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig)

Aggregations

BasicDeviceConfig (org.onosproject.net.config.basics.BasicDeviceConfig)8 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)5 Device (org.onosproject.net.Device)3 DeviceId (org.onosproject.net.DeviceId)3 ChassisId (org.onlab.packet.ChassisId)2 HexString (org.onlab.util.HexString)2 DeviceInjectionConfig (org.onosproject.net.config.inject.DeviceInjectionConfig)2 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Beta (com.google.common.annotations.Beta)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 ExecutorService (java.util.concurrent.ExecutorService)1