diff --git a/lib/ansible/module_utils/cnos.py b/lib/ansible/module_utils/cnos.py
new file mode 100644
index 00000000000..0338fabe7a6
--- /dev/null
+++ b/lib/ansible/module_utils/cnos.py
@@ -0,0 +1,3527 @@
+# This code is part of Ansible, but is an independent component.
+# This particular file snippet, and this file snippet only, is BSD licensed.
+# Modules you write using this snippet, which is embedded dynamically by
+# Ansible still belong to the author of the module, and may assign their own
+# license to the complete work.
+#
+# Copyright (C) 2017 Lenovo, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT 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.
+#
+# Contains utility methods
+# Lenovo Networking
+
+import time
+import ftplib
+import socket
+import re
+try:
+ import cnos_errorcodes
+ import cnos_devicerules
+ HAS_LIB = True
+except:
+ HAS_LIB = False
+from distutils.cmd import Command
+
+
+def interfaceConfig(
+ obj, deviceType, prompt, timeout, interfaceArg1,
+ interfaceArg2, interfaceArg3, interfaceArg4, interfaceArg5,
+ interfaceArg6, interfaceArg7, interfaceArg8, interfaceArg9):
+ retVal = ""
+ command = "interface "
+ newPrompt = prompt
+ if(interfaceArg1 == "port-aggregation"):
+ command = command + " " + interfaceArg1 + " " + interfaceArg2 + "\n"
+ # debugOutput(command)
+ value = checkSanityofVariable(
+ deviceType, "portchannel_interface_value", interfaceArg2)
+ if(value == "ok"):
+ newPrompt = "(config-if)#"
+ retVal = retVal + \
+ waitForDeviceResponse(command, newPrompt, timeout, obj)
+ else:
+ value = checkSanityofVariable(
+ deviceType, "portchannel_interface_range", interfaceArg2)
+ if(value == "ok"):
+ newPrompt = "(config-if-range)#"
+ retVal = retVal + \
+ waitForDeviceResponse(command, newPrompt, timeout, obj)
+ else:
+ value = checkSanityofVariable(
+ deviceType, "portchannel_interface_string", interfaceArg2)
+ if(value == "ok"):
+ newPrompt = "(config-if-range)#"
+ retVal = retVal + \
+ waitForDeviceResponse(command, newPrompt, timeout, obj)
+ else:
+ retVal = "Error-102"
+ return retVal
+
+ retVal = retVal + interfaceLevel2Config(
+ obj, deviceType, newPrompt, timeout, interfaceArg3, interfaceArg4,
+ interfaceArg5, interfaceArg6, interfaceArg7, interfaceArg8,
+ interfaceArg9)
+ elif(interfaceArg1 == "ethernet"):
+ # command = command + interfaceArg1 + " 1/"
+ value = checkSanityofVariable(
+ deviceType, "ethernet_interface_value", interfaceArg2)
+ if(value == "ok"):
+ newPrompt = "(config-if)#"
+ command = command + interfaceArg1 + " 1/" + interfaceArg2 + " \n"
+ retVal = retVal + \
+ waitForDeviceResponse(command, newPrompt, timeout, obj)
+ else:
+ value = checkSanityofVariable(
+ deviceType, "ethernet_interface_range", interfaceArg2)
+ if(value == "ok"):
+ command = command + \
+ interfaceArg1 + " 1/" + interfaceArg2 + " \n"
+ newPrompt = "(config-if-range)#"
+ retVal = retVal + \
+ waitForDeviceResponse(command, newPrompt, timeout, obj)
+ else:
+ value = checkSanityofVariable(
+ deviceType, "ethernet_interface_string", interfaceArg2)
+ if(value == "ok"):
+ command = command + \
+ interfaceArg1 + " " + interfaceArg2 + "\n"
+ newPrompt = "(config-if-range)#"
+ retVal = retVal + \
+ waitForDeviceResponse(command, newPrompt, timeout, obj)
+ else:
+ retVal = "Error-102"
+ return retVal
+
+ retVal = retVal + interfaceLevel2Config(
+ obj, deviceType, newPrompt, timeout, interfaceArg3, interfaceArg4,
+ interfaceArg5, interfaceArg6, interfaceArg7, interfaceArg8,
+ interfaceArg9)
+ elif(interfaceArg1 == "loopback"):
+ value = checkSanityofVariable(
+ deviceType, "loopback_interface_value", interfaceArg2)
+ if(value == "ok"):
+ newPrompt = "(config-if)#"
+ command = command + interfaceArg1 + " " + interfaceArg2 + "\n"
+ retVal = retVal + \
+ waitForDeviceResponse(command, newPrompt, timeout, obj)
+ else:
+ retVal = "Error-102"
+ return retVal
+ retVal = retVal + interfaceLevel2Config(
+ obj, deviceType, newPrompt, timeout, interfaceArg3, interfaceArg4,
+ interfaceArg5, interfaceArg6, interfaceArg7, interfaceArg8,
+ interfaceArg9)
+ elif(interfaceArg1 == "mgmt"):
+ value = checkSanityofVariable(
+ deviceType, "mgmt_interface_value", interfaceArg2)
+ if(value == "ok"):
+ newPrompt = "(config-if)#"
+ command = command + interfaceArg1 + " " + interfaceArg2 + "\n"
+ retVal = retVal + \
+ waitForDeviceResponse(command, newPrompt, timeout, obj)
+ else:
+ retVal = "Error-102"
+ return retVal
+ retVal = retVal + interfaceLevel2Config(
+ obj, deviceType, newPrompt, timeout, interfaceArg3, interfaceArg4,
+ interfaceArg5, interfaceArg6, interfaceArg7, interfaceArg8,
+ interfaceArg9)
+ elif(interfaceArg1 == "vlan"):
+ value = checkSanityofVariable(
+ deviceType, "vlan_interface_value", interfaceArg2)
+ if(value == "ok"):
+ newPrompt = "(config-if)#"
+ command = command + interfaceArg1 + " " + interfaceArg2 + "\n"
+ retVal = retVal + \
+ waitForDeviceResponse(command, newPrompt, timeout, obj)
+ else:
+ retVal = "Error-102"
+ return retVal
+ retVal = retVal + interfaceLevel2Config(
+ obj, deviceType, newPrompt, timeout, interfaceArg3, interfaceArg4,
+ interfaceArg5, interfaceArg6, interfaceArg7, interfaceArg8,
+ interfaceArg9)
+ else:
+ retVal = "Error-102"
+
+ return retVal
+# EOM
+
+
+def interfaceLevel2Config(
+ obj, deviceType, prompt, timeout, interfaceL2Arg1, interfaceL2Arg2,
+ interfaceL2Arg3, interfaceL2Arg4, interfaceL2Arg5, interfaceL2Arg6,
+ interfaceL2Arg7):
+ retVal = ""
+ command = ""
+ if(interfaceL2Arg1 == "aggregation-group"):
+ # debugOutput("aggregation-group")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "aggregation_group_no", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2 + " mode "
+ value = checkSanityofVariable(
+ deviceType, "aggregation_group_mode", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-200"
+ return retVal
+ else:
+ retVal = "Error-201"
+ return retVal
+
+ elif (interfaceL2Arg1 == "bfd"):
+ # debugOutput("bfd")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bfd_options", interfaceL2Arg2)
+ if(value == "ok"):
+ if(interfaceL2Arg2 == "echo"):
+ command = command + interfaceL2Arg2
+ elif(interfaceL2Arg2 == "interval"):
+ command = command + interfaceL2Arg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "bfd_interval", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ value = checkSanityofVariable(
+ deviceType, "bfd_minrx", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + " minrx " + interfaceL2Arg4
+ value = checkSanityofVariable(
+ deviceType, "bfd_ multiplier", interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + " multiplier " + \
+ interfaceL2Arg5
+ else:
+ retVal = "Error-236"
+ return retVal
+ else:
+ retVal = "Error-235"
+ return retVal
+ else:
+ retVal = "Error-234"
+ return retVal
+ elif(interfaceL2Arg2 == "authentication"):
+ command = command + interfaceL2Arg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "bfd_auth_options", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ if((interfaceL2Arg3 == "keyed-md5") or
+ (interfaceL2Arg3 == "keyed-sha1") or
+ (interfaceL2Arg3 == "meticulous-keyed-md5") or
+ (interfaceL2Arg3 == "meticulous-keyed-sha1") or
+ (interfaceL2Arg3 == "simple")):
+ value = checkSanityofVariable(
+ deviceType, "bfd_key_options", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4 + " "
+ if(interfaceL2Arg4 == "key-chain"):
+ value = checkSanityofVariable(
+ deviceType, "bfd_key_chain",
+ interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5
+ else:
+ retVal = "Error-237"
+ return retVal
+ elif(interfaceL2Arg4 == "key-id"):
+ value = checkSanityofVariable(
+ deviceType, "bfd_key_id", interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5
+ command = command + " key "
+ value = checkSanityofVariable(
+ deviceType, "bfd_key_name",
+ interfaceL2Arg6)
+ if(value == "ok"):
+ command = command + interfaceL2Arg6
+ else:
+ retVal = "Error-238"
+ return retVal
+ else:
+ retVal = "Error-239"
+ return retVal
+ else:
+ retVal = "Error-240"
+ return retVal
+ else:
+ retVal = "Error-241"
+ return retVal
+
+ elif(interfaceL2Arg2 == "ipv4" or interfaceL2Arg2 == "ipv6"):
+ command = command + interfaceL2Arg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "bfd_ipv4_options", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ if(interfaceL2Arg3 == "authentication"):
+ value = checkSanityofVariable(
+ deviceType, "bfd_auth_options", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4 + " "
+ if((interfaceL2Arg4 == "keyed-md5") or
+ (interfaceL2Arg4 == "keyed-sha1") or
+ (interfaceL2Arg4 == "meticulous-keyed-md5") or
+ (interfaceL2Arg4 == "meticulous-keyed-sha1") or
+ (interfaceL2Arg4 == "simple")):
+ value = checkSanityofVariable(
+ deviceType, "bfd_key_options",
+ interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5 + " "
+ if(interfaceL2Arg5 == "key-chain"):
+ value = checkSanityofVariable(
+ deviceType, "bfd_key_chain",
+ interfaceL2Arg6)
+ if(value == "ok"):
+ command = command + interfaceL2Arg6
+ else:
+ retVal = "Error-237"
+ return retVal
+ elif(interfaceL2Arg5 == "key-id"):
+ value = checkSanityofVariable(
+ deviceType, "bfd_key_id",
+ interfaceL2Arg6)
+ if(value == "ok"):
+ command = command + \
+ interfaceL2Arg6 + " key "
+ value = checkSanityofVariable(
+ deviceType, "bfd_key_name",
+ interfaceL2Arg7)
+ if(value == "ok"):
+ command = command + \
+ interfaceL2Arg7
+ else:
+ retVal = "Error-238"
+ return retVal
+ else:
+ retVal = "Error-239"
+ return retVal
+
+ else:
+ retVal = "Error-240"
+ return retVal
+ else:
+ retVal = "Error-240"
+ return retVal
+ else:
+ retVal = "Error-241"
+ return retVal
+ elif(interfaceL2Arg3 == "echo"):
+ command = command + interfaceL2Arg3
+ elif(interfaceL2Arg3 == "interval"):
+ command = command + interfaceL2Arg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "bfd_interval", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4
+ value = checkSanityofVariable(
+ deviceType, "bfd_minrx", interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + " minrx " + interfaceL2Arg5
+ value = checkSanityofVariable(
+ deviceType, "bfd_ multiplier",
+ interfaceL2Arg6)
+ if(value == "ok"):
+ command = command + " multiplier " + \
+ interfaceL2Arg6
+ else:
+ retVal = "Error-236"
+ return retVal
+ else:
+ retVal = "Error-235"
+ return retVal
+ else:
+ retVal = "Error-234"
+ return retVal
+ else:
+ command = command # None is taken care here
+
+ elif(interfaceL2Arg2 == "neighbor"):
+ command = command + interfaceL2Arg2 + " src-ip "
+ value = checkSanityofVariable(
+ deviceType, "bfd_neighbor_ip", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " dest-ip "
+ value = checkSanityofVariable(
+ deviceType, "bfd_neighbor_ip", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4 + " "
+ if(interfaceL2Arg5 is not None):
+ value = checkSanityofVariable(
+ deviceType, "bfd_neighbor_options",
+ interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5 + " "
+ if(interfaceL2Arg6 is not None):
+ if((interfaceL2Arg6 == "admin-down") or
+ (interfaceL2Arg6 ==
+ "non-persistent")):
+ command = command + \
+ interfaceL2Arg6 + " "
+ if((interfaceL2Arg7 is not None) and
+ (interfaceL2Arg7 ==
+ "admin-down")):
+ command = command + interfaceL2Arg7
+ else:
+ retVal = "Error-277"
+ return retVal
+ else:
+ retVal = "Error-277"
+ return retVal
+ # Else is not there are its optionsal
+ # Else is not there as this is optional
+ # Else is not there as this is optional
+ else:
+ retVal = "Error-242"
+ return retVal
+ else:
+ retVal = "Error-243"
+ return retVal
+
+ else:
+ retVal = "Error-205"
+ return retVal
+ else:
+ retVal = "Error-205"
+ return retVal
+
+ elif (interfaceL2Arg1 == "bridge-port"):
+ # debugOutput("bridge-port")
+ command = interfaceL2Arg1 + " "
+ if(interfaceL2Arg2 is None):
+ command = command
+ elif(interfaceL2Arg2 == "access"):
+ command = command + interfaceL2Arg2 + " vlan "
+ value = checkSanityofVariable(
+ deviceType, "bfd_access_vlan", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-202"
+ return retVal
+ elif(interfaceL2Arg2 == "mode"):
+ command = command + interfaceL2Arg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "bfd_bridgeport_mode", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-203"
+ return retVal
+ elif(interfaceL2Arg2 == "trunk"):
+ command = command + interfaceL2Arg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "trunk_options", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ if((interfaceL2Arg3 == "allowed") or
+ (interfaceL2Arg3 == "native")):
+ command = command + "vlan " # Only permiting one vlan id
+ if(interfaceL2Arg4 == "all" or interfaceL2Arg4 == "none"):
+ command = command + interfaceL2Arg4
+ elif(interfaceL2Arg4 == "add" or
+ interfaceL2Arg4 == "remove" or
+ interfaceL2Arg4 == "none"):
+ command = command + interfaceL2Arg4 + " "
+ value = checkSanityofVariable(
+ deviceType, "bfd_access_vlan", interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5
+ else:
+ retVal = "Error-202"
+ return retVal
+ else:
+ value = checkSanityofVariable(
+ deviceType, "bfd_access_vlan", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4
+ else:
+ retVal = "Error-202"
+ return retVal
+ else:
+ retVal = "Error-204"
+ return retVal
+ else:
+ retVal = "Error-204"
+ return retVal
+ else:
+ retVal = "Error-205"
+ return retVal
+
+ elif (interfaceL2Arg1 == "description"):
+ # debugOutput("description")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "portCh_description", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2
+ else:
+ retVal = "Error-206"
+ return retVal
+ elif (interfaceL2Arg1 == "duplex"):
+ # debugOutput("duplex")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "duplex_option", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2
+ else:
+ retVal = "Error-207"
+ return retVal
+ elif (interfaceL2Arg1 == "flowcontrol"):
+ # debugOutput("flowcontrol")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "flowcontrol_options", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg3 == "on" or interfaceL2Arg3 == "off"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-208"
+ return retVal
+ else:
+ retVal = "Error-209"
+ return retVal
+ elif (interfaceL2Arg1 == "ip"):
+ # debugOutput("ip")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ip_options", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg2 == "access-group"):
+ value = checkSanityofVariable(
+ deviceType, "accessgroup_name", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ if(interfaceL2Arg4 == "in" or interfaceL2Arg4 == "out"):
+ command = command + interfaceL2Arg4
+ else:
+ retVal = "Error-245"
+ return retVal
+ else:
+ retVal = "Error-246"
+ return retVal
+ elif(interfaceL2Arg2 == "address"):
+ if(interfaceL2Arg3 == "dhcp"):
+ command = command + interfaceL2Arg3
+ elif(interfaceL2Arg3 is not None):
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv4", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv4", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4 + " "
+ if(interfaceL2Arg5 == "secondary"):
+ command = command + interfaceL2Arg5
+ elif(interfaceL2Arg5 is None):
+ command = command + interfaceL2Arg5
+ else:
+ retVal = "Error-278"
+ return retVal
+ else:
+ retVal = "Error-279"
+ return retVal
+ else:
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv4_mask",
+ interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ if(interfaceL2Arg4 == "secondary"):
+ command = command + interfaceL2Arg4
+ elif(interfaceL2Arg4 is None):
+ command = command + interfaceL2Arg4
+ else:
+ retVal = "Error-278"
+ return retVal
+ else:
+ retVal = "Error-279"
+ return retVal
+
+ elif(interfaceL2Arg2 == "arp"):
+ value = checkSanityofVariable(
+ deviceType, "arp_ipaddress", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "arp_macaddress", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4 + " "
+ else:
+ retVal = "Error-247"
+ return retVal
+ elif(interfaceL2Arg3 == "timeout"):
+ command = command + interfaceL2Arg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "arp_timeout_value", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4 + " "
+ else:
+ retVal = "Error-248"
+ return retVal
+ else:
+ retVal = "Error-249"
+ return retVal
+ elif(interfaceL2Arg2 == "dhcp"):
+ if(interfaceL2Arg3 == "client"):
+ command = command + interfaceL2Arg3 + " "
+ if(interfaceL2Arg4 == "class-id"):
+ command = command + interfaceL2Arg3 + " "
+ if(interfaceL2Arg4 is not None):
+ command = command + interfaceL2Arg4
+ elif(interfaceL2Arg4 == "request"):
+ command = command + interfaceL2Arg4 + " "
+ if(interfaceL2Arg5 == "bootfile-name" or
+ interfaceL2Arg5 == "host-name" or
+ interfaceL2Arg5 == "log-server" or
+ interfaceL2Arg5 == "tftp-server-name"):
+ command = command + interfaceL2Arg5 + " "
+ else:
+ retVal = "Error-250"
+ return retVal
+ else:
+ retVal = "Error-251"
+ return retVal
+ elif(interfaceL2Arg3 == "relay"):
+ command = command + interfaceL2Arg3 + " address "
+ value = checkSanityofVariable(
+ deviceType, "relay_ipaddress", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4
+ else:
+ retVal = "Error-252"
+ return retVal
+ else:
+ retVal = "Error-253"
+ return retVal
+ elif(interfaceL2Arg2 == "ospf"):
+ value = checkSanityofVariable(
+ deviceType, "ip_ospf_options", interfaceL2Arg3)
+ if(value == "ok"):
+ retVal = "Error-102"
+ return retVal
+ else:
+ retVal = "Error-254"
+ return retVal
+
+ elif(interfaceL2Arg2 == "port"):
+ command = command + "access-group "
+ value = checkSanityofVariable(
+ deviceType, "accessgroup_name", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " in"
+ else:
+ retVal = "Error-246"
+ return retVal
+ elif(interfaceL2Arg2 == "port-unreachable"):
+ command = command + interfaceL2Arg2
+
+ elif(interfaceL2Arg2 == "redirects"):
+ command = command + interfaceL2Arg2
+
+ elif(interfaceL2Arg2 == "router"):
+ command = command + interfaceL2Arg2 + " 0 "
+ if(interfaceL2Arg3 == "area" or
+ interfaceL2Arg3 == "multi-area"):
+ command = command + interfaceL2Arg3
+ value = checkSanityofVariable(
+ deviceType, "ospf_id_decimal_value", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4
+ else:
+ value = checkSanityofVariable(
+ deviceType, "ospf_id_ipaddres_value",
+ interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4
+ else:
+ retVal = "Error-255"
+ return retVal
+ else:
+ retVal = "Error-256"
+ return retVal
+
+ elif(interfaceL2Arg2 == "unreachables"):
+ command = command + interfaceL2Arg2
+ else:
+ retVal = "Error-244"
+ return retVal
+ else:
+ retVal = "Error-244"
+ return retVal
+
+ elif (interfaceL2Arg1 == "ipv6"):
+ # debugOutput("ipv6")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv6_options", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg2 == "address"):
+ if(interfaceL2Arg3 == "dhcp"):
+ command = command + interfaceL2Arg3
+ else:
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv6_address",
+ interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ if(interfaceL2Arg4 == "anycast" or
+ interfaceL2Arg4 == "secondary" or
+ interfaceL2Arg4 is None):
+ command = command + interfaceL2Arg4
+ else:
+ retVal = "Error-276"
+ return retVal
+ else:
+ retVal = "Error-275"
+ return retVal
+ elif(interfaceL2Arg2 == "dhcp"):
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv6_dhcp", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + "relay address " + interfaceL2Arg3
+ if(interfaceL2Arg4 is not None):
+ if(interfaceL2Arg4 == "ethernet"):
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv6_dhcp_ethernet",
+ interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + " interface ethernet " + \
+ interfaceL2Arg4
+ else:
+ retVal = "Error-271"
+ return retVal
+ elif(interfaceL2Arg4 == "vlan"):
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv6_dhcp_vlan",
+ interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + " interface vlan " + \
+ interfaceL2Arg4
+ else:
+ retVal = "Error-272"
+ return retVal
+ else:
+ retVal = "Error-270"
+ return retVal
+ else:
+ retVal = "Error-269"
+ return retVal
+
+ elif(interfaceL2Arg2 == "link-local"):
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv6_linklocal", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-273"
+ return retVal
+ elif(interfaceL2Arg2 == "nd"):
+ retVal = "Error-102"
+ return retVal
+ elif(interfaceL2Arg2 == "neighbor"):
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv6_neighbor_address",
+ interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "portchannel_ipv6_neighbor_mac",
+ interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4
+ else:
+ retVal = "Error-267"
+ return retVal
+ else:
+ retVal = "Error-268"
+ return retVal
+ else:
+ retVal = "Error-266"
+ return retVal
+ else:
+ retVal = "Error-102"
+ return retVal
+
+ elif (interfaceL2Arg1 == "lacp"):
+ # debugOutput("lacp")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "lacp_options", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg2 == "port-priority"):
+ value = checkSanityofVariable(
+ deviceType, "port_priority", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-210"
+ return retVal
+ elif(interfaceL2Arg2 == "suspend-individual"):
+ command = command + interfaceL2Arg3
+ elif(interfaceL2Arg2 == "timeout"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg3 == "long" or interfaceL2Arg3 == "short"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-211"
+ return retVal
+ else:
+ retVal = "Error-212"
+ return retVal
+ else:
+ retVal = "Error-212"
+ return retVal
+
+ elif (interfaceL2Arg1 == "lldp"):
+ # debugOutput("lldp")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "lldp_options", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg2 == "receive" or
+ interfaceL2Arg2 == "trap-notification" or
+ interfaceL2Arg2 == "transmit"):
+ command = command
+ elif(interfaceL2Arg2 == "tlv-select"):
+ value = checkSanityofVariable(
+ deviceType, "lldp_tlv_options", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-213"
+ return retVal
+ else:
+ retVal = "Error-214"
+ return retVal
+ else:
+ retVal = "Error-214"
+ return retVal
+
+ elif (interfaceL2Arg1 == "load-interval"):
+ # debugOutput("load-interval")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "load_interval_delay", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2
+ else:
+ if(interfaceL2Arg2 == "counter"):
+ command = command + interfaceL2Arg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "load_interval_counter", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "load_interval_delay", interfaceL2Arg4)
+ if(value == "ok"):
+ command = command + interfaceL2Arg4
+ else:
+ retVal = "Error-215"
+ return retVal
+ else:
+ retVal = "Error-216"
+ return retVal
+ else:
+ retVal = "Error-217"
+ return retVal
+
+ elif (interfaceL2Arg1 == "mac"):
+ # debugOutput("mac")
+ command = interfaceL2Arg1 + " port access-group "
+ value = checkSanityofVariable(
+ deviceType, "mac_accessgroup_name", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2
+ else:
+ retVal = "Error-218"
+ return retVal
+ elif (interfaceL2Arg1 == "mac-address"):
+ # debugOutput("mac-address")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "mac_address", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2
+ else:
+ retVal = "Error-219"
+ return retVal
+
+ elif (interfaceL2Arg1 == "mac-learn"):
+ # debugOutput("mac-learn")
+ command = interfaceL2Arg1 + " disable"
+
+ elif (interfaceL2Arg1 == "microburst-detection"):
+ # debugOutput("microburst-detection")
+ command = interfaceL2Arg1 + " enable threshold "
+ value = checkSanityofVariable(
+ deviceType, "microburst_threshold", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2
+ else:
+ retVal = "Error-220"
+ return retVal
+
+ elif (interfaceL2Arg1 == "mtu"):
+ # debugOutput("mtu")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(deviceType, "mtu_value", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2
+ else:
+ retVal = "Error-221"
+ return retVal
+
+ elif (interfaceL2Arg1 == "service"):
+ # debugOutput("service")
+ command = interfaceL2Arg1 + " instance "
+ value = checkSanityofVariable(
+ deviceType, "service_instance", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2
+ else:
+ retVal = "Error-222"
+ return retVal
+
+ elif (interfaceL2Arg1 == "service-policy"):
+ # debugOutput("service-policy")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "service_policy_options", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg2 == "input" or interfaceL2Arg2 == "output"):
+ value = checkSanityofVariable(
+ deviceType, "service_policy_name", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-223"
+ return retVal
+ elif(interfaceL2Arg2 == "copp-system-policy"):
+ command = command + "class all"
+ elif(interfaceL2Arg2 == "type" and interfaceL2Arg3 == "qos"):
+ command = command + interfaceL2Arg3 + " "
+ if(interfaceL2Arg4 == "input" or interfaceL2Arg4 == "output"):
+ value = checkSanityofVariable(
+ deviceType, "service_policy_name", interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5
+ else:
+ retVal = "Error-223"
+ return retVal
+ elif(interfaceL2Arg2 == "type" and interfaceL2Arg3 == "queuing"):
+ command = command + interfaceL2Arg3 + " "
+ if(interfaceL2Arg4 == "input" or interfaceL2Arg4 == "output"):
+ value = checkSanityofVariable(
+ deviceType, "service_policy_name", interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5
+ else:
+ retVal = "Error-223"
+ return retVal
+ else:
+ retVal = "Error-224"
+ return retVal
+
+ elif (interfaceL2Arg1 == "shutdown"):
+ # debugOutput("shutdown")
+ command = interfaceL2Arg1
+
+ elif (interfaceL2Arg1 == "snmp"):
+ # debugOutput("snmp")
+ command = interfaceL2Arg1 + " trap link-status "
+
+ elif (interfaceL2Arg1 == "spanning-tree"):
+ # debugOutput("spanning-tree")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "spanning_tree_options", interfaceL2Arg2)
+ if(value == "ok"):
+ if(interfaceL2Arg2 == "bpdufilter"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg3 == "enable" or
+ interfaceL2Arg3 == "disable"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-257"
+ return retVal
+ elif(interfaceL2Arg2 == "bpduguard"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg3 == "enable" or
+ interfaceL2Arg3 == "disable"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-258"
+ return retVal
+ elif(interfaceL2Arg2 == "cost"):
+ command = command + interfaceL2Arg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "spanning_tree_cost", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ elif(interfaceL2Arg3 == "auto"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-259"
+ return retVal
+ elif(interfaceL2Arg2 == "disable" or interfaceL2Arg2 == "enable"):
+ command = command + interfaceL2Arg2 + " "
+ elif(interfaceL2Arg2 == "guard"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg3 == "loop" or interfaceL2Arg3 == "root"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-260"
+ return retVal
+ elif(interfaceL2Arg2 == "link-type"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg3 == "auto" or
+ interfaceL2Arg3 == "point-to-point" or
+ interfaceL2Arg3 == "shared"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-261"
+ return retVal
+
+ elif(interfaceL2Arg2 == "mst"):
+ command = command + interfaceL2Arg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "spanning_tree_interfacerange",
+ interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3 + " "
+ if(interfaceL2Arg4 == "cost"):
+ command = command + interfaceL2Arg4 + " "
+ value = checkSanityofVariable(
+ deviceType, "spanning_tree_cost", interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5
+ elif(interfaceL2Arg5 == "auto"):
+ command = command + interfaceL2Arg5
+ else:
+ retVal = "Error-259"
+ return retVal
+ elif(interfaceL2Arg4 == "port-priority"):
+ command = command + interfaceL2Arg4 + " "
+ value = checkSanityofVariable(
+ deviceType, "spanning_tree_portpriority",
+ interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5
+ else:
+ retVal = "Error-259"
+ return retVal
+ else:
+ retVal = "Error-259"
+ return retVal
+ else:
+ retVal = "Error-263"
+ return retVal
+ elif(interfaceL2Arg2 == "port"):
+ command = command + interfaceL2Arg2 + " type edge"
+ elif(interfaceL2Arg2 == "port-priority"):
+ command = command + interfaceL2Arg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "spanning_tree_portpriority", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ else:
+ retVal = "Error-264"
+ return retVal
+
+ elif(interfaceL2Arg2 == "vlan"):
+ command = command + interfaceL2Arg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_id_range", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+ if(interfaceL2Arg4 == "cost"):
+ command = command + interfaceL2Arg4 + " "
+ value = checkSanityofVariable(
+ deviceType, "spanning_tree_cost", interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5
+ elif(interfaceL2Arg5 == "auto"):
+ command = command + interfaceL2Arg5
+ else:
+ retVal = "Error-263"
+ return retVal
+ elif(interfaceL2Arg4 == "port-priority"):
+ command = command + interfaceL2Arg4 + " "
+ value = checkSanityofVariable(
+ deviceType, "spanning_tree_portpriority",
+ interfaceL2Arg5)
+ if(value == "ok"):
+ command = command + interfaceL2Arg5
+ else:
+ retVal = "Error-264"
+ return retVal
+ else:
+ retVal = "Error-264"
+ return retVal
+ else:
+ retVal = "Error-134"
+ return retVal
+ else:
+ retVal = "Error-263"
+ return retVal
+ elif (interfaceL2Arg1 == "speed"):
+ # debugOutput("speed")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "interface_speed", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2
+ else:
+ retVal = "Error-225"
+ return retVal
+ elif (interfaceL2Arg1 == "storm-control"):
+ # debugOutput("storm-control")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "stormcontrol_options", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2 + " level "
+ value = checkSanityofVariable(
+ deviceType, "stormcontrol_level", interfaceL2Arg3)
+ if(value == "ok"):
+ command = command + interfaceL2Arg3
+
+ else:
+ retVal = "Error-226"
+ return retVal
+ else:
+ retVal = "Error-227"
+ return retVal
+
+ elif (interfaceL2Arg1 == "vlan"):
+ # debugOutput("vlan")
+ command = interfaceL2Arg1 + " dot1q tag native "
+ value = checkSanityofVariable(
+ deviceType, "portchannel_dot1q_tag", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2
+ if(interfaceL2Arg2 == "egress-only"):
+ command = command + " enable"
+ else:
+ retVal = "Error-228"
+ return retVal
+
+ elif (interfaceL2Arg1 == "vrrp"):
+ # debugOutput("vrrp")
+ command = interfaceL2Arg1 + " "
+ value = checkSanityofVariable(deviceType, "vrrp_id", interfaceL2Arg2)
+ if(value == "ok"):
+ command = command + interfaceL2Arg2 + " "
+ if(interfaceL2Arg3 == "ipv6"):
+ command = command + interfaceL2Arg3 + " "
+ elif(interfaceL2Arg3 is None):
+ command = command + ""
+ else:
+ retVal = "Error-229"
+ return retVal
+ else:
+ retVal = "Error-230"
+ return retVal
+
+ else:
+ retVal = "Error-233"
+ return retVal
+
+ command = command + "\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, prompt, timeout, obj)
+ # Come back to config mode
+ if((prompt == "(config-if)#") or (prompt == "(config-if-range)#")):
+ command = "exit \n"
+ # debugOutput(command)
+ retVal = retVal + \
+ waitForDeviceResponse(command, "(config)#", timeout, obj)
+
+ return retVal
+# EOM
+
+
+def portChannelConfig(
+ obj, deviceType, prompt, timeout, portChArg1, portChArg2, portChArg3,
+ portChArg4, portChArg5, portChArg6, portChArg7):
+ retVal = ""
+ command = ""
+ if(portChArg1 == "port-aggregation" and prompt == "(config)#"):
+ command = command + portChArg1 + " load-balance ethernet "
+ if(portChArg2 == "destination-ip" or
+ portChArg2 == "destination-mac" or
+ portChArg2 == "destination-port" or
+ portChArg2 == "source-dest-ip" or
+ portChArg2 == "source-dest-mac" or
+ portChArg2 == "source-dest-port" or
+ portChArg2 == "source-interface" or
+ portChArg2 == "source-ip" or
+ portChArg2 == "source-mac" or
+ portChArg2 == "source-port"):
+
+ # debugOutput(portChArg2)
+ command = command + portChArg2 + " "
+ if(portChArg3 is None):
+ command = command + ""
+ elif(portChArg3 == "source-interface"):
+ command = command + portChArg3
+ else:
+ retVal = "Error-231"
+ return retVal
+ else:
+ retVal = "Error-232"
+ return retVal
+
+# EOM
+
+
+def routerConfig(
+ obj, deviceType, prompt, timeout, protocol, asNum, routerArg1,
+ routerArg2, routerArg3, routerArg4, routerArg5, routerArg6, routerArg7,
+ routerArg8):
+ retVal = ""
+ # Wait time to get response from server
+ timeout = timeout
+ if(protocol == "bgp"):
+ # bgp config command happens here.
+ command = "routing-protocol bgp "
+ value = checkSanityofVariable(deviceType, "bgp_as_number", asNum)
+ if(value == "ok"):
+ # BGP command happens here. It creates if not present
+ command = command + asNum + "\n"
+ # debugOutput(command)
+ retVal = waitForDeviceResponse(
+ command, "(config-router)#", timeout, obj)
+ retVal = retVal + bgpConfig(
+ obj, deviceType, "(config-router)#", timeout, routerArg1,
+ routerArg2, routerArg3, routerArg4, routerArg5, routerArg6,
+ routerArg7, routerArg8)
+ else:
+ retVal = "Error-176"
+
+ elif(protocol == "ospf"):
+ retVal = "Command Value is Not supported as of now"
+
+ else:
+ retVal = "Error-177"
+
+ return retVal
+# EOM
+
+
+def bgpNeighborAFConfig(
+ obj, deviceType, prompt, timeout, bgpNeighborAFArg1, bgpNeighborAFArg2,
+ bgpNeighborAFArg3):
+ retVal = ""
+ command = ""
+ timeout = timeout
+ if(bgpNeighborAFArg1 == "allowas-in"):
+ command = command + bgpNeighborAFArg1 + " "
+ if(bgpNeighborAFArg2 is not None):
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_af_occurances", bgpNeighborAFArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborAFArg2
+ else:
+ retVal = "Error-325"
+ return retVal
+ else:
+ command = command
+ elif(bgpNeighborAFArg1 == "default-originate"):
+ command = command + bgpNeighborAFArg1 + " "
+ if(bgpNeighborAFArg2 is not None and bgpNeighborAFArg2 == "route-map"):
+ command = command + bgpNeighborAFArg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_af_routemap", bgpNeighborAFArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborAFArg3
+ else:
+ retVal = "Error-324"
+ return retVal
+ elif(bgpNeighborAFArg1 == "filter-list"):
+ command = command + bgpNeighborAFArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_af_filtername", bgpNeighborAFArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborAFArg2 + " "
+ if(bgpNeighborAFArg3 == "in" or bgpNeighborAFArg3 == "out"):
+ command = command + bgpNeighborAFArg3
+ else:
+ retVal = "Error-323"
+ return retVal
+ else:
+ retVal = "Error-322"
+ return retVal
+
+ elif(bgpNeighborAFArg1 == "maximum-prefix"):
+ command = command + bgpNeighborAFArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_af_maxprefix", bgpNeighborAFArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborAFArg2 + " "
+ if(bgpNeighborAFArg3 is not None):
+ command = command + bgpNeighborAFArg3
+ else:
+ command = command
+ else:
+ retVal = "Error-326"
+ return retVal
+
+ elif(bgpNeighborAFArg1 == "next-hop-self"):
+ command = command + bgpNeighborAFArg1
+
+ elif(bgpNeighborAFArg1 == "prefix-list"):
+ command = command + bgpNeighborAFArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_af_prefixname", bgpNeighborAFArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborAFArg2 + " "
+ if(bgpNeighborAFArg3 == "in" or bgpNeighborAFArg3 == "out"):
+ command = command + bgpNeighborAFArg3
+ else:
+ retVal = "Error-321"
+ return retVal
+ else:
+ retVal = "Error-320"
+ return retVal
+
+ elif(bgpNeighborAFArg1 == "route-map"):
+ command = command + bgpNeighborAFArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_af_routemap", bgpNeighborAFArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborAFArg2
+ else:
+ retVal = "Error-319"
+ return retVal
+ elif(bgpNeighborAFArg1 == "route-reflector-client"):
+ command = command + bgpNeighborAFArg1
+
+ elif(bgpNeighborAFArg1 == "send-community"):
+ command = command + bgpNeighborAFArg1 + " "
+ if(bgpNeighborAFArg2 is not None and bgpNeighborAFArg2 == "extended"):
+ command = command + bgpNeighborAFArg2
+ else:
+ command = command
+
+ elif(bgpNeighborAFArg1 == "soft-reconfiguration"):
+ command = command + bgpNeighborAFArg1 + " inbound"
+
+ elif(bgpNeighborAFArg1 == "unsuppress-map"):
+ command = command + bgpNeighborAFArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_af_routemap", bgpNeighborAFArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborAFArg2
+ else:
+ retVal = "Error-318"
+ return retVal
+
+ else:
+ retVal = "Error-317"
+ return retVal
+
+ command = command + "\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, prompt, timeout, obj)
+ command = "exit \n"
+ retVal = retVal + \
+ waitForDeviceResponse(
+ command, "(config-router-neighbor)#", timeout, obj)
+ return retVal
+# EOM
+
+
+def bgpNeighborConfig(
+ obj, deviceType, prompt, timeout, bgpNeighborArg1, bgpNeighborArg2,
+ bgpNeighborArg3, bgpNeighborArg4, bgpNeighborArg5):
+ retVal = ""
+ command = ""
+ timeout = timeout
+
+ if(bgpNeighborArg1 == "address-family"):
+ command = command + bgpNeighborArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_address_family", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2 + " unicast \n"
+ # debugOutput(command)
+ retVal = waitForDeviceResponse(
+ command, "(config-router-neighbor-af)#", timeout, obj)
+ retVal = retVal + bgpNeighborAFConfig(
+ obj, deviceType, "(config-router-neighbor-af)#", timeout,
+ bgpNeighborArg3, bgpNeighborArg4, bgpNeighborArg5)
+ return retVal
+ else:
+ retVal = "Error-316"
+ return retVal
+
+ elif(bgpNeighborArg1 == "advertisement-interval"):
+ command = command + bgpNeighborArg1
+
+ elif(bgpNeighborArg1 == "bfd"):
+ command = command + bgpNeighborArg1 + " "
+ if(bgpNeighborArg2 is not None and bgpNeighborArg2 == "mutihop"):
+ command = command + bgpNeighborArg2
+ else:
+ command = command
+
+ elif(bgpNeighborArg1 == "connection-retry-time"):
+ command = command + bgpNeighborArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_connection_retrytime", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2
+ else:
+ retVal = "Error-315"
+ return retVal
+
+ elif(bgpNeighborArg1 == "description"):
+ command = command + bgpNeighborArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_description", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2
+ else:
+ retVal = "Error-314"
+ return retVal
+
+ elif(bgpNeighborArg1 == "disallow-infinite-holdtime"):
+ command = command + bgpNeighborArg1
+
+ elif(bgpNeighborArg1 == "dont-capability-negotiate"):
+ command = command + bgpNeighborArg1
+
+ elif(bgpNeighborArg1 == "dynamic-capability"):
+ command = command + bgpNeighborArg1
+
+ elif(bgpNeighborArg1 == "ebgp-multihop"):
+ command = command + bgpNeighborArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_maxhopcount", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2
+ else:
+ retVal = "Error-313"
+ return retVal
+ elif(bgpNeighborArg1 == "interface"):
+ command = command + bgpNeighborArg1 + " "
+ # TBD
+ elif(bgpNeighborArg1 == "local-as"):
+ command = command + bgpNeighborArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_local_as", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2 + " "
+ if(bgpNeighborArg3 is not None and
+ bgpNeighborArg3 == "no-prepend"):
+ command = command + bgpNeighborArg3 + " "
+ if(bgpNeighborArg4 is not None and
+ bgpNeighborArg4 == "replace-as"):
+ command = command + bgpNeighborArg4 + " "
+ if(bgpNeighborArg5 is not None and
+ bgpNeighborArg5 == "dual-as"):
+ command = command + bgpNeighborArg5
+ else:
+ command = command
+ else:
+ command = command
+ else:
+ command = command
+ else:
+ retVal = "Error-312"
+ return retVal
+
+ elif(bgpNeighborArg1 == "maximum-peers"):
+ command = command + bgpNeighborArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_maxpeers", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2
+ else:
+ retVal = "Error-311"
+ return retVal
+
+ elif(bgpNeighborArg1 == "password"):
+ command = command + bgpNeighborArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_password", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2
+ else:
+ retVal = "Error-310"
+ return retVal
+
+ elif(bgpNeighborArg1 == "remove-private-AS"):
+ command = command + bgpNeighborArg1
+
+ elif(bgpNeighborArg1 == "timers"):
+ command = command + bgpNeighborArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_timers_Keepalive", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_timers_holdtime", bgpNeighborArg3)
+ if(value == "ok"):
+ command = command + bgpNeighborArg3
+ else:
+ retVal = "Error-309"
+ return retVal
+ else:
+ retVal = "Error-308"
+ return retVal
+
+ elif(bgpNeighborArg1 == "transport"):
+ command = command + bgpNeighborArg1 + " connection-mode passive "
+
+ elif(bgpNeighborArg1 == "ttl-security"):
+ command = command + bgpNeighborArg1 + " hops "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_ttl_hops", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2
+ else:
+ retVal = "Error-307"
+ return retVal
+
+ elif(bgpNeighborArg1 == "update-source"):
+ command = command + bgpNeighborArg1 + " "
+ if(bgpNeighborArg2 is not None):
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_update_options", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2 + " "
+ if(bgpNeighborArg2 == "ethernet"):
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_update_ethernet",
+ bgpNeighborArg3)
+ if(value == "ok"):
+ command = command + bgpNeighborArg3
+ else:
+ retVal = "Error-304"
+ return retVal
+ elif(bgpNeighborArg2 == "loopback"):
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_update_loopback",
+ bgpNeighborArg3)
+ if(value == "ok"):
+ command = command + bgpNeighborArg3
+ else:
+ retVal = "Error-305"
+ return retVal
+ else:
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_update_vlan",
+ bgpNeighborArg3)
+ if(value == "ok"):
+ command = command + bgpNeighborArg3
+ else:
+ retVal = "Error-306"
+ return retVal
+ else:
+ command = command + bgpNeighborArg2
+ else:
+ retVal = "Error-303"
+ return retVal
+
+ elif(bgpNeighborArg1 == "weight"):
+ command = command + bgpNeighborArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_neighbor_weight", bgpNeighborArg2)
+ if(value == "ok"):
+ command = command + bgpNeighborArg2
+ else:
+ retVal = "Error-302"
+ return retVal
+
+ else:
+ retVal = "Error-301"
+ return retVal
+
+ command = command + "\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, prompt, timeout, obj)
+ command = "exit \n"
+ retVal = retVal + \
+ waitForDeviceResponse(command, "(config-router)#", timeout, obj)
+ return retVal
+# EOM
+
+
+def bgpAFConfig(
+ obj, deviceType, prompt, timeout, bgpAFArg1, bgpAFArg2, bgpAFArg3,
+ bgpAFArg4, bgpAFArg5, bgpAFArg6):
+ retVal = ""
+ command = ""
+ timeout = timeout
+ if(bgpAFArg1 == "aggregate-address"):
+ command = command + bgpAFArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_aggregate_prefix", bgpAFArg2)
+ if(value == "ok"):
+ command = command + bgpAFArg2 + " "
+ if(bgpAFArg2 is None):
+ command = command
+ elif(bgpAFArg2 == "as-set" or bgpAFArg2 == "summary-only"):
+ command = command + bgpAFArg2 + " "
+ if(bgpAFArg3 is None):
+ command = command
+ elif(bgpAFArg2 == "as-set"):
+ command = command + "summary-only"
+ else:
+ command = command + "as-set"
+ else:
+ retVal = "Error-297"
+ return retVal
+ else:
+ retVal = "Error-296"
+ return retVal
+ elif(bgpAFArg1 == "client-to-client"):
+ command = command + bgpAFArg1 + " reflection "
+ elif(bgpAFArg1 == "dampening"):
+ command = command + bgpAFArg1 + " "
+ if(bgpAFArg2 == "route-map"):
+ command = command + bgpAFArg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "addrfamily_routemap_name", bgpAFArg3)
+ if(value == "ok"):
+ command = command + bgpAFArg3
+ else:
+ retVal = "Error-196"
+ return retVal
+ elif(bgpAFArg2 is not None):
+ value = checkSanityofVariable(
+ deviceType, "reachability_half_life", bgpAFArg2)
+ if(value == "ok"):
+ command = command + bgpAFArg2 + " "
+ if(bgpAFArg3 is not None):
+ value1 = checkSanityofVariable(
+ deviceType, "start_reuse_route_value", bgpAFArg3)
+ value2 = checkSanityofVariable(
+ deviceType, "start_suppress_route_value", bgpAFArg4)
+ value3 = checkSanityofVariable(
+ deviceType, "max_duration_to_suppress_route",
+ bgpAFArg5)
+ if(value1 == "ok" and value2 == "ok" and value3 == "ok"):
+ command = command + bgpAFArg3 + " " + bgpAFArg4 + \
+ " " + bgpAFArg5 + " "
+ if(bgpAFArg6 is not None):
+ value = checkSanityofVariable(
+ deviceType,
+ "unreachability_halftime_for_penalty",
+ bgpAFArg6)
+ if(value == "ok"):
+ command = command + bgpAFArg6
+ else:
+ retVal = "Error-295"
+ return retVal
+ else:
+ command = command
+ else:
+ retVal = "Error-294"
+ return retVal
+
+ elif(bgpAFArg1 == "distance"):
+ command = command + bgpAFArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "distance_external_AS", bgpAFArg2)
+ if(value == "ok"):
+ command = command + bgpAFArg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "distance_internal_AS", bgpAFArg3)
+ if(value == "ok"):
+ command = command + bgpAFArg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "distance_local_routes", bgpAFArg4)
+ if(value == "ok"):
+ command = command + bgpAFArg4
+ else:
+ retVal = "Error-291"
+ return retVal
+ else:
+ retVal = "Error-292"
+ return retVal
+ else:
+ retVal = "Error-293"
+ return retVal
+ elif(bgpAFArg1 == "maximum-paths"):
+ command = command + bgpAFArg1 + " "
+ value = checkSanityofVariable(deviceType, "maxpath_option", bgpAFArg2)
+ if(value == "ok"):
+ command = command + bgpAFArg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "maxpath_numbers", bgpAFArg3)
+ if(value == "ok"):
+ command = command + bgpAFArg3
+ else:
+ retVal = "Error-199"
+ return retVal
+ else:
+ retVal = "Error-290"
+ return retVal
+
+ elif(bgpAFArg1 == "network"):
+ command = command + bgpAFArg1 + " "
+ if(bgpAFArg2 == "synchronization"):
+ command = command + bgpAFArg2
+ else:
+ value = checkSanityofVariable(
+ deviceType, "network_ip_prefix_with_mask", bgpAFArg2)
+ if(value == "ok"):
+ command = command + bgpAFArg2 + " "
+ if(bgpAFArg3 is not None and bgpAFArg3 == "backdoor"):
+ command = command + bgpAFArg3
+ elif(bgpAFArg3 is not None and bgpAFArg3 == "route-map"):
+ command = command + bgpAFArg3
+ value = checkSanityofVariable(
+ deviceType, "addrfamily_routemap_name", bgpAFArg4)
+ if(value == "ok"):
+ command = command + bgpAFArg4 + " "
+ if(bgpAFArg5 is not None and bgpAFArg5 == "backdoor"):
+ command = command + bgpAFArg5
+ else:
+ retVal = "Error-298"
+ return retVal
+ else:
+ retVal = "Error-196"
+ return retVal
+ else:
+ command = command
+ else:
+ value = checkSanityofVariable(
+ deviceType, "network_ip_prefix_value", bgpAFArg2)
+ if(value == "ok"):
+ command = command + bgpAFArg2 + " "
+ if(bgpAFArg3 is not None and bgpAFArg3 == "backdoor"):
+ command = command + bgpAFArg3
+ elif(bgpAFArg3 is not None and bgpAFArg3 == "route-map"):
+ command = command + bgpAFArg3
+ value = checkSanityofVariable(
+ deviceType, "addrfamily_routemap_name", bgpAFArg4)
+ if(value == "ok"):
+ command = command + bgpAFArg4 + " "
+ if(bgpAFArg5 is not None and
+ bgpAFArg5 == "backdoor"):
+ command = command + bgpAFArg5
+ else:
+ retVal = "Error-298"
+ return retVal
+ else:
+ retVal = "Error-196"
+ return retVal
+ elif(bgpAFArg3 is not None and bgpAFArg3 == "mask"):
+ command = command + bgpAFArg3
+ value = checkSanityofVariable(
+ deviceType, "network_ip_prefix_mask", bgpAFArg4)
+ if(value == "ok"):
+ command = command + bgpAFArg4 + " "
+ else:
+ retVal = "Error-299"
+ return retVal
+ else:
+ command = command
+ else:
+ retVal = "Error-300"
+ return retVal
+
+ elif(bgpAFArg1 == "nexthop"):
+ command = command + bgpAFArg1 + " trigger-delay critical "
+ value = checkSanityofVariable(
+ deviceType, "nexthop_crtitical_delay", bgpAFArg2)
+ if(value == "ok"):
+ command = command + bgpAFArg2 + " "
+ value = checkSanityofVariable(
+ deviceType, "nexthop_noncrtitical_delay", bgpAFArg3)
+ if(value == "ok"):
+ command = command + bgpAFArg3 + " "
+ else:
+ retVal = "Error-198"
+ return retVal
+ else:
+ retVal = "Error-197"
+ return retVal
+ elif(bgpAFArg1 == "redistribute"):
+ command = command + bgpAFArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "addrfamily_redistribute_option", bgpAFArg2)
+ if(value == "ok"):
+ command = command + bgpAFArg2 + " "
+ if(bgpAFArg2 is not None):
+ command = command + "route-map "
+ value = checkSanityofVariable(
+ deviceType, "addrfamily_routemap_name", bgpAFArg3)
+ if(value == "ok"):
+ command = command + bgpAFArg3
+ else:
+ retVal = "Error-196"
+ return retVal
+ else:
+ retVal = "Error-195"
+ return retVal
+ elif(bgpAFArg1 == "save" or bgpAFArg1 == "synchronization"):
+ command = command + bgpAFArg1
+ else:
+ retVal = "Error-194"
+ return retVal
+ command = command + "\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, prompt, timeout, obj)
+ command = "exit \n"
+ retVal = retVal + \
+ waitForDeviceResponse(command, "(config-router)#", timeout, obj)
+ return retVal
+# EOM
+
+
+def bgpConfig(
+ obj, deviceType, prompt, timeout, bgpArg1, bgpArg2, bgpArg3, bgpArg4,
+ bgpAgr5, bgpArg6, bgpArg7, bgpArg8):
+ retVal = ""
+ command = ""
+ # Wait time to get response from server
+ timeout = timeout
+ if(bgpArg1 == "address-family"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "bgp_address_family", bgpArg2)
+ if(value == "ok"):
+ command = command + bgpArg2 + " " + "unicast \n"
+ debugOutput(command)
+ retVal = waitForDeviceResponse(
+ command, "(config-router-af)#", timeout, obj)
+ retVal = retVal + bgpAFConfig(
+ obj, deviceType, "(config-router-af)#", timeout,
+ bgpArg3, bgpArg4, bgpAgr5, bgpArg6, bgpArg7, bgpArg8)
+ return retVal
+ else:
+ retVal = "Error-178"
+ return retVal
+
+ elif(bgpArg1 == "bestpath"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " "
+ if(bgpArg2 == "always-compare-med"):
+ # debugOutput(bgpArg2)
+ command = command + bgpArg2
+ elif(bgpArg2 == "compare-confed-aspath"):
+ # debugOutput(bgpArg2)
+ command = command + bgpArg2
+ elif(bgpArg2 == "compare-routerid"):
+ # debugOutput(bgpArg2)
+ command = command + bgpArg2
+ elif(bgpArg2 == "dont-compare-originator-id"):
+ # debugOutput(bgpArg2)
+ command = command + bgpArg2
+ elif(bgpArg2 == "tie-break-on-age"):
+ # debugOutput(bgpArg2)
+ command = command + bgpArg2
+ elif(bgpArg2 == "as-path"):
+ # debugOutput(bgpArg2)
+ command = command + bgpArg2 + " "
+ if(bgpArg3 == "ignore" or bgpArg3 == "multipath-relax"):
+ command = command + bgpArg3
+ else:
+ retVal = "Error-179"
+ return retVal
+ elif(bgpArg2 == "med"):
+ # debugOutput(bgpArg2)
+ command = command + bgpArg2 + " "
+ if(bgpArg3 == "confed" or
+ bgpArg3 == "missing-as-worst" or
+ bgpArg3 == "non-deterministic" or
+ bgpArg3 == "remove-recv-med" or
+ bgpArg3 == "remove-send-med"):
+ command = command + bgpArg3
+ else:
+ retVal = "Error-180"
+ return retVal
+ else:
+ retVal = "Error-181"
+ return retVal
+
+ elif(bgpArg1 == "bgp"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " as-local-count "
+ value = checkSanityofVariable(
+ deviceType, "bgp_bgp_local_count", bgpArg2)
+ if(value == "ok"):
+ command = command + bgpArg2
+ else:
+ retVal = "Error-182"
+ return retVal
+
+ elif(bgpArg1 == "cluster-id"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " "
+ value = checkSanityofVariable(deviceType, "cluster_id_as_ip", bgpArg2)
+ if(value == "ok"):
+ command = command + bgpArg2
+ else:
+ value = checkSanityofVariable(
+ deviceType, "cluster_id_as_number", bgpArg2)
+ if(value == "ok"):
+ command = command + bgpArg2
+ else:
+ retVal = "Error-183"
+ return retVal
+
+ elif(bgpArg1 == "confederation"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " "
+ if(bgpArg2 == "identifier"):
+ value = checkSanityofVariable(
+ deviceType, "confederation_identifier", bgpArg3)
+ if(value == "ok"):
+ command = command + " " + bgpArg2 + " " + bgpArg3
+ else:
+ retVal = "Error-184"
+ return retVal
+ elif(bgpArg2 == "peers"):
+ value = checkSanityofVariable(
+ deviceType, "confederation_peers_as", bgpArg3)
+ if(value == "ok"):
+ command = command + " " + bgpArg2 + " " + bgpArg3
+ else:
+ retVal = "Error-185"
+ return retVal
+ else:
+ retVal = "Error-186"
+ return retVal
+
+ elif(bgpArg1 == "enforce-first-as"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1
+
+ elif(bgpArg1 == "fast-external-failover"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1
+
+ elif(bgpArg1 == "graceful-restart"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " stalepath-time "
+ value = checkSanityofVariable(
+ deviceType, "stalepath_delay_value", bgpArg2)
+ if(value == "ok"):
+ command = command + bgpArg2
+ else:
+ retVal = "Error-187"
+ return retVal
+
+ elif(bgpArg1 == "graceful-restart-helper"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1
+
+ elif(bgpArg1 == "log-neighbor-changes"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1f
+
+ elif(bgpArg1 == "maxas-limit"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " "
+ value = checkSanityofVariable(deviceType, "maxas_limit_as", bgpArg2)
+ if(value == "ok"):
+ command = command + bgpArg2
+ else:
+ retVal = "Error-188"
+ return retVal
+
+ elif(bgpArg1 == "neighbor"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "neighbor_ipaddress", bgpArg2)
+ # retVal = "Error-102"
+ # return retVal
+ if(value == "ok"):
+ command = command + bgpArg2
+ if(bgpArg3 is not None):
+ command = command + " remote-as "
+ value = checkSanityofVariable(
+ deviceType, "neighbor_as", bgpArg3)
+ if(value == "ok"):
+ command = command + bgpArg3 + "\n"
+ # debugOutput(command)
+ retVal = waitForDeviceResponse(
+ command, "(config-router-neighbor)#", timeout, obj)
+ retVal = retVal + bgpNeighborConfig(
+ obj, deviceType, "(config-router-neighbor)#",
+ timeout, bgpArg4, bgpAgr5, bgpArg6, bgpArg7, bgpArg8)
+ return retVal
+ else:
+ retVal = "Error-189"
+ return retVal
+
+ elif(bgpArg1 == "router-id"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " "
+ value = checkSanityofVariable(deviceType, "router_id", bgpArg2)
+ if(value == "ok"):
+ command = command + bgpArg2
+ else:
+ retVal = "Error-190"
+ return retVal
+
+ elif(bgpArg1 == "shutdown"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1
+
+ elif(bgpArg1 == "synchronization"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1
+
+ elif(bgpArg1 == "timers"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " bgp "
+ value = checkSanityofVariable(
+ deviceType, "bgp_keepalive_interval", bgpArg2)
+ if(value == "ok"):
+ command = command + bgpArg2
+ else:
+ retVal = "Error-191"
+ return retVal
+ if(bgpArg3 is not None):
+ value = checkSanityofVariable(deviceType, "bgp_holdtime", bgpArg3)
+ if(value == "ok"):
+ command = command + " " + bgpArg3
+ else:
+ retVal = "Error-192"
+ return retVal
+ else:
+ retVal = "Error-192"
+ return retVal
+
+ elif(bgpArg1 == "vrf"):
+ # debugOutput(bgpArg1)
+ command = command + bgpArg1 + " default"
+ else:
+ # debugOutput(bgpArg1)
+ retVal = "Error-192"
+ return retVal
+ command = command + "\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, prompt, timeout, obj)
+ # Come back to config mode
+ command = "exit \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "(config)#", timeout, obj)
+
+ return retVal
+# EOM
+
+
+def vlanConfig(
+ obj, deviceType, prompt, timeout, vlanArg1, vlanArg2, vlanArg3,
+ vlanArg4, vlanArg5):
+
+ retVal = ""
+ # Wait time to get response from server
+ timeout = timeout
+ # vlan config command happens here.
+ command = "vlan "
+
+ if(vlanArg1 == "access-map"):
+ # debugOutput("access-map ")
+ command = command + vlanArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_access_map_name", vlanArg2)
+ if(value == "ok"):
+ command = command + vlanArg2 + " \n"
+ # debugOutput(command)
+ retVal = waitForDeviceResponse(
+ command, "(config-access-map)#", timeout, obj)
+ retVal = retVal + vlanAccessMapConfig(
+ obj, deviceType, "(config-access-map)#", timeout, vlanArg3,
+ vlanArg4, vlanArg5)
+ return retVal
+ else:
+ retVal = "Error-130"
+ return retVal
+
+ elif(vlanArg1 == "dot1q"):
+ # debugOutput("dot1q")
+ command = command + vlanArg1 + " tag native "
+ if(vlanArg2 is not None):
+ value = checkSanityofVariable(
+ deviceType, "vlan_dot1q_tag", vlanArg2)
+ if(value == "ok"):
+ command = command + vlanArg2
+ else:
+ retVal = "Error-131"
+ return retVal
+
+ elif(vlanArg1 == "filter"):
+ # debugOutput( "filter")
+ command = command + vlanArg1 + " "
+ if(vlanArg2 is not None):
+ value = checkSanityofVariable(
+ deviceType, "vlan_filter_name", vlanArg2)
+ if(value == "ok"):
+ command = command + vlanArg2 + " vlan-list "
+ value = checkSanityofVariable(deviceType, "vlan_id", vlanArg3)
+ if(value == "ok"):
+ command = command + vlanArg3
+ else:
+ value = checkSanityofVariable(
+ deviceType, "vlan_id_range", vlanArg3)
+ if(value == "ok"):
+ command = command + vlanArg3
+ else:
+ retVal = "ERROR-133"
+ return retVal
+ else:
+ retVal = "Error-132"
+ return retVal
+
+ else:
+ value = checkSanityofVariable(deviceType, "vlan_id", vlanArg1)
+ if(value == "ok"):
+ retVal = createVlan(obj, deviceType, "(config-vlan)#",
+ timeout, vlanArg1, vlanArg2, vlanArg3,
+ vlanArg4, vlanArg5)
+ return retVal
+ else:
+ value = checkSanityofVariable(
+ deviceType, "vlan_id_range", vlanArg1)
+ if(value == "ok"):
+ retVal = createVlan(obj, deviceType, "(config-vlan)#",
+ timeout, vlanArg1, vlanArg2, vlanArg3,
+ vlanArg4, vlanArg5)
+ return retVal
+ retVal = "Error-133"
+ return retVal
+ retVal = "Error-134"
+ return retVal
+
+ # debugOutput(command)
+ command = command + "\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, prompt, timeout, obj)
+ return retVal
+# EOM
+
+
+def vlanAccessMapConfig(
+ obj, deviceType, prompt, timeout, vlanArg3, vlanArg4, vlanArg5):
+ retVal = ""
+ # Wait time to get response from server
+ timeout = timeout
+ command = ""
+ if(vlanArg3 == "action"):
+ command = command + vlanArg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_accessmap_action", vlanArg4)
+ if(value == "ok"):
+ command = command + vlanArg4
+ else:
+ retVal = "Error-135"
+ return retVal
+ elif(vlanArg3 == "match"):
+ command = command + vlanArg3 + " "
+ if(vlanArg4 == "ip" or vlanArg4 == "mac"):
+ command = command + vlanArg4 + " address "
+ value = checkSanityofVariable(
+ deviceType, "vlan_access_map_name", vlanArg5)
+ if(value == "ok"):
+ command = command + vlanArg5
+ else:
+ retVal = "Error-136"
+ return retVal
+ else:
+ retVal = "Error-137"
+ return retVal
+ elif(vlanArg3 == "statistics"):
+ command = vlanArg3 + " per-entry"
+ else:
+ retVal = "Error-138"
+ return retVal
+
+ command = command + "\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, prompt, timeout, obj)
+ return retVal
+# EOM
+
+
+# Utility Method to create vlan
+def createVlan(
+ obj, deviceType, prompt, timeout, vlanArg1, vlanArg2, vlanArg3,
+ vlanArg4, vlanArg5):
+
+ # vlan config command happens here. It creates if not present
+ command = "vlan " + vlanArg1 + "\n"
+ # debugOutput(command)
+ retVal = waitForDeviceResponse(command, prompt, timeout, obj)
+ command = ""
+ if(vlanArg2 == "name"):
+ # debugOutput("name")
+ command = vlanArg2 + " "
+ value = checkSanityofVariable(deviceType, "vlan_name", vlanArg3)
+ if(value == "ok"):
+ command = command + vlanArg3
+ else:
+ retVal = "Error-139"
+ return retVal
+ elif (vlanArg2 == "flood"):
+ # debugOutput("flood")
+ command = vlanArg2 + " "
+ value = checkSanityofVariable(deviceType, "vlan_flood", vlanArg3)
+ if(value == "ok"):
+ command = command + vlanArg3
+ else:
+ retVal = "Error-140"
+ return retVal
+
+ elif(vlanArg2 == "state"):
+ # debugOutput("state")
+ command = vlanArg2 + " "
+ value = checkSanityofVariable(deviceType, "vlan_state", vlanArg3)
+ if(value == "ok"):
+ command = command + vlanArg3
+ else:
+ retVal = "Error-141"
+ return retVal
+
+ elif(vlanArg2 == "ip"):
+ # debugOutput("ip")
+ command = vlanArg2 + " igmp snooping "
+ # debugOutput("vlanArg3")
+ if(vlanArg3 is None or vlanArg3 == ""):
+ # debugOutput("None or empty")
+ command = command
+ elif(vlanArg3 == "fast-leave"):
+ # debugOutput("fast-leave")
+ command = command + vlanArg3
+
+ elif (vlanArg3 == "last-member-query-interval"):
+ # debugOutput("last-member-query-interval")
+ command = command + vlanArg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_last_member_query_interval", vlanArg4)
+ if(value == "ok"):
+ command = command + vlanArg4
+ else:
+ retVal = "Error-142"
+ return retVal
+
+ elif (vlanArg3 == "querier"):
+ # debugOutput("querier")
+ command = command + vlanArg3 + " "
+ value = checkSanityofVariable(deviceType, "vlan_querier", vlanArg4)
+ if(value == "ok"):
+ command = command + vlanArg4
+ else:
+ retVal = "Error-143"
+ return retVal
+ elif (vlanArg3 == "querier-timeout"):
+ # debugOutput("querier-timeout")
+ command = command + vlanArg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_querier_timeout", vlanArg4)
+ if(value == "ok"):
+ command = command + vlanArg4
+ else:
+ retVal = "Error-144"
+ return retVal
+ elif (vlanArg3 == "query-interval"):
+ # debugOutput("query-interval")
+ command = command + vlanArg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_query_interval", vlanArg4)
+ if(value == "ok"):
+ command = command + vlanArg4
+ else:
+ retVal = "Error-145"
+ return retVal
+ elif (vlanArg3 == "query-max-response-time"):
+ # debugOutput("query-max-response-time")
+ command = command + vlanArg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_query_max_response_time", vlanArg4)
+ if(value == "ok"):
+ command = command + vlanArg4
+ else:
+ retVal = "Error-146"
+ return retVal
+ elif (vlanArg3 == "report-suppression"):
+ # debugOutput("report-suppression")
+ command = command + vlanArg3
+
+ elif (vlanArg3 == "robustness-variable"):
+ # debugOutput("robustness-variable")
+ command = command + vlanArg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_robustness_variable", vlanArg4)
+ if(value == "ok"):
+ command = command + vlanArg4
+ else:
+ retVal = "Error-147"
+ return retVal
+ elif (vlanArg3 == "startup-query-count"):
+ # debugOutput("startup-query-count")
+ command = command + vlanArg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_startup_query_count", vlanArg4)
+ if(value == "ok"):
+ command = command + vlanArg4
+ else:
+ retVal = "Error-148"
+ return retVal
+ elif (vlanArg3 == "startup-query-interval"):
+ # debugOutput("startup-query-interval")
+ command = command + vlanArg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_startup_query_interval", vlanArg4)
+ if(value == "ok"):
+ command = command + vlanArg4
+ else:
+ retVal = "Error-149"
+ return retVal
+ elif (vlanArg3 == "static-group"):
+ # debugOutput("static-group")
+ # command = command + vlanArg3 + " "
+ # value = checkSanityofVariable(deviceType, variableId, vlanArg4)
+ # if(value == "ok"):
+ # command = command + vlanArg4
+
+ # else :
+ retVal = "Error-102"
+ return retVal
+ elif (vlanArg3 == "version"):
+ # debugOutput("version")
+ command = command + vlanArg3 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_snooping_version", vlanArg4)
+ if(value == "ok"):
+ command = command + vlanArg4
+ else:
+ retVal = "Error-150"
+ return retVal
+ elif (vlanArg3 == "mrouter"):
+ # debugOutput("mrouter")
+ command = command + vlanArg3 + " interface "
+ if(vlanArg4 == "ethernet"):
+ command = command + vlanArg4 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_ethernet_interface", vlanArg5)
+ if(value == "ok"):
+ command = command + vlanArg5
+ else:
+ retVal = "Error-151"
+ return retVal
+ elif(vlanArg4 == "port-aggregation"):
+ command = command + vlanArg4 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlan_portagg_number", vlanArg5)
+ if(value == "ok"):
+ command = command + vlanArg5
+ else:
+ retVal = "Error-152"
+ return retVal
+ else:
+ retVal = "Error-153"
+ return retVal
+ else:
+ command = command + vlanArg3
+
+ else:
+ retVal = "Error-154"
+ return retVal
+ command = command + "\n"
+ # debugOutput(command)
+ retVal = retVal + "\n" + \
+ waitForDeviceResponse(command, prompt, timeout, obj)
+ # Come back to config mode
+ command = "exit \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "(config)#", timeout, obj)
+
+ return retVal
+# EOM
+
+
+def vlagConfig(
+ obj, deviceType, prompt, timeout, vlagArg1, vlagArg2, vlagArg3,
+ vlagArg4):
+
+ retVal = ""
+ # Wait time to get response from server
+ timeout = timeout
+ # vlag config command happens here.
+ command = "vlag "
+
+ if(vlagArg1 == "enable"):
+ # debugOutput("enable")
+ command = command + vlagArg1 + " "
+
+ elif(vlagArg1 == "auto-recovery"):
+ # debugOutput("auto-recovery")
+ command = command + vlagArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlag_auto_recovery", vlagArg2)
+ if(value == "ok"):
+ command = command + vlagArg2
+ else:
+ retVal = "Error-160"
+ return retVal
+
+ elif(vlagArg1 == "config-consistency"):
+ # debugOutput("config-consistency")
+ command = command + vlagArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlag_config_consistency", vlagArg2)
+ if(value == "ok"):
+ command = command + vlagArg2
+ else:
+ retVal = "Error-161"
+ return retVal
+
+ elif(vlagArg1 == "isl"):
+ # debugOutput("isl")
+ command = command + vlagArg1 + " port-aggregation "
+ value = checkSanityofVariable(
+ deviceType, "vlag_port_aggregation", vlagArg2)
+ if(value == "ok"):
+ command = command + vlagArg2
+ else:
+ retVal = "Error-162"
+ return retVal
+
+ elif(vlagArg1 == "mac-address-table"):
+ # debugOutput("mac-address-table")
+ command = command + vlagArg1 + " refresh"
+
+ elif(vlagArg1 == "peer-gateway"):
+ # debugOutput("peer-gateway")
+ command = command + vlagArg1 + " "
+
+ elif(vlagArg1 == "priority"):
+ # debugOutput("priority")
+ command = command + vlagArg1 + " "
+ value = checkSanityofVariable(deviceType, "vlag_priority", vlagArg2)
+ if(value == "ok"):
+ command = command + vlagArg2
+ else:
+ retVal = "Error-163"
+ return retVal
+
+ elif(vlagArg1 == "startup-delay"):
+ # debugOutput("startup-delay")
+ command = command + vlagArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlag_startup_delay", vlagArg2)
+ if(value == "ok"):
+ command = command + vlagArg2
+ else:
+ retVal = "Error-164"
+ return retVal
+
+ elif(vlagArg1 == "tier-id"):
+ # debugOutput("tier-id")
+ command = command + vlagArg1 + " "
+ value = checkSanityofVariable(deviceType, "vlag_tier_id", vlagArg2)
+ if(value == "ok"):
+ command = command + vlagArg2
+ else:
+ retVal = "Error-165"
+ return retVal
+
+ elif(vlagArg1 == "vrrp"):
+ # debugOutput("vrrp")
+ command = command + vlagArg1 + " active"
+
+ elif(vlagArg1 == "instance"):
+ # debugOutput("instance")
+ command = command + vlagArg1 + " "
+ value = checkSanityofVariable(deviceType, "vlag_instance", vlagArg2)
+ if(value == "ok"):
+ command = command + vlagArg2
+ if(vlagArg3 is not None):
+ command = command + " port-aggregation "
+ value = checkSanityofVariable(
+ deviceType, "vlag_port_aggregation", vlagArg3)
+ if(value == "ok"):
+ command = command + vlagArg3
+ else:
+ retVal = "Error-162"
+ return retVal
+ else:
+ command = command + " enable "
+ else:
+ retVal = "Error-166"
+ return retVal
+
+ elif(vlagArg1 == "hlthchk"):
+ # debugOutput("hlthchk")
+ command = command + vlagArg1 + " "
+ value = checkSanityofVariable(
+ deviceType, "vlag_hlthchk_options", vlagArg2)
+ if(value == "ok"):
+ if(vlagArg2 == "keepalive-attempts"):
+ value = checkSanityofVariable(
+ deviceType, "vlag_keepalive_attempts", vlagArg3)
+ if(value == "ok"):
+ command = command + vlagArg2 + " " + vlagArg3
+ else:
+ retVal = "Error-167"
+ return retVal
+ elif(vlagArg2 == "keepalive-interval"):
+ value = checkSanityofVariable(
+ deviceType, "vlag_keepalive_interval", vlagArg3)
+ if(value == "ok"):
+ command = command + vlagArg2 + " " + vlagArg3
+ else:
+ retVal = "Error-168"
+ return retVal
+ elif(vlagArg2 == "retry-interval"):
+ value = checkSanityofVariable(
+ deviceType, "vlag_retry_interval", vlagArg3)
+ if(value == "ok"):
+ command = command + vlagArg2 + " " + vlagArg3
+ else:
+ retVal = "Error-169"
+ return retVal
+ elif(vlagArg2 == "peer-ip"):
+ # Here I am not taking care of IPV6 option.
+ value = checkSanityofVariable(
+ deviceType, "vlag_peerip", vlagArg3)
+ if(value == "ok"):
+ command = command + vlagArg2 + " " + vlagArg3
+ if(vlagArg4 is not None):
+ value = checkSanityofVariable(
+ deviceType, "vlag_peerip_vrf", vlagArg4)
+ if(value == "ok"):
+ command = command + " vrf " + vlagArg4
+ else:
+ retVal = "Error-170"
+ return retVal
+ else:
+ retVal = "Error-171"
+ return retVal
+
+ else:
+ retVal = "Error-172"
+ return retVal
+
+ # debugOutput(command)
+ command = command + "\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "(config)#", timeout, obj)
+
+ return retVal
+# EOM
+
+# Utility Method to back up the start up config
+# This method supports only TFTP or FTP
+# Tuning of timeout parameter is pending
+
+
+def doStartupConfigBackUp(
+ protocol, timeout, confServerIp, confPath, confServerUser,
+ confServerPwd, obj):
+ # server = "10.241.105.214"
+ server = confServerIp
+
+ # username = "pbhosale"
+ username = confServerUser
+
+ # password = "Lab4man1"
+ password = confServerPwd
+
+ path = "cnos_config"
+ if((confPath is not None) & (confPath != "")):
+ path = confPath
+
+ retVal = ""
+
+ # config backup command happens here
+ if(protocol == "ftp"):
+ command = "cp startup-config " + protocol + " " + protocol + "://" + \
+ username + "@" + server + "/" + path + " vrf management\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
+ elif(protocol == "tftp"):
+ command = "cp startup-config " + protocol + " " + protocol + \
+ "://" + server + "/" + path + " vrf management\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "#", 3, obj)
+ else:
+ return "Error-110"
+
+ return retVal
+# EOM
+
+# Utility Method to back up the start up config
+# This method supports only SCP or SFTP
+# Tuning of timeout parameter is pending
+
+
+def doSecureStartupConfigBackUp(
+ protocol, timeout, confServerIp, confPath, confServerUser,
+ confServerPwd, obj):
+ # server = "10.241.105.214"
+ server = confServerIp
+
+ # username = "pbhosale"
+ username = confServerUser
+
+ # password = "Lab4man1"
+ password = confServerPwd
+
+ path = "cnos_config"
+ if((confPath is not None) and (confPath != "")):
+ path = confPath
+
+ retVal = ""
+
+ # config backup command happens here
+ command = "cp startup-config " + protocol + " " + protocol + "://" + \
+ username + "@" + server + "/" + path + " vrf management\n"
+ # debugOutput(command)
+ response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
+ if(response.lower().find("error-101")):
+ command = password + "\n"
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+ return retVal
+ retVal = retVal + response
+ if(protocol == "scp"):
+ command = "yes \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "timeout:", 3, obj)
+ command = "0\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ elif(protocol == "sftp"):
+ command = "yes \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ else:
+ return "Error-110"
+
+ # Password entry happens here
+ # debugOutput(command)
+ command = password + "\n"
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+
+ return retVal
+# EOM
+
+# Utility Method to restore the Running config
+# This method supports only TFTP or FTP
+# Tuning of timeout parameter is pending
+
+
+def doStartUpConfigRollback(
+ protocol, timeout, confServerIp, confPath, confServerUser,
+ confServerPwd, obj):
+ # server = "10.241.105.214"
+ server = confServerIp
+
+ # username = "pbhosale"
+ username = confServerUser
+
+ # password = "Lab4man1"
+ password = confServerPwd
+
+ path = "cnos_config"
+ if((confPath is not None) & (confPath != "")):
+ path = confPath
+
+ retVal = ""
+
+ # config backup command happens here
+ if(protocol == "ftp"):
+ command = "cp " + protocol + " " + protocol + "://" + username + \
+ "@" + server + "/" + path + " startup-config vrf management\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "[n]", timeout, obj)
+ command = "y\n"
+ retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
+ elif(protocol == "tftp"):
+ command = "cp " + protocol + " " + protocol + "://" + \
+ server + "/" + path + " startup-config vrf management\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "[n]", timeout, obj)
+ command = "y\n"
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+ else:
+ return "Error-110"
+
+ return retVal
+# EOM
+
+# Utility Method to restore the start up config
+# This method supports only SCP or SFTP
+# Tuning of timeout parameter is pending
+
+
+def doSecureStartUpConfigRollback(
+ protocol, timeout, confServerIp, confPath, confServerUser,
+ confServerPwd, obj):
+ # server = "10.241.105.214"
+ server = confServerIp
+
+ # username = "pbhosale"
+ username = confServerUser
+
+ # password = "Lab4man1"
+ password = confServerPwd
+
+ path = "cnos_config"
+ if((confPath is not None) and (confPath != "")):
+ path = confPath
+
+ retVal = ""
+
+ # config backup command happens here
+
+ # cp sftp sftp://root@10.241.106.118/cnos_config/running_config.conf
+ # startup-config vrf management
+ command = "cp " + protocol + " " + protocol + "://" + username + \
+ "@" + server + "/" + path + " startup-config vrf management \n"
+
+ # debugOutput(command)
+ response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
+ if(response.lower().find("error-101")):
+ command = password + "\n"
+ retVal = retVal + waitForDeviceResponse(command, "[n]", timeout, obj)
+ command = "y\n"
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+ return retVal
+ retVal = retVal + response
+ if(protocol == "scp"):
+ command = "yes \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "timeout:", 3, obj)
+ command = "0\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ elif(protocol == "sftp"):
+ command = "yes \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ else:
+ return "Error-110"
+
+ # Password entry happens here
+ # debugOutput(command)
+ command = password + "\n"
+ retVal = retVal + waitForDeviceResponse(command, "[n]", timeout, obj)
+ command = "y\n"
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+
+ return retVal
+# EOM
+
+# Utility Method to back up the Running config
+# This method supports only TFTP or FTP
+# Tuning of timeout parameter is pending
+
+
+def doRunningConfigBackUp(
+ protocol, timeout, confServerIp, confPath, confServerUser,
+ confServerPwd, obj):
+ # server = "10.241.105.214"
+ server = confServerIp
+
+ # username = "pbhosale"
+ username = confServerUser
+
+ # password = "Lab4man1"
+ password = confServerPwd
+
+ path = "cnos_config"
+ if((confPath is not None) & (confPath != "")):
+ path = confPath
+
+ retVal = ""
+
+ # config backup command happens here
+ if(protocol == "ftp"):
+ command = "cp running-config " + protocol + " " + protocol + "://" + \
+ username + "@" + server + "/" + path + " vrf management\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
+ elif(protocol == "tftp"):
+ command = "cp running-config " + protocol + " " + protocol + \
+ "://" + server + "/" + path + " vrf management\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "#", 3, obj)
+ else:
+ return "Error-110"
+
+ return retVal
+# EOM
+
+
+# Utility Method to back up the running config
+# This method supports only SCP or SFTP
+# Tuning of timeout parameter is pending
+def doSecureRunningConfigBackUp(
+ protocol, timeout, confServerIp, confPath, confServerUser,
+ confServerPwd, obj):
+ # server = "10.241.105.214"
+ server = confServerIp
+
+ # username = "pbhosale"
+ username = confServerUser
+
+ # password = "Lab4man1"
+ password = confServerPwd
+
+ path = "cnos_config"
+ if((confPath is not None) and (confPath != "")):
+ path = confPath
+
+ retVal = ""
+
+ # config backup command happens here
+ command = "cp running-config " + protocol + " " + protocol + "://" + \
+ username + "@" + server + "/" + path + " vrf management\n"
+ # debugOutput(command)
+ response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
+ if(response.lower().find("error-101")):
+ command = password + "\n"
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+ return retVal
+ retVal = retVal + response
+ if(protocol == "scp"):
+ command = "yes \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "timeout:", 3, obj)
+ command = "0\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ elif(protocol == "sftp"):
+ command = "yes \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ else:
+ return "Error-110"
+
+ # Password entry happens here
+ # debugOutput(command)
+ command = password + "\n"
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+
+ return retVal
+# EOM
+
+# Utility Method to restore the Running config
+# This method supports only TFTP or FTP
+# Tuning of timeout parameter is pending
+
+
+def doRunningConfigRollback(
+ protocol, timeout, confServerIp, confPath, confServerUser,
+ confServerPwd, obj):
+ # server = "10.241.105.214"
+ server = confServerIp
+
+ # username = "pbhosale"
+ username = confServerUser
+
+ # password = "Lab4man1"
+ password = confServerPwd
+
+ path = "cnos_config"
+ if((confPath is not None) & (confPath != "")):
+ path = confPath
+
+ retVal = ""
+
+ # config backup command happens here
+ if(protocol == "ftp"):
+ command = "cp " + protocol + " " + protocol + "://" + username + \
+ "@" + server + "/" + path + " running-config vrf management\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(password, "#", timeout, obj)
+ elif(protocol == "tftp"):
+ command = "cp " + protocol + " " + protocol + "://" + \
+ server + "/" + path + " running-config vrf management\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+ else:
+ return "Error-110"
+
+ return retVal
+# EOM
+
+# Utility Method to restore the running config
+# This method supports only SCP or SFTP
+# Tuning of timeout parameter is pending
+
+
+def doSecureRunningConfigRollback(
+ protocol, timeout, confServerIp, confPath, confServerUser,
+ confServerPwd, obj):
+ # server = "10.241.105.214"
+ server = confServerIp
+
+ # username = "pbhosale"
+ username = confServerUser
+
+ # password = "Lab4man1"
+ password = confServerPwd
+
+ path = "cnos_config"
+ if((confPath is not None) and (confPath != "")):
+ path = confPath
+
+ retVal = ""
+
+ # config backup command happens here
+
+ # cp sftp sftp://root@10.241.106.118/cnos_config/running_config.conf
+ # running-config vrf management
+ command = "cp " + protocol + " " + protocol + "://" + username + \
+ "@" + server + "/" + path + " running-config vrf management \n"
+
+ # debugOutput(command)
+ response = waitForDeviceResponse(command, "(yes/no)", 3, obj)
+ if(response.lower().find("error-101")):
+ command = password + "\n"
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+ return retVal
+ retVal = retVal + response
+
+ if(protocol == "scp"):
+ command = "yes \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "timeout:", 3, obj)
+ command = "0\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ elif(protocol == "sftp"):
+ command = "yes \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ else:
+ return "Error-110"
+
+ # Password entry happens here
+ # debugOutput(command)
+ command = password + "\n"
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+
+ return retVal
+# EOM
+
+# Utility Method to download an image from FTP/TFTP server to device.
+# This method supports only FTP or TFTP
+# Tuning of timeout parameter is pending
+
+
+def doImageTransfer(
+ protocol, timeout, imgServerIp, imgPath, imgType, imgServerUser,
+ imgServerPwd, obj):
+ # server = "10.241.106.118"
+ server = imgServerIp
+ # username = "root"
+ username = imgServerUser
+ # password = "root123"
+ password = imgServerPwd
+
+ type = "os"
+ if(imgType is not None):
+ type = imgType.lower()
+
+ path = "cnos_images"
+ if((imgPath is not None) and (imgPath != "")):
+ path = imgPath
+
+ retVal = ""
+
+ # Image transfer command happens here
+ if(protocol == "ftp"):
+ command = "cp " + protocol + " " + protocol + "://" + username + \
+ "@" + server + "/" + path + " system-image " + type + \
+ " vrf management\n"
+ elif(protocol == "tftp"):
+ command = "cp " + protocol + " " + protocol + "://" + server + \
+ "/" + path + " system-image " + type + " vrf management\n"
+ else:
+ return "Error-110"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "[n]", 3, obj)
+ # Confirmation command happens here
+ command = "y\n"
+ # debugOutput(command)
+ # retVal = retVal+ waitForDeviceResponse(command, "(yes/no)?", 3, obj)
+ # command = "Yes \n"
+ # debugOutput(command)
+ if(protocol == "ftp"):
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ # Password entry happens here Only for FTP
+ command = password + " \n"
+ # debugOutput(command)
+ # Change to standby image y
+ retVal = retVal + waitForDeviceResponse(command, "[n]", timeout, obj)
+ command = "y\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+ return retVal
+# EOM
+
+# Utility Method to download an image from SFTP/SCP server to device.
+# This method supports only SCP or SFTP
+# Tuning of timeout parameter is pending
+
+
+def doSecureImageTransfer(
+ protocol, timeout, imgServerIp, imgPath, imgType, imgServerUser,
+ imgServerPwd, obj):
+ # server = "10.241.105.214"
+ server = imgServerIp
+ # username = "pbhosale"
+ username = imgServerUser
+ # password = "Lab4man1"
+ password = imgServerPwd
+
+ type = "scp"
+ if(imgType is not None):
+ type = imgType.lower()
+
+ path = "cnos_images"
+ if((imgPath is not None) and(imgPath != "")):
+ path = imgPath
+
+ retVal = ""
+
+ # Image transfer command happens here
+ command = "cp " + protocol + " " + protocol + "://" + username + "@" + \
+ server + "/" + path + " system-image " + type + " vrf management \n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "[n]", 3, obj)
+ # Confirmation command happens here
+ if(protocol == "scp"):
+ command = "y\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "(yes/no)?", 3, obj)
+ command = "Yes\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "timeout:", 3, obj)
+ command = "0\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ elif(protocol == "sftp"):
+ command = "y\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "(yes/no)?", 3, obj)
+ command = "Yes\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "Password:", 3, obj)
+ else:
+ return "Error-110"
+
+ # Password entry happens here
+ command = password + "\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "[n]", timeout, obj)
+ # Change to standby image y
+ command = "y\n"
+ # debugOutput(command)
+ retVal = retVal + waitForDeviceResponse(command, "#", timeout, obj)
+ return retVal
+# EOM
+
+# Method to find whether image is there in server or not
+# This is not complete. Need to figure out How to do for SCP and SFTP
+
+
+def checkServerForImage(protocol, ipaddress, folder, username, password):
+ # server = "10.241.105.214"
+ server = ipaddress
+ # username = "pbhosale"
+ username = username
+ # password = "Lab4man1"
+ password = password
+ imageDir = "cnos_images"
+ output = 0
+ try:
+ ftp = ftplib.FTP(server)
+ ftp.login(username, password)
+ except Exception:
+ # debugOutput e
+ return 1
+ else:
+ filelist = [] # to store all files
+ ftp.retrlines('NLST', filelist.append) # append to list
+ num = 0
+ for f in filelist:
+ # debugOutput f
+ if(f == imageDir):
+ num = 1
+ if(num == 0):
+ resp = ftp.mkd(imageDir)
+ if(resp != imageDir):
+ return 1
+ return output
+# EOM
+
+# Method for device response than time delay
+#
+
+
+def enterEnableModeForDevice(enablePassword, timeout, obj):
+ command = "enable\n"
+ pwdPrompt = "password:"
+ # debugOutput(enablePassword)
+ # debugOutput('\n')
+ obj.settimeout(int(timeout))
+ # Executing enable
+ obj.send(command)
+ flag = False
+ retVal = ""
+ count = 5
+ while (flag is False):
+ # If wait time is execeeded.
+ if(count == 0):
+ flag = True
+ else:
+ count = count - 1
+ # A delay of one second
+ time.sleep(1)
+ try:
+ buffByte = obj.recv(9999)
+ buff = buffByte.decode()
+ retVal = retVal + buff
+ # debugOutput(buff)
+ gotit = buff.find(pwdPrompt)
+ if(gotit != -1):
+ time.sleep(1)
+ if(enablePassword is None or enablePassword == ""):
+ return "\n Error-106"
+ obj.send(enablePassword)
+ obj.send("\r")
+ obj.send("\n")
+ time.sleep(1)
+ innerBuffByte = obj.recv(9999)
+ innerBuff = innerBuffByte.decode()
+ retVal = retVal + innerBuff
+ # debugOutput(innerBuff)
+ innerGotit = innerBuff.find("#")
+ if(innerGotit != -1):
+ return retVal
+ else:
+ gotit = buff.find("#")
+ if(gotit != -1):
+ return retVal
+ except:
+ retVal = retVal + "\n Error-101"
+ flag = True
+ if(retVal == ""):
+ retVal = "\n Error-101"
+ return retVal
+# EOM
+
+# Method for device response than time delay
+#
+
+
+def waitForDeviceResponse(command, prompt, timeout, obj):
+ obj.settimeout(int(timeout))
+ obj.send(command)
+ flag = False
+ retVal = ""
+ while (flag is False):
+ time.sleep(1)
+ try:
+ buffByte = obj.recv(9999)
+ buff = buffByte.decode()
+ retVal = retVal + buff
+ # debugOutput(retVal)
+ gotit = buff.find(prompt)
+ if(gotit != -1):
+ flag = True
+ except:
+ retVal = retVal + "\n Error-101"
+ flag = True
+ return retVal
+# EOM
+
+
+def checkOutputForError(output):
+ retVal = ""
+ index = output.lower().find("error")
+ startIndex = index + 6
+ if(index == -1):
+ index = output.lower().find("invalid")
+ startIndex = index + 8
+ if(index == -1):
+ index = output.lower().find("incorrect")
+ startIndex = index + 9
+ if(index == -1):
+ index = output.lower().find("failure")
+ startIndex = index + 8
+ if(index == -1):
+ return None
+
+ endIndex = startIndex + 3
+ errorCode = output[startIndex:endIndex]
+ result = errorCode.isdigit()
+ if(result is not True):
+ return "Device returned an Error. Please check Results for more \
+ information"
+
+ errorFile = "dictionary/ErrorCodes.lvo"
+ try:
+ # with open(errorFile, 'r') as f:
+ f = open(errorFile, 'r')
+ for line in f:
+ if('=' in line):
+ data = line.split('=')
+ if(data[0].strip() == errorCode):
+ errorString = data[1].strip()
+ return errorString
+ except Exception:
+ errorString = cnos_errorcodes.getErrorString(errorCode)
+ errorString = errorString.strip()
+ return errorString
+ return "Error Code Not Found"
+# EOM
+
+
+def checkSanityofVariable(deviceType, variableId, variableValue):
+ retVal = ""
+ ruleFile = "dictionary/" + deviceType + "_rules.lvo"
+ ruleString = getRuleStringForVariable(deviceType, ruleFile, variableId)
+ retVal = validateValueAgainstRule(ruleString, variableValue)
+ return retVal
+# EOM
+
+
+def getRuleStringForVariable(deviceType, ruleFile, variableId):
+ retVal = ""
+ try:
+ # with open(ruleFile, 'r') as f:
+ f = open(errorFile, 'r')
+ for line in f:
+ # debugOutput(line)
+ if(':' in line):
+ data = line.split(':')
+ # debugOutput(data[0])
+ if(data[0].strip() == variableId):
+ retVal = line
+ except Exception:
+ ruleString = cnos_devicerules.getRuleString(deviceType, variableId)
+ retVal = ruleString.strip()
+ return retVal
+# EOM
+
+
+def validateValueAgainstRule(ruleString, variableValue):
+
+ retVal = ""
+ if(ruleString == ""):
+ return 1
+ rules = ruleString.split(':')
+ variableType = rules[1].strip()
+ varRange = rules[2].strip()
+ if(variableType == "INTEGER"):
+ result = checkInteger(variableValue)
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-111"
+ elif(variableType == "FLOAT"):
+ result = checkFloat(variableValue)
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-112"
+
+ elif(variableType == "INTEGER_VALUE"):
+ int_range = varRange.split('-')
+ r = range(int(int_range[0].strip()), int(int_range[1].strip()))
+ if(checkInteger(variableValue) is not True):
+ return "Error-111"
+ result = int(variableValue) in r
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-113"
+
+ elif(variableType == "INTEGER_VALUE_RANGE"):
+ int_range = varRange.split('-')
+ varLower = int_range[0].strip()
+ varHigher = int_range[1].strip()
+ r = range(int(varLower), int(varHigher))
+ val_range = variableValue.split('-')
+ try:
+ valLower = val_range[0].strip()
+ valHigher = val_range[1].strip()
+ except Exception:
+ return "Error-113"
+ if((checkInteger(valLower) is not True) or
+ (checkInteger(valHigher) is not True)):
+ # debugOutput("Error-114")
+ return "Error-114"
+ result = (int(valLower) in r) and (int(valHigher)in r) \
+ and (int(valLower) < int(valHigher))
+ if(result is True):
+ return "ok"
+ else:
+ # debugOutput("Error-113")
+ return "Error-113"
+
+ elif(variableType == "INTEGER_OPTIONS"):
+ int_options = varRange.split(',')
+ if(checkInteger(variableValue) is not True):
+ return "Error-111"
+ for opt in int_options:
+ if(opt.strip() is variableValue):
+ result = True
+ break
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-115"
+
+ elif(variableType == "LONG"):
+ result = checkLong(variableValue)
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-116"
+
+ elif(variableType == "LONG_VALUE"):
+ long_range = varRange.split('-')
+ r = range(long(long_range[0].strip()), long(long_range[1].strip()))
+ if(checkLong(variableValue) is not True):
+ # debugOutput(variableValue)
+ return "Error-116"
+ result = long(variableValue) in r
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-113"
+
+ elif(variableType == "LONG_VALUE_RANGE"):
+ long_range = varRange.split('-')
+ r = range(long(long_range[0].strip()), long(long_range[1].strip()))
+ val_range = variableValue.split('-')
+ if((checkLong(val_range[0]) is not True) or
+ (checkLong(val_range[1]) is not True)):
+ return "Error-117"
+ result = (val_range[0] in r) and (
+ val_range[1] in r) and (val_range[0] < val_range[1])
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-113"
+ elif(variableType == "LONG_OPTIONS"):
+ long_options = varRange.split(',')
+ if(checkLong(variableValue) is not True):
+ return "Error-116"
+ for opt in long_options:
+ if(opt.strip() == variableValue):
+ result = True
+ break
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-115"
+
+ elif(variableType == "TEXT"):
+ if(variableValue == ""):
+ return "Error-118"
+ if(True is isinstance(variableValue, str)):
+ return "ok"
+ else:
+ return "Error-119"
+
+ elif(variableType == "NO_VALIDATION"):
+ if(variableValue == ""):
+ return "Error-118"
+ else:
+ return "ok"
+
+ elif(variableType == "TEXT_OR_EMPTY"):
+ if(variableValue is None or variableValue == ""):
+ return "ok"
+ if(result == isinstance(variableValue, str)):
+ return "ok"
+ else:
+ return "Error-119"
+
+ elif(variableType == "MATCH_TEXT"):
+ if(variableValue == ""):
+ return "Error-118"
+ if(isinstance(variableValue, str)):
+ if(varRange == variableValue):
+ return "ok"
+ else:
+ return "Error-120"
+ else:
+ return "Error-119"
+
+ elif(variableType == "MATCH_TEXT_OR_EMPTY"):
+ if(variableValue is None or variableValue == ""):
+ return "ok"
+ if(isinstance(variableValue, str)):
+ if(varRange == variableValue):
+ return "ok"
+ else:
+ return "Error-120"
+ else:
+ return "Error-119"
+
+ elif(variableType == "TEXT_OPTIONS"):
+ str_options = varRange.split(',')
+ if(isinstance(variableValue, str) is not True):
+ return "Error-119"
+ result = False
+ for opt in str_options:
+ if(opt.strip() == variableValue):
+ result = True
+ break
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-115"
+
+ elif(variableType == "TEXT_OPTIONS_OR_EMPTY"):
+ if(variableValue is None or variableValue == ""):
+ return "ok"
+ str_options = varRange.split(',')
+ if(isinstance(variableValue, str) is not True):
+ return "Error-119"
+ for opt in str_options:
+ if(opt.strip() == variableValue):
+ result = True
+ break
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-115"
+
+ elif(variableType == "IPV4Address"):
+ try:
+ socket.inet_pton(socket.AF_INET, variableValue)
+ result = True
+ except socket.Error:
+ result = False
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-121"
+ elif(variableType == "IPV4AddressWithMask"):
+ if(variableValue is None or variableValue == ""):
+ return "Error-119"
+ str_options = variableValue.split('/')
+ ipaddr = str_options[0]
+ mask = str_options[1]
+ try:
+ socket.inet_pton(socket.AF_INET, ipaddr)
+ if(checkInteger(mask) is True):
+ result = True
+ else:
+ result = False
+ except socket.Error:
+ result = False
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-121"
+
+ elif(variableType == "IPV6Address"):
+ try:
+ socket.inet_pton(socket.AF_INET6, variableValue)
+ result = True
+ except socket.Error:
+ result = False
+ if(result is True):
+ return "ok"
+ else:
+ return "Error-122"
+
+ return retVal
+# EOM
+
+
+def disablePaging(remote_conn):
+ remote_conn.send("terminal length 0\n")
+ time.sleep(1)
+ # Clear the buffer on the screen
+ outputByte = remote_conn.recv(1000)
+ output = outputByte.decode()
+ return output
+# EOM
+
+
+def checkInteger(s):
+ try:
+ int(s)
+ return True
+ except ValueError:
+ return False
+# EOM
+
+
+def checkFloat(s):
+ try:
+ float(s)
+ return True
+ except ValueError:
+ return False
+# EOM
+
+
+def checkLong(s):
+ try:
+ long(s)
+ return True
+ except ValueError:
+ return False
+
+
+def debugOutput(command):
+ f = open('debugOuput.txt', 'a')
+ f.write(str(command)) # python will convert \n to os.linesep
+ f.close() # you can omit in most cases as the destructor will call it
+# EOM
diff --git a/lib/ansible/module_utils/cnos_devicerules.py b/lib/ansible/module_utils/cnos_devicerules.py
new file mode 100644
index 00000000000..2908feef70b
--- /dev/null
+++ b/lib/ansible/module_utils/cnos_devicerules.py
@@ -0,0 +1,789 @@
+# This code is part of Ansible, but is an independent component.
+# This particular file snippet, and this file snippet only, is BSD licensed.
+# Modules you write using this snippet, which is embedded dynamically by
+# Ansible still belong to the author of the module, and may assign their
+# own license to the complete work.
+#
+# Copyright (C) 2017 Lenovo, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT 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.
+#
+# Contains device rule and methods
+# Lenovo Networking
+
+
+def getRuleString(deviceType, variableId):
+ retVal = variableId + ":"
+ if(deviceType == 'g8272_cnos'):
+ if variableId in g8272_cnos:
+ retVal = retVal + g8272_cnos[variableId]
+ else:
+ retVal = "The variable " + variableId + " is not supported"
+ elif(deviceType == 'g8296_cnos'):
+ if variableId in g8296_cnos:
+ retVal = retVal + g8296_cnos[variableId]
+ else:
+ retVal = "The variable " + variableId + " is not supported"
+ elif(deviceType == 'g8332_cnos'):
+ if variableId in g8332_cnos:
+ retVal = retVal + g8332_cnos[variableId]
+ else:
+ retVal = "The variable " + variableId + " is not supported"
+ else:
+ if variableId in default_cnos:
+ retVal = retVal + default_cnos[variableId]
+ else:
+ retVal = "The variable " + variableId + " is not supported"
+ return retVal
+# EOM
+
+default_cnos = {'vlan_id': 'INTEGER_VALUE:1-3999',
+ 'vlan_id_range': 'INTEGER_VALUE_RANGE:1-3999',
+ 'vlan_name': 'TEXT:',
+ 'vlan_flood': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'vlan_state': 'TEXT_OPTIONS:active,suspend',
+ 'vlan_last_member_query_interval': 'INTEGER_VALUE:1-25',
+ 'vlan_querier': 'IPV4Address:',
+ 'vlan_querier_timeout': 'INTEGER_VALUE:1-65535',
+ 'vlan_query_interval': 'INTEGER_VALUE:1-18000',
+ 'vlan_query_max_response_time': 'INTEGER_VALUE:1-25',
+ 'vlan_report_suppression': 'INTEGER_VALUE:1-25',
+ 'vlan_robustness_variable': 'INTEGER_VALUE:1-7',
+ 'vlan_startup_query_count': 'INTEGER_VALUE:1-10',
+ 'vlan_startup_query_interval': 'INTEGER_VALUE:1-18000',
+ 'vlan_snooping_version': 'INTEGER_VALUE:2-3',
+ 'vlan_access_map_name': 'TEXT: ',
+ 'vlan_ethernet_interface': 'TEXT:',
+ 'vlan_portagg_number': 'INTEGER_VALUE:1-4096',
+ 'vlan_accessmap_action': 'TEXT_OPTIONS:drop,forward,redirect',
+ 'vlan_dot1q_tag': 'MATCH_TEXT_OR_EMPTY:egress-only',
+ 'vlan_filter_name': 'TEXT:',
+ 'vlag_auto_recovery': 'INTEGER_VALUE:240-3600',
+ 'vlag_config_consistency': 'TEXT_OPTIONS:disable,strict',
+ 'vlag_instance': 'INTEGER_VALUE:1-64',
+ 'vlag_port_aggregation': 'INTEGER_VALUE:1-4096',
+ 'vlag_priority': 'INTEGER_VALUE:0-65535',
+ 'vlag_startup_delay': 'INTEGER_VALUE:0-3600',
+ 'vlag_tier_id': 'INTEGER_VALUE:1-512',
+ 'vlag_hlthchk_options': 'TEXT_OPTIONS:keepalive-attempts,\
+ keepalive-interval,peer-ip,retry-interval',
+ 'vlag_keepalive_attempts': 'INTEGER_VALUE:1-24',
+ 'vlag_keepalive_interval': 'INTEGER_VALUE:2-300',
+ 'vlag_retry_interval': 'INTEGER_VALUE:1-300',
+ 'vlag_peerip': 'IPV4Address:',
+ 'vlag_peerip_vrf': 'TEXT_OPTIONS:default,management',
+ 'bgp_as_number': 'NO_VALIDATION:1-4294967295',
+ 'bgp_address_family': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'bgp_bgp_local_count': 'INTEGER_VALUE:2-64',
+ 'cluster_id_as_ip': 'IPV4Address:',
+ 'cluster_id_as_number': 'NO_VALIDATION:1-4294967295',
+ 'confederation_identifier': 'INTEGER_VALUE:1-65535',
+ 'condeferation_peers_as': 'INTEGER_VALUE:1-65535',
+ 'stalepath_delay_value': 'INTEGER_VALUE:1-3600',
+ 'maxas_limit_as': 'INTEGER_VALUE:1-2000',
+ 'neighbor_ipaddress': 'IPV4Address:',
+ 'neighbor_as': 'NO_VALIDATION:1-4294967295',
+ 'router_id': 'IPV4Address:',
+ 'bgp_keepalive_interval': 'INTEGER_VALUE:0-3600',
+ 'bgp_holdtime': 'INTEGER_VALUE:0-3600',
+ 'bgp_aggregate_prefix': 'IPV4AddressWithMask:',
+ 'addrfamily_routemap_name': 'TEXT:',
+ 'reachability_half_life': 'INTEGER_VALUE:1-45',
+ 'start_reuse_route_value': 'INTEGER_VALUE:1-20000',
+ 'start_suppress_route_value': 'INTEGER_VALUE:1-20000',
+ 'max_duration_to_suppress_route': 'INTEGER_VALUE:1-255',
+ 'unreachability_halftime_for_penalty': 'INTEGER_VALUE:1-45',
+ 'distance_external_AS': 'INTEGER_VALUE:1-255',
+ 'distance_internal_AS': 'INTEGER_VALUE:1-255',
+ 'distance_local_routes': 'INTEGER_VALUE:1-255',
+ 'maxpath_option': 'TEXT_OPTIONS:ebgp,ibgp',
+ 'maxpath_numbers': 'INTEGER_VALUE:2-32',
+ 'network_ip_prefix_with_mask': 'IPV4AddressWithMask:',
+ 'network_ip_prefix_value': 'IPV4Address:',
+ 'network_ip_prefix_mask': 'IPV4Address:',
+ 'nexthop_crtitical_delay': 'NO_VALIDATION:1-4294967295',
+ 'nexthop_noncrtitical_delay': 'NO_VALIDATION:1-4294967295',
+ 'addrfamily_redistribute_option': 'TEXT_OPTIONS:direct,ospf,\
+ static',
+ 'bgp_neighbor_af_occurances': 'INTEGER_VALUE:1-10',
+ 'bgp_neighbor_af_filtername': 'TEXT:',
+ 'bgp_neighbor_af_maxprefix': 'INTEGER_VALUE:1-15870',
+ 'bgp_neighbor_af_prefixname': 'TEXT:',
+ 'bgp_neighbor_af_routemap': 'TEXT:',
+ 'bgp_neighbor_address_family': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'bgp_neighbor_connection_retrytime': 'INTEGER_VALUE:1-65535',
+ 'bgp_neighbor_description': 'TEXT:',
+ 'bgp_neighbor_maxhopcount': 'INTEGER_VALUE:1-255',
+ 'bgp_neighbor_local_as': 'NO_VALIDATION:1-4294967295',
+ 'bgp_neighbor_maxpeers': 'INTEGER_VALUE:1-96',
+ 'bgp_neighbor_password': 'TEXT:',
+ 'bgp_neighbor_timers_Keepalive': 'INTEGER_VALUE:0-3600',
+ 'bgp_neighbor_timers_holdtime': 'INTEGER_VALUE:0-3600',
+ 'bgp_neighbor_ttl_hops': 'INTEGER_VALUE:1-254',
+ 'bgp_neighbor_update_options': 'TEXT_OPTIONS:ethernet,loopback,\
+ vlan',
+ 'bgp_neighbor_update_ethernet': 'TEXT:',
+ 'bgp_neighbor_update_loopback': 'INTEGER_VALUE:0-7',
+ 'bgp_neighbor_update_vlan': 'INTEGER_VALUE:1-4094',
+ 'bgp_neighbor_weight': 'INTEGER_VALUE:0-65535',
+ 'ethernet_interface_value': 'INTEGER_VALUE:1-54',
+ 'ethernet_interface_range': 'INTEGER_VALUE_RANGE:1-54',
+ 'ethernet_interface_string': 'TEXT:',
+ 'loopback_interface_value': 'INTEGER_VALUE:0-7',
+ 'mgmt_interface_value': 'INTEGER_VALUE:0-0',
+ 'vlan_interface_value': 'INTEGER_VALUE:1-4094',
+ 'portchannel_interface_value': 'INTEGER_VALUE:1-4096',
+ 'portchannel_interface_range': 'INTEGER_VALUE_RANGE:1-4096',
+ 'portchannel_interface_string': 'TEXT:',
+ 'aggregation_group_no': 'INTEGER_VALUE:1-4096',
+ 'aggregation_group_mode': 'TEXT_OPTIONS:active,on,passive',
+ 'bfd_options': 'TEXT_OPTIONS:authentication,echo,interval,ipv4,\
+ ipv6,neighbor',
+ 'bfd_interval': 'INTEGER_VALUE:50-999',
+ 'bfd_minrx': 'INTEGER_VALUE:50-999',
+ 'bfd_ multiplier': 'INTEGER_VALUE:3-50',
+ 'bfd_ipv4_options': 'TEXT_OPTIONS:authentication,echo,\
+ interval',
+ 'bfd_auth_options': 'TEXT_OPTIONS:keyed-md5,keyed-sha1,\
+ meticulous-keyed-md5,meticulous-keyed-sha1,simple',
+ 'bfd_key_options': 'TEXT_OPTIONS:key-chain,key-id',
+ 'bfd_key_chain': 'TEXT:',
+ 'bfd_key_id': 'INTEGER_VALUE:0-255',
+ 'bfd_key_name': 'TEXT:',
+ 'bfd_neighbor_ip': 'TEXT:',
+ 'bfd_neighbor_options': 'TEXT_OPTIONS:admin-down,multihop,\
+ non-persistent',
+ 'bfd_access_vlan': 'INTEGER_VALUE:1-3999',
+ 'bfd_bridgeport_mode': 'TEXT_OPTIONS:access,dot1q-tunnel,\
+ trunk',
+ 'trunk_options': 'TEXT_OPTIONS:allowed,native',
+ 'trunk_vlanid': 'INTEGER_VALUE:1-3999',
+ 'portCh_description': 'TEXT:',
+ 'duplex_option': 'TEXT_OPTIONS:auto,full,half',
+ 'flowcontrol_options': 'TEXT_OPTIONS:receive,send',
+ 'portchannel_ip_options': 'TEXT_OPTIONS:access-group,address,\
+ arp,dhcp,ospf,port,port-unreachable,redirects,router,\
+ unreachables',
+ 'accessgroup_name': 'TEXT:',
+ 'portchannel_ipv4': 'IPV4Address:',
+ 'portchannel_ipv4_mask': 'TEXT:',
+ 'arp_ipaddress': 'IPV4Address:',
+ 'arp_macaddress': 'TEXT:',
+ 'arp_timeout_value': 'INTEGER_VALUE:60-28800',
+ 'relay_ipaddress': 'IPV4Address:',
+ 'ip_ospf_options': 'TEXT_OPTIONS:authentication,\
+ authentication-key,bfd,cost,database-filter,dead-interval,\
+ hello-interval,message-digest-key,mtu,mtu-ignore,network,\
+ passive-interface,priority,retransmit-interval,shutdown,\
+ transmit-delay',
+ 'ospf_id_decimal_value': 'NO_VALIDATION:1-4294967295',
+ 'ospf_id_ipaddres_value': 'IPV4Address:',
+ 'lacp_options': 'TEXT_OPTIONS:port-priority,suspend-individual,\
+ timeout',
+ 'port_priority': 'INTEGER_VALUE:1-65535',
+ 'lldp_options': 'TEXT_OPTIONS:receive,tlv-select,transmit,\
+ trap-notification',
+ 'lldp_tlv_options': 'TEXT_OPTIONS:link-aggregation,\
+ mac-phy-status,management-address,max-frame-size,\
+ port-description,port-protocol-vlan,port-vlan,power-mdi,\
+ protocol-identity,system-capabilities,system-description,\
+ system-name,vid-management,vlan-name',
+ 'load_interval_delay': 'INTEGER_VALUE:30-300',
+ 'load_interval_counter': 'INTEGER_VALUE:1-3',
+ 'mac_accessgroup_name': 'TEXT:',
+ 'mac_address': 'TEXT:',
+ 'microburst_threshold': 'NO_VALIDATION:1-4294967295',
+ 'mtu_value': 'INTEGER_VALUE:64-9216',
+ 'service_instance': 'NO_VALIDATION:1-4294967295',
+ 'service_policy_options': 'TEXT_OPTIONS:copp-system-policy,\
+ input,output,type',
+ 'service_policy_name': 'TEXT:',
+ 'spanning_tree_options': 'TEXT_OPTIONS:bpdufilter,bpduguard,\
+ cost,disable,enable,guard,link-type,mst,port,port-priority,\
+ vlan',
+ 'spanning_tree_cost': 'NO_VALIDATION:1-200000000',
+ 'spanning_tree_interfacerange': 'INTEGER_VALUE_RANGE:1-3999',
+ 'spanning_tree_portpriority': 'TEXT_OPTIONS:0,32,64,96,128,160,\
+ 192,224',
+ 'portchannel_ipv6_neighbor_mac': 'TEXT:',
+ 'portchannel_ipv6_neighbor_address': 'IPV6Address:',
+ 'portchannel_ipv6_linklocal': 'IPV6Address:',
+ 'portchannel_ipv6_dhcp_vlan': 'INTEGER_VALUE:1-4094',
+ 'portchannel_ipv6_dhcp_ethernet': 'TEXT:',
+ 'portchannel_ipv6_dhcp': 'IPV6Address:',
+ 'portchannel_ipv6_address': 'IPV6Address:',
+ 'portchannel_ipv6_options': 'TEXT_OPTIONS:address,dhcp,\
+ link-local,nd,neighbor',
+ 'interface_speed': 'TEXT_OPTIONS:1000,10000,40000,auto',
+ 'stormcontrol_options': 'TEXT_OPTIONS:broadcast,multicast,\
+ unicast',
+ 'stormcontrol_level': 'FLOAT:',
+ 'portchannel_dot1q_tag': 'TEXT_OPTIONS:disable,enable,\
+ egress-only',
+ 'vrrp_id': 'INTEGER_VALUE:1-255',
+ }
+
+g8272_cnos = {'vlan_id': 'INTEGER_VALUE:1-3999',
+ 'vlan_id_range': 'INTEGER_VALUE_RANGE:1-3999',
+ 'vlan_name': 'TEXT:',
+ 'vlan_flood': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'vlan_state': 'TEXT_OPTIONS:active,suspend',
+ 'vlan_last_member_query_interval': 'INTEGER_VALUE:1-25',
+ 'vlan_querier': 'IPV4Address:',
+ 'vlan_querier_timeout': 'INTEGER_VALUE:1-65535',
+ 'vlan_query_interval': 'INTEGER_VALUE:1-18000',
+ 'vlan_query_max_response_time': 'INTEGER_VALUE:1-25',
+ 'vlan_report_suppression': 'INTEGER_VALUE:1-25',
+ 'vlan_robustness_variable': 'INTEGER_VALUE:1-7',
+ 'vlan_startup_query_count': 'INTEGER_VALUE:1-10',
+ 'vlan_startup_query_interval': 'INTEGER_VALUE:1-18000',
+ 'vlan_snooping_version': 'INTEGER_VALUE:2-3',
+ 'vlan_access_map_name': 'TEXT: ',
+ 'vlan_ethernet_interface': 'TEXT:',
+ 'vlan_portagg_number': 'INTEGER_VALUE:1-4096',
+ 'vlan_accessmap_action': 'TEXT_OPTIONS:drop,forward,redirect',
+ 'vlan_dot1q_tag': 'MATCH_TEXT_OR_EMPTY:egress-only',
+ 'vlan_filter_name': 'TEXT:',
+ 'vlag_auto_recovery': 'INTEGER_VALUE:240-3600',
+ 'vlag_config_consistency': 'TEXT_OPTIONS:disable,strict',
+ 'vlag_instance': 'INTEGER_VALUE:1-64',
+ 'vlag_port_aggregation': 'INTEGER_VALUE:1-4096',
+ 'vlag_priority': 'INTEGER_VALUE:0-65535',
+ 'vlag_startup_delay': 'INTEGER_VALUE:0-3600',
+ 'vlag_tier_id': 'INTEGER_VALUE:1-512',
+ 'vlag_hlthchk_options': 'TEXT_OPTIONS:keepalive-attempts,\
+ keepalive-interval,peer-ip,retry-interval',
+ 'vlag_keepalive_attempts': 'INTEGER_VALUE:1-24',
+ 'vlag_keepalive_interval': 'INTEGER_VALUE:2-300',
+ 'vlag_retry_interval': 'INTEGER_VALUE:1-300',
+ 'vlag_peerip': 'IPV4Address:',
+ 'vlag_peerip_vrf': 'TEXT_OPTIONS:default,management',
+ 'bgp_as_number': 'NO_VALIDATION:1-4294967295',
+ 'bgp_address_family': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'bgp_bgp_local_count': 'INTEGER_VALUE:2-64',
+ 'cluster_id_as_ip': 'IPV4Address:',
+ 'cluster_id_as_number': 'NO_VALIDATION:1-4294967295',
+ 'confederation_identifier': 'INTEGER_VALUE:1-65535',
+ 'condeferation_peers_as': 'INTEGER_VALUE:1-65535',
+ 'stalepath_delay_value': 'INTEGER_VALUE:1-3600',
+ 'maxas_limit_as': 'INTEGER_VALUE:1-2000',
+ 'neighbor_ipaddress': 'IPV4Address:',
+ 'neighbor_as': 'NO_VALIDATION:1-4294967295',
+ 'router_id': 'IPV4Address:',
+ 'bgp_keepalive_interval': 'INTEGER_VALUE:0-3600',
+ 'bgp_holdtime': 'INTEGER_VALUE:0-3600',
+ 'bgp_aggregate_prefix': 'IPV4AddressWithMask:',
+ 'addrfamily_routemap_name': 'TEXT:',
+ 'reachability_half_life': 'INTEGER_VALUE:1-45',
+ 'start_reuse_route_value': 'INTEGER_VALUE:1-20000',
+ 'start_suppress_route_value': 'INTEGER_VALUE:1-20000',
+ 'max_duration_to_suppress_route': 'INTEGER_VALUE:1-255',
+ 'unreachability_halftime_for_penalty': 'INTEGER_VALUE:1-45',
+ 'distance_external_AS': 'INTEGER_VALUE:1-255',
+ 'distance_internal_AS': 'INTEGER_VALUE:1-255',
+ 'distance_local_routes': 'INTEGER_VALUE:1-255',
+ 'maxpath_option': 'TEXT_OPTIONS:ebgp,ibgp',
+ 'maxpath_numbers': 'INTEGER_VALUE:2-32',
+ 'network_ip_prefix_with_mask': 'IPV4AddressWithMask:',
+ 'network_ip_prefix_value': 'IPV4Address:',
+ 'network_ip_prefix_mask': 'IPV4Address:',
+ 'nexthop_crtitical_delay': 'NO_VALIDATION:1-4294967295',
+ 'nexthop_noncrtitical_delay': 'NO_VALIDATION:1-4294967295',
+ 'addrfamily_redistribute_option': 'TEXT_OPTIONS:direct,ospf,\
+ static',
+ 'bgp_neighbor_af_occurances': 'INTEGER_VALUE:1-10',
+ 'bgp_neighbor_af_filtername': 'TEXT:',
+ 'bgp_neighbor_af_maxprefix': 'INTEGER_VALUE:1-15870',
+ 'bgp_neighbor_af_prefixname': 'TEXT:',
+ 'bgp_neighbor_af_routemap': 'TEXT:',
+ 'bgp_neighbor_address_family': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'bgp_neighbor_connection_retrytime': 'INTEGER_VALUE:1-65535',
+ 'bgp_neighbor_description': 'TEXT:',
+ 'bgp_neighbor_maxhopcount': 'INTEGER_VALUE:1-255',
+ 'bgp_neighbor_local_as': 'NO_VALIDATION:1-4294967295',
+ 'bgp_neighbor_maxpeers': 'INTEGER_VALUE:1-96',
+ 'bgp_neighbor_password': 'TEXT:',
+ 'bgp_neighbor_timers_Keepalive': 'INTEGER_VALUE:0-3600',
+ 'bgp_neighbor_timers_holdtime': 'INTEGER_VALUE:0-3600',
+ 'bgp_neighbor_ttl_hops': 'INTEGER_VALUE:1-254',
+ 'bgp_neighbor_update_options': 'TEXT_OPTIONS:ethernet,loopback,\
+ vlan',
+ 'bgp_neighbor_update_ethernet': 'TEXT:',
+ 'bgp_neighbor_update_loopback': 'INTEGER_VALUE:0-7',
+ 'bgp_neighbor_update_vlan': 'INTEGER_VALUE:1-4094',
+ 'bgp_neighbor_weight': 'INTEGER_VALUE:0-65535',
+ 'ethernet_interface_value': 'INTEGER_VALUE:1-54',
+ 'ethernet_interface_range': 'INTEGER_VALUE_RANGE:1-54',
+ 'ethernet_interface_string': 'TEXT:',
+ 'loopback_interface_value': 'INTEGER_VALUE:0-7',
+ 'mgmt_interface_value': 'INTEGER_VALUE:0-0',
+ 'vlan_interface_value': 'INTEGER_VALUE:1-4094',
+ 'portchannel_interface_value': 'INTEGER_VALUE:1-4096',
+ 'portchannel_interface_range': 'INTEGER_VALUE_RANGE:1-4096',
+ 'portchannel_interface_string': 'TEXT:',
+ 'aggregation_group_no': 'INTEGER_VALUE:1-4096',
+ 'aggregation_group_mode': 'TEXT_OPTIONS:active,on,passive',
+ 'bfd_options': 'TEXT_OPTIONS:authentication,echo,interval,ipv4,\
+ ipv6,neighbor',
+ 'bfd_interval': 'INTEGER_VALUE:50-999',
+ 'bfd_minrx': 'INTEGER_VALUE:50-999',
+ 'bfd_ multiplier': 'INTEGER_VALUE:3-50',
+ 'bfd_ipv4_options': 'TEXT_OPTIONS:authentication,echo,interval',
+ 'bfd_auth_options': 'TEXT_OPTIONS:keyed-md5,keyed-sha1,\
+ meticulous-keyed-md5,meticulous-keyed-sha1,simple',
+ 'bfd_key_options': 'TEXT_OPTIONS:key-chain,key-id',
+ 'bfd_key_chain': 'TEXT:',
+ 'bfd_key_id': 'INTEGER_VALUE:0-255',
+ 'bfd_key_name': 'TEXT:',
+ 'bfd_neighbor_ip': 'TEXT:',
+ 'bfd_neighbor_options': 'TEXT_OPTIONS:admin-down,multihop,\
+ non-persistent',
+ 'bfd_access_vlan': 'INTEGER_VALUE:1-3999',
+ 'bfd_bridgeport_mode': 'TEXT_OPTIONS:access,dot1q-tunnel,trunk',
+ 'trunk_options': 'TEXT_OPTIONS:allowed,native',
+ 'trunk_vlanid': 'INTEGER_VALUE:1-3999',
+ 'portCh_description': 'TEXT:',
+ 'duplex_option': 'TEXT_OPTIONS:auto,full,half',
+ 'flowcontrol_options': 'TEXT_OPTIONS:receive,send',
+ 'portchannel_ip_options': 'TEXT_OPTIONS:access-group,address,\
+ arp,dhcp,ospf,port,port-unreachable,redirects,router,\
+ unreachables',
+ 'accessgroup_name': 'TEXT:',
+ 'portchannel_ipv4': 'IPV4Address:',
+ 'portchannel_ipv4_mask': 'TEXT:',
+ 'arp_ipaddress': 'IPV4Address:',
+ 'arp_macaddress': 'TEXT:',
+ 'arp_timeout_value': 'INTEGER_VALUE:60-28800',
+ 'relay_ipaddress': 'IPV4Address:',
+ 'ip_ospf_options': 'TEXT_OPTIONS:authentication,\
+ authentication-key,bfd,cost,database-filter,dead-interval,\
+ hello-interval,message-digest-key,mtu,mtu-ignore,network,\
+ passive-interface,priority,retransmit-interval,shutdown,\
+ transmit-delay',
+ 'ospf_id_decimal_value': 'NO_VALIDATION:1-4294967295',
+ 'ospf_id_ipaddres_value': 'IPV4Address:',
+ 'lacp_options': 'TEXT_OPTIONS:port-priority,suspend-individual,\
+ timeout',
+ 'port_priority': 'INTEGER_VALUE:1-65535',
+ 'lldp_options': 'TEXT_OPTIONS:receive,tlv-select,transmit,\
+ trap-notification',
+ 'lldp_tlv_options': 'TEXT_OPTIONS:link-aggregation,\
+ mac-phy-status,management-address,max-frame-size,\
+ port-description,port-protocol-vlan,port-vlan,power-mdi,\
+ protocol-identity,system-capabilities,system-description,\
+ system-name,vid-management,vlan-name',
+ 'load_interval_delay': 'INTEGER_VALUE:30-300',
+ 'load_interval_counter': 'INTEGER_VALUE:1-3',
+ 'mac_accessgroup_name': 'TEXT:',
+ 'mac_address': 'TEXT:',
+ 'microburst_threshold': 'NO_VALIDATION:1-4294967295',
+ 'mtu_value': 'INTEGER_VALUE:64-9216',
+ 'service_instance': 'NO_VALIDATION:1-4294967295',
+ 'service_policy_options': 'TEXT_OPTIONS:copp-system-policy,input,\
+ output,type',
+ 'service_policy_name': 'TEXT:',
+ 'spanning_tree_options': 'TEXT_OPTIONS:bpdufilter,bpduguard,\
+ cost,disable,enable,guard,link-type,mst,port,port-priority,vlan',
+ 'spanning_tree_cost': 'NO_VALIDATION:1-200000000',
+ 'spanning_tree_interfacerange': 'INTEGER_VALUE_RANGE:1-3999',
+ 'spanning_tree_portpriority': 'TEXT_OPTIONS:0,32,64,96,128,160,\
+ 192,224',
+ 'portchannel_ipv6_neighbor_mac': 'TEXT:',
+ 'portchannel_ipv6_neighbor_address': 'IPV6Address:',
+ 'portchannel_ipv6_linklocal': 'IPV6Address:',
+ 'portchannel_ipv6_dhcp_vlan': 'INTEGER_VALUE:1-4094',
+ 'portchannel_ipv6_dhcp_ethernet': 'TEXT:',
+ 'portchannel_ipv6_dhcp': 'IPV6Address:',
+ 'portchannel_ipv6_address': 'IPV6Address:',
+ 'portchannel_ipv6_options': 'TEXT_OPTIONS:address,dhcp,\
+ link-local,nd,neighbor',
+ 'interface_speed': 'TEXT_OPTIONS:1000,10000,40000,auto',
+ 'stormcontrol_options': 'TEXT_OPTIONS:broadcast,multicast,\
+ unicast',
+ 'stormcontrol_level': 'FLOAT:',
+ 'portchannel_dot1q_tag': 'TEXT_OPTIONS:disable,enable,\
+ egress-only',
+ 'vrrp_id': 'INTEGER_VALUE:1-255',
+ }
+g8296_cnos = {'vlan_id': 'INTEGER_VALUE:1-3999',
+ 'vlan_id_range': 'INTEGER_VALUE_RANGE:1-3999',
+ 'vlan_name': 'TEXT:',
+ 'vlan_flood': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'vlan_state': 'TEXT_OPTIONS:active,suspend',
+ 'vlan_last_member_query_interval': 'INTEGER_VALUE:1-25',
+ 'vlan_querier': 'IPV4Address:',
+ 'vlan_querier_timeout': 'INTEGER_VALUE:1-65535',
+ 'vlan_query_interval': 'INTEGER_VALUE:1-18000',
+ 'vlan_query_max_response_time': 'INTEGER_VALUE:1-25',
+ 'vlan_report_suppression': 'INTEGER_VALUE:1-25',
+ 'vlan_robustness_variable': 'INTEGER_VALUE:1-7',
+ 'vlan_startup_query_count': 'INTEGER_VALUE:1-10',
+ 'vlan_startup_query_interval': 'INTEGER_VALUE:1-18000',
+ 'vlan_snooping_version': 'INTEGER_VALUE:2-3',
+ 'vlan_access_map_name': 'TEXT: ',
+ 'vlan_ethernet_interface': 'TEXT:',
+ 'vlan_portagg_number': 'INTEGER_VALUE:1-4096',
+ 'vlan_accessmap_action': 'TEXT_OPTIONS:drop,forward,redirect',
+ 'vlan_dot1q_tag': 'MATCH_TEXT_OR_EMPTY:egress-only',
+ 'vlan_filter_name': 'TEXT:',
+ 'vlag_auto_recovery': 'INTEGER_VALUE:240-3600',
+ 'vlag_config_consistency': 'TEXT_OPTIONS:disable,strict',
+ 'vlag_instance': 'INTEGER_VALUE:1-128',
+ 'vlag_port_aggregation': 'INTEGER_VALUE:1-4096',
+ 'vlag_priority': 'INTEGER_VALUE:0-65535',
+ 'vlag_startup_delay': 'INTEGER_VALUE:0-3600',
+ 'vlag_tier_id': 'INTEGER_VALUE:1-512',
+ 'vlag_hlthchk_options': 'TEXT_OPTIONS:keepalive-attempts,\
+ keepalive-interval,peer-ip,retry-interval',
+ 'vlag_keepalive_attempts': 'INTEGER_VALUE:1-24',
+ 'vlag_keepalive_interval': 'INTEGER_VALUE:2-300',
+ 'vlag_retry_interval': 'INTEGER_VALUE:1-300',
+ 'vlag_peerip': 'IPV4Address:',
+ 'vlag_peerip_vrf': 'TEXT_OPTIONS:default,management',
+ 'bgp_as_number': 'NO_VALIDATION:1-4294967295',
+ 'bgp_address_family': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'bgp_bgp_local_count': 'INTEGER_VALUE:2-64',
+ 'cluster_id_as_ip': 'IPV4Address:',
+ 'cluster_id_as_number': 'NO_VALIDATION:1-4294967295',
+ 'confederation_identifier': 'INTEGER_VALUE:1-65535',
+ 'condeferation_peers_as': 'INTEGER_VALUE:1-65535',
+ 'stalepath_delay_value': 'INTEGER_VALUE:1-3600',
+ 'maxas_limit_as': 'INTEGER_VALUE:1-2000',
+ 'neighbor_ipaddress': 'IPV4Address:',
+ 'neighbor_as': 'NO_VALIDATION:1-4294967295',
+ 'router_id': 'IPV4Address:',
+ 'bgp_keepalive_interval': 'INTEGER_VALUE:0-3600',
+ 'bgp_holdtime': 'INTEGER_VALUE:0-3600',
+ 'bgp_aggregate_prefix': 'IPV4AddressWithMask:',
+ 'addrfamily_routemap_name': 'TEXT:',
+ 'reachability_half_life': 'INTEGER_VALUE:1-45',
+ 'start_reuse_route_value': 'INTEGER_VALUE:1-20000',
+ 'start_suppress_route_value': 'INTEGER_VALUE:1-20000',
+ 'max_duration_to_suppress_route': 'INTEGER_VALUE:1-255',
+ 'unreachability_halftime_for_penalty': 'INTEGER_VALUE:1-45',
+ 'distance_external_AS': 'INTEGER_VALUE:1-255',
+ 'distance_internal_AS': 'INTEGER_VALUE:1-255',
+ 'distance_local_routes': 'INTEGER_VALUE:1-255',
+ 'maxpath_option': 'TEXT_OPTIONS:ebgp,ibgp',
+ 'maxpath_numbers': 'INTEGER_VALUE:2-32',
+ 'network_ip_prefix_with_mask': 'IPV4AddressWithMask:',
+ 'network_ip_prefix_value': 'IPV4Address:',
+ 'network_ip_prefix_mask': 'IPV4Address:',
+ 'nexthop_crtitical_delay': 'NO_VALIDATION:1-4294967295',
+ 'nexthop_noncrtitical_delay': 'NO_VALIDATION:1-4294967295',
+ 'addrfamily_redistribute_option': 'TEXT_OPTIONS:direct,ospf,\
+ static',
+ 'bgp_neighbor_af_occurances': 'INTEGER_VALUE:1-10',
+ 'bgp_neighbor_af_filtername': 'TEXT:',
+ 'bgp_neighbor_af_maxprefix': 'INTEGER_VALUE:1-15870',
+ 'bgp_neighbor_af_prefixname': 'TEXT:',
+ 'bgp_neighbor_af_routemap': 'TEXT:',
+ 'bgp_neighbor_address_family': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'bgp_neighbor_connection_retrytime': 'INTEGER_VALUE:1-65535',
+ 'bgp_neighbor_description': 'TEXT:',
+ 'bgp_neighbor_maxhopcount': 'INTEGER_VALUE:1-255',
+ 'bgp_neighbor_local_as': 'NO_VALIDATION:1-4294967295',
+ 'bgp_neighbor_maxpeers': 'INTEGER_VALUE:1-96',
+ 'bgp_neighbor_password': 'TEXT:',
+ 'bgp_neighbor_timers_Keepalive': 'INTEGER_VALUE:0-3600',
+ 'bgp_neighbor_timers_holdtime': 'INTEGER_VALUE:0-3600',
+ 'bgp_neighbor_ttl_hops': 'INTEGER_VALUE:1-254',
+ 'bgp_neighbor_update_options': 'TEXT_OPTIONS:ethernet,loopback,\
+ vlan',
+ 'bgp_neighbor_update_ethernet': 'TEXT:',
+ 'bgp_neighbor_update_loopback': 'INTEGER_VALUE:0-7',
+ 'bgp_neighbor_update_vlan': 'INTEGER_VALUE:1-4094',
+ 'bgp_neighbor_weight': 'INTEGER_VALUE:0-65535',
+ 'ethernet_interface_value': 'INTEGER_VALUE:1-96',
+ 'ethernet_interface_range': 'INTEGER_VALUE_RANGE:1-96',
+ 'ethernet_interface_string': 'TEXT:',
+ 'loopback_interface_value': 'INTEGER_VALUE:0-7',
+ 'mgmt_interface_value': 'INTEGER_VALUE:0-0',
+ 'vlan_interface_value': 'INTEGER_VALUE:1-4094',
+ 'portchannel_interface_value': 'INTEGER_VALUE:1-4096',
+ 'portchannel_interface_range': 'INTEGER_VALUE_RANGE:1-4096',
+ 'portchannel_interface_string': 'TEXT:',
+ 'aggregation_group_no': 'INTEGER_VALUE:1-4096',
+ 'aggregation_group_mode': 'TEXT_OPTIONS:active,on,passive',
+ 'bfd_options': 'TEXT_OPTIONS:authentication,echo,interval,ipv4,\
+ ipv6,neighbor',
+ 'bfd_interval': 'INTEGER_VALUE:50-999',
+ 'bfd_minrx': 'INTEGER_VALUE:50-999',
+ 'bfd_ multiplier': 'INTEGER_VALUE:3-50',
+ 'bfd_ipv4_options': 'TEXT_OPTIONS:authentication,echo,interval',
+ 'bfd_auth_options': 'TEXT_OPTIONS:keyed-md5,keyed-sha1,\
+ meticulous-keyed-md5,meticulous-keyed-sha1,simple',
+ 'bfd_key_options': 'TEXT_OPTIONS:key-chain,key-id',
+ 'bfd_key_chain': 'TEXT:',
+ 'bfd_key_id': 'INTEGER_VALUE:0-255',
+ 'bfd_key_name': 'TEXT:',
+ 'bfd_neighbor_ip': 'TEXT:',
+ 'bfd_neighbor_options': 'TEXT_OPTIONS:admin-down,multihop,\
+ non-persistent',
+ 'bfd_access_vlan': 'INTEGER_VALUE:1-3999',
+ 'bfd_bridgeport_mode': 'TEXT_OPTIONS:access,dot1q-tunnel,trunk',
+ 'trunk_options': 'TEXT_OPTIONS:allowed,native',
+ 'trunk_vlanid': 'INTEGER_VALUE:1-3999',
+ 'portCh_description': 'TEXT:',
+ 'duplex_option': 'TEXT_OPTIONS:auto,full,half',
+ 'flowcontrol_options': 'TEXT_OPTIONS:receive,send',
+ 'portchannel_ip_options': 'TEXT_OPTIONS:access-group,address,\
+ arp,dhcp,ospf,port,port-unreachable,redirects,router,\
+ unreachables',
+ 'accessgroup_name': 'TEXT:',
+ 'portchannel_ipv4': 'IPV4Address:',
+ 'portchannel_ipv4_mask': 'TEXT:',
+ 'arp_ipaddress': 'IPV4Address:',
+ 'arp_macaddress': 'TEXT:',
+ 'arp_timeout_value': 'INTEGER_VALUE:60-28800',
+ 'relay_ipaddress': 'IPV4Address:',
+ 'ip_ospf_options': 'TEXT_OPTIONS:authentication,\
+ authentication-key,bfd,cost,database-filter,dead-interval,\
+ hello-interval,message-digest-key,mtu,mtu-ignore,network,\
+ passive-interface,priority,retransmit-interval,shutdown,\
+ transmit-delay',
+ 'ospf_id_decimal_value': 'NO_VALIDATION:1-4294967295',
+ 'ospf_id_ipaddres_value': 'IPV4Address:',
+ 'lacp_options': 'TEXT_OPTIONS:port-priority,suspend-individual,\
+ timeout',
+ 'port_priority': 'INTEGER_VALUE:1-65535',
+ 'lldp_options': 'TEXT_OPTIONS:receive,tlv-select,transmit,\
+ trap-notification',
+ 'lldp_tlv_options': 'TEXT_OPTIONS:link-aggregation,\
+ mac-phy-status,management-address,max-frame-size,\
+ port-description,port-protocol-vlan,port-vlan,power-mdi,\
+ protocol-identity,system-capabilities,system-description,\
+ system-name,vid-management,vlan-name',
+ 'load_interval_delay': 'INTEGER_VALUE:30-300',
+ 'load_interval_counter': 'INTEGER_VALUE:1-3',
+ 'mac_accessgroup_name': 'TEXT:',
+ 'mac_address': 'TEXT:',
+ 'microburst_threshold': 'NO_VALIDATION:1-4294967295',
+ 'mtu_value': 'INTEGER_VALUE:64-9216',
+ 'service_instance': 'NO_VALIDATION:1-4294967295',
+ 'service_policy_options': 'TEXT_OPTIONS:copp-system-policy,\
+ input,output,type',
+ 'service_policy_name': 'TEXT:',
+ 'spanning_tree_options': 'TEXT_OPTIONS:bpdufilter,bpduguard,\
+ cost,disable,enable,guard,link-type,mst,port,port-priority,vlan',
+ 'spanning_tree_cost': 'NO_VALIDATION:1-200000000',
+ 'spanning_tree_interfacerange': 'INTEGER_VALUE_RANGE:1-3999',
+ 'spanning_tree_portpriority': 'TEXT_OPTIONS:0,32,64,96,128,160,\
+ 192,224',
+ 'portchannel_ipv6_neighbor_mac': 'TEXT:',
+ 'portchannel_ipv6_neighbor_address': 'IPV6Address:',
+ 'portchannel_ipv6_linklocal': 'IPV6Address:',
+ 'portchannel_ipv6_dhcp_vlan': 'INTEGER_VALUE:1-4094',
+ 'portchannel_ipv6_dhcp_ethernet': 'TEXT:',
+ 'portchannel_ipv6_dhcp': 'IPV6Address:',
+ 'portchannel_ipv6_address': 'IPV6Address:',
+ 'portchannel_ipv6_options': 'TEXT_OPTIONS:address,dhcp,\
+ link-local,nd,neighbor',
+ 'interface_speed': 'TEXT_OPTIONS:1000,10000,40000,auto',
+ 'stormcontrol_options': 'TEXT_OPTIONS:broadcast,multicast,\
+ unicast',
+ 'stormcontrol_level': 'FLOAT:',
+ 'portchannel_dot1q_tag': 'TEXT_OPTIONS:disable,enable,\
+ egress-only',
+ 'vrrp_id': 'INTEGER_VALUE:1-255',
+ }
+g8332_cnos = {'vlan_id': 'INTEGER_VALUE:1-3999',
+ 'vlan_id_range': 'INTEGER_VALUE_RANGE:1-3999',
+ 'vlan_name': 'TEXT:',
+ 'vlan_flood': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'vlan_state': 'TEXT_OPTIONS:active,suspend',
+ 'vlan_last_member_query_interval': 'INTEGER_VALUE:1-25',
+ 'vlan_querier': 'IPV4Address:',
+ 'vlan_querier_timeout': 'INTEGER_VALUE:1-65535',
+ 'vlan_query_interval': 'INTEGER_VALUE:1-18000',
+ 'vlan_query_max_response_time': 'INTEGER_VALUE:1-25',
+ 'vlan_report_suppression': 'INTEGER_VALUE:1-25',
+ 'vlan_robustness_variable': 'INTEGER_VALUE:1-7',
+ 'vlan_startup_query_count': 'INTEGER_VALUE:1-10',
+ 'vlan_startup_query_interval': 'INTEGER_VALUE:1-18000',
+ 'vlan_snooping_version': 'INTEGER_VALUE:2-3',
+ 'vlan_access_map_name': 'TEXT: ',
+ 'vlan_ethernet_interface': 'TEXT:',
+ 'vlan_portagg_number': 'INTEGER_VALUE:1-4096',
+ 'vlan_accessmap_action': 'TEXT_OPTIONS:drop,forward,redirect',
+ 'vlan_dot1q_tag': 'MATCH_TEXT_OR_EMPTY:egress-only',
+ 'vlan_filter_name': 'TEXT:',
+ 'vlag_auto_recovery': 'INTEGER_VALUE:240-3600',
+ 'vlag_config_consistency': 'TEXT_OPTIONS:disable,strict',
+ 'vlag_instance': 'INTEGER_VALUE:1-128',
+ 'vlag_port_aggregation': 'INTEGER_VALUE:1-4096',
+ 'vlag_priority': 'INTEGER_VALUE:0-65535',
+ 'vlag_startup_delay': 'INTEGER_VALUE:0-3600',
+ 'vlag_tier_id': 'INTEGER_VALUE:1-512',
+ 'vlag_hlthchk_options': 'TEXT_OPTIONS:keepalive-attempts,\
+ keepalive-interval,peer-ip,retry-interval',
+ 'vlag_keepalive_attempts': 'INTEGER_VALUE:1-24',
+ 'vlag_keepalive_interval': 'INTEGER_VALUE:2-300',
+ 'vlag_retry_interval': 'INTEGER_VALUE:1-300',
+ 'vlag_peerip': 'IPV4Address:',
+ 'vlag_peerip_vrf': 'TEXT_OPTIONS:default,management',
+ 'bgp_as_number': 'NO_VALIDATION:1-4294967295',
+ 'bgp_address_family': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'bgp_bgp_local_count': 'INTEGER_VALUE:2-64',
+ 'cluster_id_as_ip': 'IPV4Address:',
+ 'cluster_id_as_number': 'NO_VALIDATION:1-4294967295',
+ 'confederation_identifier': 'INTEGER_VALUE:1-65535',
+ 'condeferation_peers_as': 'INTEGER_VALUE:1-65535',
+ 'stalepath_delay_value': 'INTEGER_VALUE:1-3600',
+ 'maxas_limit_as': 'INTEGER_VALUE:1-2000',
+ 'neighbor_ipaddress': 'IPV4Address:',
+ 'neighbor_as': 'NO_VALIDATION:1-4294967295',
+ 'router_id': 'IPV4Address:',
+ 'bgp_keepalive_interval': 'INTEGER_VALUE:0-3600',
+ 'bgp_holdtime': 'INTEGER_VALUE:0-3600',
+ 'bgp_aggregate_prefix': 'IPV4AddressWithMask:',
+ 'addrfamily_routemap_name': 'TEXT:',
+ 'reachability_half_life': 'INTEGER_VALUE:1-45',
+ 'start_reuse_route_value': 'INTEGER_VALUE:1-20000',
+ 'start_suppress_route_value': 'INTEGER_VALUE:1-20000',
+ 'max_duration_to_suppress_route': 'INTEGER_VALUE:1-255',
+ 'unreachability_halftime_for_penalty': 'INTEGER_VALUE:1-45',
+ 'distance_external_AS': 'INTEGER_VALUE:1-255',
+ 'distance_internal_AS': 'INTEGER_VALUE:1-255',
+ 'distance_local_routes': 'INTEGER_VALUE:1-255',
+ 'maxpath_option': 'TEXT_OPTIONS:ebgp,ibgp',
+ 'maxpath_numbers': 'INTEGER_VALUE:2-32',
+ 'network_ip_prefix_with_mask': 'IPV4AddressWithMask:',
+ 'network_ip_prefix_value': 'IPV4Address:',
+ 'network_ip_prefix_mask': 'IPV4Address:',
+ 'nexthop_crtitical_delay': 'NO_VALIDATION:1-4294967295',
+ 'nexthop_noncrtitical_delay': 'NO_VALIDATION:1-4294967295',
+ 'addrfamily_redistribute_option': 'TEXT_OPTIONS:direct,ospf,\
+ static',
+ 'bgp_neighbor_af_occurances': 'INTEGER_VALUE:1-10',
+ 'bgp_neighbor_af_filtername': 'TEXT:',
+ 'bgp_neighbor_af_maxprefix': 'INTEGER_VALUE:1-15870',
+ 'bgp_neighbor_af_prefixname': 'TEXT:',
+ 'bgp_neighbor_af_routemap': 'TEXT:',
+ 'bgp_neighbor_address_family': 'TEXT_OPTIONS:ipv4,ipv6',
+ 'bgp_neighbor_connection_retrytime': 'INTEGER_VALUE:1-65535',
+ 'bgp_neighbor_description': 'TEXT:',
+ 'bgp_neighbor_maxhopcount': 'INTEGER_VALUE:1-255',
+ 'bgp_neighbor_local_as': 'NO_VALIDATION:1-4294967295',
+ 'bgp_neighbor_maxpeers': 'INTEGER_VALUE:1-96',
+ 'bgp_neighbor_password': 'TEXT:',
+ 'bgp_neighbor_timers_Keepalive': 'INTEGER_VALUE:0-3600',
+ 'bgp_neighbor_timers_holdtime': 'INTEGER_VALUE:0-3600',
+ 'bgp_neighbor_ttl_hops': 'INTEGER_VALUE:1-254',
+ 'bgp_neighbor_update_options': 'TEXT_OPTIONS:ethernet,loopback,\
+ vlan',
+ 'bgp_neighbor_update_ethernet': 'TEXT:',
+ 'bgp_neighbor_update_loopback': 'INTEGER_VALUE:0-7',
+ 'bgp_neighbor_update_vlan': 'INTEGER_VALUE:1-4094',
+ 'bgp_neighbor_weight': 'INTEGER_VALUE:0-65535',
+ 'ethernet_interface_value': 'INTEGER_VALUE:1-32',
+ 'ethernet_interface_range': 'INTEGER_VALUE_RANGE:1-32',
+ 'ethernet_interface_string': 'TEXT:',
+ 'loopback_interface_value': 'INTEGER_VALUE:0-7',
+ 'mgmt_interface_value': 'INTEGER_VALUE:0-0',
+ 'vlan_interface_value': 'INTEGER_VALUE:1-4094',
+ 'portchannel_interface_value': 'INTEGER_VALUE:1-4096',
+ 'portchannel_interface_range': 'INTEGER_VALUE_RANGE:1-4096',
+ 'portchannel_interface_string': 'TEXT:',
+ 'aggregation_group_no': 'INTEGER_VALUE:1-4096',
+ 'aggregation_group_mode': 'TEXT_OPTIONS:active,on,passive',
+ 'bfd_options': 'TEXT_OPTIONS:authentication,echo,interval,ipv4,\
+ ipv6,neighbor',
+ 'bfd_interval': 'INTEGER_VALUE:50-999',
+ 'bfd_minrx': 'INTEGER_VALUE:50-999',
+ 'bfd_ multiplier': 'INTEGER_VALUE:3-50',
+ 'bfd_ipv4_options': 'TEXT_OPTIONS:authentication,echo,interval',
+ 'bfd_auth_options': 'TEXT_OPTIONS:keyed-md5,keyed-sha1,\
+ meticulous-keyed-md5,meticulous-keyed-sha1,simple',
+ 'bfd_key_options': 'TEXT_OPTIONS:key-chain,key-id',
+ 'bfd_key_chain': 'TEXT:',
+ 'bfd_key_id': 'INTEGER_VALUE:0-255',
+ 'bfd_key_name': 'TEXT:',
+ 'bfd_neighbor_ip': 'TEXT:',
+ 'bfd_neighbor_options': 'TEXT_OPTIONS:admin-down,multihop,\
+ non-persistent',
+ 'bfd_access_vlan': 'INTEGER_VALUE:1-3999',
+ 'bfd_bridgeport_mode': 'TEXT_OPTIONS:access,dot1q-tunnel,trunk',
+ 'trunk_options': 'TEXT_OPTIONS:allowed,native',
+ 'trunk_vlanid': 'INTEGER_VALUE:1-3999',
+ 'portCh_description': 'TEXT:',
+ 'duplex_option': 'TEXT_OPTIONS:auto,full,half',
+ 'flowcontrol_options': 'TEXT_OPTIONS:receive,send',
+ 'portchannel_ip_options': 'TEXT_OPTIONS:access-group,address,arp,\
+ dhcp,ospf,port,port-unreachable,redirects,router,unreachables',
+ 'accessgroup_name': 'TEXT:',
+ 'portchannel_ipv4': 'IPV4Address:',
+ 'portchannel_ipv4_mask': 'TEXT:',
+ 'arp_ipaddress': 'IPV4Address:',
+ 'arp_macaddress': 'TEXT:',
+ 'arp_timeout_value': 'INTEGER_VALUE:60-28800',
+ 'relay_ipaddress': 'IPV4Address:',
+ 'ip_ospf_options': 'TEXT_OPTIONS:authentication,\
+ authentication-key,bfd,cost,database-filter,dead-interval,\
+ hello-interval,message-digest-key,mtu,mtu-ignore,network,\
+ passive-interface,priority,retransmit-interval,shutdown,\
+ transmit-delay',
+ 'ospf_id_decimal_value': 'NO_VALIDATION:1-4294967295',
+ 'ospf_id_ipaddres_value': 'IPV4Address:',
+ 'lacp_options': 'TEXT_OPTIONS:port-priority,suspend-individual,\
+ timeout',
+ 'port_priority': 'INTEGER_VALUE:1-65535',
+ 'lldp_options': 'TEXT_OPTIONS:receive,tlv-select,transmit,\
+ trap-notification',
+ 'lldp_tlv_options': 'TEXT_OPTIONS:link-aggregation,\
+ mac-phy-status,management-address,max-frame-size,\
+ port-description,port-protocol-vlan,port-vlan,power-mdi,\
+ protocol-identity,system-capabilities,system-description,\
+ system-name,vid-management,vlan-name',
+ 'load_interval_delay': 'INTEGER_VALUE:30-300',
+ 'load_interval_counter': 'INTEGER_VALUE:1-3',
+ 'mac_accessgroup_name': 'TEXT:',
+ 'mac_address': 'TEXT:',
+ 'microburst_threshold': 'NO_VALIDATION:1-4294967295',
+ 'mtu_value': 'INTEGER_VALUE:64-9216',
+ 'service_instance': 'NO_VALIDATION:1-4294967295',
+ 'service_policy_options': 'TEXT_OPTIONS:copp-system-policy,\
+ input,output,type',
+ 'service_policy_name': 'TEXT:',
+ 'spanning_tree_options': 'TEXT_OPTIONS:bpdufilter,bpduguard,\
+ cost,disable,enable,guard,link-type,mst,port,port-priority,vlan',
+ 'spanning_tree_cost': 'NO_VALIDATION:1-200000000',
+ 'spanning_tree_interfacerange': 'INTEGER_VALUE_RANGE:1-3999',
+ 'spanning_tree_portpriority': 'TEXT_OPTIONS:0,32,64,96,128,160,\
+ 192,224',
+ 'portchannel_ipv6_neighbor_mac': 'TEXT:',
+ 'portchannel_ipv6_neighbor_address': 'IPV6Address:',
+ 'portchannel_ipv6_linklocal': 'IPV6Address:',
+ 'portchannel_ipv6_dhcp_vlan': 'INTEGER_VALUE:1-4094',
+ 'portchannel_ipv6_dhcp_ethernet': 'TEXT:',
+ 'portchannel_ipv6_dhcp': 'IPV6Address:',
+ 'portchannel_ipv6_address': 'IPV6Address:',
+ 'portchannel_ipv6_options': 'TEXT_OPTIONS:address,dhcp,\
+ link-local,nd,neighbor',
+ 'interface_speed': 'TEXT_OPTIONS:1000,10000,40000,50000,auto',
+ 'stormcontrol_options': 'TEXT_OPTIONS:broadcast,multicast,\
+ unicast',
+ 'stormcontrol_level': 'FLOAT:',
+ 'portchannel_dot1q_tag': 'TEXT_OPTIONS:disable,enable,\
+ egress-only',
+ 'vrrp_id': 'INTEGER_VALUE:1-255',
+ }
diff --git a/lib/ansible/module_utils/cnos_errorcodes.py b/lib/ansible/module_utils/cnos_errorcodes.py
new file mode 100644
index 00000000000..47c98e0b27f
--- /dev/null
+++ b/lib/ansible/module_utils/cnos_errorcodes.py
@@ -0,0 +1,256 @@
+# This code is part of Ansible, but is an independent component.
+# This particular file snippet, and this file snippet only, is BSD licensed.
+# Modules you write using this snippet, which is embedded dynamically by
+# Ansible still belong to the author of the module, and may assign their own
+# license to the complete work.
+#
+# Copyright (C) 2017 Lenovo, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT 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.
+#
+# Contains error codes and methods
+# Lenovo Networking
+
+errorDict = {0: 'Success',
+ 1: 'NOK',
+ 101: 'Device Response Timed out',
+ 102: 'Command Not supported - Use CLI command',
+ 103: 'Invalid Context',
+ 104: 'Command Value Not Supported as of Now. Use vlan Id only',
+ 105: 'Invalid interface Range',
+ 106: 'Please provide Enable Password.',
+ 108: '',
+ 109: '',
+ 110: 'Invalid protocol option',
+ 111: 'The Value is not Integer',
+ 112: 'The Value is not Float',
+ 113: 'Value is not in Range',
+ 114: 'Range value is not Integer',
+ 115: 'Value is not in Options',
+ 116: 'The Value is not Long',
+ 117: 'Range value is not Long',
+ 118: 'The Value cannot be empty',
+ 119: 'The Value is not String',
+ 120: 'The Value is not Matching',
+ 121: 'The Value is not IPV4 Address',
+ 122: 'The Value is not IPV6 Address',
+ 123: '',
+ 124: '',
+ 125: '',
+ 126: '',
+ 127: '',
+ 128: '',
+ 129: '',
+ 130: 'Invalid Access Map Name',
+ 131: 'Invalid Vlan Dot1q Tag',
+ 132: 'Invalid Vlan filter value',
+ 133: 'Invalid Vlan Range Value',
+ 134: 'Invalid Vlan Id',
+ 135: 'Invalid Vlan Access Map Action',
+ 136: 'Invalid Vlan Access Map Name',
+ 137: 'Invalid Access List',
+ 138: 'Invalid Vlan Access Map parameter',
+ 139: 'Invalid Vlan Name',
+ 140: 'Invalid Vlan Flood value,',
+ 141: 'Invalid Vlan State Value',
+ 142: 'Invalid Vlan Last Member query Interval',
+ 143: 'Invalid Querier IP address',
+ 144: 'Invalid Querier Time out',
+ 145: 'Invalid Query Interval',
+ 146: 'Invalid Vlan query max response time',
+ 147: 'Invalid vlan robustness variable',
+ 148: 'Invalid Vlan Startup Query count',
+ 149: 'Invalid vlan Startup Query Interval',
+ 150: 'Invalid Vlan snooping version',
+ 151: 'Invalid Vlan Ethernet Interface',
+ 152: 'Invalid Vlan Port Tag Number',
+ 153: 'Invalid mrouter option',
+ 154: 'Invalid Vlan Option',
+ 155: '',
+ 156: '',
+ 157: '',
+ 158: '',
+ 159: '',
+ 160: 'Invalid Vlag Auto Recovery Value',
+ 161: 'Invalid Vlag Config Consistency Value',
+ 162: 'Invalid Vlag Port Aggregation Number',
+ 163: 'Invalid Vlag Priority Value',
+ 164: 'Invalid Vlag Startup delay value',
+ 165: 'Invalid Vlag Trie Id',
+ 166: 'Invalid Vlag Instance Option',
+ 167: 'Invalid Vlag Keep Alive Attempts',
+ 168: 'Invalid Vlag Keep Alive Interval',
+ 169: 'Invalid Vlag Retry Interval',
+ 170: 'Invalid Vlag Peer Ip VRF Value',
+ 171: 'Invalid Vlag Health Check Options',
+ 172: 'Invalid Vlag Option',
+ 173: '',
+ 174: '',
+ 175: '',
+ 176: 'Invalid BGP As Number',
+ 177: 'Invalid Routing protocol option',
+ 178: 'Invalid BGP Address Family',
+ 179: 'Invalid AS Path options',
+ 180: 'Invalid BGP med options',
+ 181: 'Invalid Best Path option',
+ 182: 'Invalid BGP Local count number',
+ 183: 'Cluster Id has to either IP or AS Number',
+ 184: 'Invalid confederation identifier',
+ 185: 'Invalid Confederation Peer AS Value',
+ 186: 'Invalid Confederation Option',
+ 187: 'Invalid state path relay value',
+ 188: 'Invalid Maxas Limit AS Value',
+ 189: 'Invalid Neighbor IP Address or Neighbor AS Number',
+ 190: 'Invalid Router Id',
+ 191: 'Invalid BGP Keep Alive Interval',
+ 192: 'Invalid BGP Hold time',
+ 193: 'Invalid BGP Option',
+ 194: 'Invalid BGP Address Family option',
+ 195: 'Invalid BGP Address Family Redistribution option. ',
+ 196: 'Invalid BGP Address Family Route Map Name',
+ 197: 'Invalid Next Hop Critical Delay',
+ 198: 'Invalid Next Hop Non Critical Delay',
+ 199: 'Invalid Multipath Number Value',
+ 200: 'Invalid Aggegation Group Mode',
+ 201: 'Invalid Aggregation Group No',
+ 202: 'Invalid BFD Access Vlan',
+ 203: 'Invalid CFD Bridgeport Mode',
+ 204: 'Invalid Trunk Option',
+ 205: 'Invalid BFD Option',
+ 206: 'Invalid Portchannel description',
+ 207: 'Invalid Portchannel duplex option',
+ 208: 'Invalid Flow control option state',
+ 209: 'Invalid Flow control option',
+ 210: 'Invalid LACP Port priority',
+ 211: 'Invalid LACP Time out options',
+ 212: 'Invalid LACP Command options',
+ 213: 'Invalid LLDP TLV Option',
+ 214: 'Invalid LLDP Option',
+ 215: 'Invalid Load interval delay',
+ 216: 'Invalid Load interval Counter Number',
+ 217: 'Invalid Load Interval option',
+ 218: 'Invalid Mac Access Group Name',
+ 219: 'Invalid Mac Address',
+ 220: 'Invalid Microburst threshold value',
+ 221: 'Invalid MTU Value',
+ 222: 'Invalid Service instance value',
+ 223: 'Invalid service policy name',
+ 224: 'Invalid service policy options',
+ 225: 'Invalid Interface speed value',
+ 226: 'Invalid Storm control level value',
+ 227: 'Invalid Storm control option',
+ 228: 'Invalid Portchannel dot1q tag',
+ 229: 'Invalid VRRP Id Value',
+ 230: 'Invalid VRRP Options',
+ 231: 'Invalid portchannel source interface option',
+ 232: 'Invalid portchannel load balance options',
+ 233: 'Invalid Portchannel configuration attribute',
+ 234: 'Invalid BFD Interval Value',
+ 235: 'Invalid BFD minrx Value',
+ 236: 'Invalid BFD multiplier Value',
+ 237: 'Invalid Key Chain Value',
+ 238: 'Invalid key name option',
+ 239: 'Invalid key id value',
+ 240: 'Invalid Key Option',
+ 241: 'Invalid authentication option',
+ 242: 'Invalid destination Ip',
+ 243: 'Invalid source Ip',
+ 244: 'Invalid IP Option',
+ 245: 'Invalid Access group option',
+ 246: 'Invalid Access group name',
+ 247: 'Invalid ARP MacAddress Value',
+ 248: 'Invalid ARP timeout value',
+ 249: 'Invalid ARP Option',
+ 250: 'Invalid dhcp request option',
+ 251: 'Invalid dhcp Client option',
+ 252: 'Invalid relay Ip Address',
+ 253: 'Invalid dhcp Option',
+ 254: 'Invalid OSPF Option',
+ 255: 'Invalid OSPF Id IP Address Value',
+ 256: 'Invalid Ip Router Option',
+ 257: 'Invalid Spanning tree bpdufilter Options',
+ 258: 'Invalid Spanning tree bpduguard Options',
+ 259: 'Invalid Spanning tree cost Options',
+ 260: 'Invalid Spanning tree guard Options',
+ 261: 'Invalid Spanning tree link-type Options',
+ 262: 'Invalid Spanning tree link-type Options',
+ 263: 'Invalid Spanning tree options',
+ 264: 'Port-priority in increments of 32 is required',
+ 265: 'Invalid Spanning tree vlan options',
+ 266: 'Invalid IPv6 option',
+ 267: 'Invalid IPV6 neighbor IP Address',
+ 268: 'Invalid IPV6 neighbor mac addres',
+ 269: 'Invalid IPV6 dhcp option',
+ 270: 'Invalid IPV6 relay address option',
+ 271: 'Invalid IPV6 Ethernet option',
+ 272: 'Invalid IPV6 Vlan option',
+ 273: 'Invalid IPV6 Link Local option',
+ 274: 'Invalid IPV6 dhcp option',
+ 275: 'Invalid IPV6 Address',
+ 276: 'Invalid IPV6 Address option',
+ 277: 'Invalid BFD neighbor options',
+ 278: 'Invalid Secondary option',
+ 289: 'Invalid PortChannel IPV4 address',
+ 290: 'Invalid Max Path Options',
+ 291: 'Invalid Distance Local Route value',
+ 292: 'Invalid Distance Internal AS value',
+ 293: 'Invalid Distance External AS value',
+ 294: 'Invalid BGP Reachability Half Life',
+ 295: 'Invalid BGP Dampening parameter',
+ 296: 'Invalid BGP Aggregate Prefix value',
+ 297: 'Invalid BGP Aggregate Prefix Option',
+ 298: 'Invalid BGP Address Family Route Map Name',
+ 299: 'Invalid BGP Net IP Mask Value',
+ 300: 'Invalid BGP Net IP Prefix Value',
+ 301: 'Invalid BGP Neighbor configuration option',
+ 302: 'Invalid BGP Neighbor Weight Value',
+ 303: 'Invalid Neigbor update source option',
+ 304: 'Invalid Ethernet slot/chassis number',
+ 305: 'Invalid Loopback Interface number',
+ 306: 'Invalid vlan id',
+ 307: 'Invalid Number of hops',
+ 308: 'Invalid Neighbor Keepalive interval',
+ 309: 'Invalid Neighbor timer hold time',
+ 310: 'Invalid neighbor password ',
+ 311: 'Invalid Max peer limit',
+ 312: 'Invalid Local AS Number',
+ 313: 'Invalid maximum hop count',
+ 314: 'Invalid neighbor description',
+ 315: 'Invalid Neighbor connect timer value',
+ 316: 'Invalid Neighbor address family option',
+ 317: 'Invalid neighbor address family option',
+ 318: 'Invalid route-map name',
+ 319: 'Invalid route-map',
+ 320: 'Invalid Name of a prefix list',
+ 321: 'Invalid Filter incoming option',
+ 322: 'Invalid AS path access-list name',
+ 323: 'Invalid Filter route option',
+ 324: 'Invalid route-map name',
+ 325: 'Invalid Number of occurrences of AS number',
+ 326: 'Invalid Prefix Limit'}
+
+
+def getErrorString(errorCode):
+ retVal = errorDict[int(errorCode)]
+ return retVal
+# EOM
diff --git a/lib/ansible/modules/network/cnos/__init__.py b/lib/ansible/modules/network/cnos/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/lib/ansible/modules/network/cnos/cnos_vlan.py b/lib/ansible/modules/network/cnos/cnos_vlan.py
new file mode 100644
index 00000000000..c7b513cfaa4
--- /dev/null
+++ b/lib/ansible/modules/network/cnos/cnos_vlan.py
@@ -0,0 +1,288 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2017 Lenovo, Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see .
+#
+# Module to send VLAN commands to Lenovo Switches
+# Overloading aspect of vlan creation in a range is pending
+# Lenovo Networking
+#
+
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
+DOCUMENTATION = '''
+---
+module: cnos_vlan
+short_description: Performs VLAN switch configuration and state management.
+description:
+ - This module allows you to work with VLAN related configurations. The
+ operators used are overloaded to ensure control over switch VLAN
+ configurations. The first level of VLAN configuration allows to set up the
+ VLAN range, the VLAN tag persistence, a VLAN access map and access map
+ filter. After passing this level, there are five VLAN arguments that will
+ perform further configurations. They are vlanArg1, vlanArg2, vlanArg3,
+ vlanArg4, and vlanArg5. The value of vlanArg1 will determine the way
+ following arguments will be evaluated. For more details on how to use these
+ arguments, see [Overloaded Variables].
+ This module uses SSH to manage network device configuration.
+ The results of the operation will be placed in a directory named 'results'
+ that must be created by the user in their local directory to where the playbook is run.
+ For more information about this module from Lenovo and customizing it usage for your
+ use cases, please visit our [User Guide](http://systemx.lenovofiles.com/help/index.jsp?topic=%2Fcom.lenovo.switchmgt.ansible.doc%2Fcnos_vlan.html)
+version_added: "2.3"
+extends_documentation_fragment: cnos
+options:
+ vlanArg1:
+ description:
+ - This is an overloaded vlan first argument. Usage of this argument can be found is the User Guide referenced above.
+ required: true
+ default: null
+ choices: [access-map, dot1q, filter, <1-3999> VLAN ID 1-3999 or range]
+ vlanArg2:
+ description:
+ - This is an overloaded vlan second argument. Usage of this argument can be found is the User Guide referenced above.
+ required: false
+ default: null
+ choices: [VLAN Access Map name,egress-only,name, flood,state, ip]
+ vlanArg3:
+ description:
+ - This is an overloaded vlan third argument. Usage of this argument can be found is the User Guide referenced above.
+ required: false
+ default: null
+ choices: [action, match, statistics, enter VLAN id or range of vlan, ascii name for the VLAN, ipv4 or ipv6, active or suspend, fast-leave,
+ last-member-query-interval, mrouter, querier, querier-timeout, query-interval, query-max-response-time, report-suppression,
+ robustness-variable, startup-query-count, startup-query-interval, static-group]
+ vlanArg4:
+ description:
+ - This is an overloaded vlan fourth argument. Usage of this argument can be found is the User Guide referenced above.
+ required: false
+ default: null
+ choices: [drop or forward or redirect, ip or mac,Interval in seconds,ethernet, port-aggregation, Querier IP address,
+ Querier Timeout in seconds, Query Interval in seconds, Query Max Response Time in seconds, Robustness Variable value,
+ Number of queries sent at startup, Query Interval at startup]
+ vlanArg5:
+ description:
+ - This is an overloaded vlan fifth argument. Usage of this argument can be found is the User Guide referenced above.
+ required: false
+ default: null
+ choices: [access-list name, Slot/chassis number, Port Aggregation Number]
+
+'''
+EXAMPLES = '''
+
+Tasks: The following are examples of using the module cnos_vlan. These are written in the main.yml file of the tasks directory.
+---
+- 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'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_vlan_{{ inventory_hostname }}_output.txt"
+ vlanArg1: 13
+ vlanArg2: "name"
+ vlanArg3: "Anil"
+
+- 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'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_vlan_{{ inventory_hostname }}_output.txt"
+ vlanArg1: 13
+ vlanArg2: "flood"
+ vlanArg3: "ipv4"
+
+- 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'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_vlan_{{ inventory_hostname }}_output.txt"
+ vlanArg1: 13
+ vlanArg2: "state"
+ vlanArg3: "active"
+
+- 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'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_vlan_{{ inventory_hostname }}_output.txt"
+ vlanArg1: "access-map"
+ vlanArg2: "Anil"
+ vlanArg3: "statistics"
+
+- 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'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_vlan_{{ inventory_hostname }}_output.txt"
+ vlanArg1: "access-map"
+ vlanArg2: "Anil"
+ vlanArg3: "action"
+ vlanArg4: "forward"
+
+- 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'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_vlan_{{ inventory_hostname }}_output.txt"
+ vlanArg1: 13
+ vlanArg2: "ip"
+ vlanArg3: "query-interval"
+ vlanArg4: 1313
+
+- name: Test Vlan - ip igmp snooping mrouter interface port-aggregation 23
+ cnos_vlan:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_vlan_{{ inventory_hostname }}_output.txt"
+ vlanArg1: 13
+ vlanArg2: "ip"
+ vlanArg3: "mrouter"
+ vlanArg4: "port-aggregation"
+ vlanArg5: 23
+
+'''
+RETURN = '''
+return value: |
+ On successful execution, the method returns a message in JSON format
+ [VLAN configurations are successful]
+ Upon any failure, the method returns an error display string.
+'''
+
+import sys
+import paramiko
+import time
+import argparse
+import socket
+import array
+import json
+import time
+import re
+
+try:
+ import cnos
+ HAS_LIB = True
+except:
+ HAS_LIB = False
+
+from ansible.module_utils.basic import AnsibleModule
+from collections import defaultdict
+
+def main():
+ #
+ # Define parameters for vlan creation entry
+ #
+ module = AnsibleModule(
+ argument_spec=dict(
+ outputfile=dict(required=True),
+ host=dict(required=True),
+ username=dict(required=True),
+ password=dict(required=True, no_log=True),
+ enablePassword=dict(required=False, no_log=True),
+ deviceType=dict(required=True),
+ vlanArg1=dict(required=True),
+ vlanArg2=dict(required=False),
+ vlanArg3=dict(required=False),
+ vlanArg4=dict(required=False),
+ vlanArg5=dict(required=False),),
+ supports_check_mode=False)
+
+ username = module.params['username']
+ password = module.params['password']
+ enablePassword = module.params['enablePassword']
+ vlanArg1 = module.params['vlanArg1']
+ vlanArg2 = module.params['vlanArg2']
+ vlanArg3 = module.params['vlanArg3']
+ vlanArg4 = module.params['vlanArg4']
+ vlanArg5 = module.params['vlanArg5']
+ outputfile = module.params['outputfile']
+ hostIP = module.params['host']
+ deviceType = module.params['deviceType']
+
+ output = ""
+
+ # Create instance of SSHClient object
+ remote_conn_pre = paramiko.SSHClient()
+
+ # Automatically add untrusted hosts (make sure okay for security policy in
+ # your environment)
+ remote_conn_pre.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+
+ # initiate SSH connection with the switch
+ remote_conn_pre.connect(hostIP, username=username, password=password)
+ time.sleep(2)
+
+ # Use invoke_shell to establish an 'interactive session'
+ remote_conn = remote_conn_pre.invoke_shell()
+ time.sleep(2)
+
+ # Enable and enter configure terminal then send command
+ output = output + cnos.waitForDeviceResponse("\n", ">", 2, remote_conn)
+
+ output = output + \
+ cnos.enterEnableModeForDevice(enablePassword, 3, remote_conn)
+
+ # Make terminal length = 0
+ output = output + \
+ cnos.waitForDeviceResponse("terminal length 0\n", "#", 2, remote_conn)
+
+ # Go to config mode
+ output = output + \
+ cnos.waitForDeviceResponse("conf d\n", "(config)#", 2, remote_conn)
+
+ # Send the CLi command
+ output = output + \
+ cnos.vlanConfig(
+ remote_conn, deviceType, "(config)#", 2, vlanArg1, vlanArg2,
+ vlanArg3, vlanArg4, vlanArg5)
+
+ # Save it into the file
+ file = open(outputfile, "a")
+ file.write(output)
+ file.close()
+
+ # need to add logic to check when changes occur or not
+ errorMsg = cnos.checkOutputForError(output)
+ if(errorMsg is None):
+ module.exit_json(changed=True, msg="VLAN configuration isaccomplished")
+ else:
+ module.fail_json(msg=errorMsg)
+
+if __name__ == '__main__':
+ main()
diff --git a/lib/ansible/utils/module_docs_fragments/cnos.py b/lib/ansible/utils/module_docs_fragments/cnos.py
new file mode 100644
index 00000000000..913f1311ef9
--- /dev/null
+++ b/lib/ansible/utils/module_docs_fragments/cnos.py
@@ -0,0 +1,85 @@
+# Copyright (C) 2017 Lenovo, Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see .
+#
+
+
+class ModuleDocFragment(object):
+ # Standard CNOS documentation fragment
+ DOCUMENTATION = '''
+options:
+ outputfile:
+ description:
+ - This specifies the file path where the output of each command
+ execution is saved. Each command that is specified in the merged
+ template file and each response from the device are saved here.
+ Usually the location is the results folder, but you can
+ choose another location based on your write permission.
+ required: true
+ default: Null
+ version_added: 2.3
+ host:
+ description:
+ - This is the variable used to search the hosts file at
+ /etc/ansible/hosts and identify the IP address of the device on
+ which the template is going to be applied. Usually the Ansible
+ keyword {{ inventory_hostname }} is specified in the playbook as
+ an abstraction of the group of network elements that need to be
+ configured.
+ required: true
+ default: Null
+ version_added: 2.3
+ username:
+ description:
+ - Configures the username used to authenticate the connection to
+ the remote device. The value of the username parameter is used to
+ authenticate the SSH session. While generally the value should
+ come from the inventory file, you can also specify it as a
+ variable. This parameter is optional. If it is not specified, no
+ default value will be used.
+ required: true
+ default: Null
+ version_added: 2.3
+ password:
+ description:
+ - Configures the password used to authenticate the connection to
+ the remote device. The value of the password parameter is used to
+ authenticate the SSH session. While generally the value should
+ come from the inventory file, you can also specify it as a
+ variable. This parameter is optional. If it is not specified, no
+ default value will be used.
+ required: true
+ default: Null
+ version_added: 2.3
+ enablePassword:
+ description:
+ - Configures the password used to enter Global Configuration
+ command mode on the switch. If the switch does not request this
+ password, the parameter is ignored.While generally the value
+ should come from the inventory file, you can also specify it as a
+ variable. This parameter is optional. If it is not specified,
+ no default value will be used.
+ required: false
+ default: Null
+ version_added: 2.3
+ deviceType:
+ description:
+ - This specifies the type of device where the method is executed.
+ required: Yes
+ default: null
+ choices: [g8272_cnos,g8296_cnos,g8332_cnos]
+ version_added: 2.3
+'''
diff --git a/test/integration/cnos.yaml b/test/integration/cnos.yaml
new file mode 100644
index 00000000000..eab7a879431
--- /dev/null
+++ b/test/integration/cnos.yaml
@@ -0,0 +1,24 @@
+- hosts: cnos
+ gather_facts: no
+ connection: local
+
+ vars:
+ limit_to: "*"
+ debug: false
+
+ roles:
+ - { role: cnos_facts, when: "limit_to in ['*', 'cnos_facts']" }
+ - { role: cnos_vlan, when: "limit_to in ['*', 'cnos_vlan']" }
+ - { role: cnos_ethernet, when: "limit_to in ['*', 'cnos_ethernet']" }
+ - { role: cnos_image, when: "limit_to in ['*', 'cnos_image']" }
+ - { role: cnos_portchannel, when: "limit_to in ['*', 'cnos_portchannel']" }
+ - { role: cnos_rollback, when: "limit_to in ['*', 'cnos_rollback']" }
+ - { role: cnos_save, when: "limit_to in ['*', 'cnos_save']" }
+ - { role: cnos_template, when: "limit_to in ['*', 'cnos_template']" }
+ - { role: cnos_conditional_template, when: "limit_to in ['*', 'cnos_conditional_template']" }
+ - { role: cnos_conditional_command, when: "limit_to in ['*', 'cnos_conditional_command']" }
+ - { role: cnos_vlag, when: "limit_to in ['*', 'cnos_vlag']" }
+ - { role: cnos_command, when: "limit_to in ['*', 'cnos_command']" }
+ - { role: cnos_bgp, when: "limit_to in ['*', 'cnos_bgp']" }
+ - { role: cnos_backup, when: "limit_to in ['*', 'cnos_backup']" }
+ - { role: cnos_showrun, when: "limit_to in ['*', 'cnos_showrun']" }
\ No newline at end of file
diff --git a/test/integration/targets/cnos_vlan/README.md b/test/integration/targets/cnos_vlan/README.md
new file mode 100644
index 00000000000..35e89792ca1
--- /dev/null
+++ b/test/integration/targets/cnos_vlan/README.md
@@ -0,0 +1,114 @@
+# Ansible Role: cnos_vlan_sample - Switch VLAN configuration
+---
+
+
+This role is an example of using the *cnos_vlan.py* Lenovo module in the context of CNOS switch configuration. This module allows you to work with VLAN related configurations. The operators used are overloaded to ensure control over switch VLAN configurations.
+
+The first level of VLAN configuration allows to set up the VLAN range, the VLAN tag persistence, a VLAN access map and access map filter. After passing this level, there are five VLAN arguments that will perform further configurations. They are *vlanArg1*, *vlanArg2*, *vlanArg3*, *vlanArg4*, and *vlanArg5*. The value of *vlanArg1* will determine the way following arguments will be evaluated.
+
+The results of the operation can be viewed in *results* directory.
+
+For more details, see [Lenovo modules for Ansible: cnos_vlan](http://systemx.lenovofiles.com/help/index.jsp?topic=%2Fcom.lenovo.switchmgt.ansible.doc%2Fcnos_vlan.html&cp=0_3_1_0_4_14).
+
+
+## Requirements
+---
+
+
+- Ansible version 2.2 or later ([Ansible installation documentation](http://docs.ansible.com/ansible/intro_installation.html))
+- Lenovo switches running CNOS version 10.2.1.0 or later
+- an SSH connection to the Lenovo switch (SSH must be enabled on the network device)
+
+
+## Role Variables
+---
+
+
+Available variables are listed below, along with description.
+
+The following are mandatory inventory variables:
+
+Variable | Description
+--- | ---
+`username` | Specifies the username used to log into the switch
+`password` | Specifies the password used to log into the switch
+`enablePassword` | Configures the password used to enter Global Configuration command mode on the switch (this is an optional parameter)
+`hostname` | Searches the hosts file at */etc/ansible/hosts* and identifies the IP address of the switch on which the role is going to be applied
+`deviceType` | Specifies the type of device from where the configuration will be backed up (**g8272_cnos** - G8272, **g8296_cnos** - G8296)
+
+The values of the variables used need to be modified to fit the specific scenario in which you are deploying the solution. To change the values of the variables, you need to visits the *vars* directory of each role and edit the *main.yml* file located there. The values stored in this file will be used by Ansible when the template is executed.
+
+The syntax of *main.yml* file for variables is the following:
+
+```
+:
+```
+
+You will need to replace the `` field with the value that suits your topology. The `` fields are taken from the template and it is recommended that you leave them unchanged.
+
+Variable | Description
+--- | ---
+`vlanArg1` | This is an overloaded BGP variable. Please refer to the [cnos_vlan module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_vlan.html?cp=0_3_1_0_2_16) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **access-map**, **dot1q**, **filter**, specify VLAN.
+`vlanArg2` | This is an overloaded BGP variable. Please refer to the [cnos_vlan module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_vlan.html?cp=0_3_1_0_2_16) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: VLAN access map name, **egress-only**, **name**, **flood**, **state**, **ip**.
+`vlanArg3` | This is an overloaded BGP variable. Please refer to the [cnos_vlan module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_vlan.html?cp=0_3_1_0_2_16) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **action**, **match**, **statistics**, specify VLAN, name of the VLAN, **ipv4**, **ipv6**, **active**, **suspend**, **fast-leave**, **last-member-query-interval**, **mrouter**, **querier**, **querier-timeout**, **query-interval**, **query-max-response-time**, **report-suppression**, **robustness-variable**, **startup-query-count**, **startup-query-interval**.
+`vlanArg4` | This is an overloaded BGP variable. Please refer to the [cnos_vlan module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_vlan.html?cp=0_3_1_0_2_16) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **drop**, **forward**, **redirect**, **ip**, **mac**, last member query interval, **ethernet**, **port-aggregation**, querier IP address, querier timeout interval, query interval, query maximum response interval, robustness variable value, numbers of queries sent at startup, startup query interval.
+`vlanArg5` | This is an overloaded BGP variable. Please refer to the [cnos_vlan module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_vlan.html?cp=0_3_1_0_2_16) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: ACL name, specify ethernet port, LAG number.
+
+
+## Dependencies
+---
+
+
+- username.iptables - Configures the firewall and blocks all ports except those needed for web server and SSH access.
+- username.common - Performs common server configuration.
+- cnos_vlan.py - This modules needs to be present in the *library* directory of the role.
+- cnos.py - This module needs to be present in the PYTHONPATH environment variable set in the Ansible system.
+- /etc/ansible/hosts - You must edit the */etc/ansible/hosts* file with the device information of the switches designated as leaf switches. You may refer to *cnos_vlan_sample_hosts* for a sample configuration.
+
+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.
+
+```
+[cnos_vlan_sample]
+10.241.107.39 username= password= deviceType=g8272_cnos
+10.241.107.40 username= password= deviceType=g8272_cnos
+```
+
+**Note:** You need to change the IP addresses to fit your specific topology. You also need to change the `` and `` to the appropriate values used to log into the specific Lenovo network devices.
+
+
+## Example Playbook
+---
+
+
+To execute an Ansible playbook, use the following command:
+
+```
+ansible-playbook cnos_vlan_sample.yml -vvv
+```
+
+`-vvv` is an optional verbos command that helps identify what is happening during playbook execution. The playbook for each role is located in the main directory of the solution.
+
+```
+ - name: Module to do VLAN configurations
+ hosts: cnos_vlan_sample
+ gather_facts: no
+ connection: local
+ roles:
+ - cnos_vlan_sample
+```
+
+
+## License
+---
+
+Copyright (C) 2017 Lenovo, Inc.
+
+This file is part of Ansible
+
+Ansible is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+
+Ansible is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with Ansible. If not, see .
\ No newline at end of file
diff --git a/test/integration/targets/cnos_vlan/aliases b/test/integration/targets/cnos_vlan/aliases
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/test/integration/targets/cnos_vlan/cnos_vlan_sample_hosts b/test/integration/targets/cnos_vlan/cnos_vlan_sample_hosts
new file mode 100644
index 00000000000..9d822245615
--- /dev/null
+++ b/test/integration/targets/cnos_vlan/cnos_vlan_sample_hosts
@@ -0,0 +1,15 @@
+# You have to paste this dummy information in /etc/ansible/hosts
+# Notes:
+# - Comments begin with the '#' character
+# - Blank lines are ignored
+# - Groups of hosts are delimited by [header] elements
+# - You can enter hostnames or ip addresses
+# - A hostname/ip can be a member of multiple groups
+#
+# In the /etc/ansible/hosts file u have to enter [cnos_vlan_sample] tag
+# Following you should specify IP Adresses details
+# Please change and with appropriate value for your switch.
+
+[cnos_vlan_sample]
+10.241.107.39 username= password= deviceType=g8272_cnos
+
diff --git a/test/integration/targets/cnos_vlan/tasks/main.yml b/test/integration/targets/cnos_vlan/tasks/main.yml
new file mode 100644
index 00000000000..0d19e68555a
--- /dev/null
+++ b/test/integration/targets/cnos_vlan/tasks/main.yml
@@ -0,0 +1,30 @@
+# This contain sample template execution task
+---
+- 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}}"
+# Completed file
\ No newline at end of file
diff --git a/test/integration/targets/cnos_vlan/vars/main.yml b/test/integration/targets/cnos_vlan/vars/main.yml
new file mode 100644
index 00000000000..c22b9cda1b9
--- /dev/null
+++ b/test/integration/targets/cnos_vlan/vars/main.yml
@@ -0,0 +1,19 @@
+---
+cnos_vlan_data1:
+ - {vlanArg1: 13, vlanArg2: "name", vlanArg3: "anil"}
+cnos_vlan_data2:
+ - {vlanArg1: 13, vlanArg2: "flood", vlanArg3: "ipv4"}
+cnos_vlan_data3:
+ - {vlanArg1: 13, vlanArg2: "state", vlanArg3: "active"}
+cnos_vlan_data4:
+ - {vlanArg1: "access-map", vlanArg2: "anil", vlanArg3: "statistics"}
+cnos_vlan_data5:
+ - {vlanArg1: "access-map", vlanArg2: "anil", vlanArg3: "action", vlanArg4: "forward"}
+cnos_vlan_data6:
+ - {vlanArg1: 13, vlanArg2: "ip", vlanArg3: "query-interval", vlanArg4: 1313}
+cnos_vlan_data7:
+ - {vlanArg1: 13, vlanArg2: "ip", vlanArg3: "last-member-query-interval", vlanArg4: 23}
+cnos_vlan_data8:
+ - {vlanArg1: 13, vlanArg2: "ip", vlanArg3: "mrouter", vlanArg4: "port-aggregation", vlanArg5: 23}
+cnos_vlan_data9:
+ - {clicommand: "no vlan 13"}
\ No newline at end of file
diff --git a/test/integration/targets/parsing/cnos_vlan/README.md b/test/integration/targets/parsing/cnos_vlan/README.md
new file mode 100644
index 00000000000..7deb238783e
--- /dev/null
+++ b/test/integration/targets/parsing/cnos_vlan/README.md
@@ -0,0 +1,114 @@
+# Ansible Role: cnos_vlan_sample - Switch VLAN configuration
+---
+
+
+This role is an example of using the *cnos_vlan.py* Lenovo module in the context of CNOS switch configuration. This module allows you to work with VLAN related configurations. The operators used are overloaded to ensure control over switch VLAN configurations.
+
+The first level of VLAN configuration allows to set up the VLAN range, the VLAN tag persistence, a VLAN access map and access map filter. After passing this level, there are five VLAN arguments that will perform further configurations. They are *vlanArg1*, *vlanArg2*, *vlanArg3*, *vlanArg4*, and *vlanArg5*. The value of *vlanArg1* will determine the way following arguments will be evaluated.
+
+The results of the operation can be viewed in *results* directory.
+
+For more details, see [Lenovo modules for Ansible: cnos_vlan](http://systemx.lenovofiles.com/help/index.jsp?topic=%2Fcom.lenovo.switchmgt.ansible.doc%2Fcnos_vlan.html&cp=0_3_1_0_4_14).
+
+
+## Requirements
+---
+
+
+- Ansible version 2.2 or later ([Ansible installation documentation](http://docs.ansible.com/ansible/intro_installation.html))
+- Lenovo switches running CNOS version 10.2.1.0 or later
+- an SSH connection to the Lenovo switch (SSH must be enabled on the network device)
+
+
+## Role Variables
+---
+
+
+Available variables are listed below, along with description.
+
+The following are mandatory inventory variables:
+
+Variable | Description
+--- | ---
+`username` | Specifies the username used to log into the switch
+`password` | Specifies the password used to log into the switch
+`enablePassword` | Configures the password used to enter Global Configuration command mode on the switch (this is an optional parameter)
+`hostname` | Searches the hosts file at */etc/ansible/hosts* and identifies the IP address of the switch on which the role is going to be applied
+`deviceType` | Specifies the type of device from where the configuration will be backed up (**g8272_cnos** - G8272, **g8296_cnos** - G8296)
+
+The values of the variables used need to be modified to fit the specific scenario in which you are deploying the solution. To change the values of the variables, you need to visits the *vars* directory of each role and edit the *main.yml* file located there. The values stored in this file will be used by Ansible when the template is executed.
+
+The syntax of *main.yml* file for variables is the following:
+
+```
+:
+```
+
+You will need to replace the `` field with the value that suits your topology. The `` fields are taken from the template and it is recommended that you leave them unchanged.
+
+Variable | Description
+--- | ---
+`vlanArg1` | This is an overloaded BGP variable. Please refer to the [cnos_vlan module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_vlan.html?cp=0_3_1_0_2_16) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **access-map**, **dot1q**, **filter**, specify VLAN.
+`vlanArg2` | This is an overloaded BGP variable. Please refer to the [cnos_vlan module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_vlan.html?cp=0_3_1_0_2_16) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: VLAN access map name, **egress-only**, **name**, **flood**, **state**, **ip**.
+`vlanArg3` | This is an overloaded BGP variable. Please refer to the [cnos_vlan module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_vlan.html?cp=0_3_1_0_2_16) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **action**, **match**, **statistics**, specify VLAN, name of the VLAN, **ipv4**, **ipv6**, **active**, **suspend**, **fast-leave**, **last-member-query-interval**, **mrouter**, **querier**, **querier-timeout**, **query-interval**, **query-max-response-time**, **report-suppression**, **robustness-variable**, **startup-query-count**, **startup-query-interval**.
+`vlanArg4` | This is an overloaded BGP variable. Please refer to the [cnos_vlan module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_vlan.html?cp=0_3_1_0_2_16) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **drop**, **forward**, **redirect**, **ip**, **mac**, last member query interval, **ethernet**, **port-aggregation**, querier IP address, querier timeout interval, query interval, query maximum response interval, robustness variable value, numbers of queries sent at startup, startup query interval.
+`vlanArg5` | This is an overloaded BGP variable. Please refer to the [cnos_vlan module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_vlan.html?cp=0_3_1_0_2_16) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: ACL name, specify ethernet port, LAG number.
+
+
+## Dependencies
+---
+
+
+- username.iptables - Configures the firewall and blocks all ports except those needed for web server and SSH access.
+- username.common - Performs common server configuration.
+- cnos_vlan.py - This modules needs to be present in the *library* directory of the role.
+- cnos.py - This module needs to be present in the PYTHONPATH environment variable set in the Ansible system.
+- /etc/ansible/hosts - You must edit the */etc/ansible/hosts* file with the device information of the switches designated as leaf switches. You may refer to *cnos_vlan_sample_hosts* for a sample configuration.
+
+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 sample hosts file for the role is located in the main directory.
+
+```
+[cnos_vlan_sample]
+10.241.107.39 username= password= deviceType=g8272_cnos
+10.241.107.40 username= password= deviceType=g8272_cnos
+```
+
+**Note:** You need to change the IP addresses to fit your specific topology. You also need to change the `` and `` to the appropriate values used to log into the specific Lenovo network devices.
+
+
+## Example Playbook
+---
+
+
+To execute an Ansible playbook, use the following command:
+
+```
+ansible-playbook cnos_vlan_sample.yml -vvv
+```
+
+`-vvv` is an optional verbos command that helps identify what is happening during playbook execution. The playbook for each role is located in the main directory of the solution.
+
+```
+ - name: Module to do VLAN configurations
+ hosts: cnos_vlan_sample
+ gather_facts: no
+ connection: local
+ roles:
+ - cnos_vlan_sample
+```
+
+
+## License
+---
+
+Copyright (C) 2017 Lenovo, Inc.
+
+This file is part of Ansible
+
+Ansible is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+
+Ansible is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with Ansible. If not, see .
\ No newline at end of file
diff --git a/test/integration/targets/parsing/cnos_vlan/aliases b/test/integration/targets/parsing/cnos_vlan/aliases
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/test/integration/targets/parsing/cnos_vlan/cnos_vlan_sample_hosts b/test/integration/targets/parsing/cnos_vlan/cnos_vlan_sample_hosts
new file mode 100644
index 00000000000..9d822245615
--- /dev/null
+++ b/test/integration/targets/parsing/cnos_vlan/cnos_vlan_sample_hosts
@@ -0,0 +1,15 @@
+# You have to paste this dummy information in /etc/ansible/hosts
+# Notes:
+# - Comments begin with the '#' character
+# - Blank lines are ignored
+# - Groups of hosts are delimited by [header] elements
+# - You can enter hostnames or ip addresses
+# - A hostname/ip can be a member of multiple groups
+#
+# In the /etc/ansible/hosts file u have to enter [cnos_vlan_sample] tag
+# Following you should specify IP Adresses details
+# Please change and with appropriate value for your switch.
+
+[cnos_vlan_sample]
+10.241.107.39 username= password= deviceType=g8272_cnos
+
diff --git a/test/integration/targets/parsing/cnos_vlan/tasks/main.yml b/test/integration/targets/parsing/cnos_vlan/tasks/main.yml
new file mode 100644
index 00000000000..c5bced79cfd
--- /dev/null
+++ b/test/integration/targets/parsing/cnos_vlan/tasks/main.yml
@@ -0,0 +1,30 @@
+# This contain sample template execution task
+---
+- 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}}"
+# Completed file
diff --git a/test/integration/targets/parsing/cnos_vlan/vars/main.yml b/test/integration/targets/parsing/cnos_vlan/vars/main.yml
new file mode 100644
index 00000000000..3ac98a7cb79
--- /dev/null
+++ b/test/integration/targets/parsing/cnos_vlan/vars/main.yml
@@ -0,0 +1,19 @@
+---
+cnos_vlan_data1:
+ - {vlanArg1: 13, vlanArg2: "name", vlanArg3: "anil"}
+cnos_vlan_data2:
+ - {vlanArg1: 13, vlanArg2: "flood", vlanArg3: "ipv4"}
+cnos_vlan_data3:
+ - {vlanArg1: 13, vlanArg2: "state", vlanArg3: "active"}
+cnos_vlan_data4:
+ - {vlanArg1: "access-map", vlanArg2: "anil", vlanArg3: "statistics"}
+cnos_vlan_data5:
+ - {vlanArg1: "access-map", vlanArg2: "anil", vlanArg3: "action", vlanArg4: "forward"}
+cnos_vlan_data6:
+ - {vlanArg1: 13, vlanArg2: "ip", vlanArg3: "query-interval", vlanArg4: 1313}
+cnos_vlan_data7:
+ - {vlanArg1: 13, vlanArg2: "ip", vlanArg3: "last-member-query-interval", vlanArg4: 23}
+cnos_vlan_data8:
+ - {vlanArg1: 13, vlanArg2: "ip", vlanArg3: "mrouter", vlanArg4: "port-aggregation", vlanArg5: 23}
+cnos_vlan_data9:
+ - {clicommand: "no vlan 13"}