shh travis, it'll all be over soon
diff --git a/gstack/__init__.py b/gstack/__init__.py
index c96f7b1..276ebbf 100644
--- a/gstack/__init__.py
+++ b/gstack/__init__.py
@@ -29,12 +29,12 @@
os.path.expanduser('~'),
'.gstack/gstack.conf'
)
-
if not os.path.exists(config_file):
sys.exit('No configuration found, please run gstack-configure')
return config_file
+
def _load_database():
database_file = os.path.join(
os.path.expanduser('~'),
diff --git a/gstack/configure.py b/gstack/configure.py
index 3b1bd0c..e4d042b 100644
--- a/gstack/configure.py
+++ b/gstack/configure.py
@@ -74,6 +74,7 @@
config_file.close()
+
def _create_database():
directory = os.path.join(os.path.dirname(__file__), '../migrations')
config = AlembicConfig(os.path.join(
diff --git a/gstack/controllers/__init__.py b/gstack/controllers/__init__.py
index 0b31b42..966f540 100644
--- a/gstack/controllers/__init__.py
+++ b/gstack/controllers/__init__.py
@@ -78,6 +78,7 @@
else:
return errors.resource_not_found(func_route)
+
def _get_requested_items(authorization, args, type, to_cloudstack, **kwargs):
name = None
filter = helpers.get_filter(request.args)
@@ -131,4 +132,4 @@
def describe_items(authorization, args, type, to_cloudstack, **kwargs):
items = _get_requested_items(authorization, args, type, to_cloudstack, **kwargs)
- return items
\ No newline at end of file
+ return items
diff --git a/gstack/controllers/disks.py b/gstack/controllers/disks.py
index 4ce196e..c0bbbb0 100644
--- a/gstack/controllers/disks.py
+++ b/gstack/controllers/disks.py
@@ -20,10 +20,8 @@
import urllib
from flask import request, url_for
from gstack import app, authentication
-from gstack.services import requester
from gstack import helpers
from gstack import controllers
-from gstack.controllers import zones, errors
def _cloudstack_volume_to_gce(cloudstack_response, projectid, zone):
@@ -50,8 +48,8 @@
@app.route('/compute/v1/projects/<projectid>/aggregated/disks', methods=['GET'])
@authentication.required
def aggregatedlistdisks(projectid, authorization):
- args = {'command':'listVolumes'}
- kwargs = {'projectid':projectid}
+ args = {'command': 'listVolumes'}
+ kwargs = {'projectid': projectid}
items = controllers.describe_items_aggregated(
authorization, args, 'volume', 'disk',
_cloudstack_volume_to_gce, **kwargs)
@@ -69,8 +67,8 @@
@app.route('/compute/v1/projects/<projectid>/zones/<zone>/disks', methods=['GET'])
@authentication.required
def listdisks(projectid, authorization, zone):
- args = {'command':'listVolumes'}
- kwargs = {'projectid':projectid, 'zone':zone}
+ args = {'command': 'listVolumes'}
+ kwargs = {'projectid': projectid, 'zone': zone}
items = controllers.describe_items(
authorization, args, 'volume',
_cloudstack_volume_to_gce, **kwargs)
@@ -89,8 +87,8 @@
@authentication.required
def getdisk(projectid, authorization, zone, disk):
func_route = url_for('getdisk', projectid=projectid, zone=zone, disk=disk)
- args = {'command':'listVolumes'}
- kwargs = {'projectid':projectid, 'zone':zone}
+ args = {'command': 'listVolumes'}
+ kwargs = {'projectid': projectid, 'zone': zone}
return controllers.get_item_with_name_or_error(
authorization, disk, args, 'volume', func_route,
_cloudstack_volume_to_gce, **kwargs)
diff --git a/gstack/controllers/errors.py b/gstack/controllers/errors.py
index 7e935e1..1381297 100644
--- a/gstack/controllers/errors.py
+++ b/gstack/controllers/errors.py
@@ -20,7 +20,7 @@
import urllib
from gstack import app
from gstack import helpers
-from flask import jsonify, Response
+from flask import Response
@app.errorhandler(404)
diff --git a/gstack/controllers/firewalls.py b/gstack/controllers/firewalls.py
index d3810a6..b2264ac 100755
--- a/gstack/controllers/firewalls.py
+++ b/gstack/controllers/firewalls.py
@@ -63,7 +63,7 @@
@app.route('/compute/v1/projects/<projectid>/global/firewalls', methods=['GET'])
@authentication.required
def listsecuritygroups(projectid, authorization):
- args = {'command':'listSecurityGroups'}
+ args = {'command': 'listSecurityGroups'}
items = controllers.describe_items(
authorization, args, 'securitygroup',
_cloudstack_securitygroup_to_gce, **{})
@@ -136,7 +136,6 @@
json.dumps(cloudstack_response, indent=4, separators=(',', ': '))
)
- # return Global Operations
populated_response = {}
res = jsonify(populated_response)
diff --git a/gstack/controllers/images.py b/gstack/controllers/images.py
index 49ab9ff..c31af2b 100755
--- a/gstack/controllers/images.py
+++ b/gstack/controllers/images.py
@@ -19,14 +19,13 @@
import urllib
from gstack import app, authentication
-from gstack.services import requester
from gstack import helpers
from gstack import controllers
-from gstack.controllers import errors
from flask import request, url_for
+
def get_template_by_name(authorization, image):
- args = {'templatefilter': 'executable', 'command':'listTemplates'}
+ args = {'templatefilter': 'executable', 'command': 'listTemplates'}
return controllers.get_item_with_name(authorization, image, args, 'template')
@@ -44,17 +43,13 @@
def _cloudstack_template_to_gce(cloudstack_response):
- translate_image_status = {
- 'True': 'Ready',
- 'False': 'Failed'}
-
response = {}
response['kind'] = 'compute#image'
response['id'] = cloudstack_response['id']
response['creationTimestamp'] = cloudstack_response['created']
response['name'] = cloudstack_response['name']
response['description'] = cloudstack_response['displaytext']
- response['status'] = translate_image_status[str(cloudstack_response['isready'])]
+ response['status'] = cloudstack_response['isready']
response['selfLink'] = urllib.unquote_plus(request.base_url) + '/' + response['name']
return response
@@ -77,7 +72,7 @@
@app.route('/compute/v1/projects/<projectid>/global/images', methods=['GET'])
@authentication.required
def listimages(projectid, authorization):
- args = {'templatefilter': 'executable', 'command':'listTemplates'}
+ args = {'templatefilter': 'executable', 'command': 'listTemplates'}
items = controllers.describe_items(
authorization, args, 'template',
_cloudstack_template_to_gce, **{})
@@ -90,7 +85,7 @@
@authentication.required
def getimage(projectid, authorization, image):
func_route = url_for('getimage', projectid=projectid, image=image)
- args = {'templatefilter': 'executable', 'command':'listTemplates'}
+ args = {'templatefilter': 'executable', 'command': 'listTemplates'}
return controllers.get_item_with_name_or_error(
authorization, image, args, 'template', func_route,
- _cloudstack_template_to_gce, **{})
\ No newline at end of file
+ _cloudstack_template_to_gce, **{})
diff --git a/gstack/controllers/instances.py b/gstack/controllers/instances.py
index 4b9d22f..08d7ae8 100755
--- a/gstack/controllers/instances.py
+++ b/gstack/controllers/instances.py
@@ -52,7 +52,7 @@
if 'network' in args:
network = networks.get_network_by_name(
authorization=authorization,
- securitygroup=args['network']
+ network=args['network']
)
converted_args['securitygroupids'] = network['id']
@@ -116,8 +116,8 @@
@app.route('/compute/v1/projects/<projectid>/aggregated/instances', methods=['GET'])
@authentication.required
def aggregatedlistinstances(authorization, projectid):
- args = {'command':'listVirtualMachines'}
- kwargs = {'projectid':projectid}
+ args = {'command': 'listVirtualMachines'}
+ kwargs = {'projectid': projectid}
items = controllers.describe_items_aggregated(
authorization, args, 'virtualmachine', 'instances',
_cloudstack_virtual_machine_to_gce, **kwargs)
@@ -134,8 +134,8 @@
@app.route('/compute/v1/projects/<projectid>/zones/<zone>/instances', methods=['GET'])
@authentication.required
def listinstances(authorization, projectid, zone):
- args = {'command':'listVirtualMachines'}
- kwargs = {'projectid':projectid, 'zone':zone}
+ args = {'command': 'listVirtualMachines'}
+ kwargs = {'projectid': projectid, 'zone': zone}
items = controllers.describe_items(
authorization, args, 'virtualmachine',
_cloudstack_virtual_machine_to_gce, **kwargs)
@@ -194,7 +194,7 @@
@app.route('/compute/v1/projects/<projectid>/zones/<zone>/instances/<instance>', methods=['DELETE'])
@authentication.required
def deleteinstance(projectid, authorization, zone, instance):
- args = {'command':'listVirtualMachines'}
+ args = {'command': 'listVirtualMachines'}
virtual_machine = controllers.get_item_with_name(authorization, instance, args, 'virtualmachine')
if virtual_machine is None:
func_route = url_for('deleteinstance', projectid=projectid, zone=zone, instance=instance)
@@ -218,12 +218,13 @@
return helpers.create_response(data=populated_response)
+
@app.route('/compute/v1/projects/<projectid>/zones/<zone>/instances/<instance>', methods=['GET'])
@authentication.required
def getinstance(projectid, authorization, zone, instance):
func_route = url_for('getinstance', projectid=projectid, zone=zone, instance=instance)
- args = {'command':'listVirtualMachines'}
- kwargs = {'projectid':projectid, 'zone':zone}
+ args = {'command': 'listVirtualMachines'}
+ kwargs = {'projectid': projectid, 'zone': zone}
return controllers.get_item_with_name_or_error(
authorization, instance, args, 'virtualmachine', func_route,
- _cloudstack_virtual_machine_to_gce, **kwargs)
\ No newline at end of file
+ _cloudstack_virtual_machine_to_gce, **kwargs)
diff --git a/gstack/controllers/machine_type.py b/gstack/controllers/machine_type.py
index 202a86e..b78a6c5 100755
--- a/gstack/controllers/machine_type.py
+++ b/gstack/controllers/machine_type.py
@@ -22,11 +22,11 @@
from gstack import authentication
from gstack import helpers
from gstack import controllers
-from gstack.controllers import errors, zones
from flask import request, url_for
+
def get_machinetype_by_name(authorization, machinetype):
- args = {'command':'listServiceOfferings'}
+ args = {'command': 'listServiceOfferings'}
return controllers.get_item_with_name(authorization, machinetype, args, 'serviceoffering')
@@ -54,8 +54,8 @@
@app.route('/compute/v1/projects/<projectid>/aggregated/machineTypes', methods=['GET'])
@authentication.required
def aggregatedlistmachinetypes(projectid, authorization):
- args = {'command':'listServiceOfferings'}
- kwargs = {'projectid':projectid}
+ args = {'command': 'listServiceOfferings'}
+ kwargs = {'projectid': projectid}
items = controllers.describe_items_aggregated(
authorization, args, 'serviceoffering', 'machineTypes',
_cloudstack_service_offering_to_gce, **kwargs)
@@ -72,8 +72,8 @@
@app.route('/compute/v1/projects/<projectid>/zones/<zone>/machineTypes', methods=['GET'])
@authentication.required
def listmachinetype(projectid, authorization, zone):
- args = {'command':'listServiceOfferings'}
- kwargs = {'projectid':projectid, 'zone':zone}
+ args = {'command': 'listServiceOfferings'}
+ kwargs = {'projectid': projectid, 'zone': zone}
items = controllers.describe_items(
authorization, args, 'serviceoffering',
_cloudstack_service_offering_to_gce, **kwargs)
@@ -92,8 +92,8 @@
@authentication.required
def getmachinetype(projectid, authorization, zone, machinetype):
func_route = url_for('getmachinetype', projectid=projectid, zone=zone, machinetype=machinetype)
- args = {'command':'listServiceOfferings'}
- kwargs = {'projectid':projectid, 'zone':zone}
+ args = {'command': 'listServiceOfferings'}
+ kwargs = {'projectid': projectid, 'zone': zone}
return controllers.get_item_with_name_or_error(
authorization, machinetype, args, 'serviceoffering', func_route,
_cloudstack_service_offering_to_gce, **kwargs)
diff --git a/gstack/controllers/networks.py b/gstack/controllers/networks.py
index 5932de1..b8a0726 100644
--- a/gstack/controllers/networks.py
+++ b/gstack/controllers/networks.py
@@ -26,10 +26,12 @@
from gstack.services import requester
from gstack.controllers import errors
+
def get_network_by_name(authorization, network):
- args = {'command':'SecurityGroups'}
+ args = {'command': 'SecurityGroups'}
return controllers.get_item_with_name(authorization, network, args, 'securitygroup')
+
def _add_network(authorization, args=None):
command = 'createSecurityGroup'
if not args:
@@ -46,7 +48,7 @@
def _delete_network(authorization, projectid, network):
- args = {'command':'SecurityGroups'}
+ args = {'command': 'SecurityGroups'}
network_response = controllers.get_item_with_name(authorization, network, args, 'securitygroup')
if not network_response:
return None
@@ -92,7 +94,7 @@
@app.route('/compute/v1/projects/<projectid>/global/networks', methods=['GET'])
@authentication.required
def listnetworks(projectid, authorization):
- args = {'command':'listSecurityGroups'}
+ args = {'command': 'listSecurityGroups'}
kwargs = {}
items = controllers.describe_items(
authorization, args, 'securitygroup',
@@ -109,7 +111,7 @@
@authentication.required
def getnetwork(projectid, authorization, network):
func_route = url_for('getnetwork', projectid=projectid, network=network)
- args = {'command':'listSecurityGroups'}
+ args = {'command': 'listSecurityGroups'}
kwargs = {}
return controllers.get_item_with_name_or_error(
authorization, network, args, 'securitygroup', func_route,
diff --git a/gstack/controllers/project.py b/gstack/controllers/project.py
index 4381429..35408bd 100755
--- a/gstack/controllers/project.py
+++ b/gstack/controllers/project.py
@@ -28,8 +28,9 @@
import urllib
import collections
+
def _get_account_by_name(authorization, projectid):
- args = {'command':'listAccounts'}
+ args = {'command': 'listAccounts'}
return controllers.get_item_with_name(authorization, projectid, args, 'account')
@@ -133,7 +134,6 @@
@authentication.required
def getproject(authorization, projectid):
project = _get_account_by_name(authorization, projectid)
- print project
if project:
metadata = {}
diff --git a/gstack/controllers/regions.py b/gstack/controllers/regions.py
index 6c15362..136e5e0 100755
--- a/gstack/controllers/regions.py
+++ b/gstack/controllers/regions.py
@@ -22,7 +22,6 @@
from gstack import helpers
from gstack import controllers
from gstack import authentication
-from gstack.controllers import errors
from flask import request, url_for
@@ -39,7 +38,7 @@
@app.route('/compute/v1/projects/<projectid>/regions', methods=['GET'])
@authentication.required
def listregions(projectid, authorization):
- args = {'command':'listAccounts'}
+ args = {'command': 'listAccounts'}
kwargs = {}
items = controllers.describe_items(
authorization, args, 'region',
@@ -58,7 +57,7 @@
@authentication.required
def getregion(projectid, authorization, region):
func_route = url_for('getregion', projectid=projectid, region=region)
- args = {'command':'listAccounts'}
+ args = {'command': 'listAccounts'}
return controllers.get_item_with_name_or_error(
authorization, region, args, 'region', func_route,
_cloudstack_account_to_gce, **{})
diff --git a/gstack/controllers/zones.py b/gstack/controllers/zones.py
index 213ec50..8e9985c 100755
--- a/gstack/controllers/zones.py
+++ b/gstack/controllers/zones.py
@@ -22,17 +22,16 @@
from gstack import controllers
from gstack import app, authentication
from gstack.services import requester
-from gstack.controllers import errors
+
def get_zone_by_name(authorization, zone):
- args = {'command':'listZones'}
+ args = {'command': 'listZones'}
return controllers.get_item_with_name(authorization, zone, args, 'zone')
-def _get_zones(authorization, args=None):
+def _get_zones(authorization):
command = 'listZones'
- if not args:
- args = {}
+ args = {}
cloudstack_response = requester.make_request(
command,
args,
@@ -55,16 +54,12 @@
def _cloudstack_zone_to_gce(cloudstack_response):
- translate_zone_status = {
- 'Enabled': 'UP',
- 'Disabled': 'DOWN'
- }
return ({
'kind': 'compute#zone',
'name': cloudstack_response['name'],
'description': cloudstack_response['name'],
'id': cloudstack_response['id'],
- 'status': translate_zone_status[str(cloudstack_response['allocationstate'])]
+ 'status': cloudstack_response['allocationstate']
})
@@ -92,8 +87,7 @@
@authentication.required
def getzone(projectid, authorization, zone):
func_route = url_for('getzone', projectid=projectid, zone=zone)
- args = {'command':'listZones'}
+ args = {'command': 'listZones'}
return controllers.get_item_with_name_or_error(
authorization, zone, args, 'zone', func_route,
_cloudstack_zone_to_gce, **{})
-
diff --git a/gstack/core.py b/gstack/core.py
index 1b3ecf0..2fb3de1 100644
--- a/gstack/core.py
+++ b/gstack/core.py
@@ -46,4 +46,4 @@
def delete(self, model):
self._isinstance(model)
db.session.delete(model)
- db.session.commit()
\ No newline at end of file
+ db.session.commit()
diff --git a/gstack/helpers.py b/gstack/helpers.py
index b6a0162..76e73c2 100644
--- a/gstack/helpers.py
+++ b/gstack/helpers.py
@@ -20,7 +20,7 @@
import os
import urllib
from gstack import app
-from flask import jsonify, render_template, make_response
+from flask import jsonify
def create_response(data):
@@ -29,6 +29,7 @@
return res
+
def create_errored_response(data, status_code):
res = jsonify(data)
res.status_code = status_code
diff --git a/gstack/models/__init__.py b/gstack/models/__init__.py
index 59cf9f0..a9d480d 100644
--- a/gstack/models/__init__.py
+++ b/gstack/models/__init__.py
@@ -26,9 +26,10 @@
class AccessTokenService(Service):
__model__ = AccessToken
+
class RefreshTokenService(Service):
__model__ = RefreshToken
+
class ClientService(Service):
__model__ = Client
-
diff --git a/gstack/oauth2provider.py b/gstack/oauth2provider.py
index 8cc2654..ce08aa1 100644
--- a/gstack/oauth2provider.py
+++ b/gstack/oauth2provider.py
@@ -55,8 +55,8 @@
existing_client.client_secret = client_secret
else:
client = Client(
- client_id=client_id,
- client_secret=client_secret
+ client_id,
+ client_secret
)
db.session.add(client)
@@ -77,15 +77,8 @@
def persist_authorization_code(self, client_id, code, scope):
return
- def persist_token_information(
- self,
- client_id,
- scope,
- access_token,
- token_type,
- expires_in,
- refresh_token,
- data):
+ def persist_token_information(self, client_id, scope, access_token, token_type,
+ expires_in, refresh_token, data):
client = Client.query.get(client_id)
if client is not None:
existing_access_token = AccessToken.query.filter_by(
@@ -100,8 +93,7 @@
else:
db.session.add(
AccessToken(
- access_token=access_token, client_id=client_id,
- expires_in=expires_in, data=json.dumps(data)
+ access_token, client_id, expires_in, json.dumps(data)
)
)
@@ -110,11 +102,7 @@
existing_refresh_token.data = json.dumps(data)
else:
db.session.add(
- RefreshToken(
- refresh_token=refresh_token, client_id=client_id,
- data=json.dumps(data)
- )
- )
+ RefreshToken(refresh_token, client_id, json.dumps(data)))
db.session.commit()
return True
diff --git a/pylint.rc b/pylint.rc
index 315faa8..6173b69 100644
--- a/pylint.rc
+++ b/pylint.rc
@@ -24,33 +24,7 @@
[MESSAGES CONTROL]
-# Enable the message, report, category or checker with the given id(s). You can
-# either give multiple identifier separated by comma (,) or put this option
-# multiple time.
-#enable=
-
-# Disable the message, report, category or checker with the given id(s). You
-# can either give multiple identifier separated by comma (,) or put this option
-# multiple time (only on the command line, not in the configuration file where
-# it should appear only once).
-# F0401: *Unable to import %r*
-# E0611: *No name %r in module %r*
-# E1101: *%s %r has no %r member*
-# W0142: *Used * or ** magic*
-# W0212: *Access to a protected member %s of a client class*
-# :R0201: *Method could be a function*
-# w0703: Allow catching Exception
-# R0801: 1: Similar lines in 2 files, badamson: had trouble disabling this locally
-# FIXME: should be re-enabled after it's fixed
-# hbrown: I don't think R0801 can be disabled locally
-# http://www.logilab.org/ticket/6905
-# pylint #6905: R0801 message cannot be disabled locally [open]
-# R0901: Too many ancestors
-# C0111: missing docstring
-# C0301: line too long (too many to fix right now)
-# C0103: invalid variable name (too many to fix right now)
-# I0011: disabling pylint error
-disable=F0401,E0611,E1101,W0142,W0212,R0201,W0703,R0801,R0901,C0111,C0301,C0103,E1002,W0231,W0232,W0401,W0402,W0511,W0603,W0611,W0612,W0613,W0614,W0621,W0622,W0702,W0710,R0922,I0011,E1103
+disable=F0401,E0611,E1120,W0110,E1121,R0401,E1101,W0142,W0141,E1003,E1102,W0212,R0201,W0703,R0801,R0901,C0111,C0301,C0103,E1002,W0231,W0232,W0401,W0402,W0511,W0603,W0611,W0612,W0613,W0614,W0621,W0622,W0702,W0710,R0922,I0011,E1103