Java Code Examples for org.onosproject.net.config.NetworkConfigService#addConfig()
The following examples show how to use
org.onosproject.net.config.NetworkConfigService#addConfig() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeviceViewMessageHandler.java From onos with Apache License 2.0 | 6 votes |
@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); }
Example 2
Source File: HostViewMessageHandler.java From onos with Apache License 2.0 | 6 votes |
@Override public void process(ObjectNode payload) { HostId hostId = hostId(string(payload, ID, "")); String name = emptyToNull(string(payload, NAME, null)); log.debug("Name change request: {} -- '{}'", hostId, name); NetworkConfigService service = get(NetworkConfigService.class); BasicHostConfig cfg = service.addConfig(hostId, BasicHostConfig.class); // Name attribute missing from the payload (or empty string) // means that the friendly name should be unset. cfg.name(name); cfg.apply(); sendMessage(HOST_NAME_CHANGE_RESP, payload); }
Example 3
Source File: CreateNullDevice.java From onos with Apache License 2.0 | 6 votes |
@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); }
Example 4
Source File: GluonServer.java From onos with Apache License 2.0 | 6 votes |
/** * Gluon data updating and deleting into/from NetworkConfig datastore. * config.apply will raise GluonConfig.class event for add, * get and delete operations. * * @param gluonConfigMessage Etcdresponse data after parsing */ public void processEtcdResponse(GluonConfig gluonConfigMessage) { NetworkConfigService configService = DefaultServiceDirectory.getService(NetworkConfigService.class); if (gluonConfigMessage.action.equals(ACTION_SET) || gluonConfigMessage.action.equals(ACTION_GET)) { GluonConfig config = configService .addConfig(gluonConfigMessage.key, GluonConfig.class); config.setEtcdResponse(gluonConfigMessage); config.apply(); log.info(DATA_UPDATED); } else if (gluonConfigMessage.action.equals(ACTION_DEL)) { configService.removeConfig(gluonConfigMessage.key, GluonConfig.class); log.info(DATA_REMOVED); } else { log.info(INVALID_ACTION); } }
Example 5
Source File: SdnIpCommand.java From onos with Apache License 2.0 | 6 votes |
/** * Sets the encapsulation type for SDN-IP. * * @param encap the encapsulation type */ private void setEncap(String encap) { EncapsulationType encapType = EncapsulationType.enumFromString(encap); if (encapType.equals(EncapsulationType.NONE) && !encapType.toString().equals(encap)) { print(ENCAP_NOT_FOUND, encap); return; } NetworkConfigService configService = get(NetworkConfigService.class); CoreService coreService = get(CoreService.class); ApplicationId appId = coreService.getAppId(SdnIp.SDN_IP_APP); SdnIpConfig config = configService.addConfig(appId, SdnIpConfig.class); config.setEncap(encapType); config.apply(); //configService.applyConfig(appId, SdnIpConfig.class, config.node()); }
Example 6
Source File: CreateNullHost.java From onos with Apache License 2.0 | 5 votes |
@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; HostId id = sim.nextHostId(); Set<HostLocation> locations; try { locations = getLocations(sim, deviceNames); } catch (NoLocationException e) { error("\u001B[1;31mHost not created - no location (free port) available on %s\u001B[0m", e.getMessage()); return; } Set<IpAddress> ips = getIps(hostIps); BasicHostConfig cfg = cfgService.addConfig(id, BasicHostConfig.class); setUiCoordinates(cfg, locType, latOrY, longOrX); Tools.delay(10); sim.createHost(id, locations, ips); }
Example 7
Source File: CreateNullHosts.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { NullProviders service = get(NullProviders.class); NetworkConfigService cfgService = get(NetworkConfigService.class); TopologySimulator simulator = service.currentSimulator(); if (!validateSimulator(simulator)) { return; } CustomTopologySimulator sim = (CustomTopologySimulator) simulator; List<ConnectPoint> points = findAvailablePorts(sim.deviceId(deviceName)); String pattern = hostIpPattern.replace("*", "%d"); double yStep = rowGap / hostsPerRow; double y = gridY; double x = gridX - (colGap * (hostsPerRow - 1)) / 2; for (int h = 0; h < hostCount; h++) { HostLocation location = new HostLocation(points.get(h), System.currentTimeMillis()); IpAddress ip = IpAddress.valueOf(String.format(pattern, h)); HostId id = sim.nextHostId(); if (gridY != NONE) { BasicHostConfig cfg = cfgService.addConfig(id, BasicHostConfig.class); setUiCoordinates(cfg, GRID, y, x); if (((h + 1) % hostsPerRow) == 0) { x = gridX - (colGap * (hostsPerRow - 1)) / 2; } else { x += colGap; y += yStep; } } Tools.delay(10); sim.createHost(id, location, ip); } }
Example 8
Source File: ConfigureLinkCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { DeviceService deviceService = get(DeviceService.class); NetworkConfigService netCfgService = get(NetworkConfigService.class); ConnectPoint srcCp = ConnectPoint.deviceConnectPoint(src); if (deviceService.getPort(srcCp) == null) { print("[ERROR] %s does not exist", srcCp); return; } ConnectPoint dstCp = ConnectPoint.deviceConnectPoint(dst); if (deviceService.getPort(dstCp) == null) { print("[ERROR] %s does not exist", dstCp); return; } LinkKey link = linkKey(srcCp, dstCp); if (remove) { netCfgService.removeConfig(link, BasicLinkConfig.class); return; } Long bw = Optional.ofNullable(bandwidth) .map(Long::valueOf) .orElse(null); Link.Type linkType = Link.Type.valueOf(type); BasicLinkConfig cfg = netCfgService.addConfig(link, BasicLinkConfig.class); cfg.isAllowed(!disallow); cfg.isBidirectional(!isUniDi); cfg.type(linkType); if (bw != null) { cfg.bandwidth(bw); } cfg.apply(); }
Example 9
Source File: RegionAddCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { RegionAdminService service = get(RegionAdminService.class); RegionId regionId = RegionId.regionId(id); NetworkConfigService cfgService = get(NetworkConfigService.class); BasicRegionConfig cfg = cfgService.addConfig(regionId, BasicRegionConfig.class); setConfigurationData(cfg); List<Set<NodeId>> masters = parseMasterArgs(); service.createRegion(regionId, name, REGION_TYPE_MAP.get(type), masters); print("Region successfully added."); }
Example 10
Source File: AnnotatePortCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { DeviceService deviceService = get(DeviceService.class); NetworkConfigService netcfgService = get(NetworkConfigService.class); ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(port); if (deviceService.getPort(connectPoint) == null) { print("Port %s does not exist.", port); return; } if (removeCfg && key == null) { // remove whole port annotation config netcfgService.removeConfig(connectPoint, PortAnnotationConfig.class); print("Annotation Config about %s removed", connectPoint); return; } if (key == null) { print("[ERROR] Annotation key not specified."); return; } PortAnnotationConfig cfg = netcfgService.addConfig(connectPoint, PortAnnotationConfig.class); if (removeCfg) { // remove config about entry cfg.annotation(key); } else { // add remove request config cfg.annotation(key, value); } cfg.apply(); }
Example 11
Source File: AddSpeakerCommand.java From onos with Apache License 2.0 | 5 votes |
@Override protected void doExecute() { NetworkConfigService configService = get(NetworkConfigService.class); CoreService coreService = get(CoreService.class); ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID); BgpConfig config = configService.addConfig(appId, BgpConfig.class); if (name != null) { BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name); if (speaker != null) { log.debug("Speaker already exists: {}", name); return; } } if (vlanId == null || vlanId.isEmpty()) { vlanIdObj = VlanId.NONE; } else { vlanIdObj = VlanId.vlanId(Short.valueOf(vlanId)); } addSpeakerToConf(config); configService.applyConfig(appId, BgpConfig.class, config.node()); print(SPEAKER_ADD_SUCCESS); }