blob: 50a67546b501cb0aae99574313f30e9a733887cc [file] [log] [blame]
Hongtao Yin36f79aa2015-02-14 03:51:39 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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;
Brian O'Connor6de2e202015-05-21 14:30:41 -070025import org.onosproject.net.resource.link.LinkResourceAllocations;
Hongtao Yin36f79aa2015-02-14 03:51:39 -080026
27import java.util.List;
28import java.util.Set;
29
30/**
31 * A intent compiler for {@link org.onosproject.net.intent.TwoWayP2PIntent}.
32 */
33@Component(immediate = true)
34public class TwoWayP2PIntentCompiler
35 extends ConnectivityIntentCompiler<TwoWayP2PIntent> {
36
37 @Activate
38 public void activate() {
39 intentManager.registerCompiler(TwoWayP2PIntent.class, this);
40 }
41
42 @Deactivate
43 public void deactivate() {
44 intentManager.unregisterCompiler(TwoWayP2PIntent.class);
45 }
46
47 @Override
48 public List<Intent> compile(TwoWayP2PIntent intent, List<Intent> installable,
49 Set<LinkResourceAllocations> resources) {
50 return Lists.newArrayList(
Ray Milkey3e3ec5f2015-03-17 17:00:38 -070051 PointToPointIntent.builder()
52 .appId(intent.appId())
53 .key(intent.key())
54 .selector(intent.selector())
55 .treatment(intent.treatment())
56 .ingressPoint(intent.one())
57 .egressPoint(intent.two())
58 .constraints(intent.constraints())
59 .priority(intent.priority())
60 .build(),
61 PointToPointIntent.builder()
62 .appId(intent.appId())
63 .key(intent.key())
64 .selector(intent.selector())
65 .treatment(intent.treatment())
66 .ingressPoint(intent.two())
67 .egressPoint(intent.one())
68 .constraints(intent.constraints())
69 .priority(intent.priority())
70 .build());
Hongtao Yin36f79aa2015-02-14 03:51:39 -080071 }
72}