Running the `MinionBase` init method with `super` is literally the same as the
`self.opts = opts` statement that was in the init method for `SMinion` anyway
so if it makes flake8 happy, then sure.
This fixes https://github.com/saltstack/salt/issues/24354
There was inconsistent behavior between salt-minion (`Minion` under the hood)
and salt-call (`SMinion` under the hood) with regard to how the master was
determined from the minion config. `SMinion` had its own hard-coded master
evaluation in its `__init__` method that was not congruent with documentation.
The "standard" master evaluation logic existed in `master_eval`, a method of
`Minion`.
This was resolved by moving `master_eval` into `MinionBase` (which `Minion`
inherits from) and making `SMinion` also subclass `MinionBase`, which
otherwise only consists of a couple of methods that `SMinion` won't access.
This modifies the existing behavior such that re.IGNORECASE will be used
if we're on Python 2.7 or later. If not, then we try to match the regex
first on a lowercased version of the string, and if it matches, return
the substitution on a lowercased version of the string. If there is no
match, we just return the original string. This keeps us from
unnecessarily lowercasing the string.
There was a problem wherein two sockets would race to see which was connected first,
causing unit.utils.event_test.TestSaltEvent.test_event_multiple_clients to fail from
time to time. This gives a little breathing room to the second socket.
This also only does the pub connect if necessary on SaltEvent instantation.
The code assumed rc.conf to be existing and non-empty. Added a length
check to ensure it works even if rc.conf is missing, such as in a newly
created jail.
sig4() and query() upon getting a location set to None will attempt
to fetch it from EC2 instance metadata before falling back to
us-east-1.
get_region_from_metadata() uses caching just like creds() does. If
it can't connect to the metadata service, it does not try again.
If a value is successfully retrieved, it is cached so that future
calls are faster.
get_location() will call get_region_from_metadata() if location is
not explicitly set in config.
If sig4() receives an empty location value, it tries to
fetch it using get_region_from_metadata()
Log error. The integer comparison is Python 3 compatible and ripped from
[1]. This will catch incorrectly implemented version comparison
functions.
[1] http://stackoverflow.com/a/3646519/260805