Saurav Das | fb93c25 | 2014-08-18 20:40:13 -0700 | [diff] [blame^] | 1 | package net.onrc.onos.core.configmanager; |
| 2 | |
| 3 | import org.projectfloodlight.openflow.util.HexString; |
| 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 | public static class DuplicateDpid extends RuntimeException { |
| 19 | private static final long serialVersionUID = 5491113234592145335L; |
| 20 | |
| 21 | public DuplicateDpid(long dpid) { |
| 22 | super(); |
| 23 | log.error("Duplicate dpid found in switch-config Dpid:{}", |
| 24 | HexString.toHexString(dpid)); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | public static class DuplicateName extends RuntimeException { |
| 29 | private static final long serialVersionUID = -4090171438031376129L; |
| 30 | |
| 31 | public DuplicateName(String name) { |
| 32 | super(); |
| 33 | log.error("Duplicate name found in switch-config name:{}", name); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | public static class DpidNotSpecified extends RuntimeException { |
| 38 | private static final long serialVersionUID = -8494418855597117254L; |
| 39 | |
| 40 | public DpidNotSpecified(String name) { |
| 41 | super(); |
| 42 | log.error("Dpid not specified for switch-config name:{}", name); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | public static class NameNotSpecified extends RuntimeException { |
| 47 | private static final long serialVersionUID = -3518881744110422891L; |
| 48 | |
| 49 | public NameNotSpecified(long dpid) { |
| 50 | super(); |
| 51 | log.error("Name not specified for switch-config dpid:{}", |
| 52 | HexString.toHexString(dpid)); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | public static class SwitchTypeNotSpecified extends RuntimeException { |
| 57 | private static final long serialVersionUID = 2527453336226053753L; |
| 58 | |
| 59 | public SwitchTypeNotSpecified(long dpid) { |
| 60 | super(); |
| 61 | log.error("Switch type not specified for switch-config dpid:{}", |
| 62 | HexString.toHexString(dpid)); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | public static class UnknownSwitchType extends RuntimeException { |
| 67 | private static final long serialVersionUID = 7758418165512249170L; |
| 68 | |
| 69 | public UnknownSwitchType(String type, String name) { |
| 70 | super(); |
| 71 | log.error("Unknown switch type {} for switch name:{}", type, name); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | public static class ParamsNotSpecified extends RuntimeException { |
| 76 | private static final long serialVersionUID = 6247582323691265513L; |
| 77 | |
| 78 | public ParamsNotSpecified(String name) { |
| 79 | super(); |
| 80 | log.error("Params required - not specified for switch:{}", name); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | public static class LinkTypeNotSpecified extends RuntimeException { |
| 85 | private static final long serialVersionUID = -2089470389588542215L; |
| 86 | |
| 87 | public LinkTypeNotSpecified(String dpid1, String dpid2) { |
| 88 | super(); |
| 89 | log.error("Link type not specified for link-config between " |
| 90 | + "dpid1:{} and dpid2:{}", dpid1, dpid2); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | public static class LinkDpidNotSpecified extends RuntimeException { |
| 95 | private static final long serialVersionUID = -5701825916378616004L; |
| 96 | |
| 97 | public LinkDpidNotSpecified(String dpid1, String dpid2) { |
| 98 | super(); |
| 99 | if (dpid1 == null) { |
| 100 | log.error("nodeDpid1 not specified for link-config "); |
| 101 | } |
| 102 | if (dpid2 == null) { |
| 103 | log.error("nodeDpid2 not specified for link-config "); |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | public static class LinkForUnknownSwitchConfig extends RuntimeException { |
| 109 | private static final long serialVersionUID = -2910458439881964094L; |
| 110 | |
| 111 | public LinkForUnknownSwitchConfig(String dpid) { |
| 112 | super(); |
| 113 | log.error("Link configuration was specified for a switch-dpid {} " |
| 114 | + "that has not been configured", dpid); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | public static class UnknownLinkType extends RuntimeException { |
| 119 | private static final long serialVersionUID = -5505376193106542305L; |
| 120 | |
| 121 | public UnknownLinkType(String linktype, String dpid1, String dpid2) { |
| 122 | super(); |
| 123 | log.error("unknown link type {} for links between dpid1:{} " |
| 124 | + "and dpid2:{}", linktype, dpid1, dpid2); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | public static class ErrorConfig extends RuntimeException { |
| 129 | private static final long serialVersionUID = -2827406314700193147L; |
| 130 | |
| 131 | public ErrorConfig(String errorMsg) { |
| 132 | super(); |
| 133 | log.error(errorMsg); |
| 134 | } |
| 135 | |
| 136 | } |
| 137 | |
| 138 | public static class SwitchDpidNotConverted extends RuntimeException { |
| 139 | private static final long serialVersionUID = 5640347104590170426L; |
| 140 | |
| 141 | public SwitchDpidNotConverted(String name) { |
| 142 | super(); |
| 143 | log.error("Switch dpid specified as a HexString {} does not match " |
| 144 | + "with long value", name); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | public static class LinkDpidNotConverted extends RuntimeException { |
| 149 | private static final long serialVersionUID = 2397245646094080774L; |
| 150 | |
| 151 | public LinkDpidNotConverted(String dpid1, String dpid2) { |
| 152 | log.error("Dpids expressed as HexStrings for links between dpid1:{} " |
| 153 | + "and dpid2:{} do not match with long values", dpid1, dpid2); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | |
| 158 | } |
| 159 | |