Skip to content

Commit

Permalink
Add CentOS7-devel image type option to select in form
Browse files Browse the repository at this point in the history
Fixes #36
  • Loading branch information
dkhandel committed Apr 10, 2018
1 parent e8bd119 commit b389ddd
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 37 deletions.
26 changes: 0 additions & 26 deletions migrations/versions/ac40d51a4114_.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
8 changes: 0 additions & 8 deletions softserve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions softserve/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions softserve/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions softserve/templates/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ <h3>Create Nodes</h3>
<input type="text" class="form-control" name="node_name" data-toggle="tooltip" title='Should not contain any special characters except underscore' required>
</div>
</div>
<div class='row'>
<div class="form-group col-md-5">
<label for="image">Image type</label>
<select class="form-control" name="image">
<option value="CentOS 7 (PVHVM)">CentOS7</option>
<option value="centos7-devel">CentOS7-devel</option>
</select>
</div>
</div>
<div class='row'>
<div class="form-group col-md-5">
<label for="hours">Number of hours</label>
Expand Down
4 changes: 3 additions & 1 deletion softserve/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit b389ddd

Please sign in to comment.