diff --git a/app/routes.py b/app/routes.py index 98710741e..89995f578 100644 --- a/app/routes.py +++ b/app/routes.py @@ -28,6 +28,34 @@ def avatar(email, size): if name[0] != '.': toscaTemplates.append( os.path.relpath(os.path.join(path, name), toscaDir )) +import_metadata = False +tosca_metadata_dir = app.config.get('TOSCA_METADATA_DIR') +if tosca_metadata_dir: + import_metadata = True + metadata_dict = {} + tosca_metadata_path = tosca_metadata_dir + "/" + + for tosca in toscaTemplates: + # Assign default metadata vaules + metadata_dict[tosca] = dict(name=tosca, + icon=app.root_path+"/static/defaults/default_app.svg") + # Search for metadata file + for mpath, msubs, mnames in os.walk(tosca_metadata_path): + for mname in mnames: + if fnmatch(mname, '*.metadata.yml') or fnmatch(mname, '*.metadata.yaml'): + # skip hidden files + if mname[0] != '.': + tosca_metadata_file = os.path.join(mpath, mname) + with io.open(tosca_metadata_file) as metadata_file: + metadata = yaml.load(metadata_file) + template_metadata = metadata["template_metadata"] + if(tosca == template_metadata["name"]): + metadata_dict[tosca] = template_metadata + + toscaTemplates = metadata_dict + +tosca_pars_dir = app.config.get('TOSCA_PARAMETERS_DIR') + orchestratorUrl = app.config.get('ORCHESTRATOR_URL') slamUrl = app.config.get('SLAM_URL') cmdbUrl = app.config.get('CMDB_URL') @@ -66,7 +94,7 @@ def get_slas(access_token): url = slamUrl + "/rest/slam/preferences/" + session['organisation_name'] verify = True - if slam_cert: + if slam_cert: verify = slam_cert response = requests.get(url, headers=headers, timeout=20, verify=verify) app.logger.info("SLA response status: " + str(response.status_code)) @@ -101,10 +129,9 @@ def getslas(): return render_template('sla.html', slas=slas) -@app.route('/dashboard/') -@app.route('/') +@app.route('/dashboard/') @app.route('/') -def home(page=0): +def home(): if not iam_blueprint.session.authorized: return redirect(url_for('login')) @@ -120,7 +147,7 @@ def home(page=0): headers = {'Authorization': 'bearer %s' % (access_token)} - url = orchestratorUrl + "/deployments?createdBy=me&page=" + str(page) + url = orchestratorUrl + "/deployments?createdBy=me&page=0&size=9999" response = requests.get(url, headers=headers) deployments = {} @@ -128,11 +155,10 @@ def home(page=0): flash("Error retrieving deployment list: \n" + response.text, 'warning') else: deployments = response.json()["content"] - pages=response.json()['page']['totalPages'] - app.logger.debug(pages) - return render_template('deployments.html', deployments=deployments, tot_pages=pages, current_page=page) - except Exception: - app.logger.info("error") + app.logger.debug("Deployments: " + str(deployments)) + return render_template('deployments.html', deployments=deployments) + except Exception as e: + app.logger.info("Error: " + str(e)) return redirect(url_for('logout')) @@ -179,7 +205,7 @@ def depcreate(): access_token = iam_blueprint.session.token['access_token'] if request.method == 'GET': - return render_template('createdep.html', templates=toscaTemplates, inputs={}) + return render_template('createdep.html', templates=toscaTemplates, inputs={}, import_metadata=import_metadata) else: selected_tosca = request.form.get('tosca_template') @@ -192,26 +218,53 @@ def depcreate(): inputs={} if 'inputs' in template['topology_template']: inputs = template['topology_template']['inputs'] - + + ## add parameters code here + enable_config_form = False + tabs={} + if tosca_pars_dir: + tosca_pars_path = tosca_pars_dir + "/" # this has to be reassigned here because is local. + for fpath, subs, fnames in os.walk(tosca_pars_path): + for fname in fnames: + if fnmatch(fname, os.path.splitext(selected_tosca)[0] + '.parameters.yml') or \ + fnmatch(fname, os.path.splitext(selected_tosca)[0] + '.parameters.yaml'): + # skip hidden files + if fname[0] != '.': + tosca_pars_file = os.path.join(fpath, fname) + with io.open(tosca_pars_file) as pars_file: + enable_config_form = True + pars_data = yaml.load(pars_file) + inputs = pars_data["inputs"] + if "tabs" in pars_data: + tabs = pars_data["tabs"] description = "N/A" if 'description' in template: description = template['description'] - slas = get_slas(access_token) - return render_template('createdep.html', templates=toscaTemplates, selectedTemplate=selected_tosca, description=description, inputs=inputs, slas=slas) + try: + slas = get_slas(access_token) + + except Exception as e: + flash("Error retrieving SLAs list: \n" + str(e), 'warning') + return redirect(url_for('home')) + + return render_template('createdep.html', + templates=toscaTemplates, + selectedTemplate=selected_tosca, + import_metadata=import_metadata, + description=description, + inputs=inputs, + slas=slas, + enable_config_form=enable_config_form, + tabs=tabs) def add_sla_to_template(template, sla_id): # Add the placement policy - nodes=template['topology_template']['node_templates'] - compute_nodes = [] -# for key, dict in nodes.items(): -# node_type=dict["type"] -# if node_type == "tosca.nodes.indigo.Compute" or node_type == "tosca.nodes.indigo.Container.Application.Docker.Chronos" : -# compute_nodes.append(key) -# template['topology_template']['policies']=[{ "deploy_on_specific_site": { "type": "tosca.policies.Placement", "properties": { "sla_id": sla_id }, "targets": compute_nodes } }] - template['topology_template']['policies']=[{ "deploy_on_specific_site": { "type": "tosca.policies.Placement", "properties": { "sla_id": sla_id } } }] - app.logger.info(yaml.dump(template,default_flow_style=False)) + template['topology_template']['policies'] = [ + {"deploy_on_specific_site": {"type": "tosca.policies.Placement", "properties": {"sla_id": sla_id}}}] + app.logger.info(yaml.dump(template, default_flow_style=False)) + return template # # @@ -246,11 +299,9 @@ def createdep(): payload = { "template" : yaml.dump(template,default_flow_style=False), "parameters": inputs } - #body= json.dumps(payload) url = orchestratorUrl + "/deployments/" headers = {'Content-Type': 'application/json', 'Authorization': 'bearer %s' % (access_token)} - #response = requests.post(url, data=body, headers=headers) response = requests.post(url, json=payload, params=params, headers=headers) if not response.ok: @@ -269,5 +320,3 @@ def logout(): iam_blueprint.session.get("/logout") # del iam_blueprint.session.token return redirect(url_for('login')) - - diff --git a/app/static/images/favicon_io/android-chrome-192x192.png b/app/static/images/favicon_io/android-chrome-192x192.png new file mode 100755 index 000000000..5fe8a7089 Binary files /dev/null and b/app/static/images/favicon_io/android-chrome-192x192.png differ diff --git a/app/static/images/favicon_io/android-chrome-512x512.png b/app/static/images/favicon_io/android-chrome-512x512.png new file mode 100755 index 000000000..dd67a4937 Binary files /dev/null and b/app/static/images/favicon_io/android-chrome-512x512.png differ diff --git a/app/static/images/favicon_io/apple-touch-icon.png b/app/static/images/favicon_io/apple-touch-icon.png new file mode 100755 index 000000000..38b14dd16 Binary files /dev/null and b/app/static/images/favicon_io/apple-touch-icon.png differ diff --git a/app/static/images/favicon_io/favicon-16x16.png b/app/static/images/favicon_io/favicon-16x16.png new file mode 100755 index 000000000..24f745b68 Binary files /dev/null and b/app/static/images/favicon_io/favicon-16x16.png differ diff --git a/app/static/images/favicon_io/favicon-32x32.png b/app/static/images/favicon_io/favicon-32x32.png new file mode 100755 index 000000000..8c5657355 Binary files /dev/null and b/app/static/images/favicon_io/favicon-32x32.png differ diff --git a/app/static/images/favicon_io/favicon.ico b/app/static/images/favicon_io/favicon.ico new file mode 100755 index 000000000..2aa760920 Binary files /dev/null and b/app/static/images/favicon_io/favicon.ico differ diff --git a/app/static/images/favicon_io/site.webmanifest b/app/static/images/favicon_io/site.webmanifest new file mode 100755 index 000000000..45dc8a206 --- /dev/null +++ b/app/static/images/favicon_io/site.webmanifest @@ -0,0 +1 @@ +{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} \ No newline at end of file diff --git a/app/templates/base.html b/app/templates/base.html index d36c5dae8..52ca05e78 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -1,46 +1,73 @@ - - - - - - - - - - - - - {% block content %}{% endblock %} - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% block content %}{% endblock %} + diff --git a/app/templates/config_form.html b/app/templates/config_form.html new file mode 100644 index 000000000..5ee9a7e0e --- /dev/null +++ b/app/templates/config_form.html @@ -0,0 +1,51 @@ + + + + +
+ + {% if tabs|length > 0 %} + {% for tab in tabs %} + {% if loop.first %} +
+ {% else %} +
+ {% endif %} + +
+ {% for key, value in inputs.items() %} + {% if value.tab == tab %} + {% include 'input_types.html' %} + {% endif %} + {% endfor %} +
+ {% endfor %} + + {% else %} +
+ {% for key, value in inputs.items() %} + {% include 'input_types.html' %} + {% endfor %} +
+ {% endif %} + + + +
+
+ {% include 'scheduling.html' %} +
+
diff --git a/app/templates/createdep.html b/app/templates/createdep.html index 640286a72..c122e10cf 100644 --- a/app/templates/createdep.html +++ b/app/templates/createdep.html @@ -1,85 +1,83 @@ {% extends "base.html" %} {% block content %} +
-{% with messages = get_flashed_messages() %} -{% if messages %} -{% for message in messages %} -
- Warning! {{ message }} -
-

