X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_openvim%2Fvim_db.py;h=355bbaca2b02cafa419d64d30ededf37a2bab2ef;hb=refs%2Ftags%2Fv3.0.0rc2;hp=31d4a0f29b24703911cec21d8980b8d74c0e1f3f;hpb=a69330400c877adb0e5af22e2bf113941f808668;p=osm%2Fopenvim.git diff --git a/osm_openvim/vim_db.py b/osm_openvim/vim_db.py index 31d4a0f..355bbac 100644 --- a/osm_openvim/vim_db.py +++ b/osm_openvim/vim_db.py @@ -1070,7 +1070,7 @@ class vim_db(): #get extended extended = {} #get devices - cmd = "SELECT type, vpci, image_id, xml,dev FROM instance_devices WHERE instance_id = '%s' " % str(instance_id) + cmd = "SELECT type, vpci, image_id, xml, dev, image_size FROM instance_devices WHERE instance_id = '%s' " % str(instance_id) self.logger.debug(cmd) self.cur.execute(cmd) if self.cur.rowcount > 0 : @@ -1428,6 +1428,12 @@ class vim_db(): 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, dhcp_cidr, used_dhcp_ips) + if 'links' in iface: + del iface['links'] + if 'dns' in iface: + del iface['dns'] + if 'routes' in iface: + del iface['routes'] iface['uuid'] = str(myUuid.uuid1()) # create_uuid cmd = "INSERT INTO uuids (uuid, root_uuid, used_at) VALUES ('%s','%s', 'ports')" % (iface['uuid'], uuid) @@ -1443,6 +1449,7 @@ class vim_db(): else: iface['mac'] = iface['mac_address'] del iface['mac_address'] + #iface['mac']=iface.pop('mac_address', None) #for leaving mac generation to libvirt keys = ",".join(iface.keys()) values = ",".join( map(lambda x: "Null" if x is None else "'"+str(x)+"'", iface.values() ) ) @@ -1520,8 +1527,10 @@ class vim_db(): else: xml = 'Null' if 'dev' in device: dev = "'" + device['dev'] + "'" else: dev = 'Null' - cmd = "INSERT INTO instance_devices (type, instance_id, image_id, vpci, xml, dev) VALUES ('%s','%s', %s, %s, %s, %s)" % \ - (device['type'], uuid, image_id, vpci, xml, dev) + if 'image_size' in device: size = device['image_size'] + else: size = 0 + cmd = "INSERT INTO instance_devices (type, instance_id, image_id, vpci, xml, dev, image_size) VALUES ('%s','%s', %s, %s, %s, %s, %s)" % \ + (device['type'], uuid, image_id, vpci, xml, dev, str(size)) self.logger.debug(cmd) self.cur.execute(cmd) ##inserting new log @@ -1550,6 +1559,7 @@ class vim_db(): ip_used_list.append(str(ips[1])) # gw ip ip_used_list.append(str(ips[-1])) # broadcast ip + ip_used_list.append(first_ip) for vm_ip in ips: if str(vm_ip) not in ip_used_list and IPAddress(first_ip) <= IPAddress(vm_ip) <= IPAddress(last_ip):