change apache vhost to fix exec periossions and the ip rand func

This commit is contained in:
deflax 2018-04-16 14:28:52 +03:00
parent 370c4bad1e
commit 9cee885966
4 changed files with 25 additions and 16 deletions

View file

@ -12,6 +12,10 @@ from flask_moment import Moment
from werkzeug.contrib.fixers import ProxyFix from werkzeug.contrib.fixers import ProxyFix
from config import config from config import config
import sys, os
sys.stderr.write("My uid={}, gid={}, euid={}, egid={}".format(os.getuid(), os.getgid(), os.geteuid(), os.getegid()))
sys.stderr.flush()
app = Flask(__name__) app = Flask(__name__)
app.config.from_object(config['dev']) app.config.from_object(config['dev'])
config['dev'].init_app(app) config['dev'].init_app(app)

View file

@ -221,8 +221,8 @@ def contact_proxmaster(data, method):
try: try:
db_result = requests.post( url, data=data_json, headers={"content-type": "application/json"}, timeout=30 ) db_result = requests.post( url, data=data_json, headers={"content-type": "application/json"}, timeout=30 )
proxjson = db_result.json() proxjson = db_result.json()
if current_app.config['DEBUG'] == 1: #if current_app.config['DEBUG'] == 1:
current_app.logger.info('API> {}'.format(str(proxjson))) # current_app.logger.info('API> {}'.format(str(proxjson)))
return proxjson return proxjson
except: except:
return { 'status': 'UNREACHABLE' } return { 'status': 'UNREACHABLE' }

View file

@ -55,6 +55,7 @@ def slavetables():
def vmcreate(orderid): def vmcreate(orderid):
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import validators, RadioField, SubmitField from wtforms import validators, RadioField, SubmitField
from sqlalchemy.sql.expression import func, select
order = Order.query.filter_by(pid=int(orderid)).first() order = Order.query.filter_by(pid=int(orderid)).first()
if order == None: if order == None:
@ -69,6 +70,11 @@ def vmcreate(orderid):
#happyslave = '2' #warrior in our case #happyslave = '2' #warrior in our case
happyslave = '1' happyslave = '1'
rand_pub_addr = Address.query.filter_by(region_id=int(order.region_id)).filter_by(reserved=False).filter_by(pubvlan_id=None).order_by(func.random()).first()
if rand_pub_addr == None:
flash('No free addresses in the selected region')
return redirect(url_for('admin.list_addresses'))
class SlaveForm(FlaskForm): class SlaveForm(FlaskForm):
slaveswitcher = RadioField('Select Slave Server', [validators.Required()], choices=serverchoices, default=happyslave) slaveswitcher = RadioField('Select Slave Server', [validators.Required()], choices=serverchoices, default=happyslave)
submit = SubmitField('Create') submit = SubmitField('Create')
@ -104,6 +110,10 @@ def vmcreate(orderid):
db.session.add(new_vlan) db.session.add(new_vlan)
db.session.commit() db.session.commit()
rand_pub_addr.pubvlan_id = new_vlan.pid
rand_pub_addr.user_id = order.user_id
db.session.commit()
order.status = 'accepted' order.status = 'accepted'
db.session.commit() db.session.commit()
flash('A new deployment is created successfully in region "{}".'.format(str(order.region.description))) flash('A new deployment is created successfully in region "{}".'.format(str(order.region.description)))

View file

@ -9,25 +9,20 @@
RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L] RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]
WSGIDaemonProcess proxadmin user=proxadmin group=proxadmin threads=5 home=/home/proxadmin/appserver/proxadmin/ WSGIDaemonProcess panel user=proxadmin group=proxadmin threads=10 home=/home/proxadmin/appserver/proxadmin/
WSGIProcessGroup panel
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
WSGIScriptAlias / /home/proxadmin/appserver/proxadmin/start.wsgi WSGIScriptAlias / /home/proxadmin/appserver/proxadmin/start.wsgi
<Directory "/home/proxadmin/appserver/proxadmin"> <Files "start.wsgi">
<Files "start.wsgi">
Require all granted
</Files>
</Directory>
<Directory "/home/proxadmin/appserver/proxadmin/app">
WSGIProcessGroup proxadmin
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Require all granted Require all granted
</Directory> </Files>
<Directory "/home/proxadmin/appserver/proxadmin/log"> <Directory "/home/proxadmin/appserver/proxadmin">
Require all granted Require all granted
</Directory> </Directory>
Alias /static /home/proxadmin/appserver/proxadmin/app/static Alias /static /home/proxadmin/appserver/proxadmin/app/static
<Directory "/home/proxadmin/appserver/proxadmin/app/static"> <Directory "/home/proxadmin/appserver/proxadmin/app/static">