<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calc_device_links(self):
 """ Calculate a router or VirtualBox link """

        for connection in self.interfaces:
            int_type = connection['from'][0]
            int_name = connection['from'].replace(int_type,
                                                  PORT_TYPES[int_type.upper()])
            # Get the source port id
            src_port = None
            for port in self.node['ports']:
                if int_name == port['name']:
                    src_port = port['id']
                    break
            dest_temp = connection['to'].split(' ')

            if len(dest_temp) == 2:
                conn_to = {'device': dest_temp[0],
                           'port': dest_temp[1]}
            else:
                conn_to = {'device': 'NIO',
                           'port': dest_temp[0]}

            self.calc_link(self.node['id'], src_port, int_name, conn_to)