blob: 6deba8f445036b37c0cf16d090ef2c180682d731 [file] [log] [blame]
Hongtao Yin36f79aa2015-02-14 03:51:39 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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;
19import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.onosproject.net.intent.Intent;
23import org.onosproject.net.intent.PointToPointIntent;
24import org.onosproject.net.intent.TwoWayP2PIntent;
Hongtao Yin36f79aa2015-02-14 03:51:39 -080025
26import java.util.List;
Hongtao Yin36f79aa2015-02-14 03:51:39 -080027
28/**
29 * A intent compiler for {@link org.onosproject.net.intent.TwoWayP2PIntent}.
30 */
31@Component(immediate = true)
32public class TwoWayP2PIntentCompiler
33 extends ConnectivityIntentCompiler<TwoWayP2PIntent> {
34
35 @Activate
36 public void activate() {
37 intentManager.registerCompiler(TwoWayP2PIntent.class, this);
38 }
39
40 @Deactivate
41 public void deactivate() {
42 intentManager.unregisterCompiler(TwoWayP2PIntent.class);
43 }
44
45 @Override
Sho SHIMIZUec07ffd2016-02-22 20:45:21 -080046 public List<Intent> compile(TwoWayP2PIntent intent, List<Intent> installable) {
Hongtao Yin36f79aa2015-02-14 03:51:39 -080047 return Lists.newArrayList(
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070048 PointToPointIntent.builder()
49 .appId(intent.appId())
50 .key(intent.key())
51 .selector(intent.selector())
52 .treatment(intent.treatment())
53 .ingressPoint(intent.one())
54 .egressPoint(intent.two())
55 .constraints(intent.constraints())
56 .priority(intent.priority())
57 .build(),
58 PointToPointIntent.builder()
59 .appId(intent.appId())
60 .key(intent.key())
61 .selector(intent.selector())
62 .treatment(intent.treatment())
63 .ingressPoint(intent.two())
64 .egressPoint(intent.one())
65 .constraints(intent.constraints())
66 .priority(intent.priority())
67 .build());
Hongtao Yin36f79aa2015-02-14 03:51:39 -080068 }
69}