Example #1
0
 def __init__(self, version):
     super(ConfigCommand, self).__init__()
     self.version = version
     self.prompt = 'SDN Handmade ({:s})(config)# '.format(version)
     self.add_device_cmd = AddDeviceCommand()
     self.device_repository = repository.get("device")
     self.logbug = logbug.get()
class SDNCommand(cmd.Cmd):
    logbug = logbug.get()

    def __init__(self):
        super(SDNCommand, self).__init__()

    def do_exit(self, args):
        return True

    def emptyline(self):
        self.logbug.prompt = self.prompt

    def preloop(self):
        self.logbug.prompt = self.prompt
        self.logbug.is_wait_input = True

    def postcmd(self, stop, line):
        self.logbug.prompt = self.prompt
        self.logbug.is_wait_input = True
        return cmd.Cmd.postcmd(self, stop, line)

    def precmd(self, line):
        self.logbug.prompt = self.prompt
        self.logbug.is_wait_input = False
        return cmd.Cmd.precmd(self, line)

    def postloop(self):
        self.logbug.prompt = self.prompt
def main():
    """ Run SDN Controller Server
    """
    import time
    import logbug as lb
    from cli.cli_controller import CLIController
    import settings

    lb.init(logging.INFO)

    # Start CLI
    cli = CLIController(settings.app['version'])

    cli.cmdloop("Welcome to SDN Handmade. Type help to list commands.\n")

    lb.get().pre_shutdown()
    time.sleep(0.5)
    # topology.shutdown()
    # rest_server.shutdown()
    # time.sleep(0.5)
    lb.get().post_shutdown()
Example #4
0
def main():
    """ Run SDN Controller Server
    """
    import time
    import logbug as lb
    import sdn_handmade as sdn
    from cli.cli_controller import CLIController
    import settings

    import sys
    from pymongo import MongoClient

    lb.init(logging.INFO)

    # Create topology
    topology = sdn.Topology(
        netflow_ip=settings.netflow['bind_ip'],
        netflow_port=settings.netflow['bind_port']
    )

    # Start topology loop
    topology.run()

    # Start CLI
    cli = CLIController(settings.app['version'])
    # cli.init()

    cli.cmdloop("Welcome to SDN Handmade. Type help to list commands.\n")

    lb.get().pre_shutdown()
    time.sleep(0.5)
    topology.shutdown()
    time.sleep(0.5)
    lb.get().post_shutdown()

    sys.exit(MongoClient('localhost', 27017).drop_database('sdn01'))
Example #5
0
 def __init__(self):
     self.logbug = logbug.get()