new django app descriptionhandler 83/6783/1
authorlombardofr <lombardo@everyup.it>
Mon, 29 Oct 2018 12:41:08 +0000 (13:41 +0100)
committerlombardofr <lombardo@everyup.it>
Mon, 29 Oct 2018 12:41:08 +0000 (13:41 +0100)
Change-Id: I0d7bdece62413ad1a9aa30c64fbd9f785705dc8e
Signed-off-by: lombardofr <lombardo@everyup.it>
42 files changed:
.gitignore
descriptorhandler/__init__.py [new file with mode: 0644]
descriptorhandler/apps.py [new file with mode: 0644]
descriptorhandler/models.py [new file with mode: 0644]
descriptorhandler/template/composer.html [new file with mode: 0644]
descriptorhandler/template/descriptor_new.html [new file with mode: 0644]
descriptorhandler/template/descriptor_view.html [new file with mode: 0644]
descriptorhandler/template/descriptor_view_base.html [new file with mode: 0644]
descriptorhandler/template/descriptorlist.html [new file with mode: 0644]
descriptorhandler/template/modal/choose_node_id.html [new file with mode: 0644]
descriptorhandler/template/modal/create_link_chooser.html [new file with mode: 0644]
descriptorhandler/urls.py [new file with mode: 0644]
descriptorhandler/views.py [new file with mode: 0644]
instancehandler/template/instance_list_ns.html
projecthandler/template/project/descriptor/descriptor_view_base.html [deleted file]
projecthandler/template/project/descriptor/modal/choose_node_id.html [deleted file]
projecthandler/template/project/osm/descriptor/descriptor_new.html [deleted file]
projecthandler/template/project/osm/descriptor/descriptor_view.html [deleted file]
projecthandler/template/project/osm/descriptor/descriptorlist.html [deleted file]
projecthandler/template/project/osm/descriptor/modal/choose_node_id.html [deleted file]
projecthandler/template/project/osm/descriptor/modal/create_link_chooser.html [deleted file]
projecthandler/template/project/osm/osm_project_descriptors.html
projecthandler/template/project/osm/osm_project_details.html
projecthandler/template/project/osm/osm_project_left_sidebar.html
projecthandler/template/project/osm/project_graph.html
projecthandler/template/project/project_graph_base.html
projecthandler/urls/project.py
projecthandler/views.py
sdnctrlhandler/admin.py [deleted file]
sdnctrlhandler/apps.py
sdnctrlhandler/models.py
sdnctrlhandler/tests.py [deleted file]
sf_t3d/context_processor.py
sf_t3d/settings.py
sf_t3d/urls.py
sf_t3d/views.py
sf_t3d/wsgi.py
static/TopologyComposer/css/composer.css
userhandler/admin.py [deleted file]
userhandler/apps.py
userhandler/tests.py [deleted file]
userhandler/views.py

index da69467..6672790 100644 (file)
@@ -46,6 +46,7 @@ static/bower_components
 
 #migrations
 projecthandler/migrations/
+descriptorhandler/migrations/
 instancehandler/migrations
 sdnctrlhandler/migrations
 authosm/migrations
