'Add switch.
name: name of switch to add
cls: custom switch class/constructor (optional)
returns: added switch
side effect: increments listenPort ivar .'

def addSwitch(self, name, cls=None, **params):

    defaults = {'listenPort': self.listenPort, 'inNamespace': self.inNamespace}
    defaults.update(params)
    if (not cls):
        cls = self.switch
    sw = cls(name, **defaults)
    if ((not self.inNamespace) and self.listenPort):
        self.listenPort += 1
    self.switches.append(sw)
    self.nameToNode[name] = sw
    return sw
