Search in sources :

Example 1 with DefaultDriver

use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.

the class SoamManagerTest method testCreateDmNoBehavior.

@Test
public void testCreateDmNoBehavior() throws CfmConfigException, SoamConfigException {
    final DeviceId deviceId3 = DeviceId.deviceId("netconf:3.2.3.4:830");
    final MepId mepId3 = MepId.valueOf((short) 3);
    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(deviceService.getDevice(deviceId3)).andReturn(device3).anyTimes();
    replay(deviceService);
    MepEntry mep3 = DefaultMepEntry.builder(mepId3, deviceId3, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).buildEntry();
    expect(mepService.getMep(MDNAME1, MANAME1, mepId3)).andReturn(mep3).anyTimes();
    replay(mepService);
    expect(driverService.getDriver(deviceId3)).andReturn(testDriver3).anyTimes();
    replay(driverService);
    DelayMeasurementCreate dmCreate1 = DefaultDelayMeasurementCreate.builder(DelayMeasurementCreate.DmType.DM1DMTX, DelayMeasurementCreate.Version.Y17312011, MepId.valueOf((short) 11), Mep.Priority.PRIO3).binsPerFdInterval((short) 4).binsPerFdrInterval((short) 5).binsPerIfdvInterval((short) 6).build();
    try {
        soamManager.createDm(MDNAME1, MANAME1, mepId3, dmCreate1);
        fail("Expecting exception since device does not support behavior");
    } catch (CfmConfigException e) {
        assertEquals("Device netconf:3.2.3.4:830 from MEP :md-1/" + "ma-1-1/3 does not implement SoamDmProgrammable", 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) MepEntry(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry) DefaultMepEntry(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepEntry) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DelayMeasurementCreate(org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate) DefaultDelayMeasurementCreate(org.onosproject.incubator.net.l2monitoring.soam.delay.DefaultDelayMeasurementCreate) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) Test(org.junit.Test)

Example 2 with DefaultDriver

use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.

the class DriverCodecTest method codecTest.

@Test
public void codecTest() {
    Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = ImmutableMap.of(TestBehaviour.class, TestBehaviourImpl.class, TestBehaviourTwo.class, TestBehaviourTwoImpl.class);
    Map<String, String> properties = ImmutableMap.of("key1", "value1", "key2", "value2");
    DefaultDriver parent = new DefaultDriver("parent", new ArrayList<>(), "Acme", "HW1.2.3", "SW1.2.3", behaviours, properties);
    DefaultDriver child = new DefaultDriver("child", ImmutableList.of(parent), "Acme", "HW1.2.3.1", "SW1.2.3.1", behaviours, properties);
    MockCodecContext context = new MockCodecContext();
    ObjectNode driverJson = context.codec(Driver.class).encode(child, context);
    assertThat(driverJson, matchesDriver(child));
}
Also used : TestBehaviour(org.onosproject.net.driver.TestBehaviour) Behaviour(org.onosproject.net.driver.Behaviour) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DriverJsonMatcher.matchesDriver(org.onosproject.codec.impl.DriverJsonMatcher.matchesDriver) Driver(org.onosproject.net.driver.Driver) Test(org.junit.Test)

Example 3 with DefaultDriver

use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.

the class PiPipeconfManager method buildMergedDriver.

private Driver buildMergedDriver(PiPipeconfId pipeconfId, String baseDriverName, String newDriverName) {
    final Driver baseDriver = getDriver(baseDriverName);
    if (baseDriver == null) {
        log.error("Base driver {} not found, cannot build a merged one", baseDriverName);
        return null;
    }
    final PiPipeconf pipeconf = pipeconfs.get(pipeconfId);
    if (pipeconf == null) {
        log.error("Pipeconf {} is not registered, cannot build a merged driver", pipeconfId);
        return null;
    }
    // extract the behaviours from the pipipeconf.
    final Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
    pipeconf.behaviours().forEach(b -> behaviours.put(b, pipeconf.implementation(b).get()));
    // general, we should give higher priority to pipeconf behaviours.
    if (baseDriver.hasBehaviour(PortStatisticsDiscovery.class) && behaviours.remove(PortStatisticsDiscovery.class) != null) {
        log.warn("Ignoring {} behaviour from pipeconf {}, but using " + "the one provided by {} driver...", PortStatisticsDiscovery.class.getSimpleName(), pipeconfId, baseDriver.name());
    }
    final Driver piPipeconfDriver = new DefaultDriver(newDriverName, baseDriver.parents(), baseDriver.manufacturer(), baseDriver.hwVersion(), baseDriver.swVersion(), behaviours, new HashMap<>());
    // merge it with the base driver that was assigned to the device
    return piPipeconfDriver.merge(baseDriver);
}
Also used : PortStatisticsDiscovery(org.onosproject.net.device.PortStatisticsDiscovery) Behaviour(org.onosproject.net.driver.Behaviour) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PiPipeconf(org.onosproject.net.pi.model.PiPipeconf) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) Driver(org.onosproject.net.driver.Driver)

