diff --git a/app/uinvoice/routes.py b/app/uinvoice/routes.py
index b04024b..1d93298 100644
--- a/app/uinvoice/routes.py
+++ b/app/uinvoice/routes.py
@@ -14,7 +14,7 @@ from ..models import User, Transaction
def transactions():
page = { 'title': 'Payment Transaction' }
cuser = current_user
- transactions = Transaction.query.filter_by(user_id=cuser.pid).order_by(Transaction.date_created.desc()).limit(100)
+ transactions = Transaction.query.filter_by(user_id=cuser.pid).order_by(Transaction.date_created.desc()).limit(20)
labelslist = ['today']
translist = [cuser.wallet]
diff --git a/app/vmanager/routes.py b/app/vmanager/routes.py
index 0c2fe12..c38dc01 100644
--- a/app/vmanager/routes.py
+++ b/app/vmanager/routes.py
@@ -56,49 +56,9 @@ def createvm():
form = CreateForm()
if current_user.confirmed and form.validate_on_submit():
+ #selects the chosen region
selected_region = Region.query.filter_by(pid=int(form.region.data)).first()
- #TODO: Filter bridges for the selected region only. switch should return slave name
- selected_bridge = current_user.inv_bridges.filter_by(deleted=False).first()
- if selected_bridge is None:
- #no bridges in the account. create one...
- data = { 'clientid': str(current_user.pid),
- 'clientemail': str(current_user.email),
- 'region': str(selected_region.name),
- 'type': 'br'
- }
- #create bridge unit
- query = contact_proxmaster(data, 'create')
- if query['status'] == 'bridge_created':
- newbridge = True
- #machine will be installed where the bridge physically is
- region_name = query['region']
- slave_name = query['slave']
- bridge_id = query['unit_id']
- bridge_phy_id = query['phy_id']
- selected_bridge = Bridge(user_id=int(current_user.pid), bridge_id=bridge_id)
- db.session.add(selected_bridge)
- db.session.commit()
- flash('New point created successfully in region "{}".'.format(str(selected_region.description)))
- else:
- flash('Point could not be created! Please try again later...')
- return redirect(url_for('panel.dashboard'))
- else:
- #bridge found. lets see on which slave it is so we can create the instance on the same slave.
- data = { 'unit_id': int(selected_bridge.bridge_id),
- 'type': 'br' }
- query = contact_proxmaster(data, 'query')
- if query['status'] == 'query_success':
- newbridge = False
- #machine will be installed where the switch physically is
- region_name = query['region']
- slave_name = query['slave']
- bridge_phy_id = query['phy_id']
- else:
- flash('Point found but cannot be used!')
- return redirect(url_for('panel.dashboard'))
-
- ###
#create new machine...
data = { 'clientid': str(current_user.pid),
'clientemail': str(current_user.email),
@@ -109,7 +69,7 @@ def createvm():
'cpu': '1',
'mem': '512',
'hdd': '20',
- 'net0if': 'vmbr' + str(bridge_phy_id)
+ 'net0if': 'vmbr7'
}
try:
query = contact_proxmaster(data, 'create')
@@ -121,10 +81,10 @@ def createvm():
deployment = Deployment(user_id=int(current_user.pid), machine_alias=str(form.servername.data), 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, bridge_id=int(selected_bridge.pid))
db.session.add(deployment)
db.session.commit()
- flash('New device created successfully in region "{}".'.format(str(selected_region.description)))
+ flash('A new deployment is created successfully in region "{}".'.format(str(selected_region.description)))
return redirect(url_for('panel.dashboard'))
else:
- flash('Device could not be created! Please try again later...')
+ flash('Deployment could not be created! Please try again later...')
#TODO: cleanup bridge if the machine is new and we were not be able to create it
@@ -174,52 +134,6 @@ def activate(itemid=0):
else:
return redirect(url_for('uinvoice.transactions'))
current_app.logger.info('[{}] Charge deployment: {}'.format(owner.email, deploy.machine_id))
-
- #TODO: Filter routers for the selected region only. switch should return slave name
- selected_router = owner.inv_routers.filter_by(deleted=False).first()
- if selected_router is None:
- #TODO: Filter bridges for the selected region only. switch should return slave name
- selected_bridge = owner.inv_bridges.filter_by(deleted=False).first()
- if selected_bridge is None:
- flash('No private network found.')
- else:
- #bridge found. lets see on which slave it is so we can create the instance on the same slave.
- data = { 'unit_id': int(selected_bridge.bridge_id),
- 'type': 'br' }
- query = contact_proxmaster(data, 'query')
- if query['status'] == 'query_success':
- #TODO: selected random ip address from the pool.
- selected_ip = '87.120.110.41'
- #machine will be installed where the switch physically is
- region_name = query['region']
- slave_name = query['slave']
- bridge_phy_id = query['phy_id']
- data = { 'clientid': str(owner.pid),
- 'clientemail': str(owner.email),
- 'hostname': 'c' + str(owner.pid) + '-r' + selected_ip,
- 'region': str(region_name),
- 'slave': str(slave_name),
- 'type': 'lxc',
- 'cpu': '1',
- 'mem': '256',
- 'hdd': '1',
- 'net0if': 'vmbr' + str(bridge_phy_id),
- 'net0ip': '192.168.9.1',
- 'net0mask': '24',
- 'net1if': 'vmbr0',
- 'net1ip': selected_ip,
- 'net1mask': '24',
- 'net1gw': '87.120.110.1' #should be queried from the current region
- }
- query = contact_proxmaster(data, 'create')
- if query['status'] == 'lxc_created':
- router = Router(user_id=int(owner.pid), machine_id=query['unit_id'])
- db.session.add(router)
- db.session.commit()
- else:
- flash('Router cannot be created.')
- return redirect(url_for('panel.dashboard'))
-
today = datetime.utcnow()
expiry = today + relativedelta(today, months=+(form.period.data))
daysleft = expiry - today