mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Format source code using latest black
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
207da610a0
commit
da85244a91
26 changed files with 112 additions and 129 deletions
|
@ -643,4 +643,4 @@ def _jittered_backoff(attempt, max_retry_delay):
|
|||
|
||||
salt myminion boto_kinesis._jittered_backoff current_attempt_number max_delay_in_seconds
|
||||
"""
|
||||
return min(random.random() * (2 ** attempt), max_retry_delay)
|
||||
return min(random.random() * (2**attempt), max_retry_delay)
|
||||
|
|
|
@ -280,7 +280,7 @@ def put(consul_url=None, token=None, key=None, value=None, **kwargs):
|
|||
_current = get(consul_url=consul_url, token=token, key=key)
|
||||
|
||||
if "flags" in kwargs:
|
||||
if kwargs["flags"] >= 0 and kwargs["flags"] <= 2 ** 64:
|
||||
if kwargs["flags"] >= 0 and kwargs["flags"] <= 2**64:
|
||||
query_params["flags"] = kwargs["flags"]
|
||||
|
||||
if "cas" in kwargs:
|
||||
|
|
|
@ -1631,20 +1631,17 @@ def init(
|
|||
run(name, "rm -f '{}'".format(SEED_MARKER), path=path, python_shell=False)
|
||||
gid = "/.lxc.initial_seed"
|
||||
gids = [gid, "/lxc.initial_seed"]
|
||||
if (
|
||||
any(
|
||||
retcode(
|
||||
name,
|
||||
"test -e {}".format(x),
|
||||
path=path,
|
||||
chroot_fallback=True,
|
||||
ignore_retcode=True,
|
||||
)
|
||||
== 0
|
||||
for x in gids
|
||||
if any(
|
||||
retcode(
|
||||
name,
|
||||
"test -e {}".format(x),
|
||||
path=path,
|
||||
chroot_fallback=True,
|
||||
ignore_retcode=True,
|
||||
)
|
||||
or not ret.get("result", True)
|
||||
):
|
||||
== 0
|
||||
for x in gids
|
||||
) or not ret.get("result", True):
|
||||
pass
|
||||
elif seed or seed_cmd:
|
||||
if seed:
|
||||
|
|
|
@ -407,7 +407,7 @@ def port_create_gre(br, port, id, remote):
|
|||
|
||||
salt '*' openvswitch.port_create_gre br0 gre1 5001 192.168.1.10
|
||||
"""
|
||||
if not 0 <= id < 2 ** 32:
|
||||
if not 0 <= id < 2**32:
|
||||
return False
|
||||
elif not __salt__["dig.check_ip"](remote):
|
||||
return False
|
||||
|
@ -451,7 +451,7 @@ def port_create_vxlan(br, port, id, remote, dst_port=None):
|
|||
salt '*' openvswitch.port_create_vxlan br0 vx1 5001 192.168.1.10 8472
|
||||
"""
|
||||
dst_port = " options:dst_port=" + str(dst_port) if 0 < dst_port <= 65535 else ""
|
||||
if not 0 <= id < 2 ** 64:
|
||||
if not 0 <= id < 2**64:
|
||||
return False
|
||||
elif not __salt__["dig.check_ip"](remote):
|
||||
return False
|
||||
|
|
|
@ -27,7 +27,6 @@ if not available:
|
|||
def _deserialize(stream_or_string, **options):
|
||||
_fail()
|
||||
|
||||
|
||||
elif salt.utils.msgpack.version >= (1, 0, 0):
|
||||
|
||||
def _serialize(obj, **options):
|
||||
|
@ -44,7 +43,6 @@ elif salt.utils.msgpack.version >= (1, 0, 0):
|
|||
except Exception as error: # pylint: disable=broad-except
|
||||
raise DeserializationError(error)
|
||||
|
||||
|
||||
elif salt.utils.msgpack.version >= (0, 2, 0):
|
||||
|
||||
def _serialize(obj, **options):
|
||||
|
@ -61,7 +59,6 @@ elif salt.utils.msgpack.version >= (0, 2, 0):
|
|||
except Exception as error: # pylint: disable=broad-except
|
||||
raise DeserializationError(error)
|
||||
|
||||
|
||||
else: # msgpack.version < 0.2.0
|
||||
|
||||
def _encoder(obj):
|
||||
|
|
|
@ -1576,12 +1576,13 @@ class _Swagger:
|
|||
ret["result"] = False
|
||||
ret["abort"] = True
|
||||
if "error" in update_model_schema_response:
|
||||
ret[
|
||||
"comment"
|
||||
] = "Failed to update existing model {} with schema {}, " "error: {}".format(
|
||||
model,
|
||||
_dict_to_json_pretty(schema),
|
||||
update_model_schema_response["error"]["message"],
|
||||
ret["comment"] = (
|
||||
"Failed to update existing model {} with schema {}, "
|
||||
"error: {}".format(
|
||||
model,
|
||||
_dict_to_json_pretty(schema),
|
||||
update_model_schema_response["error"]["message"],
|
||||
)
|
||||
)
|
||||
return ret
|
||||
|
||||
|
|
|
@ -1691,13 +1691,13 @@ def host_cache_configured(
|
|||
)
|
||||
)
|
||||
else:
|
||||
if (existing_datastore["capacity"] / 1024.0 ** 2) < swap_size_MiB:
|
||||
if (existing_datastore["capacity"] / 1024.0**2) < swap_size_MiB:
|
||||
|
||||
raise ArgumentValueError(
|
||||
"Capacity of host cache datastore '{}' ({} MiB) is "
|
||||
"smaller than the required swap size ({} MiB)".format(
|
||||
existing_datastore["name"],
|
||||
existing_datastore["capacity"] / 1024.0 ** 2,
|
||||
existing_datastore["capacity"] / 1024.0**2,
|
||||
swap_size_MiB,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -199,7 +199,7 @@ def present(
|
|||
def _check_gre():
|
||||
interface_options = __salt__["openvswitch.interface_get_options"](name)
|
||||
interface_type = __salt__["openvswitch.interface_get_type"](name)
|
||||
if not 0 <= id <= 2 ** 32:
|
||||
if not 0 <= id <= 2**32:
|
||||
ret["result"] = False
|
||||
ret["comment"] = comments["comment_gre_invalid_id"]
|
||||
elif not __salt__["dig.check_ip"](remote):
|
||||
|
@ -223,7 +223,7 @@ def present(
|
|||
def _check_vxlan():
|
||||
interface_options = __salt__["openvswitch.interface_get_options"](name)
|
||||
interface_type = __salt__["openvswitch.interface_get_type"](name)
|
||||
if not 0 <= id <= 2 ** 64:
|
||||
if not 0 <= id <= 2**64:
|
||||
ret["result"] = False
|
||||
ret["comment"] = comments["comment_vxlan_invalid_id"]
|
||||
elif not __salt__["dig.check_ip"](remote):
|
||||
|
|
|
@ -734,11 +734,12 @@ def export(name, path, replace=False):
|
|||
if __salt__["file.file_exists"](cfg_tmp):
|
||||
__salt__["file.remove"](cfg_tmp)
|
||||
ret["result"] = False
|
||||
ret[
|
||||
"comment"
|
||||
] = "Unable to be re-export zone configuration for {}" " to {}!".format(
|
||||
name,
|
||||
path,
|
||||
ret["comment"] = (
|
||||
"Unable to be re-export zone configuration for {}"
|
||||
" to {}!".format(
|
||||
name,
|
||||
path,
|
||||
)
|
||||
)
|
||||
else:
|
||||
ret["result"] = True
|
||||
|
|
|
@ -122,7 +122,7 @@ async def test_send_many(channel):
|
|||
|
||||
|
||||
async def test_very_big_message(channel):
|
||||
long_str = "".join([str(num) for num in range(10 ** 5)])
|
||||
long_str = "".join([str(num) for num in range(10**5)])
|
||||
msg = {"long_str": long_str, "stop": True}
|
||||
await channel.send(msg)
|
||||
assert channel.payloads[0] == msg
|
||||
|
|
|
@ -90,20 +90,17 @@ def test_add():
|
|||
mock = MagicMock(return_value=True)
|
||||
with patch.dict(beacons.__salt__, {"event.fire": mock}):
|
||||
with patch.object(SaltEvent, "get_event", side_effect=event_returns):
|
||||
assert (
|
||||
beacons.add(
|
||||
"ps",
|
||||
[
|
||||
{
|
||||
"processes": {
|
||||
"salt-master": "stopped",
|
||||
"apache2": "stopped",
|
||||
}
|
||||
assert beacons.add(
|
||||
"ps",
|
||||
[
|
||||
{
|
||||
"processes": {
|
||||
"salt-master": "stopped",
|
||||
"apache2": "stopped",
|
||||
}
|
||||
],
|
||||
)
|
||||
== {"comment": comm1, "result": True}
|
||||
)
|
||||
}
|
||||
],
|
||||
) == {"comment": comm1, "result": True}
|
||||
|
||||
|
||||
@pytest.mark.slow_test
|
||||
|
@ -241,16 +238,13 @@ def test_add_beacon_module():
|
|||
mock = MagicMock(return_value=True)
|
||||
with patch.dict(beacons.__salt__, {"event.fire": mock}):
|
||||
with patch.object(SaltEvent, "get_event", side_effect=event_returns):
|
||||
assert (
|
||||
beacons.add(
|
||||
"watch_salt_master",
|
||||
[
|
||||
{"processes": {"salt-master": "stopped"}},
|
||||
{"beacon_module": "ps"},
|
||||
],
|
||||
)
|
||||
== {"comment": comm1, "result": True}
|
||||
)
|
||||
assert beacons.add(
|
||||
"watch_salt_master",
|
||||
[
|
||||
{"processes": {"salt-master": "stopped"}},
|
||||
{"beacon_module": "ps"},
|
||||
],
|
||||
) == {"comment": comm1, "result": True}
|
||||
|
||||
|
||||
@pytest.mark.slow_test
|
||||
|
|
|
@ -1354,7 +1354,7 @@ def test_update_add_cpu_topology(make_mock_vm):
|
|||
assert setxml.find("./cpu/feature[@name='lahf']").get("policy") == "optional"
|
||||
|
||||
assert setxml.find("./cpu/numa/cell/[@id='0']").get("cpus") == "0,1,2,3"
|
||||
assert setxml.find("./cpu/numa/cell/[@id='0']").get("memory") == str(1024 ** 3)
|
||||
assert setxml.find("./cpu/numa/cell/[@id='0']").get("memory") == str(1024**3)
|
||||
assert setxml.find("./cpu/numa/cell/[@id='0']").get("unit") == "bytes"
|
||||
assert setxml.find("./cpu/numa/cell/[@id='0']").get("discard") == "yes"
|
||||
assert (
|
||||
|
@ -1383,7 +1383,7 @@ def test_update_add_cpu_topology(make_mock_vm):
|
|||
)
|
||||
assert setxml.find("./cpu/numa/cell/[@id='1']").get("cpus") == "4,5,6"
|
||||
assert setxml.find("./cpu/numa/cell/[@id='1']").get("memory") == str(
|
||||
int(1024 ** 3 / 2)
|
||||
int(1024**3 / 2)
|
||||
)
|
||||
assert setxml.find("./cpu/numa/cell/[@id='1']").get("unit") == "bytes"
|
||||
assert setxml.find("./cpu/numa/cell/[@id='1']").get("discard") == "no"
|
||||
|
@ -1571,10 +1571,10 @@ def test_update_add_memtune(make_mock_vm):
|
|||
|
||||
assert ret["definition"]
|
||||
setxml = ET.fromstring(virt.libvirt.openAuth().defineXML.call_args[0][0])
|
||||
assert_equal_unit(setxml.find("memtune/soft_limit"), int(0.5 * 1024 ** 3), "bytes")
|
||||
assert_equal_unit(setxml.find("memtune/hard_limit"), 1024 * 1024 ** 2, "bytes")
|
||||
assert_equal_unit(setxml.find("memtune/swap_hard_limit"), 2048 * 1024 ** 2, "bytes")
|
||||
assert_equal_unit(setxml.find("memtune/min_guarantee"), 1 * 1024 ** 3, "bytes")
|
||||
assert_equal_unit(setxml.find("memtune/soft_limit"), int(0.5 * 1024**3), "bytes")
|
||||
assert_equal_unit(setxml.find("memtune/hard_limit"), 1024 * 1024**2, "bytes")
|
||||
assert_equal_unit(setxml.find("memtune/swap_hard_limit"), 2048 * 1024**2, "bytes")
|
||||
assert_equal_unit(setxml.find("memtune/min_guarantee"), 1 * 1024**3, "bytes")
|
||||
|
||||
|
||||
def test_update_add_memtune_invalid_unit(make_mock_vm):
|
||||
|
@ -1625,7 +1625,7 @@ def test_update_mem_simple(make_mock_vm):
|
|||
assert ret["definition"]
|
||||
assert ret["mem"]
|
||||
setxml = ET.fromstring(virt.libvirt.openAuth().defineXML.call_args[0][0])
|
||||
assert setxml.find("memory").text == str(2048 * 1024 ** 2)
|
||||
assert setxml.find("memory").text == str(2048 * 1024**2)
|
||||
assert setxml.find("memory").get("unit") == "bytes"
|
||||
assert domain_mock.setMemoryFlags.call_args[0][0] == 2048 * 1024
|
||||
|
||||
|
@ -1644,9 +1644,9 @@ def test_update_mem(make_mock_vm):
|
|||
assert ret["mem"]
|
||||
setxml = ET.fromstring(virt.libvirt.openAuth().defineXML.call_args[0][0])
|
||||
assert setxml.find("memory").get("unit") == "bytes"
|
||||
assert setxml.find("memory").text == str(int(0.5 * 1024 ** 3))
|
||||
assert setxml.find("maxMemory").text == str(1 * 1024 ** 3)
|
||||
assert setxml.find("currentMemory").text == str(2 * 1024 ** 3)
|
||||
assert setxml.find("memory").text == str(int(0.5 * 1024**3))
|
||||
assert setxml.find("maxMemory").text == str(1 * 1024**3)
|
||||
assert setxml.find("currentMemory").text == str(2 * 1024**3)
|
||||
|
||||
|
||||
def test_update_add_mem_backing(make_mock_vm):
|
||||
|
@ -1676,8 +1676,8 @@ def test_update_add_mem_backing(make_mock_vm):
|
|||
p.get("nodeset"): {"size": p.get("size"), "unit": p.get("unit")}
|
||||
for p in setxml.findall("memoryBacking/hugepages/page")
|
||||
} == {
|
||||
"1,2,3,5": {"size": str(1024 ** 3), "unit": "bytes"},
|
||||
"4": {"size": str(2 * 1024 ** 3), "unit": "bytes"},
|
||||
"1,2,3,5": {"size": str(1024**3), "unit": "bytes"},
|
||||
"4": {"size": str(2 * 1024**3), "unit": "bytes"},
|
||||
}
|
||||
assert setxml.find("./memoryBacking/nosharepages") is not None
|
||||
assert setxml.find("./memoryBacking/nosharepages").text is None
|
||||
|
|
|
@ -60,7 +60,7 @@ def test_jinja_undefined_error_context(minion_opts, local_salt):
|
|||
# exception was raised is to match on the initial wording of the exception
|
||||
# message.
|
||||
match_regex = re.compile(
|
||||
fr"^Jinja variable .*; line .*{marker}$", re.DOTALL | re.MULTILINE
|
||||
rf"^Jinja variable .*; line .*{marker}$", re.DOTALL | re.MULTILINE
|
||||
)
|
||||
with pytest.raises(SaltRenderError, match=match_regex):
|
||||
render_jinja_tmpl(
|
||||
|
|
|
@ -722,14 +722,14 @@ def test_human_to_bytes(unit):
|
|||
# second multiplier is metric/decimal
|
||||
conversion = {
|
||||
"B": (1, 1),
|
||||
"K": (2 ** 10, 10 ** 3),
|
||||
"M": (2 ** 20, 10 ** 6),
|
||||
"G": (2 ** 30, 10 ** 9),
|
||||
"T": (2 ** 40, 10 ** 12),
|
||||
"P": (2 ** 50, 10 ** 15),
|
||||
"E": (2 ** 60, 10 ** 18),
|
||||
"Z": (2 ** 70, 10 ** 21),
|
||||
"Y": (2 ** 80, 10 ** 24),
|
||||
"K": (2**10, 10**3),
|
||||
"M": (2**20, 10**6),
|
||||
"G": (2**30, 10**9),
|
||||
"T": (2**40, 10**12),
|
||||
"P": (2**50, 10**15),
|
||||
"E": (2**60, 10**18),
|
||||
"Z": (2**70, 10**21),
|
||||
"Y": (2**80, 10**24),
|
||||
}
|
||||
|
||||
idx = 0
|
||||
|
@ -774,7 +774,7 @@ def test_human_to_bytes_edge_cases():
|
|||
# no unit - bytes
|
||||
assert salt.utils.stringutils.human_to_bytes("32") == 32
|
||||
# no unit - default MB
|
||||
assert salt.utils.stringutils.human_to_bytes("32", default_unit="M") == 32 * 2 ** 20
|
||||
assert salt.utils.stringutils.human_to_bytes("32", default_unit="M") == 32 * 2**20
|
||||
# bad value
|
||||
assert salt.utils.stringutils.human_to_bytes("32-1") == 0
|
||||
assert salt.utils.stringutils.human_to_bytes("3.4.MB") == 0
|
||||
|
|
|
@ -14,7 +14,6 @@ try:
|
|||
class WinError(win32net.error):
|
||||
winerror = 0
|
||||
|
||||
|
||||
except ImportError:
|
||||
HAS_WIN32 = False
|
||||
|
||||
|
@ -26,7 +25,6 @@ try:
|
|||
class PyWinError(pywintypes.error):
|
||||
pywinerror = 0
|
||||
|
||||
|
||||
except ImportError:
|
||||
HAS_PYWIN = False
|
||||
|
||||
|
|
|
@ -265,7 +265,7 @@ def flaky(caller=None, condition=True, attempts=4):
|
|||
teardown = getattr(cls, "tearDown", None)
|
||||
if callable(teardown):
|
||||
teardown()
|
||||
backoff_time = attempt ** 2
|
||||
backoff_time = attempt**2
|
||||
log.info("Found Exception. Waiting %s seconds to retry.", backoff_time)
|
||||
time.sleep(backoff_time)
|
||||
return cls
|
||||
|
|
|
@ -735,7 +735,7 @@ class EntropyGenerator:
|
|||
"-out",
|
||||
target_file.name,
|
||||
"-base64",
|
||||
str(int(2 ** 30 * 3 / 4)), # 1GB
|
||||
str(int(2**30 * 3 / 4)), # 1GB
|
||||
],
|
||||
shell=False,
|
||||
check=True,
|
||||
|
|
|
@ -89,7 +89,6 @@ try:
|
|||
self.stream.writeln("Finished generating XML reports")
|
||||
return result
|
||||
|
||||
|
||||
except ImportError:
|
||||
HAS_XMLRUNNER = False
|
||||
|
||||
|
|
|
@ -174,8 +174,8 @@ class CommonTestMixin_v4(CommonTestMixin):
|
|||
|
||||
def test_large_ints_rejected(self):
|
||||
msg = "%d (>= 2**32) is not permitted as an IPv4 address"
|
||||
with self.assertAddressError(re.escape(msg % 2 ** 32)):
|
||||
self.factory(2 ** 32)
|
||||
with self.assertAddressError(re.escape(msg % 2**32)):
|
||||
self.factory(2**32)
|
||||
|
||||
def test_bad_packed_length(self):
|
||||
def assertBadLength(length):
|
||||
|
@ -213,8 +213,8 @@ class CommonTestMixin_v6(CommonTestMixin):
|
|||
|
||||
def test_large_ints_rejected(self):
|
||||
msg = "%d (>= 2**128) is not permitted as an IPv6 address"
|
||||
with self.assertAddressError(re.escape(msg % 2 ** 128)):
|
||||
self.factory(2 ** 128)
|
||||
with self.assertAddressError(re.escape(msg % 2**128)):
|
||||
self.factory(2**128)
|
||||
|
||||
def test_bad_packed_length(self):
|
||||
def assertBadLength(length):
|
||||
|
@ -1275,30 +1275,30 @@ class IpaddrUnitTest(TestCase):
|
|||
ipaddress.IPv4Address("1.1.1.1") - 256, ipaddress.IPv4Address("1.1.0.1")
|
||||
)
|
||||
self.assertEqual(
|
||||
ipaddress.IPv6Address("::1") + (2 ** 16 - 2),
|
||||
ipaddress.IPv6Address("::1") + (2**16 - 2),
|
||||
ipaddress.IPv6Address("::ffff"),
|
||||
)
|
||||
self.assertEqual(
|
||||
ipaddress.IPv6Address("::ffff") - (2 ** 16 - 2),
|
||||
ipaddress.IPv6Address("::ffff") - (2**16 - 2),
|
||||
ipaddress.IPv6Address("::1"),
|
||||
)
|
||||
self.assertNotEqual(
|
||||
ipaddress.IPv6Address("::1%scope") + (2 ** 16 - 2),
|
||||
ipaddress.IPv6Address("::1%scope") + (2**16 - 2),
|
||||
ipaddress.IPv6Address("::ffff%scope"),
|
||||
)
|
||||
self.assertNotEqual(
|
||||
ipaddress.IPv6Address("::ffff%scope") - (2 ** 16 - 2),
|
||||
ipaddress.IPv6Address("::ffff%scope") - (2**16 - 2),
|
||||
ipaddress.IPv6Address("::1%scope"),
|
||||
)
|
||||
|
||||
def testInvalidIntToBytes(self):
|
||||
self.assertRaises(ValueError, ipaddress.v4_int_to_packed, -1)
|
||||
self.assertRaises(
|
||||
ValueError, ipaddress.v4_int_to_packed, 2 ** ipaddress.IPV4LENGTH
|
||||
ValueError, ipaddress.v4_int_to_packed, 2**ipaddress.IPV4LENGTH
|
||||
)
|
||||
self.assertRaises(ValueError, ipaddress.v6_int_to_packed, -1)
|
||||
self.assertRaises(
|
||||
ValueError, ipaddress.v6_int_to_packed, 2 ** ipaddress.IPV6LENGTH
|
||||
ValueError, ipaddress.v6_int_to_packed, 2**ipaddress.IPV6LENGTH
|
||||
)
|
||||
|
||||
def testInternals(self):
|
||||
|
@ -2462,7 +2462,7 @@ class IpaddrUnitTest(TestCase):
|
|||
def testReservedIpv6(self):
|
||||
|
||||
self.assertEqual(True, ipaddress.ip_network("ffff::").is_multicast)
|
||||
self.assertEqual(True, ipaddress.ip_network(2 ** 128 - 1).is_multicast)
|
||||
self.assertEqual(True, ipaddress.ip_network(2**128 - 1).is_multicast)
|
||||
self.assertEqual(True, ipaddress.ip_network("ff00::").is_multicast)
|
||||
self.assertEqual(False, ipaddress.ip_network("fdff::").is_multicast)
|
||||
|
||||
|
@ -2496,7 +2496,7 @@ class IpaddrUnitTest(TestCase):
|
|||
self.assertEqual(True, ipaddress.ip_network("200::1/128").is_global)
|
||||
# test addresses
|
||||
self.assertEqual(True, ipaddress.ip_address("ffff::").is_multicast)
|
||||
self.assertEqual(True, ipaddress.ip_address(2 ** 128 - 1).is_multicast)
|
||||
self.assertEqual(True, ipaddress.ip_address(2**128 - 1).is_multicast)
|
||||
self.assertEqual(True, ipaddress.ip_address("ff00::").is_multicast)
|
||||
self.assertEqual(False, ipaddress.ip_address("fdff::").is_multicast)
|
||||
|
||||
|
@ -2603,7 +2603,7 @@ class IpaddrUnitTest(TestCase):
|
|||
net = self.ipv4_network
|
||||
self.assertEqual("1.2.3.0/24", net.compressed)
|
||||
net = self.ipv6_network
|
||||
self.assertRaises(ValueError, net._string_from_ip_int, 2 ** 128 + 1)
|
||||
self.assertRaises(ValueError, net._string_from_ip_int, 2**128 + 1)
|
||||
|
||||
def testIPv6NetworkHelpers(self):
|
||||
net = self.ipv6_network
|
||||
|
|
|
@ -69,7 +69,7 @@ boto_conn_parameters = {
|
|||
|
||||
|
||||
def _random_group_id():
|
||||
group_id = "sg-{:x}".format(random.randrange(2 ** 32))
|
||||
group_id = "sg-{:x}".format(random.randrange(2**32))
|
||||
return group_id
|
||||
|
||||
|
||||
|
|
|
@ -194,7 +194,6 @@ if HAS_LIBCLOUD:
|
|||
assert key_pair.name == "test_key"
|
||||
return True
|
||||
|
||||
|
||||
else:
|
||||
MockComputeDriver = object
|
||||
|
||||
|
|
|
@ -77,7 +77,6 @@ if HAS_LIBCLOUD:
|
|||
assert balancer.id == "test_id"
|
||||
return [self._TEST_MEMBER]
|
||||
|
||||
|
||||
else:
|
||||
MockLBDriver = object
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ if HAS_LIBCLOUD:
|
|||
assert object_name == "test_obj"
|
||||
return self._TEST_OBJECT
|
||||
|
||||
|
||||
else:
|
||||
MockStorageDriver = object
|
||||
|
||||
|
|
|
@ -562,7 +562,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
self.assertFalse("slots" in root.find("maxMemory").keys())
|
||||
self.assert_equal_unit(root.find("memtune/hard_limit"), 1024 * 1024)
|
||||
self.assert_equal_unit(root.find("memtune/soft_limit"), 512 * 1024)
|
||||
self.assert_equal_unit(root.find("memtune/swap_hard_limit"), 1024 ** 2)
|
||||
self.assert_equal_unit(root.find("memtune/swap_hard_limit"), 1024**2)
|
||||
self.assert_equal_unit(root.find("memtune/min_guarantee"), 256 * 1024)
|
||||
self.assertEqual(
|
||||
[
|
||||
|
@ -705,7 +705,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
cell0 = root.find("cpu/numa/cell[@id='0']")
|
||||
self.assertEqual(cell0.get("cpus"), "0-3")
|
||||
self.assertIsNone(cell0.get("unit"))
|
||||
self.assertEqual(cell0.get("memory"), str(1024 ** 2))
|
||||
self.assertEqual(cell0.get("memory"), str(1024**2))
|
||||
self.assertEqual(cell0.get("discard"), "yes")
|
||||
self.assertEqual(
|
||||
{d.get("id"): d.get("value") for d in cell0.findall("distances/sibling")},
|
||||
|
@ -715,7 +715,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
cell1 = root.find("cpu/numa/cell[@id='1']")
|
||||
self.assertEqual(cell1.get("cpus"), "4-7")
|
||||
self.assertIsNone(cell0.get("unit"))
|
||||
self.assertEqual(cell1.get("memory"), str(2 * 1024 ** 2))
|
||||
self.assertEqual(cell1.get("memory"), str(2 * 1024**2))
|
||||
self.assertFalse("discard" in cell1.keys())
|
||||
self.assertEqual(
|
||||
{d.get("id"): d.get("value") for d in cell1.findall("distances/sibling")},
|
||||
|
@ -3253,7 +3253,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
)
|
||||
self.assertEqual(
|
||||
setxml.find("./cpu/numa/cell/[@id='0']").attrib["memory"],
|
||||
str(512 * 1024 ** 2),
|
||||
str(512 * 1024**2),
|
||||
)
|
||||
self.assertEqual(
|
||||
setxml.find("./cpu/numa/cell/[@id='0']").get("unit"),
|
||||
|
@ -3292,7 +3292,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
)
|
||||
self.assertEqual(
|
||||
setxml.find("./cpu/numa/cell/[@id='1']").attrib["memory"],
|
||||
str(int(2 * 1024 ** 3)),
|
||||
str(int(2 * 1024**3)),
|
||||
)
|
||||
self.assertEqual(
|
||||
setxml.find("./cpu/numa/cell/[@id='1']").get("unit"),
|
||||
|
@ -3360,7 +3360,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
)
|
||||
self.assertEqual(
|
||||
setxml.find("./cpu/numa/cell/[@id='0']").attrib["memory"],
|
||||
str(512 * 1024 ** 2),
|
||||
str(512 * 1024**2),
|
||||
)
|
||||
self.assertEqual(
|
||||
setxml.find("./cpu/numa/cell/[@id='0']").get("unit"),
|
||||
|
@ -3396,7 +3396,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
)
|
||||
self.assertEqual(
|
||||
setxml.find("./cpu/numa/cell/[@id='1']").attrib["memory"],
|
||||
str(int(2 * 1024 ** 3)),
|
||||
str(int(2 * 1024**3)),
|
||||
)
|
||||
self.assertEqual(
|
||||
setxml.find("./cpu/numa/cell/[@id='1']").attrib["discard"], "yes"
|
||||
|
@ -3429,7 +3429,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
)
|
||||
self.assertEqual(
|
||||
setxml.find("./cpu/numa/cell/[@id='1']").attrib["memory"],
|
||||
str(int(1024 ** 3 * 2)),
|
||||
str(int(1024**3 * 2)),
|
||||
)
|
||||
self.assertEqual(
|
||||
setxml.find("./cpu/numa/cell/[@id='1']").attrib["discard"], "yes"
|
||||
|
@ -3506,7 +3506,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
virt.update("vm_with_memtune_param", mem=memtune_new_val),
|
||||
)
|
||||
self.assertEqual(
|
||||
domain_mock.setMemoryFlags.call_args[0][0], int(2.5 * 1024 ** 2)
|
||||
domain_mock.setMemoryFlags.call_args[0][0], int(2.5 * 1024**2)
|
||||
)
|
||||
|
||||
setxml = ET.fromstring(define_mock.call_args[0][0])
|
||||
|
@ -3518,22 +3518,22 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
)
|
||||
self.assertEqual(
|
||||
setxml.find("memtune").find("swap_hard_limit").text,
|
||||
str(int(2.5 * 1024 ** 2)),
|
||||
str(int(2.5 * 1024**2)),
|
||||
)
|
||||
self.assertEqual(
|
||||
setxml.find("memtune").find("swap_hard_limit").get("unit"),
|
||||
"KiB",
|
||||
)
|
||||
self.assertEqual(
|
||||
setxml.find("memtune").find("min_guarantee").text, str(1 * 1024 ** 3)
|
||||
setxml.find("memtune").find("min_guarantee").text, str(1 * 1024**3)
|
||||
)
|
||||
self.assertEqual(
|
||||
setxml.find("memtune").find("min_guarantee").attrib.get("unit"), "bytes"
|
||||
)
|
||||
self.assertEqual(setxml.find("maxMemory").text, str(3096 * 1024 ** 2))
|
||||
self.assertEqual(setxml.find("maxMemory").text, str(3096 * 1024**2))
|
||||
self.assertEqual(setxml.find("maxMemory").attrib.get("slots"), "10")
|
||||
self.assertEqual(setxml.find("currentMemory").text, str(int(2.5 * 1024 ** 3)))
|
||||
self.assertEqual(setxml.find("memory").text, str(int(0.7 * 1024 ** 3)))
|
||||
self.assertEqual(setxml.find("currentMemory").text, str(int(2.5 * 1024**3)))
|
||||
self.assertEqual(setxml.find("memory").text, str(int(0.7 * 1024**3)))
|
||||
|
||||
max_slot_reverse = {
|
||||
"slots": "10",
|
||||
|
@ -3548,7 +3548,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
virt.update("vm_with_memtune_param", mem=max_slot_reverse),
|
||||
)
|
||||
setxml = ET.fromstring(define_mock.call_args[0][0])
|
||||
self.assertEqual(setxml.find("maxMemory").text, str(3096 * 1024 ** 2))
|
||||
self.assertEqual(setxml.find("maxMemory").text, str(3096 * 1024**2))
|
||||
self.assertEqual(setxml.find("maxMemory").get("unit"), "bytes")
|
||||
self.assertEqual(setxml.find("maxMemory").attrib.get("slots"), "10")
|
||||
|
||||
|
@ -3574,7 +3574,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
virt.update("vm_with_memtune_param", mem=max_swap_none),
|
||||
)
|
||||
self.assertEqual(
|
||||
domain_mock.setMemoryFlags.call_args[0][0], int(2.5 * 1024 ** 2)
|
||||
domain_mock.setMemoryFlags.call_args[0][0], int(2.5 * 1024**2)
|
||||
)
|
||||
|
||||
setxml = ET.fromstring(define_mock.call_args[0][0])
|
||||
|
@ -3586,14 +3586,14 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
)
|
||||
self.assertEqual(setxml.find("memtune").find("swap_hard_limit"), None)
|
||||
self.assertEqual(
|
||||
setxml.find("memtune").find("min_guarantee").text, str(1 * 1024 ** 3)
|
||||
setxml.find("memtune").find("min_guarantee").text, str(1 * 1024**3)
|
||||
)
|
||||
self.assertEqual(
|
||||
setxml.find("memtune").find("min_guarantee").attrib.get("unit"), "bytes"
|
||||
)
|
||||
self.assertEqual(setxml.find("maxMemory").text, None)
|
||||
self.assertEqual(setxml.find("currentMemory").text, str(int(2.5 * 1024 ** 3)))
|
||||
self.assertEqual(setxml.find("memory").text, str(int(0.7 * 1024 ** 3)))
|
||||
self.assertEqual(setxml.find("currentMemory").text, str(int(2.5 * 1024**3)))
|
||||
self.assertEqual(setxml.find("memory").text, str(int(0.7 * 1024**3)))
|
||||
|
||||
memtune_none = {
|
||||
"soft_limit": None,
|
||||
|
@ -3632,8 +3632,8 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
|
||||
setxml = ET.fromstring(define_mock.call_args[0][0])
|
||||
self.assertEqual(setxml.find("maxMemory"), None)
|
||||
self.assertEqual(setxml.find("currentMemory").text, str(int(1 * 1024 ** 2)))
|
||||
self.assertEqual(setxml.find("memory").text, str(int(1 * 1024 ** 2)))
|
||||
self.assertEqual(setxml.find("currentMemory").text, str(int(1 * 1024**2)))
|
||||
self.assertEqual(setxml.find("memory").text, str(int(1 * 1024**2)))
|
||||
|
||||
def test_update_exist_memorybacking_params(self):
|
||||
"""
|
||||
|
@ -3698,8 +3698,8 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|||
for p in setxml.findall("memoryBacking/hugepages/page")
|
||||
},
|
||||
{
|
||||
"1,2,4": {"size": str(1024 ** 3), "unit": "bytes"},
|
||||
"3": {"size": str(2 * 1024 ** 3), "unit": "bytes"},
|
||||
"1,2,4": {"size": str(1024**3), "unit": "bytes"},
|
||||
"3": {"size": str(2 * 1024**3), "unit": "bytes"},
|
||||
},
|
||||
)
|
||||
self.assertEqual(setxml.find("./memoryBacking/nosharepages"), None)
|
||||
|
|
|
@ -255,7 +255,7 @@ class TestFind(TestCase):
|
|||
self.assertEqual(option.match("", "", [1] * 9), False)
|
||||
|
||||
option = salt.utils.find.MtimeOption("mtime", "-1s")
|
||||
self.assertEqual(option.match("", "", [10 ** 10] * 9), True)
|
||||
self.assertEqual(option.match("", "", [10**10] * 9), True)
|
||||
|
||||
|
||||
class TestGrepOption(TestCase):
|
||||
|
@ -376,7 +376,7 @@ class TestPrintOption(TestCase):
|
|||
self.assertEqual(option.execute("", [0] * 10), "root")
|
||||
|
||||
option = salt.utils.find.PrintOption("print", "user")
|
||||
self.assertEqual(option.execute("", [2 ** 31] * 10), 2 ** 31)
|
||||
self.assertEqual(option.execute("", [2**31] * 10), 2**31)
|
||||
|
||||
@skipIf(sys.platform.startswith("win"), "grp not available on Windows")
|
||||
def test_print_group(self):
|
||||
|
|
|
@ -11,7 +11,6 @@ try:
|
|||
class WinError(win32net.error):
|
||||
winerror = 0
|
||||
|
||||
|
||||
except ImportError:
|
||||
HAS_WIN32 = False
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue