mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
fix linting errors
This commit is contained in:
parent
5bdcf9d72a
commit
3a08d55ff5
@ -21,9 +21,11 @@ events based on the channels they are subscribed to.
|
|||||||
|
|
||||||
:depends: redis
|
:depends: redis
|
||||||
'''
|
'''
|
||||||
|
from __future__ import absolute_import
|
||||||
import redis
|
import redis
|
||||||
import threading
|
|
||||||
import salt.client
|
import salt.client
|
||||||
|
from salt.ext import six
|
||||||
|
from salt.ext.six import zip
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import redis
|
import redis
|
||||||
@ -59,12 +61,16 @@ class Listener(object):
|
|||||||
|
|
||||||
def work(self, item):
|
def work(self, item):
|
||||||
ret = {'channel': item['channel']}
|
ret = {'channel': item['channel']}
|
||||||
if isinstance(item['data'], (int, long)):
|
if isinstance(item['data'], six.integer_types):
|
||||||
ret['code'] = item['data']
|
ret['code'] = item['data']
|
||||||
elif item['channel'] == '+switch-master':
|
elif item['channel'] == '+switch-master':
|
||||||
ret.update(dict(zip(('master', 'old_host', 'old_port', 'new_host', 'new_port'), item['data'].split(' '))))
|
ret.update(dict(list(zip(
|
||||||
|
('master', 'old_host', 'old_port', 'new_host', 'new_port'), item['data'].split(' ')
|
||||||
|
))))
|
||||||
elif item['channel'] in ('+odown', '-odown'):
|
elif item['channel'] in ('+odown', '-odown'):
|
||||||
ret.update(dict(zip(('master', 'host', 'port'), item['data'].split(' ')[1:])))
|
ret.update(dict(list(zip(
|
||||||
|
('master', 'host', 'port'), item['data'].split(' ')[1:]
|
||||||
|
))))
|
||||||
else:
|
else:
|
||||||
ret = {
|
ret = {
|
||||||
'channel': item['channel'],
|
'channel': item['channel'],
|
||||||
|
@ -15,8 +15,9 @@ Module to provide redis functionality to Salt
|
|||||||
redis.password: None
|
redis.password: None
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# Import Pytho libs
|
# Import Python libs
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from salt.ext.six.moves import zip
|
||||||
|
|
||||||
# Import third party libs
|
# Import third party libs
|
||||||
try:
|
try:
|
||||||
@ -53,6 +54,7 @@ def _connect(host=None, port=None, db=None, password=None):
|
|||||||
|
|
||||||
return redis.StrictRedis(host, port, db, password)
|
return redis.StrictRedis(host, port, db, password)
|
||||||
|
|
||||||
|
|
||||||
def _sconnect(host=None, port=None, password=None):
|
def _sconnect(host=None, port=None, password=None):
|
||||||
'''
|
'''
|
||||||
Returns an instance of the redis client
|
Returns an instance of the redis client
|
||||||
@ -517,7 +519,7 @@ def sentinel_get_master_ip(master, host=None, port=None, password=None):
|
|||||||
'''
|
'''
|
||||||
server = _sconnect(host, port, password)
|
server = _sconnect(host, port, password)
|
||||||
ret = server.sentinel_get_master_addr_by_name(master)
|
ret = server.sentinel_get_master_addr_by_name(master)
|
||||||
return dict(zip(('master_host', 'master_port'), ret))
|
return dict(list(zip(('master_host', 'master_port'), ret)))
|
||||||
|
|
||||||
|
|
||||||
def get_master_ip(host=None, port=None, password=None):
|
def get_master_ip(host=None, port=None, password=None):
|
||||||
@ -535,4 +537,4 @@ def get_master_ip(host=None, port=None, password=None):
|
|||||||
server = _connect(host, port, password)
|
server = _connect(host, port, password)
|
||||||
info = server.info()
|
info = server.info()
|
||||||
ret = (info.get('master_host', ''), info.get('master_port', ''))
|
ret = (info.get('master_host', ''), info.get('master_port', ''))
|
||||||
return dict(zip(('master_host', 'master_port'), ret))
|
return dict(list(zip(('master_host', 'master_port'), ret)))
|
||||||
|
@ -28,6 +28,7 @@ overridden in states using the following arguments: ``host``, ``post``, ``db``,
|
|||||||
- db: 0
|
- db: 0
|
||||||
- password: somuchkittycat
|
- password: somuchkittycat
|
||||||
'''
|
'''
|
||||||
|
from __future__ import absolute_import
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
__virtualname__ = 'redis'
|
__virtualname__ = 'redis'
|
||||||
@ -121,7 +122,7 @@ def slaveof(name, sentinel_host=None, sentinel_port=None, sentinel_password=None
|
|||||||
Set this redis instance as a slave.
|
Set this redis instance as a slave.
|
||||||
|
|
||||||
.. versionadded: Boron
|
.. versionadded: Boron
|
||||||
|
|
||||||
name
|
name
|
||||||
Master to make this a slave of
|
Master to make this a slave of
|
||||||
|
|
||||||
@ -141,7 +142,7 @@ def slaveof(name, sentinel_host=None, sentinel_port=None, sentinel_password=None
|
|||||||
sentinel_master = __salt__['redis.sentinel_get_master_ip'](name, sentinel_host, sentinel_port, sentinel_password)
|
sentinel_master = __salt__['redis.sentinel_get_master_ip'](name, sentinel_host, sentinel_port, sentinel_password)
|
||||||
if sentinel_master['master_host'] in __salt__['network.ip_addrs']():
|
if sentinel_master['master_host'] in __salt__['network.ip_addrs']():
|
||||||
ret['result'] = True
|
ret['result'] = True
|
||||||
ret['comment'] = 'Minion is the master: '.format(name)
|
ret['comment'] = 'Minion is the master: {0}'.format(name)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
first_master = __salt__['redis.get_master_ip'](**connection_args)
|
first_master = __salt__['redis.get_master_ip'](**connection_args)
|
||||||
@ -150,8 +151,7 @@ def slaveof(name, sentinel_host=None, sentinel_port=None, sentinel_password=None
|
|||||||
ret['comment'] = 'Minion already slave of master: {0}'.format(name)
|
ret['comment'] = 'Minion already slave of master: {0}'.format(name)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
if __opts__['test'] is True:
|
||||||
if __opts__['test'] == True:
|
|
||||||
ret['comment'] = 'Minion will be made a slave of {0}: {1}'.format(name, sentinel_master['host'])
|
ret['comment'] = 'Minion will be made a slave of {0}: {1}'.format(name, sentinel_master['host'])
|
||||||
ret['result'] = None
|
ret['result'] = None
|
||||||
return ret
|
return ret
|
||||||
|
Loading…
Reference in New Issue
Block a user