From 9b5d7f9b3e7e13cd18370c84b1f78907cb89bf92 Mon Sep 17 00:00:00 2001 From: tierno Date: Wed, 14 Mar 2018 15:18:20 +0100 Subject: [PATCH] Feature 5650. Allow set VM interface ip-address Change-Id: I375ab8464a77c626f9badff29f6b2734c22d807c Signed-off-by: tierno --- osm_openvim/ovim.py | 4 ++-- osm_openvim/vim_db.py | 12 +++++++++--- osm_openvim/vim_schema.py | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/osm_openvim/ovim.py b/osm_openvim/ovim.py index 942855c..78c5c5e 100755 --- a/osm_openvim/ovim.py +++ b/osm_openvim/ovim.py @@ -43,8 +43,8 @@ import openflow_conn __author__ = "Alfonso Tierno, Leonardo Mirabal" __date__ = "$06-Feb-2017 12:07:15$" -__version__ = "0.5.23-r539" -version_date = "Jan 2018" +__version__ = "0.5.24-r540" +version_date = "Mar 2018" database_version = 22 #needed database schema version HTTP_Bad_Request = 400 diff --git a/osm_openvim/vim_db.py b/osm_openvim/vim_db.py index 355bbac..ec29943 100644 --- a/osm_openvim/vim_db.py +++ b/osm_openvim/vim_db.py @@ -136,8 +136,10 @@ class vim_db(): self.logger.error("%s DB Exception %s. Command %s",func, str(e), cmd) if type(e[0]) is str: - if e[0][-5:] == "'con'": return -HTTP_Internal_Server_Error, "DB Exception, no connection." - else: raise + if e[0][-5:] == "'con'": + return -HTTP_Internal_Server_Error, "DB Exception, no connection." + else: + return -HTTP_Internal_Server_Error, e.args[1] if e.args[0]==2006 or e.args[0]==2013 : #MySQL server has gone away (((or))) Exception 2013: Lost connection to MySQL server during query #reconnect self.connect() @@ -1426,7 +1428,11 @@ class vim_db(): del iface["cidr"] del iface["enable_dhcp"] used_dhcp_ips = self._get_dhcp_ip_used_list(iface["net_id"]) - iface["ip_address"] = self.get_free_ip_from_range(dhcp_first_ip, dhcp_last_ip, + if iface.get("ip_address"): + if iface["ip_address"] in used_dhcp_ips: + iface["ip_address"] = None + else: + iface["ip_address"] = self.get_free_ip_from_range(dhcp_first_ip, dhcp_last_ip, dhcp_cidr, used_dhcp_ips) if 'links' in iface: del iface['links'] diff --git a/osm_openvim/vim_schema.py b/osm_openvim/vim_schema.py index 697b4e9..b7629f5 100644 --- a/osm_openvim/vim_schema.py +++ b/osm_openvim/vim_schema.py @@ -520,6 +520,7 @@ networks_schema={ "vpci":pci_schema, "uuid":id_schema, "mac_address": mac_schema, + "ip_address": ip_schema, "model": {"type":"string", "enum":["virtio","e1000","ne2k_pci","pcnet","rtl8139"]}, "type": {"type":"string", "enum":["virtual","PF","VF","VFnotShared"]} }, -- 2.25.1