The widespread diffusion of Infrastructure-as-aService and cloud computing paradigms requires large-scale data centers with thousands of running nodes and high energy demands, thus causing relevant economical and environmental costs. In this perspective, the paper presents an energy-aware consolidation strategy based on predictive control, in which virtual machines are migrated among nodes to reduce the number of active units. To describe a general cloud infrastructure, a discrete-time dynamic model is presented together with constraints. The migration strategies of virtual machines are obtained by solving finite-horizon optimal control problems involving integer variables. To reduce the computational effort, approximate solutions are searched for via Monte Carlo optimization. Besides power savings, the proposed method allows one to reduce violations of the service level agreement and aggressive on/off cycles of nodes. To showcase the effectiveness of the proposed approach, preliminary simulation results are provided.