diff --git a/app/admin/routes.py b/app/admin/routes.py index d5b341b..f1e1db1 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -46,8 +46,20 @@ def list_orders(): @fresh_login_required @admin_required def list_deployments(): - AllDeploymentProtected = Deployment.query.filter_by(deleted=False).order_by(Deployment.daysleft.asc()).all() - return render_template('admin/list_deployments.html', deployments=AllDeploymentProtected) + AllDeploymentsProtected = Deployment.query.filter_by(deleted=False).order_by(Deployment.daysleft.asc()).all() + statuses = {} + for deploy in AllDeploymentsProtected: + data = { 'unit_id': int(deploy.machine_id), + 'type': 'kvm' } + try: + query = contact_proxmaster(data, 'status') + status = { int(deploy.machine_id): str(query) } + statuses.update(status) + except: + stauts = { int(deploy.machine_id): 'unknown' } + statuses.update(status) + pass + return render_template('admin/list_deployments.html', deployments=AllDeploymentsProtected, statuses=statuses) @admin.route("/listservices", methods=['GET']) @fresh_login_required diff --git a/app/auth/routes.py b/app/auth/routes.py index 2c40553..a957bea 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -178,9 +178,9 @@ def confirm(token): @login_required def resend_confirmation(): token = current_user.generate_confirmation_token() - send_email(current_user.email, 'Потвърдете_вашият_акаунт', + send_email(current_user.email, 'Confirm_your_account', 'auth/email/confirm', user=current_user, token=token) - flash('Изпратен е нов код за потвърждение..') + flash('New confirmation code was sent.') return redirect(url_for('main.index')) @auth.route('/change-password', methods=['GET', 'POST']) @@ -192,10 +192,10 @@ def change_password(): current_user.password = form.password.data db.session.add(current_user) db.session.commit() - flash('Вашата парола беше променена.') + flash('Your password was changed') return redirect(url_for('main.index')) else: - flash('Грешна парола.') + flash('Wrong password.') return render_template("auth/change_password.html", form=form) @auth.route('/reset', methods=['GET', 'POST']) diff --git a/app/panel/routes.py b/app/panel/routes.py index 2deac95..550a3e1 100644 --- a/app/panel/routes.py +++ b/app/panel/routes.py @@ -64,9 +64,7 @@ def dashboard(user_pid): if invcls.user_id == cuser.pid: inv_deploycubeids.extend([invcls.machine_id]) #warning detector - #current_app.logger.info(str(invcls.machine_alias)) if invcls.warning == True or invcls.enabled == False: - #current_app.logger.warning('[{}] Deploy {} triggered a warning'.format(cuser.email, invcls.machine_alias)) warnflag = True inv_services = cuser.inv_services.filter_by(deleted=False).order_by(Service.date_last_charge.asc()).all() @@ -77,21 +75,12 @@ def dashboard(user_pid): statuses = {} #current_app.logger.warning(str(inv_deploycubeids)) for unit_id in inv_deploycubeids: - rrd[unit_id] = {} data = { 'unit_id': int(unit_id), 'type': 'kvm' } try: query = contact_proxmaster(data, 'vmrrd') - except Exception as e: - current_app.logger.error(e) - flash('Support is notified about {}.'.format(str(cuser.inv_deployments.filter_by(machine_id=unit_id).first().machine_alias))) - send_email(current_app.config['MAIL_USERNAME'], 'Cube {} is unreachable'.format(unit_id), - 'vmanager/email/adm_unreachable', user=current_user, unit_id=unit_id, error=str(e)) - #current_app.logger.info('debug query:') - #current_app.logger.info(query) - - graphs_list = ['net', 'cpu', 'mem', 'hdd'] - try: + graphs_list = ['net', 'cpu', 'mem', 'hdd'] + rrd[unit_id] = {} for graph in graphs_list: raw = query[graph]['image'].encode('raw_unicode_escape') rrd[unit_id][graph] = base64.b64encode(raw).decode() @@ -99,10 +88,12 @@ def dashboard(user_pid): statuses.update(status) except Exception as e: current_app.logger.error(e) - #flash('Support is notified.'.format(str(unit_id))) + for invcls in inv_deployments: + if invcls.machine_id == unit_id: + inv_deployments.remove(invcls) flash('Support is notified about {}.'.format(str(cuser.inv_deployments.filter_by(machine_id=unit_id).first().machine_alias))) send_email(current_app.config['MAIL_USERNAME'], 'Cube {} is unreachable'.format(unit_id), - 'vmanager/email/adm_unreachable', user=current_user, unit_id=unit_id, error=str(e)) - + 'vmanager/email/adm_unreachable', user=current_user, unit_id=unit_id, error=repr(e)) + continue return render_template('panel/dashboard.html', sys_regions=sys_regions, inv_deployments=inv_deployments, inv_services=inv_services, inv_domains=inv_domains, inv_addresses=inv_addresses, rrd=rrd, status=statuses, warnflag=warnflag, regions=regions) diff --git a/app/templates/admin/list_archive.html b/app/templates/admin/list_archive.html index 45dae64..9faae42 100644 --- a/app/templates/admin/list_archive.html +++ b/app/templates/admin/list_archive.html @@ -64,7 +64,6 @@ addEventListener("DOMContentLoaded", function() { Owner - Cube ID Alias CPU Mem @@ -90,7 +89,6 @@ addEventListener("DOMContentLoaded", function() { {% endif %} {% endif %} {{ deploy.owner.email }} - {{ deploy.machine_id }} {{ deploy.machine_alias }} {{ deploy.machine_cpu }} {{ deploy.machine_mem }} MB diff --git a/app/templates/admin/list_deployments.html b/app/templates/admin/list_deployments.html index 0600d66..35716c1 100644 --- a/app/templates/admin/list_deployments.html +++ b/app/templates/admin/list_deployments.html @@ -44,7 +44,7 @@ {% endif %} {{ deploy.server.name }} {% for vlan in deploy.inv_pubvlans %}{{ vlan.vlan_id }}{% endfor %} - {% if deploy.enabled == True %}{% else %}{% endif %}{{ deploy.machine_alias }} + {% if status[deploy.machine_id] == 'unknown' %}{% else %}{% endif %}{{ deploy.machine_alias }} {{ deploy.machine_cpu }} {{ deploy.machine_mem }} MB {{ deploy.machine_hdd }} GB diff --git a/app/vmanager/routes.py b/app/vmanager/routes.py index 5c85d6b..caabd7f 100644 --- a/app/vmanager/routes.py +++ b/app/vmanager/routes.py @@ -66,7 +66,8 @@ def vmcreate(orderid): serverchoice = (str(server.pid), str(server.name)) serverchoices.append(serverchoice) #TODO: check api for happiness and preselect suggested slave - happyslave = '2' #warrior in our case + #happyslave = '2' #warrior in our case + happyslave = '1' class SlaveForm(FlaskForm): slaveswitcher = RadioField('Select Slave Server', [validators.Required()], choices=serverchoices, default=happyslave)