adapt create data json

This commit is contained in:
deflax 2018-04-02 15:44:33 +03:00
parent 5d088b7dd7
commit 00e0848d26
3 changed files with 13 additions and 13 deletions

View file

@ -9,8 +9,8 @@ class OrderForm(FlaskForm):
region_choices = [(1, 'Plovdiv, Bulgaria'), (2, 'International Space Station')]
region = SelectField('Region:', choices=region_choices, coerce=int)
vmtype_choices = [(1, 'RootVPS')]
vmtype = SelectField('Type:', choices=vmtype_choices, coerce=int)
recipe_choices = [(1, 'RootVPS')]
recipe = SelectField('Type:', choices=recipe_choices, coerce=int)
cpu = DecimalRangeField('Processor Cores', default=2)
memory = DecimalRangeField('Memory', default=2048)

View file

@ -46,8 +46,8 @@ function storageUpdate(value) {
<div class="panel-heading">2. Image</div>
<div class="panel-body">
<p>
{{ form.vmtype.label }}<br /> {{ form.vmtype }}<br />
{% for error in form.vmtype.errors %}
{{ form.recipe.label }}<br /> {{ form.recipe }}<br />
{% for error in form.recipe.errors %}
{{ error }}<br />
{% endfor %}
</p>

View file

@ -74,14 +74,14 @@ def vmcreate(orderid):
form = SlaveForm()
if form.validate_on_submit():
data = { 'clientid': str(current_user.pid),
'clientemail': str(current_user.email),
'hostname': 'c' + str(current_user.pid) + '-' + str(form.servername.data),
'region': str(selected_region.name),
data = { 'clientid': str(order.user_id),
'clientemail': str(order.owner.email),
'hostname': 'c' + str(order.user_id) + '-' + str(order.parameter1),
'region': str(order.region.name),
'type': 'kvm',
'cpu': '1',
'mem': '512',
'hdd': '20',
'cpu': str(int(order.parameter2)),
'mem': str(int(order.parameter3)),
'hdd': str(int(order.parameter4)),
'net0if': 'vmbr7'
}
try:
@ -92,7 +92,7 @@ def vmcreate(orderid):
if query['status'] == 'kvm_created':
selected_slave = Server.query.filter_by(name=query['slave']).first()
deployment = Deployment(user_id=int(current_user.pid), machine_alias=str(form.servername.data), period=1, machine_id=query['unit_id'], machine_cpu=data['cpu'], machine_mem=data['mem'], machine_hdd=data['hdd'], enabled=True, protected=False, daysleft=15, warning=True, discount=0, server_id=int(selected_slave.pid))
deployment = Deployment(user_id=order.user_id, machine_alias=str(order.parameter1), period=1, machine_id=query['unit_id'], machine_cpu=data['cpu'], machine_mem=data['mem'], machine_hdd=data['hdd'], enabled=True, protected=False, daysleft=15, warning=True, discount=0, server_id=int(selected_slave.pid))
db.session.add(deployment)
db.session.commit()
@ -103,7 +103,7 @@ def vmcreate(orderid):
order.status = 'accepted'
db.session.update(order)
db.session.commit()
flash('A new deployment is created successfully in region "{}".'.format(str(selected_region.description)))
flash('A new deployment is created successfully in region "{}".'.format(str(order.region.description)))
return redirect(url_for('panel.dashboard'))
else:
flash('Deployment could not be created! Please try again later...')