lenovo-rbapi 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,124 @@
1
+ ##
2
+ ## Copyright (c) 2017, Lenovo. All rights reserved.
3
+ ##
4
+ ## This program and the accompanying materials are licensed and made available
5
+ ## under the terms and conditions of the 3-clause BSD License that accompanies
6
+ ## this distribution.
7
+ ##
8
+ ## The full text of the license may be found at
9
+ ##
10
+ ## https://opensource.org/licenses/BSD-3-Clause
11
+ ##
12
+ ## THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13
+ ## WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
+ ##
15
+ require 'rest-client'
16
+ require 'json'
17
+ require_relative 'connect'
18
+ require_relative 'rest_utils'
19
+
20
+
21
+
22
+ ##
23
+ ## The Vlan class provides a class implementation and methods for managing the VLANs
24
+ ## on the node. This class presents an abstraction
25
+ ##
26
+ #
27
+
28
+ class Vlan
29
+ @cfg = '/nos/api/cfg/vlan'
30
+
31
+ # This API gets properties of all VLANS.
32
+ #
33
+ #
34
+ # parameters:
35
+ # conn - connection object to the node
36
+ #
37
+ # return: JSON response
38
+ def self.get_all_vlan(conn)
39
+ url = form_url(conn, @cfg)
40
+ hdr = form_hdr(conn)
41
+ Rest.get(conn, url, hdr)
42
+ end
43
+
44
+ # This API creates a Vlan.
45
+ #
46
+ #
47
+ # parameters:
48
+ # conn - connection object to the node
49
+ # params - dictionary that requires the following format of key-value pairs
50
+ # {
51
+ #   "vlan_name": "<vlan_name>",
52
+ #   "vlan_id": "<vlan_id>",
53
+ #   "admin_state": "<admin_state>",
54
+ # }
55
+ # description -
56
+ # vlan_name :VLAN name; a string up to 32 characters long. To create a VLAN
57
+ # with the default name, the vlan_name field must be null.
58
+ # vlan_id :VLAN number.; an integer from 2‐3999.
59
+ # admin_state :The admin status; one of up, down
60
+ #
61
+ # return: JSON response
62
+ def self.create_vlan(conn, params)
63
+ url = form_url(conn, @cfg)
64
+ hdr = form_hdr(conn)
65
+ params = params.to_json
66
+ Rest.post(conn, url, hdr, params)
67
+
68
+ end
69
+
70
+ # This API gets properties of a vlan.
71
+ #
72
+ #
73
+ # parameters:
74
+ # conn - connection object to the node
75
+ # vlan_id - VLAN number
76
+ #
77
+ # return: JSON response
78
+ def self.get_vlan_prop(conn, vlan_id)
79
+ url = form_url(conn, @cfg + '/' + vlan_id.to_s)
80
+ hdr = form_hdr(conn)
81
+ Rest.get(conn, url, hdr)
82
+ end
83
+
84
+ # This API updates properties of a VLAN.
85
+ #
86
+ #
87
+ # parameters:
88
+ # conn - connection object to the node
89
+ # vlan_id - VLAN number
90
+ # params - dictionary that requires the following format of key-value pairs
91
+ # {
92
+ #  "vlan_name": "<vlan_name>",
93
+ #  "admin_state": "<admin_state>"
94
+ # }
95
+ # description -
96
+ # vlan_name :VLAN name; a string up to 32 characters long. To change a VLAN
97
+ # name with default name, the vlan_name field must be null.
98
+ # admin_state :The admin status; one of up, down
99
+ #
100
+ # return: JSON response
101
+ def self.update_vlan(conn, vlan_id, params)
102
+ url = form_url(conn, @cfg + '/' + vlan_id.to_s)
103
+ hdr = form_hdr(conn)
104
+ params = params.to_json
105
+ Rest.put(conn, url, hdr, params)
106
+
107
+ end
108
+
109
+ # This API deletes a vlan.
110
+ #
111
+ #
112
+ # parameters:
113
+ # conn - connection object to the node
114
+ # vlan_id - VLAN number
115
+ # Note: If the specified vlan_id is all, all user‐created VLANs will be deleted.
116
+ #
117
+ # return:
118
+ def self.delete_vlan(conn, vlan_id)
119
+ url = form_url(conn, @cfg + '/' + vlan_id.to_s)
120
+ hdr = form_hdr(conn)
121
+ Rest.delete(conn, url, hdr)
122
+ end
123
+
124
+ end
@@ -0,0 +1,89 @@
1
+ ##
2
+ ## Copyright (c) 2017, Lenovo. All rights reserved.
3
+ ##
4
+ ## This program and the accompanying materials are licensed and made available
5
+ ## under the terms and conditions of the 3-clause BSD License that accompanies
6
+ ## this distribution.
7
+ ##
8
+ ## The full text of the license may be found at
9
+ ##
10
+ ## https://opensource.org/licenses/BSD-3-Clause
11
+ ##
12
+ ## THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13
+ ## WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
+ ##
15
+ require 'rest-client'
16
+ require 'json'
17
+ require_relative 'connect'
18
+ require_relative 'rest_utils'
19
+
20
+ ##
21
+ ## The VlanIntf class provides a class implementation and methods for managing the Vlan Interfaces
22
+ ## on the node. This class presents an abstraction
23
+ ##
24
+
25
+
26
+ class VlanIntf
27
+ @cfg = '/nos/api/cfg/vlan_interface'
28
+ # This API gets VLAN properties of all Ethernet interfaces.
29
+ #
30
+ #
31
+ # parameters:
32
+ # conn - connection object to the node
33
+ #
34
+ # return: JSON response
35
+ def self.get_all_vlan_intf(conn)
36
+ url = form_url(conn, @cfg)
37
+ hdr = form_hdr(conn)
38
+ Rest.get(conn, url, hdr)
39
+ end
40
+
41
+ # This API gets VLAN properties of an Ethernet Interface.
42
+ #
43
+ #
44
+ # parameters:
45
+ # conn - connection object to the node
46
+ # vlan_intf - Interface
47
+ #
48
+ # return: JSON response
49
+ def self.get_vlan_prop_intf(conn, vlan_intf)
50
+ temp = vlan_intf.dup
51
+ temp.sub! '/', '%2F'
52
+ url = form_url(conn, @cfg + '/' + temp)
53
+ hdr = form_hdr(conn)
54
+ Rest.get(conn, url, hdr)
55
+ end
56
+
57
+ # This API updates properties of a Lag.
58
+ #
59
+ #
60
+ # parameters:
61
+ # conn - connection object to the node
62
+ # params - dictionary that requires the following format of key-value pairs
63
+ # {
64
+ #
65
+ # "if_name": "<if_name>",
66
+ # “bridgeport_mode”: “<bridgeport_mode>”
67
+ # “pvid”: "<pvid>",
68
+ # “vlans”: ["<vlan_id>"]
69
+ # }
70
+ # description -
71
+ # if_name :Ethernet interface name (String).Note: The Ethernet interface must exist.
72
+ # bridgeport_ mode :Bridge port mode; one of access, trunk
73
+ # pvid :Native VLAN for a port (the access VLAN for access ports or the
74
+ # native VLAN for trunk ports); an integer from 1‐3999. Default
75
+ # value: 1.
76
+ # vlans :(Optional) VLAN memberships; all, none, or an integer from
77
+ # 1‐3999.
78
+ #
79
+ # return: JSON response
80
+ def self.update_vlan_intf(conn, vlan_intf, params)
81
+ temp = vlan_intf.dup
82
+ temp.sub! '/', '%2F'
83
+ url = form_url(conn, @cfg + '/' + temp)
84
+ hdr = form_hdr(conn)
85
+ params = params.to_json
86
+ Rest.put(conn, url, hdr, params)
87
+ end
88
+
89
+ end
@@ -0,0 +1,198 @@
1
+ ##
2
+ ## Copyright (c) 2017, Lenovo. All rights reserved.
3
+ ##
4
+ ## This program and the accompanying materials are licensed and made available
5
+ ## under the terms and conditions of the 3-clause BSD License that accompanies
6
+ ## this distribution.
7
+ ##
8
+ ## The full text of the license may be found at
9
+ ##
10
+ ## https://opensource.org/licenses/BSD-3-Clause
11
+ ##
12
+ ## THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13
+ ## WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
+ ##
15
+ require 'rest-client'
16
+ require 'json'
17
+ require_relative 'connect'
18
+ require_relative 'rest_utils'
19
+
20
+
21
+ ##
22
+ ## The Vrrp class provides a class implementation and methods for managing Vrrp
23
+ ## on the node. This class presents an abstraction
24
+ ##
25
+
26
+ class Vrrp
27
+ @cfg = '/nos/api/cfg/vrrp'
28
+ # This API gets properties of all VRRP VRs of all interfaces.
29
+ #
30
+ #
31
+ # parameters:
32
+ # conn - connection object to the node
33
+ #
34
+ # return: JSON response
35
+ def self.get_vrrp_prop_all(conn)
36
+ url = form_url(conn, @cfg)
37
+ hdr = form_hdr(conn)
38
+ Rest.get(conn, url, hdr)
39
+ end
40
+
41
+ # This API gets properties of all VRRP VRs under one specified interface.
42
+ #
43
+ #
44
+ # parameters:
45
+ # conn - connection object to the node
46
+ # intf - Interface on switch
47
+ #
48
+ # return: JSON response
49
+ def self.get_vrrp_intf(conn, intf)
50
+ temp = intf.dup
51
+ temp.sub! '/', '%2F'
52
+ url = form_url(conn, @cfg + '/' + temp)
53
+ hdr = form_hdr(conn)
54
+ Rest.get(conn, url, hdr)
55
+ end
56
+
57
+
58
+ # This API create a VRRP VR.
59
+ #
60
+ #
61
+ # parameters:
62
+ # conn - connection object to the node
63
+ # intf - Interface on switch
64
+ # params - dictionary that requires the following format of key-value pairs
65
+ # {
66
+ #    "if_name": "<if_name>",
67
+ #     "vr_id": "<vr_id>",
68
+ #     "ip_addr": "<ip_addr>",
69
+ #     "ad_intvl": "<ad_intvl>",
70
+ #     "preempt": "<preempt>",
71
+ #     "prio": "<prio>",
72
+ #     "admin_state": "<admin_state>",
73
+ #     "track_if": "<track_if>",
74
+ #     "accept_mode": "<accept_mode>",
75
+ #     "switch_back_delay": "<switch_back_delay>",
76
+ #     "v2_compt": "<v2_compt>"
77
+ # }
78
+ # description -
79
+ # if_name :Interface name.Note: The interface must exist.
80
+ # vr_id :Virtual Router (VR) identifier; an integer from 1‐255.
81
+ # ip_addr :The IP address of the VR; a valid IPv4 address.
82
+ # ad_intvl :Advertisement interval (The number of centi‐seconds between
83
+ # advertisements for VRRPv3); a multiple of 5 from 5‐4095. Default
84
+ # value: 100 centi‐seconds.
85
+ # preempt :Enable the preemption of a lower priority master; one of yes
86
+ # (default) , no.
87
+ # prio :The priority of the VR on the switch; an integer from 1‐254.
88
+ # Default value: 100.
89
+ # admin_state :Enable the VR one of up (default), down.
90
+ # oper_state :The operation state of the VR; one of master, backup, init.
91
+ # track_if :The interface to track by this VR. Default value: noneNote: If an interface is specified, it must exist.
92
+ # accept_mode Enables or disables the accept mode for this session; one of yes
93
+ # (default), no.
94
+ # switch_back_delay :The switch back delay interval; an integer from 1‐500000, or 0 to
95
+ # disable (default).
96
+ # v2_compt :Enables backward compatibility for VRRPv2 for the VR; one of
97
+ # yes, no (default).
98
+ #
99
+ # return: JSON response
100
+ def self.create_vrrp_intf(conn, intf, params)
101
+ temp = intf.dup
102
+ temp.sub! '/', '%2F'
103
+ url = form_url(conn, @cfg + '/' + temp)
104
+ hdr = form_hdr(conn)
105
+ params = params.to_json
106
+ Rest.post(conn, url, hdr, params)
107
+ end
108
+
109
+ # This API gets properties of a VRRP VR.
110
+ #
111
+ #
112
+ # parameters:
113
+ # conn - connection object to the node
114
+ # intf - Interface on switch
115
+ # vrid - Virtual Router Identifier 1-255
116
+ #
117
+ # return: JSON response
118
+ def self.get_vrrp_intf_vrid(conn, intf, vrid)
119
+ temp = intf.dup
120
+ temp.sub! '/', '%2F'
121
+ url = form_url(conn, @cfg + '/' + temp + '/' + vrid.to_s)
122
+ hdr = form_hdr(conn)
123
+ Rest.get(conn, url, hdr)
124
+ end
125
+
126
+
127
+ # This API updates the properties of a VRRP VR.
128
+ #
129
+ #
130
+ # parameters:
131
+ # conn - connection object to the node
132
+ # intf - Interface on switch
133
+ # vrid - Virtual Router Identifier 1-255
134
+ #
135
+ # params - dictionary that requires the following format of key-value pairs
136
+ # {
137
+ #    "if_name": "<if_name>",
138
+ #     "vr_id": "<vr_id>",
139
+ #     "ip_addr": "<ip_addr>",
140
+ #     "ad_intvl": "<ad_intvl>",
141
+ #     "preempt": "<preempt>",
142
+ #     "prio": "<prio>",
143
+ #     "admin_state": "<admin_state>",
144
+ #     "track_if": "<track_if>",
145
+ #     "accept_mode": "<accept_mode>",
146
+ #     "switch_back_delay": "<switch_back_delay>",
147
+ #     "v2_compt": "<v2_compt>"
148
+ # }
149
+ #
150
+ # description -
151
+ # if_name :Interface name.Note: The interface must exist.
152
+ # vr_id :Virtual Router (VR) identifier; an integer from 1‐255.
153
+ # ip_addr :The IP address of the VR; a valid IPv4 address.
154
+ # ad_intvl :Advertisement interval (The number of centi‐seconds between
155
+ # advertisements for VRRPv3); a multiple of 5 from 5‐4095. Default
156
+ # value: 100 centi‐seconds.
157
+ # preempt :Enable the preemption of a lower priority master; one of yes
158
+ # (default) , no.
159
+ # prio :The priority of the VR on the switch; an integer from 1‐254.
160
+ # Default value: 100.
161
+ # admin_state :Enable the VR one of up (default), down.
162
+ # oper_state :The operation state of the VR; one of master, backup, init.
163
+ # track_if :The interface to track by this VR. Default value: noneNote: If an interface is specified, it must exist.
164
+ # accept_mode Enables or disables the accept mode for this session; one of yes
165
+ # (default), no.
166
+ # switch_back_delay :The switch back delay interval; an integer from 1‐500000, or 0 to
167
+ # disable (default).
168
+ # v2_compt :Enables backward compatibility for VRRPv2 for the VR; one of
169
+ # yes, no (default).
170
+ #
171
+ # return: JSON response
172
+ def self.update_vrrp_intf_vrid(conn, intf, vrid, params)
173
+ temp = intf.dup
174
+ temp.sub! '/', '%2F'
175
+ url = form_url(conn, @cfg + '/' + temp + '/' + vrid.to_s)
176
+ hdr = form_hdr(conn)
177
+ params = params.to_json
178
+ Rest.put(conn, url, hdr, params)
179
+ end
180
+
181
+ # This API Delete a VRRP VR.
182
+ #
183
+ #
184
+ # parameters:
185
+ # conn - connection object to the node
186
+ # intf - Interface on switch
187
+ # vrid - Virtual Router Identifier 1-255
188
+ #
189
+ # return:
190
+ def self.del_vrrp_intf_vrid(conn, intf, vrid)
191
+ temp = intf.dup
192
+ temp.sub! '/', '%2F'
193
+ url = form_url(conn, @cfg + '/' + temp + '/' + vrid.to_s)
194
+ hdr = form_hdr(conn)
195
+ Rest.delete(conn, url, hdr)
196
+ end
197
+
198
+ end
@@ -0,0 +1,1046 @@
1
+
2
+ require 'cnos-rbapi'
3
+ require 'cnos-rbapi/vlan'
4
+ require 'cnos-rbapi/vlan_intf'
5
+ require 'cnos-rbapi/lag'
6
+ require 'cnos-rbapi/arp'
7
+ require 'cnos-rbapi/lldp'
8
+ require 'cnos-rbapi/lacp'
9
+ require 'cnos-rbapi/vlag'
10
+ require 'cnos-rbapi/telemetry'
11
+ require 'cnos-rbapi/vrrp'
12
+ require 'cnos-rbapi/mstp'
13
+ require 'cnos-rbapi/ip_intf'
14
+ require 'cnos-rbapi/system'
15
+ require 'cnos-rbapi/igmp'
16
+ require 'cnos-rbapi/stp'
17
+ require 'yaml'
18
+ require 'json'
19
+
20
+ config = ["mars.yml", "jupiter.yml", "neptune.yml", "voyager.yml"]
21
+ file = File.open("/tmp/test_log.txt", "w")
22
+
23
+ config.each do |line|
24
+ file.puts("\n\n " + line + "\n\n")
25
+ params = YAML.load_file(line)
26
+ conn = Connect.new(params)
27
+ resp = Vlan.get_all_vlan(conn)
28
+ if resp == nil
29
+ file.puts( "CH_LEN_088 - get_all_vlan -------->FAILED\n")
30
+ else
31
+ file.puts( "CH_LEN_088 - get_all_vlan -------->PASSED\n")
32
+ end
33
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
34
+ params = {"vlan_name" => "test", "vlan_id" => 10, "admin_state" => "up"}
35
+ resp = Vlan.create_vlan(conn, params)
36
+ if resp == nil
37
+ file.puts( "CH_LEN_089 - create_vlan -------->FAILED\n")
38
+ else
39
+ file.puts( "CH_LEN_089 - create_vlan -------->PASSED\n")
40
+ end
41
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
42
+ resp = Vlan.get_vlan_prop(conn, 10)
43
+ if resp == nil
44
+ file.puts( "CH_LEN_090 get_vlan_prop -------->FAILED\n")
45
+ else
46
+ file.puts( "CH_LEN_090 get_vlan_prop -------->PASSED\n")
47
+ end
48
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
49
+ params = {"vlan_name" => "testagain", "admin_state" => "up"}
50
+ resp = Vlan.update_vlan(conn, 10, params)
51
+ if resp == nil
52
+ file.puts( "CH_LEN_092 - update_vlan -------->FAILED\n")
53
+ else
54
+ if resp['vlan_name'] == "testagain"
55
+ file.puts( "CH_LEN_092 - update_vlan -------->PASSED\n")
56
+ else
57
+ file.puts( "CH_LEN_092 - update_vlan -------->FAILED\n")
58
+ end
59
+ end
60
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
61
+ resp = Vlan.delete_vlan(conn, 10)
62
+ resp = Vlan.get_vlan_prop(conn, 10)
63
+ if resp == nil
64
+ file.puts( "CH_LEN_091 - delete_vlan -------->PASSED\n")
65
+ else
66
+ file.puts( "CH_LEN_091 - delete_vlan -------->FAILED \n")
67
+ end
68
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
69
+
70
+
71
+ ###########################################################################
72
+
73
+ file.puts( "\n testing vlan_intf.rb \n\n")
74
+ resp = VlanIntf.get_all_vlan_intf(conn)
75
+ if resp == nil
76
+ file.puts( "CH_LEN_093 get_all_vlan_intf -------->FAILED\n")
77
+ else
78
+ file.puts( "CH_LEN_093 get_all_vlan_intf -------->PASSED\n")
79
+ end
80
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
81
+ resp = VlanIntf.get_vlan_prop_intf(conn, 'Ethernet1/2')
82
+ if resp == nil
83
+ file.puts( "CH_LEN_094 get_vlan_prop_intf -------->FAILED\n")
84
+ else
85
+ file.puts( "CH_LEN_094 get_vlan_prop_intf -------->PASSED\n")
86
+ end
87
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
88
+ params = {"pvid"=>1, "vlans"=>[1], "bridgeport_mode"=>"access", "if_name"=>"Ethernet1/92"}
89
+ VlanIntf.update_vlan_intf(conn, 'Ethernet1/2', params)
90
+ if resp == nil
91
+ file.puts( "CH_LEN_095 update_vlan_intf -------->FAILED\n")
92
+ else
93
+ if resp['bridgeport_mode'] == "access"
94
+ file.puts( "CH_LEN_095 update_vlan_intf -------->PASSED\n")
95
+ else
96
+ file.puts( "CH_LEN_095 update_vlan_intf -------->FAILED\n")
97
+ end
98
+ end
99
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
100
+
101
+ ##########################################################################
102
+
103
+ file.puts( "\n testing lag.rb \n\n")
104
+ resp = Lag.get_all_lag(conn)
105
+ if resp == nil
106
+ file.puts( "CH_LEN_007 get_all_lag -------->FAILED\n")
107
+ else
108
+ file.puts( "CH_LEN_007 get_all_lag -------->PASSED\n")
109
+ end
110
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
111
+ resp = Lag.create_lag(conn, 25)
112
+ if resp == nil
113
+ file.puts( "CH_LEN_001 create_lag -------->FAILED\n")
114
+ else
115
+ file.puts( "CH_LEN_001 create_lag -------->PASSED\n")
116
+ end
117
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
118
+ resp = Lag.get_lag_prop(conn, 25)
119
+ if resp == nil
120
+ file.puts( "CH_LEN_006 get_lag_prop -------->FAILED\n")
121
+ else
122
+ file.puts( "CH_LEN_006 get_lag_prop -------->PASSED\n")
123
+ end
124
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
125
+ resp = Lag.get_load_balance(conn)
126
+ if resp == nil
127
+ file.puts( "CH_LEN_004 get_load_balance -------->FAILED\n")
128
+ else
129
+ file.puts( "CH_LEN_004 get_load_balance -------->PASSED\n")
130
+ end
131
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
132
+ params = {"interfaces"=> [], "lag_id"=> 25, "min_links"=> 2}
133
+ resp = Lag.update_lag(conn, 25, params)
134
+ if resp == nil
135
+ file.puts( "CH_LEN_003 update_lag-------->FAILED\n")
136
+ else
137
+ if resp['min_links'] == 2
138
+ file.puts( "CH_LEN_003 update_lag-------->PASSED\n")
139
+ else
140
+ file.puts( "CH_LEN_003 update_lag-------->FAILED\n")
141
+ end
142
+ end
143
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
144
+ params = { "destination-port" => "no"}
145
+ resp = Lag.update_lag_load_balance(conn, params)
146
+ if resp == nil
147
+ file.puts( "CH_LEN_005 update_lag_load_balance -------->FAILED\n")
148
+ else
149
+ if resp['destination-port'] == "no"
150
+ file.puts( "CH_LEN_005 update_lag_load_balance -------->PASSED\n")
151
+ else
152
+ file.puts( "CH_LEN_005 update_lag_load_balance -------->FAILED\n")
153
+ end
154
+ end
155
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
156
+ Lag.delete_lag(conn, 25)
157
+ resp = Lag.get_lag_prop(conn, 25)
158
+ if resp == nil
159
+ file.puts( "CH_LEN_002 delete_lag -------->PASSED\n")
160
+ else
161
+ file.puts( "CH_LEN_002 delete_lag -------->FAILED\n")
162
+ end
163
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
164
+
165
+ #########################################################################
166
+
167
+ file.puts( "\n testing arp.rb \n\n")
168
+ resp = Arp.get_arp_sys_prop(conn)
169
+ if resp == nil
170
+ file.puts( "CH_LEN_061 get_arp_sys_prop -------->FAILED\n")
171
+ else
172
+ file.puts( "CH_LEN_061 get_arp_sys_prop -------->PASSED\n")
173
+ end
174
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
175
+ resp = Arp.get_arp_prop_all(conn)
176
+ if resp == nil
177
+ file.puts( "CH_LEN_115 get_arp_prop_all -------->FAILED\n")
178
+ else
179
+ file.puts( "CH_LEN_115 get_arp_prop_all -------->PASSED\n")
180
+ end
181
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
182
+ params = {"ageout_time"=>100}
183
+ resp = Arp.set_arp_sys_prop(conn, params)
184
+ if resp == nil
185
+ file.puts( "CH_LEN_062 set_arp_sys_prop -------->FAILED\n")
186
+ else
187
+ file.puts( "CH_LEN_062 set_arp_sys_prop -------->PASSED\n")
188
+ end
189
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
190
+ resp = Arp.get_arp_intf_prop(conn, 'Ethernet1/1')
191
+ if resp == nil
192
+ file.puts( "CH_LEN_063 get_arp_intf_prop -------->FAILED\n")
193
+ else
194
+ file.puts( "CH_LEN_063 get_arp_intf_prop -------->PASSED\n")
195
+ end
196
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
197
+ params = {"ageout_time"=> 70, "if_name"=>"Ethernet1/1"}
198
+ resp = Arp.set_arp_intf_prop(conn, 'Ethernet1/1', params)
199
+ if resp == nil
200
+ file.puts( "CH_LEN_064 set_arp_intf_prop -------->FAILED\n")
201
+ else
202
+ if resp['ageout_time'] == 70
203
+ file.puts( "CH_LEN_064 set_arp_intf_prop -------->PASSED\n")
204
+ else
205
+ file.puts( "CH_LEN_064 set_arp_intf_prop -------->FAILED\n")
206
+ end
207
+ end
208
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
209
+
210
+
211
+ ####################################################################
212
+
213
+ file.puts( "\n testing lldp.rb \n\n")
214
+ resp = Lldp.get_lldp_prop(conn)
215
+ if resp == nil
216
+ file.puts( "CH_LEN_069 get_lldp_prop -------->FAILED\n")
217
+ else
218
+ file.puts( "CH_LEN_069 get_lldp_prop -------->PASSED\n")
219
+ end
220
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
221
+ resp = Lldp.get_lldp_all_intf(conn)
222
+ if resp == nil
223
+ file.puts( "CH_LEN_071 get_lldp_all_intf -------->FAILED\n")
224
+ else
225
+ file.puts( "CH_LEN_071 get_lldp_all_intf -------->PASSED\n")
226
+ end
227
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
228
+ resp = Lldp.get_lldp_intf(conn, 'Ethernet1/1')
229
+ if resp == nil
230
+ file.puts( "CH_LEN_072 get_lldp_intf -------->FAILED\n")
231
+ else
232
+ file.puts( "CH_LEN_072 get_lldp_intf -------->PASSED\n")
233
+ end
234
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
235
+ resp = Lldp.get_lldp_intf_stats(conn, 'Ethernet1/1')
236
+ if resp == nil
237
+ file.puts( "CH_LEN_116 get_lldp_intf_stats -------->FAILED\n")
238
+ else
239
+ file.puts( "CH_LEN_116 get_lldp_intf_stats -------->PASSED\n")
240
+ end
241
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
242
+ resp = Lldp.get_lldp_intf_neighbor(conn, 'Ethernet1/3')
243
+ if resp == nil
244
+ file.puts( "CH_LEN_117 get_lldp_intf_neighbour -------->FAILED\n")
245
+ else
246
+ file.puts( "CH_LEN_117 get_lldp_intf_neighbour -------->PASSED\n")
247
+ end
248
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
249
+ resp = Lldp.get_lldp_intf_neighbor_all(conn)
250
+ if resp == nil
251
+ file.puts( "CH_LEN_118 get_lldp_intf_neighbour_all -------->FAILED\n")
252
+ else
253
+ file.puts( "CH_LEN_118 get_lldp_intf_neighbour_all -------->PASSED\n")
254
+ end
255
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
256
+ params = {"transmit interval": 35, "transmit delay": 2, "reinit delay": 3}
257
+ resp = Lldp.update_lldp_prop(conn, params)
258
+ if resp == nil
259
+ file.puts( "CH_LEN_070 update_lldp_prop -------->FAILED\n")
260
+ else
261
+ if resp['reinit delay'] == 3
262
+ file.puts( "CH_LEN_070 update_lldp_prop -------->PASSED\n")
263
+ else
264
+ file.puts( "CH_LEN_070 update_lldp_prop -------->FAILED\n")
265
+ end
266
+ end
267
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
268
+ params = {"ena_lldp_rx": "yes", "if_name": "Ethernet1/3", "ena_lldp_tx": "yes"}
269
+ resp = Lldp.update_lldp_intf(conn, 'Ethernet1/3', params)
270
+ if resp == nil
271
+ file.puts( "CH_LEN_073 update_lldp_intf -------->FAILED\n")
272
+ else
273
+ if resp['ena_lldp_tx'] == 'yes'
274
+ file.puts( "CH_LEN_073 update_lldp_intf -------->PASSED\n")
275
+ else
276
+ file.puts( "CH_LEN_073 update_lldp_intf -------->FAILED\n")
277
+ end
278
+ end
279
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
280
+
281
+ file.puts( "\n testing lacp.rb \n\n")
282
+ resp = Lacp.get_lacp(conn)
283
+ if resp == nil
284
+ file.puts( "CH_LEN_074 get_lacp -------->FAILED\n")
285
+ else
286
+ file.puts( "CH_LEN_074 get_lacp -------->PASSED\n")
287
+ end
288
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
289
+ params = {"sys_prio" => 32767}
290
+ resp = Lacp.update_lacp(conn, params)
291
+ if resp == nil
292
+ file.puts( "CH_LEN_075 update_lacp -------->FAILED\n")
293
+ else
294
+ if resp['sys_prio'] == 32767
295
+ file.puts( "CH_LEN_075 update_lacp -------->PASSED\n")
296
+ else
297
+ file.puts( "CH_LEN_075 update_lacp -------->FAILED\n")
298
+ end
299
+ end
300
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
301
+
302
+ ##################################################################
303
+
304
+ file.puts( "\n testing ip_intf.rb \n\n")
305
+ resp = Ipintf.get_ip_prop_all(conn)
306
+ if resp == nil
307
+ file.puts("CH_LEN_076 get_ip_prop_all -------->FAILED\n")
308
+ else
309
+ file.puts("CH_LEN_076 get_ip_prop_all -------->PASSED\n")
310
+ end
311
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
312
+ resp = Ipintf.get_ip_prop_intf(conn,'Ethernet1/1')
313
+ if resp == nil
314
+ file.puts("CH_LEN_077 get_ip_prop_intf -------->FAILED\n")
315
+ else
316
+ file.puts("CH_LEN_077 get_ip_prop_intf -------->PASSED\n")
317
+ end
318
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
319
+ params = { "ip_addr": "1.1.1.1", "bridge_port": "no", "if_name": "Ethernet1/1", "mtu": 1500, "vrf_name": "default", "admin_state": "up", "ip_prefix_len": 24}
320
+ resp = Ipintf.update_ip_prop_intf(conn, 'Ethernet1/1', params)
321
+ if resp == nil
322
+ file.puts("CH_LEN_078 update_ip_prop_intf -------->FAILED\n")
323
+ else
324
+ if resp['bridge_port'] == "no"
325
+ file.puts( "CH_LEN_078 - update_ip_prop_intf -------->PASSED\n")
326
+ else
327
+ file.puts( "CH_LEN_078 - update_ip_prop_intf -------->FAILED\n")
328
+ end
329
+ end
330
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
331
+
332
+ ########################################################################
333
+
334
+ file.puts( "\n testing vrrp.rb \n\n")
335
+ resp = Vrrp.get_vrrp_prop_all(conn)
336
+ if resp == nil
337
+ file.puts( "CH_LEN_032 get_vrrp_prop_all -------->FAILED\n")
338
+ else
339
+ file.puts( "CH_LEN_032 get_vrrp_prop_all -------->PASSED\n")
340
+ end
341
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
342
+ resp = Vrrp.get_vrrp_intf(conn, 'Ethernet1/1')
343
+ if resp == nil
344
+ file.puts( "CH_LEN_033 get_vrrp_intf -------->FAILED\n")
345
+ else
346
+ file.puts( "CH_LEN_033 get_vrrp_intf_stats -------->PASSED\n")
347
+ end
348
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
349
+ params = {
350
+ "if_name":"Ethernet1/1",
351
+ "vr_id":1,
352
+ "ip_addr":"1.1.1.254",
353
+ "ad_intvl":100,
354
+ "preempt":"no",
355
+ "prio":100,
356
+ "admin_state":"down",
357
+ "accept_mode":"no",
358
+ "switch_back_delay":1,
359
+ "v2_compt":"no"
360
+ }
361
+ resp = Vrrp.create_vrrp_intf(conn, 'Ethernet1/1', params)
362
+ if resp == nil
363
+ file.puts( "CH_LEN_035 create_vrrp_intf_vrid -------->FAILED\n")
364
+ else
365
+ file.puts( "CH_LEN_035 create_vrrp_intf_vrid -------->PASSED\n")
366
+ end
367
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
368
+ params = {
369
+ "if_name":"Ethernet1/1",
370
+ "vr_id":1,
371
+ "ip_addr":"1.1.1.254",
372
+ "ad_intvl":100,
373
+ "preempt":"no",
374
+ "prio":100,
375
+ "admin_state":"up",
376
+ "accept_mode":"no",
377
+ "switch_back_delay":1,
378
+ "v2_compt":"no"
379
+ }
380
+ resp = Vrrp.update_vrrp_intf_vrid(conn, 'Ethernet1/1', 1, params)
381
+ if resp == nil
382
+ file.puts( "CH_LEN_036 update_vrrp_intf_vrid -------->FAILED\n")
383
+ else
384
+ if resp['admin_state'] == "up"
385
+ file.puts( "CH_LEN_036 update_vrrp_intf_vrid -------->PASSED\n")
386
+ else
387
+ file.puts( "CH_LEN_036 update_vrrp_intf_vrid -------->FAILED\n")
388
+ end
389
+ end
390
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
391
+ resp = Vrrp.del_vrrp_intf_vrid(conn, 'Ethernet1/1', 1)
392
+ resp = Vrrp.get_vrrp_intf_vrid(conn, 'Ethernet1/1' , 1)
393
+ if resp == []
394
+ file.puts( "delete_vrrp_intf_vrid -------->PASSED\n")
395
+ else
396
+ file.puts( "delete_vrrp_intf_vrid -------->FAILED\n")
397
+ end
398
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
399
+
400
+ ##################################################################
401
+
402
+ file.puts( "\n testing vlag.rb \n\n")
403
+ resp = Vlag.get_vlag_conf(conn)
404
+ if resp == nil
405
+ file.puts( "CH_LEN_020 get_vlag_conf -------->FAILED\n")
406
+ else
407
+ file.puts( "CH_LEN_020 get_vlag_conf -------->PASSED\n")
408
+ end
409
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
410
+ resp = Vlag.get_global_vlag(conn)
411
+ if resp == nil
412
+ file.puts( "CH_LEN_022 get_global_vlag -------->FAILED\n")
413
+ else
414
+ file.puts( "CH_LEN_022 get_global_vlag -------->PASSED\n")
415
+ end
416
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
417
+ resp = Vlag.get_vlag_isl(conn)
418
+ if resp == nil
419
+ file.puts( "CH_LEN_023 get_vlag_isl -------->FAILED\n")
420
+ else
421
+ file.puts( "CH_LEN_023 get_vlag_isl -------->PASSED\n")
422
+ end
423
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
424
+ resp = Vlag.get_vlag_health(conn)
425
+ if resp == nil
426
+ file.puts( "CH_LEN_025 get_vlag_health -------->FAILED\n")
427
+ else
428
+ file.puts( "CH_LEN_025 get_vlag_health -------->PASSED\n")
429
+ end
430
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
431
+ resp = Vlag.get_vlag_inst_info(conn, 2)
432
+ if resp == nil
433
+ file.puts( "CH_LEN_031 get_vlag_inst_info -------->FAILED\n")
434
+ else
435
+ file.puts( "CH_LEN_031 get_vlag_inst_info -------->PASSED\n")
436
+ end
437
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
438
+ resp = Vlag.get_vlag_inst_confg(conn, 2)
439
+ if resp == nil
440
+ file.puts( "CH_LEN_030 get_vlag_inst_confg -------->FAILED\n")
441
+ else
442
+ file.puts( "CH_LEN_030 get_vlag_inst_confg -------->PASSED\n")
443
+ end
444
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
445
+ params = {"priority": 0, "auto_recovery": 300, "startup_delay": 120, "tier_id": 11, "status": "disable"}
446
+ resp = Vlag.update_vlag_conf(conn, params)
447
+ if resp == nil
448
+ file.puts( "CH_LEN_021 update_vlag_conf -------->FAILED\n")
449
+ else
450
+ if resp['auto_recovery'] == 300
451
+ file.puts( "CH_LEN_021 update_vlag_conf -------->PASSED\n")
452
+ else
453
+ file.puts( "CH_LEN_021 update_vlag_conf -------->FAILED\n")
454
+ end
455
+ end
456
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
457
+ params = {"port_aggregator": 200}
458
+ resp = Vlag.update_vlag_isl(conn, params)
459
+ resp = Vlag.get_vlag_isl(conn)
460
+ if resp == nil
461
+ file.puts( "CH_LEN_024 update_vlag_isl -------->FAILED\n")
462
+ else
463
+ if resp['port_aggregator'] == 200
464
+ file.puts( "CH_LEN_024 update_vlag_isl -------->PASSED\n")
465
+ else
466
+ file.puts( "CH_LEN_024 update_vlag_isl -------->FAILED\n")
467
+ end
468
+ end
469
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
470
+ params = { "keepalive_interval": 5, "retry_interval": 30, "peer_ip": "10.240.177.120", "vrf": "default", "keepalive_attempts": 3}
471
+ resp = Vlag.update_vlag_health(conn, params)
472
+ if resp == nil
473
+ file.puts( "CH_LEN_026 update_vlag_health -------->FAILED\n")
474
+ else
475
+ if resp['keepalive_interval'] == 5
476
+ file.puts( "CH_LEN_026 update_vlag_health -------->PASSED\n")
477
+ else
478
+ file.puts( "CH_LEN_026 update_vlag_health -------->FAILED\n")
479
+ end
480
+ end
481
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
482
+ params = {"port_aggregator": 2, "status": "disable", "inst_id": 1}
483
+ resp = Vlag.create_vlag_inst(conn, params)
484
+ resp = Vlag.get_vlag_inst_confg(conn, 1)
485
+ if resp == nil
486
+ file.puts( "CH_LEN_027 create_vlag_inst -------->FAILED\n")
487
+ else
488
+ if resp['status'] == 'disable'
489
+ file.puts( "CH_LEN_027 create_vlag_inst -------->PASSED\n")
490
+ else
491
+ file.puts( "CH_LEN_027 create_vlag_inst -------->FAILED\n")
492
+ end
493
+
494
+ end
495
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
496
+ params = {"status": "enable"}
497
+ resp = Vlag.update_vlag_inst(conn, 1, params)
498
+ resp = Vlag.get_vlag_inst_confg(conn, 1)
499
+ if resp == nil
500
+ file.puts( "CH_LEN_028 update_vlag_inst -------->FAILED\n")
501
+ else
502
+ if resp['status'] == 'enable'
503
+ file.puts( "CH_LEN_028 update_vlag_inst -------->PASSED\n")
504
+ else
505
+ file.puts( "CH_LEN_028 update_vlag_inst -------->FAILED\n")
506
+ end
507
+ end
508
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
509
+ Vlag.delete_vlag_inst(conn, 1)
510
+ resp = Vlag.get_vlag_inst_confg(conn, 1)
511
+ if resp == nil
512
+ file.puts( "CH_LEN_029 delete_vlag_inst -------->PASSED\n")
513
+ else
514
+ if resp['port_aggregator'] == 0
515
+ file.puts( "CH_LEN_029 delete_vlag_inst -------->PASSED\n")
516
+ else
517
+ file.puts( "CH_LEN_029 delete_vlag_inst -------->FAILED\n")
518
+ end
519
+ end
520
+
521
+ ###################################################################
522
+
523
+ params = {"vlan_name" => "test", "vlan_id" => 10, "admin_state" => "up"}
524
+ resp = Vlan.create_vlan(conn, params)
525
+ file.puts( "\n testing mstp.rb \n\n")
526
+ resp = Mstp.get_mstp_sys_prop(conn)
527
+ if resp == nil
528
+ file.puts("CH_LEN_011 get_mstp_sys_prop -------->FAILED\n")
529
+ else
530
+ file.puts("CH_LEN_011 get_mstp_sys_prop -------->PASSED\n")
531
+ end
532
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
533
+ params = {'region_name' => 'test', 'revision' => 1}
534
+ resp = Mstp.update_mstp_sys_prop(conn, params)
535
+ if resp == nil
536
+ file.puts("CH_LEN_012 update_mstp_sys_prop -------->FAILED\n")
537
+ else
538
+ if resp['region_name'] == 'test'
539
+ file.puts("CH_LEN_012 update_mstp_sys_prop -------->PASSED\n")
540
+ else
541
+ file.puts("CH_LEN_012 update_mstp_sys_prop -------->FAILED\n")
542
+ end
543
+ end
544
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
545
+ resp = Mstp.get_mstp_inst_all(conn)
546
+ if resp == nil
547
+ file.puts( "CH_LEN_013 get_mstp_all -------->FAILED\n")
548
+ else
549
+ file.puts( "CH_LEN_013 get_mst_all -------->PASSED\n")
550
+ end
551
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
552
+ params = {"instance_id": 1, "vlans": [{"vlan_id": 10}], "instance_prio": 32768}
553
+ Mstp.create_mstp_inst(conn,params)
554
+ resp = Mstp.get_mstp_inst(conn, 1)
555
+ if resp == nil
556
+ file.puts( "CH_LEN_014 create_mstp_inst -------->FAILED\n")
557
+ else
558
+ file.puts( "CH_LEN_014 create_mstp_inst -------->PASSED\n")
559
+ end
560
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
561
+ resp = Mstp.get_mstp_inst(conn, 0)
562
+ if resp == nil
563
+ file.puts( "CH_LEN_015 get_mstp_inst -------->FAILED\n")
564
+ else
565
+ file.puts( "CH_LEN_015 get_mstp_inst -------->PASSED\n")
566
+ end
567
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
568
+ params = [{"instance_id": 0, "vlans": [{"vlan_id": 1}], "instance_prio": 3276}]
569
+ resp = Mstp.update_mstp_inst(conn, 0, params)
570
+ resp = Mstp.get_mstp_inst(conn, 0)
571
+ if resp == nil
572
+ file.puts( "CH_LEN_016 update_mstp_inst -------->FAILED\n")
573
+ else
574
+ if resp[0]['instance_prio'] == 3276
575
+ file.puts("CH_LEN_016 update_mstp_inst -------->PASSED\n")
576
+ else
577
+ file.puts("CH_LEN_016 update_mstp_inst -------->FAILED\n")
578
+ end
579
+ end
580
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
581
+ resp = Mstp.del_mstp_inst(conn, 1)
582
+ resp = Mstp.get_mstp_inst(conn, 1)
583
+ if resp == nil
584
+ file.puts( "CH_LEN_017 del_mstp_inst -------->PASSED\n")
585
+ else
586
+ file.puts( "CH_LEN_017 del_mstp_inst -------->FAILED\n")
587
+ end
588
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
589
+ resp = Mstp.get_mstp_inst_intf(conn, 0, "Ethernet1/1")
590
+ if resp == nil
591
+ file.puts( "CH_LEN_018 get_mstp_inst_intf -------->FAILED\n")
592
+ else
593
+ file.puts( "CH_LEN_018 get_mstp_inst_intf-------->PASSED\n")
594
+ end
595
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
596
+ params = {"if_name": 'Ethernet1/1', "path_cost": 1, "port_prio": 128}
597
+ resp = Mstp.update_mstp_inst_intf(conn, 1, 'Ethernet1/1', params)
598
+ resp = Mstp.get_mstp_inst_intf(conn, 1,'Ethernet1/1')
599
+ if resp == nil
600
+ file.puts( "CH_LEN_019 update_mstp_inst_intf -------->FAILED\n")
601
+ else
602
+ if resp['instance_prio'] == 3276
603
+ file.puts("CH_LEN_019 update_mstp_inst_intf -------->PASSED\n")
604
+ else
605
+ file.puts("CH_LEN_019 update_mstp_inst_intf -------->FAILED\n")
606
+ end
607
+ end
608
+
609
+ #######################################################################3
610
+
611
+ file.puts( "\n testing stp.rb \n\n")
612
+ resp = Stp.get_all_stp(conn)
613
+ if resp == nil
614
+ file.puts("CH_LEN_008 get_all_stp -------->FAILED\n")
615
+ else
616
+ file.puts("CH_LEN_008 get_all_stp -------->PASSED\n")
617
+ end
618
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
619
+ resp = Stp.get_stp_intf(conn, 'Ethernet1/2')
620
+ if resp == nil
621
+ file.puts("CH_LEN_009 get_stp_intf -------->FAILED\n")
622
+ else
623
+ file.puts("CH_LEN_009 get_stp_intf -------->PASSED\n")
624
+ end
625
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
626
+ params = {"root_guard": "disable", "edge_port": "yes", "loop_guard": "disable", "if_name": "Ethernet1/2", "bpdu_guard": "disable"}
627
+ resp = Stp.update_stp(conn, 'Ethernet1/2', params)
628
+ if resp == nil
629
+ file.puts("CH_LEN_010 update_stp -------->FAILED\n")
630
+ else
631
+ if resp['edge_port'] == "yes"
632
+ file.puts( "CH_LEN_010 - update_stp -------->PASSED\n")
633
+ else
634
+ file.puts( "CH_LEN_010 - update_stp -------->FAILED\n")
635
+ end
636
+ end
637
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
638
+ #########################################################################
639
+
640
+ file.puts( "\n testing system.rb \n\n")
641
+ resp = System.get_hostname(conn)
642
+ if resp == nil
643
+ file.puts("CH_LEN_038 get_hostname -------->FAILED\n")
644
+ else
645
+ file.puts("CH_LEN_038 get_hostname -------->PASSED\n")
646
+ end
647
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
648
+ params = {"hostname": "G8296"}
649
+ resp = System.set_hostname(conn, params)
650
+ if resp == nil
651
+ file.puts("CH_LEN_039 set_hostname -------->FAILED\n")
652
+ else
653
+ if resp['hostname'] == "G8296"
654
+ file.puts( "CH_LEN_039 - set_hostname -------->PASSED\n")
655
+ else
656
+ file.puts( "CH_LEN_039 - set_hostname -------->FAILED\n")
657
+ end
658
+ end
659
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
660
+ resp = System.get_clock(conn)
661
+ if resp == nil
662
+ file.puts("CH_LEN_040 get_clock -------->FAILED\n")
663
+ else
664
+ file.puts("CH_LEN_040 get_clock -------->PASSED\n")
665
+ end
666
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
667
+ params = {"time" => "12:23:23", "day"=> 3, "month" => "November", "year" => 2017}
668
+ resp = System.set_clock(conn, params)
669
+ if resp == nil
670
+ file.puts("CH_LEN_041 set_clock -------->FAILED\n")
671
+ else
672
+ file.puts( "CH_LEN_041 - set_clock -------->PASSED\n")
673
+ end
674
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
675
+ params = {"format": 12}
676
+ resp = System.set_clock_format(conn, params)
677
+ if resp == nil
678
+ file.puts("CH_LEN_042 set_clock_format -------->FAILED\n")
679
+ else
680
+ if resp['format'] == 12
681
+ file.puts( "CH_LEN_042 - set_clock_format -------->PASSED\n")
682
+ else
683
+ file.puts( "CH_LEN_042 - set_clock_format -------->FAILED\n")
684
+ end
685
+ end
686
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
687
+ params = {"protocol": "ntp"}
688
+ resp = System.set_clock_protocol(conn, params)
689
+ if resp == nil
690
+ file.puts("CH_LEN_043 set_clock_protocol -------->FAILED\n")
691
+ else
692
+ if resp['protocol'] == "ntp"
693
+ file.puts( "CH_LEN_043 - set_clock_protocol -------->PASSED\n")
694
+ else
695
+ file.puts( "CH_LEN_043 - set_clock_protocol -------->FAILED\n")
696
+ end
697
+ end
698
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
699
+ params = {"timezone" => "PST", "offsethour" => 10, "offsetmin" => 10}
700
+ resp = System.set_clock_timezone(conn, params)
701
+ if resp == nil
702
+ file.puts("CH_LEN_044 set_clock_timezone -------->FAILED\n")
703
+ else
704
+ file.puts( "CH_LEN_044 - set_clock_timezone -------->PASSED\n")
705
+ end
706
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
707
+ resp = System.get_device_contact(conn)
708
+ if resp == nil
709
+ file.puts("CH_LEN_045 get_device_contact -------->FAILED\n")
710
+ else
711
+ file.puts("CH_LEN_045 get_device_contact -------->PASSED\n")
712
+ end
713
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
714
+ params = {"contact": "test"}
715
+ resp = System.set_device_contact(conn, params)
716
+ if resp == nil
717
+ file.puts("CH_LEN_046 set_device_contact -------->FAILED\n")
718
+ else
719
+ if resp['contact'] == "test"
720
+ file.puts( "CH_LEN_046 - set_device_contact -------->PASSED\n")
721
+ else
722
+ file.puts( "CH_LEN_046 - set_device_contact -------->FAILED\n")
723
+ end
724
+ end
725
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
726
+ params = {"descr": "test"}
727
+ resp = System.set_device_descr(conn, params)
728
+ if resp == nil
729
+ file.puts("CH_LEN_047 set_device_descr -------->FAILED\n")
730
+ else
731
+ if resp['descr'] == "test"
732
+ file.puts( "CH_LEN_047 - set_device_descr -------->PASSED\n")
733
+ else
734
+ file.puts( "CH_LEN_047 - set_device_descr -------->FAILED\n")
735
+ end
736
+ end
737
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
738
+ resp = System.get_device_descr(conn)
739
+ if resp == nil
740
+ file.puts("CH_LEN_120 get_device_descr -------->FAILED\n")
741
+ else
742
+ file.puts("CH_LEN_120 get_device_descr -------->PASSED\n")
743
+ end
744
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
745
+
746
+ file.puts( "\n testing igmp.rb \n\n")
747
+ resp = Igmp.get_igmp_snoop_prop(conn)
748
+ if resp == nil
749
+ file.puts("CH_LEN_065 get_igmp_snoop_prop -------->FAILED\n")
750
+ else
751
+ file.puts("CH_LEN_065 get_igmp_snoop_prop -------->PASSED\n")
752
+ end
753
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
754
+ params = {"ena_igmp_snoop": "yes"}
755
+ resp = Igmp.set_igmp_snoop_prop(conn, params)
756
+ if resp == nil
757
+ file.puts("CH_LEN_066 set_igmp_snoop_prop -------->FAILED\n")
758
+ else
759
+ if resp['ena_igmp_snoop'] == "yes"
760
+ file.puts( "CH_LEN_066 - set_igmp_snoop_prop -------->PASSED\n")
761
+ else
762
+ file.puts( "CH_LEN_066 - set_igmp_snoop_prop -------->FAILED\n")
763
+ end
764
+ end
765
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
766
+ resp = Igmp.get_igmp_vlan_prop(conn, 1)
767
+ if resp == nil
768
+ file.puts("CH_LEN_067 get_igmp_vlan_prop -------->FAILED\n")
769
+ else
770
+ file.puts("CH_LEN_067 get_igmp_vlan_prop -------->PASSED\n")
771
+ end
772
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
773
+ params = {"fast_leave": "no", "query_interval": 120, "version": 3, "ena_igmp_snoop": "yes", "vlan_id": 1}
774
+ resp = Igmp.set_igmp_vlan_prop(conn, 1 , params)
775
+ if resp == nil
776
+ file.puts("CH_LEN_068 set_igmp_snoop_prop -------->FAILED\n")
777
+ else
778
+ if resp['query_interval'] == 120
779
+ file.puts( "CH_LEN_068 - set_igmp_vlan_prop -------->PASSED\n")
780
+ else
781
+ file.puts( "CH_LEN_068 - set_igmp_vlan_prop -------->FAILED\n")
782
+ end
783
+ end
784
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
785
+
786
+ ###########################################################################
787
+
788
+ file.puts( "\n testing telemetry.rb \n\n")
789
+ resp = Telemetry.get_sys_feature(conn)
790
+ if resp == nil
791
+ file.puts("CH_LEN_049 get_sys_feature -------->FAILED\n")
792
+ else
793
+ file.puts("CH_LEN_049 get_sys_feature -------->PASSED\n")
794
+ end
795
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
796
+ params = {"heartbeat-enable"=> 1, "msg-interval"=> 10}
797
+ resp = Telemetry.set_sys_feature(conn, params)
798
+ resp = Telemetry.get_sys_feature(conn)
799
+ if resp == nil
800
+ file.puts("CH_LEN_050 set_sys_feature -------->FAILED\n")
801
+ else
802
+ if resp['msg-interval'] == 10
803
+ file.puts( "CH_LEN_050 - set_sys_feature -------->PASSED\n")
804
+ else
805
+ file.puts( "CH_LEN_050 - set_sys_feature -------->FAILED\n")
806
+ end
807
+ end
808
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
809
+ resp = Telemetry.get_bst_tracking(conn)
810
+ if resp == nil
811
+ file.puts("CH_LEN_051 get_bst_tracking -------->FAILED\n")
812
+ else
813
+ file.puts("CH_LEN_051 get_bst_tracking -------->PASSED\n")
814
+ end
815
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
816
+ params = {"track-egress-port-service-pool"=> 1,
817
+ "track-egress-uc-queue"=> 1,
818
+ "track-egress-rqe-queue"=> 1,
819
+ "track-egress-cpu-queue"=> 1,
820
+ "track-ingress-port-service-pool"=> 1,
821
+ "track-ingress-service-pool"=> 1,
822
+ "track-egress-mc-queue"=> 1,
823
+ "track-peak-stats"=> 0,
824
+ "track-ingress-port-priority-group"=> 1,
825
+ "track-egress-service-pool"=> 1,
826
+ "track-device"=> 1}
827
+ resp = Telemetry.set_bst_tracking(conn, params)
828
+ resp = Telemetry.get_bst_tracking(conn)
829
+ if resp == nil
830
+ file.puts("CH_LEN_052 set_bst_tracking -------->FAILED\n")
831
+ else
832
+ if resp['track-peak-stats'] == 0
833
+ file.puts( "CH_LEN_052 - set_bst_tracking -------->PASSED\n")
834
+ else
835
+ file.puts( "CH_LEN_052 - set_bst_tracking -------->FAILED\n")
836
+ end
837
+ end
838
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
839
+ resp = Telemetry.get_bst_feature(conn)
840
+ if resp == nil
841
+ file.puts("CH_LEN_053 get_bst_feature -------->FAILED\n")
842
+ else
843
+ file.puts("CH_LEN_053 get_bst_feature -------->PASSED\n")
844
+ end
845
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
846
+ params = {
847
+ "collection-interval" => 60,
848
+ "send-async-reports"=> 0,
849
+ "send-snapshot-on-trigger"=> 1,
850
+ "trigger-rate-limit"=> 1,
851
+ "async-full-report"=> 0,
852
+ "trigger-rate-limit-interval"=> 10,
853
+ "bst-enable"=> 1}
854
+
855
+ resp = Telemetry.set_bst_feature(conn, params)
856
+ resp = Telemetry.get_bst_feature(conn)
857
+ if resp == nil
858
+ file.puts("CH_LEN_054 set_bst_feature -------->FAILED\n")
859
+ else
860
+ if resp['bst-enable'] == 1
861
+ file.puts( "CH_LEN_054 - set_bst_feature -------->PASSED\n")
862
+ else
863
+ file.puts( "CH_LEN_054 - set_bst_feature -------->FAILED\n")
864
+ end
865
+ end
866
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
867
+ params = {
868
+ "include-ingress-port-priority-group" => 1,
869
+ "include-ingress-port-service-pool" => 1,
870
+ "include-ingress-service-pool" => 1,
871
+ "include-egress-port-service-pool" => 1,
872
+ "include-egress-service-pool" => 1,
873
+ "include-egress-rqe-queue" => 1,
874
+ "include-device" => 1
875
+ }
876
+ resp = Telemetry.get_bst_report(conn, params)
877
+ if resp == nil
878
+ file.puts("CH_LEN_055 get_bst_report -------->FAILED\n")
879
+ else
880
+ file.puts("CH_LEN_055 get_bst_report -------->PASSED\n")
881
+ end
882
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
883
+ params = {
884
+ "include-ingress-port-priority-group" => 1,
885
+ "include-ingress-port-service-pool" => 1,
886
+ "include-ingress-service-pool" => 1,
887
+ "include-egress-port-service-pool" => 1,
888
+ "include-egress-service-pool" => 1,
889
+ "include-egress-rqe-queue" => 1,
890
+ "include-device" => 1
891
+ }
892
+ resp = Telemetry.get_bst_threshold(conn, params)
893
+ if resp == nil
894
+ file.puts("CH_LEN_056 get_bst_threshold -------->FAILED\n")
895
+ else
896
+ file.puts("CH_LEN_056 get_bst_threshold -------->PASSED\n")
897
+ end
898
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
899
+ params = {"realm": "device", "threshold": 10}
900
+ resp = Telemetry.set_bst_threshold(conn, params)
901
+ params = {
902
+ "include-ingress-port-priority-group" => 0,
903
+ "include-ingress-port-service-pool" => 0,
904
+ "include-ingress-service-pool" => 0,
905
+ "include-egress-port-service-pool" => 0,
906
+ "include-egress-service-pool" => 0,
907
+ "include-egress-rqe-queue" => 0,
908
+ "include-device" => 1
909
+ }
910
+ resp = Telemetry.get_bst_threshold(conn, params)
911
+ if resp['report'][0]['data'] == '10'
912
+ file.puts("CH_LEN_057 set_bst_threshold -------->PASSED\n")
913
+ else
914
+ file.puts("CH_LEN_057 set_bst_threshold -------->FAILED\n")
915
+ end
916
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
917
+ resp = Telemetry.clear_bst_threshold(conn)
918
+ if resp != nil
919
+ file.puts("CH_LEN_058 clear_bst_threshold -------->FAILED\n")
920
+ else
921
+ file.puts("CH_LEN_058 clear_bst_threshold -------->PASSED\n")
922
+ end
923
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
924
+ resp = Telemetry.clear_bst_stats(conn)
925
+ if resp != nil
926
+ file.puts("CH_LEN_059 clear_bst_stats -------->FAILED\n")
927
+ else
928
+ file.puts("CH_LEN_059 clear_bst_stats -------->PASSED\n")
929
+ end
930
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
931
+ resp = Telemetry.clear_bst_cgsn_ctrs(conn)
932
+ if resp != nil
933
+ file.puts("CH_LEN_060 clear_bst_cgsn_ctrs -------->FAILED\n")
934
+ else
935
+ file.puts("CH_LEN_060 clear_bst_cgsn_ctrs -------->PASSED\n")
936
+ end
937
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
938
+
939
+ #################################################################
940
+
941
+ conf = line.dup
942
+ conf = conf.split('.')[0]
943
+ conf = conf + '.conf'
944
+ file.puts( "\n testing system.rb \n\n")
945
+ resp = System.get_startup_sw(conn)
946
+ if resp != nil
947
+ file.puts("CH_LEN_081 get_startup_sw -------->PASSED\n")
948
+ else
949
+ file.puts("CH_LEN_081 get_startup_sw -------->FAILED\n")
950
+ end
951
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
952
+ params = {"boot software" => "active"}
953
+ resp = System.put_startup_sw(conn, params)
954
+ if resp == nil
955
+ file.puts("CH_LEN_080 put_startup_sw -------->FAILED\n")
956
+ else
957
+ if resp['boot software'] == "active"
958
+ file.puts( "CH_LEN_080 - put_startup_sw -------->PASSED\n")
959
+ else
960
+ file.puts( "CH_LEN_080 - put_startup_sw -------->FAILED\n")
961
+ end
962
+ end
963
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
964
+ params = {
965
+ "protocol" => "tftp",
966
+ "serverip" => "10.240.130.108",
967
+ "dstfile" => "temp/chid/" + conf,
968
+ "srcfile" => "running_config",
969
+ "vrf_name" => "management"
970
+ }
971
+ resp = System.upload_sw_config(conn, params)
972
+ if resp != nil
973
+ file.puts("CH_LEN_085 upload_sw_config -------->PASSED\n")
974
+ else
975
+ file.puts("CH_LEN_085 upload_sw_config -------->FAILED\n")
976
+ end
977
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
978
+ params = {
979
+ "protocol" => "tftp",
980
+ "serverip" => "10.240.130.108",
981
+ "srcfile" => "temp/chid/" + conf,
982
+ "dstfile" => "running_config",
983
+ "vrf_name" => "management"
984
+ }
985
+ resp = System.download_sw_config(conn, params)
986
+ if resp != nil
987
+ file.puts("CH_LEN_083 download_sw_config -------->PASSED\n")
988
+ else
989
+ file.puts("CH_LEN_083 download_sw_config -------->FAILED\n")
990
+ end
991
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
992
+ resp = System.save_config(conn)
993
+ if resp != nil
994
+ file.puts("CH_LEN_084 save_config -------->PASSED\n")
995
+ else
996
+ file.puts("CH_LEN_084 save_config -------->FAILED\n")
997
+ end
998
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
999
+ params = {
1000
+ "protocol" => "tftp",
1001
+ "serverip" => "10.240.130.108",
1002
+ "dstfile" => "running_config",
1003
+ "vrf_name" => "management"
1004
+ }
1005
+ resp = System.upload_tech_support(conn, params)
1006
+ if resp != nil
1007
+ file.puts("CH_LEN_086 upload_tech_support -------->PASSED\n")
1008
+ else
1009
+ file.puts("CH_LEN_086 upload_tech_support -------->FAILED\n")
1010
+ end
1011
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
1012
+ img = YAML.load_file(line)
1013
+ image = img['image']
1014
+ params = {
1015
+ "protocol" => "tftp",
1016
+ "serverip" => "10.240.130.108",
1017
+ "srcfile" => "temp/chid/" + image,
1018
+ "imgtype" => "all",
1019
+ "vrf_name" => "default"
1020
+ }
1021
+ resp = System.download_boot_img(conn, params)
1022
+ if resp != nil
1023
+ file.puts("CH_LEN_079 download_boot_img -------->PASSED\n")
1024
+ else
1025
+ file.puts("CH_LEN_079 download_boot_img -------->FAILED\n")
1026
+ end
1027
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
1028
+ resp = System.get_transfer_status(conn, 'download', 'image')
1029
+ if resp != nil
1030
+ file.puts("CH_LEN_087 get_transfer_status -------->PASSED\n")
1031
+ else
1032
+ file.puts("CH_LEN_087 get_transfer_status -------->FAILED\n")
1033
+ end
1034
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
1035
+ puts "Sleeping to complete image download on switch"
1036
+ sleep(200)
1037
+ resp = System.reset_switch(conn)
1038
+ if resp != nil
1039
+ file.puts("CH_LEN_082 reset_switch -------->PASSED\n")
1040
+ else
1041
+ file.puts("CH_LEN_082 reset_switch -------->FAILED\n")
1042
+ end
1043
+ file.puts( ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
1044
+ end
1045
+
1046
+ puts("\n\n\n CHECK \\tmp\\test_log.txt FOR RESULTS\n\n")