MCPcopy Create free account
hub / github.com/apache/cloudstack / compareChecksum

Function compareChecksum

tools/marvin/marvin/lib/common.py:1702–1767  ·  view source on GitHub ↗

Create md5 checksum of the data present on the disk and compare it with the given checksum

(
        apiclient,
        service=None,
        original_checksum=None,
        disk_type=None,
        virt_machine=None
        )

Source from the content-addressed store, hash-verified

1700
1701
1702def compareChecksum(
1703 apiclient,
1704 service=None,
1705 original_checksum=None,
1706 disk_type=None,
1707 virt_machine=None
1708 ):
1709 """
1710 Create md5 checksum of the data present on the disk and compare
1711 it with the given checksum
1712 """
1713 if virt_machine.state != "Running":
1714 virt_machine.start(apiclient)
1715
1716 try:
1717 # Login to VM to verify test directories and files
1718 ssh = SshClient(
1719 virt_machine.ssh_ip,
1720 virt_machine.ssh_port,
1721 virt_machine.username,
1722 virt_machine.password
1723 )
1724 except Exception:
1725 raise Exception("SSH access failed for server with IP address: %s" %
1726 virt_machine.ssh_ip)
1727
1728 # Mount datadiskdevice_1 because this is the first data disk of the new
1729 # virtual machine
1730 cmds = ["blkid",
1731 "fdisk -l",
1732 "mkdir -p %s" % service["data_write_paths"]["mount_dir"],
1733 "mount -t ext3 %s1 %s" % (
1734 service["volume_write_path"][
1735 virt_machine.hypervisor.lower()][disk_type],
1736 service["data_write_paths"]["mount_dir"]
1737 ),
1738 ]
1739
1740 for c in cmds:
1741 ssh.execute(c)
1742
1743 returned_data_0 = ssh.execute(
1744 "cat %s/%s/%s/%s" % (
1745 service["data_write_paths"]["mount_dir"],
1746 service["data_write_paths"]["sub_dir"],
1747 service["data_write_paths"]["sub_lvl_dir1"],
1748 service["data_write_paths"]["random_data"]
1749 ))
1750
1751 n = hashlib.md5()
1752 n.update(returned_data_0[0])
1753 ckecksum_returned_data_0 = n.hexdigest()
1754
1755 # Verify returned data
1756 assert original_checksum == ckecksum_returned_data_0, \
1757 "Cheskum does not match with checksum of original data"
1758
1759 # Unmount the Sec Storage

Calls 4

executeMethod · 0.95
SshClientClass · 0.90
startMethod · 0.65
updateMethod · 0.65