Jonathan Hart | 8f6dc09 | 2014-04-18 15:56:43 -0700 | [diff] [blame] | 1 | package net.onrc.onos.apps.sdnip; |
Jonathan Hart | 1236a9b | 2013-06-18 22:10:05 +1200 | [diff] [blame] | 2 | |
Jonathan Hart | 4dfc365 | 2013-08-02 20:22:36 +1200 | [diff] [blame] | 3 | import java.util.Collections; |
Jonathan Hart | 1236a9b | 2013-06-18 22:10:05 +1200 | [diff] [blame] | 4 | import java.util.List; |
Jonathan Hart | 1236a9b | 2013-06-18 22:10:05 +1200 | [diff] [blame] | 5 | |
Jonathan Hart | 2f790d2 | 2013-08-15 14:01:24 +1200 | [diff] [blame] | 6 | import net.floodlightcontroller.util.MACAddress; |
| 7 | |
Jonathan Hart | 1236a9b | 2013-06-18 22:10:05 +1200 | [diff] [blame] | 8 | import org.codehaus.jackson.annotate.JsonProperty; |
Jonathan Hart | c78b8f6 | 2014-08-07 22:31:09 -0700 | [diff] [blame] | 9 | import org.projectfloodlight.openflow.util.HexString; |
Jonathan Hart | 1236a9b | 2013-06-18 22:10:05 +1200 | [diff] [blame] | 10 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 11 | /** |
| 12 | * Contains the configuration data for SDN-IP that has been read from a |
| 13 | * JSON-formatted configuration file. |
| 14 | */ |
Jonathan Hart | 1236a9b | 2013-06-18 22:10:05 +1200 | [diff] [blame] | 15 | public class Configuration { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 16 | private long bgpdAttachmentDpid; |
| 17 | private short bgpdAttachmentPort; |
| 18 | private MACAddress bgpdMacAddress; |
| 19 | private short vlan; |
| 20 | private List<String> switches; |
| 21 | private List<Interface> interfaces; |
| 22 | private List<BgpPeer> peers; |
Jonathan Hart | 1236a9b | 2013-06-18 22:10:05 +1200 | [diff] [blame] | 23 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Default constructor. |
| 26 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 27 | public Configuration() { |
| 28 | // TODO Auto-generated constructor stub |
| 29 | } |
Jonathan Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 30 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 31 | /** |
| 32 | * Gets the switch that BGPd is attached to. |
| 33 | * |
| 34 | * @return the dpid of BGPd's attachment point |
| 35 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 36 | public long getBgpdAttachmentDpid() { |
| 37 | return bgpdAttachmentDpid; |
| 38 | } |
Jonathan Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 39 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 40 | /** |
| 41 | * Sets the switch that BGPd is attached to. |
| 42 | * |
| 43 | * @param bgpdAttachmentDpid the dpid of BGPd's attachment point |
| 44 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 45 | @JsonProperty("bgpdAttachmentDpid") |
| 46 | public void setBgpdAttachmentDpid(String bgpdAttachmentDpid) { |
| 47 | this.bgpdAttachmentDpid = HexString.toLong(bgpdAttachmentDpid); |
| 48 | } |
Jonathan Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 49 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 50 | /** |
| 51 | * Gets the port that BGPd is attached to. |
| 52 | * |
| 53 | * @return the port number on the switch where BGPd is attached |
| 54 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 55 | public short getBgpdAttachmentPort() { |
| 56 | return bgpdAttachmentPort; |
| 57 | } |
Jonathan Hart | 2f790d2 | 2013-08-15 14:01:24 +1200 | [diff] [blame] | 58 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 59 | /** |
| 60 | * Sets the port that BGPd is attached to. |
| 61 | * |
| 62 | * @param bgpdAttachmentPort the port number on the switch where BGPd is |
| 63 | * attached |
| 64 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 65 | @JsonProperty("bgpdAttachmentPort") |
| 66 | public void setBgpdAttachmentPort(short bgpdAttachmentPort) { |
| 67 | this.bgpdAttachmentPort = bgpdAttachmentPort; |
| 68 | } |
Jonathan Hart | 1236a9b | 2013-06-18 22:10:05 +1200 | [diff] [blame] | 69 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 70 | /** |
| 71 | * Gets the MAC address of the BGPd host interface. |
| 72 | * |
| 73 | * @return the MAC address |
| 74 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 75 | public MACAddress getBgpdMacAddress() { |
| 76 | return bgpdMacAddress; |
| 77 | } |
Jonathan Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 78 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 79 | /** |
| 80 | * Sets the MAC address of the BGPd host interface. |
| 81 | * |
| 82 | * @param strMacAddress the MAC address |
| 83 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 84 | @JsonProperty("bgpdMacAddress") |
| 85 | public void setBgpdMacAddress(String strMacAddress) { |
| 86 | this.bgpdMacAddress = MACAddress.valueOf(strMacAddress); |
| 87 | } |
Jonathan Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 88 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 89 | /** |
| 90 | * Gets a list of the DPIDs of all switches in the system. The DPIDs are |
| 91 | * in String format represented in hexadecimal. |
| 92 | * |
| 93 | * @return the list of DPIDs |
| 94 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 95 | public List<String> getSwitches() { |
| 96 | return Collections.unmodifiableList(switches); |
| 97 | } |
| 98 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 99 | /** |
| 100 | * Sets a list of DPIDs of all switches in the system. |
| 101 | * |
| 102 | * @param switches the list of DPIDs |
| 103 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 104 | @JsonProperty("switches") |
| 105 | public void setSwitches(List<String> switches) { |
| 106 | this.switches = switches; |
| 107 | } |
| 108 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 109 | /** |
| 110 | * Gets the VLAN number of the VLAN the system is running in, if any. |
| 111 | * 0 means we are not running in a VLAN. |
| 112 | * |
| 113 | * @return the VLAN number if we are running in a VLAN, otherwise 0 |
| 114 | */ |
| 115 | public short getVlan() { |
| 116 | return vlan; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Sets the VLAN number of the VLAN the system is running in. |
| 121 | * |
| 122 | * @param vlan the VLAN number |
| 123 | */ |
| 124 | @JsonProperty("vlan") |
| 125 | public void setVlan(short vlan) { |
| 126 | this.vlan = vlan; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Gets a list of interfaces in the system, represented by |
| 131 | * {@link Interface} objects. |
| 132 | * |
| 133 | * @return the list of interfaces |
| 134 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 135 | public List<Interface> getInterfaces() { |
| 136 | return Collections.unmodifiableList(interfaces); |
| 137 | } |
| 138 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 139 | /** |
| 140 | * Sets a list of interfaces in the system. |
| 141 | * |
| 142 | * @param interfaces the list of interfaces |
| 143 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 144 | @JsonProperty("interfaces") |
| 145 | public void setInterfaces(List<Interface> interfaces) { |
| 146 | this.interfaces = interfaces; |
| 147 | } |
| 148 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 149 | /** |
| 150 | * Gets a list of BGP peers we are configured to peer with. Peers are |
| 151 | * represented by {@link BgpPeer} objects. |
| 152 | * |
| 153 | * @return the list of BGP peers |
| 154 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 155 | public List<BgpPeer> getPeers() { |
| 156 | return Collections.unmodifiableList(peers); |
| 157 | } |
| 158 | |
Jonathan Hart | 31e15f1 | 2014-04-10 10:33:00 -0700 | [diff] [blame] | 159 | /** |
| 160 | * Sets a list of BGP peers we are configured to peer with. |
| 161 | * |
| 162 | * @param peers the list of BGP peers |
| 163 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 164 | @JsonProperty("bgpPeers") |
| 165 | public void setPeers(List<BgpPeer> peers) { |
| 166 | this.peers = peers; |
| 167 | } |
Jonathan Hart | 832a7cb | 2013-06-24 11:25:35 +1200 | [diff] [blame] | 168 | |
Jonathan Hart | 1236a9b | 2013-06-18 22:10:05 +1200 | [diff] [blame] | 169 | } |