def do_switch(self, cmd_input):
        args = cmd_input.split()
        if len(args) == 0:
            print "pleas input option"
            return False
        switch_name = args[0]
        sw_alias = self.controller_db["sw_alias"]
        if switch_name in sw_alias:
            dpid = sw_alias.get(switch_name)
        elif switch_name in sw_alias.values():
            dpid = switch_name
        else :
            print "switch not found"
            return False

        switch_console = S_ODLSwitch.S_ODLSwitch()
        switch_console.S_Start(self.ip, self.port, self.token, dpid)
        self.controller_db = odl_api.controller_db_init(self.ip, self.port, self.token)
    def S_Start(self, ip, port, token, dpid):
        self.ip = ip
        self.port = port
        self.token = token
        self.dpid = dpid
        self.init_call_back()
        
        # switch info print 
        switch_info = odl_api.get_switch(self.ip, self.port, self.token, self.dpid)
        odl_print.print_switch(switch_info)
        print odl_print.LINE

        # switch alias load
        controller_db = odl_api.controller_db_init(ip, port, token)
        sw_alias_db = controller_db["sw_alias"]
        self.alias = odl_api.find_alias_in_dpid(self.dpid, sw_alias_db)
        controller_db.clear()
        self.prompt = "Switch(" + self.alias + ") # "

        # console start
        self.cmdloop()
    def complete(self, text, state):
        """Return the next possible completion for 'text'.

        If a command has not been entered, then complete against command list.
        Otherwise try to call complete_<command> to get list of completions.
        """
        if state == 0:
            import readline
            origline = readline.get_line_buffer()
            line = origline.lstrip()
            stripped = len(origline) - len(line)
            begidx = readline.get_begidx() - stripped
            endidx = readline.get_endidx() - stripped
            if begidx>0:
                cmd, args, foo = self.parseline(line)
                
                if cmd == '':
                    compfunc = self.completedefault
                elif cmd == 'show':
                    compfunc = getattr(self, 'complete_show')
                    self.sub_command = self.show_options.keys()
                elif cmd == 'switch':
                    compfunc = getattr(self, 'complete_switch')
                    controller_db = odl_api.controller_db_init(self.ip, self.port, self.token)
                    self.sub_command = controller_db.get("sw_alias").keys()
                else:
                    try:
                        compfunc = getattr(self, 'complete_' + cmd)
                    except AttributeError:
                        #traceback.print_exc()
                        compfunc = self.completedefault

            else:
                compfunc = self.completenames
            self.completion_matches = compfunc(text, line, begidx, endidx)
        try:
            return self.completion_matches[state]
        except IndexError:
            return None
    def C_Start(self, ip, port): # init odl info
        self.ip = ip
        self.port = port
        self.username = raw_input( 'username : '******'password : ' )

        # odl_api login
        self.token = odl_api.login(
                                    self.ip,
                                    self.port,
                                    self.username,
                                    self.password
                                   )

        if self.token == None:
            return False

        self.controller_db = odl_api.controller_db_init(
                                                        self.ip, 
                                                        self.port, 
                                                        self.token
                                                       )
        self.init_call_back()
        self.cmdloop()