Move salt.utils.network.valid_ipv4()

This is a better fit in salt.utils.validate.net, so it has been moved to
salt.utils.validate.net.ipv4_addr().
Merge pull request #9645 from s0undt3ch/0.17

Move salt.utils.network.valid_ipv4()
Allow '_in' requisites to match both on ID and name

Under the hood, all '_in' requisites are changed to extends of their
corresponding type. For example, a require_in for a given state extends
the target of the require_in with a 'require' requisite, pointing back
at the state where the require_in was located.

When these extends are reconciled, only the ID declarations are examined
to see if there is a state matching the requisite's target, meaning that
these '_in' requisites cannot point to a 'name' override in the same way
as their counterparts are able to. For more info, see
https://github.com/saltstack/salt/issues/9061.

This commit modifies the extend reconciliation behavior. If there is no
ID declaration matching the requisite's target, then
salt.state.find_name() is used to search the high data for an ID
declaration with a 'name' param matching the requisite target. If a
match is found, then the extend is reconciled against that matching ID.
If no match is found, then the requisite is not found the appropriate
error is returned.
Compensate for time spent waiting for events
Fix issue #7157
Restore event subscription
Increase master timeout during tests now that it is not incorrectly incrementing
Quiet the logstash handler loading message

@s0undt3ch FYI.  If you think this is a bad change, I'd be happy to
discuss it with you, but 99% of salt users don't use that handler (as
far as I know) and it's just garbage in the debug log.
Do not waste CPU cycles on stat(2) on each _auth

Currently servers that handle many thousands of minions spend measurable time
doing only stat(2) calls.

In strace it looks like::

     0.000093 stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=118, ...}) = 0
     0.000236 open("/etc/salt/pki/master/minions", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 154
     0.011412 stat("/etc/salt/pki/master/minions/hostXXXX.linkedin.com", {st_mode=S_IFREG|0644, st_size=800, ...}) = 0
     0.000102 stat("/etc/salt/pki/master/minions/hostXXXX.linkedin.com", {st_mode=S_IFREG|0644, st_size=800, ...}) = 0
     ...many thousands lines...
     0.000064 stat("/etc/salt/pki/master/minions/hostXXXX.linkedin.com", {st_mode=S_IFREG|0644, st_size=800, ...}) = 0
     0.000062 stat("/etc/salt/pki/master/minions/hostXXXX.linkedin.com", {st_mode=S_IFREG|0644, st_size=796, ...}) = 0
     0.000485 stat("/export/apps/salt/log/master", {st_mode=S_IFREG|0644, st_size=37769598988, ...}) = 0
     0.000065 stat("/export/apps/salt/log/master", {st_mode=S_IFREG|0644, st_size=37769598988, ...}) = 0
     0.000184 stat("/etc/salt/pki/master/minions_rejected/hostXXXX.linkedin.com", 0x7fff28209f40) = -1 ENOENT (No such file or directory)
     0.000071 stat("/etc/salt/pki/master/minions/hostXXXX.linkedin.com", {st_mode=S_IFREG|0644, st_size=800, ...}) = 0
     0.000074 open("/etc/salt/pki/master/minions/hostXXXX.linkedin.com", O_RDONLY) = 154

Happens that on each _auth() call salt is counting files in pki/master/minions
and checks whenever those are regular files by applying os.path.isfile()
function to each which considerably slows things down.

This patch removes isfile() call that effectively makes check_max_open_files()
check less precise (but since it's already subject to external race conditions
like creation/removal of files by another process it should be OK) in exchange
for making it much faster.

PS. Note that calling salt.utils.verify.check_max_open_files() on each _auth is
not really efficient, it probably should be done periodically in a background
thread.

Sponsored by: LinkedIn
Signed-off-by: Alexey Ivanov <SaveTheRbtz@GMail.com>
Move the check_max_open_files into loop_interval.

Since check_max_open_files has no bearing on wether we accept the minion or not, there is no reason to list the directory on every auth call. With this mechanism it is a "fixed cost" since it will run at loop_interval instead of on each auth call
Fix regression in postgres module.

Closes #9372
Alias cmd.watch state to cmd.wait
Hide cmd.watch state alias from docs
Handle a possible exception where a file source does not specify a protocol.
virtualenv.managed: use "user" instead of "runas" for pip install

This commit changes the virtualenv.managed state to use "user" instead
of "runas" when it runs pip.install to satisfy a requirements file.

Conflicts:
	salt/states/virtualenv_mod.py
Fix pylint for salt/states/cmd.py
Remove undefined variable in virtualenv_mod.py
Revert "Remove undefined variable in virtualenv_mod.py"

This reverts commit 8a7c40a63fb7c834922e26af4a20ae478f9ecd96.
Revert "virtualenv.managed: use "user" instead of "runas" for pip install"

This reverts commit 8099bda3059abbb76c5aba60b697bb0422581262.
Fix #6306

Properly warn if the minion could not reach the master and prevent the
minion from stack tracing