create-activate phase 4

This commit is contained in:
deflax 2017-12-26 18:00:53 +02:00
parent 0550142d2c
commit d0402b56f9
7 changed files with 80 additions and 53 deletions

View file

@ -154,11 +154,16 @@ def dashboard(user_pid=0):
cuser = User.query.filter_by(pid=user_pid).first() cuser = User.query.filter_by(pid=user_pid).first()
inv_deployments = cuser.inv_deployments.filter_by(deleted=False).order_by(Deployment.date_created.desc()).all() inv_deployments = cuser.inv_deployments.filter_by(deleted=False).order_by(Deployment.date_created.desc()).all()
inv_legacy = cuser.inv_deployments.filter_by(deleted=False).filter_by(bridge_id=None).order_by(Deployment.date_created.desc()).all()
inv_deploycubeids = [] inv_deploycubeids = []
inv_deployments_list = [] inv_deployments_list = []
for invcls in inv_deployments: for invcls in inv_deployments:
inv_deploycubeids.extend([invcls.machine_id]) inv_deploycubeids.extend([invcls.machine_id])
inv_deployments_list.extend([invcls.machine_alias]) inv_deployments_list.extend([invcls.machine_alias])
for invcls in inv_legacy:
if invcls.user_id == cuser.pid:
inv_deploycubeids.extend([invcls.machine_id])
inv_services = cuser.inv_services.filter_by(deleted=False).order_by(Service.date_last_charge.asc()).all() inv_services = cuser.inv_services.filter_by(deleted=False).order_by(Service.date_last_charge.asc()).all()
inv_services_list = [] inv_services_list = []
@ -205,6 +210,6 @@ def dashboard(user_pid=0):
status = { unit_id : query['status'] } status = { unit_id : query['status'] }
statuses.update(status) statuses.update(status)
current_app.logger.info('[{}] Enabled deployments: {}, services: {}, domains: {}, bridges: {}, addresses: {}'.format(cuser.email, inv_deployments_list, inv_services_list, inv_domains_list, inv_bridges_list, inv_addresses_list)) current_app.logger.info('[{}] Enabled deployments: {}, services: {}, domains: {}, bridges: {}, addresses: {}'.format(cuser.email, inv_deployments_list, inv_services_list, inv_domains_list, inv_bridges_list, inv_addresses_list))
return render_template('main/dashboard.html', rrd=rrd, status=statuses, inv_deployments=inv_deployments, inv_services=inv_services, inv_domains=inv_domains, inv_bridges=inv_bridges, inv_addresses=inv_addresses, region=regions) return render_template('main/dashboard.html', rrd=rrd, status=statuses, inv_deployments=inv_deployments, inv_legacy=inv_legacy, inv_services=inv_services, inv_domains=inv_domains, inv_bridges=inv_bridges, inv_addresses=inv_addresses, regions=regions)

View file

