9194221654e648ca143babcf901578942c52ebac
[onosfw.git] /
1 package org.onosproject.segmentrouting.config;
2
3 import org.onosproject.net.DeviceId;
4 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory;
6
7 /**
8  * NetworkConfigExceptions specifies a set of unchecked runtime exceptions that
9  * can be thrown by the {@link NetworkConfigManager}. It indicates errors that
10  * must be fixed in the config file before controller execution can proceed.
11  */
12 public class NetworkConfigException extends RuntimeException {
13
14     private static final long serialVersionUID = 4959684709803000652L;
15     protected static final Logger log = LoggerFactory
16             .getLogger(NetworkConfigException.class);
17
18     /**
19      * Exception for duplicate device identifier configuration.
20      */
21     public static class DuplicateDpid extends RuntimeException {
22         private static final long serialVersionUID = 5491113234592145335L;
23
24         public DuplicateDpid(DeviceId dpid) {
25             super();
26             log.error("Duplicate dpid found in switch-config Dpid:{}",
27                     dpid);
28         }
29     }
30
31     /**
32      * Exception for duplicate device name configuration.
33      */
34     public static class DuplicateName extends RuntimeException {
35         private static final long serialVersionUID = -4090171438031376129L;
36
37         public DuplicateName(String name) {
38             super();
39             log.error("Duplicate name found in switch-config name:{}", name);
40         }
41     }
42
43     /**
44      * Exception for unspecified device identifier for a switch.
45      */
46     public static class DpidNotSpecified extends RuntimeException {
47         private static final long serialVersionUID = -8494418855597117254L;
48
49         public DpidNotSpecified(String name) {
50             super();
51             log.error("Dpid not specified for switch-config name:{}", name);
52         }
53     }
54
55     /**
56      * Exception for unspecified device name for a switch.
57      */
58     public static class NameNotSpecified extends RuntimeException {
59         private static final long serialVersionUID = -3518881744110422891L;
60
61         public NameNotSpecified(DeviceId dpid) {
62             super();
63             log.error("Name not specified for switch-config dpid:{}",
64                     dpid);
65         }
66     }
67
68     /**
69      * Exception for unspecified device type for a switch.
70      */
71     public static class SwitchTypeNotSpecified extends RuntimeException {
72         private static final long serialVersionUID = 2527453336226053753L;
73
74         public SwitchTypeNotSpecified(DeviceId dpid) {
75             super();
76             log.error("Switch type not specified for switch-config dpid:{}",
77                     dpid);
78         }
79     }
80
81     /**
82      * Exception for unknown device type configured for a switch.
83      */
84     public static class UnknownSwitchType extends RuntimeException {
85         private static final long serialVersionUID = 7758418165512249170L;
86
87         public UnknownSwitchType(String type, String name) {
88             super();
89             log.error("Unknown switch type {} for switch name:{}", type, name);
90         }
91     }
92
93     /**
94      * Exception for missing required parameter configuration for a switch.
95      */
96     public static class ParamsNotSpecified extends RuntimeException {
97         private static final long serialVersionUID = 6247582323691265513L;
98
99         public ParamsNotSpecified(String name) {
100             super();
101             log.error("Params required - not specified for switch:{}", name);
102         }
103     }
104
105     /**
106      * Reserved for future use.
107      */
108     public static class LinkTypeNotSpecified extends RuntimeException {
109         private static final long serialVersionUID = -2089470389588542215L;
110
111         public LinkTypeNotSpecified(String dpid1, String dpid2) {
112             super();
113             log.error("Link type not specified for link-config between "
114                     + "dpid1:{} and dpid2:{}", dpid1, dpid2);
115         }
116     }
117
118     /**
119      * Reserved for future use.
120      */
121     public static class LinkDpidNotSpecified extends RuntimeException {
122         private static final long serialVersionUID = -5701825916378616004L;
123
124         public LinkDpidNotSpecified(String dpid1, String dpid2) {
125             super();
126             if (dpid1 == null) {
127                 log.error("nodeDpid1 not specified for link-config ");
128             }
129             if (dpid2 == null) {
130                 log.error("nodeDpid2 not specified for link-config ");
131             }
132         }
133     }
134
135     /**
136      * Reserved for future use.
137      */
138     public static class LinkForUnknownSwitchConfig extends RuntimeException {
139         private static final long serialVersionUID = -2910458439881964094L;
140
141         public LinkForUnknownSwitchConfig(String dpid) {
142             super();
143             log.error("Link configuration was specified for a switch-dpid {} "
144                     + "that has not been configured", dpid);
145         }
146     }
147
148     /**
149      * Reserved for future use.
150      */
151     public static class UnknownLinkType extends RuntimeException {
152         private static final long serialVersionUID = -5505376193106542305L;
153
154         public UnknownLinkType(String linktype, String dpid1, String dpid2) {
155             super();
156             log.error("unknown link type {} for links between dpid1:{} "
157                     + "and dpid2:{}", linktype, dpid1, dpid2);
158         }
159     }
160
161     /**
162      * Exception for generic configuration errors.
163      */
164     public static class ErrorConfig extends RuntimeException {
165         private static final long serialVersionUID = -2827406314700193147L;
166
167         public ErrorConfig(String errorMsg) {
168             super();
169             log.error(errorMsg);
170         }
171
172     }
173
174     /**
175      * Reserved for future use.
176      */
177     public static class SwitchDpidNotConverted extends RuntimeException {
178         private static final long serialVersionUID = 5640347104590170426L;
179
180         public SwitchDpidNotConverted(String name) {
181             super();
182             log.error("Switch dpid specified as a HexString {} does not match "
183                     + "with long value", name);
184         }
185     }
186
187     /**
188      * Reserved for future use.
189      */
190     public static class LinkDpidNotConverted extends RuntimeException {
191         private static final long serialVersionUID = 2397245646094080774L;
192
193         public LinkDpidNotConverted(String dpid1, String dpid2) {
194             log.error("Dpids expressed as HexStrings for links between dpid1:{} "
195                     + "and dpid2:{} do not match with long values", dpid1, dpid2);
196         }
197     }
198
199 }
200