Search in sources :

Example 6 with DefaultDriver

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()));
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) ClusterServiceAdapter(org.onosproject.cluster.ClusterServiceAdapter) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DriverRegistryManager(org.onosproject.net.driver.impl.DriverRegistryManager) SimplePacketStore(org.onosproject.store.trivial.SimplePacketStore) Before(org.junit.Before)

Example 7 with DefaultDriver

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);
    }
}
Also used : NetconfException(org.onosproject.netconf.NetconfException) NetconfDevice(org.onosproject.netconf.NetconfDevice) NetconfDeviceInfo(org.onosproject.netconf.NetconfDeviceInfo) DeviceId(org.onosproject.net.DeviceId) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 8 with DefaultDriver

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;
}
Also used : HashMap(java.util.HashMap) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) Driver(org.onosproject.net.driver.Driver) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 9 with DefaultDriver

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<>());
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) ChassisId(org.onlab.packet.ChassisId) Behaviour(org.onosproject.net.driver.Behaviour) HashMap(java.util.HashMap) DelayMeasurementEntry(org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementEntry) DefaultDelayMeasurementEntry(org.onosproject.incubator.net.l2monitoring.soam.delay.DefaultDelayMeasurementEntry) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultDriver(org.onosproject.net.driver.DefaultDriver) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 10 with DefaultDriver

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());
    }
}
Also used : ChassisId(org.onlab.packet.ChassisId) Behaviour(org.onosproject.net.driver.Behaviour) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) Driver(org.onosproject.net.driver.Driver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DefaultMep(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMep) Mep(org.onosproject.incubator.net.l2monitoring.cfm.Mep) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) Test(org.junit.Test)

Aggregations

DefaultDriver (org.onosproject.net.driver.DefaultDriver)16 Before (org.junit.Before)7 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 TestEventDispatcher (org.onosproject.common.event.impl.TestEventDispatcher)6 Behaviour (org.onosproject.net.driver.Behaviour)6 Driver (org.onosproject.net.driver.Driver)5 ChassisId (org.onlab.packet.ChassisId)4 DefaultDevice (org.onosproject.net.DefaultDevice)4 TestBehaviour (org.onosproject.net.driver.TestBehaviour)4 DriverRegistryManager (org.onosproject.net.driver.impl.DriverRegistryManager)4 ArrayList (java.util.ArrayList)3 ComponentConfigAdapter (org.onosproject.cfg.ComponentConfigAdapter)3 DeviceId (org.onosproject.net.DeviceId)3 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)3 DefaultDriverProvider (org.onosproject.net.driver.DefaultDriverProvider)3 DefaultDriverTest (org.onosproject.net.driver.DefaultDriverTest)3 TestBehaviourImpl (org.onosproject.net.driver.TestBehaviourImpl)3 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)2 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)2