blob: ae2fc0e7fcbfdb13d15634033855e36451da6ed4 [file] [log] [blame]
Yixiao Chen68bfab22016-11-11 11:04:10 -05001/*
2 * Copyright 2016-present 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 */
16package org.onosproject.tetopology.management.impl;
17
18import org.onlab.packet.Ip4Address;
19import org.onosproject.core.ApplicationId;
20import org.onosproject.incubator.net.config.basics.ConfigException;
21import 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";
29 private static final String TENODE_ID_START = "tenode-id-start";
30 private static final String TENODE_ID_END = "tenode-id-end";
31
32 /**
33 * Retrieves TE topology provider identifier.
34 *
35 * @return provider Id
36 * @throws ConfigException if the parameters are not correctly configured
37 * or conversion of the parameters fails
38 */
39 public long providerId() throws ConfigException {
40 try {
41 return object.path(PROVIDER_ID).asLong();
42 } catch (IllegalArgumentException e) {
43 throw new ConfigException(CONFIG_VALUE_ERROR, e);
44 }
45 }
46
47 /**
48 * Retrieves TE node starting IPv4 address.
49 *
50 * @return the IPv4 address
51 * @throws ConfigException if the parameters are not correctly configured
52 * or conversion of the parameters fails
53 */
54 public Ip4Address teNodeIpStart() throws ConfigException {
55 try {
56 return Ip4Address.valueOf(object.path(TENODE_ID_START).asText());
57 } catch (IllegalArgumentException e) {
58 throw new ConfigException(CONFIG_VALUE_ERROR, e);
59 }
60 }
61
62 /**
63 * Retrieves TE node end IPv4 address.
64 *
65 * @return the IPv4 address
66 * @throws ConfigException if the parameters are not correctly configured
67 * or conversion of the parameters fails
68 */
69 public Ip4Address teNodeIpEnd() throws ConfigException {
70 try {
71 return Ip4Address.valueOf(object.path(TENODE_ID_END).asText());
72 } catch (IllegalArgumentException e) {
73 throw new ConfigException(CONFIG_VALUE_ERROR, e);
74 }
75 }
76
77}