The switches in legacy networks perform both control and data forwarding operations. In contrast, in a software defined network (SDN), a controller is responsible for network control and each SDN-switch (s-switch) only forwards data packets. Advantageously, controllers can be upgraded easily to run state-of-the-art network configuration and management solutions. In this context, this paper addresses the novel problem of upgrading a legacy network into an SDN over multiple stages that span months or years. More specifically, it aims to minimize energy consumption by optimizing switch upgrades, controller placement, and traffic routing subject to an operator's budget, traffic delay tolerance, and controller capacity. We formulate the problem as a mixed integer program (MIP), and develop a heuristic solution that ensures a single path is used between switches and up to two link-disjoint paths are used between an s-switch and its controller. Our simulation results show that increasing an operator's budget and the number of upgrade stages reduce the energy consumption of tested networks by 68.42%. Further, our heuristic solution yields energy saving that is within 5% away from the optimal value. In addition, deploying controllers at strategic locations saves more energy than placing them at arbitrary locations. Lastly, our heuristic solution guarantees the delay requirement of traffic demands and runs up to 307 times faster than a prior solution.