Aruba indenting (#33884)

* Fixing aruba's inconsitent indenting.

* Adding config with different children indentation and unit test to confirm the different spacing does not matter.

* Fixing pylint check. Missed an r prefix.
This commit is contained in:
James Mighion 2017-12-14 01:07:34 -08:00 committed by Ganesh Nalawade
parent 53abf45cec
commit f8e3cfe9e2
4 changed files with 34 additions and 10 deletions

View file

@ -25,6 +25,9 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
import re
from ansible.module_utils._text import to_text
from ansible.module_utils.basic import env_fallback, return_values
from ansible.module_utils.network.common.utils import to_list, ComplexList
@ -77,11 +80,19 @@ def get_config(module, flags=None):
rc, out, err = exec_command(module, cmd)
if rc != 0:
module.fail_json(msg='unable to retrieve current config', stderr=to_text(err, errors='surrogate_then_replace'))
cfg = to_text(out, errors='surrogate_then_replace').strip()
cfg = sanitize(to_text(out, errors='surrogate_then_replace').strip())
_DEVICE_CONFIGS[cmd] = cfg
return cfg
def sanitize(resp):
# Takes response from device and adjusts leading whitespace to just 1 space
cleaned = []
for line in resp.splitlines():
cleaned.append(re.sub(r"^\s+", " ", line))
return '\n'.join(cleaned).strip()
def to_commands(module, commands):
spec = {
'command': dict(key=True),