def main():
    if len(sys.argv) < 2:
        print usage_str
        return

    common_config.init(['--config-file', '/etc/neutron/neutron.conf'])
    db_driver_class = importutils.import_class(cfg.CONF.df.nb_db_class)
    db_driver = db_driver_class()
    db_driver.initialize(db_ip=cfg.CONF.df.remote_db_ip,
                         db_port=cfg.CONF.df.remote_db_port,
                         config=cfg.CONF.df)

    action = sys.argv[1]

    if action == 'ls':
        if len(sys.argv) == 2:
            print_tables()
            return
        table = sys.argv[2]
        if table not in db_tables:
            print "<table> must be one of the following:"
            print db_tables
            return
        print_table(db_driver, table)
        return

    if action == 'get':
        if len(sys.argv) < 4:
            print "must supply a key"
            print usage_str
            return
        table = sys.argv[2]
        if table not in db_tables:
            print "<table> must be one of the following:"
            print db_tables
            return
        key = sys.argv[3]
        print_key(db_driver, table, key)
        return

    if action == 'dump':
        for table in db_tables:
            print_whole_table(db_driver, table)
        return

    if action == 'bind':
        port_id = sys.argv[2]
        bind_port_to_localhost(db_driver, port_id)
        return

    if action == 'clean':
        for table in db_tables:
            clean_whole_table(db_driver, table)

    if action == 'rm':
        if len(sys.argv) < 4:
            print "must supply a key"
            print usage_str
            return
        table = sys.argv[2]
        if table not in db_tables:
            print "<table> must be one of the following: %s" % db_tables
            return
        key = sys.argv[3]
        remove_record(db_driver, table, key)
        return

    print usage_str
dataset/ETHPy150Open openstack/dragonflow/dragonflow/cli/df_db.py/main/original