diff --git a/dash/__init__.py b/dash/__init__.py index 08269e5..55da073 100644 --- a/dash/__init__.py +++ b/dash/__init__.py @@ -60,6 +60,18 @@ def create_app(config_name): # server application from .server import server as server_blueprint dash.register_blueprint(server_blueprint, url_prefix='/server') + + # image application + from .image import image as image_blueprint + dash.register_blueprint(image_blueprint, url_prefix='/image') + + # security application + from .security import security as security_blueprint + dash.register_blueprint(security_blueprint, url_prefix='/security') + + # network application + from .network import network as network_blueprint + dash.register_blueprint(network_blueprint, url_prefix='/network') # admin application from .admin import admin as admin_blueprint diff --git a/dash/image/__init__.py b/dash/image/__init__.py new file mode 100644 index 0000000..1ed4ee4 --- /dev/null +++ b/dash/image/__init__.py @@ -0,0 +1,5 @@ +from flask import Blueprint + +image = Blueprint('image', __name__) + +from . import views \ No newline at end of file diff --git a/dash/image/forms.py b/dash/image/forms.py new file mode 100644 index 0000000..e69de29 diff --git a/dash/image/views.py b/dash/image/views.py new file mode 100644 index 0000000..82c8ca3 --- /dev/null +++ b/dash/image/views.py @@ -0,0 +1,46 @@ +import datetime, requests, json, string, random +import humanize as humanize + +from keystoneauth1 import loading +from keystoneauth1 import session +import glanceclient.v2.client as glclient + +from flask import render_template, redirect, request, url_for, flash +from flask_login import login_user, logout_user, login_required, \ + current_user +from flask_principal import Identity, AnonymousIdentity, \ + identity_changed + +from . import image +from .. import db +from ..models import User, Role, Provider +from ..email import send_email +from ..decorators import requires_roles + +@image.route('/', methods=['GET', 'POST']) +@login_required +@requires_roles("user","admin") +def index(): + return render_template('image/index.html') + +@image.route('/list-images', methods=['GET', 'POST']) +@login_required +@requires_roles("user","admin") +def list_images(): + user = User.query.get_or_404(current_user.id) + provider = Provider.query.get_or_404("1") + loader = loading.get_plugin_loader('password') + auth = loader.load_from_options(auth_url=provider.url, + username=user.username, + password=user.provider_password, + project_name=user.username, + project_domain_name='Default', + user_domain_name='Default') + sess = session.Session(auth=auth) + glance = glclient.Client('2', session=sess) + images = glance.images.list() + return render_template('image/list_images.html',humanize=humanize, + title="List Imags", + block_description = "list images and applications", + user=user, provider=provider,glance=glance, + images=images) \ No newline at end of file diff --git a/dash/network/__init__.py b/dash/network/__init__.py new file mode 100644 index 0000000..b9de437 --- /dev/null +++ b/dash/network/__init__.py @@ -0,0 +1,5 @@ +from flask import Blueprint + +network = Blueprint('network', __name__) + +from . import views \ No newline at end of file diff --git a/dash/network/forms.py b/dash/network/forms.py new file mode 100644 index 0000000..e69de29 diff --git a/dash/network/views.py b/dash/network/views.py new file mode 100644 index 0000000..458d153 --- /dev/null +++ b/dash/network/views.py @@ -0,0 +1,61 @@ +import datetime, requests, json, string, random + +from keystoneauth1 import identity +from keystoneauth1 import session +from neutronclient.v2_0 import client + + +from flask import render_template, redirect, request, url_for, flash +from flask_login import login_user, logout_user, login_required, \ + current_user +from flask_principal import Identity, AnonymousIdentity, \ + identity_changed + +from . import network +from .. import db +from ..models import User, Role, Provider +from ..email import send_email +from ..decorators import requires_roles + +def print_values(val, type): + if type == 'ports': + val_list = val['ports'] + if type == 'networks': + val_list = val['networks'] + if type == 'routers': + val_list = val['routers'] + for p in val_list: + for k, v in p.items(): + print("%s : %s" % (k, v)) + print('\n') + + +@network.route('/', methods=['GET', 'POST']) +@login_required +@requires_roles("user","admin") +def index(): + return render_template('network/index.html') + +@network.route('/list-networks', methods=['GET', 'POST']) +@login_required +@requires_roles("user","admin") +def list_networks(): + user = User.query.get_or_404(current_user.id) + provider = Provider.query.get_or_404("1") + auth = identity.Password(auth_url=provider.url, + username=user.username, + password=user.provider_password, + project_name=user.username, + project_domain_name='Default', + user_domain_name='Default') + sess = session.Session(auth=auth) + neutron = client.Client(session=sess) + networks = neutron.list_networks() + subnets = neutron.list_subnets() + routers = neutron.list_routers() + return render_template('network/list_networks.html', + title="List Networks", + block_description = "manage all of your networks", + user=user, provider=provider,neutron=neutron, + networks=networks,subnets=subnets,routers=routers, + sess=sess) \ No newline at end of file diff --git a/dash/security/__init__.py b/dash/security/__init__.py new file mode 100644 index 0000000..d0aeb5f --- /dev/null +++ b/dash/security/__init__.py @@ -0,0 +1,5 @@ +from flask import Blueprint + +security = Blueprint('security', __name__) + +from . import views \ No newline at end of file diff --git a/dash/security/forms.py b/dash/security/forms.py new file mode 100644 index 0000000..e69de29 diff --git a/dash/security/views.py b/dash/security/views.py new file mode 100644 index 0000000..2eee0ce --- /dev/null +++ b/dash/security/views.py @@ -0,0 +1,22 @@ +import datetime, requests, json, string, random + +from keystoneauth1 import loading +from keystoneauth1 import session + +from flask import render_template, redirect, request, url_for, flash +from flask_login import login_user, logout_user, login_required, \ + current_user +from flask_principal import Identity, AnonymousIdentity, \ + identity_changed + +from . import security +from .. import db +from ..models import User, Role, Provider +from ..email import send_email +from ..decorators import requires_roles + +@security.route('/', methods=['GET', 'POST']) +@login_required +@requires_roles("user","admin") +def index(): + return render_template('security/index.html') \ No newline at end of file diff --git a/dash/templates/image/content_header.html b/dash/templates/image/content_header.html new file mode 100644 index 0000000..92c0bef --- /dev/null +++ b/dash/templates/image/content_header.html @@ -0,0 +1,8 @@ +

