blob: d446de11a2b9fed00276081d87bb6f47714d39b6 [file] [log] [blame]
Shashikanth VHa676b292017-02-24 12:19:26 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Shashikanth VHa676b292017-02-24 12:19:26 +05303 *
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 */
16package org.onosproject.pcep.api;
17
18import org.onosproject.net.LinkKey;
19import org.onosproject.net.config.Config;
20
21/**
22 * Configuration to specify traffic engineering parameters of the link.
23 */
24public class TeLinkConfig extends Config<LinkKey> {
25 public static final String MAX_RESV_BW = "maxRervableBandwidth";
26 public static final String UNRESV_BWS = "unReservedBandwidths";
27 public static final String IGP_COST = "igpCost";
28 public static final String TE_COST = "teCost";
29
30 @Override
31 public boolean isValid() {
32 return hasOnlyFields(MAX_RESV_BW, UNRESV_BWS, IGP_COST, TE_COST);
33 }
34
35 /**
36 * Gets the maximum reservable bandwidth of the link.
37 *
38 * @return maximum reservable bandwidth
39 */
40 public Double maxResvBandwidth() {
41
42 String resvBw = get(MAX_RESV_BW, null);
43 return resvBw != null ?
44 Double.valueOf(resvBw) :
45 0.0;
46 }
47
48 /**
49 * Gets the set of unreserved bandwidth of the link.
50 *
51 * @return set of unreserved bandwidth
52 */
53 public Double unResvBandwidth() {
54 String unResvBw = get(UNRESV_BWS, null);
55 return unResvBw != null ? Double.valueOf(unResvBw) : 0.0;
56 }
57
58 /**
59 * Gets the igp cost of the link.
60 *
61 * @return igp cost of the link
62 */
63 public int igpCost() {
64 return get(IGP_COST, 0);
65 }
66
67 /**
68 * Gets the te cost of the link.
69 *
70 * @return te cost of the link
71 */
72 public int teCost() {
73 return get(TE_COST, 0);
74 }
75
76 /**
77 * Sets the maximum reservable bandwidth of the link.
78 *
79 * @param maxResvBw maximum reservable bandwidth of link
80 * @return te link configuration
81 */
82 public TeLinkConfig maxResvBandwidth(Double maxResvBw) {
83 return (TeLinkConfig) setOrClear(MAX_RESV_BW, maxResvBw);
84 }
85
86 /**
87 * Sets unreserved bandwidths of the link in priority order.
88 *
89 * @param unResvBw unreserved bandwidths of the link in priority order
90 * @return te link configuration
91 */
92 public TeLinkConfig unResvBandwidth(Double unResvBw) {
93 return (TeLinkConfig) setOrClear(UNRESV_BWS, unResvBw);
94 }
95
96 /**
97 * Sets the igp cost of the link.
98 *
99 * @param igpCost igp cost of link
100 * @return te link configuration
101 */
102 public TeLinkConfig igpCost(int igpCost) {
103 return (TeLinkConfig) setOrClear(IGP_COST, igpCost);
104 }
105
106 /**
107 * Sets the te cost of the link.
108 *
109 * @param teCost te cost of link
110 * @return te link configuration
111 */
112 public TeLinkConfig teCost(int teCost) {
113 return (TeLinkConfig) setOrClear(TE_COST, teCost);
114 }
115
116
117}
118