use of org.onosproject.segmentrouting.SegmentRoutingManager in project trellis-control by opennetworkinglab.
the class PseudowireRemoveCommand method doExecute.
@Override
protected void doExecute() {
SegmentRoutingService srService = AbstractShellCommand.get(SegmentRoutingService.class);
// remove the pseudowire
SegmentRoutingManager mngr = (SegmentRoutingManager) srService;
int pwIntId;
try {
pwIntId = parsePwId(pwId);
} catch (IllegalArgumentException e) {
log.error("Exception while parsing pseudowire id : \n\t %s", e.getMessage());
print("Exception while parsing pseudowire id : \n\t %s", e.getMessage());
return;
}
log.info("Removing pseudowire {} from the command line.", pwIntId);
L2TunnelHandler.Result res = mngr.removePseudowire(pwIntId);
switch(res) {
case WRONG_PARAMETERS:
error("Pseudowire could not be removed , wrong parameters: \n\t %s\n", res.getSpecificError());
break;
case INTERNAL_ERROR:
error("Pseudowire could not be removed, internal error : \n\t %s\n", res.getSpecificError());
break;
case SUCCESS:
break;
default:
break;
}
}
use of org.onosproject.segmentrouting.SegmentRoutingManager in project trellis-control by opennetworkinglab.
the class DeviceConfigurationTest method setUp.
@Before
public void setUp() throws Exception {
InterfaceService interfaceService;
networkConfigService = null;
NeighbourResolutionService neighbourResolutionService;
SegmentRoutingManager srManager;
// Mock device netcfg
InputStream jsonStream = SegmentRoutingDeviceConfigTest.class.getResourceAsStream("/device.json");
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readTree(jsonStream);
SegmentRoutingDeviceConfig srDevConfig = new SegmentRoutingDeviceConfig();
srDevConfig.init(DEV1, CONFIG_KEY, jsonNode, mapper, config -> {
});
BasicDeviceConfig basicDeviceConfig = new BasicDeviceConfig();
basicDeviceConfig.init(DEV1, DEV1.toString(), JsonNodeFactory.instance.objectNode(), mapper, config -> {
});
// Mock interface netcfg
jsonStream = InterfaceConfig.class.getResourceAsStream("/interface1.json");
jsonNode = mapper.readTree(jsonStream);
InterfaceConfig interfaceConfig1 = new InterfaceConfig();
interfaceConfig1.init(CP1, CONFIG_KEY, jsonNode, mapper, config -> {
});
jsonStream = InterfaceConfig.class.getResourceAsStream("/interface2.json");
jsonNode = mapper.readTree(jsonStream);
InterfaceConfig interfaceConfig2 = new InterfaceConfig();
interfaceConfig2.init(CP1, CONFIG_KEY, jsonNode, mapper, config -> {
});
jsonStream = BasicHostConfig.class.getResourceAsStream("/host1.json");
jsonNode = mapper.readTree(jsonStream);
BasicHostConfig hostConfig1 = new BasicHostConfig();
hostConfig1.init(ROUTER_HOST, "basic", jsonNode, mapper, config -> {
});
networkConfigService = createMock(NetworkConfigRegistry.class);
expect(networkConfigService.getSubjects(DeviceId.class, SegmentRoutingDeviceConfig.class)).andReturn(Sets.newHashSet(DEV1)).anyTimes();
expect(networkConfigService.getConfig(DEV1, SegmentRoutingDeviceConfig.class)).andReturn(srDevConfig).anyTimes();
expect(networkConfigService.addConfig(DEV1, BasicDeviceConfig.class)).andReturn(basicDeviceConfig).anyTimes();
expect(networkConfigService.getConfig(DEV1, BasicDeviceConfig.class)).andReturn(basicDeviceConfig).anyTimes();
expect(networkConfigService.getSubjects(ConnectPoint.class, InterfaceConfig.class)).andReturn(Sets.newHashSet(CP1, CP2)).anyTimes();
expect(networkConfigService.getConfig(CP1, InterfaceConfig.class)).andReturn(interfaceConfig1).anyTimes();
expect(networkConfigService.getConfig(CP2, InterfaceConfig.class)).andReturn(interfaceConfig2).anyTimes();
expect(networkConfigService.applyConfig(eq(CP1), eq(InterfaceConfig.class), anyObject())).andReturn(interfaceConfig1).anyTimes();
expect(networkConfigService.applyConfig(eq(CP2), eq(InterfaceConfig.class), anyObject())).andReturn(interfaceConfig2).anyTimes();
expect(networkConfigService.getConfig(null, SegmentRoutingAppConfig.class)).andReturn(null).anyTimes();
expect(networkConfigService.getConfig(ROUTER_HOST, BasicHostConfig.class)).andReturn(hostConfig1).anyTimes();
expect(networkConfigService.applyConfig(eq(ROUTER_HOST), eq(BasicHostConfig.class), anyObject())).andReturn(hostConfig1).anyTimes();
replay(networkConfigService);
interfaceService = createMock(InterfaceService.class);
expect(interfaceService.getInterfaces()).andReturn(INTERFACES).anyTimes();
expect(interfaceService.getInterfacesByPort(CP1)).andReturn(Sets.newHashSet(INTF1)).anyTimes();
expect(interfaceService.getInterfacesByPort(CP2)).andReturn(Sets.newHashSet(INTF2)).anyTimes();
replay(interfaceService);
neighbourResolutionService = createMock(NeighbourResolutionService.class);
neighbourResolutionService.registerNeighbourHandler(anyObject(ConnectPoint.class), anyObject(), anyObject());
expectLastCall().anyTimes();
replay(neighbourResolutionService);
srManager = new SegmentRoutingManager();
srManager.interfaceService = interfaceService;
srManager.cfgService = networkConfigService;
srManager.neighbourResolutionService = neighbourResolutionService;
devConfig = new DeviceConfiguration(srManager);
devConfig.addSubnet(CP2, ROUTE1);
}
Aggregations