FIOEndpProfile create can now take a connections_per_port arg

This commit is contained in:
Logan Lipke
2020-12-17 15:32:48 -08:00
parent eef7eb1c76
commit 4edf9cb73c

View File

@@ -2452,68 +2452,69 @@ class FIOEndpProfile(LFCliBase):
self.json_post(req_url, data) self.json_post(req_url, data)
#pprint(data) #pprint(data)
def create(self, ports=[], sleep_time=.5, debug_=False, suppress_related_commands_=None): def create(self, ports=[], connections_per_port=1, sleep_time=.5, debug_=False, suppress_related_commands_=None):
cx_post_data = [] cx_post_data = []
for port_name in ports: for port_name in ports:
if len(self.local_realm.name_to_eid(port_name)) == 3: for num_connection in range(connections_per_port):
shelf = self.local_realm.name_to_eid(port_name)[0] if len(self.local_realm.name_to_eid(port_name)) == 3:
resource = self.local_realm.name_to_eid(port_name)[1] shelf = self.local_realm.name_to_eid(port_name)[0]
name = self.local_realm.name_to_eid(port_name)[2] resource = self.local_realm.name_to_eid(port_name)[1]
else: name = self.local_realm.name_to_eid(port_name)[2]
raise ValueError("Unexpected name for port_name %s" % port_name) else:
if self.directory is None or self.server_mount is None or self.fs_type is None: raise ValueError("Unexpected name for port_name %s" % port_name)
raise ValueError("directory [%s], server_mount [%s], and type [%s] must not be None" % (self.directory, self.server_mount, self.fs_type)) if self.directory is None or self.server_mount is None or self.fs_type is None:
endp_data = { raise ValueError("directory [%s], server_mount [%s], and type [%s] must not be None" % (self.directory, self.server_mount, self.fs_type))
"alias": self.cx_prefix + name + "_fio", endp_data = {
"shelf": shelf, "alias": self.cx_prefix + name + "_" + str(num_connection) + "_fio" ,
"resource": resource, "shelf": shelf,
"port": name, "resource": resource,
"type": self.fs_type, "port": name,
"min_read_rate": self.min_read_rate_bps, "type": self.fs_type,
"max_read_rate": self.max_read_rate_bps, "min_read_rate": self.min_read_rate_bps,
"min_write_rate": self.min_write_rate_bps, "max_read_rate": self.max_read_rate_bps,
"max_write_rate": self.max_write_rate_bps, "min_write_rate": self.min_write_rate_bps,
"directory": self.directory, "max_write_rate": self.max_write_rate_bps,
"server_mount": self.server_mount, "directory": self.directory,
"mount_dir": self.mount_dir, "server_mount": self.server_mount,
"prefix": self.file_prefix, "mount_dir": self.mount_dir,
"payload_pattern": self.pattern, "prefix": self.file_prefix,
"payload_pattern": self.pattern,
} }
# Read direction is copy of write only directory # Read direction is copy of write only directory
if self.io_direction == "read": if self.io_direction == "read":
endp_data["prefix"] = "wo_" + name + "_fio" endp_data["prefix"] = "wo_" + name + "_" + str(num_connection) + "_fio"
endp_data["directory"] = "/mnt/lf/wo_" + name + "_fio" endp_data["directory"] = "/mnt/lf/wo_" + name + "_" + str(num_connection) + "_fio"
url = "cli-json/add_file_endp" url = "cli-json/add_file_endp"
self.local_realm.json_post(url, endp_data, debug_=True, suppress_related_commands_=suppress_related_commands_) self.local_realm.json_post(url, endp_data, debug_=True, suppress_related_commands_=suppress_related_commands_)
time.sleep(sleep_time) time.sleep(sleep_time)
data = { data = {
"name": self.cx_prefix + name + "_fio", "name": self.cx_prefix + name + "_" + str(num_connection) + "_fio" ,
"io_direction": self.io_direction, "io_direction": self.io_direction,
"num_files": 5 "num_files": 5
} }
self.local_realm.json_post("cli-json/set_fe_info", data, debug_=debug_, self.local_realm.json_post("cli-json/set_fe_info", data, debug_=debug_,
suppress_related_commands_=suppress_related_commands_) suppress_related_commands_=suppress_related_commands_)
self.local_realm.json_post("/cli-json/nc_show_endpoints", {"endpoint": "all"}) self.local_realm.json_post("/cli-json/nc_show_endpoints", {"endpoint": "all"})
for port_name in ports: for port_name in ports:
if len(self.local_realm.name_to_eid(port_name)) == 3: for num_connection in range(connections_per_port):
shelf = self.local_realm.name_to_eid(port_name)[0] if len(self.local_realm.name_to_eid(port_name)) == 3:
resource = self.local_realm.name_to_eid(port_name)[1] shelf = self.local_realm.name_to_eid(port_name)[0]
name = self.local_realm.name_to_eid(port_name)[2] resource = self.local_realm.name_to_eid(port_name)[1]
name = self.local_realm.name_to_eid(port_name)[2]
endp_data = { endp_data = {
"alias": "CX_" + self.cx_prefix + name + "_fio", "alias": "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio" ,
"test_mgr": "default_tm", "test_mgr": "default_tm",
"tx_endp": self.cx_prefix + name + "_fio", "tx_endp": self.cx_prefix + name + "_" + str(num_connection) + "_fio" ,
"rx_endp": "NA" "rx_endp": "NA"
} }
cx_post_data.append(endp_data) cx_post_data.append(endp_data)
self.created_cx[self.cx_prefix + name + "_fio"] = "CX_" + self.cx_prefix + name + "_fio" self.created_cx[self.cx_prefix + name + "_" + str(num_connection) + "_fio" ] = "CX_" + self.cx_prefix + name + "_" + str(num_connection) + "_fio"
# time.sleep(3)
for cx_data in cx_post_data: for cx_data in cx_post_data:
url = "/cli-json/add_cx" url = "/cli-json/add_cx"
self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_)