From 2b2ada1780af0eb7853c17b84edbd817c5c07957 Mon Sep 17 00:00:00 2001 From: micafer Date: Fri, 27 Jan 2017 09:07:31 +0100 Subject: [PATCH 1/7] Bugfix in get_inf_ids --- IM/InfrastructureList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IM/InfrastructureList.py b/IM/InfrastructureList.py index 12b68a7c7..75ff2075b 100644 --- a/IM/InfrastructureList.py +++ b/IM/InfrastructureList.py @@ -61,7 +61,7 @@ def remove_inf(del_inf): @staticmethod def get_inf_ids(): """ Get the IDs of the Infrastructures """ - return InfrastructureList._get_data_from_db(Config.DATA_DB) + return InfrastructureList._get_inf_ids_from_db(Config.DATA_DB) @staticmethod def get_infrastructure(inf_id): From a5d002952eaa03e8aec13c7098b23c3634dbeb9a Mon Sep 17 00:00:00 2001 From: micafer Date: Fri, 27 Jan 2017 09:28:47 +0100 Subject: [PATCH 2/7] Bugfix in get_inf_ids --- IM/InfrastructureList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IM/InfrastructureList.py b/IM/InfrastructureList.py index 75ff2075b..c20ced507 100644 --- a/IM/InfrastructureList.py +++ b/IM/InfrastructureList.py @@ -61,7 +61,7 @@ def remove_inf(del_inf): @staticmethod def get_inf_ids(): """ Get the IDs of the Infrastructures """ - return InfrastructureList._get_inf_ids_from_db(Config.DATA_DB) + return InfrastructureList._get_inf_ids_from_db() @staticmethod def get_infrastructure(inf_id): From b61de2607dfe64f6bfc325453d9201e7ce87122d Mon Sep 17 00:00:00 2001 From: micafer Date: Fri, 27 Jan 2017 09:52:36 +0100 Subject: [PATCH 3/7] Do not load all data --- im_service.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/im_service.py b/im_service.py index 699539421..782fe4ea6 100755 --- a/im_service.py +++ b/im_service.py @@ -195,8 +195,6 @@ def launch_daemon(): """ Launch the IM daemon """ - InfrastructureList.load_data() - if Config.XMLRCP_SSL: # if specified launch the secure version import ssl From bddd18d4a0be94c6f7c9745a1abebc386d472097 Mon Sep 17 00:00:00 2001 From: micafer Date: Fri, 27 Jan 2017 09:53:30 +0100 Subject: [PATCH 4/7] Add . and .. to sys path --- scripts/db_1_4_to_1_5.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/db_1_4_to_1_5.py b/scripts/db_1_4_to_1_5.py index 1e0d5cd74..cc115b51d 100644 --- a/scripts/db_1_4_to_1_5.py +++ b/scripts/db_1_4_to_1_5.py @@ -14,10 +14,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import sys + +sys.path.append("..") +sys.path.append(".") + from IM.config import Config from IM.db import DataBase import cPickle as pickle -import sys import time import threading From ec2bfdb649577464d3eaac3543ddb82b250cc5c4 Mon Sep 17 00:00:00 2001 From: micafer Date: Fri, 27 Jan 2017 10:02:08 +0100 Subject: [PATCH 5/7] Fix in table_exist --- IM/db.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/IM/db.py b/IM/db.py index abcb01b15..983932434 100644 --- a/IM/db.py +++ b/IM/db.py @@ -208,8 +208,10 @@ def table_exists(self, table_name): res = self.select( 'select name from sqlite_master where type="table" and name="' + table_name + '"') elif self.db_type == "MySQL": - res = self.select( - 'SELECT * FROM information_schema.tables WHERE table_name ="' + table_name + '"') + uri = uriparse(self.db_url) + db = uri[2][1:] + res = self.select('SELECT * FROM information_schema.tables WHERE table_name ="' + + table_name + '" and table_schema = "' + db + '"') else: return False From 71d4fe0ad98a525ab813d41fb7255c9271d7c1a4 Mon Sep 17 00:00:00 2001 From: micafer Date: Fri, 27 Jan 2017 10:59:13 +0100 Subject: [PATCH 6/7] Init DB correctly --- IM/InfrastructureList.py | 26 +++++++++++++++++++------- im_service.py | 2 ++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/IM/InfrastructureList.py b/IM/InfrastructureList.py index c20ced507..31b21b2ca 100644 --- a/IM/InfrastructureList.py +++ b/IM/InfrastructureList.py @@ -119,15 +119,27 @@ def save_data(inf_id=None): sys.stderr.write("ERROR saving data: " + str(ex) + ".\nChanges not stored!!") @staticmethod - def _get_data_from_db(db_url, inf_id=None): - db = DataBase(db_url) + def init_table(): + """ Creates de database """ + db = DataBase(Config.DATA_DB) if db.connect(): if not db.table_exists("inf_list"): db.execute("CREATE TABLE inf_list(id VARCHAR(255) PRIMARY KEY, deleted INTEGER," " date TIMESTAMP, data LONGBLOB)") db.close() - return {} - else: + return True + else: + InfrastructureList.logger.error("ERROR connecting with the database!.") + + return False + + @staticmethod + def _get_data_from_db(db_url, inf_id=None): + if InfrastructureList.init_table(): + return {} + else: + db = DataBase(db_url) + if db.connect(): inf_list = {} if inf_id: res = db.select("select * from inf_list where id = '%s'" % inf_id) @@ -149,9 +161,9 @@ def _get_data_from_db(db_url, inf_id=None): db.close() return inf_list - else: - InfrastructureList.logger.error("ERROR connecting with the database!.") - return {} + else: + InfrastructureList.logger.error("ERROR connecting with the database!.") + return {} @staticmethod def _save_data_to_db(db_url, inf_list, inf_id=None): diff --git a/im_service.py b/im_service.py index 782fe4ea6..cb3d00564 100755 --- a/im_service.py +++ b/im_service.py @@ -195,6 +195,8 @@ def launch_daemon(): """ Launch the IM daemon """ + InfrastructureList.init_table() + if Config.XMLRCP_SSL: # if specified launch the secure version import ssl From 0995993dac405489b9fb3f6b1688a7f03dc47b1d Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Fri, 27 Jan 2017 12:58:47 +0100 Subject: [PATCH 7/7] Enable set net provider_id in private nets --- IM/tosca/Tosca.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/IM/tosca/Tosca.py b/IM/tosca/Tosca.py index 708f7ba9f..19f16673b 100644 --- a/IM/tosca/Tosca.py +++ b/IM/tosca/Tosca.py @@ -235,6 +235,9 @@ def _add_node_nets(node, radl, system, nodetemplates): public_ip = True parts = cap_props["network_name"].value.split(".") net_provider_id = ".".join(parts[:-1]) + elif str(cap_props["network_name"].value).endswith(".PRIVATE"): + parts = cap_props["network_name"].value.split(".") + net_provider_id = ".".join(parts[:-1]) if cap_props and "dns_name" in cap_props: dns_name = cap_props["dns_name"].value if cap_props and "ports" in cap_props: