def add_remote_varanus_collector( self, name, user, server, varanus_home, cid, **params ): """ Adds a remote VARANUS collector to the current topology and returns a RemoteCollectorConfig object representing it, or a NullNodeConfig if VARANUS usage is disabled. - name : a textual representation of the collector - user : the name of the user on the remote server - server : the IP address of the remote server - varanus_home: home directory of varanus project - cid : the collector identifier """ if self.enable_varanus: if self.built: raise RuntimeError( 'build() method was already called; cannot add any more collectors' ) name = as_str( name ) storage = self.hosts check_duplicate( storage, name ) c = self._new_remote_node( RemoteCollectorConfig, name, user, server, \ varanus_home=varanus_home, cid=cid, \ **params ) storage[ name ] = c info( newline( '=== Added remote VARANUS collector', c ) ) return c else: return self.add_null_host( name )
def add_port(self, portnum, name=None, is_virtual=None, **params): check_duplicate(self.ports, portnum) p = self._new_port(portnum, name=name, is_virtual=is_virtual, **params) self.ports[portnum] = p return p
def add_custom_remote_host( self, name, user, server, \ startcmd, stopcmd, morecmds=None, \ **params ): """ Adds a custom remote host to the current topology and returns a CustomRemoteHostConfig object representing it. - name : a textual representation of the host - user : the name of the user on the remote server - server : the IP address of the remote server - startcmd: a function used to start the host when called - stopcmd : a function used to stop the host when called - morecmds: additional optional commands to define in the Mininet node """ if self.built: raise RuntimeError( 'build() method was already called; cannot add any more hosts' ) name = as_str( name ) storage = self.hosts check_duplicate( storage, name ) h = self._new_remote_node( CustomRemoteHostConfig, name, user, server, \ startcmd=startcmd, stopcmd=stopcmd, morecmds=morecmds, \ **params ) storage[ name ] = h info( newline( '=== Added custom remote host', h ) ) return h
def add_null_switch( self, name, **params ): """ Adds a dummy non-existent switch to the current topology and returns a NullNodeConfig object representing it. - name: a textual representation of the switch """ if self.built: raise RuntimeError( 'build() method was already called; cannot add any more switches' ) name = as_str( name ) storage = self.switches check_duplicate( storage, name ) s = self._new_node( NullNodeConfig, name, **params ) storage[ name ] = s info( newline( '=== Added null switch', s ) ) return s
def add_local_host( self, name, **params ): """ Adds a new local host to the current topology and returns a LocalHostConfig object representing it. - name: a textual representation of the host """ if self.built: raise RuntimeError( 'build() method was already called; cannot add any more hosts' ) name = as_str( name ) storage = self.hosts check_duplicate( storage, name ) h = self._new_node( LocalHostConfig, name, **params ) storage[ name ] = h info( newline( '=== Added local host', h ) ) return h
def add_null_controller( self, name, **params ): """ Adds a dummy non-existent controller to the current topology and returns a NullControllerConfig object representing it. - name: a textual representation of the controller """ if self.built: raise RuntimeError( 'build() method was already called; cannot add any more controllers' ) name = as_str( name ) storage = self.controllers check_duplicate( storage, name ) c = self._new_node( NullControllerConfig, name, **params ) storage[ name ] = c info( newline( '=== Added null controller', c ) ) return c
def add_local_ovs_switch( self, name, **params ): """ Adds a new local OVS switch to the current topology and returns a LocalOVSSwitchConfig object representing it. - name: a textual representation of the switch """ if self.built: raise RuntimeError( 'build() method was already called; cannot add any more switches' ) name = as_str( name ) storage = self.switches check_duplicate( storage, name ) s = self._new_node( LocalOVSSwitchConfig, name, \ protocols=self.of_version, **params ) storage[ name ] = s info( newline( '=== Added local OVS switch', s ) ) return s
def add_remote_host( self, name, user, server, **params ): """ Adds a new remote host to the current topology and returns a RemoteHostConfig object representing it. - name : a textual representation of the host - user : the name of the user on the remote server - server: the IP address of the remote server """ if self.built: raise RuntimeError( 'build() method was already called; cannot add any more hosts' ) name = as_str( name ) storage = self.hosts check_duplicate( storage, name ) h = self._new_remote_node( RemoteHostConfig, name, user, server, **params ) storage[ name ] = h info( newline( '=== Added remote host', h ) ) return h
def add_pica8_switch( self, name, user, server, **params ): """ Adds a new pica8 switch (remote) to the current topology and returns a Pica8SwitchConfig object representing it. - name : a textual representation of the switch - user : the name of the user on the remote server - server: the IP address of the remote server """ if self.built: raise RuntimeError( 'build() method was already called; cannot add any more switches' ) name = as_str( name ) storage = self.switches check_duplicate( storage, name ) s = self._new_remote_node( Pica8SwitchConfig, name, user, server, \ protocols=self.of_version, \ **params ) storage[ name ] = s info( newline( '=== Added Pica8 switch', s ) ) return s
def add_custom_local_controller( self, name, startcmd, stopcmd, morecmds=None, \ **params ): """ Adds a custom local controller to the current topology and returns a CustomLocalControllerConfig object representing it. - name : a textual representation of the controller - startcmd: a function used to start the controller when called - stopcmd : a function used to stop the controller when called - morecmds: additional optional commands to define in the Mininet node """ if self.built: raise RuntimeError( 'build() method was already called; cannot add any more controllers' ) name = as_str( name ) storage = self.controllers check_duplicate( storage, name ) c = self._new_node( CustomLocalControllerConfig, name, \ startcmd=startcmd, stopcmd=stopcmd, morecmds=morecmds, \ **params ) storage[ name ] = c info( newline( '=== Added custom local controller', c ) ) return c
def add_local_varanus_sdncontroller( self, name, varanus_home, sudo=None, **params ): """ Adds a local VARANUS SDN controller to the current topology and returns a LocalSDNControllerConfig object representing it, or a NullControllerConfig if VARANUS usage is disabled. - name : a textual representation of the controller - varanus_home: home directory of varanus project """ if self.enable_varanus: if self.built: raise RuntimeError( 'build() method was already called; cannot add any more controllers' ) name = as_str( name ) storage = self.controllers check_duplicate( storage, name ) c = self._new_node( LocalSDNControllerConfig, name, \ varanus_home=varanus_home, sudo=sudo, \ **params ) storage[ name ] = c info( newline( '=== Added local VARANUS SDN controller', c ) ) return c else: return self.add_null_controller( name )