本文整理汇总了Python中cloudcafe.compute.common.equality_tools.EqualityTools.are_sizes_equal方法的典型用法代码示例。如果您正苦于以下问题:Python EqualityTools.are_sizes_equal方法的具体用法?Python EqualityTools.are_sizes_equal怎么用?Python EqualityTools.are_sizes_equal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudcafe.compute.common.equality_tools.EqualityTools
的用法示例。
在下文中一共展示了EqualityTools.are_sizes_equal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ram_and_disk_size_on_resize_up_server_revert
# 需要导入模块: from cloudcafe.compute.common.equality_tools import EqualityTools [as 别名]
# 或者: from cloudcafe.compute.common.equality_tools.EqualityTools import are_sizes_equal [as 别名]
def test_ram_and_disk_size_on_resize_up_server_revert(self):
"""
The server's RAM and disk space should return to its original
values after a resize is reverted
"""
server_response = self.server_behaviors.create_active_server()
server_to_resize = server_response.entity
self.resources.add(server_to_resize.id, self.servers_client.delete_server)
#resize server and revert
self.servers_client.resize(server_to_resize.id, self.flavor_ref_alt)
self.server_behaviors.wait_for_server_status(server_to_resize.id, NovaServerStatusTypes.VERIFY_RESIZE)
self.servers_client.revert_resize(server_to_resize.id)
reverted_server_response = self.server_behaviors.wait_for_server_status(server_to_resize.id, NovaServerStatusTypes.ACTIVE)
reverted_server = reverted_server_response.entity
flavor_response = self.flavors_client.get_flavor_details(self.flavor_ref)
flavor = flavor_response.entity
# Verify that the server resize was reverted
public_address = self.server_behaviors.get_public_ip_address(reverted_server)
reverted_server.admin_pass = server_to_resize.admin_pass
remote_instance = self.server_behaviors.get_remote_instance_client(reverted_server,
self.servers_config,
public_address)
self.assertEqual(self.flavor_ref, reverted_server.flavor.id,
msg="Flavor id not reverted")
lower_limit = int(flavor.ram) - (int(flavor.ram) * .1)
server_ram_size = int(remote_instance.get_ram_size_in_mb())
self.assertTrue(int(flavor.ram) == server_ram_size or lower_limit <= server_ram_size,
msg="Ram size after revert did not match.Expected ram size : %s, Actual ram size : %s" % (flavor.ram, server_ram_size))
self.assertTrue(EqualityTools.are_sizes_equal(flavor.disk, remote_instance.get_disk_size_in_gb(), 0.5),
msg="Disk size %s after revert did not match %s" % (remote_instance.get_disk_size_in_gb(), flavor.disk))
示例2: __eq__
# 需要导入模块: from cloudcafe.compute.common.equality_tools import EqualityTools [as 别名]
# 或者: from cloudcafe.compute.common.equality_tools.EqualityTools import are_sizes_equal [as 别名]
def __eq__(self, other):
"""
@summary: Overrides the default equals
@param other: DiskSize object to compare with
@type other: DiskSize
@return: True if DiskSize objects are equal, False otherwise
@rtype: bool
"""
return self.unit == other.unit and EqualityTools.are_sizes_equal(
self.value, other.value,
self.leeway_for_disk_size)
示例3: test_ram_and_disk_size_on_resize_up_server_confirm_test
# 需要导入模块: from cloudcafe.compute.common.equality_tools import EqualityTools [as 别名]
# 或者: from cloudcafe.compute.common.equality_tools.EqualityTools import are_sizes_equal [as 别名]
def test_ram_and_disk_size_on_resize_up_server_confirm_test(self):
"""
The server's RAM and disk space should be modified to that of
the provided flavor
"""
new_flavor = self.flavors_client.get_flavor_details(self.flavor_ref).entity
public_address = self.compute_provider.get_public_ip_address(self.resized_server)
remote_instance = self.compute_provider.get_remote_instance_client(self.resized_server, public_address)
lower_limit = int(new_flavor.ram) - (int(new_flavor.ram) * .1)
server_ram_size = int(remote_instance.get_ram_size_in_mb())
server_swap_size = int(remote_instance.get_swap_size_in_mb())
self.assertTrue(int(new_flavor.ram) == server_ram_size or lower_limit <= server_ram_size,
msg="Ram size after confirm-resize did not match. Expected ram size : %s, Actual ram size : %s" % (new_flavor.ram, server_ram_size))
self.assertEquals(int(new_flavor.swap), server_swap_size,
msg="Swap size after confirm-resize did not match. Expected swap size: %s, Actual swap size: %s" % (new_flavor.swap, server_swap_size))
self.assertTrue(EqualityTools.are_sizes_equal(new_flavor.disk, remote_instance.get_disk_size_in_gb(), 0.5),
msg="Disk size %s after confirm-resize did not match size %s" % (remote_instance.get_disk_size_in_gb(), new_flavor.disk))
示例4: test_ram_and_disk_size_on_resize_up_server_revert
# 需要导入模块: from cloudcafe.compute.common.equality_tools import EqualityTools [as 别名]
# 或者: from cloudcafe.compute.common.equality_tools.EqualityTools import are_sizes_equal [as 别名]
def test_ram_and_disk_size_on_resize_up_server_revert(self):
"""
The server's RAM and disk space should return to its original
values after a resize is reverted
"""
server_response = self.compute_provider.create_active_server()
server_to_resize = server_response.entity
self.resources.add(server_to_resize.id, self.servers_client.delete_server)
remote_instance = self.compute_provider.get_remote_instance_client(server_to_resize)
file_name = rand_name('file') + '.txt'
file_content = 'This is a test file'
file_details = remote_instance.create_file(file_name, file_content)
#resize server and revert
self.servers_client.resize(server_to_resize.id, self.flavor_ref_alt)
self.compute_provider.wait_for_server_status(server_to_resize.id, NovaServerStatusTypes.VERIFY_RESIZE)
self.servers_client.revert_resize(server_to_resize.id)
reverted_server_response = self.compute_provider.wait_for_server_status(server_to_resize.id, NovaServerStatusTypes.ACTIVE)
reverted_server = reverted_server_response.entity
flavor_response = self.flavors_client.get_flavor_details(self.flavor_ref)
flavor = flavor_response.entity
'''Verify that the server resize was reverted '''
public_address = self.compute_provider.get_public_ip_address(reverted_server)
reverted_server.adminPass = server_to_resize.adminPass
remote_instance = self.compute_provider.get_remote_instance_client(reverted_server, public_address)
actual_file_content = remote_instance.get_file_details(file_details.name)
'''Verify that the file content does not change after resize revert'''
self.assertEqual(actual_file_content, file_details, msg="file changed after resize revert")
self.assertEqual(self.flavor_ref, reverted_server.flavor.id,
msg="Flavor id not reverted")
lower_limit = int(flavor.ram) - (int(flavor.ram) * .1)
server_ram_size = int(remote_instance.get_ram_size_in_mb())
self.assertTrue(int(flavor.ram) == server_ram_size or lower_limit <= server_ram_size,
msg="Ram size after revert did not match.Expected ram size : %s, Actual ram size : %s" % (flavor.ram, server_ram_size))
self.assertTrue(EqualityTools.are_sizes_equal(flavor.disk, remote_instance.get_disk_size_in_gb(), 0.5),
msg="Disk size %s after revert did not match %s" % (remote_instance.get_disk_size_in_gb(), flavor.disk))