Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a few PEP8 compliance issues, and removed unused variables.

git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1212975 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 3cda3bed2f3be776575e506dc735357204618a47 1 parent cca04c7
Hutson Betts authored
Showing with 286 additions and 278 deletions.
  1. +5 −3 demos/compute_demo.py
  2. +3 −3 example_compute.py
  3. +1 −0  example_loadbalancer.py
  4. +2 −1  libcloud/common/aws.py
  5. +15 −11 libcloud/common/base.py
  6. +5 −1 libcloud/common/cloudstack.py
  7. +0 −4 libcloud/common/gandi.py
  8. +6 −7 libcloud/common/gogrid.py
  9. +10 −10 libcloud/common/linode.py
  10. +3 −3 libcloud/compute/base.py
  11. +1 −1  libcloud/compute/deployment.py
  12. +9 −10 libcloud/compute/drivers/bluebox.py
  13. +29 −29 libcloud/compute/drivers/brightbox.py
  14. +47 −38 libcloud/compute/drivers/cloudsigma.py
  15. +2 −4 libcloud/compute/drivers/cloudstack.py
  16. +3 −3 libcloud/compute/drivers/dreamhost.py
  17. +31 −31 libcloud/compute/drivers/dummy.py
  18. +5 −8 libcloud/compute/drivers/ecp.py
  19. +1 −2  libcloud/compute/drivers/gandi.py
  20. +10 −11 libcloud/compute/drivers/gogrid.py
  21. +19 −17 libcloud/compute/drivers/ibm_sbc.py
  22. +17 −9 libcloud/compute/drivers/linode.py
  23. +6 −6 libcloud/compute/drivers/rimuhosting.py
  24. +2 −2 libcloud/compute/drivers/slicehost.py
  25. +29 −29 libcloud/compute/drivers/softlayer.py
  26. +0 −1  libcloud/compute/drivers/voxel.py
  27. +1 −1  libcloud/compute/ssh.py
  28. +2 −1  libcloud/compute/types.py
  29. +3 −4 libcloud/dns/drivers/linode.py
  30. +6 −5 libcloud/httplib_ssl.py
  31. +0 −1  libcloud/loadbalancer/__init__.py
  32. +2 −3 libcloud/loadbalancer/drivers/cloudstack.py
  33. +3 −1 libcloud/pricing.py
  34. +1 −1  libcloud/storage/base.py
  35. +1 −2  libcloud/storage/drivers/atmos.py
  36. +2 −3 libcloud/storage/drivers/google_storage.py
  37. +0 −3  libcloud/utils/__init__.py
  38. +3 −7 setup.py
  39. +1 −1  test/loadbalancer/test_gogrid.py
  40. +0 −1  test/test_pricing.py
