2 Provision 3800 Object Definition
3 Authors: james.luhrsen@hp.com
7 from BaseSwitch import BaseSwitch
10 class ProVision(BaseSwitch):
18 mgmt_protocol = 'telnet'
21 mgmt_prompt = model + '.*#'
23 initialization_type = 'reboot'
28 def connection_configs(self):
31 \rconsole local-terminal none \
36 def initialization_cmds(self):
37 return ['\rend\rboot system flash primary config odl_test_startup_config\r',
42 def cleanup_cmds(self):
49 def base_openflow_config(self):
53 'controller-id ' + self.of_instance_id + ' ip ' + self.of_controller_ip + \
54 ' controller-interface oobm', \
55 'instance ' + self.of_instance_id, \
57 'controller-id ' + self.of_instance_id + ' ', \
64 def openflow_enable_config(self):
71 def openflow_validation_cmd(self):
76 def openflow_enable_validations(self):
77 return ['OpenFlow +: Enabled',
78 self.of_instance_id + ' +Up +2 +1 +1.3']
81 def openflow_disable_config(self):
88 def openflow_disable_validations(self):
89 return ['OpenFlow +: Disabled', self.of_instance_id + ' +Down +0 +0 +1.3']
92 def dump_all_flows(self):
93 return 'show openflow instance ' + self.of_instance_id + ' flows'
96 def flow_validations(self):
97 return ['(?ms)Flow Table ID : 0.*Flow Table ID : 100.*' +
98 'Source Protocol Address : ' + self.ip_src + '.*' +
99 'Target Protocol Address : ' + self.ip_dst + '.*' +
100 'Flow Table ID : ' + self.table_id + '.*' + self.action,
101 'Source MAC : ' + self.src_mac,
102 'Destination MAC : ' + self.dst_mac]
104 def create_flow_match_elements(self, flow_xml):
105 super(ProVision, self).create_flow_match_elements(flow_xml)
106 self.src_mac = self.format_mac_with_no_hyphens_and_one_colon(self.src_mac)
107 self.dst_mac = self.format_mac_with_no_hyphens_and_one_colon(self.dst_mac)
108 self.action = self.convert_action_to_provision_format(self.action)
110 def format_mac_with_no_hyphens_and_one_colon(self, mac):
111 mac_no_colons = re.sub(':', '', mac)
112 mac_with_hyphen = mac_no_colons[:6] + '-' + mac_no_colons[6:]
113 return mac_with_hyphen
115 def convert_action_to_provision_format(self, action):
116 if (action == 'INPORT'):
117 return 'Ingress Port'
118 if (action == 'TABLE'):
120 if (action == 'NORMAL'):
122 if (action == 'FLOOD'):
124 if (action == 'ALL'):
126 if (action == 'CONTROLLER'):
127 return 'Controller Port'
128 if (action == 'LOCAL'):
133 def datapath_id_output_command(self):
135 'show openflow instance ' + self.of_instance_id + ' | include Datapath'
137 connection_index = ''
139 def set_connection_index(self, idx):
140 self.connection_index = idx
142 datapath_id_output_string = ''
145 def update_datapath_id(self):
146 if not self.datapath_id_output_string:
147 self.datapath_id = 'unknown'
149 # Datapath ID : 000af0921c22bac0
150 # |-----------------(0)---------------------|
151 # |-----------(1)----------| |------(2)-----|
152 matches = re.search('(.*: )(\w+)', self.datapath_id_output_string)
153 datapath_id_hex = matches.group(2)
154 self.datapath_id = self.convert_hex_to_decimal_as_string(datapath_id_hex)