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

Function createChecksum

tools/marvin/marvin/lib/common.py:1629–1699  ·  view source on GitHub ↗

Calculate the MD5 checksum of the disk by writing \ data on the disk where disk_type is either root disk or data disk @return: returns the calculated checksum

(service=None,
                   virtual_machine=None,
                   disk=None,
                   disk_type=None)

Source from the content-addressed store, hash-verified

1627
1628
1629def createChecksum(service=None,
1630 virtual_machine=None,
1631 disk=None,
1632 disk_type=None):
1633
1634 """ Calculate the MD5 checksum of the disk by writing \
1635 data on the disk where disk_type is either root disk or data disk
1636 @return: returns the calculated checksum"""
1637
1638 random_data_0 = random_gen(size=100)
1639 # creating checksum(MD5)
1640 m = hashlib.md5()
1641 m.update(random_data_0)
1642 ckecksum_random_data_0 = m.hexdigest()
1643 try:
1644 ssh_client = SshClient(
1645 virtual_machine.ssh_ip,
1646 virtual_machine.ssh_port,
1647 virtual_machine.username,
1648 virtual_machine.password
1649 )
1650 except Exception:
1651 raise Exception("SSH access failed for server with IP address: %s" %
1652 virtual_machine.ssh_ip)
1653
1654 # Format partition using ext3
1655
1656 format_volume_to_ext3(
1657 ssh_client,
1658 service["volume_write_path"][
1659 virtual_machine.hypervisor.lower()][disk_type]
1660 )
1661 cmds = ["fdisk -l",
1662 "mkdir -p %s" % service["data_write_paths"]["mount_dir"],
1663 "mount -t ext3 %s1 %s" % (
1664 service["volume_write_path"][
1665 virtual_machine.hypervisor.lower()][disk_type],
1666 service["data_write_paths"]["mount_dir"]
1667 ),
1668 "mkdir -p %s/%s/%s " % (
1669 service["data_write_paths"]["mount_dir"],
1670 service["data_write_paths"]["sub_dir"],
1671 service["data_write_paths"]["sub_lvl_dir1"],
1672 ),
1673 "echo %s > %s/%s/%s/%s" % (
1674 random_data_0,
1675 service["data_write_paths"]["mount_dir"],
1676 service["data_write_paths"]["sub_dir"],
1677 service["data_write_paths"]["sub_lvl_dir1"],
1678 service["data_write_paths"]["random_data"]
1679 ),
1680 "cat %s/%s/%s/%s" % (
1681 service["data_write_paths"]["mount_dir"],
1682 service["data_write_paths"]["sub_dir"],
1683 service["data_write_paths"]["sub_lvl_dir1"],
1684 service["data_write_paths"]["random_data"]
1685 )
1686 ]

Calls 5

executeMethod · 0.95
random_genFunction · 0.90
SshClientClass · 0.90
format_volume_to_ext3Function · 0.90
updateMethod · 0.65