Parse command-line args and return options object. returns: opts parse options dict
( self )
| 3175 | ### BELOW HERE IS THE TOPOLOGY IMPORT CODE ### |
| 3176 | |
| 3177 | def parseArgs( self ): |
| 3178 | """Parse command-line args and return options object. |
| 3179 | returns: opts parse options dict""" |
| 3180 | |
| 3181 | if '--custom' in sys.argv: |
| 3182 | index = sys.argv.index( '--custom' ) |
| 3183 | if len( sys.argv ) > index + 1: |
| 3184 | filename = sys.argv[ index + 1 ] |
| 3185 | self.parseCustomFile( filename ) |
| 3186 | else: |
| 3187 | raise Exception( 'Custom file name not found' ) |
| 3188 | |
| 3189 | desc = ( "The %prog utility creates Mininet network from the\n" |
| 3190 | "command line. It can create parametrized topologies,\n" |
| 3191 | "invoke the Mininet CLI, and run tests." ) |
| 3192 | |
| 3193 | usage = ( '%prog [options]\n' |
| 3194 | '(type %prog -h for details)' ) |
| 3195 | |
| 3196 | opts = OptionParser( description=desc, usage=usage ) |
| 3197 | |
| 3198 | addDictOption( opts, TOPOS, TOPODEF, 'topo' ) |
| 3199 | addDictOption( opts, LINKS, LINKDEF, 'link' ) |
| 3200 | |
| 3201 | opts.add_option( '--custom', type='string', default=None, |
| 3202 | help='read custom topo and node params from .py ' + |
| 3203 | 'file' ) |
| 3204 | |
| 3205 | self.options, self.args = opts.parse_args() |
| 3206 | # We don't accept extra arguments after the options |
| 3207 | if self.args: |
| 3208 | opts.print_help() |
| 3209 | exit() |
| 3210 | |
| 3211 | def setCustom( self, name, value ): |
| 3212 | "Set custom parameters for MininetRunner." |
no test coverage detected