@ -64,14 +64,19 @@ def dashboard():
inv_addresses = cuser.inv_addresses.order_by(Address.ip.asc()).all() inv_addresses = cuser.inv_addresses.order_by(Address.ip.asc()).all()
inv_routers = cuser.inv_routers.order_by(Router.date_created.asc()).all() inv_routers = cuser.inv_routers.order_by(Router.date_created.asc()).all()
inv_deployments = cuser.inv_deployments.filter_by(deleted=False).order_by(Deployment.date_created.desc()).all() inv_deployments = cuser.inv_deployments.filter_by(deleted=False).order_by(Deployment.date_created.desc()).all()
inv_legacy = cuser.inv_deployments.filter_by(deleted=False).filter_by(bridge_id=None).order_by(Deployment.date_created.desc()).all()
regions = {} regions = {}
for region in sys_regions: for region in sys_regions:
regions[region.pid] = region.description regions[region.pid] = region.description
inv_deploycubeids = [] inv_deploycubeids = []
for invcls in inv_deployments: for invcls in inv_deployments:
if invcls.user_id == cuser.pid: if invcls.user_id == cuser.pid:
inv_deploycubeids.extend([invcls.machine_id]) inv_deploycubeids.extend([invcls.machine_id])
for invcls in inv_legacy:
if invcls.user_id == cuser.pid:
inv_deploycubeids.extend([invcls.machine_id])
inv_services = cuser.inv_services.filter_by(deleted=False).order_by(Service.date_last_charge.asc()).all() inv_services = cuser.inv_services.filter_by(deleted=False).order_by(Service.date_last_charge.asc()).all()
inv_domains = cuser.inv_domains.filter_by(deleted=False).order_by(Domain.date_created.desc()).all() inv_domains = cuser.inv_domains.filter_by(deleted=False).order_by(Domain.date_created.desc()).all()
@ -107,5 +112,5 @@ def dashboard():
send_email(current_app.config['MAIL_USERNAME'], 'Cube {} is unreachable'.format(unit_id), 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=str(e))
return render_template('main/dashboard.html', sys_regions=sys_regions, inv_bridges=inv_bridges, inv_deployments=inv_deployments, inv_services=inv_services, inv_domains=inv_domains, inv_addresses=inv_addresses, rrd=rrd, status=statuses) return render_template('main/dashboard.html', sys_regions=sys_regions, inv_bridges=inv_bridges, inv_deployments=inv_deployments, inv_legacy=inv_legacy, inv_services=inv_services, inv_domains=inv_domains, inv_addresses=inv_addresses, rrd=rrd, status=statuses, regions=regions)

View file

