예제 #1
0
class ExternalTftpTest(unittest.TestCase):
    """Tests the ExternalTftp class.
    ..note:
        * For testing purposes the 'external' server points to an internally
          hosted one, but it allows us to make sure the actual TFTP protocol is
          working.
    """

    def setUp(self):
        """Create an ExternalTftp object to test with."""
        self.itftp = InternalTftp(ip_address='127.0.0.250')
        self.etftp = ExternalTftp(
                     self.itftp.get_address(relative_host=_get_relative_host()),
                     self.itftp.port)

    def test_put_and_get(self):
        """Test the put_file(src, dest) function. Test the get_file(src,dest)
        function by movign local files around using the TFT Protocol.
        """
        # Create file
        filename = random_file(1024)
        contents = open(filename).read()
        # Upload and remove original file
        basename = os.path.basename(filename)
        self.etftp.put_file(src=filename, dest=basename)
        os.remove(filename)
        self.assertFalse(os.path.exists(filename))
        # Download
        self.etftp.get_file(src=basename, dest=filename)
        # Verify match
        self.assertEqual(open(filename).read(), contents)
        os.remove(filename)
예제 #2
0
    def fabric_info_get_routing_table(self, filename, tftp_addr=None):
        """Upload a routing_table file from the node to TFTP"""
        if not(tftp_addr):
            raise IpmiError('No tftp address!')

        routing_table = []
        routing_table.append('Node 1: rt - 0.2.0.3.2')
        routing_table.append('Node 2: rt - 0.3.0.1.2')
        routing_table.append('Node 3: rt - 0.2.0.1.3')
        routing_table.append('Node 12: rt - 0.2.0.0.1')
        routing_table.append('Node 13: rt - 0.2.0.0.1')
        routing_table.append('Node 14: rt - 0.2.0.0.1')
        routing_table.append('Node 15: rt - 0.2.0.0.1')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        with open('%s/%s' % (work_dir, filename), 'w') as rt_file:
            for rtable in routing_table:
                rt_file.write(rtable + '\n')
            rt_file.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #3
0
    def fabric_info_get_routing_table(self, filename, tftp_addr=None):
        """Upload a routing_table file from the node to TFTP"""
        if not (tftp_addr):
            raise IpmiError('No tftp address!')

        routing_table = []
        routing_table.append('Node 1: rt - 0.2.0.3.2')
        routing_table.append('Node 2: rt - 0.3.0.1.2')
        routing_table.append('Node 3: rt - 0.2.0.1.3')
        routing_table.append('Node 12: rt - 0.2.0.0.1')
        routing_table.append('Node 13: rt - 0.2.0.0.1')
        routing_table.append('Node 14: rt - 0.2.0.0.1')
        routing_table.append('Node 15: rt - 0.2.0.0.1')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        with open('%s/%s' % (work_dir, filename), 'w') as rt_file:
            for rtable in routing_table:
                rt_file.write(rtable + '\n')
            rt_file.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #4
0
class ExternalTftpTest(unittest.TestCase):
    """Tests the ExternalTftp class.
    ..note:
        * For testing purposes the 'external' server points to an internally
          hosted one, but it allows us to make sure the actual TFTP protocol is
          working.
    """
    def setUp(self):
        """Create an ExternalTftp object to test with."""
        self.itftp = InternalTftp(ip_address='127.0.0.250')
        self.etftp = ExternalTftp(
            self.itftp.get_address(relative_host=_get_relative_host()),
            self.itftp.port)

    def test_put_and_get(self):
        """Test the put_file(src, dest) function. Test the get_file(src,dest)
        function by movign local files around using the TFT Protocol.
        """
        # Create file
        filename = random_file(1024)
        contents = open(filename).read()
        # Upload and remove original file
        basename = os.path.basename(filename)
        self.etftp.put_file(src=filename, dest=basename)
        os.remove(filename)
        self.assertFalse(os.path.exists(filename))
        # Download
        self.etftp.get_file(src=basename, dest=filename)
        # Verify match
        self.assertEqual(open(filename).read(), contents)
        os.remove(filename)
