Skip to content
Permalink
Browse files
Remove travis issues and Bump version number
  • Loading branch information
brogand93 committed May 15, 2014
1 parent 7be00f0 commit e5b5bf21dd171c1eaea655bce735ab5c9e994407
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 52 deletions.
@@ -18,10 +18,12 @@
# under the License.

import os
import sys

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy


def _load_config_file():
config_file = os.path.join(
os.path.expanduser('~'),
@@ -46,7 +48,7 @@ def _load_config_file():
app.config['DATA'] = os.path.abspath(os.path.dirname(__file__)) + '/data'

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
os.path.join(app.config['DATA'], 'app.db')
os.path.join(app.config['DATA'], 'app.db')

from gstack.controllers import *

@@ -19,6 +19,7 @@

import os


def main():
config_folder = _create_config_folder()
_create_config_file(config_folder)
@@ -28,7 +29,7 @@ def _create_config_folder():
config_folder = os.path.join(os.path.expanduser('~'), '.gstack')
if not os.path.exists(config_folder):
os.makedirs(config_folder)
os.chmod(config_folder, 0700)
os.chmod(config_folder, 0o700)
return config_folder


@@ -67,4 +68,4 @@ def _create_config_file(config_folder):
cloudstack_path = '/client/api'
config_file.write('CLOUDSTACK_PATH = \'%s\'\n' % cloudstack_path)

config_file.close()
config_file.close()
@@ -168,7 +168,10 @@ def listdisks(projectid, authorization, zone):


@app.route(
'/' + app.config['PATH'] + '<projectid>/zones/<zone>/disks/<disk>', methods=['GET'])
'/' +
app.config['PATH'] +
'<projectid>/zones/<zone>/disks/<disk>',
methods=['GET'])
@authentication.required
def getdisk(projectid, authorization, zone, disk):
response = get_disk_by_name(
@@ -130,7 +130,10 @@ def listimages(projectid, authorization):


@app.route(
'/' + app.config['PATH'] + '<projectid>/global/images/<image>', methods=['GET'])
'/' +
app.config['PATH'] +
'<projectid>/global/images/<image>',
methods=['GET'])
@authentication.required
def getimage(projectid, authorization, image):
response = get_template_by_name(
@@ -164,7 +164,10 @@ def _get_virtual_machine_by_name(authorization, instance):


@app.route(
'/' + app.config['PATH'] + '<projectid>/aggregated/instances', methods=['GET'])
'/' +
app.config['PATH'] +
'<projectid>/aggregated/instances',
methods=['GET'])
@authentication.required
def aggregatedlistinstances(authorization, projectid):
zone_list = zones.get_zone_names(authorization=authorization)
@@ -197,7 +200,10 @@ def aggregatedlistinstances(authorization, projectid):


@app.route(
'/' + app.config['PATH'] + '<projectid>/zones/<zone>/instances', methods=['GET'])
'/' +
app.config['PATH'] +
'<projectid>/zones/<zone>/instances',
methods=['GET'])
@authentication.required
def listinstances(authorization, projectid, zone):
instance = None
@@ -245,7 +251,10 @@ def listinstances(authorization, projectid, zone):


@app.route(
'/' + app.config['PATH'] + '<projectid>/zones/<zone>/instances/<instance>', methods=['GET'])
'/' +
app.config['PATH'] +
'<projectid>/zones/<zone>/instances/<instance>',
methods=['GET'])
@authentication.required
def getinstance(projectid, authorization, zone, instance):
response = _get_virtual_machine_by_name(
@@ -269,7 +278,11 @@ def getinstance(projectid, authorization, zone, instance):
return errors.resource_not_found(function_route)


@app.route('/' + app.config['PATH'] + '<projectid>/zones/<zone>/instances', methods=['POST'])
@app.route(
'/' +
app.config['PATH'] +
'<projectid>/zones/<zone>/instances',
methods=['POST'])
@authentication.required
def addinstance(authorization, projectid, zone):
data = json.loads(request.data)
@@ -311,7 +324,11 @@ def addinstance(authorization, projectid, zone):
return helper.create_response(data=populated_response)


@app.route('/' + app.config['PATH'] + '<projectid>/zones/<zone>/instances/<instance>', methods=['DELETE'])
@app.route(
'/' +
app.config['PATH'] +
'<projectid>/zones/<zone>/instances/<instance>',
methods=['DELETE'])
@authentication.required
def deleteinstance(projectid, authorization, zone, instance):
deletion_result = _destroy_virtual_machine(authorization, instance)
@@ -77,7 +77,10 @@ def _cloudstack_machinetype_to_gce(cloudstack_response, projectid, zone):


@app.route(
'/' + app.config['PATH'] + '<projectid>/aggregated/machineTypes', methods=['GET'])
'/' +
app.config['PATH'] +
'<projectid>/aggregated/machineTypes',
methods=['GET'])
@authentication.required
def aggregatedlistmachinetypes(projectid, authorization):
machine_types = _get_machinetypes(authorization)
@@ -112,7 +115,10 @@ def aggregatedlistmachinetypes(projectid, authorization):


