use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class AddSpeakerCommand method doExecute.
@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);
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class BgpSpeakersListCommand method doExecute.
@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.getConfig(appId, BgpConfig.class);
if (config == null) {
print("No speakers configured");
return;
}
List<BgpConfig.BgpSpeakerConfig> bgpSpeakers = Lists.newArrayList(config.bgpSpeakers());
Collections.sort(bgpSpeakers, SPEAKERS_COMPARATOR);
if (config.bgpSpeakers().isEmpty()) {
print("No speakers configured");
} else {
bgpSpeakers.forEach(s -> {
if (s.name().isPresent()) {
print(NAME_FORMAT, s.name().get(), s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
} else {
print(FORMAT, s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
}
});
}
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class RemoveSpeakerCommand method doExecute.
@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.getConfig(appId, BgpConfig.class);
if (config == null || config.bgpSpeakers().isEmpty()) {
print(NO_CONFIGURATION);
return;
}
BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
if (speaker == null) {
print(SPEAKER_NOT_FOUND, name);
return;
} else {
if (!speaker.peers().isEmpty()) {
// Removal not allowed when peer connections exist.
print(PEERS_EXIST, name);
return;
}
}
removeSpeakerFromConf(config);
configService.applyConfig(appId, BgpConfig.class, config.node());
print(SPEAKER_REMOVE_SUCCESS);
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class FibInstallerTest method setUp.
@Before
public void setUp() throws Exception {
sSfibInstaller = new FibInstaller();
sSfibInstaller.componentConfigService = createNiceMock(ComponentConfigService.class);
ComponentContext mockContext = createNiceMock(ComponentContext.class);
routerConfig = new TestRouterConfig();
interfaceService = createMock(InterfaceService.class);
networkConfigService = createMock(NetworkConfigService.class);
networkConfigService.addListener(anyObject(NetworkConfigListener.class));
expectLastCall().anyTimes();
networkConfigRegistry = createMock(NetworkConfigRegistry.class);
flowObjectiveService = createMock(FlowObjectiveService.class);
applicationService = createNiceMock(ApplicationService.class);
replay(applicationService);
deviceService = new TestDeviceService();
CoreService coreService = createNiceMock(CoreService.class);
expect(coreService.registerApplication(anyString())).andReturn(APPID).anyTimes();
replay(coreService);
sSfibInstaller.networkConfigService = networkConfigService;
sSfibInstaller.networkConfigRegistry = networkConfigRegistry;
sSfibInstaller.interfaceService = interfaceService;
sSfibInstaller.flowObjectiveService = flowObjectiveService;
sSfibInstaller.applicationService = applicationService;
sSfibInstaller.coreService = coreService;
sSfibInstaller.routeService = new TestRouteService();
sSfibInstaller.deviceService = deviceService;
setUpNetworkConfigService();
setUpInterfaceService();
sSfibInstaller.activate(mockContext);
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class SdnIpCommand method setEncap.
/**
* 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());
}
Aggregations