def prepareBlockMigrationList(self, conn, request):
        """
        Prepare the ordered lists of blocks based on input BLOCK
            1. see if block already exists at dst (no need to migrate),
               raise "ALREADY EXISTS"
            2. see if block exists at src & make sure the block's open_for_writing=0
            3. see if block has parents
            4. see if parent blocks are already at dst
            5. add 'order' to parent and then this block (ascending)
            6. return the ordered list
        """
        ordered_dict = {}
        block_name = request["migration_input"]
        url = request["migration_url"]
        order_counter = 0
        try:
            #1.
            dstblock = self.blocklist.execute(conn, block_name=block_name)
	    for item in dstblock:
		if item:
		    dbsExceptionHandler('dbsException-invalid-input', 'ALREADY EXISTS: \
			Required block (%s) migration is already at destination' %block_name, self.logger.exception)
            #2.
            srcblock = self.getSrcBlocks(url, block=block_name)
            if len(srcblock) < 1:
                e = 'DBSMigration: Invalid input. Required Block %s not found at source %s.' %(block_name, url)
                dbsExceptionHandler('dbsException-invalid-input2', e, self.logger.exception, e)
            ##This block has to be migrated
            ordered_dict[order_counter] = []
            ordered_dict[order_counter].append(block_name)
            parent_ordered_dict = self.getParentBlocksOrderedList(url, conn,
                                                block_name, order_counter+1)
            if parent_ordered_dict != {}:
                ordered_dict.update(parent_ordered_dict)
            #6.
            #check for duplicates

            return remove_duplicated_items(ordered_dict)
        except Exception as ex:
	    if '500 Internal Server Error' in str(ex):	
		#"Server Error" is the default in dbsExceptionHandler
	        dbsExceptionHandler('Server Error', str(ex), self.logger.exception, "DBSMigrate/prepareBlockMigrationList: "+str(ex))
	    if isinstance(ex, pycurl.error):
		if ex.args[0] == 7:
		    message = ex.args[1]
		    dbsExceptionHandler('dbsException-failed-connect2host', message, self.logger.exception, message)	
	    if 'urlopen error' in str(ex):
                message='Connection to source DBS server refused. Check your source url.'
            elif 'Bad Request' in str(ex):
                message='cannot get data from the source DBS server. Check your migration input.'
            else:
                message='Failed to make a block migration list.'
            dbsExceptionHandler('dbsException-invalid-input2', \
                """DBSMigrate/prepareBlockMigrationList failed
                to prepare ordered block list: %s""" %str(ex), self.logger.exception, message)