@ -56,7 +56,7 @@ class User(db.Model, UserMixin):
pid = db.Column(db.Integer, primary_key=True) pid = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String, unique=True, index=True) email = db.Column(db.String, unique=True, index=True)
role_id = db.Column(db.Integer, db.ForeignKey('roles.pid')) #FK role_id = db.Column(db.ForeignKey('roles.pid')) #FK
password_hash = db.Column(db.String) password_hash = db.Column(db.String)
tokens = db.Column(db.Text) tokens = db.Column(db.Text)
@ -243,8 +243,8 @@ class Region(db.Model):
class Bridge(db.Model): class Bridge(db.Model):
__tablename__ = 'bridges' __tablename__ = 'bridges'
pid = db.Column(db.Integer, primary_key=True) pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK user_id = db.Column(db.ForeignKey('users.pid')) #FK
region_id = db.Column(db.Integer, db.ForeignKey('regions.pid')) #FK region_id = db.Column(db.ForeignKey('regions.pid')) #FK
inv_routers = db.relationship('Router', backref='bridge', lazy='dynamic') inv_routers = db.relationship('Router', backref='bridge', lazy='dynamic')
inv_deployments = db.relationship('Deployment', backref='bridge', lazy='dynamic') inv_deployments = db.relationship('Deployment', backref='bridge', lazy='dynamic')
@ -255,8 +255,8 @@ class Bridge(db.Model):
class Router(db.Model): class Router(db.Model):
__tablename__ = 'routers' __tablename__ = 'routers'
pid = db.Column(db.Integer, primary_key=True) pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK user_id = db.Column(db.ForeignKey('users.pid')) #FK
bridge_id = db.Column(db.Integer, db.ForeignKey('bridges.pid')) #FK bridge_id = db.Column(db.ForeignKey('bridges.pid')) #FK
inv_addresses = db.relationship('Address', backref='router', lazy='dynamic') inv_addresses = db.relationship('Address', backref='router', lazy='dynamic')
date_created = db.Column(db.DateTime, default=datetime.utcnow) date_created = db.Column(db.DateTime, default=datetime.utcnow)
@ -267,8 +267,8 @@ class Router(db.Model):
class Deployment(db.Model): class Deployment(db.Model):
__tablename__ = 'deployments' __tablename__ = 'deployments'
pid = db.Column(db.Integer, primary_key=True) pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK user_id = db.Column(db.ForeignKey('users.pid')) #FK
bridge_id = db.Column(db.Integer, db.ForeignKey('bridges.pid')) #FK bridge_id = db.Column(db.ForeignKey('bridges.pid')) #FK
date_created = db.Column(db.DateTime, default=datetime.utcnow) date_created = db.Column(db.DateTime, default=datetime.utcnow)
deleted = db.Column(db.Boolean, default=False) deleted = db.Column(db.Boolean, default=False)
@ -289,9 +289,9 @@ class Deployment(db.Model):
class Address(db.Model): class Address(db.Model):
__tablename__ = 'address' __tablename__ = 'address'
pid = db.Column(db.Integer, primary_key=True) pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK user_id = db.Column(db.ForeignKey('users.pid')) #FK
region_id = db.Column(db.Integer, db.ForeignKey('regions.pid')) #FK region_id = db.Column(db.ForeignKey('regions.pid')) #FK
router_id = db.Column(db.Integer, db.ForeignKey('routers.pid')) #FK router_id = db.Column(db.ForeignKey('routers.pid')) #FK
date_assigned = db.Column(db.DateTime, default=datetime.utcnow) date_assigned = db.Column(db.DateTime, default=datetime.utcnow)
enabled = db.Column(db.Boolean) enabled = db.Column(db.Boolean)
@ -325,7 +325,7 @@ class Address(db.Model):
class Service(db.Model): class Service(db.Model):
__tablename__ = 'services' __tablename__ = 'services'
pid = db.Column(db.Integer, primary_key=True) #PK pid = db.Column(db.Integer, primary_key=True) #PK
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK user_id = db.Column(db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, default=datetime.utcnow) date_created = db.Column(db.DateTime, default=datetime.utcnow)
deleted = db.Column(db.Boolean, default=False) deleted = db.Column(db.Boolean, default=False)
@ -342,7 +342,7 @@ class Service(db.Model):
class Domain(db.Model): class Domain(db.Model):
__tablename__ = 'domains' __tablename__ = 'domains'
pid = db.Column(db.Integer, primary_key=True) pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK user_id = db.Column(db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, default=datetime.utcnow) date_created = db.Column(db.DateTime, default=datetime.utcnow)
deleted = db.Column(db.Boolean, default=False) deleted = db.Column(db.Boolean, default=False)
@ -358,7 +358,7 @@ class Domain(db.Model):
class Transaction(db.Model): class Transaction(db.Model):
__tablename__ = 'transaction' __tablename__ = 'transaction'
pid = db.Column(db.Integer, primary_key=True) pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK user_id = db.Column(db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, default=datetime.utcnow) date_created = db.Column(db.DateTime, default=datetime.utcnow)
currency = db.Column(db.String, default='BGN') currency = db.Column(db.String, default='BGN')
@ -368,7 +368,7 @@ class Transaction(db.Model):
class Invoice(db.Model): class Invoice(db.Model):
__tablename__ = 'invoice' __tablename__ = 'invoice'
pid = db.Column(db.Integer, primary_key=True) pid = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.pid')) #FK user_id = db.Column(db.ForeignKey('users.pid')) #FK
date_created = db.Column(db.DateTime, default=datetime.utcnow) date_created = db.Column(db.DateTime, default=datetime.utcnow)
invoice_number = db.Column(db.Integer, unique=True) invoice_number = db.Column(db.Integer, unique=True)
@ -398,7 +398,7 @@ class InvoiceItem(db.Model):
__tablename__ = 'invoice_item' __tablename__ = 'invoice_item'
pid = db.Column(db.Integer, primary_key=True) pid = db.Column(db.Integer, primary_key=True)
item_number = db.Column(db.Integer) item_number = db.Column(db.Integer)
invoice_id = db.Column(db.Integer, db.ForeignKey('invoice.pid')) #FK invoice_id = db.Column(db.ForeignKey('invoice.pid')) #FK
item_title = db.Column(db.Unicode) item_title = db.Column(db.Unicode)
item_quantity = db.Column(db.Float) item_quantity = db.Column(db.Float)
item_price = db.Column(db.Float) item_price = db.Column(db.Float)

