5G network nodes, fronthaul and backhaul alike, will have both forwarding and computational capabilities. This makes energy-efficient network management more challenging, as decisions such as activating or deactivating a node impact on both the ability of the network to route traffic and the amount of processing it can perform. To this end, we formulate an optimization problem accounting for the main features of 5G nodes and the traffic they serve, allowing joint decisions about (i) the nodes to activate, (ii) the network functions they run, and (iii) the traffic routing. Our optimization module is integrated within the management and orchestration framework of 5G, thus enabling swift and high-quality decisions. We test our scheme with both a real-world testbed based on OpenStack and OpenDaylight, and a large-scale emulated network whose topology and traffic come from a real-world mobile operator, finding it to consistently outperform state-of-the art alternatives and closely match the optimum.