def get_instance_scenario(self, instance_id, tenant_id=None, verbose=False): 
        for retry_ in range(0,2):
            try:
                with self.con:
                    self.cur = self.con.cursor(mdb.cursors.DictCursor)
                    #instance table
                    where_list=[]
                    if tenant_id is not None: where_list.append( "inst.tenant_id='" + tenant_id +"'" )
                    if af.check_valid_uuid(instance_id):
                        where_list.append( "inst.uuid='" + instance_id +"'" )
                    else:
                        where_list.append( "inst.name='" + instance_id +"'" )
                    where_text = " AND ".join(where_list)
                    command = "SELECT inst.uuid as uuid,inst.name as name,inst.scenario_id as scenario_id, datacenter_id" +\
                                " ,datacenter_tenant_id, s.name as scenario_name,inst.tenant_id as tenant_id" + \
                                " ,inst.description as description,inst.created_at as created_at" +\
                            " FROM instance_scenarios as inst join scenarios as s on inst.scenario_id=s.uuid"+\
                            " WHERE " + where_text
                    self.cur.execute(command)
                    rows = self.cur.fetchall()
                    if self.cur.rowcount==0:
                        return -HTTP_Bad_Request, "No instance found with this criteria " + where_text
                    elif self.cur.rowcount>1:
                        return -HTTP_Bad_Request, "More than one instance found with this criteria " + where_text
                    instance_dict = rows[0]
                    
                    #instance_vnfs
                    cmd = "SELECT iv.uuid as uuid,sv.vnf_id as vnf_id,sv.name as vnf_name, sce_vnf_id, datacenter_id, datacenter_tenant_id"\
                            " FROM instance_vnfs as iv join sce_vnfs as sv on iv.sce_vnf_id=sv.uuid" \
                            " WHERE iv.instance_scenario_id='%s'" \
                            " ORDER BY iv.created_at " % instance_dict['uuid']
                    self.cur.execute(cmd)
                    instance_dict['vnfs'] = self.cur.fetchall()
                    for vnf in instance_dict['vnfs']:
                        vnf_manage_iface_list=[]
                        #instance vms
                        cmd = "SELECT iv.uuid as uuid, vim_vm_id, status, error_msg, vim_info, iv.created_at as created_at, name "\
                                " FROM instance_vms as iv join vms on iv.vm_id=vms.uuid "\
                                " WHERE instance_vnf_id='%s' ORDER BY iv.created_at" % vnf['uuid']
                        self.cur.execute(cmd)
                        vnf['vms'] = self.cur.fetchall()
                        for vm in vnf['vms']:
                            vm_manage_iface_list=[]
                            #instance_interfaces
                            cmd = "SELECT vim_interface_id, instance_net_id, internal_name,external_name, mac_address, ip_address, vim_info, i.type as type "\
                                    " FROM instance_interfaces as ii join interfaces as i on ii.interface_id=i.uuid "\
                                    " WHERE instance_vm_id='%s' ORDER BY created_at" % vm['uuid']
                            self.cur.execute(cmd )
                            vm['interfaces'] = self.cur.fetchall()
                            for iface in vm['interfaces']:
                                if iface["type"] == "mgmt" and iface["ip_address"]:
                                    vnf_manage_iface_list.append(iface["ip_address"])
                                    vm_manage_iface_list.append(iface["ip_address"])
                                if not verbose:
                                    del iface["type"]
                            if vm_manage_iface_list: vm["ip_address"] = ",".join(vm_manage_iface_list)
                        if vnf_manage_iface_list: vnf["ip_address"] = ",".join(vnf_manage_iface_list)
                        
                    #instance_nets
                    #select_text = "instance_nets.uuid as uuid,sce_nets.name as net_name,instance_nets.vim_net_id as net_id,instance_nets.status as status,instance_nets.external as external" 
                    #from_text = "instance_nets join instance_scenarios on instance_nets.instance_scenario_id=instance_scenarios.uuid " + \
                    #            "join sce_nets on instance_scenarios.scenario_id=sce_nets.scenario_id"
                    #where_text = "instance_nets.instance_scenario_id='"+ instance_dict['uuid'] + "'"
                    cmd = "SELECT uuid,vim_net_id,status,error_msg,vim_info,external, sce_net_id, net_id as vnf_net_id, datacenter_id, datacenter_tenant_id"\
                            " FROM instance_nets" \
                            " WHERE instance_scenario_id='%s' ORDER BY created_at" % instance_dict['uuid']
                    self.cur.execute(cmd)
                    instance_dict['nets'] = self.cur.fetchall()
                    
                    af.convert_datetime2str(instance_dict)
                    af.convert_str2boolean(instance_dict, ('public','shared','external') )
                    return 1, instance_dict
            except (mdb.Error, AttributeError), e:
                print "nfvo_db.get_instance_scenario DB Exception %d: %s" % (e.args[0], e.args[1])
                r,c = self.format_error(e)
                if r!=-HTTP_Request_Timeout or retry_==1: return r,c
Obtain the instance information, filtering by one or several of the tenant, uuid or name
dataset/ETHPy150Open nfvlabs/openmano/openmano/nfvo_db.py/nfvo_db.get_instance_scenario