Example 4 with DefaultDriver

use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.

the class DriverRegistryManagerTest method basicQueries.

@Test
public void basicQueries() {
    DefaultDriverProvider mockProvider = new DefaultDriverProvider();
    DefaultDriver driver = new DefaultDriver("default", Lists.newArrayList(), MFR, HW, SW, ImmutableMap.of(TestBehaviour.class, TestBehaviourImpl.class), ImmutableMap.of("foo", "bar"));
    mockProvider.addDriver(driver);
    mgr.registerProvider(mockProvider);
    assertSame("driver is missing", driver, mgr.getDriver("default"));
    assertSame("driver is missing", driver, mgr.getDriver(MFR, HW, SW));
    assertArrayEquals("driver list is wrong", ImmutableList.of(driver).toArray(), mgr.getDrivers().toArray());
    assertArrayEquals("provider list is wrong", ImmutableList.of(mockProvider).toArray(), mgr.getProviders().toArray());
    assertEquals("wrong behaviour class", TestBehaviourImpl.class, mgr.getBehaviourClass("org.onosproject.net.driver.TestBehaviourImpl"));
}
Also used : TestBehaviourImpl(org.onosproject.net.driver.TestBehaviourImpl) DefaultDriver(org.onosproject.net.driver.DefaultDriver) TestBehaviour(org.onosproject.net.driver.TestBehaviour) DefaultDriverProvider(org.onosproject.net.driver.DefaultDriverProvider) Test(org.junit.Test) DefaultDriverTest(org.onosproject.net.driver.DefaultDriverTest)

Example 5 with DefaultDriver

use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.

the class GroupManagerTest method setUp.

@Before
public void setUp() {
    mgr = new GroupManager();
    groupService = mgr;
    // mgr.deviceService = new DeviceManager();
    mgr.deviceService = new TestDeviceService();
    mgr.cfgService = new ComponentConfigAdapter();
    mgr.store = new SimpleGroupStore();
    mgr.mastershipService = new TestMastershipService();
    injectEventDispatcher(mgr, new TestEventDispatcher());
    providerRegistry = mgr;
    mgr.activate(null);
    mgr.addListener(listener);
    DriverRegistryManager driverRegistry = new DriverRegistryManager();
    driverService = new TestDriverManager(driverRegistry);
    driverRegistry.addDriver(new DefaultDriver("foo", ImmutableList.of(), "", "", "", ImmutableMap.of(GroupProgrammable.class, TestGroupProgrammable.class), ImmutableMap.of()));
    internalProvider = new TestGroupProvider(PID);
    provider = internalProvider;
    providerService = providerRegistry.register(provider);
    appId = new DefaultApplicationId(2, "org.groupmanager.test");
    assertTrue("provider should be registered", providerRegistry.getProviders().contains(provider.id()));
}
Also used : ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) SimpleGroupStore(org.onosproject.store.trivial.SimpleGroupStore) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DriverRegistryManager(org.onosproject.net.driver.impl.DriverRegistryManager) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Before(org.junit.Before)

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