예제 #5
0
    def retrieve_firmware(self, filename, partition, image_type, tftp_addr):
        """ Mock retrieve_firmware method """
        self.partitions[partition].retrieves += 1

        # Upload blank image to tftp
        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        open("%s/%s" % (work_dir, filename), "w").write(create_simg(""))
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)
        shutil.rmtree(work_dir)

        return Result(tftp_handle_id=0)
예제 #6
0
    def retrieve_firmware(self, filename, partition, image_type, tftp_addr):
        """ Mock retrieve_firmware method """
        self.partitions[partition].retrieves += 1

        # Upload blank image to tftp
        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        open("%s/%s" % (work_dir, filename), "w").write(create_simg(""))
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)
        shutil.rmtree(work_dir)

        return Result(tftp_handle_id = 0)
예제 #7
0
def get_tftp(args):
    """Get a TFTP server"""
    if args.internal_tftp:
        tftp_args = args.internal_tftp.split(':')
        if len(tftp_args) == 1:
            ip_address = tftp_args[0]
            port = 0
        elif len(tftp_args) == 2:
            ip_address = tftp_args[0]
            port = int(tftp_args[1])
        else:
            print ('ERROR: %s is not a valid argument for --internal-tftp'
                    % args.internal_tftp)
            sys.exit(1)
        return InternalTftp(ip_address=ip_address, port=port,
                verbose=args.verbose)

    elif args.external_tftp:
        tftp_args = args.external_tftp.split(':')
        if len(tftp_args) == 1:
            ip_address = tftp_args[0]
            port = 69
        elif len(tftp_args) == 2:
            ip_address = tftp_args[0]
            port = int(tftp_args[1])
        else:
            print ('ERROR: %s is not a valid argument for --external-tftp'
                    % args.external_tftp)
            sys.exit(1)
        return ExternalTftp(ip_address=ip_address, port=port,
                verbose=args.verbose)

    return InternalTftp(verbose=args.verbose)
예제 #8
0
    def fabric_config_get_uplink_info(self, filename, tftp_addr=None):
        """ Mock fabric_config_get_uplink_info method """
        if not (tftp_addr):
            raise IpmiError('No tftp address!')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        # Create uplink info file
        ulinfo = open("%s/%s" % (work_dir, filename), "w")
        for i in range(1, len(self.ip_addresses)):
            ulinfo.write("Node %i: eth0 0, eth1 0, mgmt 0\n" % i)
        ulinfo.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #9
0
    def fabric_get_linkstats(self, filename, tftp_addr=None,
                             link=None):
        """Upload a link_stats file from the node to TFTP"""
        if not(tftp_addr):
            raise IpmiError('No tftp address!')

        link_stats = []
        link_stats.append('Packet Counts for Link %s:' % link)
        link_stats.append('Link0 StatspFS_LCn_CFG_0(link) = 0x1030d07f')
        link_stats.append('pFS_LCn_CFG_1 = 0x105f')
        link_stats.append('pFS_LCn_STATE = 0x1033')
        link_stats.append('pFS_LCn_SC_STAT = 0x0')
        link_stats.append('pFS_LCn_PKT_CNT_0 = 0x0')
        link_stats.append('pFS_LCn_PKT_CNT_1 = 0x0')
        link_stats.append('pFS_LCn_BYTE_CNT_0 = 0x0')
        link_stats.append('pFS_LCn_BYTE_CNT_1 = 0x0')
        link_stats.append('pFS_LCn_CM_TXDATA_0 = 0x82000000')
        link_stats.append('pFS_LCn_CM_TXDATA_1 = 0x0')
        link_stats.append('pFS_LCn_CM_RXDATA_0 = 0x0')
        link_stats.append('pFS_LCn_CM_RXDATA_1 = 0x0')
        link_stats.append('pFS_LCn_PKT_CNT_0 = 0x0')
        link_stats.append('pFS_LCn_PKT_CNT_1 = 0x0')
        link_stats.append('pFS_LCn_RMCSCNT = 0x1428')
        link_stats.append('pFS_LCn_RUCSCNT = 0x116')
        link_stats.append('pFS_LCn_RERRSCNT = 0x0')
        link_stats.append('pFS_LCn_RDRPSCNT = 0xb4')
        link_stats.append('pFS_LCn_RPKTSCNT = 0x0')
        link_stats.append('pFS_LCn_TPKTSCNT = 0x1')
        link_stats.append('pFS_LCn_TDRPSCNT = 0x0')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        with open('%s/%s' % (work_dir, filename), 'w') as ls_file:
            for stat in link_stats:
                ls_file.write(stat + '\n')
            ls_file.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #10
