2 Provision 3800 Object Definition
3 Authors: james.luhrsen@hp.com
9 from robot.libraries.BuiltIn import BuiltIn
10 from BaseSwitch import *
12 class ProVision(BaseSwitch):
20 mgmt_protocol = 'telnet'
23 mgmt_prompt = model + '.*#'
25 initialization_type = 'reboot'
30 def connection_configs(self):
34 \rconsole local-terminal none \
39 def initialization_cmds(self):
41 ['\rend\rboot system flash primary config odl_test_startup_config\r', \
46 def cleanup_cmds(self):
54 def base_openflow_config(self):
59 'controller-id ' + self.of_instance_id + ' ip ' + self.of_controller_ip + \
60 ' controller-interface oobm', \
61 'instance ' + self.of_instance_id, \
63 'controller-id ' + self.of_instance_id + ' ', \
70 def openflow_enable_config(self):
78 def openflow_validation_cmd(self):
83 def openflow_enable_validations(self):
85 ['OpenFlow +: Enabled', \
86 self.of_instance_id + ' +Up +2 +1 +1.3']
89 def openflow_disable_config(self):
97 def openflow_disable_validations(self):
99 ['OpenFlow +: Disabled', \
100 self.of_instance_id + ' +Down +0 +0 +1.3']
103 def dump_all_flows(self):
105 'show openflow instance ' + self.of_instance_id + ' flows'
108 def flow_validations(self):
110 ['(?ms)Flow Table ID : 0.*Flow Table ID : 100.*' + \
111 'Source Protocol Address : ' + self.ip_src + '.*' + \
112 'Target Protocol Address : ' + self.ip_dst + '.*' + \
113 'Flow Table ID : ' + self.table_id + '.*' + self.action, \
114 'Source MAC : ' + self.src_mac, \
115 'Destination MAC : ' + self.dst_mac]
117 def create_flow_match_elements(self, flow_xml):
118 super(ProVision, self).create_flow_match_elements(flow_xml)
119 self.src_mac = self.format_mac_with_no_hyphens_and_one_colon(self.src_mac)
120 self.dst_mac = self.format_mac_with_no_hyphens_and_one_colon(self.dst_mac)
121 self.action = self.convert_action_to_provision_format(self.action)
123 def format_mac_with_no_hyphens_and_one_colon(self, mac):
124 mac_no_colons = re.sub(':', '', mac)
125 mac_with_hyphen = mac_no_colons[:6] + '-' + mac_no_colons[6:]
126 return mac_with_hyphen
128 def convert_action_to_provision_format(self, action):
129 if (action == 'INPORT'):
130 return 'Ingress Port'
131 if (action == 'TABLE'):
133 if (action == 'NORMAL'):
135 if (action == 'FLOOD'):
137 if (action == 'ALL'):
139 if (action == 'CONTROLLER'):
140 return 'Controller Port'
141 if (action == 'LOCAL'):
146 def datapath_id_output_command(self):
148 'show openflow instance ' + self.of_instance_id + ' | include Datapath'
150 connection_index = ''
152 def set_connection_index(self, idx):
153 self.connection_index = idx
155 datapath_id_output_string = ''
158 def update_datapath_id(self):
159 if not self.datapath_id_output_string:
160 self.datapath_id = 'unknown'
162 #Datapath ID : 000af0921c22bac0
163 #|-----------------(0)---------------------|
164 #|-----------(1)----------| |------(2)-----|
165 matches = re.search('(.*: )(\w+)', self.datapath_id_output_string)
166 datapath_id_hex = matches.group(2)
167 self.datapath_id = self.convert_hex_to_decimal_as_string(datapath_id_hex)