/
H3C.py
119 lines (100 loc) · 2.97 KB
/
H3C.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
"""
Provision 3800 Object Definition
Authors: james.luhrsen@hp.com
Created: 2014-10-02
"""
import re
from BaseSwitch import BaseSwitch
class H3C(BaseSwitch):
"""
H3C Super Class
"""
make = "h3c"
model = ""
mgmt_protocol = "telnet"
mgmt_ip = ""
mgmt_port = ""
mgmt_prompt = "(" + model + ".*>|" + model + ".*])"
initialization_type = "reboot"
of_controller_ip = ""
of_instance_id = "21"
@property
def connection_configs(self):
return ["\r\r\r"]
@property
def initialization_cmds(self):
return [
"\rstartup saved-configuration odl_test_startup_config.cfg main\r",
"reboot\r",
"Y\r",
"\r",
"N\r",
"Y\r",
]
@property
def cleanup_cmds(self):
return [
"system-view",
"undo openflow instance " + self.of_instance_id,
"return",
]
@property
def base_openflow_config(self):
return [
"system-view",
"openflow instance " + self.of_instance_id,
"classification vlan 1",
"controller "
+ self.of_instance_id
+ " address ip "
+ self.of_controller_ip,
"active instance",
"return",
]
@property
def openflow_enable_config(self):
return [
"system-view",
"openflow instance " + self.of_instance_id,
"classification vlan 1",
"active instance",
"return",
]
@property
def openflow_validation_cmd(self):
return "display openflow summary"
@property
def openflow_enable_validations(self):
return [self.of_instance_id + " +Active", "Connected 1 24 N"]
@property
def openflow_disable_config(self):
return [
"system-view",
"openflow instance " + self.of_instance_id,
"undo classification",
"active instance",
"return",
]
@property
def openflow_disable_validations(self):
return [self.of_instance_id + " +Inactive - +- +- +- +-"]
@property
def dump_all_flows(self):
return [""]
@property
def datapath_id_output_command(self):
return "display openflow summary | include 0x"
datapath_id_output_string = ""
datapath_id = ""
def update_datapath_id(self):
if not self.datapath_id_output_string:
self.datapath_id = "unknown"
else:
# 21 Active 0x0015cc3e5f42ad23 Connected 1 24 N
# |---------------------------------(0)---------------------------------|
# |------(1)-------||------(2)-----|
matches = re.search(
r"(.*0x)(\w+) +Connected", self.datapath_id_output_string
)
datapath_id_hex = matches.group(2)
self.datapath_id = self.convert_hex_to_decimal_as_string(datapath_id_hex)