Skip to content

Commit 508966c

Browse files
Merge pull request #1265 from allmightyspiff/master
fixed pylint 2.5.0 errors
2 parents 9ee2f8d + 2d6155a commit 508966c

File tree

4 files changed

+29
-35
lines changed

4 files changed

+29
-35
lines changed

SoftLayer/managers/dedicated_host.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
66
:license: MIT, see License for more details.
77
"""
8-
98
import logging
10-
import SoftLayer
119

10+
from SoftLayer.exceptions import SoftLayerAPIError
11+
from SoftLayer.exceptions import SoftLayerError
1212
from SoftLayer.managers import ordering
1313
from SoftLayer import utils
1414

@@ -395,7 +395,7 @@ def _get_location(self, regions, datacenter):
395395
if region['location']['location']['name'] == datacenter:
396396
return region
397397

398-
raise SoftLayer.SoftLayerError("Could not find valid location for: '%s'" % datacenter)
398+
raise SoftLayerError("Could not find valid location for: '%s'" % datacenter)
399399

400400
def get_create_options(self):
401401
"""Returns valid options for ordering a dedicated host."""
@@ -426,7 +426,7 @@ def _get_price(self, package):
426426
if not price.get('locationGroupId'):
427427
return price['id']
428428

429-
raise SoftLayer.SoftLayerError("Could not find valid price")
429+
raise SoftLayerError("Could not find valid price")
430430

431431
def _get_item(self, package, flavor):
432432
"""Returns the item for ordering a dedicated host."""
@@ -435,7 +435,7 @@ def _get_item(self, package, flavor):
435435
if item['keyName'] == flavor:
436436
return item
437437

438-
raise SoftLayer.SoftLayerError("Could not find valid item for: '%s'" % flavor)
438+
raise SoftLayerError("Could not find valid item for: '%s'" % flavor)
439439

440440
def _get_backend_router(self, locations, item):
441441
"""Returns valid router options for ordering a dedicated host."""
@@ -495,7 +495,7 @@ def _get_backend_router(self, locations, item):
495495
routers = self.host.getAvailableRouters(host, mask=mask)
496496
return routers
497497

498-
raise SoftLayer.SoftLayerError("Could not find available routers")
498+
raise SoftLayerError("Could not find available routers")
499499

500500
def _get_default_router(self, routers, router_name=None):
501501
"""Returns the default router for ordering a dedicated host."""
@@ -508,7 +508,7 @@ def _get_default_router(self, routers, router_name=None):
508508
if router['hostname'] == router_name:
509509
return router['id']
510510

511-
raise SoftLayer.SoftLayerError("Could not find valid default router")
511+
raise SoftLayerError("Could not find valid default router")
512512

513513
def get_router_options(self, datacenter=None, flavor=None):
514514
"""Returns available backend routers for the dedicated host."""
@@ -524,7 +524,7 @@ def _delete_guest(self, guest_id):
524524
msg = 'Cancelled'
525525
try:
526526
self.guest.deleteObject(id=guest_id)
527-
except SoftLayer.SoftLayerAPIError as e:
527+
except SoftLayerAPIError as e:
528528
msg = 'Exception: ' + e.faultString
529529

530530
return msg

SoftLayer/managers/hardware.py

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import socket
1010
import time
1111

12-
import SoftLayer
1312
from SoftLayer.decoration import retry
13+
from SoftLayer.exceptions import SoftLayerError
1414
from SoftLayer.managers import ordering
15+
from SoftLayer.managers.ticket import TicketManager
1516
from SoftLayer import utils
1617

1718
LOGGER = logging.getLogger(__name__)
@@ -77,19 +78,18 @@ def cancel_hardware(self, hardware_id, reason='unneeded', comment='', immediate=
7778
# Get cancel reason
7879
reasons = self.get_cancellation_reasons()
7980
cancel_reason = reasons.get(reason, reasons['unneeded'])
80-
ticket_mgr = SoftLayer.TicketManager(self.client)
81+
ticket_mgr = TicketManager(self.client)
8182
mask = 'mask[id, hourlyBillingFlag, billingItem[id], openCancellationTicket[id], activeTransaction]'
8283
hw_billing = self.get_hardware(hardware_id, mask=mask)
8384

8485
if 'activeTransaction' in hw_billing:
85-
raise SoftLayer.SoftLayerError("Unable to cancel hardware with running transaction")
86+
raise SoftLayerError("Unable to cancel hardware with running transaction")
8687

8788
if 'billingItem' not in hw_billing:
8889
if utils.lookup(hw_billing, 'openCancellationTicket', 'id'):
89-
raise SoftLayer.SoftLayerError("Ticket #%s already exists for this server" %
90-
hw_billing['openCancellationTicket']['id'])
91-
raise SoftLayer.SoftLayerError("Cannot locate billing for the server. "
92-
"The server may already be cancelled.")
90+
raise SoftLayerError("Ticket #%s already exists for this server" %
91+
hw_billing['openCancellationTicket']['id'])
92+
raise SoftLayerError("Cannot locate billing for the server. The server may already be cancelled.")
9393

9494
billing_id = hw_billing['billingItem']['id']
9595

@@ -744,7 +744,7 @@ def _get_extra_price_id(items, key_name, hourly, location):
744744

745745
return price['id']
746746

747-
raise SoftLayer.SoftLayerError(
747+
raise SoftLayerError(
748748
"Could not find valid price for extra option, '%s'" % key_name)
749749

750750

@@ -762,7 +762,7 @@ def _get_default_price_id(items, option, hourly, location):
762762
_matches_location(price, location)]):
763763
return price['id']
764764

765-
raise SoftLayer.SoftLayerError(
765+
raise SoftLayerError(
766766
"Could not find valid price for '%s' option" % option)
767767

768768

@@ -792,19 +792,16 @@ def _get_bandwidth_price_id(items,
792792

793793
return price['id']
794794

795-
raise SoftLayer.SoftLayerError(
795+
raise SoftLayerError(
796796
"Could not find valid price for bandwidth option")
797797

798798

799799
def _get_os_price_id(items, os, location):
800800
"""Returns the price id matching."""
801801

802802
for item in items:
803-
if any([utils.lookup(item,
804-
'itemCategory',
805-
'categoryCode') != 'os',
806-
utils.lookup(item,
807-
'keyName') != os]):
803+
if any([utils.lookup(item, 'itemCategory', 'categoryCode') != 'os',
804+
utils.lookup(item, 'keyName') != os]):
808805
continue
809806

810807
for price in item['prices']:
@@ -813,17 +810,14 @@ def _get_os_price_id(items, os, location):
813810

814811
return price['id']
815812

816-
raise SoftLayer.SoftLayerError("Could not find valid price for os: '%s'" %
817-
os)
813+
raise SoftLayerError("Could not find valid price for os: '%s'" % os)
818814

819815

820816
def _get_port_speed_price_id(items, port_speed, no_public, location):
821817
"""Choose a valid price id for port speed."""
822818

823819
for item in items:
824-
if utils.lookup(item,
825-
'itemCategory',
826-
'categoryCode') != 'port_speed':
820+
if utils.lookup(item, 'itemCategory', 'categoryCode') != 'port_speed':
827821
continue
828822

829823
# Check for correct capacity and if the item matches private only
@@ -838,7 +832,7 @@ def _get_port_speed_price_id(items, port_speed, no_public, location):
838832

839833
return price['id']
840834

841-
raise SoftLayer.SoftLayerError(
835+
raise SoftLayerError(
842836
"Could not find valid price for port speed: '%s'" % port_speed)
843837

844838

@@ -887,7 +881,7 @@ def _get_location(package, location):
887881
if region['location']['location']['name'] == location:
888882
return region
889883

890-
raise SoftLayer.SoftLayerError("Could not find valid location for: '%s'" % location)
884+
raise SoftLayerError("Could not find valid location for: '%s'" % location)
891885

892886

893887
def _get_preset_id(package, size):
@@ -896,4 +890,4 @@ def _get_preset_id(package, size):
896890
if preset['keyName'] == size or preset['id'] == size:
897891
return preset['id']
898892

899-
raise SoftLayer.SoftLayerError("Could not find valid size for: '%s'" % size)
893+
raise SoftLayerError("Could not find valid size for: '%s'" % size)

SoftLayer/managers/metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
:license: MIT, see LICENSE for more details.
77
"""
8-
import SoftLayer
8+
from SoftLayer.API import BaseClient
99
from SoftLayer import consts
1010
from SoftLayer import exceptions
1111
from SoftLayer import transports
@@ -66,7 +66,7 @@ def __init__(self, client=None, timeout=5):
6666
timeout=timeout,
6767
endpoint_url=consts.API_PRIVATE_ENDPOINT_REST,
6868
)
69-
client = SoftLayer.BaseClient(transport=transport)
69+
client = BaseClient(transport=transport)
7070

7171
self.client = client
7272

SoftLayer/managers/vs_capacity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"""
88

99
import logging
10-
import SoftLayer
1110

11+
from SoftLayer.exceptions import SoftLayerError
1212
from SoftLayer.managers import ordering
1313
from SoftLayer.managers.vs import VSManager
1414
from SoftLayer import utils
@@ -144,7 +144,7 @@ def create_guest(self, capacity_id, test, guest_object):
144144
capacity_flavor = capacity['instances'][0]['billingItem']['item']['keyName']
145145
flavor = _flavor_string(capacity_flavor, guest_object['primary_disk'])
146146
except KeyError:
147-
raise SoftLayer.SoftLayerError("Unable to find capacity Flavor.")
147+
raise SoftLayerError("Unable to find capacity Flavor.")
148148

149149
guest_object['flavor'] = flavor
150150
guest_object['datacenter'] = capacity['backendRouter']['datacenter']['name']

0 commit comments

Comments
 (0)