blob: 8ed1d94594f451fd83c2f70bba891c5048e47445 [file] [log] [blame]
Hongtao Yin36f79aa2015-02-14 03:51:39 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Hongtao Yin36f79aa2015-02-14 03:51:39 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Sho SHIMIZU6c28f832015-02-20 16:12:19 -080016package org.onosproject.net.intent.impl.compiler;
Hongtao Yin36f79aa2015-02-14 03:51:39 -080017
18import com.google.common.collect.Lists;
Ray Milkeyd84f89b2018-08-17 14:54:17 -070019import org.osgi.service.component.annotations.Activate;
20import org.osgi.service.component.annotations.Component;
21import org.osgi.service.component.annotations.Deactivate;
Ray Milkeya2cf3a12018-02-15 16:13:56 -080022import org.onosproject.net.FilteredConnectPoint;
Hongtao Yin36f79aa2015-02-14 03:51:39 -080023import org.onosproject.net.intent.Intent;
24import org.onosproject.net.intent.PointToPointIntent;
25import org.onosproject.net.intent.TwoWayP2PIntent;
Hongtao Yin36f79aa2015-02-14 03:51:39 -080026
27import java.util.List;
Hongtao Yin36f79aa2015-02-14 03:51:39 -080028
29/**
30 * A intent compiler for {@link org.onosproject.net.intent.TwoWayP2PIntent}.
31 */
32@Component(immediate = true)
33public class TwoWayP2PIntentCompiler
34 extends ConnectivityIntentCompiler<TwoWayP2PIntent> {
35
36 @Activate
37 public void activate() {
38 intentManager.registerCompiler(TwoWayP2PIntent.class, this);
39 }
40
41 @Deactivate
42 public void deactivate() {
43 intentManager.unregisterCompiler(TwoWayP2PIntent.class);
44 }
45
46 @Override
Sho SHIMIZUec07ffd2016-02-22 20:45:21 -080047 public List<Intent> compile(TwoWayP2PIntent intent, List<Intent> installable) {
Hongtao Yin36f79aa2015-02-14 03:51:39 -080048 return Lists.newArrayList(
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070049 PointToPointIntent.builder()
50 .appId(intent.appId())
51 .key(intent.key())
52 .selector(intent.selector())
53 .treatment(intent.treatment())
Ray Milkeya2cf3a12018-02-15 16:13:56 -080054 .filteredIngressPoint(new FilteredConnectPoint(intent.one()))
55 .filteredEgressPoint(new FilteredConnectPoint(intent.two()))
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070056 .constraints(intent.constraints())
57 .priority(intent.priority())
Luca Prete670ac5d2017-02-03 15:55:43 -080058 .resourceGroup(intent.resourceGroup())
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070059 .build(),
60 PointToPointIntent.builder()
61 .appId(intent.appId())
62 .key(intent.key())
63 .selector(intent.selector())
64 .treatment(intent.treatment())
Ray Milkeya2cf3a12018-02-15 16:13:56 -080065 .filteredIngressPoint(new FilteredConnectPoint(intent.two()))
66 .filteredEgressPoint(new FilteredConnectPoint(intent.one()))
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070067 .constraints(intent.constraints())
68 .priority(intent.priority())
Luca Prete670ac5d2017-02-03 15:55:43 -080069 .resourceGroup(intent.resourceGroup())
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070070 .build());
Hongtao Yin36f79aa2015-02-14 03:51:39 -080071 }
72}