diff --git a/descriptorhandler/__init__.py b/descriptorhandler/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/descriptorhandler/apps.py b/descriptorhandler/apps.py
new file mode 100644 (file)
index 0000000..9d952fc
--- /dev/null
@@ -0,0 +1,23 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
+from __future__ import unicode_literals
+
+from django.apps import AppConfig
+
+
+class DescriptorhandlerConfig(AppConfig):
+    name = 'descriptorhandler'
diff --git a/descriptorhandler/models.py b/descriptorhandler/models.py
new file mode 100644 (file)
index 0000000..ed2a5ae
--- /dev/null
@@ -0,0 +1,21 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
+from __future__ import unicode_literals
+
+from django.db import models
+
+# Create your models here.
diff --git a/descriptorhandler/template/composer.html b/descriptorhandler/template/composer.html
new file mode 100644 (file)
index 0000000..cad68fa
--- /dev/null
@@ -0,0 +1,80 @@
+{% extends "base.html" %}
+{% load get %}
+{% load staticfiles %}
+
+
+
+{% block head_block %}
+    {{ block.super }}
+
+<!-- TopologyComposer D3 -->
+    <link rel="stylesheet" href="/static/TopologyComposer/css/composer.css">
+    <link rel="stylesheet" href="/static/TopologyComposer/css/d3-context-menu.css">
+
+
+{% endblock %}
+{% block title_header_big %}
+    {{ block.super }}
+{% endblock %}
+{% block left_sidebar %}
+    {% include 'osm/osm_project_left_sidebar.html' %}
+{% endblock %}
+
+
+{% block breadcrumb_body %}
+    {{ block.super }}
+    {% comment %}<li><a href="{% url 'projects:descriptors:list_descriptors'  type=type %}">{{ type|upper }} Descriptors</a></li>
+    <li><a href="#"><i class="fa fa-sitemap"></i> {{ type|upper }} Topology</a></li>{% endcomment %}
+{% endblock %}
+
+{% block content_body %}
+    {{ block.super }}
+    {% csrf_token %}
+    <div class="container-fluid">
+        <div id="main" class="row">
+            <div id="leftside">
+
+            </div>
+            <div id="graph_editor_container" class="col">
+                <div class="btn-group left-tool-bar-monitoring">
+                    <button id="topology_force" type="button" class="btn btn btn-default" onclick="handleForce(this)"
+                            data-toggle="button" aria-pressed="false" autocomplete="off"><i
+                            class="fas fa-thumbtack"></i></button>
+                    <button id="reset_filter" type="button" class="btn btn btn-default" onclick="resetFilters(this)"><i
+                            class="fa fa-backward"></i></button>
+                </div>
+                <div id="legenda">
+                </div>
+            </div>
+            <div id="side">
+
+            </div>
+        </div>
+    </div>
+
+{% endblock %}
+
+{% block resource_block %}
+    {{ block.super }}
+    <script>
+        var topology_data = {};//{{topology_data|safe }};
+    </script>
+    <!-- d3.js -->
+    <script src="/static/bower_components/d3/d3.js"></script>
+
+    <!-- TopologyComposer D3 -->
+    <script src="/static/TopologyComposer/js/event.js"></script>
+    <script src="/static/TopologyComposer/js/settings.js"></script>
+    <script src="/static/TopologyComposer/js/graph_editor.js"></script>
+    <script src="/static/TopologyComposer/js/model_graph_editor.js"></script>
+    <script src="/static/TopologyComposer/js/d3-context-menu.js"></script>
+
+
+    <script src="/static/src/osm_gui_properties.js"></script>
+{#    <script src="/static/src/instancehandler/instance_topology_view.js"></script>#}
+
+{% endblock %}
+
+{% block footer %}
+    {% include "footer.html" %}
+{% endblock %}
diff --git a/descriptorhandler/template/descriptor_new.html b/descriptorhandler/template/descriptor_new.html
new file mode 100644 (file)
index 0000000..2551f30
--- /dev/null
@@ -0,0 +1,67 @@
+{% extends "/descriptor_view_base.html" %}
+
+{% load staticfiles %}
+
+
+{% block title_header_big %}
+{{ block.super }}
+Onboard new {{ descriptor_type }} package
+{% endblock %}
+
+{% block left_sidebar %}
+{% include 'osm/osm_project_left_sidebar.html' %}
+{% endblock %}
+
+{% block breadcrumb_body %}
+{{ block.super }}
+<li><a href="{% url 'projects:open_project'  %}">{{project_id}}</a></li>
+<li><a href="{% url 'projects:open_project'  %}descriptors/{{descriptor_type}}">{{ descriptor_type }}  Descriptors</a></li>
+<li>Create Descriptor</li>
+{% endblock %}
+
+{% block tab_pane_button_list %}
+{{ block.super }}
+<li id="file_li" class="active"><a href="#upload" data-toggle="tab"><i class="fa fa-upload"></i> Onboard Package</a></li>
+{% endblock %}
+
+{% block nav_buttons_list %}
+{{ block.super }}
+<li class="pull-right">
+    <button id="cancel" type="button" class="btn btn-block btn-primary btn-sm" onclick="cancel(this.id)"><i
+            class="fa fa-times"></i> Cancel
+    </button>
+</li>
+{% endblock %}
+
+{% block tab_pane_list %}
+{{ block.super }}
+
+<div class="tab-pane active" id="upload">
+
+    <h4>Drag and drop file below</h4>
+    <div class="upload-drop-zone" id="drop-zone">
+            Just drag and drop files here
+    </div>
+</div>
+{% endblock %}
+
+
+{% block resource_block %}
+{{ block.super }}
+
+<script>
+    var descr_list_url = '{% url "projects:descriptors:list_descriptors"   descriptor_type=descriptor_type%}';
+    var csrf_token = '{{csrf_token}}';
+    var new_desc_url ="{% url 'projects:descriptors:new_descriptor'  descriptor_type=descriptor_type %}"
+
+    function cancel(id) {
+        window.location.href = descr_list_url
+    }
+
+</script>
+    <script src="/static/src/projecthandler/onboard_package.js"></script>
+{% endblock %}
+
+{% block footer %}
+    {% include "footer.html" %}
+{% endblock %}
diff --git a/descriptorhandler/template/descriptor_view.html b/descriptorhandler/template/descriptor_view.html
new file mode 100644 (file)
index 0000000..2a18666
--- /dev/null
@@ -0,0 +1,132 @@
+{% extends "descriptor_view_base.html" %}
+
+{% load staticfiles %}
+
+
+{% block title_header_big %}
+{{ block.super }}
+Edit {{ descriptor_type|upper }} Descriptor
+{% endblock %}
+
+
+{% block left_sidebar %}
+{% include 'osm/osm_project_left_sidebar.html' %}
+{% endblock %}
+
+{% block breadcrumb_body %}
+{{ block.super }}
+<li><a href="{% url 'projects:open_project' %}">{{project_id}}</a></li>
+<li><a href="{% url 'projects:descriptors:list_descriptors' descriptor_type=descriptor_type %}">{{ descriptor_type }} Descriptors</a></li>
+<li><a>{{descriptor_id}}</a></li>
+{% endblock %}
+
+{% block tab_pane_button_list %}
+{{ block.super }}
+<li class="active" id="yaml_li"><a href="#yaml" data-toggle="tab"><i class="fa fa-file-code-o"></i> YAML</a></li>
+<li id="json_li"><a href="#json" data-toggle="tab"><i class="fa fa-file-code-o"></i> JSON</a></li>
+{% endblock %}
+
+{% block nav_buttons_list %}
+    {{ block.super }}
+    <li class="pull-right"><button id="save" type="button" class="btn btn-block btn-primary btn-sm"  onclick="update(this.id)" ><i class="fa fa-save"></i> Update</button></li>
+    <li class="pull-right"><button id="save_show_graph" type="button" class="btn btn-block btn-primary btn-sm"  onclick="update(this.id)" disabled><i class="fa fa-save"></i> Update and Show Graph</button></li>
+    <li class="pull-right"><button type="button" class="btn btn-block btn-primary btn-sm"  onclick="goToGraph()" disabled><i class="fa fa-sitemap"></i> Show Graph</button></li>
+
+{% endblock %}
+
+{% block tab_pane_list %}
+{{ block.super }}
+
+<!-- /.tab-pane -->
+<div class="active tab-pane" id="yaml">
+    <textarea id="code_editor_yaml">
+    </textarea>
+</div>
+<!-- /.tab-pane-->
+
+<div class="tab-pane" id="json">
+    <textarea id="code_editor_json">
+    </textarea>
+</div>
+
+{% endblock %}
+
+{% block resource_block %}
+{{ block.super }}
+
+
+<script>
+    var editorJSON;
+    var editorYaml;
+
+    $(document).ready(function () {
+        //var cmjsoneditor = CodeMirror.fromTextArea(document.getElementById("code_editor"), json_editor_settings);
+        var myJsonTextArea = document.getElementById("code_editor_json");
+        editorJSON = CodeMirror(function (elt) {
+            myJsonTextArea.parentNode.replaceChild(elt, myJsonTextArea);
+        }, json_editor_settings);
+        editorJSON.setValue(JSON.stringify({{descriptor_strings.descriptor_string_json | safe}}, null, "\t"));
+        editorJSON.setOption("autoRefresh", true);
+        editorJSON.setSize("auto", "auto");
+
+        var myYamlTextArea = document.getElementById("code_editor_yaml");
+        editorYaml = CodeMirror(function (elt) {
+            myYamlTextArea.parentNode.replaceChild(elt, myYamlTextArea);
+        }, yaml_editor_settings);
+        var des_strings = {{descriptor_strings | safe}};
+        editorYaml.setValue(des_strings.descriptor_string_yaml);
+        editorYaml.setSize("auto", "auto");
+    });
+
+
+    function update(e) {
+        var dialog = bootbox.dialog({
+            message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
+            closeButton: false
+        });
+
+        var id = $('.nav-tabs .active').attr('id');
+        var type, text;
+        switch (id) {
+            case 'yaml_li':
+                type = 'yaml';
+                text = editorYaml.getValue();
+                break;
+            case 'json_li':
+                type = 'json';
+                text = editorJSON.getValue();
+                break;
+        }
+        $.ajax({
+            url: "/projects/descriptors/{{descriptor_type}}/{{descriptor_id}}/",
+            type: 'POST',
+            dataType: 'json',
+            data: {
+                'csrfmiddlewaretoken': '{{csrf_token}}',
+                'type': type,
+                'text': text
+            },
+            success: function (result) {
+                dialog.modal('hide');
+                $("#success-alert").fadeTo(2000, 500).slideDown(500, function(){
+                    setTimeout(function () {
+                        $("#success-alert").slideUp(500);
+                    }, 2000);
+
+                });
+            },
+            error: function (result) {
+                console.log(result);
+                dialog.modal('hide');
+                bootbox.alert(result);
+            }
+        });
+    }
+
+</script>
+{% endblock %}
+
+
+{% block footer %}
+    {% include "footer.html" %}
+{% endblock %}
diff --git a/descriptorhandler/template/descriptor_view_base.html b/descriptorhandler/template/descriptor_view_base.html
new file mode 100644 (file)
index 0000000..918e810
--- /dev/null
@@ -0,0 +1,141 @@
+{% extends "base.html" %}
+
+{% load staticfiles %}
+
+{% block head_block %}
+       {{ block.super }}
+
+
+    <!-- Codemirror core CSS -->
+    <link rel="stylesheet" href="/static/bower_components/codemirror/lib/codemirror.css" >
+    <link rel="stylesheet" href="/static/bower_components/codemirror/addon/fold/foldgutter.css"  />
+    <link rel="stylesheet" href="/static/bower_components/codemirror/theme/neat.css" >
+    <link rel="stylesheet" href="/static/bower_components/codemirror/addon/dialog/dialog.css" >
+    <link rel="stylesheet" href="/static/bower_components/codemirror/addon/display/fullscreen.css" >
+
+{% endblock %}
+
+
+
+
+{% block content_body %}
+       {{ block.super }}
+<div class="row">
+    <div class="col-md-12">
+    <div class="nav-tabs-custom" style="position: relative;">
+    <ul class="nav nav-tabs" >
+        {% block tab_pane_button_list %}
+
+        {% endblock %}
+
+        {% block nav_buttons_list %}
+
+        {% endblock %}
+
+    </ul>
+        <div class="alert alert-success" id="success-alert" style="position: absolute; z-index: 100; top: 44px; left: 0;
+    width: 100%;
+    border-radius: 1px;
+    background-color: rgba(0, 166, 90, 0.8) !important;
+    text-align: center;
+    border-color: rgba(0, 141, 76, 0.4);" hidden>
+            <button type="button" class="close" onclick="$('#success-alert').toggle()">x</button>
+            <strong>Success! </strong>
+            Descriptor updated!
+        </div>
+    <div class="tab-content">
+        {% block tab_pane_list %}
+
+        {% endblock %}
+    </div>
+    <!-- /.tab-content -->
+
+
+
+
+</div>
+
+    </div>
+</div>
+{% endblock %}
+
+{% block resource_block %}
+       {{ block.super }}
+
+
+    <script src="/static/bower_components/codemirror/lib/codemirror.js" ></script>
+    <script src="/static/bower_components/codemirror/addon/fold/foldcode.js" ></script>
+    <script src="/static/bower_components/codemirror/addon/fold/foldgutter.js" ></script>
+    <script src="/static/bower_components/codemirror/addon/fold/brace-fold.js" ></script>
+    <script src="/static/bower_components/codemirror/mode/javascript/javascript.js" ></script>
+    <script src="/static/bower_components/codemirror/mode/yaml/yaml.js" ></script>
+    <script src="/static/bower_components/codemirror/mode/markdown/markdown.js" ></script>
+    <script src="/static/bower_components/codemirror/addon/search/searchcursor.js" ></script>
+    <script src="/static/bower_components/codemirror/addon/search/search.js" ></script>
+    <script src="/static/bower_components/codemirror/addon/dialog/dialog.js" ></script>
+    <script src="/static/bower_components/codemirror/addon/display/autorefresh.js" ></script>
+    <script src="/static/bower_components/codemirror/addon/edit/matchbrackets.js" ></script>
+    <script src="/static/bower_components/codemirror/addon/edit/closebrackets.js" ></script>
+    <script src="/static/bower_components/codemirror/addon/display/fullscreen.js" ></script>
+    <script src="/static/bower_components/codemirror/keymap/sublime.js" ></script>
+
+
+    <script>
+
+        var json_editor_settings = {
+            mode: "javascript",
+            showCursorWhenSelecting: true,
+            autofocus: true,
+            lineNumbers: true,
+            lineWrapping: true,
+            foldGutter: true,
+            gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
+            autoCloseBrackets: true,
+            matchBrackets: true,
+            extraKeys: {
+                "F11": function (cm) {
+                    cm.setOption("fullScreen", !cm.getOption("fullScreen"));
+                },
+                "Esc": function (cm) {
+                    if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
+                },
+                "Ctrl-Q": function (cm) {
+                    cm.foldCode(cm.getCursor());
+                }
+            },
+            theme: "neat",
+            keyMap: "sublime"
+        };
+
+        var yaml_editor_settings = {
+            mode: "yaml",
+            showCursorWhenSelecting: true,
+            autofocus: true,
+            autoRefresh: true,
+            lineNumbers: true,
+            lineWrapping: true,
+            foldGutter: true,
+            gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
+            autoCloseBrackets: true,
+            matchBrackets: true,
+            extraKeys: {
+                "F11": function (cm) {
+                    cm.setOption("fullScreen", !cm.getOption("fullScreen"));
+                },
+                "Esc": function (cm) {
+                    if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
+                },
+                "Ctrl-Q": function (cm) {
+                    cm.foldCode(cm.getCursor());
+                }
+            },
+            theme: "neat",
+            keyMap: "sublime"
+        };
+
+
+        function goToGraph() {
+            window.location.href = '/projects/graph?type={{descriptor_type}}&id={{descriptor_id}}'
+        }
+    </script>
+{% endblock %}
diff --git a/descriptorhandler/template/descriptorlist.html b/descriptorhandler/template/descriptorlist.html
new file mode 100644 (file)
index 0000000..9d86624
--- /dev/null
@@ -0,0 +1,47 @@
+{% load staticfiles %}
+{% load get %}
+<div class="col-md-12">
+
+    <div class="box">
+        <div class="box-header with-border">
+            <h3 class="box-title">
+            </h3>
+            <div class="box-tools">
+                <div class="btn-group">
+
+                </div>
+            </div>
+        </div>
+        <div class="box-body">
+            <table id="descriptors_table" class="table table-bordered table-striped dataTable"
+                   role="grid">
+                <thead>
+                <tr role="row">
+                    <th>Name</th>
+                    <th>Identified</th>
+                    <th>Description</th>
+                    <th style="width:10%">Vendor</th>
+                    <th style="width:5%">Version</th>
+                    <th style="width:35%">Actions</th>
+                </tr>
+                </thead>
+                <tbody>
+
+                </tbody>
+
+            </table>
+        </div>
+    </div>
+</div>
+
+<div class="col-sm-12">
+    <div class="box box-solid">
+        <div class="box-body">
+
+            <div class="upload-drop-zone" id="drop-zone">
+               <i class="fa fa-upload"></i> Just drag and drop files here
+            </div>
+        </div>
+    </div>
+</div>
+
diff --git a/descriptorhandler/template/modal/choose_node_id.html b/descriptorhandler/template/modal/choose_node_id.html
new file mode 100644 (file)
index 0000000..91c4d20
--- /dev/null
@@ -0,0 +1 @@
+{% extends "descriptor/modal/choose_node_id.html" %}
\ No newline at end of file
diff --git a/descriptorhandler/template/modal/create_link_chooser.html b/descriptorhandler/template/modal/create_link_chooser.html
new file mode 100644 (file)
index 0000000..ed9a4a5
--- /dev/null
@@ -0,0 +1,21 @@
+<div class="modal" id="modal_create_link_chooser">
+  <div class="modal-dialog">
+    <div class="modal-content">
+      <div class="modal-header">
+        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+          <span aria-hidden="true">×</span></button>
+        <h4 class="modal-title" id="modal_chooser_title">Default Modal</h4>
+      </div>
+      <div class="modal-body" >
+          <select class="form-control" id="selection_chooser">
+          </select>
+    </div>
+      <div class="modal-footer">
+        <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
+        <button type="button" class="btn btn-primary" id="save_chooser">Save changes</button>
+      </div>
+    </div>
+    <!-- /.modal-content -->
+  </div>
+  <!-- /.modal-dialog -->
+</div>
\ No newline at end of file
diff --git a/descriptorhandler/urls.py b/descriptorhandler/urls.py
new file mode 100644 (file)
index 0000000..c6e987e
--- /dev/null
@@ -0,0 +1,30 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
+from django.conf.urls import url
+from descriptorhandler import views
+
+urlpatterns = [
+    url(r'(?P<descriptor_type>\w+)/list$', views.show_descriptors, name='list_descriptors'),
+    url(r'(?P<descriptor_type>\w+)/(?P<descriptor_id>[-\w]+)(/$)', views.edit_descriptor, name='edit_descriptor'),
+    url(r'(?P<descriptor_type>\w+)/(?P<descriptor_id>[-\w]+)/delete$', views.delete_descriptor, name='delete_descriptor'),
+    url(r'(?P<descriptor_type>\w+)/(?P<descriptor_id>[-\w]+)/clone', views.clone_descriptor, name='clone_descriptor'),
+    url(r'(?P<descriptor_type>\w+)/(?P<descriptor_id>[-\w]+)/action/(?P<action_name>[-\w]+)',views.custom_action,
+        name='custom_action'),
+    url(r'(?P<descriptor_type>\w+)/new$', views.new_descriptor, name='new_descriptor'),
+    url(r'composer$', views.open_composer, name='open_composer'),
+    url(r'availablenodes', views.get_available_nodes, name='get_available_nodes'),
+]
diff --git a/descriptorhandler/views.py b/descriptorhandler/views.py
new file mode 100644 (file)
index 0000000..8b902af
--- /dev/null
@@ -0,0 +1,458 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
+import json
+import logging
+
+import yaml
+from sf_t3d.decorators import login_required
+from django.http import HttpResponse
+from django.shortcuts import render, redirect
+
+
+from lib.util import Util
+from lib.osm.osmclient.clientv2 import Client
+import authosm.utils as osmutils
+
+logging.basicConfig(level=logging.DEBUG)
+log = logging.getLogger('descriptorhandler/view.py')
+
+
+@login_required
+def show_descriptors(request, descriptor_type=None):
+    user = osmutils.get_user(request)
+    project_id = user.project_id
+    client = Client()
+    print descriptor_type
+    try:
+        if descriptor_type == 'nsd':
+            descriptors = client.nsd_list(user.get_token())
+        elif descriptor_type == 'vnfd':
+            descriptors = client.vnfd_list(user.get_token())
+    except Exception as e:
+        log.exception(e)
+        descriptors = []
+
+    url = 'osm/osm_project_descriptors.html'
+    return __response_handler(request, {
+        'descriptors': descriptors['data'] if descriptors and descriptors['error'] is False else [],
+        'project_id': project_id,
+        'project_type': 'osm',
+        'descriptor_type': descriptor_type
+    }, url)
+
+
+@login_required
+def delete_descriptor(request, descriptor_type=None, descriptor_id=None):
+    user = osmutils.get_user(request)
+    project_id = user.project_id
+    try:
+        client = Client()
+        if descriptor_type == 'nsd':
+            result = client.nsd_delete(user.get_token(), descriptor_id)
+        elif descriptor_type == 'vnfd':
+            result = client.vnfd_delete(user.get_token(), descriptor_id)
+    except Exception as e:
+        log.exception(e)
+        result = {'error': True, 'data': str(e)}
+
+    url = 'osm/osm_project_descriptors.html'
+    descriptors = {}
+    try:
+        if descriptor_type == 'nsd':
+            descriptors = client.nsd_list(user.get_token())
+        elif descriptor_type == 'vnfd':
+            descriptors = client.vnfd_list(user.get_token())
+    except Exception as e:
+        log.exception(e)
+
+    return __response_handler(request, {
+        'descriptors': descriptors['data'] if descriptors and descriptors['error'] is False else [],
+        'project_id': project_id,
+        'project_type': 'osm',
+        'descriptor_type': descriptor_type,
+        'alert_message': {
+            'success': False if result['error'] is True else True,
+            'message': 'An error occurred while processing your request.' if result and result['error'] is True else "Record deleted successfully"}
+    }, url)
+
+
+@login_required
+def clone_descriptor(request, descriptor_type=None, descriptor_id=None):
+    user = osmutils.get_user(request)
+    project_id = user.project_id
+
+    try:
+        client = Client()
+        if descriptor_type == 'nsd':
+            result = client.nsd_clone(user.get_token(), descriptor_id)
+        elif descriptor_type == 'vnfd':
+            result = client.vnfd_clone(user.get_token(), descriptor_id)
+        else:
+            log.debug('Update descriptor: Unknown data type')
+            result = {'error': True, 'data': 'Update descriptor: Unknown data type'}
+    except Exception as e:
+        log.exception(e)
+        result = {'error': True, 'data': str(e)}
+    if result['error'] == True:
+        return __response_handler(request, result['data'], url=None,
+                                  status=result['data']['status'] if 'status' in result['data'] else 500)
+
+    else:
+        return __response_handler(request, {}, url=None, status=200)
+
+
+@login_required
+def new_descriptor(request, descriptor_type=None):
+    user = osmutils.get_user(request)
+    project_id = user.project_id
+    page = 'descriptor_new.html'
+    if request.method == 'GET':
+        request_id = request.GET.get('id', '')
+
+        return __response_handler(request,  {
+            'project_id': project_id,
+            'descriptor_type': descriptor_type,
+            'descriptor_id': request_id,
+        }, page)
+    elif request.method == 'POST':
+        data_type = request.POST.get('type')
+        if data_type == "file":
+            file_uploaded = request.FILES['file']
+
+            try:
+                client = Client()
+                if descriptor_type == 'nsd':
+                    result = client.nsd_onboard(user.get_token(), file_uploaded)
+                elif descriptor_type == 'vnfd':
+                    result = client.vnfd_onboard(user.get_token(), file_uploaded)
+                else:
+                    log.debug('Create descriptor: Unknown data type')
+                    result = {'error': True, 'data': 'Create descriptor: Unknown data type'}
+
+            except Exception as e:
+                log.exception(e)
+                result = {'error': True, 'data': str(e)}
+        else:
+            result = {'error': True, 'data': 'Create descriptor: Unknown data type'}
+
+        if result['error']:
+            return __response_handler(request, result['data'], url=None, status=result['data']['status'] if 'status' in result['data'] else 500)
+        else:
+            return __response_handler(request, {}, url=None, status=200)
+
+
+@login_required
+def edit_descriptor(request, descriptor_id=None, descriptor_type=None):
+    user = osmutils.get_user(request)
+    project_id = user.project_id
+    if request.method == 'POST':
+        new_data = request.POST.get('text'),
+        data_type = request.POST.get('type')
+        #print new_data
+        try:
+            client = Client()
+            if descriptor_type == 'nsd':
+                if data_type == 'yaml':
+                    new_data = yaml.load(request.POST.get('text'))
+                elif data_type == 'json':
+                    new_data = json.loads(request.POST.get('text'))
+                result = client.nsd_update(user.get_token(), descriptor_id, new_data)
+            elif descriptor_type == 'vnfd':
+                if data_type == 'yaml':
+                    new_data = yaml.load(request.POST.get('text'))
+                elif data_type == 'json':
+                    new_data = json.loads(request.POST.get('text'))
+                result = client.vnfd_update(user.get_token(), descriptor_id, new_data)
+
+            else:
+                log.debug('Update descriptor: Unknown data type')
+                result = {'error': True, 'data': 'Update descriptor: Unknown data type'}
+        except Exception as e:
+            log.exception(e)
+            result = {'error': True, 'data': str(e)}
+        if result['error'] == True:
+            return __response_handler(request, result['data'], url=None, status=result['data']['status'] if 'status' in result['data'] else 500)
+
+        else:
+            return __response_handler(request, {}, url=None, status=200)
+
+    elif request.method == 'GET':
+
+        page = 'descriptor_view.html'
+        try:
+            client = Client()
+            if descriptor_type == 'nsd':
+                result = client.nsd_get(user.get_token(), descriptor_id)
+            elif descriptor_type == 'vnfd':
+                result = client.vnfd_get(user.get_token(), descriptor_id)
+
+        except Exception as e:
+            log.exception(e)
+            result = {'error': True, 'data': str(e)}
+
+        if isinstance(result, dict) and 'error' in result and result['error']:
+            return render(request, 'error.html')
+
+        descriptor_string_json = json.dumps(result, indent=2)
+        descriptor_string_yaml = Util.json2yaml(result)
+        # print descriptor
+        return render(request, page, {
+            'project_id': project_id,
+            'descriptor_id': descriptor_id,
+            'descriptor_type': descriptor_type,
+            'descriptor_strings': {'descriptor_string_yaml': descriptor_string_yaml,
+                                   'descriptor_string_json': descriptor_string_json}})
+
+
+@login_required
+def get_package_files_list(request, descriptor_id, descriptor_type):
+    user = osmutils.get_user(request)
+    try:
+        client = Client()
+        if descriptor_type == 'nsd':
+            artifacts_res = client.nsd_artifacts(user.get_token(), descriptor_id)
+        elif descriptor_type == 'vnfd':
+            artifacts_res = client.vnf_packages_artifacts(user.get_token(), descriptor_id)
+        else:
+            return False
+
+        files_list = yaml.load(artifacts_res['data'] if artifacts_res and artifacts_res['error'] is False else [])
+        result = {'files': files_list}
+    except Exception as e:
+        log.exception(e)
+        url = 'error.html'
+        result = {'error_msg': 'Unknown error.'}
+    return __response_handler(request, result)
+
+
+@login_required
+def download_pkg(request, descriptor_id, descriptor_type):
+    user = osmutils.get_user(request)
+    file_name = "osm_export.tar.gz"
+    tar_pkg = None
+    try:
+        client = Client()
+        if descriptor_type == 'nsd':
+            tar_pkg = client.get_nsd_pkg(user.get_token(), descriptor_id)
+        elif descriptor_type == 'vnfd':
+            tar_pkg = client.get_vnfd_pkg(user.get_token(), descriptor_id)
+
+    except Exception as e:
+        log.exception(e)
+
+    response = HttpResponse(content_type="application/tgz")
+    response["Content-Disposition"] = "attachment; filename="+ file_name
+    response.write(tar_pkg.getvalue())
+    return response
+
+@login_required
+def open_composer(request):
+    user = osmutils.get_user(request)
+    project_id = user.project_id
+    result = {'project_id': project_id,
+              'vertices': [
+                  {"info": {"type": "vnf", "property": {"custom_label": ""},
+                            "group": []}, "id": "vm"},
+                  {"info": {"type": "vnf", "property": {"custom_label": ""},
+                            "group": []}, "id": "vlan"},
+                  {"info": {"type": "vnf", "property": {"custom_label": ""},
+                            "group": []}, "id": "firewall"},
+                  {"info": {"type": "vnf", "property": {"custom_label": ""},
+                            "group": []}, "id": "ping"},
+
+                  {"info": {"type": "ns_vl", "property": {"custom_label": ""},
+                            "group": []}, "id": "vl1"},
+                  {"info": {"type": "ns_vl", "property": {"custom_label": ""},
+                            "group": []}, "id": "vl2"},
+                  {"info": {"type": "ns_vl", "property": {"custom_label": ""},
+                            "group": []}, "id": "vl3"},
+              ],
+              'edges': [
+                  {"source": "vm", "group": [], "target": "vl3", "view": "ns"},
+                  {"source": "vlan", "group": [], "target": "vl3", "view": "ns"},
+                  {"source": "vlan", "group": [], "target": "vl1", "view": "ns"},
+                  {"source": "firewall", "group": [], "target": "vl1", "view": "ns"},
+                  {"source": "firewall", "group": [], "target": "vl2", "view": "ns"},
+                  {"source": "ping", "group": [], "target": "vl2", "view": "ns"},
+              ],
+              'model': {
+                "layer": {
+
+                    "ns": {
+                        "nodes": {
+                            "vnf": {
+                                "addable": {
+                                    "callback": "addNode"
+                                },
+                                "removable": {
+                                    "callback": "removeNode"
+                                },
+                                "expands": "vnf"
+                            },
+                            "ns_vl": {
+                                "addable": {
+                                    "callback": "addNode"
+                                },
+                                "removable": {
+                                    "callback": "removeNode"
+                                }
+                            },
+
+                        },
+                        "allowed_edges": {
+                            "ns_vl": {
+                                "destination": {
+                                    "vnf": {
+                                        "callback": "addLink",
+                                        "direct_edge": False,
+                                        "removable": {
+                                            "callback": "removeLink"
+                                        }
+                                    }
+                                }
+                            },
+                            "vnf": {
+                                "destination": {
+                                    "ns_vl": {
+                                        "callback": "addLink",
+                                        "direct_edge": False,
+                                        "removable": {
+                                            "callback": "removeLink"
+                                        }
+                                    },
+
+                                }
+                            }
+
+                        }
+                    },
+                    "vnf": {
+                        "nodes": {
+                            "vdu": {
+                                "addable": {
+                                    "callback": "addNode"
+                                },
+                                "removable": {
+                                    "callback": "removeNode"
+                                }
+                            },
+                            "cp": {
+                                "addable": {
+                                    "callback": "addNode"
+                                },
+                                "removable": {
+                                    "callback": "removeNode"
+                                }
+                            },
+
+                        },
+                        "allowed_edges": {
+                            "vdu": {
+                                "destination": {
+                                    "cp": {
+                                        "callback": "addLink",
+                                        "direct_edge": False,
+                                        "removable": {
+                                            "callback": "removeLink"
+                                        }
+                                    }
+                                }
+                            },
+                            "cp": {
+                                "destination": {
+                                    "vdu": {
+                                        "callback": "addLink",
+                                        "direct_edge": False,
+                                        "removable": {
+                                            "callback": "removeLink"
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    },
+                    "name": "OSM",
+                    "version": 1,
+                    "nodes": {
+                        "vnf": {
+                            "label": "vnf"
+                        },
+                        "ns_vl": {
+                            "label": "vl"
+                        },
+                        "cp": {
+                            "label": "cp"
+                        },
+                        "vdu": {
+                            "label": "vdu"
+                        }
+                    },
+                    "description": "osm",
+                    "callback": {
+                        "addNode": {
+                            "file": "osm_controller.js",
+                            "class": "OsmController"
+                        },
+                        "removeNode": {
+                            "file": "osm_controller.js",
+                            "class": "OsmController"
+                        },
+                        "addLink": {
+                            "file": "osm_controller.js",
+                            "class": "OsmController"
+                        },
+                        "removeLink": {
+                            "file": "osm_controller.js",
+                            "class": "OsmController"
+                        }
+                    }
+
+                }
+            }}
+    return __response_handler(request, result, 'composer.html')
+
+
+def get_available_nodes(request):
+
+    params = request.GET.dict()
+    nodes = {
+        'ns': [{"types": [{"name": "Generic", "id": "vnf"},
+                          {"name": "ping", "id": "vnf"},
+                          {"name": "pong", "id": "vnf"},
+                          {"name": "hackfest1-vm", "id": "vnf"}], "category_name": "Vnf"},
+               {"types": [{"name": "VL", "id": "ns_vl"}], "category_name": "VirtualLink"}],
+        'vnf': [{"types": [{"name": "VDU", "id": "vdu"}], "category_name": "Vdu"},
+                {"types": [{"name": "CP", "id": "cp"}], "category_name": "CP"}]
+    }
+
+    return __response_handler(request, nodes[params['layer']])
+
+
+@login_required
+def custom_action(request, descriptor_id=None, descriptor_type=None, action_name=None):
+    if request.method == 'GET':
+        return globals()[action_name](request, descriptor_id, descriptor_type)
+
+
+def __response_handler(request, data_res, url=None, to_redirect=None, *args, **kwargs):
+    raw_content_types = request.META.get('HTTP_ACCEPT', '*/*').split(',')
+    if 'application/json' in raw_content_types or url is None:
+        return HttpResponse(json.dumps(data_res), content_type="application/json", *args, **kwargs)
+    elif to_redirect:
+        return redirect(url, *args, **kwargs)
+    else:
+        return render(request, url, data_res)
index 9a50881..e532076 100644 (file)
@@ -7,7 +7,7 @@
 
             <button type="button" class="btn btn-default" data-container="body"
                     data-toggle="tooltip" data-placement="top" title="Instantiate NS"
-                    onclick="javascript:openModalCreateNS({ 'project_id':'{{ project_id }}','vim_list_url': '{% url "vims:list"  %}', 'nsd_list_url': '{% url "projects:list_descriptors" descriptor_type='nsd' %}'})">
+                    onclick="javascript:openModalCreateNS({ 'project_id':'{{ project_id }}','vim_list_url': '{% url "vims:list"  %}', 'nsd_list_url': '{% url "projects:descriptors:list_descriptors" descriptor_type='nsd' %}'})">
                 <i class="fa fa-paper-plane"></i> <span> New NS</span></button>
 
         </div>
diff --git a/projecthandler/template/project/descriptor/descriptor_view_base.html b/projecthandler/template/project/descriptor/descriptor_view_base.html
deleted file mode 100644 (file)
index 918e810..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-{% extends "base.html" %}
-
-{% load staticfiles %}
-
-{% block head_block %}
-       {{ block.super }}
-
-
-    <!-- Codemirror core CSS -->
-    <link rel="stylesheet" href="/static/bower_components/codemirror/lib/codemirror.css" >
-    <link rel="stylesheet" href="/static/bower_components/codemirror/addon/fold/foldgutter.css"  />
-    <link rel="stylesheet" href="/static/bower_components/codemirror/theme/neat.css" >
-    <link rel="stylesheet" href="/static/bower_components/codemirror/addon/dialog/dialog.css" >
-    <link rel="stylesheet" href="/static/bower_components/codemirror/addon/display/fullscreen.css" >
-
-{% endblock %}
-
-
-
-
-{% block content_body %}
-       {{ block.super }}
-<div class="row">
-    <div class="col-md-12">
-    <div class="nav-tabs-custom" style="position: relative;">
-    <ul class="nav nav-tabs" >
-        {% block tab_pane_button_list %}
-
-        {% endblock %}
-
-        {% block nav_buttons_list %}
-
-        {% endblock %}
-
-    </ul>
-        <div class="alert alert-success" id="success-alert" style="position: absolute; z-index: 100; top: 44px; left: 0;
-    width: 100%;
-    border-radius: 1px;
-    background-color: rgba(0, 166, 90, 0.8) !important;
-    text-align: center;
-    border-color: rgba(0, 141, 76, 0.4);" hidden>
-            <button type="button" class="close" onclick="$('#success-alert').toggle()">x</button>
-            <strong>Success! </strong>
-            Descriptor updated!
-        </div>
-    <div class="tab-content">
-        {% block tab_pane_list %}
-
-        {% endblock %}
-    </div>
-    <!-- /.tab-content -->
-
-
-
-
-</div>
-
-    </div>
-</div>
-{% endblock %}
-
-{% block resource_block %}
-       {{ block.super }}
-
-
-    <script src="/static/bower_components/codemirror/lib/codemirror.js" ></script>
-    <script src="/static/bower_components/codemirror/addon/fold/foldcode.js" ></script>
-    <script src="/static/bower_components/codemirror/addon/fold/foldgutter.js" ></script>
-    <script src="/static/bower_components/codemirror/addon/fold/brace-fold.js" ></script>
-    <script src="/static/bower_components/codemirror/mode/javascript/javascript.js" ></script>
-    <script src="/static/bower_components/codemirror/mode/yaml/yaml.js" ></script>
-    <script src="/static/bower_components/codemirror/mode/markdown/markdown.js" ></script>
-    <script src="/static/bower_components/codemirror/addon/search/searchcursor.js" ></script>
-    <script src="/static/bower_components/codemirror/addon/search/search.js" ></script>
-    <script src="/static/bower_components/codemirror/addon/dialog/dialog.js" ></script>
-    <script src="/static/bower_components/codemirror/addon/display/autorefresh.js" ></script>
-    <script src="/static/bower_components/codemirror/addon/edit/matchbrackets.js" ></script>
-    <script src="/static/bower_components/codemirror/addon/edit/closebrackets.js" ></script>
-    <script src="/static/bower_components/codemirror/addon/display/fullscreen.js" ></script>
-    <script src="/static/bower_components/codemirror/keymap/sublime.js" ></script>
-
-
-    <script>
-
-        var json_editor_settings = {
-            mode: "javascript",
-            showCursorWhenSelecting: true,
-            autofocus: true,
-            lineNumbers: true,
-            lineWrapping: true,
-            foldGutter: true,
-            gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
-            autoCloseBrackets: true,
-            matchBrackets: true,
-            extraKeys: {
-                "F11": function (cm) {
-                    cm.setOption("fullScreen", !cm.getOption("fullScreen"));
-                },
-                "Esc": function (cm) {
-                    if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
-                },
-                "Ctrl-Q": function (cm) {
-                    cm.foldCode(cm.getCursor());
-                }
-            },
-            theme: "neat",
-            keyMap: "sublime"
-        };
-
-        var yaml_editor_settings = {
-            mode: "yaml",
-            showCursorWhenSelecting: true,
-            autofocus: true,
-            autoRefresh: true,
-            lineNumbers: true,
-            lineWrapping: true,
-            foldGutter: true,
-            gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
-            autoCloseBrackets: true,
-            matchBrackets: true,
-            extraKeys: {
-                "F11": function (cm) {
-                    cm.setOption("fullScreen", !cm.getOption("fullScreen"));
-                },
-                "Esc": function (cm) {
-                    if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
-                },
-                "Ctrl-Q": function (cm) {
-                    cm.foldCode(cm.getCursor());
-                }
-            },
-            theme: "neat",
-            keyMap: "sublime"
-        };
-
-
-        function goToGraph() {
-            window.location.href = '/projects/graph?type={{descriptor_type}}&id={{descriptor_id}}'
-        }
-    </script>
-{% endblock %}
diff --git a/projecthandler/template/project/descriptor/modal/choose_node_id.html b/projecthandler/template/project/descriptor/modal/choose_node_id.html
deleted file mode 100644 (file)
index 3bfea9e..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<div class="modal" id="modal_choose_node_id" xmlns="http://www.w3.org/1999/html">
-    <div class="modal-dialog">
-        <div class="modal-content">
-            <div class="modal-header">
-                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-                    <span aria-hidden="true">×</span></button>
-                <h4 class="modal-title" id="modal_chooser_title_add_node">Add node</h4>
-            </div>
-            <div class="modal-body">
-                <div id="div_chose_id">
-                    <label>Choose an id </label>
-                    <input name="input_choose_node_id" id="input_choose_node_id" type="text" size="40" maxlength="20"/>
-                </div>
-                {% block content_body %}
-
-                {% endblock %}
-            </div>
-
-            <div class="modal-footer">
-                <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>
-                <button type="button" class="btn btn-primary" id="save_choose_node_id">Add</button>
-            </div>
-        </div>
-        <!-- /.modal-content -->
-    </div>
-    <!-- /.modal-dialog -->
-</div>
\ No newline at end of file
diff --git a/projecthandler/template/project/osm/descriptor/descriptor_new.html b/projecthandler/template/project/osm/descriptor/descriptor_new.html
deleted file mode 100644 (file)
index 7711b57..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-{% extends "descriptor/descriptor_view_base.html" %}
-
-{% load staticfiles %}
-
-
-{% block title_header_big %}
-{{ block.super }}
-Onboard new {{ descriptor_type }} package
-{% endblock %}
-
-{% block left_sidebar %}
-{% include 'osm/osm_project_left_sidebar.html' %}
-{% endblock %}
-
-{% block breadcrumb_body %}
-{{ block.super }}
-<li><a href="{% url 'projects:open_project'  %}">{{project_id}}</a></li>
-<li><a href="{% url 'projects:open_project'  %}descriptors/{{descriptor_type}}">{{ descriptor_type }}  Descriptors</a></li>
-<li>Create Descriptor</li>
-{% endblock %}
-
-{% block tab_pane_button_list %}
-{{ block.super }}
-<li id="file_li" class="active"><a href="#upload" data-toggle="tab"><i class="fa fa-upload"></i> Onboard Package</a></li>
-{% endblock %}
-
-{% block nav_buttons_list %}
-{{ block.super }}
-<li class="pull-right">
-    <button id="cancel" type="button" class="btn btn-block btn-primary btn-sm" onclick="cancel(this.id)"><i
-            class="fa fa-times"></i> Cancel
-    </button>
-</li>
-{% endblock %}
-
-{% block tab_pane_list %}
-{{ block.super }}
-
-<div class="tab-pane active" id="upload">
-
-    <h4>Drag and drop file below</h4>
-    <div class="upload-drop-zone" id="drop-zone">
-            Just drag and drop files here
-    </div>
-</div>
-{% endblock %}
-
-
-{% block resource_block %}
-{{ block.super }}
-
-<script>
-    var descr_list_url = '{% url "projects:list_descriptors"   descriptor_type=descriptor_type%}';
-    var csrf_token = '{{csrf_token}}';
-    var new_desc_url ="{% url 'projects:new_descriptor'  descriptor_type=descriptor_type %}"
-
-    function cancel(id) {
-        window.location.href = descr_list_url
-    }
-
-</script>
-    <script src="/static/src/projecthandler/onboard_package.js"></script>
-{% endblock %}
-
-{% block footer %}
-    {% include "footer.html" %}
-{% endblock %}
diff --git a/projecthandler/template/project/osm/descriptor/descriptor_view.html b/projecthandler/template/project/osm/descriptor/descriptor_view.html
deleted file mode 100644 (file)
index aa43149..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-{% extends "descriptor/descriptor_view_base.html" %}
-
-{% load staticfiles %}
-
-
-{% block title_header_big %}
-{{ block.super }}
-Edit {{ descriptor_type|upper }} Descriptor
-{% endblock %}
-
-
-{% block left_sidebar %}
-{% include 'osm/osm_project_left_sidebar.html' %}
-{% endblock %}
-
-{% block breadcrumb_body %}
-{{ block.super }}
-<li><a href="{% url 'projects:open_project' %}">{{project_id}}</a></li>
-<li><a href="{% url 'projects:list_descriptors' descriptor_type=descriptor_type %}">{{ descriptor_type }} Descriptors</a></li>
-<li><a>{{descriptor_id}}</a></li>
-{% endblock %}
-
-{% block tab_pane_button_list %}
-{{ block.super }}
-<li class="active" id="yaml_li"><a href="#yaml" data-toggle="tab"><i class="fa fa-file-code-o"></i> YAML</a></li>
-<li id="json_li"><a href="#json" data-toggle="tab"><i class="fa fa-file-code-o"></i> JSON</a></li>
-{% endblock %}
-
-{% block nav_buttons_list %}
-    {{ block.super }}
-    <li class="pull-right"><button id="save" type="button" class="btn btn-block btn-primary btn-sm"  onclick="update(this.id)" ><i class="fa fa-save"></i> Update</button></li>
-    <li class="pull-right"><button id="save_show_graph" type="button" class="btn btn-block btn-primary btn-sm"  onclick="update(this.id)" disabled><i class="fa fa-save"></i> Update and Show Graph</button></li>
-    <li class="pull-right"><button type="button" class="btn btn-block btn-primary btn-sm"  onclick="goToGraph()" disabled><i class="fa fa-sitemap"></i> Show Graph</button></li>
-
-{% endblock %}
-
-{% block tab_pane_list %}
-{{ block.super }}
-
-<!-- /.tab-pane -->
-<div class="active tab-pane" id="yaml">
-    <textarea id="code_editor_yaml">
-    </textarea>
-</div>
-<!-- /.tab-pane-->
-
-<div class="tab-pane" id="json">
-    <textarea id="code_editor_json">
-    </textarea>
-</div>
-
-{% endblock %}
-
-{% block resource_block %}
-{{ block.super }}
-
-
-<script>
-    var editorJSON;
-    var editorYaml;
-
-    $(document).ready(function () {
-        //var cmjsoneditor = CodeMirror.fromTextArea(document.getElementById("code_editor"), json_editor_settings);
-        var myJsonTextArea = document.getElementById("code_editor_json");
-        editorJSON = CodeMirror(function (elt) {
-            myJsonTextArea.parentNode.replaceChild(elt, myJsonTextArea);
-        }, json_editor_settings);
-        editorJSON.setValue(JSON.stringify({{descriptor_strings.descriptor_string_json | safe}}, null, "\t"));
-        editorJSON.setOption("autoRefresh", true);
-        editorJSON.setSize("auto", "auto");
-
-        var myYamlTextArea = document.getElementById("code_editor_yaml");
-        editorYaml = CodeMirror(function (elt) {
-            myYamlTextArea.parentNode.replaceChild(elt, myYamlTextArea);
-        }, yaml_editor_settings);
-        var des_strings = {{descriptor_strings | safe}};
-        editorYaml.setValue(des_strings.descriptor_string_yaml);
-        editorYaml.setSize("auto", "auto");
-    });
-
-
-    function update(e) {
-        var dialog = bootbox.dialog({
-            message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
-            closeButton: false
-        });
-
-        var id = $('.nav-tabs .active').attr('id');
-        var type, text;
-        switch (id) {
-            case 'yaml_li':
-                type = 'yaml';
-                text = editorYaml.getValue();
-                break;
-            case 'json_li':
-                type = 'json';
-                text = editorJSON.getValue();
-                break;
-        }
-        $.ajax({
-            url: "/projects/descriptors/{{descriptor_type}}/{{descriptor_id}}/",
-            type: 'POST',
-            dataType: 'json',
-            data: {
-                'csrfmiddlewaretoken': '{{csrf_token}}',
-                'type': type,
-                'text': text
-            },
-            success: function (result) {
-                dialog.modal('hide');
-                $("#success-alert").fadeTo(2000, 500).slideDown(500, function(){
-                    setTimeout(function () {
-                        $("#success-alert").slideUp(500);
-                    }, 2000);
-
-                });
-            },
-            error: function (result) {
-                console.log(result);
-                dialog.modal('hide');
-                bootbox.alert(result);
-            }
-        });
-    }
-
-</script>
-{% endblock %}
-
-
-{% block footer %}
-    {% include "footer.html"  %}
-{% endblock %}
diff --git a/projecthandler/template/project/osm/descriptor/descriptorlist.html b/projecthandler/template/project/osm/descriptor/descriptorlist.html
deleted file mode 100644 (file)
index b2222e2..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-{% load staticfiles %}
-{% load get %}
-<div class="col-md-12">
-
-    <div class="box">
-        <div class="box-header with-border">
-            <h3 class="box-title">
-            </h3>
-            <div class="box-tools">
-                <div class="btn-group">
-                    <!--
-                <a href="{% url 'projects:open_composer'%}"
-                   class="btn btn-block btn-primary btn-sm"><i
-                        class="fa fa-paint-brush" disabled></i><span> Composer</span></a>
-                        -->
-                </div>
-            </div>
-        </div>
-        <div class="box-body">
-            <table id="descriptors_table" class="table table-bordered table-striped dataTable"
-                   role="grid">
-                <thead>
-                <tr role="row">
-                    <th>Name</th>
-                    <th>Identified</th>
-                    <th>Description</th>
-                    <th style="width:10%">Vendor</th>
-                    <th style="width:5%">Version</th>
-                    <th style="width:35%">Actions</th>
-                </tr>
-                </thead>
-                <tbody>
-
-                </tbody>
-
-            </table>
-        </div>
-    </div>
-</div>
-
-<div class="col-sm-12">
-    <div class="box box-solid">
-        <div class="box-body">
-
-            <div class="upload-drop-zone" id="drop-zone">
-               <i class="fa fa-upload"></i> Just drag and drop files here
-            </div>
-        </div>
-    </div>
-</div>
-
diff --git a/projecthandler/template/project/osm/descriptor/modal/choose_node_id.html b/projecthandler/template/project/osm/descriptor/modal/choose_node_id.html
deleted file mode 100644 (file)
index 91c4d20..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{% extends "descriptor/modal/choose_node_id.html" %}
\ No newline at end of file
diff --git a/projecthandler/template/project/osm/descriptor/modal/create_link_chooser.html b/projecthandler/template/project/osm/descriptor/modal/create_link_chooser.html
deleted file mode 100644 (file)
index ed9a4a5..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<div class="modal" id="modal_create_link_chooser">
-  <div class="modal-dialog">
-    <div class="modal-content">
-      <div class="modal-header">
-        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-          <span aria-hidden="true">×</span></button>
-        <h4 class="modal-title" id="modal_chooser_title">Default Modal</h4>
-      </div>
-      <div class="modal-body" >
-          <select class="form-control" id="selection_chooser">
-          </select>
-    </div>
-      <div class="modal-footer">
-        <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
-        <button type="button" class="btn btn-primary" id="save_chooser">Save changes</button>
-      </div>
-    </div>
-    <!-- /.modal-content -->
-  </div>
-  <!-- /.modal-dialog -->
-</div>
\ No newline at end of file
index 83a8b38..8c1ceb2 100644 (file)
@@ -36,7 +36,7 @@
 {% include 'osm/modal/files_list.html' %}
 {% include 'modal/instance_create.html' %}
 <div class="row">
-    {% include "osm/descriptor/descriptorlist.html" %}
+    {% include "descriptorlist.html" %}
 </div>
 {% endblock %}
 
@@ -52,9 +52,9 @@
 
     <script>
     var csrf_token = '{{csrf_token}}';
-    var descr_list_url = '{% url "projects:list_descriptors"   descriptor_type=descriptor_type%}';
+    var descr_list_url = '{% url "projects:descriptors:list_descriptors"   descriptor_type=descriptor_type%}';
     var vim_list_url = '{% url "vims:list"  %}';
-    var new_desc_url ="{% url 'projects:new_descriptor'  descriptor_type=descriptor_type %}";
+    var new_desc_url ="{% url 'projects:descriptors:new_descriptor'  descriptor_type=descriptor_type %}";
     var descriptor_type = '{{ descriptor_type | safe }}';
     var project_id = '{{ project_id }}';
     var table;
index d5edc1e..d4b7eb5 100644 (file)
@@ -44,7 +44,7 @@
                     <div class="inner"><h3>{{ project_overview.nsd }}</h3>
                         <p>NS packages</p></div>
                     <div class="icon"><i class="fa fa-archive"></i></div>
-                    <a href='{% url "projects:list_descriptors"   descriptor_type="nsd" %}' class="small-box-footer">Open list <i
+                    <a href='{% url "projects:descriptors:list_descriptors"   descriptor_type="nsd" %}' class="small-box-footer">Open list <i
                             class="fa fa-arrow-circle-right"></i></a></div>
             </div>
             <div class="col-md-6 ">
@@ -52,7 +52,7 @@
                     <div class="inner"><h3>{{ project_overview.vnfd }}</h3>
                         <p>VNF packages</p></div>
                     <div class="icon"><i class="fa fa-archive"></i></div>
-                    <a href='{% url "projects:list_descriptors"   descriptor_type="vnfd" %}' class="small-box-footer">Open list <i
+                    <a href='{% url "projects:descriptors:list_descriptors"   descriptor_type="vnfd" %}' class="small-box-footer">Open list <i
                             class="fa fa-arrow-circle-right"></i></a></div>
             </div>
         </div>
index 5bd34fd..63f9854 100644 (file)
@@ -14,8 +14,8 @@
                     <i class="fa fa-file-text fa-fw"></i> <span>Overview</span>
                 </a>
             </li>
-            {% url "projects:list_descriptors"   descriptor_type="nsd" as  nsd_list_url %}
-            {% url "projects:list_descriptors"   descriptor_type='vnfd' as  vnfd_list_url %}
+            {% url "projects:descriptors:list_descriptors"   descriptor_type="nsd" as  nsd_list_url %}
+            {% url "projects:descriptors:list_descriptors"   descriptor_type='vnfd' as  vnfd_list_url %}
             <li {% if request.get_full_path == nsd_list_url or  request.get_full_path == vnfd_list_url %}
                 class="active treeview menu-open" {% else %} class="treeview  menu-open" {% endif %} >
                 <a href="#">
index 15d2eeb..3d94118 100644 (file)
@@ -36,9 +36,8 @@
  {% csrf_token %}
 
 
-{% include 'osm/descriptor/modal/create_link_chooser.html' %}
-{% include 'osm/descriptor/modal/choose_node_id.html' %}
-{% include 'osm/modal/modal_keyboard_info.html' %}
+{% include 'modal/create_link_chooser.html' %}
+{% include 'modal/choose_node_id.html' %}
 {% endblock %}
 
 {% block resource_block %}
index 282afb4..5c43e22 100644 (file)
@@ -30,9 +30,8 @@
 {% block content_body %}
     {{ block.super }}
     {% csrf_token %}
-    {% include 'osm/descriptor/modal/create_link_chooser.html' %}
-{% include 'osm/descriptor/modal/choose_node_id.html' %}
-{% include 'osm/modal/modal_keyboard_info.html' %}
+    {% include 'modal/create_link_chooser.html' %}
+    {% include 'modal/choose_node_id.html' %}
     <div class="row" >
         <div class="col-md-12">
             {% block topology_toolbar %}
index e69bd29..1660607 100644 (file)
@@ -21,25 +21,13 @@ urlpatterns = [
     url(r'^$', views.open_project, name='open_project'),
     url(r'^list/', views.user_projects, name='projects_list'),
     url(r'^new/', views.create_new_project, name='new_project'),
+    url(r'^descriptors/', include('descriptorhandler.urls', namespace='descriptors'), name='descriptor_base'),
     url(r'^(?P<project_id>[\w ]+)/delete$', views.delete_project, name='delete_project'),
     url(r'^(?P<project_id>[\w ]+)/switch', views.switch_project, name='switch_project'),
     url(r'^(?P<project_id>[\w ]+)/edit', views.edit_project, name='edit_project'),
-    url(r'^descriptors/(?P<descriptor_type>\w+)/list$', views.show_descriptors, name='list_descriptors'),
-    url(r'^descriptors/(?P<descriptor_type>\w+)/(?P<descriptor_id>[-\w]+)(/$)',
-        views.edit_descriptor, name='edit_descriptor'),
-    url(r'^descriptors/(?P<descriptor_type>\w+)/(?P<descriptor_id>[-\w]+)/delete$',
-        views.delete_descriptor,
-        name='delete_descriptor'),
-    url(r'^descriptors/(?P<descriptor_type>\w+)/(?P<descriptor_id>[-\w]+)/clone',
-        views.clone_descriptor,
-        name='clone_descriptor'),
-    url(r'^descriptors/(?P<descriptor_type>\w+)/(?P<descriptor_id>[-\w]+)/action/(?P<action_name>[-\w]+)',
-        views.custom_action,
-        name='custom_action'),
-    url(r'^descriptors/(?P<descriptor_type>\w+)/new$', views.new_descriptor,
-        name='new_descriptor'),
-    url(r'^composer$', views.open_composer, name='open_composer'),
-    url(r'^availablenodes', views.get_available_nodes, name='get_available_nodes'),
+
+
+
 
 
 ]
\ No newline at end of file
index 9d4055d..6a9a98a 100644 (file)
@@ -62,189 +62,6 @@ def user_projects(request):
         'projects': result['data'] if result and result['error'] is False else [],
     },'projectlist.html')
 
-
-def open_composer(request):
-    user = osmutils.get_user(request)
-    project_id = user.project_id
-    result = {'project_id': project_id,
-              'vertices': [
-                  {"info": {"type": "vnf", "property": {"custom_label": ""},
-                            "group": []}, "id": "vm"},
-                  {"info": {"type": "vnf", "property": {"custom_label": ""},
-                            "group": []}, "id": "vlan"},
-                  {"info": {"type": "vnf", "property": {"custom_label": ""},
-                            "group": []}, "id": "firewall"},
-                  {"info": {"type": "vnf", "property": {"custom_label": ""},
-                            "group": []}, "id": "ping"},
-
-                  {"info": {"type": "ns_vl", "property": {"custom_label": ""},
-                            "group": []}, "id": "vl1"},
-                  {"info": {"type": "ns_vl", "property": {"custom_label": ""},
-                            "group": []}, "id": "vl2"},
-                  {"info": {"type": "ns_vl", "property": {"custom_label": ""},
-                            "group": []}, "id": "vl3"},
-              ],
-              'edges': [
-                  {"source": "vm", "group": [], "target": "vl3", "view": "ns"},
-                  {"source": "vlan", "group": [], "target": "vl3", "view": "ns"},
-                  {"source": "vlan", "group": [], "target": "vl1", "view": "ns"},
-                  {"source": "firewall", "group": [], "target": "vl1", "view": "ns"},
-                  {"source": "firewall", "group": [], "target": "vl2", "view": "ns"},
-                  {"source": "ping", "group": [], "target": "vl2", "view": "ns"},
-              ],
-              'model': {
-                "layer": {
-
-                    "ns": {
-                        "nodes": {
-                            "vnf": {
-                                "addable": {
-                                    "callback": "addNode"
-                                },
-                                "removable": {
-                                    "callback": "removeNode"
-                                },
-                                "expands": "vnf"
-                            },
-                            "ns_vl": {
-                                "addable": {
-                                    "callback": "addNode"
-                                },
-                                "removable": {
-                                    "callback": "removeNode"
-                                }
-                            },
-
-                        },
-                        "allowed_edges": {
-                            "ns_vl": {
-                                "destination": {
-                                    "vnf": {
-                                        "callback": "addLink",
-                                        "direct_edge": False,
-                                        "removable": {
-                                            "callback": "removeLink"
-                                        }
-                                    }
-                                }
-                            },
-                            "vnf": {
-                                "destination": {
-                                    "ns_vl": {
-                                        "callback": "addLink",
-                                        "direct_edge": False,
-                                        "removable": {
-                                            "callback": "removeLink"
-                                        }
-                                    },
-
-                                }
-                            }
-
-                        }
-                    },
-                    "vnf": {
-                        "nodes": {
-                            "vdu": {
-                                "addable": {
-                                    "callback": "addNode"
-                                },
-                                "removable": {
-                                    "callback": "removeNode"
-                                }
-                            },
-                            "cp": {
-                                "addable": {
-                                    "callback": "addNode"
-                                },
-                                "removable": {
-                                    "callback": "removeNode"
-                                }
-                            },
-
-                        },
-                        "allowed_edges": {
-                            "vdu": {
-                                "destination": {
-                                    "cp": {
-                                        "callback": "addLink",
-                                        "direct_edge": False,
-                                        "removable": {
-                                            "callback": "removeLink"
-                                        }
-                                    }
-                                }
-                            },
-                            "cp": {
-                                "destination": {
-                                    "vdu": {
-                                        "callback": "addLink",
-                                        "direct_edge": False,
-                                        "removable": {
-                                            "callback": "removeLink"
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    },
-                    "name": "OSM",
-                    "version": 1,
-                    "nodes": {
-                        "vnf": {
-                            "label": "vnf"
-                        },
-                        "ns_vl": {
-                            "label": "vl"
-                        },
-                        "cp": {
-                            "label": "cp"
-                        },
-                        "vdu": {
-                            "label": "vdu"
-                        }
-                    },
-                    "description": "osm",
-                    "callback": {
-                        "addNode": {
-                            "file": "osm_controller.js",
-                            "class": "OsmController"
-                        },
-                        "removeNode": {
-                            "file": "osm_controller.js",
-                            "class": "OsmController"
-                        },
-                        "addLink": {
-                            "file": "osm_controller.js",
-                            "class": "OsmController"
-                        },
-                        "removeLink": {
-                            "file": "osm_controller.js",
-                            "class": "OsmController"
-                        }
-                    }
-
-                }
-            }}
-    return __response_handler(request, result, 'project_graph_base.html')
-
-
-def get_available_nodes(request):
-
-    params = request.GET.dict()
-    nodes = {
-        'ns': [{"types": [{"name": "Generic", "id": "vnf"},
-                          {"name": "ping", "id": "vnf"},
-                          {"name": "pong", "id": "vnf"},
-                          {"name": "hackfest1-vm", "id": "vnf"}], "category_name": "Vnf"},
-               {"types": [{"name": "VL", "id": "ns_vl"}], "category_name": "VirtualLink"}],
-        'vnf': [{"types": [{"name": "VDU", "id": "vdu"}], "category_name": "Vdu"},
-                {"types": [{"name": "CP", "id": "cp"}], "category_name": "CP"}]
-    }
-
-    return __response_handler(request, nodes[params['layer']])
-
-
 @login_required
 def open_project(request):
     user = osmutils.get_user(request)
@@ -313,238 +130,7 @@ def edit_project(request, project_id):
             return __response_handler(request, {}, url=None, status=200)
 
 
-@login_required
-def show_descriptors(request, descriptor_type=None):
-    user = osmutils.get_user(request)
-    project_id = user.project_id
-    client = Client()
-    try:
-        if descriptor_type == 'nsd':
-            descriptors = client.nsd_list(user.get_token())
-        elif descriptor_type == 'vnfd':
-            descriptors = client.vnfd_list(user.get_token())
-    except Exception as e:
-        log.exception(e)
-        descriptors = []
-
-    url = 'osm/osm_project_descriptors.html'
-    return __response_handler(request, {
-        'descriptors': descriptors['data'] if descriptors and descriptors['error'] is False else [],
-        'project_id': project_id,
-        'project_type': 'osm',
-        'descriptor_type': descriptor_type
-    },url)
-
-
-@login_required
-def delete_descriptor(request, descriptor_type=None, descriptor_id=None):
-    user = osmutils.get_user(request)
-    project_id = user.project_id
-    try:
-        client = Client()
-        if descriptor_type == 'nsd':
-            result = client.nsd_delete(user.get_token(), descriptor_id)
-        elif descriptor_type == 'vnfd':
-            result = client.vnfd_delete(user.get_token(), descriptor_id)
-    except Exception as e:
-        log.exception(e)
-        result = {'error': True, 'data': str(e)}
-
-    url = 'osm/osm_project_descriptors.html'
-    descriptors = {}
-    try:
-        if descriptor_type == 'nsd':
-            descriptors = client.nsd_list(user.get_token())
-        elif descriptor_type == 'vnfd':
-            descriptors = client.vnfd_list(user.get_token())
-    except Exception as e:
-        log.exception(e)
-
-    return __response_handler(request, {
-        'descriptors': descriptors['data'] if descriptors and descriptors['error'] is False else [],
-        'project_id': project_id,
-        'project_type': 'osm',
-        'descriptor_type': descriptor_type,
-        'alert_message': {
-            'success': False if result['error'] is True else True,
-            'message': 'An error occurred while processing your request.' if result and result['error'] is True else "Record deleted successfully"}
-    }, url)
-
-
-@login_required
-def clone_descriptor(request, descriptor_type=None, descriptor_id=None):
-    user = osmutils.get_user(request)
-    project_id = user.project_id
-
-    try:
-        client = Client()
-        if descriptor_type == 'nsd':
-            result = client.nsd_clone(user.get_token(), descriptor_id)
-        elif descriptor_type == 'vnfd':
-            result = client.vnfd_clone(user.get_token(), descriptor_id)
-        else:
-            log.debug('Update descriptor: Unknown data type')
-            result = {'error': True, 'data': 'Update descriptor: Unknown data type'}
-    except Exception as e:
-        log.exception(e)
-        result = {'error': True, 'data': str(e)}
-    if result['error'] == True:
-        return __response_handler(request, result['data'], url=None,
-                                  status=result['data']['status'] if 'status' in result['data'] else 500)
-
-    else:
-        return __response_handler(request, {}, url=None, status=200)
-
-
-
-@login_required
-def new_descriptor(request, descriptor_type=None):
-    user = osmutils.get_user(request)
-    project_id = user.project_id
-    page = 'osm/descriptor/descriptor_new.html'
-    if request.method == 'GET':
-        request_id = request.GET.get('id', '')
-
-        return __response_handler(request,  {
-            'project_id': project_id,
-            'descriptor_type': descriptor_type,
-            'descriptor_id': request_id,
-        }, page)
-    elif request.method == 'POST':
-        data_type = request.POST.get('type')
-        if data_type == "file":
-            file_uploaded = request.FILES['file']
-
-            try:
-                client = Client()
-                if descriptor_type == 'nsd':
-                    result = client.nsd_onboard(user.get_token(), file_uploaded)
-                elif descriptor_type == 'vnfd':
-                    result = client.vnfd_onboard(user.get_token(), file_uploaded)
-                else:
-                    log.debug('Create descriptor: Unknown data type')
-                    result = {'error': True, 'data': 'Create descriptor: Unknown data type'}
-
-            except Exception as e:
-                log.exception(e)
-                result = {'error': True, 'data': str(e)}
-        else:
-            result = {'error': True, 'data': 'Create descriptor: Unknown data type'}
-
-        if result['error']:
-            return __response_handler(request, result['data'], url=None, status=result['data']['status'] if 'status' in result['data'] else 500)
-        else:
-            return __response_handler(request, {}, url=None, status=200)
-
-
-@login_required
-def edit_descriptor(request, descriptor_id=None, descriptor_type=None):
-    user = osmutils.get_user(request)
-    project_id = user.project_id
-    if request.method == 'POST':
-        new_data = request.POST.get('text'),
-        data_type = request.POST.get('type')
-        #print new_data
-        try:
-            client = Client()
-            if descriptor_type == 'nsd':
-                if data_type == 'yaml':
-                    new_data = yaml.load(request.POST.get('text'))
-                elif data_type == 'json':
-                    new_data = json.loads(request.POST.get('text'))
-                result = client.nsd_update(user.get_token(), descriptor_id, new_data)
-            elif descriptor_type == 'vnfd':
-                if data_type == 'yaml':
-                    new_data = yaml.load(request.POST.get('text'))
-                elif data_type == 'json':
-                    new_data = json.loads(request.POST.get('text'))
-                result = client.vnfd_update(user.get_token(), descriptor_id, new_data)
-
-            else:
-                log.debug('Update descriptor: Unknown data type')
-                result = {'error': True, 'data': 'Update descriptor: Unknown data type'}
-        except Exception as e:
-            log.exception(e)
-            result = {'error': True, 'data': str(e)}
-        if result['error'] == True:
-            return __response_handler(request, result['data'], url=None, status=result['data']['status'] if 'status' in result['data'] else 500)
-
-        else:
-            return __response_handler(request, {}, url=None, status=200)
-
-    elif request.method == 'GET':
 
-        page = 'osm/descriptor/descriptor_view.html'
-        try:
-            client = Client()
-            if descriptor_type == 'nsd':
-                result = client.nsd_get(user.get_token(), descriptor_id)
-            elif descriptor_type == 'vnfd':
-                result = client.vnfd_get(user.get_token(), descriptor_id)
-
-        except Exception as e:
-            log.exception(e)
-            result = {'error': True, 'data': str(e)}
-
-        if isinstance(result, dict) and 'error' in result and result['error']:
-            return render(request, 'error.html')
-
-        descriptor_string_json = json.dumps(result, indent=2)
-        descriptor_string_yaml = Util.json2yaml(result)
-        # print descriptor
-        return render(request, page, {
-            'project_id': project_id,
-            'descriptor_id': descriptor_id,
-            'descriptor_type': descriptor_type,
-            'descriptor_strings': {'descriptor_string_yaml': descriptor_string_yaml,
-                                   'descriptor_string_json': descriptor_string_json}})
-
-
-@login_required
-def get_package_files_list(request, descriptor_id, descriptor_type):
-    user = osmutils.get_user(request)
-    try:
-        client = Client()
-        if descriptor_type == 'nsd':
-            artifacts_res = client.nsd_artifacts(user.get_token(), descriptor_id)
-        elif descriptor_type == 'vnfd':
-            artifacts_res = client.vnf_packages_artifacts(user.get_token(), descriptor_id)
-        else:
-            return False
-
-        files_list = yaml.load(artifacts_res['data'] if artifacts_res and artifacts_res['error'] is False else [])
-        result = {'files': files_list}
-    except Exception as e:
-        log.exception(e)
-        url = 'error.html'
-        result = {'error_msg': 'Unknown error.'}
-    return __response_handler(request, result)
-
-@login_required
-def download_pkg(request, descriptor_id, descriptor_type):
-    user = osmutils.get_user(request)
-    file_name = "osm_export.tar.gz"
-    tar_pkg = None
-    try:
-        client = Client()
-        if descriptor_type == 'nsd':
-            tar_pkg = client.get_nsd_pkg(user.get_token(), descriptor_id)
-        elif descriptor_type == 'vnfd':
-            tar_pkg = client.get_vnfd_pkg(user.get_token(), descriptor_id)
-
-    except Exception as e:
-        log.exception(e)
-
-    response = HttpResponse(content_type="application/tgz")
-    response["Content-Disposition"] = "attachment; filename="+ file_name
-    response.write(tar_pkg.getvalue())
-    return response
-
-
-@login_required
-def custom_action(request, descriptor_id=None, descriptor_type=None, action_name=None):
-    if request.method == 'GET':
-        return globals()[action_name](request, descriptor_id, descriptor_type)
 
 
 def __response_handler(request, data_res, url=None, to_redirect=None, *args, **kwargs):
diff --git a/sdnctrlhandler/admin.py b/sdnctrlhandler/admin.py
deleted file mode 100644 (file)
index 8c38f3f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.contrib import admin
-
-# Register your models here.
index 588547f..e81839d 100644 (file)
@@ -1,3 +1,19 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
 from __future__ import unicode_literals
 
 from django.apps import AppConfig
index bd4b2ab..ed2a5ae 100644 (file)
@@ -1,3 +1,19 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
 from __future__ import unicode_literals
 
 from django.db import models
diff --git a/sdnctrlhandler/tests.py b/sdnctrlhandler/tests.py
deleted file mode 100644 (file)
index 7ce503c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.test import TestCase
-
-# Create your tests here.
index d554515..cd48f12 100644 (file)
@@ -1,3 +1,19 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
 from django.conf import settings  # import the settings file
 
 
index 753537a..2b22ac1 100644 (file)
@@ -1,14 +1,18 @@
-"""
-Django settings for sf_t3d project.
-
-Generated by 'django-admin startproject' using Django 1.9.
-
-For more information on this file, see
-https://docs.djangoproject.com/en/1.9/topics/settings/
-
-For the full list of settings and their values, see
-https://docs.djangoproject.com/en/1.9/ref/settings/
-"""
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
 
 import os
 
@@ -49,6 +53,7 @@ INSTALLED_APPS = [
     'django.contrib.sessions',
     'authosm',
     'projecthandler',
+    'descriptorhandler',
     'vimhandler',
     'instancehandler',
     'sdnctrlhandler',
@@ -85,6 +90,7 @@ TEMPLATES = [
             os.path.join(BASE_DIR, 'projecthandler', 'template'),
             os.path.join(BASE_DIR, 'projecthandler', 'template', 'download'),
             os.path.join(BASE_DIR, 'projecthandler', 'template', 'project'),
+            os.path.join(BASE_DIR, 'descriptorhandler', 'template'),
             os.path.join(BASE_DIR, 'vimhandler', 'template'),
             os.path.join(BASE_DIR, 'instancehandler', 'template'),
             os.path.join(BASE_DIR, 'sdnctrlhandler', 'template'),
index ea95716..5d9d02a 100644 (file)
@@ -1,21 +1,20 @@
-"""sf_t3d URL Configuration
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
 
-The `urlpatterns` list routes URLs to views. For more information please see:
-    https://docs.djangoproject.com/en/1.9/topics/http/urls/
-Examples:
-Function views
-    1. Add an import:  from my_app import views
-    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
-Class-based views
-    1. Add an import:  from other_app.views import Home
-    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
-Including another URLconf
-    1. Add an import:  from blog import urls as blog_urls
-    2. Import the include() function: from django.conf.urls import url, include
-    3. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
-"""
 from django.conf.urls import url, include
-#from sf_user import views as user_views
 from authosm import views as user_views
 from sf_t3d import views
 
index 547f20a..ecd807f 100644 (file)
@@ -1,10 +1,22 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
 from django.shortcuts import render, redirect
 from django.contrib.auth.decorators import login_required
 
-from projecthandler.models import Project
-from authosm.models import OsmUser
-
-
 @login_required
 def home(request):
     return redirect('projects:open_project')
index c52ee6f..5692ef7 100644 (file)
@@ -1,3 +1,19 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
 """
 WSGI config for sf_t3d project.
 
index ac19770..818620e 100644 (file)
@@ -92,6 +92,7 @@
     position: relative;
     min-height: 100vh;
     border-right: 1px solid #AFAFAF;
+    border-left: 1px solid #AFAFAF;
     flex: 1 1 auto;
     display: flex;
     align-items: center;
     margin-right: 10px;
 }
 
+#leftside {
+    flex: 0 0 auto;
+    max-width: 500px;
+    min-width: 300px;
+    padding: 20px 30px;
+    display: flex;
+    flex-direction: column;
+}
+
 #side {
     flex: 0 0 auto;
     max-width: 500px;
diff --git a/userhandler/admin.py b/userhandler/admin.py
deleted file mode 100644 (file)
index 8c38f3f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.contrib import admin
-
-# Register your models here.
index 45574cc..25b23e8 100644 (file)
@@ -1,3 +1,19 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
 from __future__ import unicode_literals
 
 from django.apps import AppConfig
diff --git a/userhandler/tests.py b/userhandler/tests.py
deleted file mode 100644 (file)
index 7ce503c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.test import TestCase
-
-# Create your tests here.
index a7c014d..47e4302 100644 (file)
@@ -1,3 +1,19 @@
+#
+#   Copyright 2018 EveryUP Srl
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an  BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+
 from django.shortcuts import render, redirect
 from sf_t3d.decorators import login_required
 from django.http import HttpResponse