コード例 #1
0
ファイル: dummy_bmc.py プロジェクト: SLS-Dev/cxmanage
    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)
コード例 #2
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)
コード例 #3
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)
コード例 #4
0
ファイル: dummy_bmc.py プロジェクト: SLS-Dev/cxmanage
    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)
コード例 #5
0
ファイル: dummy_bmc.py プロジェクト: SLS-Dev/cxmanage
    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)
コード例 #6
0
ファイル: dummy_bmc.py プロジェクト: SLS-Dev/cxmanage
    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)
コード例 #7
0
ファイル: dummy_bmc.py プロジェクト: SLS-Dev/cxmanage
    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)
コード例 #8
0
ファイル: dummy_bmc.py プロジェクト: SLS-Dev/cxmanage
    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)
コード例 #9
0
ファイル: dummy_bmc.py プロジェクト: SLS-Dev/cxmanage
    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)
コード例 #10
0
ファイル: dummy_bmc.py プロジェクト: SLS-Dev/cxmanage
    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)
コード例 #11
0
ファイル: tftp_test.py プロジェクト: SLS-Dev/cxmanage
 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)