Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions SoftLayer/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@

:license: MIT, see LICENSE for more details.
"""
# pylint: disable=invalid-name
import warnings

from SoftLayer import auth as slauth
from SoftLayer import config
from SoftLayer import consts
from SoftLayer import transports

# pylint: disable=invalid-name


API_PUBLIC_ENDPOINT = consts.API_PUBLIC_ENDPOINT
API_PRIVATE_ENDPOINT = consts.API_PRIVATE_ENDPOINT
__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion SoftLayer/CLI/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

:license: MIT, see LICENSE for more details.
"""
# pylint: disable=w0401
# pylint: disable=w0401, invalid-name

from SoftLayer.CLI.helpers import * # NOQA
1 change: 1 addition & 0 deletions SoftLayer/CLI/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""


# pylint: disable=keyword-arg-before-vararg
class CLIHalt(SystemExit):
"""Smoothly halt the execution of the command. No error."""
def __init__(self, code=0, *args):
Expand Down
2 changes: 0 additions & 2 deletions SoftLayer/CLI/firewall/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ def open_editor(rules=None, content=None):
data = tfile.read()
return data

return


def get_formatted_rule(rule=None):
"""Helper to format the rule into a user friendly format.
Expand Down
2 changes: 1 addition & 1 deletion SoftLayer/CLI/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

:license: MIT, see LICENSE for more details.
"""
# pylint: disable=E0202, consider-merging-isinstance, arguments-differ
# pylint: disable=E0202, consider-merging-isinstance, arguments-differ, keyword-arg-before-vararg
import collections
import json
import os
Expand Down
8 changes: 3 additions & 5 deletions SoftLayer/CLI/virt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ class MemoryType(click.ParamType):
"""Memory type."""
name = 'integer'

def convert(self, value, param, ctx):
def convert(self, value, param, ctx): # pylint: disable=inconsistent-return-statements
"""Validate memory argument. Returns the memory value in megabytes."""
matches = MEMORY_RE.match(value.lower())
if matches is None:
self.fail('%s is not a valid value for memory amount'
% value, param, ctx)
self.fail('%s is not a valid value for memory amount' % value, param, ctx)
amount_str, unit = matches.groups()
amount = int(amount_str)
if unit in [None, 'm', 'mb']:
Expand All @@ -26,8 +25,7 @@ def convert(self, value, param, ctx):
return amount * 1024
else:
if amount % 1024 != 0:
self.fail('%s is not an integer that is divisable by 1024'
% value, param, ctx)
self.fail('%s is not an integer that is divisable by 1024' % value, param, ctx)
return amount
elif unit in ['g', 'gb']:
return amount * 1024
Expand Down
2 changes: 1 addition & 1 deletion SoftLayer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

:license: MIT, see LICENSE for more details.
"""
# pylint: disable=w0401
# pylint: disable=w0401,invalid-name
from SoftLayer import consts

from SoftLayer.API import * # NOQA
Expand Down
20 changes: 9 additions & 11 deletions SoftLayer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_client_settings_env(**_):
}


def get_client_settings_config_file(**kwargs):
def get_client_settings_config_file(**kwargs): # pylint: disable=inconsistent-return-statements
"""Retrieve client settings from the possible config file locations.

:param \\*\\*kwargs: Arguments that are passed into the client instance
Expand All @@ -60,16 +60,14 @@ def get_client_settings_config_file(**kwargs):
})
config.read(config_files)

if not config.has_section('softlayer'):
return

return {
'endpoint_url': config.get('softlayer', 'endpoint_url'),
'timeout': config.getfloat('softlayer', 'timeout'),
'proxy': config.get('softlayer', 'proxy'),
'username': config.get('softlayer', 'username'),
'api_key': config.get('softlayer', 'api_key'),
}
if config.has_section('softlayer'):
return {
'endpoint_url': config.get('softlayer', 'endpoint_url'),
'timeout': config.getfloat('softlayer', 'timeout'),
'proxy': config.get('softlayer', 'proxy'),
'username': config.get('softlayer', 'username'),
'api_key': config.get('softlayer', 'api_key'),
}


SETTING_RESOLVERS = [get_client_settings_args,
Expand Down
12 changes: 11 additions & 1 deletion SoftLayer/managers/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@

:license: MIT, see LICENSE for more details.
"""
import logging
import socket

import SoftLayer
from SoftLayer.decoration import retry
from SoftLayer import exceptions
from SoftLayer.managers import ordering
from SoftLayer import utils

LOGGER = logging.getLogger(__name__)

# Invalid names are ignored due to long method names and short argument names
# pylint: disable=invalid-name, no-self-use

Expand Down Expand Up @@ -82,6 +88,7 @@ def cancel_hardware(self, hardware_id, reason='unneeded', comment='',
immediate, False, cancel_reason, comment,
id=billing_id)

@retry(exceptions.SoftLayerAPIError, logger=LOGGER)
def list_hardware(self, tags=None, cpus=None, memory=None, hostname=None,
domain=None, datacenter=None, nic_speed=None,
public_ip=None, private_ip=None, **kwargs):
Expand Down Expand Up @@ -169,6 +176,7 @@ def list_hardware(self, tags=None, cpus=None, memory=None, hostname=None,
kwargs['filter'] = _filter.to_dict()
return self.account.getHardware(**kwargs)

@retry(exceptions.SoftLayerAPIError, logger=LOGGER)
def get_hardware(self, hardware_id, **kwargs):
"""Get details about a hardware device.

Expand Down Expand Up @@ -335,6 +343,7 @@ def get_cancellation_reasons(self):
'moving': 'Moving to competitor',
}

