diff --git a/alembic.ini b/alembic.ini index 80fbbdee..ee7b8a37 100755 --- a/alembic.ini +++ b/alembic.ini @@ -11,8 +11,8 @@ script_location = alembic # the 'revision' command, regardless of autogenerate # revision_environment = false -sqlalchemy.url = driver://user:pass@localhost/dbname - +#sqlalchemy.url = driver://user:pass@localhost/dbname +sqlalchemy.url = sqlite:///db.sqlite [alembic_sqlite] # path to migration scripts diff --git a/alembic/env.py b/alembic/env.py index 3b05e9a6..6c96b45d 100755 --- a/alembic/env.py +++ b/alembic/env.py @@ -31,9 +31,9 @@ fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support -# from refstack.models import db -# target_metadata = db.metadata -target_metadata = None +from refstack.models import db +target_metadata = db.metadata +#target_metadata = None # other values from the config, defined by the needs of env.py, # can be acquired: diff --git a/alembic/versions/1d6540fc6279_added_vendor_contact.py b/alembic/versions/2d1f3e3cd357_added_architecture_t.py similarity index 52% rename from alembic/versions/1d6540fc6279_added_vendor_contact.py rename to alembic/versions/2d1f3e3cd357_added_architecture_t.py index 164b7c93..a0a4ad5a 100755 --- a/alembic/versions/1d6540fc6279_added_vendor_contact.py +++ b/alembic/versions/2d1f3e3cd357_added_architecture_t.py @@ -1,14 +1,14 @@ -"""added vendor contact name +"""added architecture to cloud -Revision ID: 1d6540fc6279 -Revises: 3790aed42558 -Create Date: 2013-10-31 01:30:12.489026 +Revision ID: 2d1f3e3cd357 +Revises: 4a425a7aff50 +Create Date: 2014-03-07 12:11:20.403933 """ # revision identifiers, used by Alembic. -revision = '1d6540fc6279' -down_revision = '3790aed42558' +revision = '2d1f3e3cd357' +down_revision = '4a425a7aff50' from alembic import op import sqlalchemy as sa @@ -17,12 +17,12 @@ import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column( - 'vendor', - sa.Column('contact_name', sa.String(length=120), nullable=True)) + 'cloud', + sa.Column('architecture', sa.String(length=40), nullable=True)) ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### - op.drop_column('vendor', 'contact_name') + op.drop_column('cloud', 'architecture') ### end Alembic commands ### diff --git a/alembic/versions/4288db006e5_added_user_cloud_rel.py b/alembic/versions/4288db006e5_added_user_cloud_rel.py deleted file mode 100755 index c71c84b0..00000000 --- a/alembic/versions/4288db006e5_added_user_cloud_rel.py +++ /dev/null @@ -1,23 +0,0 @@ -"""added user - cloud relationship - -Revision ID: 4288db006e5 -Revises: 1d6540fc6279 -Create Date: 2013-10-31 21:00:27.473833 - -""" - -# revision identifiers, used by Alembic. -revision = '4288db006e5' -down_revision = '1d6540fc6279' - - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - pass - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - pass - ### end Alembic commands ### diff --git a/alembic/versions/449461dbc725_add_apikey.py b/alembic/versions/449461dbc725_add_apikey.py deleted file mode 100755 index 89750c88..00000000 --- a/alembic/versions/449461dbc725_add_apikey.py +++ /dev/null @@ -1,32 +0,0 @@ -"""empty message - -Revision ID: 449461dbc725 -Revises: 59e15d864941 -Create Date: 2013-11-26 16:57:16.062788 - -""" - -# revision identifiers, used by Alembic. -revision = '449461dbc725' -down_revision = '59e15d864941' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - op.create_table( - 'apikey', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(length=60), nullable=True), - sa.Column('key', sa.String(length=200), nullable=True), - sa.Column('openid', sa.String(length=200), nullable=True), - sa.Column('user_id', sa.Integer(), nullable=False), - sa.Column('timestamp', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), - sa.PrimaryKeyConstraint('id'), - ) - - -def downgrade(): - op.drop_Table('apikey') diff --git a/alembic/versions/3790aed42558_from_scratch.py b/alembic/versions/4a425a7aff50_major_restructure.py similarity index 70% rename from alembic/versions/3790aed42558_from_scratch.py rename to alembic/versions/4a425a7aff50_major_restructure.py index aca331c6..752e501f 100755 --- a/alembic/versions/3790aed42558_from_scratch.py +++ b/alembic/versions/4a425a7aff50_major_restructure.py @@ -1,13 +1,13 @@ -"""from scratch +"""major restructure -Revision ID: 3790aed42558 +Revision ID: 4a425a7aff50 Revises: None -Create Date: 2013-10-30 03:52:16.922050 +Create Date: 2014-03-07 11:20:58.899889 """ # revision identifiers, used by Alembic. -revision = '3790aed42558' +revision = '4a425a7aff50' down_revision = None from alembic import op @@ -16,24 +16,12 @@ import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### - op.create_table( - 'cloud', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('label', sa.String(length=60), nullable=True), - sa.Column('endpoint', sa.String(length=120), nullable=True), - sa.Column('test_user', sa.String(length=80), nullable=True), - sa.Column('test_key', sa.String(length=80), nullable=True), - sa.Column('admin_endpoint', sa.String(length=120), nullable=True), - sa.Column('admin_user', sa.String(length=80), nullable=True), - sa.Column('admin_key', sa.String(length=80), nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('endpoint') - ) op.create_table( 'vendor', sa.Column('id', sa.Integer(), nullable=False), sa.Column('vendor_name', sa.String(length=80), nullable=True), sa.Column('contact_email', sa.String(length=120), nullable=True), + sa.Column('contact_name', sa.String(length=120), nullable=True), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('contact_email'), sa.UniqueConstraint('vendor_name') @@ -54,20 +42,39 @@ def upgrade(): sa.UniqueConstraint('openid') ) op.create_table( - 'test', + 'apikey', sa.Column('id', sa.Integer(), nullable=False), - sa.Column('cloud_id', sa.Integer(), nullable=True), - sa.Column('config', sa.String(length=4096), nullable=True), - sa.ForeignKeyConstraint(['cloud_id'], ['cloud.id'], ), + sa.Column('name', sa.String(length=60), nullable=True), + sa.Column('key', sa.String(length=200), nullable=True), + sa.Column('openid', sa.String(length=200), nullable=True), + sa.Column('timestamp', sa.DateTime(), nullable=True), + sa.Column('user_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table( - 'test_results', + 'cloud', sa.Column('id', sa.Integer(), nullable=False), - sa.Column('test_id', sa.Integer(), nullable=True), - sa.Column('timestamp', sa.DateTime(), nullable=True), - sa.Column('blob', sa.Binary(), nullable=True), - sa.ForeignKeyConstraint(['test_id'], ['test.id'], ), + sa.Column('label', sa.String(length=60), nullable=True), + sa.Column('endpoint', sa.String(length=512), nullable=True), + sa.Column('endpoint_v3', sa.String(length=512), nullable=True), + sa.Column('admin_endpoint', sa.String(length=512), nullable=True), + sa.Column('test_user', sa.String(length=80), nullable=True), + sa.Column('admin_user', sa.String(length=80), nullable=True), + sa.Column('version', sa.String(length=80), nullable=True), + sa.Column('tempest_sha', sa.String(length=128), nullable=True), + sa.Column('user_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table( + 'test', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('cloud_id', sa.Integer(), nullable=True), + sa.Column('finished', sa.Boolean(), nullable=True), + sa.Column('subunit', sa.String(length=4096), nullable=True), + sa.Column('parsed', sa.String(length=4096), nullable=True), + sa.ForeignKeyConstraint(['cloud_id'], ['cloud.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table( @@ -75,7 +82,6 @@ def upgrade(): sa.Column('id', sa.Integer(), nullable=False), sa.Column('test_id', sa.Integer(), nullable=True), sa.Column('message', sa.String(length=1024), nullable=True), - sa.Column('finished', sa.Boolean(), nullable=True), sa.Column('timestamp', sa.DateTime(), nullable=True), sa.ForeignKeyConstraint(['test_id'], ['test.id'], ), sa.PrimaryKeyConstraint('id') @@ -86,9 +92,9 @@ def upgrade(): def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_table('test_status') - op.drop_table('test_results') op.drop_table('test') + op.drop_table('cloud') + op.drop_table('apikey') op.drop_table('user') op.drop_table('vendor') - op.drop_table('cloud') ### end Alembic commands ### diff --git a/alembic/versions/4f6f77184d45_really_added_user_cl.py b/alembic/versions/4f6f77184d45_really_added_user_cl.py deleted file mode 100644 index 6afd935c..00000000 --- a/alembic/versions/4f6f77184d45_really_added_user_cl.py +++ /dev/null @@ -1,26 +0,0 @@ -"""really added user - cloud relationship - -Revision ID: 4f6f77184d45 -Revises: 4288db006e5 -Create Date: 2013-10-31 21:09:16.469966 - -""" - -# revision identifiers, used by Alembic. -revision = '4f6f77184d45' -down_revision = '4288db006e5' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.add_column('cloud', sa.Column('user_id', sa.Integer(), nullable=True)) - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.drop_column('cloud', 'user_id') - ### end Alembic commands ### diff --git a/alembic/versions/59e15d864941_added_subunit_output.py b/alembic/versions/59e15d864941_added_subunit_output.py deleted file mode 100755 index a79f7336..00000000 --- a/alembic/versions/59e15d864941_added_subunit_output.py +++ /dev/null @@ -1,29 +0,0 @@ -"""added subunit output field - -Revision ID: 59e15d864941 -Revises: 4f6f77184d45 -Create Date: 2013-11-02 04:41:58.431516 - -""" - -# revision identifiers, used by Alembic. -revision = '59e15d864941' -down_revision = '4f6f77184d45' - -from alembic import op -import sqlalchemy as sa - - -def upgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.add_column( - 'test_results', - sa.Column('subunit', sa.String(length=8192), nullable=True) - ) - ### end Alembic commands ### - - -def downgrade(): - ### commands auto generated by Alembic - please adjust! ### - op.drop_column('test_results', 'subunit') - ### end Alembic commands ### diff --git a/refstack/models.py b/refstack/models.py index 594ed987..59f0a639 100755 --- a/refstack/models.py +++ b/refstack/models.py @@ -75,14 +75,15 @@ class Cloud(db.Model): """ __tablename__ = 'cloud' id = db.Column(db.Integer, primary_key=True) - label = db.Column(db.String(60), unique=False) - endpoint = db.Column(db.String(120), unique=True) + endpoint = db.Column(db.String(512), unique=False) + endpoint_v3 = db.Column(db.String(512), unique=False) + admin_endpoint = db.Column(db.String(512), unique=False) test_user = db.Column(db.String(80), unique=False) - test_key = db.Column(db.String(80), unique=False) - admin_endpoint = db.Column(db.String(120), unique=False) admin_user = db.Column(db.String(80), unique=False) - admin_key = db.Column(db.String(80), unique=False) + version = db.Column(db.String(80), unique=False) + tempest_sha = db.Column(db.String(128), unique=False) + architecture = db.Column(db.String(40), unique=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) user = db.relationship('User', @@ -95,7 +96,9 @@ class Test(db.Model): cloud_id = db.Column(db.Integer, db.ForeignKey('cloud.id')) cloud = db.relationship('Cloud', backref=db.backref('tests', lazy='dynamic')) - config = db.Column(db.String(4096)) + finished = db.Column(db.Boolean, default=False) + subunit = db.Column(db.String(4096)) + parsed = db.Column(db.String(4096)) def __init__(self, cloud_id): self.cloud_id = cloud_id @@ -108,21 +111,9 @@ class TestStatus(db.Model): test = db.relationship('Test', backref=db.backref('status', lazy='dynamic')) message = db.Column(db.String(1024)) - finished = db.Column(db.Boolean, default=False) timestamp = db.Column(db.DateTime, default=datetime.now) def __init__(self, test_id, message, finished=False): self.test_id = test_id self.message = message self.finished = finished - - -class TestResults(db.Model): - __tablename__ = 'test_results' - id = db.Column(db.Integer, primary_key=True) - test_id = db.Column(db.Integer, db.ForeignKey('test.id')) - test = db.relationship('Test', - backref=db.backref('results', lazy='dynamic')) - timestamp = db.Column(db.DateTime, default=datetime.now) - subunit = db.Column(db.String(8192)) - blob = db.Column(db.Binary) diff --git a/refstack/templates/create_cloud.html b/refstack/templates/create_cloud.html index 8e697cc6..1458b14e 100755 --- a/refstack/templates/create_cloud.html +++ b/refstack/templates/create_cloud.html @@ -2,22 +2,22 @@ {% block title %}Create Cloud{% endblock %} {% block body %}

