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


Java BasicDeviceConfig类代码示例

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


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

示例1: process

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public void process(long sid, ObjectNode payload) {
    DeviceId deviceId = deviceId(string(payload, ID, ZERO_URI));
    String name = emptyToNull(string(payload, NAME, null));
    log.debug("Name change request: {} -- '{}'", deviceId, name);

    NetworkConfigService service = get(NetworkConfigService.class);
    BasicDeviceConfig cfg =
            service.addConfig(deviceId, BasicDeviceConfig.class);

    // Name attribute missing from the payload (or empty string)
    // means that the friendly name should be unset.
    cfg.name(name);
    cfg.apply();
    sendMessage(DEV_NAME_CHANGE_RESP, 0, payload);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:DeviceViewMessageHandler.java

示例2: process

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public void process(ObjectNode payload) {
    DeviceId deviceId = deviceId(string(payload, ID, ZERO_URI));
    String name = emptyToNull(string(payload, NAME, null));
    log.debug("Name change request: {} -- '{}'", deviceId, name);

    NetworkConfigService service = get(NetworkConfigService.class);
    BasicDeviceConfig cfg =
            service.addConfig(deviceId, BasicDeviceConfig.class);

    // Name attribute missing from the payload (or empty string)
    // means that the friendly name should be unset.
    cfg.name(name);
    cfg.apply();
    sendMessage(DEV_NAME_CHANGE_RESP, payload);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:17,代码来源:DeviceViewMessageHandler.java

示例3: getConfig

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
    if (available) {
        if (configClass.equals(NetconfProviderConfig.class)) {
            return (C) netconfProviderConfig;
        }
        DeviceId did = (DeviceId) subject;
        if (configClass.equals(NetconfDeviceConfig.class)
                && did.equals(DeviceId.deviceId(NETCONF_DEVICE_ID_STRING))) {
            return (C) netconfDeviceConfig;
        } else if (configClass.equals(NetconfDeviceConfig.class)
                && did.equals(DeviceId.deviceId(NETCONF_DEVICE_ID_STRING_OLD))) {
            if (firstRequest) {
                firstRequest = false;
                return null;
            }
            return (C) cfg;
        } else {
            return (C) new BasicDeviceConfig();
        }
    }
    return null;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:NetconfDeviceProviderTest.java

示例4: combine

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
/**
 * Generates an annotation from an existing annotation and DeviceConfig.
 *
 * @param cfg the device config entity from network config
 * @param an  the annotation
 * @return annotation combining both sources
 */
public static SparseAnnotations combine(BasicDeviceConfig cfg, SparseAnnotations an) {
    DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
    builder.putAll(an);
    if (!Objects.equals(cfg.driver(), an.value(AnnotationKeys.DRIVER))) {
        builder.set(AnnotationKeys.DRIVER, cfg.driver());
    }

    combineElementAnnotations(cfg, builder);

    if (cfg.managementAddress() != null) {
        builder.set(AnnotationKeys.MANAGEMENT_ADDRESS, cfg.managementAddress());
    }

    return builder.build();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:BasicDeviceOperator.java

示例5: getConfig

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
    if (configClass.equals(SnmpProviderConfig.class)) {
        return (C) snmpProviderConfig;
    } else {
        return (C) new BasicDeviceConfig();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:SnmpDeviceProviderTest.java

示例6: onControllerDetected

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public void onControllerDetected(Device controllerDevice) {
    if (controllerDevice == null) {
        log.error("The controller device is null");
        return;
    }
    String localIpAddress = controllerDevice.annotations()
            .value(CONTROLLER_IP_KEY);
    IpAddress localIp = IpAddress.valueOf(localIpAddress);
    DeviceId controllerDeviceId = controllerDevice.id();
    DriverHandler handler = driverService.createHandler(controllerDeviceId);
    if (mastershipService.isLocalMaster(controllerDeviceId)) {
        // Get DataPathIdGenerator
        String ipaddress = controllerDevice.annotations().value("ipaddress");
        DataPathIdGenerator dpidGenerator = DataPathIdGenerator.builder()
                                        .addIpAddress(ipaddress).build();
        DeviceId deviceId = dpidGenerator.getDeviceId();
        String dpid = dpidGenerator.getDpId();
        // Inject pipeline driver name
        BasicDeviceConfig config = configService.addConfig(deviceId,
                                                           BasicDeviceConfig.class);
        config.driver(DRIVER_NAME);
        configService.applyConfig(deviceId, BasicDeviceConfig.class, config.node());
        // Add Bridge
        Versioned<String> exPortVersioned = exPortMap.get(EX_PORT_KEY);
        if (exPortVersioned != null) {
            VtnConfig.applyBridgeConfig(handler, dpid, exPortVersioned.value());
            log.info("A new ovs is created in node {}", localIp.toString());
        }
        switchesOfController.put(localIp, true);
    }
    // Create tunnel in br-int on all controllers
    programTunnelConfig(controllerDeviceId, localIp, handler);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:VtnManager.java

示例7: deviceConnected

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public void deviceConnected(DeviceId deviceId,
                            DeviceDescription deviceDescription) {
    checkNotNull(deviceId, DEVICE_ID_NULL);
    checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL);
    checkValidity();

    BasicDeviceConfig cfg = networkConfigService.getConfig(deviceId, BasicDeviceConfig.class);
    if (!isAllowed(cfg)) {
        log.warn("Device {} is not allowed", deviceId);
        return;
    }
    // Generate updated description and establish my Role
    deviceDescription = BasicDeviceOperator.combine(cfg, deviceDescription);
    Futures.getUnchecked(mastershipService.requestRoleFor(deviceId)
            .thenAccept(role -> {
                log.info("Local role is {} for {}", role, deviceId);
                applyRole(deviceId, role);
            }));

    DeviceEvent event = store.createOrUpdateDevice(provider().id(), deviceId,
                                                   deviceDescription);
    log.info("Device {} connected", deviceId);
    if (event != null) {
        log.trace("event: {} {}", event.type(), event);
        post(event);
    }

}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:DeviceManager.java

示例8: isRelevant

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public boolean isRelevant(NetworkConfigEvent event) {
    return (event.type() == NetworkConfigEvent.Type.CONFIG_ADDED
            || event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED)
            && (event.configClass().equals(BasicDeviceConfig.class)
                || event.configClass().equals(OpticalPortConfig.class));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:DeviceManager.java

示例9: combine

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
/**
 * Generates a DeviceDescription containing fields from a DeviceDescription and
 * a DeviceConfig.
 *
 * @param bdc   the device config entity from network config
 * @param descr a DeviceDescription
 * @return DeviceDescription based on both sources
 */
public static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr) {
    if (bdc == null || descr == null) {
        return descr;
    }

    Device.Type type = descr.type();
    if (bdc.type() != null && bdc.type() != type) {
        type = bdc.type();
    }
    String manufacturer = descr.manufacturer();
    if (bdc.manufacturer() != null && !bdc.manufacturer().equals(manufacturer)) {
        manufacturer = bdc.manufacturer();
    }
    String hwVersion = descr.hwVersion();
    if (bdc.hwVersion() != null && !bdc.hwVersion().equals(hwVersion)) {
        hwVersion = bdc.hwVersion();
    }
    String swVersion = descr.swVersion();
    if (bdc.swVersion() != null && !bdc.swVersion().equals(swVersion)) {
        swVersion = bdc.swVersion();
    }
    String serial = descr.serialNumber();
    if (bdc.serial() != null && !bdc.serial().equals(serial)) {
        serial = bdc.serial();
    }

    SparseAnnotations sa = combine(bdc, descr.annotations());
    return new DefaultDeviceDescription(descr.deviceUri(), type, manufacturer,
                                        hwVersion, swVersion,
                                        serial, descr.chassisId(), sa);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:40,代码来源:BasicDeviceOperator.java

示例10: discoverDeviceDetails

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public DeviceDescription discoverDeviceDetails() {
    NetworkConfigService netcfg = handler().get(NetworkConfigService.class);
    DeviceId did = data().deviceId();

    String unk = "UNKNOWN";

    Optional<DeviceInjectionConfig> inject =
            Optional.ofNullable(netcfg.getConfig(did, DeviceInjectionConfig.class));

    Optional<BasicDeviceConfig> basic =
            Optional.ofNullable(netcfg.getConfig(did, BasicDeviceConfig.class));

    Device.Type type = basic.map(BasicDeviceConfig::type).orElse(Device.Type.SWITCH);
    String manufacturer = basic.map(BasicDeviceConfig::manufacturer).orElse(unk);
    String hwVersion = basic.map(BasicDeviceConfig::hwVersion).orElse(unk);
    String swVersion = basic.map(BasicDeviceConfig::swVersion).orElse(unk);
    String serialNumber = basic.map(BasicDeviceConfig::serial).orElse(unk);
    ChassisId chassis = new ChassisId();
    // if inject is not specified, return default unavailable device
    boolean defaultAvailable = inject.isPresent();
    return new DefaultDeviceDescription(did.uri(),
                                        type,
                                        manufacturer,
                                        hwVersion,
                                        swVersion,
                                        serialNumber,
                                        chassis,
                                        defaultAvailable);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:31,代码来源:ConfigOpticalDeviceDiscovery.java

示例11: getDriver

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
private Driver getDriver(DeviceId deviceId) {
    Driver driver = null;
    try {
        driver = driverService.getDriver(deviceId);
    } catch (ItemNotFoundException e) {
        log.debug("Falling back to configuration to fetch driver " +
                "for device {}", deviceId);
        BasicDeviceConfig cfg = cfgService.getConfig(deviceId, BasicDeviceConfig.class);
        if (cfg != null) {
            driver = driverService.getDriver(cfg.driver());
        }
    }
    return driver;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:15,代码来源:GeneralDeviceProvider.java

示例12: isRelevant

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public boolean isRelevant(NetworkConfigEvent event) {
    return (event.configClass().equals(GeneralProviderDeviceConfig.class) ||
            event.configClass().equals(BasicDeviceConfig.class) ||
            event.configClass().equals(PiPipeconfConfig.class)) &&
            (event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
                    event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:9,代码来源:GeneralDeviceProvider.java

示例13: execute

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
protected void execute() {
    NullProviders service = get(NullProviders.class);
    NetworkConfigService cfgService = get(NetworkConfigService.class);

    TopologySimulator simulator = service.currentSimulator();
    if (!(simulator instanceof CustomTopologySimulator)) {
        error("Custom topology simulator is not active.");
        return;
    }

    if (!(GEO.equals(locType) || GRID.equals(locType))) {
        error("locType must be 'geo' or 'grid'.");
        return;
    }

    CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
    DeviceId deviceId = sim.nextDeviceId();
    BasicDeviceConfig cfg = cfgService.addConfig(deviceId, BasicDeviceConfig.class);
    cfg.name(name)
            .locType(locType);

    if (GEO.equals(locType)) {
        cfg.latitude(latOrY).longitude(longOrX);
    } else {
        cfg.gridX(longOrX).gridY(latOrY);
    }
    cfg.apply();

    sim.createDevice(deviceId, name, Device.Type.valueOf(type.toUpperCase()), portCount);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:32,代码来源:CreateNullDevice.java

示例14: getConfig

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
    if (configClass.equals(SnmpProviderConfig.class)) {
        return (C) snmpProviderConfig;
    } else if (configClass.equals(SnmpDeviceConfig.class)) {
        return (C) config;
    } else {
        return (C) new BasicDeviceConfig();
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:11,代码来源:SnmpDeviceProviderTest.java

示例15: isRelevant

import org.onosproject.net.config.basics.BasicDeviceConfig; //导入依赖的package包/类
@Override
public boolean isRelevant(NetworkConfigEvent event) {
    return (event.type() == NetworkConfigEvent.Type.CONFIG_ADDED
            || event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED)
            && (event.configClass().equals(BasicDeviceConfig.class)
            || portOpsIndex.containsKey(event.configClass())
            || event.configClass().equals(PortDescriptionsConfig.class)
            || event.configClass().equals(DeviceAnnotationConfig.class));
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:10,代码来源:DeviceManager.java


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