-{% endfor %} -{% endif %} -{% endwith %} + {% with messages = get_flashed_messages() %} + {% if messages %} + {% for message in messages %} +
+ Warning! {{ message }} +
+

+ {% endfor %} + {% endif %} + {% endwith %} -
-
-
- - -
- -
+
+
+
+

New deployment

+
- {% if selectedTemplate is defined %} -

Template: {{selectedTemplate}}

+
+
+
+ + {% if import_metadata == true %} + + {% else %} + + {% endif %} +
+ + {% if not selectedTemplate is defined %} + + {% endif %} +
- {% if description is defined %} -
- Description: {{description}} -
- {% endif %} - - {% if inputs|length > 0 %} -

Set input values:

- {% endif %} -
- - {% if inputs|length > 0 %} - {% for key, value in inputs.items() %} -
- - - {{value.description}} + {% if selectedTemplate is defined %} +
+
+
+

+ Template: {% if import_metadata == true and templates[selectedTemplate]["display_name"] is defined %}{{templates[selectedTemplate]["display_name"]}}{% else %}{{selectedTemplate}}{% endif %} +

+
+ +
+ {% if description is defined %} +
+ Description: {{description}} +
+ {% endif %} + + {% if enable_config_form %} + {% include 'config_form.html' %} + {% else %} + {% include 'default_form.html' %} + {% endif %} + + + +
+
+ {% endif %}
- {% endfor %} - {% endif %} -
-

