Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | # -*- Mode: python; py-indent-offset: 4; tab-width: 8; indent-tabs-mode: t; -*- |
| 3 | |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 4 | import copy |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 5 | import pprint |
| 6 | import os |
| 7 | import sys |
| 8 | import subprocess |
| 9 | import json |
| 10 | import argparse |
| 11 | import io |
| 12 | import time |
| 13 | |
| 14 | from flask import Flask, json, Response, render_template, make_response, request |
| 15 | |
| 16 | # |
| 17 | # curl http://127.0.0.1:8080/wm/topology/route/00:00:00:00:00:00:0a:01/1/00:00:00:00:00:00:0a:04/1/json |
| 18 | # |
| 19 | |
| 20 | ## Global Var ## |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 21 | ControllerIP = "127.0.0.1" |
| 22 | ControllerPort = 8080 |
| 23 | MonitoringEnabled = False |
Pavlin Radoslavov | b549f08 | 2013-03-29 04:28:27 -0700 | [diff] [blame] | 24 | MonitoringByOnos = False |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 25 | ReadFromFile = "" |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 26 | |
| 27 | DEBUG=0 |
| 28 | pp = pprint.PrettyPrinter(indent=4) |
| 29 | |
| 30 | app = Flask(__name__) |
| 31 | |
| 32 | ## Worker Functions ## |
| 33 | def log_error(txt): |
| 34 | print '%s' % (txt) |
| 35 | |
| 36 | def debug(txt): |
| 37 | if DEBUG: |
| 38 | print '%s' % (txt) |
| 39 | |
| 40 | # @app.route("/wm/topology/route/<srcdpid>/<srcport>/<destdpid>/<destport>/json") |
| 41 | # |
| 42 | # Sample output: |
| 43 | # {'dstPort': {'port': {'value': 0}, 'dpid': {'value': '00:00:00:00:00:00:00:02'}}, 'srcPort': {'port': {'value': 0}, 'dpid': {'value': '00:00:00:00:00:00:00:01'}}, 'flowEntries': [{'outPort': {'value': 1}, 'flowEntryErrorState': None, 'flowEntryMatch': None, 'flowEntryActions': None, 'inPort': {'value': 0}, 'flowEntryId': None, 'flowEntryUserState': 'FE_USER_UNKNOWN', 'dpid': {'value': '00:00:00:00:00:00:00:01'}, 'flowEntrySwitchState': 'FE_SWITCH_UNKNOWN'}, {'outPort': {'value': 0}, 'flowEntryErrorState': None, 'flowEntryMatch': None, 'flowEntryActions': None, 'inPort': {'value': 9}, 'flowEntryId': None, 'flowEntryUserState': 'FE_USER_UNKNOWN', 'dpid': {'value': '00:00:00:00:00:00:00:02'}, 'flowEntrySwitchState': 'FE_SWITCH_UNKNOWN'}]} |
| 44 | # |
| 45 | def shortest_path(v1, p1, v2, p2): |
| 46 | try: |
| 47 | command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (ControllerIP, ControllerPort, v1, p1, v2, p2) |
| 48 | debug("shortest_path %s" % command) |
Pavlin Radoslavov | eb2d5a2 | 2013-03-14 19:58:14 -0700 | [diff] [blame] | 49 | parsedResult = [] |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 50 | |
| 51 | result = os.popen(command).read() |
| 52 | debug("result %s" % result) |
| 53 | if len(result) == 0: |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 54 | log_error("No Path found from %s/%s to %s/%s" % (v1, p1, v2, p2)) |
| 55 | else: |
| 56 | parsedResult = json.loads(result) |
| 57 | debug("parsed %s" % parsedResult) |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 58 | |
| 59 | except: |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 60 | log_error("Controller IF has issue: No Path found from %s/%s to %s/%s" % (v1, p1, v2, p2)) |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 61 | |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 62 | return parsedResult |
| 63 | |
| 64 | def print_data_path(data_path): |
| 65 | if len(data_path) == 0: |
| 66 | return |
| 67 | |
| 68 | srcSwitch = data_path['srcPort']['dpid']['value']; |
| 69 | srcPort = data_path['srcPort']['port']['value']; |
| 70 | dstSwitch = data_path['dstPort']['dpid']['value']; |
| 71 | dstPort = data_path['dstPort']['port']['value']; |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 72 | |
| 73 | print "DataPath: (src = %s/%s dst = %s/%s)" % (srcSwitch, srcPort, dstSwitch, dstPort); |
| 74 | |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 75 | for f in data_path['flowEntries']: |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 76 | inPort = f['inPort']['value']; |
| 77 | outPort = f['outPort']['value']; |
| 78 | dpid = f['dpid']['value'] |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 79 | print " FlowEntry: (%s, %s, %s)" % (inPort, dpid, outPort) |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 80 | |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 81 | def add_flow_path(flow_path): |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 82 | flow_path_json = json.dumps(flow_path) |
| 83 | |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 84 | try: |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 85 | command = "curl -s -H 'Content-Type: application/json' -d '%s' http://%s:%s/wm/flow/add/json" % (flow_path_json, ControllerIP, ControllerPort) |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 86 | debug("add_flow_path %s" % command) |
| 87 | result = os.popen(command).read() |
| 88 | debug("result %s" % result) |
| 89 | # parsedResult = json.loads(result) |
| 90 | # debug("parsed %s" % parsedResult) |
| 91 | except: |
| 92 | log_error("Controller IF has issue") |
| 93 | exit(1) |
| 94 | |
Pavlin Radoslavov | b549f08 | 2013-03-29 04:28:27 -0700 | [diff] [blame] | 95 | def add_shortest_path_flow(flow_path): |
| 96 | flow_path_json = json.dumps(flow_path) |
| 97 | |
| 98 | try: |
| 99 | command = "curl -s -H 'Content-Type: application/json' -d '%s' http://%s:%s/wm/flow/add-shortest-path/json" % (flow_path_json, ControllerIP, ControllerPort) |
| 100 | debug("add_shortest_path_flow %s" % command) |
| 101 | result = os.popen(command).read() |
| 102 | debug("result %s" % result) |
| 103 | # parsedResult = json.loads(result) |
| 104 | # debug("parsed %s" % parsedResult) |
| 105 | except: |
| 106 | log_error("Controller IF has issue") |
| 107 | exit(1) |
| 108 | |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 109 | def delete_flow_path(flow_id): |
| 110 | command = "curl -s \"http://%s:%s/wm/flow/delete/%s/json\"" % (ControllerIP, ControllerPort, flow_id) |
| 111 | debug("delete_flow_path %s" % command) |
| 112 | result = os.popen(command).read() |
| 113 | debug("result %s" % result) |
| 114 | # parsedResult = json.loads(result) |
| 115 | # debug("parsed %s" % parsedResult) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 116 | |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 117 | def extract_flow_args(my_args): |
| 118 | # Check the arguments |
| 119 | if len(my_args) < 6: |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 120 | log_error(usage_msg) |
| 121 | exit(1) |
| 122 | |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 123 | # Extract the mandatory arguments |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 124 | my_flow_id = my_args[0] |
| 125 | my_installer_id = my_args[1] |
| 126 | my_src_dpid = my_args[2] |
| 127 | my_src_port = my_args[3] |
| 128 | my_dst_dpid = my_args[4] |
| 129 | my_dst_port = my_args[5] |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 130 | |
| 131 | # |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 132 | # Extract the "flowPathFlags", "match" and "action" arguments |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 133 | # |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 134 | flowPathFlags = 0L |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 135 | match = {} |
| 136 | matchInPortEnabled = True # NOTE: Enabled by default |
| 137 | actions = [] |
| 138 | actionOutputEnabled = True # NOTE: Enabled by default |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 139 | idx = 6 |
| 140 | while idx < len(my_args): |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 141 | action = {} |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 142 | arg1 = my_args[idx] |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 143 | idx = idx + 1 |
| 144 | # Extract the second argument |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 145 | if idx >= len(my_args): |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 146 | error_arg = "ERROR: Missing or invalid '" + arg1 + "' argument" |
| 147 | log_error(error_arg) |
| 148 | log_error(usage_msg) |
| 149 | exit(1) |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 150 | arg2 = my_args[idx] |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 151 | idx = idx + 1 |
| 152 | |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 153 | if arg1 == "flowPathFlags": |
| 154 | if "DISCARD_FIRST_HOP_ENTRY" in arg2: |
| 155 | flowPathFlags = flowPathFlags + 0x1 |
| 156 | if "KEEP_ONLY_FIRST_HOP_ENTRY" in arg2: |
| 157 | flowPathFlags = flowPathFlags + 0x2 |
| 158 | elif arg1 == "matchInPort": |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 159 | # Just mark whether inPort matching is enabled |
| 160 | matchInPortEnabled = arg2 in ['True', 'true'] |
| 161 | # inPort = {} |
Pavlin Radoslavov | 1474891 | 2013-03-12 15:44:56 -0700 | [diff] [blame] | 162 | # inPort['value'] = int(arg2, 0) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 163 | # match['inPort'] = inPort |
| 164 | ## match['matchInPort'] = True |
| 165 | elif arg1 == "matchSrcMac": |
| 166 | srcMac = {} |
| 167 | srcMac['value'] = arg2 |
| 168 | match['srcMac'] = srcMac |
| 169 | # match['matchSrcMac'] = True |
| 170 | elif arg1 == "matchDstMac": |
| 171 | dstMac = {} |
| 172 | dstMac['value'] = arg2 |
| 173 | match['dstMac'] = dstMac |
| 174 | # match['matchDstMac'] = True |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 175 | elif arg1 == "matchEthernetFrameType": |
| 176 | match['ethernetFrameType'] = int(arg2, 0) |
| 177 | # match['matchEthernetFrameType'] = True |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 178 | elif arg1 == "matchVlanId": |
Pavlin Radoslavov | 1474891 | 2013-03-12 15:44:56 -0700 | [diff] [blame] | 179 | match['vlanId'] = int(arg2, 0) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 180 | # match['matchVlanId'] = True |
| 181 | elif arg1 == "matchVlanPriority": |
Pavlin Radoslavov | 1474891 | 2013-03-12 15:44:56 -0700 | [diff] [blame] | 182 | match['vlanPriority'] = int(arg2, 0) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 183 | # match['matchVlanPriority'] = True |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 184 | elif arg1 == "matchSrcIPv4Net": |
| 185 | srcIPv4Net = {} |
| 186 | srcIPv4Net['value'] = arg2 |
| 187 | match['srcIPv4Net'] = srcIPv4Net |
| 188 | # match['matchSrcIPv4Net'] = True |
| 189 | elif arg1 == "matchDstIPv4Net": |
| 190 | dstIPv4Net = {} |
| 191 | dstIPv4Net['value'] = arg2 |
| 192 | match['dstIPv4Net'] = dstIPv4Net |
| 193 | # match['matchDstIPv4Net'] = True |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 194 | elif arg1 == "matchIpProto": |
| 195 | match['ipProto'] = int(arg2, 0) |
| 196 | # match['matchIpProto'] = True |
| 197 | elif arg1 == "matchIpToS": |
| 198 | match['ipToS'] = int(arg2, 0) |
| 199 | # match['matchIpToS'] = True |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 200 | elif arg1 == "matchSrcTcpUdpPort": |
Pavlin Radoslavov | 1474891 | 2013-03-12 15:44:56 -0700 | [diff] [blame] | 201 | match['srcTcpUdpPort'] = int(arg2, 0) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 202 | # match['matchSrcTcpUdpPort'] = True |
| 203 | elif arg1 == "matchDstTcpUdpPort": |
Pavlin Radoslavov | 1474891 | 2013-03-12 15:44:56 -0700 | [diff] [blame] | 204 | match['dstTcpUdpPort'] = int(arg2, 0) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 205 | # match['matchDstTcpUdpPort'] = True |
| 206 | elif arg1 == "actionOutput": |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 207 | # Mark whether ACTION_OUTPUT action is enabled |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 208 | actionOutputEnabled = arg2 in ['True', 'true'] |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 209 | # If ACTION_OUTPUT is explicitly enabled, add an entry with a fake |
| 210 | # port number. We need this entry to preserve the action ordering. |
| 211 | if actionOutputEnabled == True: |
| 212 | actionOutput = {} |
| 213 | outPort = {} |
| 214 | outPort['value'] = 0xffff |
| 215 | actionOutput['port'] = outPort |
| 216 | actionOutput['maxLen'] = 0 |
| 217 | action['actionOutput'] = actionOutput |
| 218 | # action['actionType'] = 'ACTION_OUTPUT' |
| 219 | actions.append(action) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 220 | # |
| 221 | elif arg1 == "actionSetVlanId": |
| 222 | vlanId = {} |
Pavlin Radoslavov | 1474891 | 2013-03-12 15:44:56 -0700 | [diff] [blame] | 223 | vlanId['vlanId'] = int(arg2, 0) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 224 | action['actionSetVlanId'] = vlanId |
| 225 | # action['actionType'] = 'ACTION_SET_VLAN_VID' |
| 226 | actions.append(copy.deepcopy(action)) |
| 227 | elif arg1 == "actionSetVlanPriority": |
| 228 | vlanPriority = {} |
Pavlin Radoslavov | 1474891 | 2013-03-12 15:44:56 -0700 | [diff] [blame] | 229 | vlanPriority['vlanPriority'] = int(arg2, 0) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 230 | action['actionSetVlanPriority'] = vlanPriority |
| 231 | # action['actionType'] = 'ACTION_SET_VLAN_PCP' |
| 232 | actions.append(copy.deepcopy(action)) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 233 | elif arg1 == "actionStripVlan": |
| 234 | stripVlan = {} |
| 235 | stripVlan['stripVlan'] = arg2 in ['True', 'true'] |
| 236 | action['actionStripVlan'] = stripVlan |
| 237 | # action['actionType'] = 'ACTION_STRIP_VLAN' |
| 238 | actions.append(copy.deepcopy(action)) |
| 239 | elif arg1 == "actionSetEthernetSrcAddr": |
| 240 | ethernetSrcAddr = {} |
| 241 | ethernetSrcAddr['value'] = arg2 |
| 242 | setEthernetSrcAddr = {} |
| 243 | setEthernetSrcAddr['addr'] = ethernetSrcAddr |
| 244 | action['actionSetEthernetSrcAddr'] = setEthernetSrcAddr |
| 245 | # action['actionType'] = 'ACTION_SET_DL_SRC' |
| 246 | actions.append(copy.deepcopy(action)) |
| 247 | elif arg1 == "actionSetEthernetDstAddr": |
| 248 | ethernetDstAddr = {} |
| 249 | ethernetDstAddr['value'] = arg2 |
| 250 | setEthernetDstAddr = {} |
| 251 | setEthernetDstAddr['addr'] = ethernetDstAddr |
| 252 | action['actionSetEthernetDstAddr'] = setEthernetDstAddr |
| 253 | # action['actionType'] = 'ACTION_SET_DL_DST' |
| 254 | actions.append(copy.deepcopy(action)) |
| 255 | elif arg1 == "actionSetIPv4SrcAddr": |
| 256 | IPv4SrcAddr = {} |
| 257 | IPv4SrcAddr['value'] = arg2 |
| 258 | setIPv4SrcAddr = {} |
| 259 | setIPv4SrcAddr['addr'] = IPv4SrcAddr |
| 260 | action['actionSetIPv4SrcAddr'] = setIPv4SrcAddr |
| 261 | # action['actionType'] = 'ACTION_SET_NW_SRC' |
| 262 | actions.append(copy.deepcopy(action)) |
| 263 | elif arg1 == "actionSetIPv4DstAddr": |
| 264 | IPv4DstAddr = {} |
| 265 | IPv4DstAddr['value'] = arg2 |
| 266 | setIPv4DstAddr = {} |
| 267 | setIPv4DstAddr['addr'] = IPv4DstAddr |
| 268 | action['actionSetIPv4DstAddr'] = setIPv4DstAddr |
| 269 | # action['actionType'] = 'ACTION_SET_NW_DST' |
| 270 | actions.append(copy.deepcopy(action)) |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 271 | elif arg1 == "actionSetIpToS": |
| 272 | ipToS = {} |
| 273 | ipToS['ipToS'] = int(arg2, 0) |
| 274 | action['actionSetIpToS'] = ipToS |
| 275 | # action['actionType'] = 'ACTION_SET_NW_TOS' |
| 276 | actions.append(copy.deepcopy(action)) |
| 277 | elif arg1 == "actionSetTcpUdpSrcPort": |
| 278 | tcpUdpSrcPort = {} |
| 279 | tcpUdpSrcPort['port'] = int(arg2, 0) |
| 280 | action['actionSetTcpUdpSrcPort'] = tcpUdpSrcPort |
| 281 | # action['actionType'] = 'ACTION_SET_TP_SRC' |
| 282 | actions.append(copy.deepcopy(action)) |
| 283 | elif arg1 == "actionSetTcpUdpDstPort": |
| 284 | tcpUdpDstPort = {} |
| 285 | tcpUdpDstPort['port'] = int(arg2, 0) |
| 286 | action['actionSetTcpUdpDstPort'] = tcpUdpDstPort |
| 287 | # action['actionType'] = 'ACTION_SET_TP_DST' |
| 288 | actions.append(copy.deepcopy(action)) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 289 | elif arg1 == "actionEnqueue": |
| 290 | # TODO: Implement ACTION_ENQUEUE |
| 291 | actionEnqueue = {} |
Pavlin Radoslavov | 1474891 | 2013-03-12 15:44:56 -0700 | [diff] [blame] | 292 | # actionEnqueue['queueId'] = int(arg2, 0) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 293 | # enqueuePort = {} |
Pavlin Radoslavov | 1474891 | 2013-03-12 15:44:56 -0700 | [diff] [blame] | 294 | # enqueuePort['value'] = int(arg3, 0) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 295 | # actionEnqueue['port'] = enqueuePort |
| 296 | # action['actionEnqueue'] = actionEnqueue |
| 297 | # # action['actionType'] = 'ACTION_ENQUEUE' |
| 298 | # actions.append(copy.deepcopy(action)) |
| 299 | # |
| 300 | else: |
| 301 | log_error("ERROR: Unknown argument '%s'" % (arg1)) |
| 302 | log_error(usage_msg) |
| 303 | exit(1) |
| 304 | |
Pavlin Radoslavov | 8a002d9 | 2013-03-13 20:20:43 -0700 | [diff] [blame] | 305 | return { |
| 306 | 'my_flow_id' : my_flow_id, |
| 307 | 'my_installer_id' : my_installer_id, |
| 308 | 'my_src_dpid' : my_src_dpid, |
| 309 | 'my_src_port' : my_src_port, |
| 310 | 'my_dst_dpid' : my_dst_dpid, |
| 311 | 'my_dst_port' : my_dst_port, |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 312 | 'flowPathFlags' : flowPathFlags, |
Pavlin Radoslavov | 8a002d9 | 2013-03-13 20:20:43 -0700 | [diff] [blame] | 313 | 'match' : match, |
| 314 | 'matchInPortEnabled' : matchInPortEnabled, |
| 315 | 'actions' : actions, |
| 316 | 'actionOutputEnabled' : actionOutputEnabled |
| 317 | } |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 318 | |
| 319 | def compute_data_path(parsed_args): |
| 320 | |
| 321 | my_src_dpid = parsed_args['my_src_dpid'] |
| 322 | my_src_port = parsed_args['my_src_port'] |
| 323 | my_dst_dpid = parsed_args['my_dst_dpid'] |
| 324 | my_dst_port = parsed_args['my_dst_port'] |
| 325 | |
| 326 | # Compute the shortest path |
| 327 | data_path = shortest_path(my_src_dpid, my_src_port, my_dst_dpid, my_dst_port) |
| 328 | |
| 329 | debug("Data Path: %s" % data_path) |
| 330 | return data_path |
| 331 | |
| 332 | def compute_flow_path(parsed_args, data_path): |
| 333 | |
| 334 | my_flow_id = parsed_args['my_flow_id'] |
| 335 | my_installer_id = parsed_args['my_installer_id'] |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 336 | myFlowPathFlags = parsed_args['flowPathFlags'] |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 337 | match = parsed_args['match'] |
| 338 | matchInPortEnabled = parsed_args['matchInPortEnabled'] |
| 339 | actions = parsed_args['actions'] |
| 340 | actionOutputEnabled = parsed_args['actionOutputEnabled'] |
| 341 | my_data_path = copy.deepcopy(data_path) |
| 342 | |
| 343 | flow_id = {} |
| 344 | flow_id['value'] = my_flow_id |
| 345 | installer_id = {} |
| 346 | installer_id['value'] = my_installer_id |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 347 | flowPathFlags = {} |
| 348 | flowPathFlags['flags'] = myFlowPathFlags |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 349 | |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 350 | flowEntryActions = {} |
| 351 | |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 352 | flow_path = {} |
| 353 | flow_path['flowId'] = flow_id |
| 354 | flow_path['installerId'] = installer_id |
Pavlin Radoslavov | d28cf7c | 2013-10-26 11:27:43 -0700 | [diff] [blame] | 355 | # NOTE: The 'flowPathType' might be rewritten later |
| 356 | flow_path['flowPathType'] = 'FP_TYPE_EXPLICIT_PATH' |
Pavlin Radoslavov | 7d4a40e | 2013-10-27 23:39:40 -0700 | [diff] [blame] | 357 | flow_path['flowPathUserState'] = 'FP_USER_ADD' |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 358 | flow_path['flowPathFlags'] = flowPathFlags |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 359 | |
Pavlin Radoslavov | 67b3ef3 | 2013-04-03 02:44:48 -0700 | [diff] [blame] | 360 | if (len(match) > 0): |
| 361 | flow_path['flowEntryMatch'] = copy.deepcopy(match) |
| 362 | |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 363 | # |
| 364 | # Add the match conditions to each flow entry |
| 365 | # |
| 366 | if (len(match) > 0) or matchInPortEnabled: |
| 367 | idx = 0 |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 368 | while idx < len(my_data_path['flowEntries']): |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 369 | if matchInPortEnabled: |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 370 | inPort = my_data_path['flowEntries'][idx]['inPort'] |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 371 | match['inPort'] = copy.deepcopy(inPort) |
| 372 | # match['matchInPort'] = True |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 373 | my_data_path['flowEntries'][idx]['flowEntryMatch'] = copy.deepcopy(match) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 374 | idx = idx + 1 |
| 375 | |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 376 | |
| 377 | if (len(actions) > 0): |
| 378 | flowEntryActions['actions'] = copy.deepcopy(actions) |
| 379 | flow_path['flowEntryActions'] = flowEntryActions |
| 380 | |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 381 | # |
| 382 | # Set the actions for each flow entry |
| 383 | # NOTE: The actions from the command line are aplied |
| 384 | # ONLY to the first flow entry. |
| 385 | # |
| 386 | # If ACTION_OUTPUT action is enabled, then apply it |
| 387 | # to each flow entry. |
| 388 | # |
| 389 | if (len(actions) > 0) or actionOutputEnabled: |
| 390 | idx = 0 |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 391 | while idx < len(my_data_path['flowEntries']): |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 392 | if idx > 0: |
| 393 | actions = [] # Reset the actions for all but first entry |
| 394 | action = {} |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 395 | outPort = my_data_path['flowEntries'][idx]['outPort'] |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 396 | actionOutput = {} |
| 397 | actionOutput['port'] = copy.deepcopy(outPort) |
| 398 | # actionOutput['maxLen'] = 0 # TODO: not used for now |
| 399 | action['actionOutput'] = copy.deepcopy(actionOutput) |
| 400 | # action['actionType'] = 'ACTION_OUTPUT' |
| 401 | actions.append(copy.deepcopy(action)) |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 402 | flowEntryActions = {} |
| 403 | flowEntryActions['actions'] = copy.deepcopy(actions) |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 404 | |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 405 | my_data_path['flowEntries'][idx]['flowEntryActions'] = flowEntryActions |
Pavlin Radoslavov | f13923a | 2013-03-11 19:42:17 -0700 | [diff] [blame] | 406 | idx = idx + 1 |
| 407 | |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 408 | flow_path['dataPath'] = my_data_path |
| 409 | debug("Flow Path: %s" % flow_path) |
Pavlin Radoslavov | b549f08 | 2013-03-29 04:28:27 -0700 | [diff] [blame] | 410 | return flow_path |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 411 | |
Pavlin Radoslavov | b549f08 | 2013-03-29 04:28:27 -0700 | [diff] [blame] | 412 | def exec_monitoring_by_onos(parsed_args): |
| 413 | idx = 0 |
| 414 | while idx < len(parsed_args): |
| 415 | data_path = {} |
| 416 | src_dpid = {} |
| 417 | src_port = {} |
| 418 | dst_dpid = {} |
| 419 | dst_port = {} |
| 420 | src_switch_port = {} |
| 421 | dst_switch_port = {} |
Pavlin Radoslavov | b549f08 | 2013-03-29 04:28:27 -0700 | [diff] [blame] | 422 | flow_entries = [] |
| 423 | |
| 424 | src_dpid['value'] = parsed_args[idx]['my_src_dpid'] |
| 425 | src_port['value'] = parsed_args[idx]['my_src_port'] |
| 426 | dst_dpid['value'] = parsed_args[idx]['my_dst_dpid'] |
| 427 | dst_port['value'] = parsed_args[idx]['my_dst_port'] |
| 428 | src_switch_port['dpid'] = src_dpid |
| 429 | src_switch_port['port'] = src_port |
| 430 | dst_switch_port['dpid'] = dst_dpid |
| 431 | dst_switch_port['port'] = dst_port |
Pavlin Radoslavov | b549f08 | 2013-03-29 04:28:27 -0700 | [diff] [blame] | 432 | |
| 433 | data_path['srcPort'] = copy.deepcopy(src_switch_port) |
| 434 | data_path['dstPort'] = copy.deepcopy(dst_switch_port) |
| 435 | data_path['flowEntries'] = copy.deepcopy(flow_entries) |
| 436 | |
| 437 | # |
| 438 | # XXX: Explicitly disable the InPort matching, and |
| 439 | # the Output action, because they get in the way |
| 440 | # during the compute_flow_path() processing. |
| 441 | # |
| 442 | parsed_args[idx]['matchInPortEnabled'] = False |
| 443 | parsed_args[idx]['actionOutputEnabled'] = False |
| 444 | |
| 445 | flow_path = compute_flow_path(parsed_args[idx], data_path) |
Pavlin Radoslavov | d28cf7c | 2013-10-26 11:27:43 -0700 | [diff] [blame] | 446 | flow_path['flowPathType'] = 'FP_TYPE_SHORTEST_PATH' |
| 447 | |
Pavlin Radoslavov | b549f08 | 2013-03-29 04:28:27 -0700 | [diff] [blame] | 448 | add_shortest_path_flow(flow_path) |
| 449 | |
| 450 | idx = idx + 1 |
| 451 | |
| 452 | |
| 453 | def exec_processing_by_script(parsed_args): |
| 454 | # |
| 455 | # Initialization |
| 456 | # |
| 457 | last_data_paths = [] |
| 458 | idx = 0 |
| 459 | while idx < len(parsed_args): |
| 460 | last_data_path = [] |
| 461 | last_data_paths.append(copy.deepcopy(last_data_path)) |
| 462 | idx = idx + 1 |
| 463 | |
| 464 | # |
| 465 | # Do the work: install and/or periodically monitor each flow |
| 466 | # |
| 467 | while True: |
| 468 | idx = 0 |
| 469 | while idx < len(parsed_args): |
| 470 | last_data_path = last_data_paths[idx] |
| 471 | my_flow_id = parsed_args[idx]['my_flow_id'] |
| 472 | data_path = compute_data_path(parsed_args[idx]) |
| 473 | if data_path != last_data_path: |
| 474 | print_data_path(data_path) |
| 475 | if len(last_data_path) > 0: |
| 476 | delete_flow_path(my_flow_id) |
| 477 | if len(data_path) > 0: |
| 478 | flow_path = compute_flow_path(parsed_args[idx], data_path) |
| 479 | add_flow_path(flow_path) |
| 480 | last_data_paths[idx] = copy.deepcopy(data_path) |
| 481 | idx = idx + 1 |
| 482 | |
| 483 | if MonitoringEnabled != True: |
| 484 | break |
| 485 | time.sleep(1) |
Pavlin Radoslavov | f4ad989 | 2013-03-04 14:15:19 -0800 | [diff] [blame] | 486 | |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 487 | |
| 488 | if __name__ == "__main__": |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 489 | usage_msg = "Usage: %s [Flags] <flow-id> <installer-id> <src-dpid> <src-port> <dest-dpid> <dest-port> [Flow Path Flags] [Match Conditions] [Actions]\n" % (sys.argv[0]) |
Pavlin Radoslavov | 7be3bac | 2013-03-27 09:59:34 -0700 | [diff] [blame] | 490 | usage_msg = usage_msg + "\n" |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 491 | usage_msg = usage_msg + " Flags:\n" |
Pavlin Radoslavov | b549f08 | 2013-03-29 04:28:27 -0700 | [diff] [blame] | 492 | usage_msg = usage_msg + " -m [monitorname] Monitor and maintain the installed shortest path(s)\n" |
| 493 | usage_msg = usage_msg + " If 'monitorname' is specified and is set to 'ONOS'\n" |
| 494 | usage_msg = usage_msg + " ((case insensitive), then the flow generation and\n" |
| 495 | usage_msg = usage_msg + " maintanenance is done by ONOS itself.\n" |
| 496 | usage_msg = usage_msg + " Otherwise, it is done by this script.\n" |
| 497 | usage_msg = usage_msg + " -f <filename> Read the flow(s) to install from a file\n" |
| 498 | usage_msg = usage_msg + " File format: one line per flow starting with <flow-id>\n" |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 499 | usage_msg = usage_msg + "\n" |
Pavlin Radoslavov | 204b286 | 2013-07-12 14:15:36 -0700 | [diff] [blame] | 500 | usage_msg = usage_msg + " Flow Path Flags:\n" |
| 501 | usage_msg = usage_msg + " flowPathFlags <Flags> (flag names separated by ',')\n" |
| 502 | usage_msg = usage_msg + "\n" |
| 503 | usage_msg = usage_msg + " Known flags:\n" |
| 504 | usage_msg = usage_msg + " DISCARD_FIRST_HOP_ENTRY : Discard the first-hop flow entry\n" |
| 505 | usage_msg = usage_msg + " KEEP_ONLY_FIRST_HOP_ENTRY : Keep only the first-hop flow entry\n" |
| 506 | usage_msg = usage_msg + "\n" |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 507 | usage_msg = usage_msg + " Match Conditions:\n" |
| 508 | usage_msg = usage_msg + " matchInPort <True|False> (default to True)\n" |
| 509 | usage_msg = usage_msg + " matchSrcMac <source MAC address>\n" |
| 510 | usage_msg = usage_msg + " matchDstMac <destination MAC address>\n" |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 511 | usage_msg = usage_msg + " matchEthernetFrameType <Ethernet frame type>\n" |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 512 | usage_msg = usage_msg + " matchVlanId <VLAN ID>\n" |
| 513 | usage_msg = usage_msg + " matchVlanPriority <VLAN priority>\n" |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 514 | usage_msg = usage_msg + " matchSrcIPv4Net <source IPv4 network address>\n" |
| 515 | usage_msg = usage_msg + " matchDstIPv4Net <destination IPv4 network address>\n" |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 516 | usage_msg = usage_msg + " matchIpProto <IP protocol>\n" |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 517 | usage_msg = usage_msg + " matchIpToS <IP ToS (DSCP field, 6 bits)>\n" |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 518 | usage_msg = usage_msg + " matchSrcTcpUdpPort <source TCP/UDP port>\n" |
| 519 | usage_msg = usage_msg + " matchDstTcpUdpPort <destination TCP/UDP port>\n" |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 520 | usage_msg = usage_msg + "\n" |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 521 | usage_msg = usage_msg + " Actions:\n" |
| 522 | usage_msg = usage_msg + " actionOutput <True|False> (default to True)\n" |
Pavlin Radoslavov | c1bafd1 | 2013-07-12 17:00:35 -0700 | [diff] [blame] | 523 | usage_msg = usage_msg + " actionSetVlanId <VLAN ID>\n" |
| 524 | usage_msg = usage_msg + " actionSetVlanPriority <VLAN priority>\n" |
| 525 | usage_msg = usage_msg + " actionStripVlan <True|False>\n" |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 526 | usage_msg = usage_msg + " actionSetEthernetSrcAddr <source MAC address>\n" |
| 527 | usage_msg = usage_msg + " actionSetEthernetDstAddr <destination MAC address>\n" |
| 528 | usage_msg = usage_msg + " actionSetIPv4SrcAddr <source IPv4 address>\n" |
| 529 | usage_msg = usage_msg + " actionSetIPv4DstAddr <destination IPv4 address>\n" |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 530 | usage_msg = usage_msg + " actionSetIpToS <IP ToS (DSCP field, 6 bits)>\n" |
| 531 | usage_msg = usage_msg + " actionSetTcpUdpSrcPort <source TCP/UDP port>\n" |
| 532 | usage_msg = usage_msg + " actionSetTcpUdpDstPort <destination TCP/UDP port>\n" |
Pavlin Radoslavov | 1bc2c47 | 2013-07-17 18:11:37 -0700 | [diff] [blame] | 533 | usage_msg = usage_msg + " Actions (not implemented yet):\n" |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 534 | usage_msg = usage_msg + " actionEnqueue <dummy argument>\n" |
| 535 | |
| 536 | # app.debug = False; |
| 537 | |
| 538 | # Usage info |
| 539 | if len(sys.argv) > 1 and (sys.argv[1] == "-h" or sys.argv[1] == "--help"): |
| 540 | print(usage_msg) |
| 541 | exit(0) |
| 542 | |
| 543 | # |
| 544 | # Check the flags |
| 545 | # |
| 546 | start_argv_index = 1 |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 547 | idx = 1 |
| 548 | while idx < len(sys.argv): |
| 549 | arg1 = sys.argv[idx] |
| 550 | idx = idx + 1 |
| 551 | if arg1 == "-m": |
| 552 | MonitoringEnabled = True |
Pavlin Radoslavov | b549f08 | 2013-03-29 04:28:27 -0700 | [diff] [blame] | 553 | if idx < len(sys.argv): |
| 554 | arg2 = sys.argv[idx] |
| 555 | if arg2.lower() == "onos": |
| 556 | MonitoringByOnos = True |
| 557 | idx = idx + 1 |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 558 | start_argv_index = idx |
| 559 | elif arg1 == "-f": |
| 560 | if idx >= len(sys.argv): |
| 561 | error_arg = "ERROR: Missing or invalid '" + arg1 + "' argument" |
| 562 | log_error(error_arg) |
| 563 | log_error(usage_msg) |
| 564 | exit(1) |
| 565 | ReadFromFile = sys.argv[idx] |
| 566 | idx = idx + 1 |
| 567 | start_argv_index = idx |
| 568 | else: |
| 569 | break; |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 570 | |
| 571 | # |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 572 | # Read the arguments from a file or from the remaining command line options |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 573 | # |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 574 | my_lines = [] |
| 575 | if len(ReadFromFile) > 0: |
| 576 | f = open(ReadFromFile, "rt") |
| 577 | my_line = f.readline() |
| 578 | while my_line: |
| 579 | if len(my_line.rstrip()) > 0 and my_line[0] != "#": |
| 580 | my_token_line = my_line.rstrip().split() |
| 581 | my_lines.append(my_token_line) |
| 582 | my_line = f.readline() |
| 583 | else: |
| 584 | my_lines.append(copy.deepcopy(sys.argv[start_argv_index:])) |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 585 | |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 586 | # |
| 587 | # Initialization |
| 588 | # |
| 589 | last_data_paths = [] |
| 590 | parsed_args = [] |
| 591 | idx = 0 |
| 592 | while idx < len(my_lines): |
| 593 | last_data_path = [] |
| 594 | last_data_paths.append(copy.deepcopy(last_data_path)) |
| 595 | # |
| 596 | # Parse the flow arguments |
| 597 | # |
| 598 | my_args = my_lines[idx] |
| 599 | parsed_args.append(copy.deepcopy(extract_flow_args(my_args))) |
| 600 | # Cleanup leftover state |
| 601 | my_flow_id = parsed_args[idx]['my_flow_id'] |
| 602 | delete_flow_path(my_flow_id) |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 603 | |
Pavlin Radoslavov | 2a0bd8b | 2013-03-15 18:45:51 -0700 | [diff] [blame] | 604 | idx = idx + 1 |
| 605 | |
| 606 | # |
Pavlin Radoslavov | b549f08 | 2013-03-29 04:28:27 -0700 | [diff] [blame] | 607 | if MonitoringByOnos == True: |
| 608 | exec_monitoring_by_onos(parsed_args) |
| 609 | else: |
| 610 | exec_processing_by_script(parsed_args) |
Pavlin Radoslavov | 3f3778a | 2013-03-13 08:16:57 -0700 | [diff] [blame] | 611 | |