def set_memory(args): options = { "mandatory": ["name", "size"], "optional" : [], } check_args(args, options) name = args["name"] size = args["size"] if re.match(r'.+G$', size): size = int(size[:-1]) size = size * 1024 * 1024 elif re.match(r'.+M$', size): size = int(size[:-1]) size = size * 1024 elif re.match(r'.+K$', size): size = int(size[:-1]) if size > 10 * 1024 * 1024: raise Exception("Size is too large.") virt = Virt(hosts()) virt.set_memory(name, size)
def set_memory(args): options = { "mandatory": ["name", "size"], "optional": [], } check_args(args, options) name = args["name"] size = args["size"] if re.match(r'.+G$', size): size = int(size[:-1]) size = size * 1024 * 1024 elif re.match(r'.+M$', size): size = int(size[:-1]) size = size * 1024 elif re.match(r'.+K$', size): size = int(size[:-1]) if size > 10 * 1024 * 1024: raise Exception("Size is too large.") virt = Virt(hosts()) virt.set_memory(name, size)
def test_set_memory(): virt = Virt() ok_(virt.set_memory("test", 1024*1024))