diff --git a/Procfile b/Procfile deleted file mode 100755 index 98db9fce..00000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: gunicorn refstack.web:app \ No newline at end of file diff --git a/README.md b/README.md index 1d363846..cb46fb67 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ RefStack ======== -Vendor-facing API for registration of interop-compliance endpoints and credentials for on-demand testing. +Vendor-facing API for registration of interop-compliance endpoints and credentials for on-demand testing. Running at http://refstack.org See (living) documentation at https://etherpad.openstack.org/RefStackBlueprint - diff --git a/refstack.wsgi b/refstack.wsgi deleted file mode 100755 index 7556fad3..00000000 --- a/refstack.wsgi +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2013 Piston Cloud Computing, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. - -import os -# os.environ['YOURAPPLICATION_CONFIG'] = '/var/www/yourapplication/application.cfg' -from refstack.app import app diff --git a/refstack/__init__.py b/refstack/__init__.py index 0fe048dc..e69de29b 100755 --- a/refstack/__init__.py +++ b/refstack/__init__.py @@ -1,15 +0,0 @@ -# -# Copyright (c) 2013 Piston Cloud Computing, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. \ No newline at end of file diff --git a/refstack/api.py b/refstack/api.py deleted file mode 100755 index 0fe048dc..00000000 --- a/refstack/api.py +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright (c) 2013 Piston Cloud Computing, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, 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. \ No newline at end of file diff --git a/refstack/app.py b/refstack/app.py index a7a56bb2..eda49674 100755 --- a/refstack/app.py +++ b/refstack/app.py @@ -14,9 +14,12 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import os -from flask import Flask, session +"""Common Flask app config.""" + +import os + +import flask #db_path = os.path.abspath( @@ -24,7 +27,9 @@ from flask import Flask, session db_path = 'tmp' -app = Flask(__name__) + +app = flask.Flask(__name__) + app.config['MAILGUN_KEY'] = '#@#@#@#@' app.config['MAILGUN_DOMAIN'] = 'refstack.org' diff --git a/refstack/models.py b/refstack/models.py index 47f2a13f..3b0f20b0 100755 --- a/refstack/models.py +++ b/refstack/models.py @@ -13,15 +13,15 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -"""striaght up sqlalchemy declarative_base model structure. +"""striaght up sqlalchemy declarative_base model structure. - *I created this because i was having a problem getting - the cli to use the models that were generated for the flask - webapp. The plan is to use this for both. But I have not + *I created this because i was having a problem getting + the cli to use the models that were generated for the flask + webapp. The plan is to use this for both. But I have not started my serious efforts on the web interface. dl 10.2013 - *For now in dev I have this database in /tmp we can talk - about someplace else for it by default. + *For now in dev I have this database in /tmp we can talk + about someplace else for it by default. """ from datetime import datetime from sqlalchemy import create_engine @@ -38,7 +38,6 @@ Base = declarative_base() Base.query = db.query_property() - class User(Base): __tablename__ = 'user' id = Column(Integer, primary_key=True) @@ -62,11 +61,10 @@ class User(Base): return self.name - """ -Note: The vendor list will be pre-populated from the sponsoring company database. +Note: The vendor list will be pre-populated from the sponsoring company database. TODO: better define the vendor object and its relationship with user -it needs the ability to facilitate a login. +it needs the ability to facilitate a login. """ class Vendor(Base): __tablename__ = 'vendor' @@ -79,13 +77,12 @@ class Vendor(Base): return self.vendor_name - class Cloud(Base): - """*need to take the time to descibe this stuff in detail. + """*need to take the time to descibe this stuff in detail. """ __tablename__ = 'cloud' id = Column(Integer, primary_key=True) - + label = Column(String(60), unique=False) endpoint = Column(String(120), unique=True) test_user = Column(String(80), unique=False) @@ -112,7 +109,6 @@ class Test(Base): self.cloud_id = cloud_id - class TestStatus(Base): __tablename__ = 'test_status' id = Column(Integer, primary_key=True) @@ -130,7 +126,6 @@ class TestStatus(Base): self.finished = finished - class TestResults(Base): __tablename__ = 'test_results' id = Column(Integer, primary_key=True) diff --git a/refstack/runserver.py b/refstack/runserver.py index 6ab289d3..84360da1 100755 --- a/refstack/runserver.py +++ b/refstack/runserver.py @@ -15,8 +15,10 @@ # License for the specific language governing permissions and limitations # under the License. import os + from web import app + app.logger.setLevel('DEBUG') port = int(os.environ.get('PORT', 5000)) -app.run(host='172.16.200.128', port=port, debug=True) \ No newline at end of file +app.run(host='172.16.200.128', port=port, debug=True) diff --git a/refstack/schema.sql b/refstack/schema.sql index 111b3a24..ac45ad3d 100755 --- a/refstack/schema.sql +++ b/refstack/schema.sql @@ -1,3 +1,3 @@ -CREATE TABLE IF NOT EXISTS VENDORS - ( vendor_id integer primary key asc autoincrement, - vendor_name TEXT NOT NULL); \ No newline at end of file +CREATE TABLE IF NOT EXISTS VENDORS + ( vendor_id integer primary key asc autoincrement, + vendor_name TEXT NOT NULL); diff --git a/refstack/web.py b/refstack/web.py index a95b297c..3a7d60bc 100755 --- a/refstack/web.py +++ b/refstack/web.py @@ -13,8 +13,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import os -import requests from flask import Flask, abort, flash, request, redirect, url_for, \ render_template, g, session from flask_openid import OpenID @@ -26,7 +24,7 @@ from wtforms import Form, BooleanField, TextField, \ PasswordField, validators from flask_mail import Mail -from refstack.app import app +from refstack.app import app from refstack.models import * mail = Mail(app) @@ -37,11 +35,10 @@ admin = Admin(app, base_template='admin/master.html') class SecureView(ModelView): - """ """ def is_accessible(self): - """ """ return g.user.su is not False + admin.add_view(SecureView(Vendor, db)) admin.add_view(SecureView(Cloud, db)) admin.add_view(SecureView(User, db)) @@ -49,17 +46,17 @@ admin.add_view(SecureView(User, db)) @app.before_request def before_request(): - """Runs before the request it self""" + """Runs before the request itself.""" g.user = None if 'openid' in session: g.user = User.query.filter_by(openid=session['openid']).first() - + @app.route('/', methods=['POST', 'GET']) def index(): - """Index view""" + """Index view.""" if g.user is not None: - # something else + # something else clouds = Cloud.query.filter_by(user_id=g.user.id).all() return render_template('home.html', clouds=clouds) else: @@ -70,15 +67,16 @@ def index(): @app.route('/login', methods=['GET', 'POST']) @oid.loginhandler def login(): - """Does the login via OpenID. Has to call into `oid.try_login` - to start the OpenID machinery. + """Does the login via OpenID. + + Has to call into `oid.try_login` to start the OpenID machinery. """ # if we are already logged in, go back to were we came from if g.user is not None: return redirect(oid.get_next_url()) return oid.try_login("https://login.launchpad.net/", ask_for=['email', 'nickname']) - + @oid.after_login def create_or_login(resp): @@ -120,21 +118,23 @@ def create_profile(): return render_template( 'create_profile.html', next_url=oid.get_next_url()) + @app.route('/delete-cloud/', methods=['GET', 'POST']) def delete_cloud(cloud_id): - """ delete function for clouds""" + """Delete function for clouds.""" c = Cloud.query.filter_by(id=cloud_id).first() if not c: flash(u'Not a valid Cloud ID!') elif not c.user_id == g.user.id: - flash(u"This isn't your cloud!") + flash(u"This isn't your cloud!") else: db.delete(c) db.commit() return redirect('/') + @app.route('/edit-cloud/', methods=['GET', 'POST']) def edit_cloud(cloud_id): c = Cloud.query.filter_by(id=cloud_id).first() @@ -143,7 +143,7 @@ def edit_cloud(cloud_id): flash(u'Not a valid Cloud ID!') return redirect('/') elif not c.user_id == g.user.id: - flash(u"This isn't your cloud!") + flash(u"This isn't your cloud!") if request.method == 'POST': #validate this biotch @@ -169,7 +169,7 @@ def edit_cloud(cloud_id): c.admin_endpoint = request.form['admin_endpoint'] c.admin_user = request.form['admin_user'] c.admin_key = request.form['admin_key'] - + db.commit() flash(u'Cloud Saved!') @@ -190,8 +190,8 @@ def edit_cloud(cloud_id): @app.route('/create-cloud', methods=['GET', 'POST']) def create_cloud(): - """This is the handler for creating a new cloud""" - + """This is the handler for creating a new cloud.""" + #if g.user is None: # abort(401) if request.method == 'POST': @@ -227,10 +227,9 @@ def create_cloud(): return render_template('create_cloud.html', next_url='/') - @app.route('/profile/edit', methods=['GET', 'POST']) def edit_profile(): - """Updates a profile""" + """Updates a profile.""" if g.user is None: abort(401) form = dict(name=g.user.name, email=g.user.email) @@ -258,16 +257,16 @@ def edit_profile(): @app.route('/profile', methods=['GET', 'POST']) def view_profile(): - """Updates a profile""" + """Updates a profile.""" if g.user is None: abort(401) - + return render_template('view_profile.html', user=g.user) @app.route('/logout') def logout(): - """logout route""" + """Log out.""" session.pop('openid', None) flash(u'You have been signed out') return redirect(oid.get_next_url()) diff --git a/requirements.txt b/requirements.txt index a646fc3f..5c640a53 100755 --- a/requirements.txt +++ b/requirements.txt @@ -12,9 +12,9 @@ WTForms==1.0.4 Werkzeug==0.8.3 alembic==0.5.0 gunicorn==0.17.4 -psycopg2==2.5 +#psycopg2==2.5 pyOpenSSL==0.13 pycrypto==2.6 python-openid==2.2.5 requests==1.2.3 -python-keystoneclient \ No newline at end of file +python-keystoneclient diff --git a/uwsgi.ini b/uwsgi.ini deleted file mode 100755 index a09e1aba..00000000 --- a/uwsgi.ini +++ /dev/null @@ -1,9 +0,0 @@ -[uwsgi] -module=refstack.web:app -socket=/tmp/uwsgi_refstack.sock -#master=False -master=True -pidfile=/tmp/project-master_refstack.pid -vacuum=True -max-requests=5000 -daemonize=/tmp/refstack.log \ No newline at end of file