0
    def fabric_config_get_uplink_info(self, filename, tftp_addr=None):
        """ Mock fabric_config_get_uplink_info method """
        if not(tftp_addr):
            raise IpmiError('No tftp address!')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        # Create uplink info file
        ulinfo = open("%s/%s" % (work_dir, filename), "w")
        for i in range(1, len(self.ip_addresses)):
            ulinfo.write("Node %i: eth0 0, eth1 0, mgmt 0\n" % i)
        ulinfo.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #11
0
    def fabric_get_linkstats(self, filename, tftp_addr=None, link=None):
        """Upload a link_stats file from the node to TFTP"""
        if not (tftp_addr):
            raise IpmiError('No tftp address!')

        link_stats = []
        link_stats.append('Packet Counts for Link %s:' % link)
        link_stats.append('Link0 StatspFS_LCn_CFG_0(link) = 0x1030d07f')
        link_stats.append('pFS_LCn_CFG_1 = 0x105f')
        link_stats.append('pFS_LCn_STATE = 0x1033')
        link_stats.append('pFS_LCn_SC_STAT = 0x0')
        link_stats.append('pFS_LCn_PKT_CNT_0 = 0x0')
        link_stats.append('pFS_LCn_PKT_CNT_1 = 0x0')
        link_stats.append('pFS_LCn_BYTE_CNT_0 = 0x0')
        link_stats.append('pFS_LCn_BYTE_CNT_1 = 0x0')
        link_stats.append('pFS_LCn_CM_TXDATA_0 = 0x82000000')
        link_stats.append('pFS_LCn_CM_TXDATA_1 = 0x0')
        link_stats.append('pFS_LCn_CM_RXDATA_0 = 0x0')
        link_stats.append('pFS_LCn_CM_RXDATA_1 = 0x0')
        link_stats.append('pFS_LCn_PKT_CNT_0 = 0x0')
        link_stats.append('pFS_LCn_PKT_CNT_1 = 0x0')
        link_stats.append('pFS_LCn_RMCSCNT = 0x1428')
        link_stats.append('pFS_LCn_RUCSCNT = 0x116')
        link_stats.append('pFS_LCn_RERRSCNT = 0x0')
        link_stats.append('pFS_LCn_RDRPSCNT = 0xb4')
        link_stats.append('pFS_LCn_RPKTSCNT = 0x0')
        link_stats.append('pFS_LCn_TPKTSCNT = 0x1')
        link_stats.append('pFS_LCn_TDRPSCNT = 0x0')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        with open('%s/%s' % (work_dir, filename), 'w') as ls_file:
            for stat in link_stats:
                ls_file.write(stat + '\n')
            ls_file.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #12
0
    def fabric_config_get_ip_info(self, filename, tftp_addr=None):
        """ Upload an ipinfo file from the node to TFTP"""
        if not(tftp_addr):
            raise IpmiError('No tftp address!')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")

        # Create IP info file
        ipinfo = open("%s/%s" % (work_dir, filename), "w")
        for i in range(len(self.ip_addresses)):
            ipinfo.write("Node %i: %s\n" % (i, self.ip_addresses[i]))
        ipinfo.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #13
0
    def fabric_config_get_ip_info(self, filename, tftp_addr=None):
        """ Upload an ipinfo file from the node to TFTP"""
        if not (tftp_addr):
            raise IpmiError('No tftp address!')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")

        # Create IP info file
        ipinfo = open("%s/%s" % (work_dir, filename), "w")
        for i in range(len(self.ip_addresses)):
            ipinfo.write("Node %i: %s\n" % (i, self.ip_addresses[i]))
        ipinfo.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #14
0
    def fabric_config_get_mac_addresses(self, filename, tftp_addr=None):
        """ Upload a macaddrs file from the node to TFTP"""
        if not(tftp_addr):
            raise IpmiError('No tftp address!')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")

        # Create macaddrs file
        macaddrs = open("%s/%s" % (work_dir, filename), "w")
        for i in range(len(self.ip_addresses)):
            for port in range(3):
                macaddr = "00:00:00:00:%x:%x" % (i, port)
                macaddrs.write("Node %i, Port %i: %s\n" % (i, port, macaddr))
        macaddrs.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #15