Configure scheduling:

- - -
-
- -
-
-

- - -

- - - {% endif %} +
+ + + + {% endblock %} diff --git a/app/templates/deptemplate.html b/app/templates/deptemplate.html index 2eb82dde0..bc1dce9e4 100644 --- a/app/templates/deptemplate.html +++ b/app/templates/deptemplate.html @@ -3,9 +3,26 @@ {% block content %}
-

TEMPLATE

-
-{{ template | safe }}
-
+ +
+ +
+
+
+
+ +

Template

+
+
+ + +
+
+
+ +
+
{{ template | safe }}
+
+
{% endblock %} diff --git a/app/templates/home.html b/app/templates/home.html index cd54b4598..c031ead7f 100644 --- a/app/templates/home.html +++ b/app/templates/home.html @@ -1,15 +1,15 @@ {% extends "base.html" %} {% block content %} - + -
-
+
+

Welcome!

diff --git a/app/templates/input_types.html b/app/templates/input_types.html new file mode 100644 index 000000000..c596a7b3b --- /dev/null +++ b/app/templates/input_types.html @@ -0,0 +1,69 @@ +
+ {% if value.tag_type is not defined or value.tag_type != "hidden" %} + + {% endif %} + {% if value.tag_type is defined %} + + + {% if value.tag_type == "text" %} + + + + + {% elif value.tag_type == "hidden" %} + + + + + {% elif value.tag_type == "email" %} + + + + + {% elif value.tag_type == "password" %} + + + + + + {% elif value.tag_type == "select" %} + + + + + {% elif value.tag_type == "radio" %} + {% for constraint in value.constraints %} + {% if loop.first %} +
{{constraint['label']}}
+ {% else %} + {{constraint['label']}}
+ {% endif %} + {% endfor %} + + + + {% elif value.tag_type == "toggle" %} + {% for constraint in value.constraints %} +
+ +
+ {% endfor %} + + + {% endif %} + + {% else %} + + {% endif %} + {{value.description}} +
diff --git a/app/templates/scheduling.html b/app/templates/scheduling.html new file mode 100644 index 000000000..ee0343ff7 --- /dev/null +++ b/app/templates/scheduling.html @@ -0,0 +1,31 @@ +
+

