|
@@ -6,7 +6,6 @@ import json
|
|
|
from flask import Blueprint, render_template, url_for, request
|
|
from flask import Blueprint, render_template, url_for, request
|
|
|
import requests
|
|
import requests
|
|
|
from math import ceil
|
|
from math import ceil
|
|
|
-import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__author__ = 'James Iter'
|
|
__author__ = 'James Iter'
|
|
@@ -21,12 +20,6 @@ blueprint = Blueprint(
|
|
|
url_prefix='/config'
|
|
url_prefix='/config'
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-blueprints = Blueprint(
|
|
|
|
|
- 'v_configs',
|
|
|
|
|
- __name__,
|
|
|
|
|
- url_prefix='/configs'
|
|
|
|
|
-)
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
def show():
|
|
def show():
|
|
|
args = list()
|
|
args = list()
|
|
@@ -113,33 +106,23 @@ def create():
|
|
|
host_url = request.host_url.rstrip('/')
|
|
host_url = request.host_url.rstrip('/')
|
|
|
|
|
|
|
|
if request.method == 'POST':
|
|
if request.method == 'POST':
|
|
|
- ability = request.form.get('ability')
|
|
|
|
|
- os_template_id = request.form.get('os_template_id')
|
|
|
|
|
- quantity = request.form.get('quantity')
|
|
|
|
|
- password = request.form.get('password')
|
|
|
|
|
- remark = request.form.get('remark')
|
|
|
|
|
-
|
|
|
|
|
- if not isinstance(ability, basestring):
|
|
|
|
|
- pass
|
|
|
|
|
-
|
|
|
|
|
- m = re.search('^(\d)c(\d)g$', ability.lower())
|
|
|
|
|
- if m is None:
|
|
|
|
|
- pass
|
|
|
|
|
-
|
|
|
|
|
- cpu = m.groups()[0]
|
|
|
|
|
- memory = m.groups()[1]
|
|
|
|
|
-
|
|
|
|
|
payload = {
|
|
payload = {
|
|
|
- "cpu": int(cpu),
|
|
|
|
|
- "memory": int(memory),
|
|
|
|
|
- "os_template_id": int(os_template_id),
|
|
|
|
|
- "quantity": int(quantity),
|
|
|
|
|
- "remark": remark,
|
|
|
|
|
- "password": password,
|
|
|
|
|
- "lease_term": 100
|
|
|
|
|
|
|
+ 'jimv_edition': request.form.get('jimv_edition'),
|
|
|
|
|
+ 'storage_mode': request.form.get('storage_mode'),
|
|
|
|
|
+ 'dfs_volume': request.form.get('dfs_volume'),
|
|
|
|
|
+ 'storage_path': request.form.get('storage_path'),
|
|
|
|
|
+ 'vm_network': request.form.get('vm_network'),
|
|
|
|
|
+ 'vm_manage_network': request.form.get('vm_manage_network'),
|
|
|
|
|
+ 'start_ip': request.form.get('start_ip'),
|
|
|
|
|
+ 'end_ip': request.form.get('end_ip'),
|
|
|
|
|
+ 'start_vnc_port': request.form.get('start_vnc_port'),
|
|
|
|
|
+ 'netmask': request.form.get('netmask'),
|
|
|
|
|
+ 'gateway': request.form.get('gateway'),
|
|
|
|
|
+ 'dns1': request.form.get('dns1'),
|
|
|
|
|
+ 'dns2': request.form.get('dns2')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- url = host_url + '/api/guest'
|
|
|
|
|
|
|
+ url = host_url + '/api/config'
|
|
|
headers = {'content-type': 'application/json'}
|
|
headers = {'content-type': 'application/json'}
|
|
|
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
|
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
|
|
j_r = json.loads(r.content)
|
|
j_r = json.loads(r.content)
|