Add switch. name: name of switch to add cls: custom switch class/constructor (optional) returns: added switch side effect: increments listenPort ivar .
( self, name, cls=None, **params )
| 253 | self.delNode( host, nodes=self.hosts ) |
| 254 | |
| 255 | def addSwitch( self, name, cls=None, **params ): |
| 256 | """Add switch. |
| 257 | name: name of switch to add |
| 258 | cls: custom switch class/constructor (optional) |
| 259 | returns: added switch |
| 260 | side effect: increments listenPort ivar .""" |
| 261 | defaults = { 'listenPort': self.listenPort, |
| 262 | 'inNamespace': self.inNamespace } |
| 263 | defaults.update( params ) |
| 264 | if not cls: |
| 265 | cls = self.switch |
| 266 | sw = cls( name, **defaults ) |
| 267 | if not self.inNamespace and self.listenPort: |
| 268 | self.listenPort += 1 |
| 269 | self.switches.append( sw ) |
| 270 | self.nameToNode[ name ] = sw |
| 271 | return sw |
| 272 | |
| 273 | def delSwitch( self, switch ): |
| 274 | "Delete a switch" |