add support topic to each deployment

This commit is contained in:
deflax 2018-05-06 19:13:02 +03:00
parent c230ddcfc8
commit 709d7912ad
9 changed files with 30 additions and 9 deletions

View file

@ -4,6 +4,7 @@ from flask_bootstrap import Bootstrap
from flask_mail import Mail
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_pagedown import PageDown
from flask_wtf.csrf import CSRFProtect, CSRFError
from flask_babel import Babel, lazy_gettext
from flask_moment import Moment
@ -34,6 +35,7 @@ mail = Mail()
mail.init_app(app)
bootstrap = Bootstrap()
bootstrap.init_app(app)
pagedown = PageDown(app)
csrf = CSRFProtect(app)
#csrf.init_app(app)
babel = Babel()

View file

@ -97,7 +97,8 @@ def dashboard(user_pid):
if not current_user.is_administrator():
send_email(current_app.config['MAIL_USERNAME'], '{} experienced an error'.format(cuser.email), '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)
supportform = MessageForm()
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, form=supportform)
#SUPPORT

View file

@ -79,7 +79,7 @@ d-i base-installer/kernel/image string linux-generic
d-i passwd/user-fullname string ubuntu-user
d-i passwd/username string ubuntu
d-i passwd/user-password-crypted password $6$HVqIDE43CsBb$JecrxJll8LUED03dz1KjS8Peek7dKVS0lR.1girEOGbh8XWh.cBFlpds9aREaDAptd8U5bLEW8ZOx8htjjPLr/
d-i passwd/user-password-crypted password $6$NafeQeIx$uKRfMInxDw3vcGFML74rdjupfENDwbltlAVoJfRzMWtJu3qN2Sl0j3IBK9dYIYQtyEZZ3wKQn6ECLrHWEf8rj/
d-i user-setup/allow-password-weak boolean true
d-i passwd/user-default-groups string sudo
d-i user-setup/encrypt-home boolean false

View file

@ -24,6 +24,12 @@ update-grub
################################################################################
#curl -sSL https://get.docker.com/ | sh
apt install docker.io
# install portainer
#docker run -d -p 9000:9000 portainer/portainer
#run with root access to host socket.
docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /opt/portainer:/data portainer/portainer
################################################################################
## install Gitlab CI Multirunner
@ -53,3 +59,6 @@ update-grub
################################################################################
#chage -d 0 gitlab-ci
#shutdown at the end
shutdown -h now

View file

@ -52,7 +52,7 @@
<li><a href="{{ url_for('uinvoice.transactions') }}"><span class="glyphicon glyphicon-list-alt"></span> Transactions</a></li>
<li role="separator" class="divider"></li>
<li><a href="{{ url_for('settings.profile') }}"><span class="glyphicon glyphicon-user"></span> Profile</a></li>
<li><a href="{{ url_for('panel.support_list') }}"><span class="glyphicon glyphicon-question-sign"></span> Support</a></li>
<!-- <li><a href="{{ url_for('panel.support_list') }}"><span class="glyphicon glyphicon-question-sign"></span> Support</a></li>-->
<li><a href="{{ url_for('auth.logout') }}"><span class="glyphicon glyphicon-off"></span> Logout</a></li>
</ul>
</li>

View file

@ -55,6 +55,9 @@ addEventListener("DOMContentLoaded", function() {
}
}, true);
</script>
{{ pagedown.include_pagedown() }}
{% endblock %}
{% block page_content %}

View file

@ -3,7 +3,7 @@
<div class="panel panel-default" style="margin-top: 0px">
<div class="panel-heading" href="#support{{ support.pid }}" aria-expanded="true" aria-controls="support{{ support.pid }}" role="tab" id="support{{ support.pid }}">
<font color="green">started at {{ moment(support.timestamp).format('ll') }}</font></b></a>
<font color="green">started at {{ moment(support.timestamp).format('ll') }}</font></b></a>
</div>
</div> <!-- end of heading -->

View file

@ -16,13 +16,13 @@
{% if deploy.enabled == False or deploy.warning == True %}
<div id="cube{{ deploy.machine_id }}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading{{ deploy.machine_id }}" style="border:3px solid #faebcc; border-top: none; margin-bottom: 10px;">
{% else %}
<div id="cube{{ deploy.machine_id }}" class="panel-collapse collapse {% if warnflag == False %}in{% endif %}" role="tabpanel" aria-labelledby="heading{{ deploy.machine_id }}" style="border:3px solid #d6e9c6; border-top: none; margin-bottom: 10px;">
<div id="cube{{ deploy.machine_id }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading{{ deploy.machine_id }}" style="border:3px solid #d6e9c6; border-top: none; margin-bottom: 10px;">
{% endif %}
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#nfo{{ deploy.machine_id }}">Information</a></li>
<li><a data-toggle="tab" href="#controls{{ deploy.machine_id }}">Control</a></li>
<li><a data-toggle="tab" href="#support{{ deploy.machine_id }}">Support</a></li>
<!-- <li><a data-toggle="tab" href="#support{{ deploy.machine_id }}">Support</a></li>-->
<li><a data-toggle="tab" href="#graphs{{ deploy.machine_id }}">Monitoring</a></li>
</ul>
@ -99,7 +99,7 @@
<div class="panel panel-info" id="supportpanel{{ deploy.machine_id }}">
<div class="panel-heading"></div>
<div class="panel-body"><p>
{% with support=deploy.discussion %}
{% with support=deploy.topic %}
{% include "panel/support_item.html" %}
{% endwith %}
</div>

View file

@ -6,7 +6,7 @@ from . import vmanager
from .forms import ActivateForm
from .. import db, csrf
from ..email import send_email
from ..models import User, Permission, Transaction, Order, Deployment, PubVLAN, Service, Region, Server, Address, Domain, contact_proxmaster
from ..models import User, Permission, Transaction, Order, Deployment, PubVLAN, Service, Region, Server, Address, Domain, SupportTopic, contact_proxmaster
from ..decorators import admin_required, permission_required
import json
@ -102,7 +102,13 @@ def vmcreate(orderid):
if query['status'] == 'kvm_created':
selected_slave = Server.query.filter_by(name=query['slave']).first()
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))
#create new topic
new_topic = SupportTopic(hashtag='deploy-' + str(query['unit_id']))
db.session.add(new_topic)
db.session.commit()
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), topic_id=int(new_topic.pid))
db.session.add(deployment)
db.session.commit()