View
8 demos/compute_demo.py
@@ -31,7 +31,8 @@
import sys
# Add parent dir of this file's dir to sys.path (OS-agnostically)
-sys.path.append(os.path.normpath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
+sys.path.append(os.path.normpath(os.path.join(os.path.dirname(__file__),
+ os.path.pardir)))
from libcloud.common.types import InvalidCredsError
from libcloud.compute.types import Provider
@@ -39,6 +40,7 @@
from pprint import pprint
+
def get_demo_driver(provider_name='RACKSPACE', *args, **kwargs):
"""An easy way to play with a driver interactively.
@@ -77,8 +79,8 @@ def get_demo_driver(provider_name='RACKSPACE', *args, **kwargs):
return DriverClass(*args, **kwargs)
except InvalidCredsError:
raise InvalidCredsError(
- 'valid values should be put in secrets.py'
- )
+ 'valid values should be put in secrets.py')
+
def main(argv):
"""Main Compute Demo
View
6 example_compute.py
@@ -20,11 +20,11 @@
Slicehost = get_driver(Provider.SLICEHOST)
Rackspace = get_driver(Provider.RACKSPACE)
-drivers = [ EC2('access key id', 'secret key'),
+drivers = [EC2('access key id', 'secret key'),
Slicehost('api key'),
- Rackspace('username', 'api key') ]
+ Rackspace('username', 'api key')]
-nodes = [ driver.list_nodes() for driver in drivers ]
+nodes = [driver.list_nodes() for driver in drivers]
print(nodes)
# [ <Node: provider=Amazon, status=RUNNING, name=bob, ip=1.2.3.4.5>,
View
1  example_loadbalancer.py
@@ -22,6 +22,7 @@
from libcloud.loadbalancer.types import Provider, State
from libcloud.loadbalancer.providers import get_driver
+
def main():
Rackspace = get_driver(Provider.RACKSPACE_US)
View
3  libcloud/common/aws.py
@@ -15,4 +15,5 @@
from libcloud.common.base import XmlResponse
-class AWSBaseResponse(XmlResponse): pass
+class AWSBaseResponse(XmlResponse):
+ pass
View
26 libcloud/common/base.py
@@ -136,9 +136,9 @@ def parse_body(self):
return self.body
try:
- body = ET.XML(self.body)
+ body = ET.XML(self.body)
except:
- raise MalformedResponseError("Failed to parse XML",
+ raise MalformedResponseError("Failed to parse XML",
body=self.body,
driver=self.connection.driver)
return body
@@ -156,7 +156,6 @@ def __init__(self, connection):
self._reason = None
self.connection = connection
-
@property
def response(self):
if not self._response:
@@ -208,10 +207,12 @@ def _log_response(self, r):
for h in r.getheaders():
ht += "%s: %s\r\n" % (h[0].title(), h[1])
ht += "\r\n"
+
# this is evil. laugh with me. ha arharhrhahahaha
class fakesock:
def __init__(self, s):
self.s = s
+
def makefile(self, mode, foo):
return StringIO(self.s)
rr = r
@@ -261,11 +262,12 @@ def getresponse(self):
def request(self, method, url, body=None, headers=None):
headers.update({'X-LC-Request-ID': str(id(self))})
if self.log is not None:
- pre = "# -------- begin %d request ----------\n" % id(self)
+ pre = "# -------- begin %d request ----------\n" % id(self)
self.log.write(pre +
self._log_curl(method, url, body, headers) + "\n")
self.log.flush()
- return LibcloudHTTPSConnection.request(self, method, url, body, headers)
+ return LibcloudHTTPSConnection.request(self, method, url, body,
+ headers)
class LoggingHTTPConnection(LoggingConnection, LibcloudHTTPConnection):
"""
@@ -283,7 +285,7 @@ def getresponse(self):
def request(self, method, url, body=None, headers=None):
headers.update({'X-LC-Request-ID': str(id(self))})
if self.log is not None:
- pre = "# -------- begin %d request ----------\n" % id(self)
+ pre = "# -------- begin %d request ----------\n" % id(self)
self.log.write(pre +
self._log_curl(method, url, body, headers) + "\n")
self.log.flush()
@@ -326,7 +328,8 @@ def __init__(self, secure=True, host=None, port=None, url=None):
self.port = 80
if url:
- (self.host, self.port, self.secure, self.request_path) = self._tuple_from_url(url)
+ (self.host, self.port, self.secure,
+ self.request_path) = self._tuple_from_url(url)
def set_context(self, context):
self.context = context
@@ -334,7 +337,8 @@ def set_context(self, context):
def _tuple_from_url(self, url):
secure = 1
port = None
- scheme, netloc, request_path, param, query, fragment = urlparse.urlparse(url)
+ (scheme, netloc, request_path, param,
+ query, fragment) = urlparse.urlparse(url)
if scheme not in ['http', 'https']:
raise LibcloudError('Invalid scheme: %s in url %s' % (scheme, url))
@@ -356,7 +360,7 @@ def _tuple_from_url(self, url):
return (host, port, secure, request_path)
- def connect(self, host=None, port=None, base_url = None):
+ def connect(self, host=None, port=None, base_url=None):
"""
Establish a connection with the API server.
@@ -511,7 +515,7 @@ def request(self,
return response
def morph_action_hook(self, action):
- return self.request_path + action
+ return self.request_path + action
def add_default_params(self, params):
"""
@@ -570,7 +574,7 @@ def async_request(self, action, params=None, data='', headers=None,
"""
Perform an 'async' request to the specified path. Keep in mind that
this function is *blocking* and 'async' in this case means that the
- hit URL only returns a job ID which is the periodically polled until
+ hit URL only returns a job ID which is the periodically polled until
the job has completed.
This function works like this:
View
6 libcloud/common/cloudstack.py
@@ -24,7 +24,10 @@
from libcloud.common.base import JsonResponse
from libcloud.common.types import MalformedResponseError
-class CloudStackResponse(JsonResponse): pass
+
+class CloudStackResponse(JsonResponse):
+ pass
+
class CloudStackConnection(ConnectionUserAndKey, PollingConnection):
responseCls = CloudStackResponse
@@ -98,6 +101,7 @@ def _sync_request(self, command, **kwargs):
result = result.object[command]
return result
+
class CloudStackDriverMixIn(object):
host = None
path = None
View
4 libcloud/common/gandi.py
@@ -22,11 +22,7 @@
from libcloud.utils.py3 import xmlrpclib
from libcloud.utils.py3 import b
-import libcloud
from libcloud.common.base import ConnectionKey
-from libcloud.compute.types import Provider, NodeState
-from libcloud.compute.base import NodeDriver, Node, \
- NodeLocation, NodeSize, NodeImage
# Global constants
API_VERSION = '2.0'
View
13 libcloud/common/gogrid.py
@@ -24,7 +24,7 @@
from libcloud.compute.base import NodeLocation
HOST = 'api.gogrid.com'
-PORTS_BY_SECURITY = { True: 443, False: 80 }
+PORTS_BY_SECURITY = {True: 443, False: 80}
API_VERSION = '1.8'
__all__ = ["GoGridResponse",
@@ -36,8 +36,8 @@
class GoGridResponse(JsonResponse):
def __init__(self, *args, **kwargs):
- self.driver = BaseGoGridDriver
- super(GoGridResponse, self).__init__(*args, **kwargs)
+ self.driver = BaseGoGridDriver
+ super(GoGridResponse, self).__init__(*args, **kwargs)
def success(self):
if self.status == 403:
@@ -76,7 +76,7 @@ def add_default_params(self, params):
def get_signature(self, key, secret):
""" create sig from md5 of key + secret + time """
- m = hashlib.md5(b(key+secret+str(int(time.time()))))
+ m = hashlib.md5(b(key + secret + str(int(time.time()))))
return m.hexdigest()
class GoGridIpAddress(object):
@@ -111,8 +111,8 @@ def _to_ip(self, element):
return ip
def _to_ips(self, object):
- return [ self._to_ip(el)
- for el in object['list'] ]
+ return [self._to_ip(el)
+ for el in object['list']]
def _to_location(self, element):
location = NodeLocation(id=element['id'],
@@ -125,7 +125,6 @@ def _to_locations(self, object):
return [self._to_location(el)
for el in object['list']]
-
def ex_list_ips(self, **kwargs):
"""Return list of IP addresses assigned to
the account.
View
20 libcloud/common/linode.py
@@ -29,16 +29,16 @@
API_ROOT = '/'
# Constants that map a RAM figure to a PlanID (updated 6/28/10)
-LINODE_PLAN_IDS = {512:'1',
- 768:'2',
- 1024:'3',
- 1536:'4',
- 2048:'5',
- 4096:'6',
- 8192:'7',
- 12288:'8',
- 16384:'9',
- 20480:'10'}
+LINODE_PLAN_IDS = {512: '1',
+ 768: '2',
+ 1024: '3',
+ 1536: '4',
+ 2048: '5',
+ 4096: '6',
+ 8192: '7',
+ 12288: '8',
+ 16384: '9',
+ 20480: '10'}
class LinodeException(Exception):
View
6 libcloud/compute/base.py
@@ -375,9 +375,9 @@ class NodeDriver(BaseDriver):
def __init__(self, key, secret=None, secure=True, host=None, port=None,
api_version=None):
- super(NodeDriver, self).__init__(key=key, secret=secret, secure=secure,
- host=host, port=port,
- api_version=api_version)
+ super(NodeDriver, self).__init__(key=key, secret=secret, secure=secure,
+ host=host, port=port,
+ api_version=api_version)
def create_node(self, **kwargs):
"""Create a new node instance.
View
2  libcloud/compute/deployment.py
@@ -120,7 +120,7 @@ class MultiStepDeployment(Deployment):
"""
Runs a chain of Deployment steps.
"""
- def __init__(self, add = None):
+ def __init__(self, add=None):
"""
@type add: C{list}
@keyword add: Deployment steps to add.
View
19 libcloud/compute/drivers/bluebox.py
@@ -32,7 +32,6 @@
from libcloud.common.base import JsonResponse, ConnectionUserAndKey
from libcloud.compute.providers import Provider
from libcloud.compute.types import NodeState, InvalidCredsError
-from libcloud.common.types import MalformedResponseError
from libcloud.compute.base import Node, NodeDriver
from libcloud.compute.base import NodeSize, NodeImage, NodeLocation
from libcloud.compute.base import NodeAuthPassword, NodeAuthSSHKey
@@ -76,11 +75,11 @@
RAM_PER_CPU = 2048
-NODE_STATE_MAP = { 'queued': NodeState.PENDING,
- 'building': NodeState.PENDING,
- 'running': NodeState.RUNNING,
- 'error': NodeState.TERMINATED,
- 'unknown': NodeState.UNKNOWN }
+NODE_STATE_MAP = {'queued': NodeState.PENDING,
+ 'building': NodeState.PENDING,
+ 'running': NodeState.RUNNING,
+ 'error': NodeState.TERMINATED,
+ 'unknown': NodeState.UNKNOWN}
class BlueboxResponse(JsonResponse):
def parse_error(self):
@@ -137,7 +136,7 @@ def list_sizes(self, location=None):
sizes = []
for key, values in list(BLUEBOX_INSTANCE_TYPES.items()):
attributes = copy.deepcopy(values)
- attributes.update({ 'price': self._get_size_price(size_id=key) })
+ attributes.update({'price': self._get_size_price(size_id=key)})
sizes.append(BlueboxNodeSize(driver=self.connection.driver,
**attributes))
@@ -147,12 +146,12 @@ def list_images(self, location=None):
result = self.connection.request('/api/block_templates.json')
images = []
for image in result.object:
- images.extend([self._to_image(image)])
+ images.extend([self._to_image(image)])
return images
def create_node(self, **kwargs):
- headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
+ headers = {'Content-Type': 'application/x-www-form-urlencoded'}
size = kwargs["size"]
name = kwargs['name']
@@ -213,7 +212,7 @@ def _to_node(self, vm):
n = Node(id=vm['id'],
name=vm['hostname'],
state=state,
- public_ips=[ ip['address'] for ip in vm['ips'] ],
+ public_ips=[ip['address'] for ip in vm['ips']],
private_ips=[],
extra={'storage':vm['storage'], 'cpu':vm['cpu']},
driver=self.connection.driver)
View
58 libcloud/compute/drivers/brightbox.py
@@ -104,25 +104,25 @@ class BrightboxNodeDriver(NodeDriver):
type = Provider.BRIGHTBOX
name = 'Brightbox'
- NODE_STATE_MAP = { 'creating': NodeState.PENDING,
- 'active': NodeState.RUNNING,
- 'inactive': NodeState.UNKNOWN,
- 'deleting': NodeState.UNKNOWN,
- 'deleted': NodeState.TERMINATED,
- 'failed': NodeState.UNKNOWN,
- 'unavailable': NodeState.UNKNOWN }
+ NODE_STATE_MAP = {'creating': NodeState.PENDING,
+ 'active': NodeState.RUNNING,
+ 'inactive': NodeState.UNKNOWN,
+ 'deleting': NodeState.UNKNOWN,
+ 'deleted': NodeState.TERMINATED,
+ 'failed': NodeState.UNKNOWN,
+ 'unavailable': NodeState.UNKNOWN}
def _to_node(self, data):
return Node(
- id = data['id'],
- name = data['name'],
- state = self.NODE_STATE_MAP[data['status']],
- public_ips = list(map(lambda cloud_ip: cloud_ip['public_ip'],
+ id=data['id'],
+ name=data['name'],
+ state=self.NODE_STATE_MAP[data['status']],
+ public_ips=list(map(lambda cloud_ip: cloud_ip['public_ip'],
data['cloud_ips'])),
- private_ips = list(map(lambda interface: interface['ipv4_address'],
+ private_ips=list(map(lambda interface: interface['ipv4_address'],
data['interfaces'])),
- driver = self.connection.driver,
- extra = {
+ driver=self.connection.driver,
+ extra={
'status': data['status'],
'interfaces': data['interfaces']
}
@@ -130,10 +130,10 @@ def _to_node(self, data):
def _to_image(self, data):
return NodeImage(
- id = data['id'],
- name = data['name'],
- driver = self,
- extra = {
+ id=data['id'],
+ name=data['name'],
+ driver=self,
+ extra={
'description': data['description'],
'arch': data['arch']
}
@@ -141,21 +141,21 @@ def _to_image(self, data):
def _to_size(self, data):
return NodeSize(
- id = data['id'],
- name = data['name'],
- ram = data['ram'],
- disk = data['disk_size'],
- bandwidth = 0,
- price = 0,
- driver = self
+ id=data['id'],
+ name=data['name'],
+ ram=data['ram'],
+ disk=data['disk_size'],
+ bandwidth=0,
+ price=0,
+ driver=self
)
def _to_location(self, data):
return NodeLocation(
- id = data['id'],
- name = data['handle'],
- country = 'GB',
- driver = self
+ id=data['id'],
+ name=data['handle'],
+ country='GB',
+ driver=self
)
def _post(self, path, data={}):
View
85 libcloud/compute/drivers/cloudsigma.py
@@ -137,6 +137,7 @@
# Default timeout (in seconds) for the drive imaging process
IMAGING_TIMEOUT = 20 * 60
+
class CloudSigmaException(Exception):
def __str__(self):
return self.args[0]
@@ -144,10 +145,12 @@ def __str__(self):
def __repr__(self):
return "<CloudSigmaException '%s'>" % (self.args[0])
+
class CloudSigmaInsufficientFundsException(Exception):
def __repr__(self):
return "<CloudSigmaInsufficientFundsException '%s'>" % (self.args[0])
+
class CloudSigmaResponse(Response):
def success(self):
if self.status == 401:
@@ -164,6 +167,7 @@ def parse_body(self):
def parse_error(self):
return 'Error: %s' % (self.body.replace('errors:', '').strip())
+
class CloudSigmaNodeSize(NodeSize):
def __init__(self, id, name, cpu, ram, disk, bandwidth, price, driver):
self.id = id
@@ -181,6 +185,7 @@ def __repr__(self):
% (self.id, self.name, self.cpu, self.ram, self.disk, self.bandwidth,
self.price, self.driver.name))
+
class CloudSigmaBaseConnection(ConnectionUserAndKey):
host = API_ENDPOINTS[DEFAULT_ENDPOINT]['host']
responseCls = CloudSigmaResponse
@@ -194,6 +199,7 @@ def add_default_headers(self, headers):
return headers
+
class CloudSigmaBaseNodeDriver(NodeDriver):
type = Provider.CLOUDSIGMA
name = 'CloudSigma'
@@ -238,37 +244,37 @@ def destroy_node(self, node):
if not stopped:
raise CloudSigmaException('Could not stop node with id %s' % (node.id))
- response = self.connection.request(action = '/servers/%s/destroy' % (node.id),
- method = 'POST')
+ response = self.connection.request(action='/servers/%s/destroy' % (node.id),
+ method='POST')
return response.status == 204
def list_images(self, location=None):
"""
Return a list of available standard images (this call might take up to 15 seconds to return).
"""
- response = self.connection.request(action = '/drives/standard/info').object
+ response = self.connection.request(action='/drives/standard/info').object
images = []
for value in response:
if value.get('type'):
if value['type'] == 'disk':
- image = NodeImage(id = value['drive'], name = value['name'], driver = self.connection.driver,
- extra = {'size': value['size']})
+ image = NodeImage(id=value['drive'], name=value['name'], driver=self.connection.driver,
+ extra={'size': value['size']})
images.append(image)
return images
- def list_sizes(self, location = None):
+ def list_sizes(self, location=None):
"""
Return a list of available node sizes.
"""
sizes = []
for key, value in INSTANCE_TYPES.items():
- size = CloudSigmaNodeSize(id = value['id'], name = value['name'],
- cpu = value['cpu'], ram = value['memory'],
- disk = value['disk'], bandwidth = value['bandwidth'],
- price = self._get_size_price(size_id=key),
- driver = self.connection.driver)
+ size = CloudSigmaNodeSize(id=value['id'], name=value['name'],
+ cpu=value['cpu'], ram=value['memory'],
+ disk=value['disk'], bandwidth=value['bandwidth'],
+ price=self._get_size_price(size_id=key),
+ driver=self.connection.driver)
sizes.append(size)
return sizes
@@ -277,7 +283,7 @@ def list_nodes(self):
"""
Return a list of nodes.
"""
- response = self.connection.request(action = '/servers/info').object
+ response = self.connection.request(action='/servers/info').object
nodes = []
for data in response:
@@ -326,18 +332,18 @@ def create_node(self, **kwargs):
'size': '%sG' % (kwargs['size'].disk),
'driveType': drive_type})
- response = self.connection.request(action = '/drives/%s/clone' % image.id, data = dict2str(drive_data),
- method = 'POST').object
+ response = self.connection.request(action='/drives/%s/clone' % image.id, data=dict2str(drive_data),
+ method='POST').object
if not response:
raise CloudSigmaException('Drive creation failed')
drive_uuid = response[0]['drive']
- response = self.connection.request(action = '/drives/%s/info' % (drive_uuid)).object
+ response = self.connection.request(action='/drives/%s/info' % (drive_uuid)).object
imaging_start = time.time()
while 'imaging' in response[0]:
- response = self.connection.request(action = '/drives/%s/info' % (drive_uuid)).object
+ response = self.connection.request(action='/drives/%s/info' % (drive_uuid)).object
elapsed_time = time.time() - imaging_start
if 'imaging' in response[0] and elapsed_time >= IMAGING_TIMEOUT:
raise CloudSigmaException('Drive imaging timed out')
@@ -351,11 +357,11 @@ def create_node(self, **kwargs):
if vnc_password:
node_data.update({'vnc:ip': 'auto', 'vnc:password': vnc_password})
- response = self.connection.request(action = '/servers/create', data = dict2str(node_data),
- method = 'POST').object
+ response = self.connection.request(action='/servers/create', data=dict2str(node_data),
+ method='POST').object
if not isinstance(response, list):
- response = [ response ]
+ response = [response]
node = self._to_node(response[0])
if node is None:
@@ -397,7 +403,7 @@ def ex_static_ip_list(self):
"""
Return a list of available static IP addresses.
"""
- response = self.connection.request(action = '/resources/ip/list', method = 'GET')
+ response = self.connection.request(action='/resources/ip/list', method='GET')
if response.status != 200:
raise CloudSigmaException('Could not retrieve IP list')
@@ -409,7 +415,7 @@ def ex_drives_list(self):
"""
Return a list of all the available drives.
"""
- response = self.connection.request(action = '/drives/info', method = 'GET')
+ response = self.connection.request(action='/drives/info', method='GET')
result = str2dicts(response.body)
return result
@@ -418,7 +424,7 @@ def ex_static_ip_create(self):
"""
Create a new static IP address.
"""
- response = self.connection.request(action = '/resources/ip/create', method = 'GET')
+ response = self.connection.request(action='/resources/ip/create', method='GET')
result = str2dicts(response.body)
return result
@@ -427,7 +433,7 @@ def ex_static_ip_destroy(self, ip_address):
"""
Destroy a static IP address.
"""
- response = self.connection.request(action = '/resources/ip/%s/destroy' % (ip_address), method = 'GET')
+ response = self.connection.request(action='/resources/ip/%s/destroy' % (ip_address), method='GET')
return response.status == 204
@@ -436,11 +442,10 @@ def ex_drive_destroy(self, drive_uuid):
Destroy a drive with a specified uuid.
If the drive is currently mounted an exception is thrown.
"""
- response = self.connection.request(action = '/drives/%s/destroy' % (drive_uuid), method = 'POST')
+ response = self.connection.request(action='/drives/%s/destroy' % (drive_uuid), method='POST')
return response.status == 204
-
def ex_set_node_configuration(self, node, **kwargs):
"""
Update a node configuration.
@@ -464,8 +469,8 @@ def ex_set_node_configuration(self, node, **kwargs):
if invalid_keys:
raise CloudSigmaException('Invalid configuration key specified: %s' % (',' .join(invalid_keys)))
- response = self.connection.request(action = '/servers/%s/set' % (node.id), data = dict2str(kwargs),
- method = 'POST')
+ response = self.connection.request(action='/servers/%s/set' % (node.id), data=dict2str(kwargs),
+ method='POST')
return (response.status == 200 and response.body != '')
@@ -473,8 +478,8 @@ def ex_start_node(self, node):
"""
Start a node.
"""
- response = self.connection.request(action = '/servers/%s/start' % (node.id),
- method = 'POST')
+ response = self.connection.request(action='/servers/%s/start' % (node.id),
+ method='POST')
return response.status == 200
@@ -482,8 +487,8 @@ def ex_stop_node(self, node):
"""
Stop (shutdown) a node.
"""
- response = self.connection.request(action = '/servers/%s/stop' % (node.id),
- method = 'POST')
+ response = self.connection.request(action='/servers/%s/stop' % (node.id),
+ method='POST')
return response.status == 204
def ex_shutdown_node(self, node):
@@ -496,8 +501,8 @@ def ex_destroy_drive(self, drive_uuid):
"""
Destroy a drive.
"""
- response = self.connection.request(action = '/drives/%s/destroy' % (drive_uuid),
- method = 'POST')
+ response = self.connection.request(action='/drives/%s/destroy' % (drive_uuid),
+ method='POST')
return response.status == 204
def _to_node(self, data):
@@ -520,7 +525,7 @@ def _to_node(self, data):
public_ips = [data['nic:0:dhcp']]
extra = {}
- extra_keys = [ ('cpu', 'int'), ('smp', 'auto'), ('mem', 'int'), ('status', 'str') ]
+ extra_keys = [('cpu', 'int'), ('smp', 'auto'), ('mem', 'int'), ('status', 'str')]
for key, value_type in extra_keys:
if key in data:
value = data[key]
@@ -538,9 +543,9 @@ def _to_node(self, data):
if 'vnc:ip' in data and 'vnc:password' in data:
extra.update({'vnc_ip': data['vnc:ip'], 'vnc_password': data['vnc:password']})
- node = Node(id = data['server'], name = data['name'], state = state,
- public_ips = public_ips, private_ips = None, driver = self.connection.driver,
- extra = extra)
+ node = Node(id=data['server'], name=data['name'], state=state,
+ public_ips=public_ips, private_ips=None, driver=self.connection.driver,
+ extra=extra)
return node
return None
@@ -555,17 +560,19 @@ def _get_node(self, node_id):
return node[0]
def _get_node_info(self, node):
- response = self.connection.request(action = '/servers/%s/info' % (node.id))
+ response = self.connection.request(action='/servers/%s/info' % (node.id))
result = str2dicts(response.body)
return result[0]
+
class CloudSigmaZrhConnection(CloudSigmaBaseConnection):
"""
Connection class for the CloudSigma driver for the Zurich end-point
"""
host = API_ENDPOINTS[DEFAULT_ENDPOINT]['host']
+
class CloudSigmaZrhNodeDriver(CloudSigmaBaseNodeDriver):
"""
CloudSigma node driver for the Zurich end-point
@@ -573,12 +580,14 @@ class CloudSigmaZrhNodeDriver(CloudSigmaBaseNodeDriver):
connectionCls = CloudSigmaZrhConnection
api_name = 'cloudsigma_zrh'
+
class CloudSigmaLvsConnection(CloudSigmaBaseConnection):
"""
Connection class for the CloudSigma driver for the Las Vegas end-point
"""
host = API_ENDPOINTS['lvs']['host']
+
class CloudSigmaLvsNodeDriver(CloudSigmaBaseNodeDriver):
"""
CloudSigma node driver for the Las Vegas end-point
View
6 libcloud/compute/drivers/cloudstack.py
@@ -14,11 +14,10 @@
# limitations under the License.
from libcloud.compute.providers import Provider
-from libcloud.common.cloudstack import CloudStackConnection, \
- CloudStackDriverMixIn
+from libcloud.common.cloudstack import CloudStackDriverMixIn
from libcloud.compute.base import Node, NodeDriver, NodeImage, NodeLocation, \
NodeSize
-from libcloud.compute.types import DeploymentError, NodeState
+from libcloud.compute.types import NodeState
class CloudStackNode(Node):
"Subclass of Node so we can expose our extension methods."
@@ -202,7 +201,6 @@ def create_node(self, name, size, image, location=None, **kwargs):
if location is None:
location = self.list_locations()[0]
-
network_id = kwargs.pop('network_id', None)
if network_id is None:
networks = self._sync_request('listNetworks')
View
6 libcloud/compute/drivers/dreamhost.py
@@ -239,6 +239,6 @@ def _to_node(self, data):
private_ips = [],
driver = self.connection.driver,
extra = {
- 'current_size' : data['memory_mb'],
- 'account_id' : data['account_id'],
- 'type' : data['type']})
+ 'current_size': data['memory_mb'],
+ 'account_id': data['account_id'],
+ 'type': data['type']})
View
62 libcloud/compute/drivers/dummy.py
@@ -67,40 +67,40 @@ class DummyNodeDriver(NodeDriver):
def __init__(self, creds):
self.creds = creds
try:
- num = int(creds)
+ num = int(creds)
except ValueError:
- num = None
+ num = None
if num:
- self.nl = []
- startip = _ip_to_int('127.0.0.1')
- for i in range(num):
- ip = _int_to_ip(startip + i)
- self.nl.append(
- Node(id=i,
- name='dummy-%d' % (i),
- state=NodeState.RUNNING,
- public_ips=[ip],
- private_ips=[],
- driver=self,
- extra={'foo': 'bar'})
- )
+ self.nl = []
+ startip = _ip_to_int('127.0.0.1')
+ for i in range(num):
+ ip = _int_to_ip(startip + i)
+ self.nl.append(
+ Node(id=i,
+ name='dummy-%d' % (i),
+ state=NodeState.RUNNING,
+ public_ips=[ip],
+ private_ips=[],
+ driver=self,
+ extra={'foo': 'bar'})
+ )
else:
- self.nl = [
- Node(id=1,
- name='dummy-1',
- state=NodeState.RUNNING,
- public_ips=['127.0.0.1'],
- private_ips=[],
- driver=self,
- extra={'foo': 'bar'}),
- Node(id=2,
- name='dummy-2',
- state=NodeState.RUNNING,
- public_ips=['127.0.0.1'],
- private_ips=[],
- driver=self,
- extra={'foo': 'bar'}),
- ]
+ self.nl = [
+ Node(id=1,
+ name='dummy-1',
+ state=NodeState.RUNNING,
+ public_ips=['127.0.0.1'],
+ private_ips=[],
+ driver=self,
+ extra={'foo': 'bar'}),
+ Node(id=2,
+ name='dummy-2',
+ state=NodeState.RUNNING,
+ public_ips=['127.0.0.1'],
+ private_ips=[],
+ driver=self,
+ extra={'foo': 'bar'}),
+ ]
self.connection = DummyConnection(self.creds)
def get_uuid(self, unique_field=None):
View
13 libcloud/compute/drivers/ecp.py
@@ -86,9 +86,9 @@ def add_default_headers(self, headers):
#Authentication
username = self.user_id
password = self.key
- base64string = base64.encodestring(
+ base64string = base64.encodestring(
b('%s:%s' % (username, password)))[:-1]
- authheader = "Basic %s" % base64string
+ authheader = "Basic %s" % base64string
headers['Authorization']= authheader
return headers
@@ -143,7 +143,6 @@ def list_nodes(self):
#And return it
return nodes
-
def _to_node(self, vm):
"""
Turns a (json) dictionary into a Node object.
@@ -209,7 +208,6 @@ def reboot_node(self, node):
else:
time.sleep(5)
-
#Turn the VM back on.
#Black magic to make the POST requests work
d = self.connection._encode_multipart_formdata({'action':'start'})
@@ -283,7 +281,6 @@ def list_images(self, location=None):
return images
-
def list_sizes(self, location=None):
"""
Returns a list of all hardware templates
@@ -300,9 +297,9 @@ def list_sizes(self, location=None):
id = htemplate['uuid'],
name = htemplate['name'],
ram = htemplate['memory'],
- disk = 0, #Disk is independent of hardware template
- bandwidth = 0, #There is no way to keep track of bandwidth
- price = 0, #The billing system is external
+ disk = 0, # Disk is independent of hardware template.
+ bandwidth = 0, # There is no way to keep track of bandwidth.
+ price = 0, # The billing system is external.
driver = self,
))
View
3  libcloud/compute/drivers/gandi.py
@@ -94,7 +94,7 @@ def list_nodes(self):
def reboot_node(self, node):
op = self.connection.request('vm.reboot', int(node.id))
- op_res = self._wait_operation(op['id'])
+ self._wait_operation(op['id'])
vm = self.connection.request('vm.info', int(node.id))
if vm['state'] == 'running':
return True
@@ -330,7 +330,6 @@ def _to_disks(self, elements):
def ex_list_disks(self):
"""Specific method to list all disk"""
res = self.connection.request('disk.list', {})
- disks = []
return self._to_disks(res)
def ex_node_attach_disk(self, node, disk):
View
21 libcloud/compute/drivers/gogrid.py
@@ -165,18 +165,17 @@ def list_nodes(self):
res = self._server_list()
try:
- for password in self._password_list()['list']:
- try:
- passwords_map[password['server']['id']] = password['password']
- except KeyError:
- pass
+ for password in self._password_list()['list']:
+ try:
+ passwords_map[password['server']['id']] = password['password']
+ except KeyError:
+ pass
except InvalidCredsError:
- # some gogrid API keys don't have permission to access the password list.
- pass
+ # some gogrid API keys don't have permission to access the password list.
+ pass
- return [ self._to_node(el, passwords_map.get(el.get('id')))
- for el
- in res['list'] ]
+ return [self._to_node(el, passwords_map.get(el.get('id')))
+ for el in res['list']]
def reboot_node(self, node):
id = node.id
@@ -213,7 +212,7 @@ def _server_delete(self, id):
def _get_first_ip(self, location=None):
ips = self.ex_list_ips(public=True, assigned=False, location=location)
try:
- return ips[0].ip
+ return ips[0].ip
except IndexError:
raise LibcloudError('No public unassigned IPs left',
GoGridNodeDriver)
View
36 libcloud/compute/drivers/ibm_sbc.py
@@ -12,10 +12,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
"""
Driver for the IBM Developer Cloud.
"""
-import base64, urllib
+
+import base64
from libcloud.utils.py3 import urlencode
from libcloud.utils.py3 import b
@@ -67,22 +69,22 @@ class IBMNodeDriver(NodeDriver):
type = Provider.IBM
name = "IBM Developer Cloud"
- NODE_STATE_MAP = { 0: NodeState.PENDING, # New
- 1: NodeState.PENDING, # Provisioning
- 2: NodeState.TERMINATED, # Failed
- 3: NodeState.TERMINATED, # Removed
- 4: NodeState.TERMINATED, # Rejected
- 5: NodeState.RUNNING, # Active
- 6: NodeState.UNKNOWN, # Unknown
- 7: NodeState.PENDING, # Deprovisioning
- 8: NodeState.REBOOTING, # Restarting
- 9: NodeState.PENDING, # Starting
- 10: NodeState.PENDING, # Stopping
- 11: NodeState.TERMINATED,# Stopped
- 12: NodeState.PENDING, # Deprovision Pending
- 13: NodeState.PENDING, # Restart Pending
- 14: NodeState.PENDING, # Attaching
- 15: NodeState.PENDING } # Detaching
+ NODE_STATE_MAP = { 0: NodeState.PENDING, # New
+ 1: NodeState.PENDING, # Provisioning
+ 2: NodeState.TERMINATED, # Failed
+ 3: NodeState.TERMINATED, # Removed
+ 4: NodeState.TERMINATED, # Rejected
+ 5: NodeState.RUNNING, # Active
+ 6: NodeState.UNKNOWN, # Unknown
+ 7: NodeState.PENDING, # Deprovisioning
+ 8: NodeState.REBOOTING, # Restarting
+ 9: NodeState.PENDING, # Starting
+ 10: NodeState.PENDING, # Stopping
+ 11: NodeState.TERMINATED, # Stopped
+ 12: NodeState.PENDING, # Deprovision Pending
+ 13: NodeState.PENDING, # Restart Pending
+ 14: NodeState.PENDING, # Attaching
+ 15: NodeState.PENDING } # Detaching
def create_node(self, **kwargs):
"""
View
26 libcloud/compute/drivers/linode.py
@@ -33,7 +33,6 @@
import json
import itertools
-import os
import binascii
from copy import copy
@@ -229,8 +228,10 @@ def create_node(self, **kwargs):
raise LinodeException(0xFB, "Root password is too short")
# Swap size
- try: swap = 128 if "ex_swap" not in kwargs else int(kwargs["ex_swap"])
- except: raise LinodeException(0xFB, "Need an integer swap size")
+ try:
+ swap = 128 if "ex_swap" not in kwargs else int(kwargs["ex_swap"])
+ except:
+ raise LinodeException(0xFB, "Need an integer swap size")
# Root partition size
imagesize = (size.disk - swap) if "ex_rsize" not in kwargs else \
@@ -308,7 +309,8 @@ def create_node(self, **kwargs):
"Size": imagesize,
"rootPass": root,
}
- if ssh: params["rootSSHKey"] = ssh
+ if ssh:
+ params["rootSSHKey"] = ssh
data = self.connection.request(API_ROOT, params=params).objects[0]
linode["rootimage"] = data["DiskID"]
@@ -399,10 +401,14 @@ def list_locations(self):
nl = []
for dc in data:
country = None
- if "USA" in dc["LOCATION"]: country = "US"
- elif "UK" in dc["LOCATION"]: country = "GB"
- elif "JP" in dc["LOCATION"]: country = "JP"
- else: country = "??"
+ if "USA" in dc["LOCATION"]:
+ country = "US"
+ elif "UK" in dc["LOCATION"]:
+ country = "GB"
+ elif "JP" in dc["LOCATION"]:
+ country = "JP"
+ else:
+ country = "??"
nl.append(NodeLocation(dc["DATACENTERID"],
dc["LOCATION"],
country,
@@ -483,9 +489,11 @@ def _izip_longest(*args, **kwds):
http://docs.python.org/library/itertools.html#itertools.izip
"""
+
fillvalue = kwds.get('fillvalue')
+
def sentinel(counter = ([fillvalue]*(len(args)-1)).pop):
- yield counter() # yields the fillvalue, or raises IndexError
+ yield counter() # yields the fillvalue, or raises IndexError
fillers = itertools.repeat(fillvalue)
iters = [itertools.chain(it, sentinel(), fillers) for it in args]
try:
View
12 libcloud/compute/drivers/rimuhosting.py
@@ -91,7 +91,7 @@ def add_default_headers(self, headers):
headers['Content-Type'] = 'application/json'
headers['Authorization'] = 'rimuhosting apikey=%s' % (self.key)
- return headers;
+ return headers
def request(self, action, params=None, data='', headers=None, method='GET'):
if not headers:
@@ -116,7 +116,7 @@ def __init__(self, key, host=API_HOST, port=443,
# Pass in some extra vars so that
self.key = key
self.secure = secure
- self.connection = self.connectionCls(key ,secure)
+ self.connection = self.connectionCls(key, secure)
self.connection.host = host
self.connection.api_context = api_context
self.connection.port = port
@@ -163,25 +163,25 @@ def list_sizes(self, location=None):
# Get plans. Note this is really just for libcloud.
# We are happy with any size.
if location == None:
- location = '';
+ location = ''
else:
location = ";dc_location=%s" % (location.id)
res = self.connection.request('/pricing-plans;server-type=VPS%s' % (location)).object
- return list(map(lambda x : self._to_size(x), res['pricing_plan_infos']))
+ return list(map(lambda x: self._to_size(x), res['pricing_plan_infos']))
def list_nodes(self):
# Returns a list of Nodes
# Will only include active ones.
res = self.connection.request('/orders;include_inactive=N').object
- return list(map(lambda x : self._to_node(x), res['about_orders']))
+ return list(map(lambda x: self._to_node(x), res['about_orders']))
def list_images(self, location=None):
# Get all base images.
# TODO: add other image sources. (Such as a backup of a VPS)
# All Images are available for use at all locations
res = self.connection.request('/distributions').object
- return list(map(lambda x : self._to_image(x), res['distro_infos']))
+ return list(map(lambda x: self._to_image(x), res['distro_infos']))
def reboot_node(self, node):
# Reboot
View
4 libcloud/compute/drivers/slicehost.py
@@ -215,8 +215,8 @@ def _to_size(self, element):
s = NodeSize(id=int(element.findtext('id')),
name=str(element.findtext('name')),
ram=int(element.findtext('ram')),
- disk=None, # XXX: needs hardcode
- bandwidth=None, # XXX: needs hardcode
+ disk=None, # XXX: needs hardcode
+ bandwidth=None, # XXX: needs hardcode
price=float(element.findtext('price'))/(100*24*30),
driver=self.connection.driver)
return s
View
58 libcloud/compute/drivers/softlayer.py
@@ -95,19 +95,19 @@
'disk': 100,
'bandwidth': None
},
- 'prices': [
- {'id': 1644}, # 1 GB
- {'id': 1639}, # 100 GB (SAN)
- {'id': 1963}, # Private 2 x 2.0 GHz Cores
- {'id': 21}, # 1 IP Address
- {'id': 55}, # Host Ping
- {'id': 58}, # Automated Notification
- {'id': 1800}, # 0 GB Bandwidth
- {'id': 57}, # Email and Ticket
- {'id': 274}, # 1000 Mbps Public & Private Networks
- {'id': 905}, # Reboot / Remote Console
- {'id': 418}, # Nessus Vulnerability Assessment & Reporting
- {'id': 420}, # Unlimited SSL VPN Users & 1 PPTP VPN User per account
+ 'prices':[
+ {'id': 1644}, # 1 GB
+ {'id': 1639}, # 100 GB (SAN)
+ {'id': 1963}, # Private 2 x 2.0 GHz Cores
+ {'id': 21}, # 1 IP Address
+ {'id': 55}, # Host Ping
+ {'id': 58}, # Automated Notification
+ {'id': 1800}, # 0 GB Bandwidth
+ {'id': 57}, # Email and Ticket
+ {'id': 274}, # 1000 Mbps Public & Private Networks
+ {'id': 905}, # Reboot / Remote Console
+ {'id': 418}, # Nessus Vulnerability Assessment & Reporting
+ {'id': 420}, # Unlimited SSL VPN Users & 1 PPTP VPN User per account
],
},
'sl2': {
@@ -118,19 +118,19 @@
'bandwidth': None
},
'prices': [
- {'id': 1646}, # 4 GB
- {'id': 1639}, # 100 GB (SAN) - This is the only available "First Disk"
- {'id': 1638}, # 250 GB (SAN)
- {'id': 1963}, # Private 2 x 2.0 GHz Cores
- {'id': 21}, # 1 IP Address
- {'id': 55}, # Host Ping
- {'id': 58}, # Automated Notification
- {'id': 1800}, # 0 GB Bandwidth
- {'id': 57}, # Email and Ticket
- {'id': 274}, # 1000 Mbps Public & Private Networks
- {'id': 905}, # Reboot / Remote Console
- {'id': 418}, # Nessus Vulnerability Assessment & Reporting
- {'id': 420}, # Unlimited SSL VPN Users & 1 PPTP VPN User per account
+ {'id': 1646}, # 4 GB
+ {'id': 1639}, # 100 GB (SAN) - This is the only available "First Disk"
+ {'id': 1638}, # 250 GB (SAN)
+ {'id': 1963}, # Private 2 x 2.0 GHz Cores
+ {'id': 21}, # 1 IP Address
+ {'id': 55}, # Host Ping
+ {'id': 58}, # Automated Notification
+ {'id': 1800}, # 0 GB Bandwidth
+ {'id': 57}, # Email and Ticket
+ {'id': 274}, # 1000 Mbps Public & Private Networks
+ {'id': 905}, # Reboot / Remote Console
+ {'id': 418}, # Nessus Vulnerability Assessment & Reporting
+ {'id': 420}, # Unlimited SSL VPN Users & 1 PPTP VPN User per account
],
}
}
@@ -256,8 +256,8 @@ def _to_node(self, host):
password = None
hourlyRecurringFee = host.get('billingItem', {}).get('hourlyRecurringFee', 0)
- recurringFee = host.get('billingItem', {}).get('recurringFee', 0)
- recurringMonths = host.get('billingItem', {}).get('recurringMonths', 0)
+ recurringFee = host.get('billingItem', {}).get('recurringFee', 0)
+ recurringMonths = host.get('billingItem', {}).get('recurringMonths', 0)
return Node(
id=host['id'],
@@ -398,7 +398,7 @@ def _to_size(self, id, size):
)
def list_sizes(self, location=None):
- return [self._to_size(id, s['imagedata']) for id, s in
+ return [self._to_size(id, s['imagedata']) for id, s in
list(SL_TEMPLATES.items())]
def _to_loc(self, loc):
View
1  libcloud/compute/drivers/voxel.py
@@ -265,7 +265,6 @@ def _getstatus(self, element):
status = element.attrib["stat"]
return status == "ok"
-
def _to_locations(self, object):
return [NodeLocation(element.attrib["label"],
element.findtext("description"),
View
2  libcloud/compute/ssh.py
@@ -175,7 +175,7 @@ def delete(self, path):
def run(self, cmd):
# based on exec_command()
bufsize = -1
- t = self.client.get_transport()
+ t = self.client.get_transport()
chan = t.open_session()
chan.exec_command(cmd)
stdin = chan.makefile('wb', bufsize)
View
3  libcloud/compute/types.py
@@ -63,7 +63,7 @@ class Provider(object):
DUMMY = 0
EC2 = 1 # deprecated name
EC2_US_EAST = 1
- EC2_EU = 2 # deprecated name
+ EC2_EU = 2 # deprecated name
EC2_EU_WEST = 2
RACKSPACE = 3
SLICEHOST = 4
@@ -137,6 +137,7 @@ class DeploymentError(LibcloudError):
def __init__(self, node, original_exception=None):
self.node = node
self.value = original_exception
+
def __str__(self):
return repr(self.value)
View
7 libcloud/dns/drivers/linode.py
@@ -20,9 +20,8 @@
from libcloud.utils.misc import merge_valid_keys, get_new_obj
from libcloud.common.linode import (API_ROOT, LinodeException,
- LinodeConnection, LinodeResponse,
- LINODE_PLAN_IDS)
-from libcloud.common.linode import API_HOST, API_ROOT, LinodeException
+ LinodeConnection, LinodeResponse)
+from libcloud.common.linode import API_ROOT, LinodeException
from libcloud.dns.types import Provider, RecordType
from libcloud.dns.types import ZoneDoesNotExistError, RecordDoesNotExistError
from libcloud.dns.base import DNSDriver, Zone, Record
@@ -153,7 +152,7 @@ def update_zone(self, zone, domain=None, type=None, ttl=None, extra=None):
merged = merge_valid_keys(params=params,
valid_keys=VALID_ZONE_EXTRA_PARAMS,
extra=extra)
- data = self.connection.request(API_ROOT, params=params).objects[0]
+ self.connection.request(API_ROOT, params=params).objects[0]
updated_zone = get_new_obj(obj=zone, klass=Zone,
attributes={'domain': domain,
'type': type, 'ttl': ttl,
View
11 libcloud/httplib_ssl.py
@@ -25,6 +25,7 @@
import libcloud.security
from libcloud.utils.py3 import httplib
+
class LibcloudHTTPSConnection(httplib.HTTPSConnection):
"""LibcloudHTTPSConnection
@@ -73,10 +74,12 @@ def _setup_ca_cert(self):
self.ca_cert = ca_certs_available[0]
else:
if self.strict:
- raise RuntimeError(libcloud.security.CA_CERTS_UNAVAILABLE_ERROR_MSG)
+ raise RuntimeError(
+ libcloud.security.CA_CERTS_UNAVAILABLE_ERROR_MSG)
else:
# no certificates found; toggle verify to False
- warnings.warn(libcloud.security.CA_CERTS_UNAVAILABLE_WARNING_MSG)
+ warnings.warn(
+ libcloud.security.CA_CERTS_UNAVAILABLE_WARNING_MSG)
self.ca_cert = None
self.verify = False
@@ -126,9 +129,7 @@ def _verify_hostname(self, hostname, cert):
r"*", r"[0-9A-Za-z]+"
)
)
- for pattern
- in (set(common_name) | set(alt_names))
- ]
+ for pattern in (set(common_name) | set(alt_names))]
return any(
pattern.search(hostname)
View
1  libcloud/loadbalancer/__init__.py
@@ -23,4 +23,3 @@
'types',
'drivers'
]
-
View
5 libcloud/loadbalancer/drivers/cloudstack.py
@@ -13,11 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from libcloud.common.cloudstack import CloudStackConnection, \
- CloudStackDriverMixIn
+from libcloud.common.cloudstack import CloudStackDriverMixIn
from libcloud.loadbalancer.base import LoadBalancer, Member, Driver, Algorithm
from libcloud.loadbalancer.base import DEFAULT_ALGORITHM
-from libcloud.loadbalancer.types import State, LibcloudLBImmutableError
+from libcloud.loadbalancer.types import State
from libcloud.utils.misc import reverse_dict
class CloudStackLBDriver(CloudStackDriverMixIn, Driver):
View
4 libcloud/pricing.py
@@ -29,7 +29,8 @@
PRICING_DATA = {}
-VALID_PRICING_DRIVER_TYPES = [ 'compute', 'storage' ]
+VALID_PRICING_DRIVER_TYPES = ['compute', 'storage']
+
def clear_pricing_data():
PRICING_DATA.clear()
@@ -39,6 +40,7 @@ def clear_pricing_data():
})
clear_pricing_data()
+
def get_pricing_file_path(file_path=None):
pricing_directory = os.path.dirname(os.path.abspath(__file__))
pricing_file_path = pjoin(pricing_directory, PRICING_FILE_PATH)
View
2  libcloud/storage/base.py
@@ -709,7 +709,7 @@ def _upload_file(self, response, file_path, chunked=False,
one is the uploaded data MD5 hash and the third one
is the number of transferred bytes.
"""
- with open (file_path, 'rb') as file_handle:
+ with open(file_path, 'rb') as file_handle:
success, data_hash, bytes_transferred = (
self._stream_data(
response=response,
View
3  libcloud/storage/drivers/atmos.py
@@ -153,7 +153,7 @@ def get_container(self, container_name):
def create_container(self, container_name):
path = self._namespace_path(container_name + '/')
try:
- result = self.connection.request(path, method='POST')
+ self.connection.request(path, method='POST')
except AtmosError:
e = sys.exc_info()[1]
if e.code != 1016:
@@ -229,7 +229,6 @@ def upload_object(self, file_path, container, object_name, extra=None,
request_method=method,
headers={}, file_path=file_path)
- response = result_dict['response'].response
bytes_transferred = result_dict['bytes_transferred']
if extra is None:
View
5 libcloud/storage/drivers/google_storage.py
@@ -13,13 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import time
-import copy
import base64
+import copy
import hmac
-from hashlib import sha1
from email.utils import formatdate
+from hashlib import sha1
from libcloud.utils.py3 import b
View
3  libcloud/utils/__init__.py
@@ -42,6 +42,3 @@ def in_development_warning(module):
warnings.warn('The module %s is in development and your are advised '
'against using it in production.' % (module),
category=FutureWarning)
-
-
-
View
10 setup.py
@@ -169,8 +169,7 @@ def run(self):
' --html-viewsource-base="%s"'
' --project-base-dir=`pwd`'
' --project-url="%s"'
- % (HTML_VIEWSOURCE_BASE, PROJECT_BASE_DIR)
- )
+ % (HTML_VIEWSOURCE_BASE, PROJECT_BASE_DIR))
class CoverageCommand(Command):
@@ -217,8 +216,7 @@ def run(self):
'libcloud.loadbalancer',
'libcloud.loadbalancer.drivers',
'libcloud.dns',
- 'libcloud.dns.drivers'
- ],
+ 'libcloud.dns.drivers'],
package_dir={
'libcloud': 'libcloud',
},
@@ -247,6 +245,4 @@ def run(self):
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.0',
'Programming Language :: Python :: 3.1',
- 'Programming Language :: Python :: 3.2'
- ]
-)
+ 'Programming Language :: Python :: 3.2'])
View
2  test/loadbalancer/test_gogrid.py
@@ -112,7 +112,7 @@ def test_balancer_list_members(self):
def test_balancer_attach_compute_node(self):
balancer = LoadBalancer(23530, None, None, None, None, self.driver)
- node = Node(id='1', name='test', state=None, public_ips=['10.0.0.75'],
+ node = Node(id='1', name='test', state=None, public_ips=['10.0.0.75'],
private_ips=[], driver=DummyNodeDriver)
member1 = self.driver.balancer_attach_compute_node(balancer, node)
member2 = balancer.attach_compute_node(node)
View
1  test/test_pricing.py
@@ -103,4 +103,3 @@ def test_set_pricing(self):
if __name__ == '__main__':
sys.exit(unittest.main())
-
Please sign in to comment.
Something went wrong with that request. Please try again.