In both metropolitan optical networks (MON) and long haul optical networks (LHON) the signal quality is often influenced by the physical impairments, therefore a proper impairment based routing decision is needed. In this paper we propose new routing and wavelength assignment (RWA) methods where the control plane has influence on the signal power of the Wavelength Division Multiplexed (WDM) channels. Nowadays in nearly all kinds of reconfigurable optical add-drop multiplexers (ROADM) the signal power can be tuned via variable optical attenuators (VOA) from the control plane. We give the exact integer linear programming (ILP) formulation of the method for both single and multilayer networks. In the first case we assume that no signal regeneration is allowed along the path, while in the more complex multilayer case 3R signal regeneration, grooming and wavelength conversion can all be done in the electronic layer. The proposed algorithm can be used in existing WDM optical networks where the nodes support signal power tuning. The algorithm finds the global optimum, if it exists, for a certain network topology, physical constraints and demand set.