From b389dddf529c819de7dddd7fddaecbbada7d468d Mon Sep 17 00:00:00 2001 From: dkhandel Date: Tue, 10 Apr 2018 11:13:26 +0530 Subject: [PATCH] Add CentOS7-devel image type option to select in form Fixes #36 --- migrations/versions/ac40d51a4114_.py | 26 -------------------------- softserve/__init__.py | 8 -------- softserve/lib.py | 4 ++-- softserve/model.py | 1 + softserve/templates/form.html | 9 +++++++++ softserve/views.py | 4 +++- 6 files changed, 15 insertions(+), 37 deletions(-) diff --git a/migrations/versions/ac40d51a4114_.py b/migrations/versions/ac40d51a4114_.py index f66ccaa..25cbbb8 100644 --- a/migrations/versions/ac40d51a4114_.py +++ b/migrations/versions/ac40d51a4114_.py @@ -1,17 +1,7 @@ -<<<<<<< c83a1dd433f7fede5bf63113f387a3a4b3e4032e -<<<<<<< d9efd336f3872be8f153d58d949a089f61376283 """Add a new column deleted_at in table vm -======= -"""empty message ->>>>>>> Create a new migration for a change in Vm table -======= -"""Add a new column deleted_at in table vm ->>>>>>> Remove commented lines and add message in version file - Revision ID: ac40d51a4114 Revises: 45b003a9a66f Create Date: 2018-03-20 15:23:15.806539 - """ from alembic import op import sqlalchemy as sa @@ -25,24 +15,8 @@ def upgrade(): -<<<<<<< c83a1dd433f7fede5bf63113f387a3a4b3e4032e -<<<<<<< d9efd336f3872be8f153d58d949a089f61376283 - op.add_column('vm', sa.Column('deleted_at', sa.DateTime(), nullable=True)) - - -def downgrade(): - op.drop_column('vm', 'deleted_at') -======= - # ### commands auto generated by Alembic - please adjust! ### -======= ->>>>>>> Remove commented lines and add message in version file op.add_column('vm', sa.Column('deleted_at', sa.DateTime(), nullable=True)) def downgrade(): op.drop_column('vm', 'deleted_at') -<<<<<<< c83a1dd433f7fede5bf63113f387a3a4b3e4032e - # ### end Alembic commands ### ->>>>>>> Create a new migration for a change in Vm table -======= ->>>>>>> Remove commented lines and add message in version file diff --git a/softserve/__init__.py b/softserve/__init__.py index 551f10f..a063094 100644 --- a/softserve/__init__.py +++ b/softserve/__init__.py @@ -19,11 +19,3 @@ from views import about # noqa: E402, F401 from model import User, NodeRequest, Vm # noqa: E402, F401 -<<<<<<< c83a1dd433f7fede5bf63113f387a3a4b3e4032e -<<<<<<< d9efd336f3872be8f153d58d949a089f61376283 -======= - -# db.create_all() ->>>>>>> Create a new migration for a change in Vm table -======= ->>>>>>> Remove commented lines and add message in version file diff --git a/softserve/lib.py b/softserve/lib.py index c7a7888..f8e9c04 100644 --- a/softserve/lib.py +++ b/softserve/lib.py @@ -37,7 +37,7 @@ def wrap(*args, **kwargs): @celery.task() -def create_node(counts, name, node_request, pubkey): +def create_node(counts, name, node_request, pubkey, image): ''' Create a node in the cloud provider ''' @@ -47,7 +47,7 @@ def create_node(counts, name, node_request, pubkey): nova = pyrax.cloudservers flavor = nova.flavors.find(name='1 GB General Purpose v1') - image = nova.images.find(name='CentOS 7 (PVHVM)') + image = nova.images.find(name=image) node_request = NodeRequest.query.get(node_request) keypair = nova.keypairs.create(name, pubkey) # create the nodes diff --git a/softserve/model.py b/softserve/model.py index 16004bf..77fee02 100644 --- a/softserve/model.py +++ b/softserve/model.py @@ -30,6 +30,7 @@ class NodeRequest(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) node_name = db.Column(db.String(100), nullable=False) + image_type = db.Column(db.String(20), nullable=False) node_counts = db.Column(db.Integer, nullable=False) hours = db.Column(db.Integer, nullable=False) pubkey = db.Column(db.VARCHAR(1024), nullable=False) diff --git a/softserve/templates/form.html b/softserve/templates/form.html index 9463cd8..c266a85 100755 --- a/softserve/templates/form.html +++ b/softserve/templates/form.html @@ -21,6 +21,15 @@

Create Nodes

+
+
+ + +
+
diff --git a/softserve/views.py b/softserve/views.py index f824905..b2f6152 100644 --- a/softserve/views.py +++ b/softserve/views.py @@ -84,6 +84,7 @@ def get_node_data(): name = request.form['node_name'] hours_ = request.form['hours'] pubkey_ = request.form['pubkey'] + image = request.form['image'] # Validating the hours and node counts if int(counts) > 5 or int(hours_) > 4 or int(counts) > n: @@ -107,12 +108,13 @@ def get_node_data(): node_request = NodeRequest( user_id=g.user.id, node_name=name, + image_type=image, node_counts=counts, hours=hours_, pubkey=pubkey_) db.session.add(node_request) db.session.commit() - create_node.delay(counts, name, node_request.id, pubkey_) + create_node.delay(counts, name, node_request.id, pubkey_, image) flash('Creating your machine. Please wait for a moment.') return redirect('/dashboard') else: