Softlayer对象存储错误的搜索结果

时间:2016-05-24 17:13:45

标签: python ibm-cloud-infrastructure

Softlayer Object Storage Python API Search

我基本上的代码与上面问题中的答案相同。 zip_prefix是“restapi-qa.zip。”

def get_cld_api_versions():
    # get next version from obj storage
    sl_storage = object_storage.get_client(
        username = environment['slos_username'],
        password = environment['api_key'],
        auth_url = environment['auth_url']
    )

    # get list, the search function doesn't actually work...
    containers = sl_storage.search(directories.local_cloudrestapi_prod["zip_prefix"])
    print directories.local_cloudrestapi_prod["zip_prefix"]
    apiversions = []
    for cont in containers['results']:
        print cont
        if cont.__dict__['name'].startswith(directories.local_cloudrestapi_prod["zip_prefix"]):
            apiversions.append(cont.name)

    return apiversions

以下是我得到的结果 - 它有重复且缺少icm10restapi_prod.zip

StorageObject(testyi, restapi-qa.zip, 0B)
StorageObject(testyi, restapi-qa.zip.28, 0B)
StorageObject(testyi, restapi-na1.zip, 0B)
StorageObject(testyi, restapi-qa.zip.23, 0B)
StorageObject(testyi, restapi-qa.zip.25, 0B)
StorageObject(testyi, restapi-qa.zip.29, 0B)
StorageObject(testyi, restapi-qa.zip.30, 0B)
StorageObject(testyi, restapi-qa.zip.22, 0B)
StorageObject(testyi, restapi-qa.zip.26, 0B)
StorageObject(testyi, restapi-qa.zip.27, 0B)
StorageObject(testyi, restapi-qa.zip.26, 0B)
StorageObject(testyi, restapi-qa.zip.27, 0B)
StorageObject(testyi, restapi-qa.zip.31, 0B)
StorageObject(testyi, restapi-qa.zip.12, 0B)
StorageObject(testyi, testapi-qa.zip.32, 0B)

有时我得到这些结果 - 缺少.26和.27

StorageObject(testyi, restapi-qa.zip, 0B)
StorageObject(testyi, restapi-qa.zip.28, 0B)
StorageObject(testyi, restapi-na1.zip, 0B)
StorageObject(testyi, restapi-qa.zip.23, 0B)
StorageObject(testyi, restapi-qa.zip.25, 0B)
StorageObject(testyi, restapi-qa.zip.29, 0B)
StorageObject(testyi, restapi-prod.zip, 0B)
StorageObject(testyi, restapi.zip, 0B)
StorageObject(testyi, restapi-qa.zip.30, 0B)
StorageObject(testyi, restapi-qa.zip.22, 0B)
StorageObject(testyi, restapi-qa.zip.31, 0B)
StorageObject(testyi, restapi-prod.zip, 0B)
StorageObject(testyi, restapi.zip, 0B)
StorageObject(testyi, restapi-qa.zip.12, 0B)
StorageObject(testyi, restapi-qa.zip.32, 0B)

这是预期的:

enter image description here

我有其他文件丢失,有时候,但为了简洁,我只粘贴了上述部分。

1 个答案:

答案 0 :(得分:0)

我尝试重现您的问题,但我无法查看以下快照:

enter image description here

我能够过滤以字符串" icm10restapi-qa.zip开头的对象。"