0
    def test_tftp(self):
        """ Test the tftp property """
        tftp = InternalTftp()
        self.fabric.tftp = tftp
        self.assertTrue(self.fabric.tftp is tftp)
        for node in self.nodes:
            self.assertTrue(node.tftp is tftp)

        tftp = ExternalTftp("127.0.0.1")
        self.fabric.tftp = tftp
        self.assertTrue(self.fabric.tftp is tftp)
        for node in self.nodes:
            self.assertTrue(node.tftp is tftp)
예제 #16
0
    def fabric_config_get_mac_addresses(self, filename, tftp_addr=None):
        """ Upload a macaddrs file from the node to TFTP"""
        if not (tftp_addr):
            raise IpmiError('No tftp address!')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")

        # Create macaddrs file
        macaddrs = open("%s/%s" % (work_dir, filename), "w")
        for i in range(len(self.ip_addresses)):
            for port in range(3):
                macaddr = "00:00:00:00:%x:%x" % (i, port)
                macaddrs.write("Node %i, Port %i: %s\n" % (i, port, macaddr))
        macaddrs.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #17
0
    def fabric_info_get_link_map(self, filename, tftp_addr=None):
        """Upload a link_map file from the node to TFTP"""
        if not(tftp_addr):
            raise IpmiError('No tftp address!')

        link_map = []
        link_map.append('Link 1: Node 2')
        link_map.append('Link 3: Node 1')
        link_map.append('Link 4: Node 3')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        with open('%s/%s' % (work_dir, filename), 'w') as lm_file:
            for lmap in link_map:
                lm_file.write(lmap + '\n')
            lm_file.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #18
0
    def fabric_info_get_link_map(self, filename, tftp_addr=None):
        """Upload a link_map file from the node to TFTP"""
        if not (tftp_addr):
            raise IpmiError('No tftp address!')

        link_map = []
        link_map.append('Link 1: Node 2')
        link_map.append('Link 3: Node 1')
        link_map.append('Link 4: Node 3')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        with open('%s/%s' % (work_dir, filename), 'w') as lm_file:
            for lmap in link_map:
                lm_file.write(lmap + '\n')
            lm_file.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #19
0
    def fabric_info_get_depth_chart(self, filename, tftp_addr=None):
        """Upload a depth_chart file from the node to TFTP"""
        if not(tftp_addr):
            raise IpmiError('No tftp address!')

        depth_chart = []
        depth_chart.append(
           'Node 1: Shortest Distance 0 hops via neighbor 0: ' +
           'other hops/neighbors -'
        )
        depth_chart.append(
            'Node 2: Shortest Distance 0 hops via neighbor 0: ' +
            'other hops/neighbors - 1/3'
        )
        depth_chart.append(
            'Node 3: Shortest Distance 0 hops via neighbor 0: ' +
            'other hops/neighbors - 1/2'
        )
        depth_chart.append(
            'Node 4: Shortest Distance 2 hops via neighbor 6: ' +
            'other hops/neighbors - 3/7'
        )
        depth_chart.append(
            'Node 5: Shortest Distance 3 hops via neighbor 4: ' +
            'other hops/neighbors -'
        )
        depth_chart.append(
            'Node 6: Shortest Distance 1 hops via neighbor 2: ' +
            'other hops/neighbors -'
        )
        depth_chart.append(
            'Node 7: Shortest Distance 2 hops via neighbor 6: ' +
            'other hops/neighbors - 3/4'
        )
        depth_chart.append(
            'Node 8: Shortest Distance 3 hops via neighbor 10: ' +
            'other hops/neighbors - 4/11'
        )
        depth_chart.append(
            'Node 9: Shortest Distance 4 hops via neighbor 8: ' +
            'other hops/neighbors -'
        )
        depth_chart.append(
            'Node 10: Shortest Distance 2 hops via neighbor 6: ' +
            'other hops/neighbors -'
        )
        depth_chart.append(
            'Node 11: Shortest Distance 3 hops via neighbor 10: ' +
            'other hops/neighbors - 4/8'
        )
        depth_chart.append(
            'Node 12: Shortest Distance 4 hops via neighbor 14: ' +
            'other hops/neighbors - 5/15'
        )
        depth_chart.append(
            'Node 13: Shortest Distance 5 hops via neighbor 12: ' +
            'other hops/neighbors -'
        )
        depth_chart.append(
            'Node 14: Shortest Distance 3 hops via neighbor 10: ' +
            'other hops/neighbors -'
        )
        depth_chart.append(
            'Node 15: Shortest Distance 4 hops via neighbor 14: ' +
            'other hops/neighbors - 5/12'
        )

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        with open('%s/%s' % (work_dir, filename), 'w') as dc_file:
            for dchart in depth_chart:
                dc_file.write(dchart + '\n')
            dc_file.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)
