mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Merge pull request #20519 from rallytime/pylint_develop
Pylint fixes for Develop
This commit is contained in:
commit
73785a2e8c
@ -37,10 +37,13 @@ from __future__ import absolute_import
|
||||
# Import python libs
|
||||
import copy
|
||||
import pprint
|
||||
import logging
|
||||
import time
|
||||
from os.path import exists, expanduser
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.ext.six as six
|
||||
import salt.ext.six.moves.range as range # pylint: disable=import-error,no-name-in-module
|
||||
|
||||
# Import linode-python
|
||||
try:
|
||||
import linode
|
||||
@ -50,7 +53,6 @@ except ImportError:
|
||||
HAS_LINODEPY = False
|
||||
|
||||
# Import salt cloud libs
|
||||
import salt.config as config
|
||||
from salt.cloud.exceptions import SaltCloudConfigError
|
||||
from salt.cloud.libcloudfuncs import * # pylint: disable=W0614,W0401
|
||||
from salt.utils import namespaced_function
|
||||
@ -271,8 +273,8 @@ def linodes(full=False, include_ips=False, conn=None):
|
||||
thisnode['state'] = LINODE_STATUS[str(n['STATUS'])]
|
||||
|
||||
if include_ips:
|
||||
thisnode = dict(thisnode.items() +
|
||||
get_ips(conn, n['LINODEID']).items())
|
||||
thisnode = dict(list(thisnode.items()) +
|
||||
list(get_ips(conn, n['LINODEID']).items()))
|
||||
|
||||
if full:
|
||||
thisnode['extra'] = n
|
||||
@ -406,14 +408,14 @@ def get_node(LinodeID=None, name=None, full=False):
|
||||
|
||||
linode_list = linodes(full=full, conn=c)
|
||||
|
||||
for l, d in linode_list.iteritems():
|
||||
for l, d in six.iteritems(linode_list):
|
||||
if LinodeID:
|
||||
if d['id'] == LinodeID:
|
||||
d = dict(d.items() + get_ips(conn=c, LinodeID=d['id']).items())
|
||||
d = dict(list(d.items()) + list(get_ips(conn=c, LinodeID=d['id']).items()))
|
||||
return d
|
||||
if name:
|
||||
if d['name'] == name:
|
||||
d = dict(d.items() + get_ips(conn=c, LinodeID=d['id']).items())
|
||||
d = dict(list(d.items()) + list(get_ips(conn=c, LinodeID=d['id']).items()))
|
||||
return d
|
||||
|
||||
return None
|
||||
|
@ -205,7 +205,7 @@ class SaltRaetRoadClusterLoadSetup(ioflo.base.deeding.Deed):
|
||||
Populate loads from masters in stack.remotes
|
||||
'''
|
||||
if self.opts.value.get('cluster_mode'):
|
||||
for remote in self.stack.value.remotes.values():
|
||||
for remote in list(self.stack.value.remotes.values()):
|
||||
if remote.kind == kinds.applKinds.master:
|
||||
self.masters.value[remote.name] = odict(load=0.0, expire=self.store.stamp)
|
||||
|
||||
@ -303,7 +303,7 @@ class SaltRaetRoadStackSetup(ioflo.base.deeding.Deed):
|
||||
offset=0.5)
|
||||
|
||||
if self.opts.value.get('raet_clear_remotes'):
|
||||
for remote in self.stack.value.remotes.values():
|
||||
for remote in list(self.stack.value.remotes.values()):
|
||||
self.stack.value.removeRemote(remote, clear=True)
|
||||
self.stack.puid = self.stack.value.Uid # reset puid
|
||||
|
||||
@ -359,12 +359,12 @@ class SaltRaetRoadStackJoiner(ioflo.base.deeding.Deed):
|
||||
not stack.remotes)
|
||||
|
||||
if refresh_masters: # clear all remote masters
|
||||
for remote in stack.remotes.values():
|
||||
for remote in list(stack.remotes.values()):
|
||||
if remote.kind == kinds.applKinds.master:
|
||||
stack.removeRemote(remote, clear=True)
|
||||
|
||||
if refresh_all: # clear all remotes
|
||||
for remote in stack.remotes.values():
|
||||
for remote in list(stack.remotes.values()):
|
||||
stack.removeRemote(remote, clear=True)
|
||||
|
||||
if refresh_all or refresh_masters:
|
||||
@ -378,7 +378,7 @@ class SaltRaetRoadStackJoiner(ioflo.base.deeding.Deed):
|
||||
ha=mha,
|
||||
kind=kinds.applKinds.master))
|
||||
|
||||
for remote in stack.remotes.values():
|
||||
for remote in list(stack.remotes.values()):
|
||||
if remote.kind == kinds.applKinds.master:
|
||||
stack.join(uid=remote.uid, timeout=0.0)
|
||||
|
||||
@ -409,7 +409,7 @@ class SaltRaetRoadStackJoined(ioflo.base.deeding.Deed):
|
||||
joined = False
|
||||
if stack and isinstance(stack, RoadStack):
|
||||
if stack.remotes:
|
||||
joined = any([remote.joined for remote in stack.remotes.values()
|
||||
joined = any([remote.joined for remote in list(stack.remotes.values())
|
||||
if remote.kind == kinds.applKinds.master])
|
||||
self.status.update(joined=joined)
|
||||
|
||||
@ -498,7 +498,7 @@ class SaltRaetRoadStackAllowed(ioflo.base.deeding.Deed):
|
||||
allowed = False
|
||||
if stack and isinstance(stack, RoadStack):
|
||||
if stack.remotes:
|
||||
allowed = any([remote.allowed for remote in stack.remotes.values()
|
||||
allowed = any([remote.allowed for remote in list(stack.remotes.values())
|
||||
if remote.kind == kinds.applKinds.master])
|
||||
self.status.update(allowed=allowed)
|
||||
|
||||
@ -685,7 +685,7 @@ class SaltLoadPillar(ioflo.base.deeding.Deed):
|
||||
Initial pillar
|
||||
'''
|
||||
# default master is the first remote that is allowed
|
||||
available_masters = [remote for remote in self.road_stack.value.remotes.values()
|
||||
available_masters = [remote for remote in list(self.road_stack.value.remotes.values())
|
||||
if remote.allowed]
|
||||
while not available_masters:
|
||||
available_masters = [remote for remote in self.road_stack.value.remotes.values()
|
||||
@ -1317,7 +1317,7 @@ class SaltRaetRouterMinion(SaltRaetRouter):
|
||||
master = self.road_stack.value.nameRemotes.get(self.master_estate_name.value)
|
||||
if not master or not master.alived: # select a different master
|
||||
available_masters = [remote for remote in
|
||||
self.road_stack.value.remotes.values()
|
||||
list(self.road_stack.value.remotes.values())
|
||||
if remote.alived]
|
||||
if available_masters:
|
||||
random_master = opts.get('random_master')
|
||||
@ -1420,7 +1420,7 @@ class SaltRaetEventerMaster(SaltRaetEventer):
|
||||
if self.opts.value.get('cluster_mode'):
|
||||
if msg.get('origin') is None:
|
||||
masters = (self.availables.value &
|
||||
set((remote.name for remote in self.road_stack.value.remotes.values()
|
||||
set((remote.name for remote in list(self.road_stack.value.remotes.values())
|
||||
if remote.kind == kinds.applKinds.master)))
|
||||
for name in masters:
|
||||
remote = self.road_stack.value.nameRemotes[name]
|
||||
@ -1529,7 +1529,7 @@ class SaltRaetPublisher(ioflo.base.deeding.Deed):
|
||||
# only publish to available minions by intersecting sets
|
||||
|
||||
minions = (self.availables.value &
|
||||
set((remote.name for remote in stack.remotes.values()
|
||||
set((remote.name for remote in list(stack.remotes.values())
|
||||
if remote.kind in [kinds.applKinds.minion,
|
||||
kinds.applKinds.syndic])))
|
||||
for minion in minions:
|
||||
@ -1609,7 +1609,7 @@ class SaltRaetMasterEvents(ioflo.base.deeding.Deed):
|
||||
while self.master_events.value:
|
||||
events.append(self.master_events.value.popleft())
|
||||
route = {'src': (self.road_stack.value.local.name, None, None),
|
||||
'dst': (next(self.road_stack.value.remotes.values()).name, None, 'remote_cmd')}
|
||||
'dst': (next(list(self.road_stack.value.remotes.values())).name, None, 'remote_cmd')}
|
||||
load = {'id': self.opts.value['id'],
|
||||
'events': events,
|
||||
'cmd': '_minion_event'}
|
||||
|
@ -201,13 +201,13 @@ def delete_record(name, zone, record_type, identifier=None, all_records=False,
|
||||
_type = record_type.upper()
|
||||
if _type == 'A':
|
||||
status = _zone.delete_a(name, identifier, all_records)
|
||||
return _wait_for_sync(status.id, conn)
|
||||
return _wait_for_sync(status.id, conn, wait_for_sync)
|
||||
elif _type == 'CNAME':
|
||||
status = _zone.delete_cname(name, identifier, all_records)
|
||||
return _wait_for_sync(status.id, conn)
|
||||
return _wait_for_sync(status.id, conn, wait_for_sync)
|
||||
elif _type == 'MX':
|
||||
status = _zone.delete_mx(name, identifier, all_records)
|
||||
return _wait_for_sync(status.id, conn)
|
||||
return _wait_for_sync(status.id, conn, wait_for_sync)
|
||||
else:
|
||||
msg = '{0} is an unsupported resource type.'.format(_type)
|
||||
log.error(msg)
|
||||
|
@ -22,6 +22,7 @@ import salt.utils
|
||||
import salt.utils.event
|
||||
from salt.utils.network import host_to_ip as _host_to_ip
|
||||
from salt.utils.network import remote_port_tcp as _remote_port_tcp
|
||||
from salt.ext.six.moves import zip
|
||||
|
||||
|
||||
__opts__ = {}
|
||||
|
@ -11,6 +11,7 @@ from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
import salt.utils
|
||||
import salt.ext.six as six
|
||||
|
||||
import os
|
||||
import ctypes
|
||||
@ -88,7 +89,7 @@ def diskusage(human_readable=False, path=None):
|
||||
#Credit for the source and ideas for this function:
|
||||
# http://code.activestate.com/recipes/577972-disk-usage/?in=user-4178764
|
||||
_, total, free = ctypes.c_ulonglong(), ctypes.c_ulonglong(), ctypes.c_longlong()
|
||||
if sys.version_info >= (3, ) or isinstance(path, unicode):
|
||||
if sys.version_info >= (3, ) or isinstance(path, six.text_type):
|
||||
fun = ctypes.windll.kernel32.GetDiskFreeSpaceExw
|
||||
else:
|
||||
fun = ctypes.windll.kernel32.GetDiskFreeSpaceExA
|
||||
|
@ -140,7 +140,7 @@ def _absent_test(user, name, enc, comment, options, source, config):
|
||||
saltenv=__env__)
|
||||
if keys:
|
||||
comment = ''
|
||||
for key, status in keys.items():
|
||||
for key, status in list(keys.items()):
|
||||
if status == 'exists':
|
||||
continue
|
||||
comment += 'Set to {0}: {1}\n'.format(status, key)
|
||||
|
Loading…
Reference in New Issue
Block a user