Exemple #1
0
    def configure(server, features, parent, memory, cpu, disk):
        """Create, get or modify server configuration"""
        if parent:
            path = parent.split('/')
            bucket = None
            for bucket, parent in zip(path, [None] + path[:-1]):
                master.create_bucket(context.GLOBAL.zk.conn, bucket, parent)
            assert bucket is not None, 'server topology missing.'

            master.create_server(context.GLOBAL.zk.conn, server, bucket)

        features = cli.combine(features)
        if features:
            # This is special case - reset features to empty.
            if features == ['-']:
                features = []

            master.update_server_features(context.GLOBAL.zk.conn, server,
                                          features)

        if memory or cpu or disk:
            master.update_server_capacity(context.GLOBAL.zk.conn,
                                          server,
                                          memory=memory,
                                          cpu=cpu,
                                          disk=disk)

        server_obj = master.get_server(context.GLOBAL.zk.conn, server)
        server_obj['name'] = server

        cli.out(formatter(server_obj))
Exemple #2
0
def sync_servers():
    """Sync servers and buckets."""
    admin_srv = admin.Server(context.GLOBAL.ldap.conn)
    servers = admin_srv.list({'cell': context.GLOBAL.cell})

    for server in servers:
        servername = server['_id']

        rack = 'rack:unknown'
        building = 'building:unknown'

        traits = []
        label = None

        master.create_bucket(context.GLOBAL.zk.conn, building, None)
        master.cell_insert_bucket(context.GLOBAL.zk.conn, building)
        master.create_bucket(context.GLOBAL.zk.conn, rack, building)
        master.create_server(context.GLOBAL.zk.conn, servername, rack)
        master.update_server_attrs(context.GLOBAL.zk.conn,
                                   servername,
                                   traits=traits,
                                   label=label)