use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.
the class PacketManagerTest method setUp.
@Before
public void setUp() {
mgr = new PacketManager();
injectEventDispatcher(mgr, new TestEventDispatcher());
mgr.store = new SimplePacketStore();
mgr.clusterService = new ClusterServiceAdapter();
mgr.deviceService = new TestDeviceService();
mgr.deviceService = new TestDeviceService();
mgr.coreService = new TestCoreService();
providerRegistry = mgr;
mgr.activate();
DriverRegistryManager driverRegistry = new DriverRegistryManager();
driverService = new TestDriverManager(driverRegistry);
driverRegistry.addDriver(new DefaultDriver("foo", ImmutableList.of(), "", "", "", ImmutableMap.of(PacketProgrammable.class, TestPacketProgrammable.class), ImmutableMap.of()));
}
use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.
the class FujitsuNetconfControllerMock method setUp.
/**
* Sets up initial test environment.
*
* @param listener listener to be added
* @return driver handler
* @throws NetconfException when there is a problem
*/
public FujitsuDriverHandlerAdapter setUp(FujitsuNetconfSessionListenerTest listener) throws NetconfException {
try {
NetconfDeviceInfo deviceInfo = new NetconfDeviceInfo(VOLT_DEVICE_USERNAME, VOLT_DEVICE_PASSWORD, IpAddress.valueOf(VOLT_DEVICE_IP), VOLT_DEVICE_PORT);
NetconfDevice netconfDevice = connectDevice(deviceInfo.getDeviceId());
FujitsuNetconfSessionMock session = (FujitsuNetconfSessionMock) netconfDevice.getSession();
session.setListener(listener);
DeviceId deviceId = deviceInfo.getDeviceId();
DefaultDriver driver = new DefaultDriver(VOLT_DRIVER_NAME, new ArrayList<>(), "Fujitsu", "1.0", "1.0", ImmutableMap.of(), ImmutableMap.of());
DefaultDriverData driverData = new DefaultDriverData(driver, deviceId);
FujitsuDriverHandlerAdapter driverHandler;
driverHandler = new FujitsuDriverHandlerAdapter(driverData);
driverHandler.setUp(this);
return driverHandler;
} catch (NetconfException e) {
throw new NetconfException("Cannot create a device ", e);
}
}
use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.
the class MockDriverHandler method init.
// Centralize some initialization.
private void init(Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours, DeviceId mockDeviceId, CoreService mockCoreService, DeviceService mockDeviceService) throws NetconfException {
Map<String, String> properties = new HashMap<String, String>();
Driver mockDriver = new DefaultDriver("mockDriver", null, "ONOSProject", "1.0.0", "1.0.0", behaviours, properties);
mockDriverData = new DefaultDriverData(mockDriver, mockDeviceId);
ncc = new MockNetconfController();
ncc.connectDevice(mockDeviceId);
coreService = mockCoreService;
mastershipService = new MockMastershipService();
deviceService = mockDeviceService;
}
use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.
the class SoamManagerTest method setup.
@Before
public void setup() throws CfmConfigException, SoamConfigException {
soamManager = new SoamManager();
TestUtils.setField(soamManager, "coreService", new TestCoreService());
TestUtils.setField(soamManager, "cfmMepService", mepService);
TestUtils.setField(soamManager, "deviceService", deviceService);
injectEventDispatcher(soamManager, new TestEventDispatcher());
soamService = soamManager;
soamManager.activate();
DelayMeasurementEntry dmEntry1 = DefaultDelayMeasurementEntry.builder(DMID101, DelayMeasurementCreate.DmType.DM1DMTX, DelayMeasurementCreate.Version.Y17312011, MepId.valueOf((short) 11), Mep.Priority.PRIO5).build();
DelayMeasurementEntry dmEntry2 = DefaultDelayMeasurementEntry.builder(DMID102, DelayMeasurementCreate.DmType.DM1DMTX, DelayMeasurementCreate.Version.Y17312011, MepId.valueOf((short) 11), Mep.Priority.PRIO6).build();
mep1 = DefaultMepEntry.builder(MEPID1, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).addToDelayMeasurementList(dmEntry1).addToDelayMeasurementList(dmEntry2).buildEntry();
device1 = new DefaultDevice(ProviderId.NONE, DEVICE_ID1, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, TEST_SN, new ChassisId(1), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER).build());
AbstractProjectableModel.setDriverService(null, driverService);
Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
behaviours.put(DeviceDescriptionDiscovery.class, TestDeviceDiscoveryBehavior.class);
behaviours.put(CfmMepProgrammable.class, TestCfmMepProgrammable.class);
behaviours.put(SoamDmProgrammable.class, TestSoamDmProgrammable.class);
testDriver = new DefaultDriver(TEST_DRIVER, new ArrayList<Driver>(), TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, behaviours, new HashMap<>());
}
use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.
the class CfmMepManagerTest method testCreateMepBehaviorNotSupported.
@Test
public void testCreateMepBehaviorNotSupported() throws CfmConfigException {
final DeviceId deviceId3 = DeviceId.deviceId("netconf:3.2.3.4:830");
Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
behaviours.put(DeviceDescriptionDiscovery.class, TestDeviceDiscoveryBehavior.class);
Driver testDriver3 = new DefaultDriver(TEST_DRIVER_3, new ArrayList<Driver>(), TEST_MFR, TEST_HW_VERSION, TEST_SW_3, behaviours, new HashMap<>());
Device device3 = new DefaultDevice(ProviderId.NONE, deviceId3, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_3, TEST_SN, new ChassisId(2), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER_3).build());
expect(mdService.getMaintenanceAssociation(MDNAME1, MANAME1)).andReturn(Optional.ofNullable(ma1)).anyTimes();
replay(mdService);
expect(deviceService.getDevice(deviceId3)).andReturn(device3).anyTimes();
replay(deviceService);
expect(driverService.getDriver(deviceId3)).andReturn(testDriver3).anyTimes();
replay(driverService);
MepId mepId3 = MepId.valueOf((short) 3);
Mep mep3 = DefaultMep.builder(mepId3, deviceId3, PortNumber.portNumber(1), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
try {
mepManager.createMep(MDNAME1, MANAME1, mep3);
fail("Expecting CfmConfigException because driver does not support behavior");
} catch (CfmConfigException e) {
assertEquals("Device netconf:3.2.3.4:830 does not support " + "CfmMepProgrammable behaviour.", e.getMessage());
}
}
Aggregations