mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
pylint
This commit is contained in:
parent
4f4db431fa
commit
8cdaf01642
@ -181,8 +181,8 @@ def cluster_configured(name, cluster_config):
|
||||
ret.update({'result': None,
|
||||
'comment': '\n'.join(comments)})
|
||||
return ret
|
||||
log.debug ('Creating cluster \'{0}\' in datacenter \'{1}\'. '
|
||||
''.format(cluster_name, datacenter_name))
|
||||
log.debug('Creating cluster \'{0}\' in datacenter \'{1}\'. '
|
||||
''.format(cluster_name, datacenter_name))
|
||||
__salt__['vsphere.create_cluster'](cluster_dict,
|
||||
datacenter_name,
|
||||
cluster_name,
|
||||
@ -258,7 +258,7 @@ def cluster_configured(name, cluster_config):
|
||||
'comment': '\n'.join(comments),
|
||||
'changes': changes})
|
||||
return ret
|
||||
except excs.CommandExecutionError as exc:
|
||||
except CommandExecutionError as exc:
|
||||
log.error('Error: {0}\n{1}'.format(exc, traceback.format_exc()))
|
||||
if si:
|
||||
__salt__['vsphere.disconnect'](si)
|
||||
@ -320,7 +320,7 @@ def vsan_datastore_configured(name, datastore_name):
|
||||
log.info(comments[-1])
|
||||
__salt__['vsphere.disconnect'](si)
|
||||
|
||||
ret.update({'result': True if (not changes_required) else None if \
|
||||
ret.update({'result': True if (not changes_required) else None if
|
||||
__opts__['test'] else True,
|
||||
'comment': '\n'.join(comments),
|
||||
'changes': changes})
|
||||
|
@ -283,16 +283,16 @@ class RecursiveDictDiffer(DictDiffer):
|
||||
keys.extend(_removed(diffs[key],
|
||||
prefix='{0}{1}.'.format(prefix, key)))
|
||||
elif diffs[key]['new'] == self.NONE_VALUE:
|
||||
keys.append('{0}{1}'.format(prefix, key))
|
||||
keys.append('{0}{1}'.format(prefix, key))
|
||||
elif isinstance(diffs[key]['new'], dict):
|
||||
keys.extend(
|
||||
_removed(diffs[key]['new'],
|
||||
prefix='{0}{1}.'.format(prefix, key)))
|
||||
keys.extend(
|
||||
_removed(diffs[key]['new'],
|
||||
prefix='{0}{1}.'.format(prefix, key)))
|
||||
return keys
|
||||
|
||||
return _removed(self._diffs, prefix='')
|
||||
|
||||
def changed(self, ignore_unset_values=True):
|
||||
def changed(self):
|
||||
'''
|
||||
Returns all keys that have been changed.
|
||||
|
||||
@ -309,7 +309,7 @@ class RecursiveDictDiffer(DictDiffer):
|
||||
keys.extend(_changed(diffs[key],
|
||||
prefix='{0}{1}.'.format(prefix, key)))
|
||||
continue
|
||||
if ignore_unset_values:
|
||||
if self.ignore_unset_values:
|
||||
if 'old' in diffs[key] and 'new' in diffs[key] and \
|
||||
diffs[key]['old'] != self.NONE_VALUE and \
|
||||
diffs[key]['new'] != self.NONE_VALUE:
|
||||
@ -320,9 +320,9 @@ class RecursiveDictDiffer(DictDiffer):
|
||||
else:
|
||||
keys.append('{0}{1}'.format(prefix, key))
|
||||
elif isinstance(diffs[key], dict):
|
||||
keys.extend(
|
||||
_changed(diffs[key],
|
||||
prefix='{0}{1}.'.format(prefix, key)))
|
||||
keys.extend(
|
||||
_changed(diffs[key],
|
||||
prefix='{0}{1}.'.format(prefix, key)))
|
||||
else:
|
||||
if 'old' in diffs[key] and 'new' in diffs[key]:
|
||||
if isinstance(diffs[key]['new'], dict):
|
||||
@ -332,9 +332,9 @@ class RecursiveDictDiffer(DictDiffer):
|
||||
else:
|
||||
keys.append('{0}{1}'.format(prefix, key))
|
||||
elif isinstance(diffs[key], dict):
|
||||
keys.extend(
|
||||
_changed(diffs[key],
|
||||
prefix='{0}{1}.'.format(prefix, key)))
|
||||
keys.extend(
|
||||
_changed(diffs[key],
|
||||
prefix='{0}{1}.'.format(prefix, key)))
|
||||
|
||||
return keys
|
||||
|
||||
@ -350,7 +350,7 @@ class RecursiveDictDiffer(DictDiffer):
|
||||
def _unchanged(current_dict, diffs, prefix):
|
||||
keys = []
|
||||
for key in current_dict.keys():
|
||||
if not key in diffs:
|
||||
if key not in diffs:
|
||||
keys.append('{0}{1}'.format(prefix, key))
|
||||
elif isinstance(current_dict[key], dict):
|
||||
if 'new' in diffs[key]:
|
||||
|
@ -1109,8 +1109,8 @@ def add_license(service_instance, key, description, license_manager=None):
|
||||
if not license_manager:
|
||||
license_manager = get_license_manager(service_instance)
|
||||
label = vim.KeyValue()
|
||||
label.key='VpxClientLicenseLabel'
|
||||
label.value=description
|
||||
label.key = 'VpxClientLicenseLabel'
|
||||
label.value = description
|
||||
log.debug('Adding license \'{}\''.format(description))
|
||||
try:
|
||||
license = license_manager.AddLicense(key, [label])
|
||||
@ -1203,7 +1203,7 @@ def get_assigned_licenses(service_instance, entity_ref=None, entity_name=None,
|
||||
raise salt.exceptions.VMwareObjectRetrievalError(
|
||||
'Unexpected return. Expect only a single assignment')
|
||||
|
||||
if check_name == True:
|
||||
if check_name:
|
||||
if entity_name != assignments[0].entityDisplayName:
|
||||
log.trace('Getting license info for wrong vcenter: '
|
||||
'{0} != {1}'.format(entity_name,
|
||||
@ -1545,8 +1545,8 @@ def get_datastores(service_instance, reference, datastore_names=None,
|
||||
mount_infos = props.get('fileSystemVolumeInfo.mountInfo', [])
|
||||
disk_datastores = []
|
||||
# Non vmfs volumes aren't backed by a disk
|
||||
for vol in [i.volume for i in mount_infos if \
|
||||
isinstance(i.volume, vim.HostVmfsVolume)]:
|
||||
for vol in [i.volume for i in mount_infos if
|
||||
isinstance(i.volume, vim.HostVmfsVolume)]:
|
||||
|
||||
if not [e for e in vol.extent if e.diskName in backing_disk_ids]:
|
||||
# Skip volume if it doesn't contain an extent with a
|
||||
@ -1598,7 +1598,7 @@ def get_datastores(service_instance, reference, datastore_names=None,
|
||||
# Traversal of root folder (doesn't support multiple levels of Folders)
|
||||
traversal_spec = vmodl.query.PropertyCollector.TraversalSpec(
|
||||
path='childEntity',
|
||||
selectSet = [
|
||||
selectSet=[
|
||||
vmodl.query.PropertyCollector.TraversalSpec(
|
||||
path='datastore',
|
||||
skip=False,
|
||||
|
@ -11,8 +11,7 @@ import logging
|
||||
|
||||
# Import Salt testing libraries
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock, call, \
|
||||
PropertyMock
|
||||
from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock, call
|
||||
from salt.exceptions import VMwareObjectRetrievalError, VMwareApiError, \
|
||||
ArgumentValueError, VMwareRuntimeError
|
||||
|
||||
@ -28,6 +27,7 @@ except ImportError:
|
||||
# Get Logging Started
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
@skipIf(not HAS_PYVMOMI, 'The \'pyvmomi\' library is missing')
|
||||
class GetStorageSystemTestCase(TestCase):
|
||||
@ -179,7 +179,6 @@ class GetDatastoresTestCase(TestCase):
|
||||
self.mock_get_storage_system.assert_called_once_with(
|
||||
self.mock_si, self.mock_reference, 'fake_host')
|
||||
|
||||
|
||||
def test_get_mount_info_call(self):
|
||||
mock_get_properties_of_managed_object = MagicMock()
|
||||
with patch('salt.utils.vmware.get_properties_of_managed_object',
|
||||
@ -200,7 +199,7 @@ class GetDatastoresTestCase(TestCase):
|
||||
|
||||
def test_host_traversal_spec(self):
|
||||
# Reference is of type vim.HostSystem
|
||||
mock_traversal_spec_init = MagicMock()
|
||||
mock_traversal_spec_init = MagicMock()
|
||||
with patch(
|
||||
'salt.utils.vmware.vmodl.query.PropertyCollector.TraversalSpec',
|
||||
mock_traversal_spec_init):
|
||||
@ -330,7 +329,7 @@ class GetDatastoresTestCase(TestCase):
|
||||
res = salt.utils.vmware.get_datastores(
|
||||
self.mock_si, self.mock_reference,
|
||||
datastore_names=['fake_ds1'],
|
||||
backing_disk_ids= ['fake_disk3'])
|
||||
backing_disk_ids=['fake_disk3'])
|
||||
self.assertEqual(res, [self.mock_entries[0]['object'],
|
||||
self.mock_entries[2]['object']])
|
||||
|
||||
@ -393,6 +392,6 @@ class RenameDatastoreTestCase(TestCase):
|
||||
|
||||
def test_rename_datastore(self):
|
||||
ret = salt.utils.vmware.rename_datastore(self.mock_ds_ref,
|
||||
'fake_new_name')
|
||||
'fake_new_name')
|
||||
self.mock_ds_ref.RenameDatastore.assert_called_once_with(
|
||||
'fake_new_name')
|
||||
|
Loading…
Reference in New Issue
Block a user