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):
32 \rconsole local-terminal none \
38 def initialization_cmds(self):
40 "\rend\rboot system flash primary config odl_test_startup_config\r",
46 def cleanup_cmds(self):
47 return ["end", "config", "no openflow\r", "y"]
50 def base_openflow_config(self):
58 + self.of_controller_ip
59 + " controller-interface oobm",
60 "instance " + self.of_instance_id,
62 "controller-id " + self.of_instance_id + " ",
70 def openflow_enable_config(self):
71 return ["end", "config", "openflow enable", "end"]
74 def openflow_validation_cmd(self):
75 return "show openflow"
78 def openflow_enable_validations(self):
79 return ["OpenFlow +: Enabled", self.of_instance_id + " +Up +2 +1 +1.3"]
82 def openflow_disable_config(self):
83 return ["end", "config", "openflow disable", "end"]
86 def openflow_disable_validations(self):
87 return ["OpenFlow +: Disabled", self.of_instance_id + " +Down +0 +0 +1.3"]
90 def dump_all_flows(self):
91 return "show openflow instance " + self.of_instance_id + " flows"
94 def flow_validations(self):
96 "(?ms)Flow Table ID : 0.*Flow Table ID : 100.*"
97 + "Source Protocol Address : "
100 + "Target Protocol Address : "
107 "Source MAC : " + self.src_mac,
108 "Destination MAC : " + self.dst_mac,
111 def create_flow_match_elements(self, flow_xml):
112 super(ProVision, self).create_flow_match_elements(flow_xml)
113 self.src_mac = self.format_mac_with_no_hyphens_and_one_colon(self.src_mac)
114 self.dst_mac = self.format_mac_with_no_hyphens_and_one_colon(self.dst_mac)
115 self.action = self.convert_action_to_provision_format(self.action)
117 def format_mac_with_no_hyphens_and_one_colon(self, mac):
118 mac_no_colons = re.sub(":", "", mac)
119 mac_with_hyphen = mac_no_colons[:6] + "-" + mac_no_colons[6:]
120 return mac_with_hyphen
122 def convert_action_to_provision_format(self, action):
123 if action == "INPORT":
124 return "Ingress Port"
125 if action == "TABLE":
127 if action == "NORMAL":
129 if action == "FLOOD":
133 if action == "CONTROLLER":
134 return "Controller Port"
135 if action == "LOCAL":
140 def datapath_id_output_command(self):
141 return "show openflow instance " + self.of_instance_id + " | include Datapath"
143 connection_index = ""
145 def set_connection_index(self, idx):
146 self.connection_index = idx
148 datapath_id_output_string = ""
151 def update_datapath_id(self):
152 if not self.datapath_id_output_string:
153 self.datapath_id = "unknown"
155 # Datapath ID : 000af0921c22bac0
156 # |-----------------(0)---------------------|
157 # |-----------(1)----------| |------(2)-----|
158 matches = re.search(r"(.*: )(\w+)", self.datapath_id_output_string)
159 datapath_id_hex = matches.group(2)
160 self.datapath_id = self.convert_hex_to_decimal_as_string(datapath_id_hex)