@retry(exceptions.SoftLayerAPIError, logger=LOGGER)
def get_create_options(self):
"""Returns valid options for ordering hardware."""

Expand Down Expand Up @@ -395,6 +404,7 @@ def get_create_options(self):
'extras': extras,
}

@retry(exceptions.SoftLayerAPIError, logger=LOGGER)
def _get_package(self):
"""Get the package related to simple hardware ordering."""
mask = '''
Expand Down Expand Up @@ -490,7 +500,7 @@ def _get_ids_from_hostname(self, hostname):
results = self.list_hardware(hostname=hostname, mask="id")
return [result['id'] for result in results]

def _get_ids_from_ip(self, ip):
def _get_ids_from_ip(self, ip): # pylint: disable=inconsistent-return-statements
"""Returns list of matching hardware IDs for a given ip address."""
try:
# Does it look like an ip address?
Expand Down
15 changes: 10 additions & 5 deletions SoftLayer/managers/vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, client, ordering_manager=None):
else:
self.ordering_manager = ordering_manager

@retry(exceptions.SoftLayerAPIError, logger=LOGGER)
def list_instances(self, hourly=True, monthly=True, tags=None, cpus=None,
memory=None, hostname=None, domain=None,
local_disk=None, datacenter=None, nic_speed=None,
Expand Down Expand Up @@ -161,6 +162,7 @@ def list_instances(self, hourly=True, monthly=True, tags=None, cpus=None,
func = getattr(self.account, call)
return func(**kwargs)

@retry(exceptions.SoftLayerAPIError, logger=LOGGER)
def get_instance(self, instance_id, **kwargs):
"""Get details about a virtual server instance.

Expand Down Expand Up @@ -235,6 +237,7 @@ def get_instance(self, instance_id, **kwargs):

return self.guest.getObject(id=instance_id, **kwargs)

@retry(exceptions.SoftLayerAPIError, logger=LOGGER)
def get_create_options(self):
"""Retrieves the available options for creating a VS.

Expand Down Expand Up @@ -411,6 +414,7 @@ def _generate_create_dict(

return data

@retry(exceptions.SoftLayerAPIError, logger=LOGGER)
def wait_for_transaction(self, instance_id, limit, delay=10):
"""Waits on a VS transaction for the specified amount of time.

Expand Down Expand Up @@ -482,6 +486,7 @@ def wait_for_ready(self, instance_id, limit, delay=10, pending=False):
return False
LOGGER.info('Auto retry in %s seconds', str(min(delay, until - now)))
time.sleep(min(delay, until - now))
return False

def verify_create_instance(self, **kwargs):
"""Verifies an instance creation command.
Expand Down Expand Up @@ -670,7 +675,7 @@ def _get_ids_from_hostname(self, hostname):
results = self.list_instances(hostname=hostname, mask="id")
return [result['id'] for result in results]

def _get_ids_from_ip(self, ip_address):
def _get_ids_from_ip(self, ip_address): # pylint: disable=inconsistent-return-statements
"""List VS ids which match the given ip address."""
try:
# Does it look like an ip address?
Expand Down Expand Up @@ -893,8 +898,8 @@ def _get_upgrade_prices(self, instance_id, include_downgrade_options=True):
mask = "mask[%s]" % ','.join(mask)
return self.guest.getUpgradeItemPrices(include_downgrade_options, id=instance_id, mask=mask)

def _get_price_id_for_upgrade_option(self, upgrade_prices, option, value,
public=True):
# pylint: disable=inconsistent-return-statements
def _get_price_id_for_upgrade_option(self, upgrade_prices, option, value, public=True):
"""Find the price id for the option and value to upgrade. This

:param list upgrade_prices: Contains all the prices related to a VS upgrade
Expand Down Expand Up @@ -934,8 +939,8 @@ def _get_price_id_for_upgrade_option(self, upgrade_prices, option, value,
else:
return price.get('id')

def _get_price_id_for_upgrade(self, package_items, option, value,
public=True):
# pylint: disable=inconsistent-return-statements
def _get_price_id_for_upgrade(self, package_items, option, value, public=True):
"""Find the price id for the option and value to upgrade.

Deprecated in favor of _get_price_id_for_upgrade_option()
Expand Down
7 changes: 3 additions & 4 deletions SoftLayer/shell/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def get_completions(self, document, complete_event):
return _click_autocomplete(self.root, document.text_before_cursor)


# pylint: disable=stop-iteration-return
def _click_autocomplete(root, text):
"""Completer generator for click applications."""
try:
Expand All @@ -41,17 +42,15 @@ def _click_autocomplete(root, text):
continue
for opt in itertools.chain(param.opts, param.secondary_opts):
if opt.startswith(incomplete):
yield completion.Completion(opt, -len(incomplete),
display_meta=param.help)
yield completion.Completion(opt, -len(incomplete), display_meta=param.help)

elif isinstance(location, (click.MultiCommand, click.core.Group)):
ctx = click.Context(location)
commands = location.list_commands(ctx)
for command in commands:
if command.startswith(incomplete):
cmd = location.get_command(ctx, command)
yield completion.Completion(command, -len(incomplete),
display_meta=cmd.short_help)
yield completion.Completion(command, -len(incomplete), display_meta=cmd.short_help)


def _click_resolve_command(root, parts):
Expand Down