Search in sources :

Example 1 with VplsConfig

use of org.onosproject.vpls.config.VplsConfig in project onos by opennetworkinglab.

the class DistributedVplsStore method writeVplsToNetConfig.

/**
 * Writes all VPLS data to the network configuration store.
 *
 * @param vplsDataCollection the VPLSs data
 */
public void writeVplsToNetConfig(Collection<VplsData> vplsDataCollection) {
    VplsAppConfig config = networkConfigService.addConfig(appId, VplsAppConfig.class);
    if (config == null) {
        log.debug("VPLS config is not available now");
        return;
    }
    config.clearVplsConfig();
    // Setup update time for this VPLS application configuration
    WallClockTimestamp ts = new WallClockTimestamp();
    config.updateTime(ts.unixTimestamp());
    vplsDataCollection.forEach(vplsData -> {
        Set<String> interfaceNames = vplsData.interfaces().stream().map(Interface::name).collect(Collectors.toSet());
        VplsConfig vplsConfig = new VplsConfig(vplsData.name(), interfaceNames, vplsData.encapsulationType());
        config.addVpls(vplsConfig);
    });
    networkConfigService.applyConfig(appId, VplsAppConfig.class, config.node());
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) VplsAppConfig(org.onosproject.vpls.config.VplsAppConfig) VplsConfig(org.onosproject.vpls.config.VplsConfig)

Example 2 with VplsConfig

use of org.onosproject.vpls.config.VplsConfig in project onos by opennetworkinglab.

the class VplsStoreTest method testAddVpls.

/**
 * Adds a VPLS to the store; checks if config store is also updated.
 */
@Test
public void testAddVpls() {
    VplsData vplsData = VplsData.of(VPLS1, VLAN);
    vplsStore.addVpls(vplsData);
    Collection<VplsData> vplsDataCollection = vplsStore.getAllVpls();
    assertEquals(1, vplsDataCollection.size());
    assertTrue(vplsDataCollection.contains(vplsData));
    VplsAppConfig storedConfig = vplsStore.networkConfigService.getConfig(null, VplsAppConfig.class);
    assertNotEquals(-1L, storedConfig.updateTime());
    assertEquals(1, storedConfig.vplss().size());
    VplsConfig vplsConfig = storedConfig.vplss().iterator().next();
    assertEquals(VPLS1, vplsConfig.name());
    assertEquals(0, vplsConfig.ifaces().size());
    assertEquals(VLAN, vplsConfig.encap());
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) VplsAppConfig(org.onosproject.vpls.config.VplsAppConfig) VplsConfig(org.onosproject.vpls.config.VplsConfig) VplsTest(org.onosproject.vpls.VplsTest) Test(org.junit.Test)

Example 3 with VplsConfig

use of org.onosproject.vpls.config.VplsConfig in project onos by opennetworkinglab.

the class VplsStoreTest method testUpdateVpls.

/**
 * Updates a VPLS from store; checks if config store is also updated.
 */
@Test
public void testUpdateVpls() {
    VplsData vplsData = VplsData.of(VPLS1, VLAN);
    vplsStore.addVpls(vplsData);
    vplsData.addInterface(V100H1);
    vplsData.addInterface(V100H2);
    vplsStore.updateVpls(vplsData);
    Collection<VplsData> vplsDataCollection = vplsStore.getAllVpls();
    assertEquals(1, vplsDataCollection.size());
    VplsData newVplsData = vplsDataCollection.iterator().next();
    assertEquals(vplsData, newVplsData);
    VplsAppConfig storedConfig = vplsStore.networkConfigService.getConfig(null, VplsAppConfig.class);
    assertNotEquals(-1L, storedConfig.updateTime());
    assertEquals(1, storedConfig.vplss().size());
    VplsConfig vplsConfig = storedConfig.vplss().iterator().next();
    assertEquals(VPLS1, vplsConfig.name());
    assertEquals(2, vplsConfig.ifaces().size());
    assertTrue(vplsConfig.ifaces().contains(V100H1.name()));
    assertTrue(vplsConfig.ifaces().contains(V100H2.name()));
    assertEquals(VLAN, vplsConfig.encap());
}
Also used : VplsData(org.onosproject.vpls.api.VplsData) VplsAppConfig(org.onosproject.vpls.config.VplsAppConfig) VplsConfig(org.onosproject.vpls.config.VplsConfig) VplsTest(org.onosproject.vpls.VplsTest) Test(org.junit.Test)

Aggregations

VplsAppConfig (org.onosproject.vpls.config.VplsAppConfig)3 VplsConfig (org.onosproject.vpls.config.VplsConfig)3 Test (org.junit.Test)2 VplsTest (org.onosproject.vpls.VplsTest)2 VplsData (org.onosproject.vpls.api.VplsData)2 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)1