|
@@ 173-189 (lines=17) @@
|
| 170 |
|
|
| 171 |
|
return jsonify("Operation successful"), 201 |
| 172 |
|
|
| 173 |
|
@rest('v3/interfaces/<interface_id>/disable', methods=['POST']) |
| 174 |
|
def disable_interface(self, interface_id): |
| 175 |
|
"""Administratively disable an interface in the topology.""" |
| 176 |
|
switch_id = ":".join(interface_id.split(":")[:-1]) |
| 177 |
|
interface_number = int(interface_id.split(":")[-1]) |
| 178 |
|
|
| 179 |
|
try: |
| 180 |
|
switch = self.controller.switches[switch_id] |
| 181 |
|
except KeyError: |
| 182 |
|
return jsonify("Switch not found"), 404 |
| 183 |
|
|
| 184 |
|
try: |
| 185 |
|
switch.interfaces[interface_number].disable() |
| 186 |
|
except KeyError: |
| 187 |
|
return jsonify("Interface not found"), 404 |
| 188 |
|
|
| 189 |
|
return jsonify("Operation successful"), 201 |
| 190 |
|
|
| 191 |
|
@rest('v3/interfaces/<interface_id>/metadata') |
| 192 |
|
def get_interface_metadata(self, interface_id): |
|
@@ 155-171 (lines=17) @@
|
| 152 |
|
|
| 153 |
|
return jsonify({'interfaces': interfaces}) |
| 154 |
|
|
| 155 |
|
@rest('v3/interfaces/<interface_id>/enable', methods=['POST']) |
| 156 |
|
def enable_interface(self, interface_id): |
| 157 |
|
"""Administratively enable an interface in the topology.""" |
| 158 |
|
switch_id = ":".join(interface_id.split(":")[:-1]) |
| 159 |
|
interface_number = int(interface_id.split(":")[-1]) |
| 160 |
|
|
| 161 |
|
try: |
| 162 |
|
switch = self.controller.switches[switch_id] |
| 163 |
|
except KeyError: |
| 164 |
|
return jsonify("Switch not found"), 404 |
| 165 |
|
|
| 166 |
|
try: |
| 167 |
|
switch.interfaces[interface_number].enable() |
| 168 |
|
except KeyError: |
| 169 |
|
return jsonify("Interface not found"), 404 |
| 170 |
|
|
| 171 |
|
return jsonify("Operation successful"), 201 |
| 172 |
|
|
| 173 |
|
@rest('v3/interfaces/<interface_id>/disable', methods=['POST']) |
| 174 |
|
def disable_interface(self, interface_id): |