Search in sources :

Example 1 with ProtectionEndpointIntent

use of org.onosproject.net.intent.ProtectionEndpointIntent in project onos by opennetworkinglab.

the class ProtectedTransportIntentCompiler method createFreshProtectedPaths.

/**
 * Creates new protected paths.
 *
 * @param intent    original intention
 * @param did1      identifier of first device
 * @param did2      identifier of second device
 * @return compilation result
 * @throws IntentCompilationException when there's no satisfying path.
 */
private List<Intent> createFreshProtectedPaths(ProtectedTransportIntent intent, DeviceId did1, DeviceId did2) {
    DisjointPath disjointPath = getDisjointPath(intent, did1, did2);
    if (disjointPath == null || disjointPath.backup() == null) {
        log.error("Unable to find disjoint path between {}, {}", did1, did2);
        throw new IntentCompilationException("Unable to find disjoint paths.");
    }
    Path primary = disjointPath.primary();
    Path secondary = disjointPath.backup();
    String fingerprint = intent.key().toString();
    // pick and allocate Vlan to use as S-tag
    Pair<VlanId, VlanId> vlans = allocateEach(intent, primary, secondary, VlanId.class);
    VlanId primaryVlan = vlans.getLeft();
    VlanId secondaryVlan = vlans.getRight();
    // Build edge Intents for head/tail
    // resource for head/tail
    Collection<NetworkResource> oneResources = new ArrayList<>();
    Collection<NetworkResource> twoResources = new ArrayList<>();
    List<TransportEndpointDescription> onePaths = new ArrayList<>();
    onePaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(primary.src(), primaryVlan)).build());
    onePaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(secondary.src(), secondaryVlan)).build());
    List<TransportEndpointDescription> twoPaths = new ArrayList<>();
    twoPaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(primary.dst(), primaryVlan)).build());
    twoPaths.add(TransportEndpointDescription.builder().withOutput(vlanPort(secondary.dst(), secondaryVlan)).build());
    ProtectionEndpointIntent oneIntent = ProtectionEndpointIntent.builder().key(intent.key()).appId(intent.appId()).priority(intent.priority()).resources(oneResources).deviceId(did1).description(buildDescription(onePaths, did2, fingerprint)).build();
    ProtectionEndpointIntent twoIntent = ProtectionEndpointIntent.builder().key(intent.key()).appId(intent.appId()).resources(twoResources).deviceId(did2).description(buildDescription(twoPaths, did1, fingerprint)).build();
    // Build transit intent for primary/secondary path
    Collection<NetworkResource> resources1 = ImmutableList.of(marker("protection1"));
    Collection<NetworkResource> resources2 = ImmutableList.of(marker("protection2"));
    ImmutableList<Intent> result = ImmutableList.<Intent>builder().addAll(createTransitIntent(intent, primary, primaryVlan, resources1)).addAll(createTransitIntent(intent, secondary, secondaryVlan, resources2)).add(oneIntent).add(twoIntent).build();
    log.trace("createFreshProtectedPaths result: {}", result);
    return result;
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) ArrayList(java.util.ArrayList) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) ProtectedTransportIntent(org.onosproject.net.intent.ProtectedTransportIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) NetworkResource(org.onosproject.net.NetworkResource) TransportEndpointDescription(org.onosproject.net.behaviour.protection.TransportEndpointDescription) IntentCompilationException(org.onosproject.net.intent.IntentCompilationException) DisjointPath(org.onosproject.net.DisjointPath) VlanId(org.onlab.packet.VlanId)

Example 2 with ProtectionEndpointIntent

use of org.onosproject.net.intent.ProtectionEndpointIntent in project onos by opennetworkinglab.

the class ProtectionEndpointIntentInstallerTest method testInstallFailed.

/**
 * Test if installation failed.
 * framework.
 */
@Test
public void testInstallFailed() {
    networkConfigService = new TestFailedNetworkConfigService();
    installer.networkConfigService = networkConfigService;
    List<Intent> intentsToUninstall = Lists.newArrayList();
    List<Intent> intentsToInstall = createProtectionIntents(CP2);
    IntentData toUninstall = null;
    IntentData toInstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
    toInstall = IntentData.compiled(toInstall, intentsToInstall);
    IntentOperationContext<ProtectionEndpointIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    assertEquals(intentInstallCoordinator.failedContext, operationContext);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Example 3 with ProtectionEndpointIntent

use of org.onosproject.net.intent.ProtectionEndpointIntent in project onos by opennetworkinglab.

the class ProtectionEndpointIntentInstallerTest method testInstallIntents.

/**
 * Installs protection endpoint Intents.
 * framework.
 */
@Test
public void testInstallIntents() {
    List<Intent> intentsToUninstall = Lists.newArrayList();
    List<Intent> intentsToInstall = createProtectionIntents(CP2);
    IntentData toUninstall = null;
    IntentData toInstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
    toInstall = IntentData.compiled(toInstall, intentsToInstall);
    IntentOperationContext<ProtectionEndpointIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    assertEquals(intentInstallCoordinator.successContext, operationContext);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Example 4 with ProtectionEndpointIntent

use of org.onosproject.net.intent.ProtectionEndpointIntent in project onos by opennetworkinglab.

the class ProtectionEndpointIntentInstallerTest method testUninstallAndInstallIntents.

/**
 * Test both uninstall and install protection endpoint Intents.
 * framework.
 */
@Test
public void testUninstallAndInstallIntents() {
    List<Intent> intentsToUninstall = createProtectionIntents(CP2);
    List<Intent> intentsToInstall = createProtectionIntents(CP3);
    IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.INSTALLED, new WallClockTimestamp());
    toUninstall = IntentData.compiled(toUninstall, intentsToInstall);
    IntentData toInstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
    toInstall = IntentData.compiled(toInstall, intentsToInstall);
    IntentOperationContext<ProtectionEndpointIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    assertEquals(intentInstallCoordinator.successContext, operationContext);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Example 5 with ProtectionEndpointIntent

use of org.onosproject.net.intent.ProtectionEndpointIntent in project onos by opennetworkinglab.

the class ProtectionEndpointIntentInstallerTest method testUninstallIntents.

/**
 * Uninstalls protection endpoint Intents.
 * framework.
 */
@Test
public void testUninstallIntents() {
    List<Intent> intentsToUninstall = createProtectionIntents(CP2);
    List<Intent> intentsToInstall = Lists.newArrayList();
    IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
    IntentData toInstall = null;
    IntentOperationContext<ProtectionEndpointIntent> operationContext;
    IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
    operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
    installer.apply(operationContext);
    assertEquals(intentInstallCoordinator.successContext, operationContext);
}
Also used : WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext) Test(org.junit.Test)

Aggregations

ProtectionEndpointIntent (org.onosproject.net.intent.ProtectionEndpointIntent)10 Intent (org.onosproject.net.intent.Intent)6 IntentData (org.onosproject.net.intent.IntentData)6 IntentOperationContext (org.onosproject.net.intent.IntentOperationContext)6 Test (org.junit.Test)5 IntentInstallationContext (org.onosproject.net.intent.IntentInstallationContext)5 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)4 ArrayList (java.util.ArrayList)3 ProtectedTransportEndpointDescription (org.onosproject.net.behaviour.protection.ProtectedTransportEndpointDescription)3 TransportEndpointDescription (org.onosproject.net.behaviour.protection.TransportEndpointDescription)3 List (java.util.List)2 DeviceId (org.onosproject.net.DeviceId)2 IntentService (org.onosproject.net.intent.IntentService)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1