blob: c52d9ee3dbca40513200e918ea23ca856c1b8dc4 [file] [log] [blame]
Yixiao Chen68bfab22016-11-11 11:04:10 -05001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Yixiao Chen68bfab22016-11-11 11:04:10 -05003 *
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.tetopology.management.impl;
17
18import org.onlab.packet.Ip4Address;
19import org.onosproject.core.ApplicationId;
Ray Milkey6c013742017-08-15 10:16:43 -070020import org.onosproject.net.config.ConfigException;
Yixiao Chen68bfab22016-11-11 11:04:10 -050021import org.onosproject.net.config.Config;
22
23/**
24 * Configuration for TE Topology parameters.
25 */
26public class TeTopologyConfig extends Config<ApplicationId> {
27 private static final String CONFIG_VALUE_ERROR = "Error parsing config value";
28 private static final String PROVIDER_ID = "provider-id";
Yixiao Chen29f06332016-12-07 16:14:29 -050029 private static final String MDSC = "mdsc";
Yixiao Chen68bfab22016-11-11 11:04:10 -050030 private static final String TENODE_ID_START = "tenode-id-start";
31 private static final String TENODE_ID_END = "tenode-id-end";
32
33 /**
Yixiao Chen265b3bb2017-01-13 10:17:03 -050034 * Retrieves TE topology provider identifier.
35 *
36 * @return provider Id
37 * @throws ConfigException if the parameters are not correctly configured
38 * or conversion of the parameters fails
39 */
Yixiao Chen68bfab22016-11-11 11:04:10 -050040 public long providerId() throws ConfigException {
41 try {
42 return object.path(PROVIDER_ID).asLong();
43 } catch (IllegalArgumentException e) {
44 throw new ConfigException(CONFIG_VALUE_ERROR, e);
45 }
46 }
47
Yixiao Chen265b3bb2017-01-13 10:17:03 -050048 /**
49 * Retrieves TE node starting IPv4 address.
50 *
51 * @return the IPv4 address
52 * @throws ConfigException if the parameters are not correctly configured
53 * or conversion of the parameters fails
54 */
55 public Ip4Address teNodeIpStart() throws ConfigException {
Yixiao Chen68bfab22016-11-11 11:04:10 -050056 try {
57 return Ip4Address.valueOf(object.path(TENODE_ID_START).asText());
58 } catch (IllegalArgumentException e) {
59 throw new ConfigException(CONFIG_VALUE_ERROR, e);
60 }
Yixiao Chen265b3bb2017-01-13 10:17:03 -050061 }
Yixiao Chen68bfab22016-11-11 11:04:10 -050062
Yixiao Chen265b3bb2017-01-13 10:17:03 -050063 /**
64 * Retrieves TE node end IPv4 address.
65 *
66 * @return the IPv4 address
67 * @throws ConfigException if the parameters are not correctly configured
68 * or conversion of the parameters fails
69 */
70 public Ip4Address teNodeIpEnd() throws ConfigException {
71 try {
72 return Ip4Address.valueOf(object.path(TENODE_ID_END).asText());
73 } catch (IllegalArgumentException e) {
74 throw new ConfigException(CONFIG_VALUE_ERROR, e);
75 }
76 }
Yixiao Chen29f06332016-12-07 16:14:29 -050077
Yixiao Chen265b3bb2017-01-13 10:17:03 -050078 /**
79 * Retrieves if this is a MDSC(Multi-Domain Super Controller).
80 *
81 * @return MDSC value
82 * @throws ConfigException if the parameters are not correctly configured or
83 * conversion of the parameters fails
84 */
85 public String mdsc() throws ConfigException {
86 try {
87 return object.path(MDSC).asText();
88 } catch (IllegalArgumentException e) {
89 throw new ConfigException(CONFIG_VALUE_ERROR, e);
90 }
91 }
Yixiao Chen68bfab22016-11-11 11:04:10 -050092
93}