fix linting errors

This commit is contained in:
Daniel Wallace 2015-08-14 15:46:29 -05:00
parent 5bdcf9d72a
commit 3a08d55ff5
3 changed files with 19 additions and 11 deletions

View File

@ -21,9 +21,11 @@ events based on the channels they are subscribed to.
:depends: redis
'''
from __future__ import absolute_import
import redis
import threading
import salt.client
from salt.ext import six
from salt.ext.six import zip
try:
import redis
@ -59,12 +61,16 @@ class Listener(object):
def work(self, item):
ret = {'channel': item['channel']}
if isinstance(item['data'], (int, long)):
if isinstance(item['data'], six.integer_types):
ret['code'] = item['data']
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'):
ret.update(dict(zip(('master', 'host', 'port'), item['data'].split(' ')[1:])))
ret.update(dict(list(zip(
('master', 'host', 'port'), item['data'].split(' ')[1:]
))))
else:
ret = {
'channel': item['channel'],

View File

@ -15,8 +15,9 @@ Module to provide redis functionality to Salt
redis.password: None
'''
# Import Pytho libs
# Import Python libs
from __future__ import absolute_import
from salt.ext.six.moves import zip
# Import third party libs
try:
@ -53,6 +54,7 @@ def _connect(host=None, port=None, db=None, password=None):
return redis.StrictRedis(host, port, db, password)
def _sconnect(host=None, port=None, password=None):
'''
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)
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):
@ -535,4 +537,4 @@ def get_master_ip(host=None, port=None, password=None):
server = _connect(host, port, password)
info = server.info()
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)))

View File

@ -28,6 +28,7 @@ overridden in states using the following arguments: ``host``, ``post``, ``db``,
- db: 0
- password: somuchkittycat
'''
from __future__ import absolute_import
import copy
__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.
.. versionadded: Boron
name
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)
if sentinel_master['master_host'] in __salt__['network.ip_addrs']():
ret['result'] = True
ret['comment'] = 'Minion is the master: '.format(name)
ret['comment'] = 'Minion is the master: {0}'.format(name)
return ret
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)
return ret
if __opts__['test'] == True:
if __opts__['test'] is True:
ret['comment'] = 'Minion will be made a slave of {0}: {1}'.format(name, sentinel_master['host'])
ret['result'] = None
return ret