View file

@ -138,7 +138,37 @@ addEventListener("DOMContentLoaded", function() {
{% endif %} {% endif %}
<div class="row"> <div class="row">
{% for bridge in inv_bridges %}
<div class="col-md-12">
<div class="panel panel-info" id="deployments">
<div class="panel-heading">Private Network Manager #{{ bridge.bridge_id }}</div>
<div class="panel-body"><p>
<div class="panel-group" id="deploycubes" role="tablist" aria-multiselectable="true">
{% for deploy in bridge.inv_deployments %}
{% include "main/vdc_pool.html" %} {% include "main/vdc_pool.html" %}
{% endfor %}
</div>
</div>
</div>
</div>
{% endfor %}
{% if inv_legacy != [] %}
<div class="col-md-12">
<div class="panel panel-info" id="legacy_deployments">
<div class="panel-heading">Network Manager</div>
<div class="panel-body"><p>
<div class="panel-group" id="deploylegacycubes" role="tablist" aria-multiselectable="true">
{% for deploy in inv_legacy %}
{% include "main/vdc_pool2.html" %}
{% endfor %}
</div>
</div>
</div>
</div>
{% endif %}
{% if inv_domains != [] %} {% if inv_domains != [] %}
<div class="col-md-12"> <div class="col-md-12">
@ -222,7 +252,7 @@ addEventListener("DOMContentLoaded", function() {
{% for address in inv_addresses %} {% for address in inv_addresses %}
<tr> <tr>
<td data-title="IP">{{ address.ip }}</td> <td data-title="IP">{{ address.ip }}</td>
<td data-title="Region">{{ region[address.region_id] }}</td> <td data-title="Region">{{ regions[address.region_id] }}</td>
<td data-title="RDNS">{{ address.rdns }}</td> <td data-title="RDNS">{{ address.rdns }}</td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -1,10 +1,4 @@
<div class="col-md-12"> {% block vdc_pool %}
<div class="panel panel-info" id="deployments">
<div class="panel-heading">Device Manager</div>
<div class="panel-body"><p>
{% if inv_deployments != [] %}
<div class="panel-group" id="deploycubes" role="tablist" aria-multiselectable="true">
{% for deploy in inv_deployments %}
{% if deploy.enabled == False %} {% if deploy.enabled == False %}
<div class="panel panel-danger" style="margin-top: 2px"> <div class="panel panel-danger" style="margin-top: 2px">
{% else %} {% else %}
@ -101,21 +95,11 @@
</div> </div>
</div> </div>
<!-- END OF HIDDEN PANEL --> <!-- END OF HIDDEN PANEL -->
{% endfor %}
</div>
<!--Cloud Storage icon by Icons8 --> <!--Cloud Storage icon by Icons8 -->
{% if inv_deployments != [] %}
<!-- TODO: Create new deployment within this pool! -->
{% else %} {% else %}
<button class="btn btn-default btn-lg btn-block" onclick="window.open('{{ url_for('vmanager.createvm') }}','_self')"><img class="icon icons8-Cloud-Storage" width="48" height="48" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAEEklEQVRYhe3Xy0/bBhwHcA6btEMP0077A3boYYdK23EHLiQ0hQBtVC1S9zjs0L069TCkSUWNpgZCshDYItZOI+tKH7Cibgw6Wu2RAXWMYyc8mpAoUAIEp6VuTR5OwAnJd5dBEbYJKDSA1J/0PfjgXz6y5W/ssrKDNm9dYl4+aqYeq00kSpnK5pGUusX1WkGgxux+/ePLvmQ4lkcp88nPfkHV6DpcEFhpGnnH2D8XKzXwQv98UtXoqioIVDeRH/1IcKlSAzsIbqXSTJ0tCKy2uNt/uy+slhrYez8JrY25XhCotdKDgzNiSXHhWB5DYRFaK+0tfAWt9Pzow9WSA8cereKYheILAo/bGDHE72z5n8E46rsC0LXR0LXRqO8K4O5kbEc7pvg8TrQxuXKD8xVFnLrJ9canVyYTO1k84FvCe+1eXCcWwPLLYPlldJMsPrg4ipsMtyPkmasBQWUk3twKWGm8PRff7kImsoxT7V5MLwrYPPNP0tDbPfh3KrltoGkgIqgaXbVbAT9zuLi00oIHfA6O4ShOOyZQZaFQZ3Pjbx8nwa3NcPAp1CYSersH529NwcuubAn8iXya0VjcXykCtVa6o9cn5JVwZzr9OHcziNBDAWI2hzCXwmourwgEAF7IgEuI6CJZ6FppMJFlRWCfX0BNq6dLEVjdQlODYfmK6RiK4twvwS0xheYasYCGnpAi8N6sCK2V8SsCq76hFsce5WRPPu2YQIBNFgXkEiL0do8icGIxB42Fisviyg3Ol463MtkpmYoZj4qoslAQs7migACgNpFo7Hsge6unl/I4+Z0nW25wHpIAVY2uw593BiQVMx4V8eGlMVwZjhSNA4B4OgtL/zROfsvIIs/eCAoVRuKIHLC26Y+IBGjqn0GHc25XcBvnh39mcaF3WgK03F1IqZoJnQR41EzVO1xPVjaf8P73o2D55V0HTi8K0LXREmAnxWe1VtogrZgW+sbvPkFygt7uAZcQdx2o9MDcnkyh1sb8KgNkvEMyFXP+1hS6SXbXgd0kK1s5rrkMalqYSQlQY6HichXjZVdwqt2LHioKXsgUDeMSIrpJFnU2N9xzacnv+R7noDFTwuaKOXSizSPKVcwasqEnhDqbu+iPI73dg4aekCwuHMtjZikPvd2TLTc4X10HVhiJI19cDe7oLeZ55suukFDRfO/tZxXTTOhMdxZK/iWnFNtf0bTKRLy7DjxmcX99meLFvYat5RodW61uYZo2PsH9fX5pxexV7gTTqGn1DGzswODwbGbPYWsZiWSgtTGhZxVjpoTxRfm3mL2In8tBY6ZS60C1icRFJrevojaReAF8bkAykkcqAxDz+W0dFxOlXVsCU///5aYy2NZxMVHadbCv4H7IC+CuA/djyg7C/AeJ36h1J+7ehgAAAABJRU5ErkJggg=="> Create</button> <button class="btn btn-default btn-lg btn-block" onclick="window.open('{{ url_for('vmanager.createvm') }}','_self')"><img class="icon icons8-Cloud-Storage" width="48" height="48" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAEEklEQVRYhe3Xy0/bBhwHcA6btEMP0077A3boYYdK23EHLiQ0hQBtVC1S9zjs0L069TCkSUWNpgZCshDYItZOI+tKH7Cibgw6Wu2RAXWMYyc8mpAoUAIEp6VuTR5OwAnJd5dBEbYJKDSA1J/0PfjgXz6y5W/ssrKDNm9dYl4+aqYeq00kSpnK5pGUusX1WkGgxux+/ePLvmQ4lkcp88nPfkHV6DpcEFhpGnnH2D8XKzXwQv98UtXoqioIVDeRH/1IcKlSAzsIbqXSTJ0tCKy2uNt/uy+slhrYez8JrY25XhCotdKDgzNiSXHhWB5DYRFaK+0tfAWt9Pzow9WSA8cereKYheILAo/bGDHE72z5n8E46rsC0LXR0LXRqO8K4O5kbEc7pvg8TrQxuXKD8xVFnLrJ9canVyYTO1k84FvCe+1eXCcWwPLLYPlldJMsPrg4ipsMtyPkmasBQWUk3twKWGm8PRff7kImsoxT7V5MLwrYPPNP0tDbPfh3KrltoGkgIqgaXbVbAT9zuLi00oIHfA6O4ShOOyZQZaFQZ3Pjbx8nwa3NcPAp1CYSersH529NwcuubAn8iXya0VjcXykCtVa6o9cn5JVwZzr9OHcziNBDAWI2hzCXwmourwgEAF7IgEuI6CJZ6FppMJFlRWCfX0BNq6dLEVjdQlODYfmK6RiK4twvwS0xheYasYCGnpAi8N6sCK2V8SsCq76hFsce5WRPPu2YQIBNFgXkEiL0do8icGIxB42Fisviyg3Ol463MtkpmYoZj4qoslAQs7migACgNpFo7Hsge6unl/I4+Z0nW25wHpIAVY2uw593BiQVMx4V8eGlMVwZjhSNA4B4OgtL/zROfsvIIs/eCAoVRuKIHLC26Y+IBGjqn0GHc25XcBvnh39mcaF3WgK03F1IqZoJnQR41EzVO1xPVjaf8P73o2D55V0HTi8K0LXREmAnxWe1VtogrZgW+sbvPkFygt7uAZcQdx2o9MDcnkyh1sb8KgNkvEMyFXP+1hS6SXbXgd0kK1s5rrkMalqYSQlQY6HichXjZVdwqt2LHioKXsgUDeMSIrpJFnU2N9xzacnv+R7noDFTwuaKOXSizSPKVcwasqEnhDqbu+iPI73dg4aekCwuHMtjZikPvd2TLTc4X10HVhiJI19cDe7oLeZ55suukFDRfO/tZxXTTOhMdxZK/iWnFNtf0bTKRLy7DjxmcX99meLFvYat5RodW61uYZo2PsH9fX5pxexV7gTTqGn1DGzswODwbGbPYWsZiWSgtTGhZxVjpoTxRfm3mL2In8tBY6ZS60C1icRFJrevojaReAF8bkAykkcqAxDz+W0dFxOlXVsCU///5aYy2NZxMVHadbCv4H7IC+CuA/djyg7C/AeJ36h1J+7ehgAAAABJRU5ErkJggg=="> Create</button>
{% endif %} {% endif %}
</div> {% endblock %}
</div>
</div>
{% else %}
<button class="btn btn-default btn-lg btn-block" onclick="window.open('{{ url_for('vmanager.createvm') }}','_self')"><img class="icon icons8-Cloud-Storage" width="48" height="48" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAEEklEQVRYhe3Xy0/bBhwHcA6btEMP0077A3boYYdK23EHLiQ0hQBtVC1S9zjs0L069TCkSUWNpgZCshDYItZOI+tKH7Cibgw6Wu2RAXWMYyc8mpAoUAIEp6VuTR5OwAnJd5dBEbYJKDSA1J/0PfjgXz6y5W/ssrKDNm9dYl4+aqYeq00kSpnK5pGUusX1WkGgxux+/ePLvmQ4lkcp88nPfkHV6DpcEFhpGnnH2D8XKzXwQv98UtXoqioIVDeRH/1IcKlSAzsIbqXSTJ0tCKy2uNt/uy+slhrYez8JrY25XhCotdKDgzNiSXHhWB5DYRFaK+0tfAWt9Pzow9WSA8cereKYheILAo/bGDHE72z5n8E46rsC0LXR0LXRqO8K4O5kbEc7pvg8TrQxuXKD8xVFnLrJ9canVyYTO1k84FvCe+1eXCcWwPLLYPlldJMsPrg4ipsMtyPkmasBQWUk3twKWGm8PRff7kImsoxT7V5MLwrYPPNP0tDbPfh3KrltoGkgIqgaXbVbAT9zuLi00oIHfA6O4ShOOyZQZaFQZ3Pjbx8nwa3NcPAp1CYSersH529NwcuubAn8iXya0VjcXykCtVa6o9cn5JVwZzr9OHcziNBDAWI2hzCXwmourwgEAF7IgEuI6CJZ6FppMJFlRWCfX0BNq6dLEVjdQlODYfmK6RiK4twvwS0xheYasYCGnpAi8N6sCK2V8SsCq76hFsce5WRPPu2YQIBNFgXkEiL0do8icGIxB42Fisviyg3Ol463MtkpmYoZj4qoslAQs7migACgNpFo7Hsge6unl/I4+Z0nW25wHpIAVY2uw593BiQVMx4V8eGlMVwZjhSNA4B4OgtL/zROfsvIIs/eCAoVRuKIHLC26Y+IBGjqn0GHc25XcBvnh39mcaF3WgK03F1IqZoJnQR41EzVO1xPVjaf8P73o2D55V0HTi8K0LXREmAnxWe1VtogrZgW+sbvPkFygt7uAZcQdx2o9MDcnkyh1sb8KgNkvEMyFXP+1hS6SXbXgd0kK1s5rrkMalqYSQlQY6HichXjZVdwqt2LHioKXsgUDeMSIrpJFnU2N9xzacnv+R7noDFTwuaKOXSizSPKVcwasqEnhDqbu+iPI73dg4aekCwuHMtjZikPvd2TLTc4X10HVhiJI19cDe7oLeZ55suukFDRfO/tZxXTTOhMdxZK/iWnFNtf0bTKRLy7DjxmcX99meLFvYat5RodW61uYZo2PsH9fX5pxexV7gTTqGn1DGzswODwbGbPYWsZiWSgtTGhZxVjpoTxRfm3mL2In8tBY6ZS60C1icRFJrevojaReAF8bkAykkcqAxDz+W0dFxOlXVsCU///5aYy2NZxMVHadbCv4H7IC+CuA/djyg7C/AeJ36h1J+7ehgAAAABJRU5ErkJggg=="> Create</button>
{% endif %}
</div>
</div>
</div>

View file

@ -62,8 +62,8 @@ def createvm():
slave_name = query['slave'] slave_name = query['slave']
bridge_id = query['unit_id'] bridge_id = query['unit_id']
bridge_phy_id = query['phy_id'] bridge_phy_id = query['phy_id']
bridge = Bridge(user_id=int(current_user.pid), bridge_id=bridge_id) selected_bridge = Bridge(user_id=int(current_user.pid), bridge_id=bridge_id)
db.session.add(bridge) db.session.add(selected_bridge)
db.session.commit() db.session.commit()
flash('New point created successfully in region "{}".'.format(str(selected_region.description))) flash('New point created successfully in region "{}".'.format(str(selected_region.description)))
else: else:
@ -104,7 +104,7 @@ def createvm():
return redirect(url_for('main.dashboard')) return redirect(url_for('main.dashboard'))
if query['status'] == 'kvm_created': if query['status'] == 'kvm_created':
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) 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.add(deployment)
db.session.commit() db.session.commit()
flash('New device created successfully in region "{}".'.format(str(selected_region.description))) flash('New device created successfully in region "{}".'.format(str(selected_region.description)))

View file

@ -67,7 +67,7 @@ def autodisable():
lastcharge = deploy.date_last_charge lastcharge = deploy.date_last_charge
expiry = lastcharge + relativedelta(lastcharge, months=+(deploy.period)) expiry = lastcharge + relativedelta(lastcharge, months=+(deploy.period))
if today > expiry: if today > expiry:
email_content = 'Deployment "' + deploy.machine_alias + '" is past expiration date and will be marked INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c') email_content = '[!] Deployment "' + deploy.machine_alias + '" is past expiration date and will be marked INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c')
print(str(email_content)) print(str(email_content))
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content)) send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content))
deploy.warning = False deploy.warning = False
@ -81,7 +81,7 @@ def autodisable():
lastcharge = service.date_last_charge lastcharge = service.date_last_charge
expiry = lastcharge + relativedelta(lastcharge, months=+(service.period)) expiry = lastcharge + relativedelta(lastcharge, months=+(service.period))
if today > expiry: if today > expiry:
email_content = 'Service "' + service.description + '" is past expiration date and will be marked INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c') email_content = '[!] Service "' + service.description + '" is past expiration date and will be marked INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c')
print(str(email_content)) print(str(email_content))
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=service.owner, content=str(email_content)) send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=service.owner, content=str(email_content))
service.warning = False service.warning = False
@ -94,7 +94,7 @@ def autodisable():
for domain in domains_ena: for domain in domains_ena:
expiry = domain.date_expire expiry = domain.date_expire
if today > expiry: if today > expiry:
email_content = 'Domain "' + domain.fqdn + '" is past expiration date and will be marked as INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c') email_content = '[!] Domain "' + domain.fqdn + '" is past expiration date and will be marked as INACTIVE. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c')
print(str(email_content)) print(str(email_content))
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=domain.owner, content=str(email_content)) send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=domain.owner, content=str(email_content))
domain.warning = False domain.warning = False
@ -118,10 +118,11 @@ def autowarn():
deploy.daysleft = daysleft.days + 1 deploy.daysleft = daysleft.days + 1
db.session.commit() db.session.commit()
warndays = deploy.period * 5 warndays = deploy.period * 5
if daysleft.days < warndays:
email_content = 'Deployment "' + deploy.machine_alias + '" is ' + str(daysleft.days) + ' days until expiration. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c') email_content = 'Deployment "' + deploy.machine_alias + '" is ' + str(daysleft.days) + ' days until expiration. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c')
print(str(email_content)) if daysleft.days == warndays or (daysleft.days / 2) == warndays:
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content)) send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=deploy.owner, content=str(email_content))
if daysleft.days < warndays:
print(str(email_content))
deploy.warning = True deploy.warning = True
db.session.commit() db.session.commit()
@ -134,10 +135,11 @@ def autowarn():
service.daysleft = daysleft.days + 1 service.daysleft = daysleft.days + 1
db.session.commit() db.session.commit()
warndays = service.period * 5 warndays = service.period * 5
if daysleft.days < warndays:
email_content = 'Service "' + service.description + '" is ' + str(daysleft.days) + ' days until expiration. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c') email_content = 'Service "' + service.description + '" is ' + str(daysleft.days) + ' days until expiration. Last charged: ' + lastcharge.strftime('%c') + ' expiry date: ' + expiry.strftime('%c')
print(str(email_content)) if daysleft.days == warndays or (daysleft.days / 2) == warndays:
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=service.owner, content=str(email_content)) send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=service.owner, content=str(email_content))
if daysleft.days < warndays:
print(str(email_content))
service.warning = True service.warning = True
db.session.commit() db.session.commit()
@ -148,10 +150,11 @@ def autowarn():
domain.daysleft = daysleft.days + 1 domain.daysleft = daysleft.days + 1
db.session.commit() db.session.commit()
warndays = domain.period * 5 warndays = domain.period * 5
if daysleft.days < warndays:
email_content = 'Domain "' + domain.fqdn + '" is ' + str(daysleft.days)+ ' days until expiration. Expiry date: ' + expiry.strftime('%c') email_content = 'Domain "' + domain.fqdn + '" is ' + str(daysleft.days)+ ' days until expiration. Expiry date: ' + expiry.strftime('%c')
print(str(email_content)) if daysleft.days == warndays or (daysleft.days / 2) == warndays:
send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=domain.owner, content=str(email_content)) send_email(app.config['MAIL_USERNAME'], str(email_content), 'email/adm_logger', user=domain.owner, content=str(email_content))
if daysleft.days < warndays:
print(str(email_content))
domain.warning = True domain.warning = True
db.session.commit() db.session.commit()