Esempio n. 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))
Esempio n. 2
0
    def list():  # pylint: disable=W0622
        """List servers"""
        servers = []
        for name in master.list_servers(context.GLOBAL.zk.conn):
            server = master.get_server(context.GLOBAL.zk.conn, name)
            server['name'] = name
            servers.append(server)

        cli.out(formatter(servers))