From fbd4aef3c700d37b5e184b31e09c1a99e6e43df3 Mon Sep 17 00:00:00 2001 From: lombardofr Date: Sat, 6 Oct 2018 14:11:43 +0200 Subject: [PATCH] Bug 541 Change-Id: If796e824032128ef3e745bb9232799a632542ba2 Signed-off-by: lombardofr --- lib/osm/osm_parser.py | 89 ------------------- lib/osm/osm_rdcl_graph.py | 51 ----------- lib/{parser.py => osm/osm_rdcl_parser.py} | 26 ++---- .../project/osm/osm_project_descriptors.html | 22 +++-- static/src/projecthandler/onboard_package.js | 11 ++- 5 files changed, 28 insertions(+), 171 deletions(-) delete mode 100644 lib/osm/osm_parser.py delete mode 100644 lib/osm/osm_rdcl_graph.py rename lib/{parser.py => osm/osm_rdcl_parser.py} (58%) diff --git a/lib/osm/osm_parser.py b/lib/osm/osm_parser.py deleted file mode 100644 index a596405..0000000 --- a/lib/osm/osm_parser.py +++ /dev/null @@ -1,89 +0,0 @@ -# -# Copyright 2017 CNIT - Consorzio Nazionale Interuniversitario per le Telecomunicazioni -# -# 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 pyaml -import yaml -from lib.util import Util -from lib.parser import Parser -import logging -import traceback -import glob -import os - -logging.basicConfig(level=logging.DEBUG) -log = logging.getLogger('OsmParser') - -class OsmParser(Parser): - """Parser methods for osm project type - - """ - - def __init__(self): - super(OsmParser, self).__init__() - - @classmethod - def importprojectdir(cls,dir_project, file_type): - """Imports all descriptor files under a given folder - - this method is specific for Osm project type - """ - - project = { - 'nsd':{}, - - 'vnfd':{}, - - 'positions': {} - } - - - for desc_type in project: - cur_type_path = os.path.join(dir_project, desc_type.upper()) - log.debug(cur_type_path) - if os.path.isdir(cur_type_path): - for file in glob.glob(os.path.join(cur_type_path, '*.'+file_type)): - if file_type == 'json': - project[desc_type][os.path.basename(file).split('.')[0]] = Util.loadjsonfile(file) - elif file_type == 'yaml': - project[desc_type][os.path.basename(file).split('.')[0]] = Util.loadyamlfile(file) - - - for vertices_file in glob.glob(os.path.join(dir_project, '*.json')): - if os.path.basename(vertices_file) == 'vertices.json': - project['positions']['vertices'] = Util.loadjsonfile(vertices_file) - - return project - - @classmethod - def importprojectfiles(cls, file_dict): - """Imports descriptors (extracted from the new project POST) - - The keys in the dictionary are the file types - """ - project = { - 'nsd':{}, - - 'vnfd':{}, - - } - for desc_type in project: - if desc_type in file_dict: - files_desc_type = file_dict[desc_type] - for file in files_desc_type: - project[desc_type][os.path.splitext(file.name)[0]] = json.loads(file.read()) - - return project \ No newline at end of file diff --git a/lib/osm/osm_rdcl_graph.py b/lib/osm/osm_rdcl_graph.py deleted file mode 100644 index 91b798f..0000000 --- a/lib/osm/osm_rdcl_graph.py +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright 2017 CNIT - Consorzio Nazionale Interuniversitario per le Telecomunicazioni -# -# 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 copy -from lib.rdcl_graph import RdclGraph - -logging.basicConfig(level=logging.DEBUG) -log = logging.getLogger('OsmRdclGraph') - -class OsmRdclGraph(RdclGraph): - """Operates on the graph representation used for the GUI graph views""" - - def __init__(self): - pass - - - def build_graph_from_project(self, json_project, model={}): - """Creates a single graph for a whole project""" - - #print "json_project ",json_project - graph_object = { - 'vertices': [], - 'edges': [], - 'graph_parameters': {}, - 'model': model - } - try: - positions = json_project['positions'] if 'positions' in json_project else False - log.debug('build graph from project json') - - - except Exception as e: - log.exception('Exception in build_graph_from_project') - raise - - return graph_object diff --git a/lib/parser.py b/lib/osm/osm_rdcl_parser.py similarity index 58% rename from lib/parser.py rename to lib/osm/osm_rdcl_parser.py index 1b764d2..e9fbecd 100644 --- a/lib/parser.py +++ b/lib/osm/osm_rdcl_parser.py @@ -1,5 +1,5 @@ # -# Copyright 2017 CNIT - Consorzio Nazionale Interuniversitario per le Telecomunicazioni +# 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. @@ -18,29 +18,17 @@ import json import pyaml import yaml from lib.util import Util +from lib.parser import Parser import logging import traceback import glob import os +logging.basicConfig(level=logging.DEBUG) +log = logging.getLogger('OsmParser') -class Parser(object): - """Parser methods base class - """ - - def __init__(self): - pass - - @classmethod - def importprojectdir(cls,dir_project, type): - """Imports all files under a given folder - - Returns an empty project - """ +class OsmParser(Parser): + """Parser methods for osm project type - project = {} - return project - - def get_all_ns_descriptors(self, nsd_id, project_data): - raise NotImplementedError \ No newline at end of file + """ diff --git a/projecthandler/template/project/osm/osm_project_descriptors.html b/projecthandler/template/project/osm/osm_project_descriptors.html index 4478ade..877e7f2 100644 --- a/projecthandler/template/project/osm/osm_project_descriptors.html +++ b/projecthandler/template/project/osm/osm_project_descriptors.html @@ -45,6 +45,11 @@ {% block resource_block %} {{ block.super }} + + + + + - - - - + {% endblock %} diff --git a/static/src/projecthandler/onboard_package.js b/static/src/projecthandler/onboard_package.js index 3d519a6..c622cad 100644 --- a/static/src/projecthandler/onboard_package.js +++ b/static/src/projecthandler/onboard_package.js @@ -52,6 +52,10 @@ function create(fs, dropzone) { data.append('text', text); data.append('id', '{{descriptor_id}}'); console.log(text); + var dialog = bootbox.dialog({ + message: '
Onboarding...
', + closeButton: true + }); $.ajax({ url: new_desc_url, type: 'POST', @@ -60,12 +64,11 @@ function create(fs, dropzone) { contentType: false, processData: false, success: function (result) { - console.log(result); - - window.location.href = descr_list_url - + dialog.modal('hide'); + refreshTable(); }, error: function (result) { + dialog.modal('hide'); showAlert(result); } }); -- 2.25.1