예제 #20
0
 def setUp(self):
     """Create an ExternalTftp object to test with."""
     self.itftp = InternalTftp(ip_address='127.0.0.250')
     self.etftp = ExternalTftp(
                  self.itftp.get_address(relative_host=_get_relative_host()),
                  self.itftp.port)
예제 #21
0
 def setUp(self):
     """Create an ExternalTftp object to test with."""
     self.itftp = InternalTftp(ip_address='127.0.0.250')
     self.etftp = ExternalTftp(
         self.itftp.get_address(relative_host=_get_relative_host()),
         self.itftp.port)
예제 #22
0
    def fabric_info_get_depth_chart(self, filename, tftp_addr=None):
        """Upload a depth_chart file from the node to TFTP"""
        if not (tftp_addr):
            raise IpmiError('No tftp address!')

        depth_chart = []
        depth_chart.append(
            'Node 1: Shortest Distance 0 hops via neighbor 0: ' +
            'other hops/neighbors -')
        depth_chart.append(
            'Node 2: Shortest Distance 0 hops via neighbor 0: ' +
            'other hops/neighbors - 1/3')
        depth_chart.append(
            'Node 3: Shortest Distance 0 hops via neighbor 0: ' +
            'other hops/neighbors - 1/2')
        depth_chart.append(
            'Node 4: Shortest Distance 2 hops via neighbor 6: ' +
            'other hops/neighbors - 3/7')
        depth_chart.append(
            'Node 5: Shortest Distance 3 hops via neighbor 4: ' +
            'other hops/neighbors -')
        depth_chart.append(
            'Node 6: Shortest Distance 1 hops via neighbor 2: ' +
            'other hops/neighbors -')
        depth_chart.append(
            'Node 7: Shortest Distance 2 hops via neighbor 6: ' +
            'other hops/neighbors - 3/4')
        depth_chart.append(
            'Node 8: Shortest Distance 3 hops via neighbor 10: ' +
            'other hops/neighbors - 4/11')
        depth_chart.append(
            'Node 9: Shortest Distance 4 hops via neighbor 8: ' +
            'other hops/neighbors -')
        depth_chart.append(
            'Node 10: Shortest Distance 2 hops via neighbor 6: ' +
            'other hops/neighbors -')
        depth_chart.append(
            'Node 11: Shortest Distance 3 hops via neighbor 10: ' +
            'other hops/neighbors - 4/8')
        depth_chart.append(
            'Node 12: Shortest Distance 4 hops via neighbor 14: ' +
            'other hops/neighbors - 5/15')
        depth_chart.append(
            'Node 13: Shortest Distance 5 hops via neighbor 12: ' +
            'other hops/neighbors -')
        depth_chart.append(
            'Node 14: Shortest Distance 3 hops via neighbor 10: ' +
            'other hops/neighbors -')
        depth_chart.append(
            'Node 15: Shortest Distance 4 hops via neighbor 14: ' +
            'other hops/neighbors - 5/12')

        work_dir = tempfile.mkdtemp(prefix="cxmanage_test-")
        with open('%s/%s' % (work_dir, filename), 'w') as dc_file:
            for dchart in depth_chart:
                dc_file.write(dchart + '\n')
            dc_file.close()

        # Upload to tftp
        address, port = tftp_addr.split(":")
        port = int(port)
        tftp = ExternalTftp(address, port)
        tftp.put_file("%s/%s" % (work_dir, filename), filename)

        shutil.rmtree(work_dir)