X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_openvim%2Fvim_db.py;h=abeb0fdd422e754f73b1ca2a9b72d923fe850231;hb=50557c2e90ad65d8d9459063bd83d5e0b2e02f37;hp=ec299432be2f7592613830ae2265f15aa2a26c36;hpb=9b5d7f9b3e7e13cd18370c84b1f78907cb89bf92;p=osm%2Fopenvim.git diff --git a/osm_openvim/vim_db.py b/osm_openvim/vim_db.py index ec29943..abeb0fd 100644 --- a/osm_openvim/vim_db.py +++ b/osm_openvim/vim_db.py @@ -248,6 +248,13 @@ class vim_db(): w = sql_dict.get('WHERE') if w: where_and = " AND ".join(map( lambda x: str(x) + (" is Null" if w[x] is None else "='"+str(w[x])+"'"), w.keys()) ) + w = sql_dict.get('WHERE_LIKE') #Unikernels extension -START- + if w: + where_and_like = " AND ".join(map( lambda x: str(x) + (" is Null" if w[x] is None else " LIKE '"+str(w[x])+"'"), w.keys()) ) + if where_and: + where_and += " AND " + where_and_like + else: + where_and = where_and_like #Unikernels extension -END- w = sql_dict.get('WHERE_NOT') if w: where_and_not = " AND ".join(map( lambda x: str(x) + (" is not Null" if w[x] is None else "!='"+str(w[x])+"'"), w.keys()) ) @@ -474,9 +481,9 @@ class vim_db(): with self.con: self.cur = self.con.cursor(mdb.cursors.DictCursor) #get HOST - cmd = "SELECT uuid, user, password, keyfile, name, ip_name, description, ranking, admin_state_up, "\ + cmd = "SELECT uuid, user, password, keyfile, name, ip_name, description, hypervisors, ranking, admin_state_up, "\ "DATE_FORMAT(created_at,'%Y-%m-%dT%H:%i:%s') as created_at "\ - "FROM hosts WHERE " + where_filter + "FROM hosts WHERE " + where_filter #Unikernels extension self.logger.debug(cmd) self.cur.execute(cmd) if self.cur.rowcount == 0: @@ -1054,8 +1061,8 @@ class vim_db(): with self.con: self.cur = self.con.cursor(mdb.cursors.DictCursor) #get INSTANCE - cmd = "SELECT uuid, name, description, progress, host_id, flavor_id, image_id, status, last_error, "\ - "tenant_id, ram, vcpus, created_at FROM instances WHERE uuid='{}'".format(instance_id) + cmd = "SELECT uuid, name, description, progress, host_id, flavor_id, image_id, status, hypervisor, os_image_type, last_error, "\ + "tenant_id, ram, vcpus, created_at FROM instances WHERE uuid='{}'".format(instance_id) #Unikernels extension self.logger.debug(cmd) self.cur.execute(cmd) if self.cur.rowcount == 0 : return 0, "instance '" + str(instance_id) +"'not found." @@ -1198,6 +1205,19 @@ class vim_db(): #self.logger.debug(error_text) return -1, error_text + if not 'hypervisor' in requirements: #Unikernels extension -END- + requirements['hypervisor'] = "kvm" + for valid_host in valid_hosts: + if not 'hypervisors' in valid_host: + valid_host['hypervisors'] = "kvm" + + valid_hosts = tuple(valid_host for valid_host in valid_hosts if requirements['hypervisor'] in valid_host['hypervisors'].split(",")) + + if len(valid_hosts)<=0: + error_text = 'No room at data center. Cannot find a host with %s hypervisor or not have enough resources available' % (str(requirements['hypervisor'])) + #self.logger.debug(error_text) + return -1, error_text #Unikernels extension -END- + #elif req_numa != None: #Find valid numa nodes for memory requirements self.cur = self.con.cursor(mdb.cursors.DictCursor)