Example #1
0
def main():
    '''this function will run a docker import, returning a list of layers
    and environmental variables and metadata to the metadata base
    '''

    container = getenv("SINGULARITY_CONTAINER", required=True)
    image_uri = get_image_uri(container, quiet=True)
    container = remove_image_uri(container)

    ########################################################################
    # Docker Image #########################################################
    ########################################################################

    if image_uri == "docker://":

        bot.debug("\n*** STARTING DOCKER IMPORT PYTHON  ****")

        from sutils import basic_auth_header
        from defaults import LAYERFILE

        bot.debug("Docker layers and metadata will be written to: %s"
                  % (LAYERFILE))

        username = getenv("SINGULARITY_DOCKER_USERNAME")
        password = getenv("SINGULARITY_DOCKER_PASSWORD",
                          silent=True)

        auth = None
        if username is not None and password is not None:
            auth = basic_auth_header(username, password)

        from docker.main import IMPORT

        manifest = IMPORT(auth=auth,
                          image=container,
                          layerfile=LAYERFILE)

    ########################################################################
    # Singularity Hub ######################################################
    ########################################################################

    elif image_uri == "shub://":

        bot.debug("\n*** STARTING SINGULARITY HUB IMPORT PYTHON  ****")

        from defaults import LAYERFILE, LABELFILE
        from shub.main import IMPORT
        IMPORT(image=container,
               layerfile=LAYERFILE,
               labelfile=LABELFILE)

    else:
        bot.error("uri %s is not supported for import. Exiting."
                  % (image_uri))
        sys.exit(1)
Example #2
0
    def test_headers(self):
        '''test_add_http ensures that http is added to a url
        '''
        print("Testing utils header functions...")

        from sutils import basic_auth_header

        # Basic auth header
        print("Case 4: ask for custom authentication header")
        auth = basic_auth_header(username='******', password='******')
        self.assertEqual(auth['Authorization'],
                         'Basic dmFuZXNzYTpwYW5jYWtlcw==')
Example #3
0
    def test_headers(self):
        '''test_add_http ensures that http is added to a url
        '''
        print("Testing utils header functions...")

        from sutils import basic_auth_header

        # Basic auth header
        print("Case 4: ask for custom authentication header")
        auth = basic_auth_header(username='******',
                                 password='******')
        self.assertEqual(auth['Authorization'],
                         'Basic dmFuZXNzYTpwYW5jYWtlcw==')
Example #4
0
def main():
    '''this function will run a docker import, returning a list of layers 
    and environmental variables and metadata to the metadata base
    '''

    container = getenv("SINGULARITY_CONTAINER", required=True)
    image_uri = get_image_uri(container, quiet=True)
    container = remove_image_uri(container)

    ##############################################################################
    # Docker Image ###############################################################
    ##############################################################################

    if image_uri == "docker://":

        bot.debug("\n*** STARTING DOCKER IMPORT PYTHON  ****")

        from sutils import basic_auth_header
        from defaults import LAYERFILE

        bot.debug(
            "Docker layers and (env,labels,runscript) will be written to: %s" %
            LAYERFILE)
        username = getenv("SINGULARITY_DOCKER_USERNAME")
        password = getenv("SINGULARITY_DOCKER_PASSWORD", silent=True)

        auth = None
        if username is not None and password is not None:
            auth = basic_auth_header(username, password)

        from docker.main import IMPORT

        manifest = IMPORT(auth=auth, image=container, layerfile=LAYERFILE)

    ##############################################################################
    # Singularity Hub ############################################################
    ##############################################################################

    elif image_uri == "shub://":

        bot.debug("\n*** STARTING SINGULARITY HUB IMPORT PYTHON  ****")

        from defaults import LAYERFILE, LABELFILE
        from shub.main import IMPORT
        IMPORT(image=container, layerfile=LAYERFILE, labelfile=LABELFILE)

    else:
        bot.error(
            "uri %s is not a currently supported uri for import. Exiting." %
            image_uri)
        sys.exit(1)
Example #5
0
def main():
    '''this function will run the main size functions and call shub clients 
    '''

    container = getenv("SINGULARITY_CONTAINER",required=True)
    image_uri = get_image_uri(container)    
    container = remove_image_uri(container)
    from defaults import LAYERFILE

    ##############################################################################
    # Singularity Hub ############################################################
    ##############################################################################

    if image_uri == "shub://":

        bot.debug("\n*** STARTING SINGULARITY HUB SIZE PYTHON  ****")    
        from shub.main import SIZE
        SIZE(image=container,
             contentfile=LAYERFILE)

    elif image_uri == "docker://":

        from sutils import basic_auth_header
        from docker.main import SIZE

        bot.debug("Docker sizes will be written to: %s" %LAYERFILE)
        username = getenv("SINGULARITY_DOCKER_USERNAME") 
        password = getenv("SINGULARITY_DOCKER_PASSWORD",silent=True)

        auth = None
        if username is not None and password is not None:
            auth = basic_auth_header(username, password)

        SIZE(image=container,
             auth=auth,
             contentfile=LAYERFILE)

    else:
        bot.error("uri %s is not a currently supported uri for size. Exiting." %image_uri)
        sys.exit(1)