Example #1
0
def get_images(provider_id=None):
    code, resp = nfsapi.get_images_list()
    print resp
    if code is not 200:
        raise NFSImagesListError(resp)
    else:
        print 'Images successfully listed!'
        images_list = []
        for image in resp['files']:
            images_list.append(
                NFSImage(0, image['name'], 'v1', '', image['vnfd_id']))
        #retrieve docker images
        code2, docker_repos = nfsapi.get_docker_repositories(
            '/_catalog', 'registry:catalog:*')
        if code2 is not 200:
            print "ERROR"
            raise NFSImagesListError(docker_repos)
        else:
            print "repo list: ", docker_repos
            code3, docker_list = nfsapi.get_docker_images_list(
                '/tags/list', docker_repos)
            print "DOCKER_RESP: " + json.dumps(docker_list)
            for repo in docker_list:
                for tag in repo['tags'] or []:
                    images_list.append(
                        NFSImage(1000, repo['name'], tag,
                                 DOCKER_HOST + '/' + repo['name'] + ':' + tag,
                                 []))
            return images_list
Example #2
0
def get_images(provider_id=None):
    code, resp = nfsapi.get_images_list()
    print resp
    if code is not 200:
        raise NFSImagesListError
    else:
        print 'Images successfully listed!'
        images_list = []
        for image in resp['files']:
            #results = re.search('^(?P<provider_id>[0-9]+)-(?P<image_name>.*)$', image['name'], re.IGNORECASE)
            #results = image['name']
            #if results and (not provider_id or provider_id == int(results.group('provider_id'))):
                #images_list.append(NFSImage(int(results.group('provider_id')), results.group('image_name'), image['vnfd_id']))
            images_list.append(NFSImage(0, image['name'], image['vnfd_id']))
        return images_list
Example #3
0
def get_images(provider_id=None):
    code, resp = nfsapi.get_images_list()
    print resp
    if code is not 200:
        raise NFSImagesListError
    else:
        print 'Images successfully listed!'
        images_list = []
        for image in resp['files']:
            #results = re.search('^(?P<provider_id>[0-9]+)-(?P<image_name>.*)$', image['name'], re.IGNORECASE)
            #results = image['name']
            #if results and (not provider_id or provider_id == int(results.group('provider_id'))):
            #images_list.append(NFSImage(int(results.group('provider_id')), results.group('image_name'), image['vnfd_id']))
            images_list.append(NFSImage(0, image['name'], image['vnfd_id']))
        return images_list
Example #4
0
def get_image(nfs_image_name, provider_id=None):
    code, resp = nfsapi.get_images_list()
    if code is not 200:
        raise NFSImagesListError(resp)
    else:
        print 'Images successfully listed!'
        for image in resp['files']:
            results = re.search('^(?P<provider_id>[0-9]+)-(?P<image_name>.*)$',
                                image['name'], re.IGNORECASE)
            if results and (not provider_id or provider_id == int(
                    results.group('provider_id'))):
                img = NFSImage(int(results.group('provider_id')),
                               results.group('image_name'), 'v1', '',
                               image['vnfd_id'])
                if img.nfs_image_name == nfs_image_name:
                    return img
        raise NFSImagesNotFoundError('Image %s Not Found' % nfs_image_name)
Example #5
0
def get_image(nfs_image_name, provider_id=None):
    code, resp = nfsapi.get_images_list()
    if code is not 200:
        raise NFSImagesListError
    else:
        print 'Images successfully listed!'
        for image in resp['files']:
            results = re.search('^(?P<provider_id>[0-9]+)-(?P<image_name>.*)$',
                                image['name'], re.IGNORECASE)
            if results and (not provider_id or provider_id == int(
                    results.group('provider_id'))):
                img = NFSImage(int(results.group('provider_id')),
                               results.group('image_name'), image['vnfd_id'])
                if img.nfs_image_name == nfs_image_name:
                    return img
        raise NFSImagesNotFoundError('Image %s Not Found' % nfs_image_name)


# image = get_image('23-ubuntu.img')
# print image
# images = get_images()
#
# for i in images:
#     print i.nfs_image_url
#     print i.provider_id
#     print i.image_name
#     print i.nfs_vnfd_id

# image = NFSImage(24, 'ubuntu.img')
#
# try:
#     image.upload('file.img')
# except NFSImageUploadError as e:
#     print e.error

# image.delete()

#
# print image.provider_id
# print image.image_name
# print image.nfs_image_name
# print image.nfs_image_url
Example #6
0
def get_image(nfs_image_name, provider_id=None):
    code, resp = nfsapi.get_images_list()
    if code is not 200:
        raise NFSImagesListError
    else:
        print 'Images successfully listed!'
        for image in resp['files']:
            results = re.search('^(?P<provider_id>[0-9]+)-(?P<image_name>.*)$', image['name'], re.IGNORECASE)
            if results and (not provider_id or provider_id == int(results.group('provider_id'))):
                img = NFSImage(int(results.group('provider_id')), results.group('image_name'), image['vnfd_id'])
                if img.nfs_image_name == nfs_image_name:
                    return img
        raise NFSImagesNotFoundError('Image %s Not Found' % nfs_image_name)


# image = get_image('23-ubuntu.img')
# print image
# images = get_images()
#
# for i in images:
#     print i.nfs_image_url
#     print i.provider_id
#     print i.image_name
#     print i.nfs_vnfd_id

# image = NFSImage(24, 'ubuntu.img')
#
# try:
#     image.upload('file.img')
# except NFSImageUploadError as e:
#     print e.error

# image.delete()



#
# print image.provider_id
# print image.image_name
# print image.nfs_image_name
# print image.nfs_image_url