Commit f874bcac by Sunil Kumar Veerappa

Clean code for FPGA reprogramming

parent 405de400
......@@ -50,23 +50,20 @@ class M2DCFPGADriver(FPGADriver):
return sysinfo.discover_boards()
def program(self, device_id, image):
LOG.error("Device id is " + str(device_id))
LOG.error("Image location is " + str(image))
device_details = Device.get_by_id(self, device_id)
LOG.error("board ip is " + str(device_details.std_board_info))
SSH_USERNAME = "root"
SSH_PASSWORD = ''
SSH_COMMAND = "aocl program " + image
#paramiko.Transport._preferred_ciphers = ('aes256-ctr',)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_stdin = ssh_stdout = ssh_stderr = None
try:
ssh.connect(device_details.std_board_info, username=SSH_USERNAME)
ssh.connect(device_details.std_board_info, username=SSH_USERNAME, password=SSH_PASSWORD)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(SSH_COMMAND)
except Exception as e:
sys.stderr.write("SSH connection error: {0}".format(e))
......
......@@ -42,8 +42,6 @@ CONF = cyborg.conf.CONF
RECS_URL = None
list_fpga_id=[]
list_fpga_id1=["fpga1","fpga2"]
list_fpga_ip1 =["192.168.2.159","192.168.2.159"]
list_fpga_mac=[]
list_fpga_ip=[]
......@@ -96,21 +94,21 @@ def _generate_dep_list(item):
driver_dep.num_accelerators = 2
driver_dep.attach_handle_list = \
[_generate_attach_handle(item)]
driver_dep.name = "test2"+item
driver_dep.name = item
dep_list.append(driver_dep)
return dep_list
def _generate_attach_handle(item):
driver_ah = driver_attach_handle.DriverAttachHandle()
driver_ah.attach_type = "PCI"
driver_ah.attach_info = "test2"+item
driver_ah.attach_info = item
driver_ah.in_use = False
return driver_ah
def _generate_controlpath_id(item):
driver_cpid = driver_controlpath_id.DriverControlPathID()
driver_cpid.cpid_type = "PCI"
driver_cpid.cpid_info = "test_cyborg"+item
driver_cpid.cpid_info = item
return driver_cpid
def _generate_driver_device(item, ip_item, device_data):
......@@ -139,22 +137,17 @@ def discover_boards():
device_data={}
#Added mechanism to extract IP addresses of the FPGA available in RECS board
list_fpga()
LOG.error("List of FPGA are "+ str(list_fpga_id))
LOG.error("List of FPGA mac address are " + str(list_fpga_mac))
#extract ip from the mac address
for mac_record in list_fpga_mac:
ip_fpga = subprocess.check_output(str("arp -n | grep -w -i \'88:a2:d7:1f:49:45\' | awk \'{print $1}\'"),
ip_fpga = subprocess.check_output(str("arp -n | grep -w -i " + mac_record + " | awk \'{print $1}\'"),
stdin=subprocess.PIPE, shell=True)
if ip_fpga.rstrip() not in list_fpga_ip:
list_fpga_ip.append(ip_fpga.rstrip())
LOG.error("List of FPGA IP address are " + str(list_fpga_ip))
#feed to the agent service ussing the extracted IP
for item, ip_item in zip(list_fpga_id1, list_fpga_ip1):
for item, ip_item in zip(list_fpga_id, list_fpga_ip):
SSH_ADDRESS = "192.168.1.155"
SSH_USERNAME = "root"
SSH_PASSWORD = ''
SSH_COMMAND = "source /home/root/init_opencl.sh ; aocl diagnose"
......@@ -164,7 +157,7 @@ def discover_boards():
ssh_stdin = ssh_stdout = ssh_stderr = None
try:
ssh.connect(SSH_ADDRESS, username=SSH_USERNAME, password=SSH_PASSWORD)
ssh.connect(ip_item, username=SSH_USERNAME, password=SSH_PASSWORD)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(SSH_COMMAND)
except Exception as e:
sys.stderr.write("SSH connection error: {0}".format(e))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment