def list_nodes(args):
    m = Maintenence(args.config_host, args.config_port, args.config_ssl)
    nodes = m.config.get_nodes({})
    for node in nodes:
        del (node["_id"])
        print dumps(node)
    return
def add_index(args):
    m = Maintenence(args.config_host, args.config_port, args.config_ssl)
    fields = loads(args.fields)
    m.config.add_index(
        db_type=args.db_type,
        fields=fields,
        background=bool(strtobool(args.background)),  #bool
        unique=bool(strtobool(args.unique)),
        sparse=bool(strtobool(args.sparse)),
        text=bool(strtobool(args.text)))
    if bool(strtobool(args.rebuild)):
        build_index(args)
    return
def add_node(args):
    m = Maintenence(args.config_host, args.config_port, args.config_ssl)
    m.config.add_node(uid=args.uid,
                      name=args.name,
                      db_type=args.db_type,
                      db_tags=loads(args.db_tags),
                      capability=args.capability,
                      host=args.host,
                      port=args.port,
                      max_size=args.max_size,
                      ssl=bool(strtobool(args.ssl)),
                      passwd_file=args.passwd_file)
    return
def remove_index():
    m = Maintenence(args.config_host, args.config_port, args.config_ssl)
    fields = loads(args.fields)
    m.remove_index(args.db_type, fields)
    return
def build_index(args):
    m = Maintenence(args.config_host, args.config_port, args.config_ssl)
    m.ensure_indexes(args.collection,
                     m.config.get_indexes(args.db_type),
                     db_type=args.db_type)
    return
def set_db_tags(args):
    m = Maintenence(args.config_host, args.config_port, args.config_ssl)
    tags = loads(args.db_tags)
    m.config.set_node_tags(args.uid, tags)
    return
def remove_node(args):
    m = Maintenence(args.config_host, args.config_port, args.config_ssl)
    m.config.remove_node(args.db_type, args.uid)
    return
Esempio n. 8
0
                      action="store",
                      dest="servername",
                      help="[REQUIRED] 'localhost' or 'mongodb.host.com'")
    parser.add_option("-p", "--port",
                      action="store",
                      type="int",
                      dest="port",
                      help="[REQUIRED] integer 27017 or other")
    parser.add_option("-c", "--collection",
                      action="store",
                      dest="collection",
                      help="[REQUIRED] collection name for indexes")
    parser.add_option("-t", "--type",
                      action="store",
                      dest="db_type",
                      help="[REQUIRED] database type")
    parser.add_option('--ssl',
                      dest='ssl',
                      action='store_true',
                      help="[optional] if the mongod requres ssl")
    parser.set_defaults(ssl=False)
    (options, args) = parser.parse_args()
    
    
    maint = Maintenence(config_host=options.servername, config_port=options.port, config_ssl=options.ssl)
    need, data_size = maint.need_to_rotate(db_type=options.db_type)
    if need:
        maint.clean_incoming(db_type=options.db_type)
        maint.ensure_indexes(options.collection, maint.config.get_indexes(options.db_type), db_type=options.db_type)
        maint.rotate_schedule(db_type=options.db_type)
Esempio n. 9
0
def remove_index():
    m = Maintenence(args.config_host, args.config_port, args.config_ssl)
    fields = loads(args.fields)
    m.remove_index(args.db_type,
                   fields)
    return
Esempio n. 10
0
def build_index(args):
    m = Maintenence(args.config_host, args.config_port, args.config_ssl)
    m.ensure_indexes(args.collection, 
                     m.config.get_indexes(args.db_type), 
                     db_type=args.db_type)
    return