Fix for cnos.py utility file for Python3.5 (#21750)

* fix in cnos.py utility file

* fix compile errors in cnos.py, update module short description in cnos_vlan.py, move vlan roles under integration/roles

* corrections in readme

* Change module directory name to Lenovo

* change import cnos statement
pull/22207/head
Dave Kasberg 8 years ago committed by John R Barker
parent 709b03d1c8
commit e5ceb3a99c

@ -3118,7 +3118,7 @@ def enterEnableModeForDevice(enablePassword, timeout, obj):
flag = False
retVal = ""
count = 5
while (flag is False):
while not flag:
# If wait time is execeeded.
if(count == 0):
flag = True
@ -3168,7 +3168,7 @@ def waitForDeviceResponse(command, prompt, timeout, obj):
obj.send(command)
flag = False
retVal = ""
while (flag is False):
while not flag:
time.sleep(1)
try:
buffByte = obj.recv(9999)
@ -3179,7 +3179,10 @@ def waitForDeviceResponse(command, prompt, timeout, obj):
if(gotit != -1):
flag = True
except:
retVal = retVal + "\n Error-101"
if prompt != "(yes/no)?":
retVal = retVal + "\n Error-101"
else:
retVal = retVal
flag = True
return retVal
# EOM

@ -30,7 +30,7 @@ ANSIBLE_METADATA = {'status': ['preview'],
DOCUMENTATION = '''
---
module: cnos_vlan
short_description: Performs VLAN switch configuration and state management.
short_description: Manage VLAN resources and attributes on devices running Lenovo CNOS
description:
- This module allows you to work with VLAN related configurations. The
operators used are overloaded to ensure control over switch VLAN
@ -196,7 +196,7 @@ import time
import re
try:
import cnos
from ansible.module_utils import cnos
HAS_LIB = True
except:
HAS_LIB = False

@ -67,7 +67,7 @@ Variable | Description
Ansible keeps track of all network elements that it manages through a hosts file. Before the execution of a playbook, the hosts file must be set up.
Open the */etc/ansible/hosts* file with root privileges. Most of the file is commented out by using **#**. You can also comment out the entries you will be adding by using **#**. You need to copy the content of the hosts file for the role into the */etc/ansible/hosts* file. The hosts file for the role is located in the main directory of the multiple layer vLAG configuration solution.
Open the */etc/ansible/hosts* file with root privileges. Most of the file is commented out by using **#**. You can also comment out the entries you will be adding by using **#**. You need to copy the content of the hosts file for the role into the */etc/ansible/hosts* file. The sample hosts file for the role is located in the main directory.
```
[cnos_vlan_sample]

@ -3,27 +3,35 @@
- name: Test Vlan - Create a vlan, name it
cnos_vlan: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_vlan_{{ inventory_hostname }}_output.txt vlanArg1='{{item.vlanArg1}}' vlanArg2='{{item.vlanArg2}}' vlanArg3='{{item.vlanArg3}}'
with_items: "{{cnos_vlan_data1}}"
- name: Test Vlan - Create a vlan, Flood configuration
cnos_vlan: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_vlan_{{ inventory_hostname }}_output.txt vlanArg1='{{item.vlanArg1}}' vlanArg2='{{item.vlanArg2}}' vlanArg3='{{item.vlanArg3}}'
with_items: "{{cnos_vlan_data2}}"
- name: Test Vlan - Create a vlan, State configuration
cnos_vlan: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_vlan_{{ inventory_hostname }}_output.txt vlanArg1='{{item.vlanArg1}}' vlanArg2='{{item.vlanArg2}}' vlanArg3='{{item.vlanArg3}}'
with_items: "{{cnos_vlan_data3}}"
- name: Test Vlan - VLAN Access map1
cnos_vlan: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_vlan_{{ inventory_hostname }}_output.txt vlanArg1='{{item.vlanArg1}}' vlanArg2='{{item.vlanArg2}}' vlanArg3='{{item.vlanArg3}}'
with_items: "{{cnos_vlan_data4}}"
- name: Test Vlan - VLAN Accep Map2
cnos_vlan: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_vlan_{{ inventory_hostname }}_output.txt vlanArg1='{{item.vlanArg1}}' vlanArg2='{{item.vlanArg2}}' vlanArg3='{{item.vlanArg3}}' vlanArg4='{{item.vlanArg4}}'
with_items: "{{cnos_vlan_data5}}"
- name: Test Vlan - ip igmp snooping query interval
cnos_vlan: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_vlan_{{ inventory_hostname }}_output.txt vlanArg1='{{item.vlanArg1}}' vlanArg2='{{item.vlanArg2}}' vlanArg3='{{item.vlanArg3}}' vlanArg4='{{item.vlanArg4}}'
with_items: "{{cnos_vlan_data6}}"
- name: Test Vlan - ip igmp snooping last member query interval
cnos_vlan: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_vlan_{{ inventory_hostname }}_output.txt vlanArg1='{{item.vlanArg1}}' vlanArg2='{{item.vlanArg2}}' vlanArg3='{{item.vlanArg3}}' vlanArg4='{{item.vlanArg4}}'
with_items: "{{cnos_vlan_data7}}"
- name: Test Vlan - ip igmp snooping mrouter interface port-aggregation
cnos_vlan: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_vlan_{{ inventory_hostname }}_output.txt vlanArg1='{{item.vlanArg1}}' vlanArg2='{{item.vlanArg2}}' vlanArg3='{{item.vlanArg3}}' vlanArg4='{{item.vlanArg4}}' vlanArg5='{{item.vlanArg5}}'
with_items: "{{cnos_vlan_data8}}"
- name: Idempotent Command
cnos_command: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} clicommand='{{item.clicommand}}' outputfile=./results/cnos_command_{{ inventory_hostname }}_output.txt
with_items: "{{cnos_vlan_data9}}"

Loading…
Cancel
Save