#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 :
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)
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() ) )
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
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):