Skip to content

Commit f67d25f

Browse files
committed
Refactor Managers
* Moves managers to SoftLayer.managers * Moves manager tests to SoftLayer.tests.managers * Adds missing manager imports so that all managers are exposed as SoftLayer.ManagerClass * Adds missing hardware manager to the docs * Adds Firewall Manager Test * Renames capital manager modules to lowercase * Moves manager exceptions to SoftLayer.exceptions * Adds a couple missing module doc blocks
1 parent a0dcea2 commit f67d25f

34 files changed

Lines changed: 225 additions & 170 deletions

SoftLayer/CLI/modules/cci.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from os import linesep
2626
import os.path
2727

28-
from SoftLayer.CCI import CCIManager
28+
from SoftLayer import CCIManager
2929
from SoftLayer.CLI import (
3030
CLIRunnable, Table, no_going_back, confirm, mb_to_gb, listing,
3131
FormattedItem)
@@ -693,7 +693,7 @@ def execute(cls, client, args):
693693

694694
@staticmethod
695695
def dns_sync(client, args):
696-
from SoftLayer.DNS import DNSManager, DNSZoneNotFound
696+
from SoftLayer import DNSManager, DNSZoneNotFound
697697
dns = DNSManager(client)
698698
cci = CCIManager(client)
699699

SoftLayer/CLI/modules/dns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# :license: BSD, see LICENSE for more details.
1818

1919
from SoftLayer.CLI import CLIRunnable, no_going_back, Table, CLIAbort
20-
from SoftLayer.DNS import DNSManager, DNSZoneNotFound
20+
from SoftLayer import DNSManager, DNSZoneNotFound
2121

2222

2323
class DumpZone(CLIRunnable):

SoftLayer/CLI/modules/firewall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from SoftLayer.CLI import CLIRunnable, Table, listing
1313
from SoftLayer.CLI.helpers import blank
14-
from SoftLayer.firewall import FirewallManager
14+
from SoftLayer import FirewallManager
1515

1616

1717
class FWList(CLIRunnable):

SoftLayer/CLI/modules/hardware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from SoftLayer.CLI.helpers import (
1616
CLIRunnable, Table, FormattedItem, NestedDict, CLIAbort, blank, listing,
1717
gb, no_going_back)
18-
from SoftLayer.hardware import HardwareManager
18+
from SoftLayer import HardwareManager
1919

2020

2121
def resolve_id(manager, identifier):

SoftLayer/CLI/modules/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# :copyright: (c) 2013, SoftLayer Technologies, Inc. All rights reserved.
2424
# :license: BSD, see LICENSE for more details.
2525

26-
from SoftLayer.metadata import MetadataManager
26+
from SoftLayer import MetadataManager
2727
from SoftLayer.CLI import CLIRunnable, Table, listing, CLIAbort
2828

2929

SoftLayer/CLI/modules/ssl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from SoftLayer.CLI.helpers import CLIRunnable, no_going_back, Table, CLIAbort
1818
from SoftLayer.CLI.helpers import blank
19-
from SoftLayer.SSL import SSLManager
19+
from SoftLayer import SSLManager
2020

2121

2222
class ListCerts(CLIRunnable):

SoftLayer/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818

1919
from API import (
2020
Client, BasicAuthentication, API_PUBLIC_ENDPOINT, API_PRIVATE_ENDPOINT)
21-
from DNS import DNSManager
22-
from CCI import CCIManager
23-
from metadata import MetadataManager
24-
from hardware import HardwareManager
21+
from managers import * # NOQA
2522
from SoftLayer.exceptions import * # NOQA
2623

2724
__title__ = 'SoftLayer'
@@ -30,5 +27,4 @@
3027
__license__ = 'The BSD License'
3128
__copyright__ = 'Copyright 2013 SoftLayer Technologies, Inc.'
3229
__all__ = ['Client', 'BasicAuthentication', 'SoftLayerError',
33-
'SoftLayerAPIError', 'API_PUBLIC_ENDPOINT', 'API_PRIVATE_ENDPOINT',
34-
'DNSManager', 'CCIManager', 'MetadataManager', 'HardwareManager']
30+
'SoftLayerAPIError', 'API_PUBLIC_ENDPOINT', 'API_PRIVATE_ENDPOINT']

SoftLayer/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@ class InvalidMethodParameters(ServerError):
7878

7979
class InternalError(ServerError):
8080
pass
81+
82+
83+
class DNSZoneNotFound(SoftLayerError):
84+
pass

SoftLayer/managers/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
SoftLayer.managers
3+
~~~~~~~~~~~~~~~~~~
4+
Managers mask out a lot of the complexities of using the API into classes
5+
that provide a simpler interface to various services. These are
6+
higher-level interfaces to the SoftLayer API.
7+
8+
:copyright: (c) 2013, SoftLayer Technologies, Inc. All rights reserved.
9+
:license: BSD, see LICENSE for more details.
10+
"""
11+
from SoftLayer.managers.cci import CCIManager
12+
from SoftLayer.managers.dns import DNSManager
13+
from SoftLayer.managers.firewall import FirewallManager
14+
from SoftLayer.managers.hardware import HardwareManager
15+
from SoftLayer.managers.metadata import MetadataManager
16+
from SoftLayer.managers.ssl import SSLManager
17+
18+
__all__ = ['CCIManager', 'DNSManager', 'FirewallManager', 'HardwareManager',
19+
'MetadataManager', 'SSLManager']
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,9 @@
1010
from time import sleep
1111
from itertools import repeat
1212

13-
from SoftLayer.exceptions import SoftLayerError
1413
from SoftLayer.utils import NestedDict, query_filter, IdentifierMixin
1514

1615

17-
class CCICreateMissingRequired(SoftLayerError):
18-
def __init__(self):
19-
self.message = "cpu, memory, hostname, and domain are required"
20-
21-
22-
class CCICreateMutuallyExclusive(SoftLayerError):
23-
def __init__(self, *args):
24-
self.message = "Can only specify one of:", ','.join(args)
25-
26-
2716
class CCIManager(IdentifierMixin, object):
2817
""" Manage CCIs """
2918
def __init__(self, client):
@@ -194,11 +183,12 @@ def _generate_create_dict(
194183
]
195184

196185
if not all(required):
197-
raise CCICreateMissingRequired()
186+
raise ValueError("cpu, memory, hostname, and domain are required")
198187

199188
for me in mutually_exclusive:
200189
if all(me.values()):
201-
raise CCICreateMutuallyExclusive(*me.keys())
190+
raise ValueError(
191+
'Can only specify one of: %s' % (','.join(me.keys())))
202192

203193
data = {
204194
"startCpus": int(cpus),

0 commit comments

Comments
 (0)