use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class RemovePeerCommand method doExecute.
@Override
protected void doExecute() {
peerAddress = IpAddress.valueOf(ip);
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
BgpConfig config = configService.getConfig(appId, BgpConfig.class);
if (config == null || config.bgpSpeakers().isEmpty()) {
print(NO_CONFIGURATION);
return;
}
peerAddress = IpAddress.valueOf(ip);
BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerFromPeer(peerAddress);
if (speaker == null) {
print(PEER_NOT_FOUND, ip);
return;
}
removePeerFromSpeakerConf(speaker, config);
configService.applyConfig(appId, BgpConfig.class, config.node());
print(PEER_REMOVE_SUCCESS);
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class TestCodecService method setup.
@Before
public void setup() throws IOException {
storageService = new TestStorageService();
mastershipService = createNiceMock(MastershipService.class);
coreService = createNiceMock(CoreService.class);
hostService = createNiceMock(HostService.class);
deviceService = createNiceMock(DeviceService.class);
expect(deviceService.getDevices()).andReturn(ImmutableList.of()).anyTimes();
networkConfigRegistry = createNiceMock(NetworkConfigRegistry.class);
networkConfigService = createNiceMock(NetworkConfigService.class);
manager = new SimpleIntManager();
manager.coreService = coreService;
manager.deviceService = deviceService;
manager.storageService = storageService;
manager.mastershipService = mastershipService;
manager.hostService = hostService;
manager.netcfgService = networkConfigService;
manager.netcfgRegistry = networkConfigRegistry;
manager.eventExecutor = MoreExecutors.newDirectExecutorService();
manager.codecService = codecService;
expect(coreService.registerApplication(APP_NAME)).andReturn(APP_ID).anyTimes();
networkConfigRegistry.registerConfigFactory(anyObject());
expectLastCall().once();
Capture<NetworkConfigListener> capture = newCapture();
networkConfigService.addListener(EasyMock.capture(capture));
expectLastCall().once();
IntReportConfig config = getIntReportConfig("/report-config.json");
expect(networkConfigService.getConfig(APP_ID, IntReportConfig.class)).andReturn(config).anyTimes();
replay(mastershipService, deviceService, coreService, hostService, networkConfigRegistry, networkConfigService);
manager.activate();
networkConfigListener = capture.getValue();
}
use of org.onosproject.net.config.NetworkConfigService in project trellis-control by opennetworkinglab.
the class BlackHoleCommand method doExecute.
@Override
protected void doExecute() {
SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
NetworkConfigService netcfgService = AbstractShellCommand.get(NetworkConfigService.class);
SegmentRoutingAppConfig appConfig = netcfgService.getConfig(srService.appId(), SegmentRoutingAppConfig.class);
if (appConfig == null) {
JsonNode jsonNode = new ObjectMapper().createObjectNode();
netcfgService.applyConfig(srService.appId(), SegmentRoutingAppConfig.class, jsonNode);
appConfig = netcfgService.getConfig(srService.appId(), SegmentRoutingAppConfig.class);
}
Set<IpPrefix> blackHoleIps;
switch(op) {
case "list":
appConfig.blackholeIPs().forEach(prefix -> print(prefix.toString()));
break;
case "add":
blackHoleIps = Sets.newConcurrentHashSet(appConfig.blackholeIPs());
blackHoleIps.add(IpPrefix.valueOf(prefix));
appConfig.setBalckholeIps(blackHoleIps);
appConfig.apply();
break;
case "remove":
blackHoleIps = Sets.newConcurrentHashSet(appConfig.blackholeIPs());
blackHoleIps.remove(IpPrefix.valueOf(prefix));
appConfig.setBalckholeIps(blackHoleIps);
appConfig.apply();
break;
default:
throw new UnsupportedOperationException("Unknown operation " + op);
}
}
use of org.onosproject.net.config.NetworkConfigService in project fabric-tna by stratum.
the class FabricUpfProgrammableTest method setUp.
@Before
public void setUp() throws Exception {
FabricCapabilities capabilities = createMock(FabricCapabilities.class);
expect(capabilities.supportUpf()).andReturn(true).anyTimes();
replay(capabilities);
// Services mock
packetService = new MockPacketService();
CoreService coreService = createMock(CoreService.class);
NetworkConfigService netcfgService = createMock(NetworkConfigService.class);
DeviceService deviceService = createMock(DeviceService.class);
SlicingService slicingService = createMock(SlicingService.class);
expect(slicingService.getSlices()).andReturn(Set.of(SliceId.of(SLICE_MOBILE))).anyTimes();
expect(slicingService.getTrafficClasses(SliceId.of(SLICE_MOBILE))).andReturn(Set.of(TrafficClass.ELASTIC)).anyTimes();
PiTranslationService piTranslationService = createMock(PiTranslationService.class);
expect(coreService.getAppId(anyString())).andReturn(APP_ID).anyTimes();
expect(netcfgService.getConfig(TestUpfConstants.DEVICE_ID, BasicDeviceConfig.class)).andReturn(TestUpfUtils.getBasicConfig(TestUpfConstants.DEVICE_ID, "/basic.json")).anyTimes();
replay(coreService, netcfgService, slicingService);
// Mock driverData to get the right device ID
DriverData driverData = createMock(DriverData.class);
expect(driverData.deviceId()).andReturn(TestUpfConstants.DEVICE_ID).anyTimes();
replay(driverData);
// Mock DriverHandler to get all the required mocked services
DriverHandler driverHandler = createMock(DriverHandler.class);
expect(driverHandler.get(FlowRuleService.class)).andReturn(new MockFlowRuleService()).anyTimes();
expect(driverHandler.get(MeterService.class)).andReturn(new MockMeterService()).anyTimes();
expect(driverHandler.get(SlicingService.class)).andReturn(slicingService).anyTimes();
expect(driverHandler.get(PacketService.class)).andReturn(packetService).anyTimes();
expect(driverHandler.get(NetworkConfigService.class)).andReturn(netcfgService).anyTimes();
expect(driverHandler.get(CoreService.class)).andReturn(coreService).anyTimes();
expect(driverHandler.get(DeviceService.class)).andReturn(deviceService).anyTimes();
expect(driverHandler.get(PiTranslationService.class)).andReturn(piTranslationService).anyTimes();
expect(driverHandler.get(PiPipeconfService.class)).andReturn(new MockPiPipeconfService(TABLE_MODELS, COUNTER_MODELS, METER_MODELS, TNA)).anyTimes();
expect(driverHandler.get(P4RuntimeController.class)).andReturn(mockP4RtController).anyTimes();
expect(driverHandler.data()).andReturn(driverData).anyTimes();
replay(driverHandler);
upfProgrammable = new FabricUpfProgrammable();
TestUtils.setField(upfProgrammable, "handler", driverHandler);
TestUtils.setField(upfProgrammable, "data", driverData);
ConcurrentMap<DeviceId, URI> channelUris = TestUtils.getField(upfProgrammable, "CHANNEL_URIS");
channelUris.put(TestUpfConstants.DEVICE_ID, new URI("grpc://localhost:1234?device_id=1"));
}
Aggregations