2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.segmentrouting.config;
18 import org.onosproject.net.DeviceId;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 * NetworkConfigExceptions specifies a set of unchecked runtime exceptions that
24 * can be thrown by the {@link NetworkConfigManager}. It indicates errors that
25 * must be fixed in the config file before controller execution can proceed.
27 public class NetworkConfigException extends RuntimeException {
29 private static final long serialVersionUID = 4959684709803000652L;
30 protected static final Logger log = LoggerFactory
31 .getLogger(NetworkConfigException.class);
34 * Exception for duplicate device identifier configuration.
36 public static class DuplicateDpid extends RuntimeException {
37 private static final long serialVersionUID = 5491113234592145335L;
39 public DuplicateDpid(DeviceId dpid) {
41 log.error("Duplicate dpid found in switch-config Dpid:{}",
47 * Exception for duplicate device name configuration.
49 public static class DuplicateName extends RuntimeException {
50 private static final long serialVersionUID = -4090171438031376129L;
52 public DuplicateName(String name) {
54 log.error("Duplicate name found in switch-config name:{}", name);
59 * Exception for unspecified device identifier for a switch.
61 public static class DpidNotSpecified extends RuntimeException {
62 private static final long serialVersionUID = -8494418855597117254L;
64 public DpidNotSpecified(String name) {
66 log.error("Dpid not specified for switch-config name:{}", name);
71 * Exception for unspecified device name for a switch.
73 public static class NameNotSpecified extends RuntimeException {
74 private static final long serialVersionUID = -3518881744110422891L;
76 public NameNotSpecified(DeviceId dpid) {
78 log.error("Name not specified for switch-config dpid:{}",
84 * Exception for unspecified device type for a switch.
86 public static class SwitchTypeNotSpecified extends RuntimeException {
87 private static final long serialVersionUID = 2527453336226053753L;
89 public SwitchTypeNotSpecified(DeviceId dpid) {
91 log.error("Switch type not specified for switch-config dpid:{}",
97 * Exception for unknown device type configured for a switch.
99 public static class UnknownSwitchType extends RuntimeException {
100 private static final long serialVersionUID = 7758418165512249170L;
102 public UnknownSwitchType(String type, String name) {
104 log.error("Unknown switch type {} for switch name:{}", type, name);
109 * Exception for missing required parameter configuration for a switch.
111 public static class ParamsNotSpecified extends RuntimeException {
112 private static final long serialVersionUID = 6247582323691265513L;
114 public ParamsNotSpecified(String name) {
116 log.error("Params required - not specified for switch:{}", name);
121 * Reserved for future use.
123 public static class LinkTypeNotSpecified extends RuntimeException {
124 private static final long serialVersionUID = -2089470389588542215L;
126 public LinkTypeNotSpecified(String dpid1, String dpid2) {
128 log.error("Link type not specified for link-config between "
129 + "dpid1:{} and dpid2:{}", dpid1, dpid2);
134 * Reserved for future use.
136 public static class LinkDpidNotSpecified extends RuntimeException {
137 private static final long serialVersionUID = -5701825916378616004L;
139 public LinkDpidNotSpecified(String dpid1, String dpid2) {
142 log.error("nodeDpid1 not specified for link-config ");
145 log.error("nodeDpid2 not specified for link-config ");
151 * Reserved for future use.
153 public static class LinkForUnknownSwitchConfig extends RuntimeException {
154 private static final long serialVersionUID = -2910458439881964094L;
156 public LinkForUnknownSwitchConfig(String dpid) {
158 log.error("Link configuration was specified for a switch-dpid {} "
159 + "that has not been configured", dpid);
164 * Reserved for future use.
166 public static class UnknownLinkType extends RuntimeException {
167 private static final long serialVersionUID = -5505376193106542305L;
169 public UnknownLinkType(String linktype, String dpid1, String dpid2) {
171 log.error("unknown link type {} for links between dpid1:{} "
172 + "and dpid2:{}", linktype, dpid1, dpid2);
177 * Exception for generic configuration errors.
179 public static class ErrorConfig extends RuntimeException {
180 private static final long serialVersionUID = -2827406314700193147L;
182 public ErrorConfig(String errorMsg) {
190 * Reserved for future use.
192 public static class SwitchDpidNotConverted extends RuntimeException {
193 private static final long serialVersionUID = 5640347104590170426L;
195 public SwitchDpidNotConverted(String name) {
197 log.error("Switch dpid specified as a HexString {} does not match "
198 + "with long value", name);
203 * Reserved for future use.
205 public static class LinkDpidNotConverted extends RuntimeException {
206 private static final long serialVersionUID = 2397245646094080774L;
208 public LinkDpidNotConverted(String dpid1, String dpid2) {
209 log.error("Dpids expressed as HexStrings for links between dpid1:{} "
210 + "and dpid2:{} do not match with long values", dpid1, dpid2);