+ {{ title }} + {{ block_description }} +

+ \ No newline at end of file diff --git a/dash/templates/image/index.html b/dash/templates/image/index.html new file mode 100644 index 0000000..9a736ba --- /dev/null +++ b/dash/templates/image/index.html @@ -0,0 +1,121 @@ +{% extends "adminlte/base.html" %} +{% import "adminlte/layout.html" as layout with context %} +{% import "adminlte/widgets.html" as widgets with context %} + +{% block navbar %} + + {% include "navbar.html" %} + +{%- endblock navbar %} + + +{% block sidebar -%} + + {% include 'sidebar.html' %} + + {% include 'sidebar_menu.html' %} + +{%- endblock sidebar %} + + +{% block content_header -%} + {% include 'content_header.html' %} +{%- endblock content_header %} + + +{% block content -%} + + +
+ + {{ + widgets.small_box( + bgcolor="bg-aqua", + header=150, + body="Total Servers", + iconclass="ion ion-cloud", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-green", + header=53, + body="Bounce Rate", + iconclass="ion ion-stats-bars", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-yellow", + header=43, + body="User Registrations", + iconclass="ion ion-person-add", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-red", + header=65, + body="Unique Visitors", + iconclass="ion ion-pie-graph", + footerlink="#" + ) + }} + +
+ + +
+ + {{ + widgets.small_box( + bgcolor="bg-blue", + header=230, + body="Sales", + iconclass="ion ion-ios7-cart-outline", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-purple", + header=80, + percentage=True, + body="Conversion Rate", + iconclass="ion ion-ios7-briefcase-outline", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-teal", + header=14, + body="Notifications", + iconclass="ion ion-ios7-alarm-outline", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-maroon", + header=160, + body="Products", + iconclass="ion ion-ios7-pricetag-outline", + footerlink="#" + ) + }} + +
+{%- endblock content %} diff --git a/dash/templates/image/list_images.html b/dash/templates/image/list_images.html new file mode 100644 index 0000000..36ac373 --- /dev/null +++ b/dash/templates/image/list_images.html @@ -0,0 +1,87 @@ +{% extends "adminlte/base.html" %} +{% import "adminlte/layout.html" as layout with context %} +{% import "adminlte/widgets.html" as widgets with context %} + +{% block title %}Server - {{ title }}{% endblock %} +{% block description %}{{ block_description }}{% endblock %} + +{% block navbar %} + + {% include "navbar.html" %} + +{%- endblock navbar %} + + +{% block sidebar -%} + + {% include 'sidebar.html' %} + + {% include 'sidebar_menu.html' %} + +{%- endblock sidebar %} + + +{% block content_header -%} + {% include 'server/content_header.html' %} +{%- endblock content_header %} + +{% block content -%} + +
+
+
+
+ + + + + + + + + + + + + {% for image in images %} + + + + + + + + + {% endfor %} + + + + + + + + + + + +
Image NameTypeStatusFormatSizeAction
{{ image.name.title() }} + {% if image.image_location %} + {{ image.image_location.title() }} + {% else %} + Image + {% endif %} + {{ image.status.title() }}{{ image.disk_format.upper() }}{{ humanize.naturalsize(image.size) }} + Edit + | + Delete +
Image NameTypeStatusFormatSizeAction
+
+ +
+ +
+ +
+ + +{%- endblock content %} \ No newline at end of file diff --git a/dash/templates/network/content_header.html b/dash/templates/network/content_header.html new file mode 100644 index 0000000..734c270 --- /dev/null +++ b/dash/templates/network/content_header.html @@ -0,0 +1,8 @@ +

+ {{ title }} + {{ block_description }} +

+ \ No newline at end of file diff --git a/dash/templates/network/index.html b/dash/templates/network/index.html new file mode 100644 index 0000000..9a736ba --- /dev/null +++ b/dash/templates/network/index.html @@ -0,0 +1,121 @@ +{% extends "adminlte/base.html" %} +{% import "adminlte/layout.html" as layout with context %} +{% import "adminlte/widgets.html" as widgets with context %} + +{% block navbar %} + + {% include "navbar.html" %} + +{%- endblock navbar %} + + +{% block sidebar -%} + + {% include 'sidebar.html' %} + + {% include 'sidebar_menu.html' %} + +{%- endblock sidebar %} + + +{% block content_header -%} + {% include 'content_header.html' %} +{%- endblock content_header %} + + +{% block content -%} + + +
+ + {{ + widgets.small_box( + bgcolor="bg-aqua", + header=150, + body="Total Servers", + iconclass="ion ion-cloud", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-green", + header=53, + body="Bounce Rate", + iconclass="ion ion-stats-bars", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-yellow", + header=43, + body="User Registrations", + iconclass="ion ion-person-add", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-red", + header=65, + body="Unique Visitors", + iconclass="ion ion-pie-graph", + footerlink="#" + ) + }} + +
+ + +
+ + {{ + widgets.small_box( + bgcolor="bg-blue", + header=230, + body="Sales", + iconclass="ion ion-ios7-cart-outline", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-purple", + header=80, + percentage=True, + body="Conversion Rate", + iconclass="ion ion-ios7-briefcase-outline", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-teal", + header=14, + body="Notifications", + iconclass="ion ion-ios7-alarm-outline", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-maroon", + header=160, + body="Products", + iconclass="ion ion-ios7-pricetag-outline", + footerlink="#" + ) + }} + +
+{%- endblock content %} diff --git a/dash/templates/network/list_networks.html b/dash/templates/network/list_networks.html new file mode 100644 index 0000000..2149b3c --- /dev/null +++ b/dash/templates/network/list_networks.html @@ -0,0 +1,83 @@ +{% extends "adminlte/base.html" %} +{% import "adminlte/layout.html" as layout with context %} +{% import "adminlte/widgets.html" as widgets with context %} + +{% block title %}Server - {{ title }}{% endblock %} +{% block description %}{{ block_description }}{% endblock %} + +{% block navbar %} + + {% include "navbar.html" %} + +{%- endblock navbar %} + + +{% block sidebar -%} + + {% include 'sidebar.html' %} + + {% include 'sidebar_menu.html' %} + +{%- endblock sidebar %} + + +{% block content_header -%} + {% include 'server/content_header.html' %} +{%- endblock content_header %} + +{% block content -%} + +
+
+
+
+ + + + + + + + + + + {% for network in networks.networks %} + + {% if network['tenant_id'] == sess.get_project_id() %} + + + + + {% endif %} + + {% endfor %} + + + + + + + + + +
Network NameSubnetsStatusAction
{{ network['name'] }} + {% for subnet in network['subnets'] %} + {{ neutron.list_subnets(subnet).subnets[loop.index0]['name'] }} | + {{ neutron.list_subnets(subnet).subnets[loop.index0]['cidr'] }} +
+ {% endfor %} +
{{ network['status'] }} + Edit + | + Delete +
Network NameSubnetsStatusAction
+
+ +
+ +
+ +
+ + +{%- endblock content %} \ No newline at end of file diff --git a/dash/templates/security/content_header.html b/dash/templates/security/content_header.html new file mode 100644 index 0000000..2235a51 --- /dev/null +++ b/dash/templates/security/content_header.html @@ -0,0 +1,8 @@ +

+ {{ title }} + {{ block_description }} +

+ \ No newline at end of file diff --git a/dash/templates/security/index.html b/dash/templates/security/index.html new file mode 100644 index 0000000..9a736ba --- /dev/null +++ b/dash/templates/security/index.html @@ -0,0 +1,121 @@ +{% extends "adminlte/base.html" %} +{% import "adminlte/layout.html" as layout with context %} +{% import "adminlte/widgets.html" as widgets with context %} + +{% block navbar %} + + {% include "navbar.html" %} + +{%- endblock navbar %} + + +{% block sidebar -%} + + {% include 'sidebar.html' %} + + {% include 'sidebar_menu.html' %} + +{%- endblock sidebar %} + + +{% block content_header -%} + {% include 'content_header.html' %} +{%- endblock content_header %} + + +{% block content -%} + + +
+ + {{ + widgets.small_box( + bgcolor="bg-aqua", + header=150, + body="Total Servers", + iconclass="ion ion-cloud", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-green", + header=53, + body="Bounce Rate", + iconclass="ion ion-stats-bars", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-yellow", + header=43, + body="User Registrations", + iconclass="ion ion-person-add", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-red", + header=65, + body="Unique Visitors", + iconclass="ion ion-pie-graph", + footerlink="#" + ) + }} + +
+ + +
+ + {{ + widgets.small_box( + bgcolor="bg-blue", + header=230, + body="Sales", + iconclass="ion ion-ios7-cart-outline", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-purple", + header=80, + percentage=True, + body="Conversion Rate", + iconclass="ion ion-ios7-briefcase-outline", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-teal", + header=14, + body="Notifications", + iconclass="ion ion-ios7-alarm-outline", + footerlink="#" + ) + }} + + {{ + widgets.small_box( + bgcolor="bg-maroon", + header=160, + body="Products", + iconclass="ion ion-ios7-pricetag-outline", + footerlink="#" + ) + }} + +
+{%- endblock content %} diff --git a/dash/templates/sidebar_menu.html b/dash/templates/sidebar_menu.html index 8f42417..cce4dc1 100644 --- a/dash/templates/sidebar_menu.html +++ b/dash/templates/sidebar_menu.html @@ -9,7 +9,7 @@
  • - + Servers @@ -22,7 +22,7 @@
  • - + List Servers @@ -32,6 +32,87 @@ {% endif %} +{% if current_user.role.name == "user" or current_user.role.name == "admin" %} + + +{% endif %} + +{% if current_user.role.name == "user" or current_user.role.name == "admin" %} + + +{% endif %} + +{% if current_user.role.name == "user" or current_user.role.name == "admin" %} + + +{% endif %} + {% if current_user.role.name == "admin" %}