@app.route(
'/' + app.config['PATH'] + '<projectid>/zones/<zone>/machineTypes', methods=['GET'])
'/' +
app.config['PATH'] +
'<projectid>/zones/<zone>/machineTypes',
methods=['GET'])
@authentication.required
def listmachinetype(projectid, authorization, zone):
machinetype = None
@@ -165,7 +171,10 @@ def listmachinetype(projectid, authorization, zone):


@app.route(
'/' + app.config['PATH'] + '<projectid>/zones/<zone>/machineTypes/<machinetype>', methods=['GET'])
'/' +
app.config['PATH'] +
'<projectid>/zones/<zone>/machineTypes/<machinetype>',
methods=['GET'])
@authentication.required
def getmachinetype(projectid, authorization, zone, machinetype):
response = get_machinetype_by_name(
@@ -146,7 +146,10 @@ def listnetworks(projectid, authorization):


@app.route(
'/' + app.config['PATH'] + '<projectid>/global/networks/<network>', methods=['GET'])
'/' +
app.config['PATH'] +
'<projectid>/global/networks/<network>',
methods=['GET'])
@authentication.required
def getnetwork(projectid, authorization, network):
response = get_network_by_name(
@@ -210,7 +213,10 @@ def addnetwork(authorization, projectid):


@app.route(
'/' + app.config['PATH'] + '<projectid>/global/networks/<network>', methods=['DELETE'])
'/' +
app.config['PATH'] +
'<projectid>/global/networks/<network>',
methods=['DELETE'])
@authentication.required
def deletenetwork(projectid, authorization, network):
_delete_network(authorization, projectid, network)
@@ -60,17 +60,20 @@ def _delete_instance_response(async_result, projectid):
elif async_result['jobstatus'] is 1:
# handle successful case
populated_response['status'] = 'DONE'
populated_response['zone'] = urllib.unquote_plus(helper.get_root_url() + url_for(
'getzone',
projectid=projectid,
zone=async_result['jobresult']['virtualmachine']['zonename'],
))
populated_response['targetLink'] = urllib.unquote_plus(helper.get_root_url() + url_for(
'getinstance',
projectid=projectid,
zone=async_result['jobresult']['virtualmachine']['zonename'],
instance=async_result['jobresult']['virtualmachine']['displayname']
))
populated_response['zone'] = urllib.unquote_plus(
helper.get_root_url() +
url_for(
'getzone',
projectid=projectid,
zone=async_result['jobresult']['virtualmachine']['zonename'],
))
populated_response['targetLink'] = urllib.unquote_plus(
helper.get_root_url() +
url_for(
'getinstance',
projectid=projectid,
zone=async_result['jobresult']['virtualmachine']['zonename'],
instance=async_result['jobresult']['virtualmachine']['displayname']))

# need to add a case here for error handling, its job status 2