Create Cloud

-
+
Label:
+
v3 Endpoint:
+
Non-Admin Keystone Endpoint:
Non-Admin User:
-
Non-Admin Password or Key:
-
Admin Keystone Endpoint:
Admin User:
-
Admin Password or Key:
-
+
Version:
+

diff --git a/refstack/templates/edit_cloud.html b/refstack/templates/edit_cloud.html index 7c6656f6..059cded4 100755 --- a/refstack/templates/edit_cloud.html +++ b/refstack/templates/edit_cloud.html @@ -6,18 +6,18 @@

Label:
+
v3 Endpoint:
+
Non-Admin Keystone Endpoint:
Non-Admin User:
-
Non-Admin Password or Key:
-
Admin Keystone Endpoint:
Admin User:
-
Admin Password or Key:
-
+
Version:
+

diff --git a/refstack/web.py b/refstack/web.py index 6c69534d..4370308b 100755 --- a/refstack/web.py +++ b/refstack/web.py @@ -135,29 +135,26 @@ def edit_cloud(cloud_id): flash(u"This isn't your cloud!") if request.method == 'POST': - #validate this biotch + # some validation + # todo: do this smarter if not request.form['label']: flash(u'Error: All fields are required') elif not request.form['endpoint']: flash(u'Error: All fields are required') elif not request.form['test_user']: flash(u'Error: All fields are required') - elif not request.form['test_key']: - flash(u'Error: All fields are required') elif not request.form['admin_endpoint']: flash(u'Error: All fields are required') elif not request.form['admin_user']: flash(u'Error: All fields are required') - elif not request.form['admin_key']: - flash(u'Error: All fields are required') else: c.label = request.form['label'] c.endpoint = request.form['endpoint'] c.test_user = request.form['test_user'] - c.test_key = request.form['test_key'] c.admin_endpoint = request.form['admin_endpoint'] + c.endpoint_v3 = request.form['endpoint_v3'] + c.version = request.form['version'] c.admin_user = request.form['admin_user'] - c.admin_key = request.form['admin_key'] db.session.commit() @@ -166,11 +163,11 @@ def edit_cloud(cloud_id): form = dict(label=c.label, endpoint=c.endpoint, - test_user=c.test_user, - test_key=c.test_key, + endpoint_v3=c.endpoint_v3, admin_endpoint=c.admin_endpoint, admin_user=c.admin_user, - admin_key=c.admin_key) + version=c.version, + test_user=c.test_user) return render_template('edit_cloud.html', form=form) @@ -179,8 +176,8 @@ def edit_cloud(cloud_id): def create_cloud(): """This is the handler for creating a new cloud.""" - #if g.user is None: - # abort(401) + if g.user is None: + abort(401) if request.method == 'POST': if not request.form['label']: flash(u'Error: All fields are required') @@ -188,24 +185,20 @@ def create_cloud(): flash(u'Error: All fields are required') elif not request.form['test_user']: flash(u'Error: All fields are required') - elif not request.form['test_key']: - flash(u'Error: All fields are required') elif not request.form['admin_endpoint']: flash(u'Error: All fields are required') elif not request.form['admin_user']: flash(u'Error: All fields are required') - elif not request.form['admin_key']: - flash(u'Error: All fields are required') else: c = Cloud() c.user_id = g.user.id c.label = request.form['label'] c.endpoint = request.form['endpoint'] c.test_user = request.form['test_user'] - c.test_key = request.form['test_key'] c.admin_endpoint = request.form['admin_endpoint'] + c.endpoint_v3 = request.form['endpoint_v3'] + c.version = request.form['version'] c.admin_user = request.form['admin_user'] - c.admin_key = request.form['admin_key'] db.session.add(c) db.session.commit()