Configure scheduling:

+ + +
+ +
+

+ + +
+ +
+ + +
+ +
+ +
diff --git a/app/templates/settings.html b/app/templates/settings.html index 5a0017ada..d51348c8a 100644 --- a/app/templates/settings.html +++ b/app/templates/settings.html @@ -1,32 +1,51 @@ {% extends "base.html" %} - {% block content %} - +
+
+

Settings

+
+
-
-

Settings

-
-
-
IAM
-
{{ iam_url }}
+
+ + + + + + + + + + + + + + + + + + +
ServiceEndpoint
IAM{{ iam_url }}
Orchestrator{{ orchestrator_url }}
+
-
-
Orchestrator
-
{{ orchestrator_url }}
-
-
+
+ {% endblock %} diff --git a/app/templates/sla.html b/app/templates/sla.html index e6427b559..c953ef538 100644 --- a/app/templates/sla.html +++ b/app/templates/sla.html @@ -1,49 +1,75 @@ {% extends "base.html" %} {% block content %} -
+
-{% with messages = get_flashed_messages() %} -{% if messages %} -{% for message in messages %} -
- Warning! {{ message }} -
-

-{% endfor %} -{% endif %} -{% endwith %} -
-

Service Level Agreements:

-
-
- -
-
- - - - - - - - - - - - {% for sla in slas %} - - - - - - - - {% endfor %} - -
SiteService TypeStart dateEnd date
{{sla.sitename}}{{sla.service_type}}{{sla.start_date}}{{sla.end_date}}
+ {% with messages = get_flashed_messages() %} + {% if messages %} + {% for message in messages %} +
+ Warning! {{ message }} +
+

+ {% endfor %} + {% endif %} + {% endwith %} + +
+ +
+
+
+
+ +

Service Level Agreements

+
+
+ + +
+
+
+
+ +
+ + + + + + + + + + + + {% for sla in slas %} + + + + + + + + {% endfor %} + +
SiteService TypeStart dateEnd date
{{sla.sitename}}{{sla.service_type}}{{sla.start_date}}{{sla.end_date}}
+
+
+
+ {% endblock %}