mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Rename "remove" argument to "clean"
This commit is contained in:
parent
7fd3bcea47
commit
e4946f9cec
2 changed files with 10 additions and 10 deletions
|
@ -67,7 +67,7 @@ from salt.ext import six
|
|||
import salt.utils.validate.net
|
||||
|
||||
|
||||
def present(name, ip, remove=False): # pylint: disable=C0103
|
||||
def present(name, ip, clean=False): # pylint: disable=C0103
|
||||
'''
|
||||
Ensures that the named host is present with the given ip
|
||||
|
||||
|
@ -78,7 +78,7 @@ def present(name, ip, remove=False): # pylint: disable=C0103
|
|||
The ip addr(s) to apply to the host. Can be a single IP or a list of IP
|
||||
addresses.
|
||||
|
||||
remove : False
|
||||
clean : False
|
||||
Remove any entries which don't match those configured in the ``ip``
|
||||
option.
|
||||
|
||||
|
@ -107,12 +107,12 @@ def present(name, ip, remove=False): # pylint: disable=C0103
|
|||
if name in aliases:
|
||||
# Found match for hostname, but the corresponding IP is not in
|
||||
# our list, so we need to remove it.
|
||||
if remove:
|
||||
if clean:
|
||||
to_remove.add((addr, name))
|
||||
else:
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Host {0} present for IP address {1}. To get rid of '
|
||||
'this warning, either run this state with \'remove\' '
|
||||
'this warning, either run this state with \'clean\' '
|
||||
'set to True to remove {0} from {1}, or add {1} to '
|
||||
'the \'ip\' argument.'.format(name, addr)
|
||||
)
|
||||
|
|
|
@ -114,14 +114,14 @@ class HostTestCase(TestCase, LoaderModuleMockMixin):
|
|||
assert add_host.mock_calls == expected, add_host.mock_calls
|
||||
assert rm_host.mock_calls == [], rm_host.mock_calls
|
||||
|
||||
# Case 3a: Repeat the above with remove=True
|
||||
# Case 3a: Repeat the above with clean=True
|
||||
add_host.reset_mock()
|
||||
rm_host.reset_mock()
|
||||
with patch.dict(host.__salt__,
|
||||
{'hosts.list_hosts': list_hosts,
|
||||
'hosts.add_host': add_host,
|
||||
'hosts.rm_host': rm_host}):
|
||||
ret = host.present(hostname, ip_str, remove=True)
|
||||
ret = host.present(hostname, ip_str, clean=True)
|
||||
assert ret['result'] is True
|
||||
assert 'Added host {0} ({1})'.format(hostname, ip_str) in ret['comment']
|
||||
assert 'Removed host {0} ({1})'.format(hostname, ip_list[0]) in ret['comment']
|
||||
|
@ -165,14 +165,14 @@ class HostTestCase(TestCase, LoaderModuleMockMixin):
|
|||
assert sorted(add_host.mock_calls) == expected, add_host.mock_calls
|
||||
assert rm_host.mock_calls == [], rm_host.mock_calls
|
||||
|
||||
# Case 4a: Repeat the above with remove=True
|
||||
# Case 4a: Repeat the above with clean=True
|
||||
add_host.reset_mock()
|
||||
rm_host.reset_mock()
|
||||
with patch.dict(host.__salt__,
|
||||
{'hosts.list_hosts': list_hosts,
|
||||
'hosts.add_host': add_host,
|
||||
'hosts.rm_host': rm_host}):
|
||||
ret = host.present(hostname, ip_list, remove=True)
|
||||
ret = host.present(hostname, ip_list, clean=True)
|
||||
assert ret['result'] is True
|
||||
assert 'Added host {0} ({1})'.format(hostname, ip_list[0]) in ret['comment']
|
||||
assert 'Added host {0} ({1})'.format(hostname, ip_list[1]) in ret['comment']
|
||||
|
@ -218,14 +218,14 @@ class HostTestCase(TestCase, LoaderModuleMockMixin):
|
|||
assert add_host.mock_calls == expected, add_host.mock_calls
|
||||
assert rm_host.mock_calls == [], rm_host.mock_calls
|
||||
|
||||
# Case 5a: Repeat the above with remove=True
|
||||
# Case 5a: Repeat the above with clean=True
|
||||
add_host.reset_mock()
|
||||
rm_host.reset_mock()
|
||||
with patch.dict(host.__salt__,
|
||||
{'hosts.list_hosts': list_hosts,
|
||||
'hosts.add_host': add_host,
|
||||
'hosts.rm_host': rm_host}):
|
||||
ret = host.present(hostname, ip_list, remove=True)
|
||||
ret = host.present(hostname, ip_list, clean=True)
|
||||
assert ret['result'] is True
|
||||
assert 'Added host {0} ({1})'.format(hostname, ip_list[1]) in ret['comment']
|
||||
assert 'Removed host {0} ({1})'.format(hostname, cur_ip) in ret['comment']
|
||||
|
|
Loading…
Add table
Reference in a new issue