redefine admin statuses and translate few bg strings

This commit is contained in:
deflax 2018-04-07 15:55:24 +03:00
parent 7fbbe5c6d0
commit c3ab881841
6 changed files with 28 additions and 26 deletions

View file

@ -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

View file

@ -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'])

View file

@ -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)

View file

@ -64,7 +64,6 @@ addEventListener("DOMContentLoaded", function() {
<thead>
<tr>
<th>Owner</th>
<th>Cube ID</th>
<th>Alias</th>
<th>CPU</th>
<th>Mem</th>
@ -90,7 +89,6 @@ addEventListener("DOMContentLoaded", function() {
{% endif %}
{% endif %}
<td><a href="{{ url_for('panel.dashboard', user_pid=deploy.user_id) }}">{{ deploy.owner.email }}</a></td>
<td>{{ deploy.machine_id }}</td>
<td>{{ deploy.machine_alias }}</font></td>
<td>{{ deploy.machine_cpu }}</td>
<td>{{ deploy.machine_mem }} MB</td>

View file

@ -44,7 +44,7 @@
{% endif %}
<td data-title="Server">{{ deploy.server.name }}</td>
<td data-title="VLAN">{% for vlan in deploy.inv_pubvlans %}{{ vlan.vlan_id }}{% endfor %}</td>
<td data-title="Alias"><a class="rrd" data-toggle="tooltip" title="Protected: {{ deploy.protected }} Online: {{ deploy.connected }}ID: {{ deploy.machine_id }}"><b>{% if deploy.enabled == True %}<font color="green">{% else %}<font color="red">{% endif %}{{ deploy.machine_alias }}</font></b></a></td>
<td data-title="Alias"><a class="rrd" data-toggle="tooltip" title="Protected: {{ deploy.protected }} ID: {{ deploy.machine_id }}"><b>{% if status[deploy.machine_id] == 'unknown' %}<font color="red">{% else %}<font color="green">{% endif %}{{ deploy.machine_alias }}</font></b></a></td>
<td data-title="CPU">{{ deploy.machine_cpu }}</td>
<td data-title="Memory">{{ deploy.machine_mem }} MB</td>
<td data-title="HDD">{{ deploy.machine_hdd }} GB</td>

View file

@ -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)