@@ -134,17 +137,20 @@ def _create_instance_response(async_result, projectid, authorization):
elif async_result['jobstatus'] is 1:
# handle successful case
populated_response['status'] = 'DONE'
populated_response['zone'] = urllib.unquote_plus(helper.get_root_url() + url_for(
'getzone',
projectid=projectid,
zone=async_result['jobresult']['virtualmachine']['zonename'],
))
populated_response['targetLink'] = urllib.unquote_plus(helper.get_root_url() + url_for(
'getinstance',
projectid=projectid,
zone=async_result['jobresult']['virtualmachine']['zonename'],
instance=async_result['jobresult']['virtualmachine']['displayname']
))
populated_response['zone'] = urllib.unquote_plus(
helper.get_root_url() +
url_for(
'getzone',
projectid=projectid,
zone=async_result['jobresult']['virtualmachine']['zonename'],
))
populated_response['targetLink'] = urllib.unquote_plus(
helper.get_root_url() +
url_for(
'getinstance',
projectid=projectid,
zone=async_result['jobresult']['virtualmachine']['zonename'],
instance=async_result['jobresult']['virtualmachine']['displayname']))
_add_sshkey_metadata(
authorization=authorization,
publickey=publickey_storage[projectid],
@@ -185,7 +191,10 @@ def create_response(authorization, projectid, operationid):


@app.route(
'/' + app.config['PATH'] + '<projectid>/global/operations/<operationid>', methods=['GET'])
'/' +
app.config['PATH'] +
'<projectid>/global/operations/<operationid>',
methods=['GET'])
@authentication.required
def getoperations(authorization, operationid, projectid):
return helper.create_response(create_response(
@@ -178,7 +178,10 @@ def getproject(authorization, projectid):


@app.route(
'/' + app.config['PATH'] + '<projectid>/setCommonInstanceMetadata', methods=['POST'])
'/' +
app.config['PATH'] +
'<projectid>/setCommonInstanceMetadata',
methods=['POST'])
@authentication.required
def setglobalmetadata(projectid, authorization):
data = json.loads(request.data)
@@ -35,12 +35,19 @@ def make_request(command, args, client_id, client_secret):
request = zip(args.keys(), args.values())
request.sort(key=lambda x: x[0].lower())

request_url = "&".join(["=".join([r[0], urllib.quote_plus(str(r[1]))]) for r in request])
request_url = "&".join(
["=".join([r[0], urllib.quote_plus(str(r[1]))]) for r in request])

hashStr = "&".join(["=".join([r[0].lower(), str.lower(urllib.quote_plus(str(r[1]))).replace("+", "%20")])
for r in request])
hashStr = "&".join(["=".join([r[0].lower(),
str.lower(urllib.quote_plus(str(r[1]))).replace("+",
"%20")]) for r in request])

sig = urllib.quote_plus(base64.encodestring(hmac.new(client_secret, hashStr, hashlib.sha1).digest()).strip())
sig = urllib.quote_plus(
base64.encodestring(
hmac.new(
client_secret,
hashStr,
hashlib.sha1).digest()).strip())

request_url += "&signature=%s" % sig

@@ -8,11 +8,12 @@ class ClientTest(unittest.TestCase):

def setUp(self):

self.client = Client(client_id='some.client',
client_secret='ASDFGHJKL',
redirect_uri='https://example.com/pyoauth2redirect',
authorization_uri='https://grapheffect.com/pyoauth2/auth',
token_uri='https://grapheffect.com/pyoauth2/token')
self.client = Client(
client_id='some.client',
client_secret='ASDFGHJKL',
redirect_uri='https://example.com/pyoauth2redirect',
authorization_uri='https://grapheffect.com/pyoauth2/auth',
token_uri='https://grapheffect.com/pyoauth2/token')

def test_get_authorization_code_uri(self):
"""Test client generation of authorization code uri."""
@@ -34,8 +34,10 @@ def test_make_json_error_response(self):

def test_get_authorization_code_invalid_response_type(self):

response = self.provider.get_authorization_code('foo', 'client12345',
'https://example.com/oauth')
response = self.provider.get_authorization_code(
'foo',
'client12345',
'https://example.com/oauth')

self.assertEquals(302, response.status_code)
self.assertEquals('https://example.com/oauth?'
@@ -33,4 +33,5 @@ def test_build_url(self):

# Note param ordering and correct new value for b
self.assertEquals(
result, 'https://www.grapheffect.com/some/path;hello?a=10&c=30&b=20')
result,
'https://www.grapheffect.com/some/path;hello?a=10&c=30&b=20')
@@ -27,7 +27,7 @@
raise RuntimeError(
"python setuptools is required to build gstack")

VERSION = '0.0.2'
VERSION = '0.0.3'

import os

0 comments on commit e5b5bf2

Please sign in to comment.