Пример #1
0
    def test_writemeta(self):
        """
        Test Write meta function
        """

        meta = {
            'workdir': "/tmp/",
            'entrypoint': '/bin/sh',
            'env': ['a=b', 'c=d'],
            'private': True,
            'userACL': [1000, 1001],
            'groupACL': [1002, 1003],
        }
        output = '%s/test.meta' % (self.outdir)
        resp = converters.writemeta('squashfs', meta, output)
        assert resp is not None
        meta = {'ENV': []}
        with open(output) as f:
            for line in f:
                (k, v) = line.strip().split(": ", 2)
                if k == 'ENV':
                    meta['ENV'].append(v)
                else:
                    meta[k] = v
        keys = ['WORKDIR', 'FORMAT', 'ENTRY']
        if 'DISABLE_ACL_METADATA' not in os.environ:
            keys.extend(['USERACL', 'GROUPACL'])
        for key in keys:
            self.assertIn(key, meta)
        if 'DISABLE_ACL_METADATA' not in os.environ:
            self.assertEquals(meta['USERACL'].find("["), -1)
            self.assertEquals(meta['USERACL'].find("]"), -1)
        self.assertGreater(len(meta['ENV']), 0)
Пример #2
0
def write_metadata(request):
    """
    Write out the metadata file

    Returns True on success
    """
    fmt = request['format']
    meta = request['meta']

    edir = CONFIG['ExpandDirectory']

    ## initially write metadata to tempfile
    (fdesc, metafile) = tempfile.mkstemp(prefix=request['id'], suffix='meta', \
            dir=edir)
    os.close(fdesc)
    request['metafile'] = metafile

    status = converters.writemeta(fmt, meta, metafile)

    ## after success move to final name
    final_metafile = os.path.join(edir, '%s.meta' % (request['id']))
    shutil.move(metafile, final_metafile)
    request['metafile'] = final_metafile

    return status
Пример #3
0
def write_metadata(request):
    """
    Write out the metadata file

    Returns True on success
    """
    fmt = request['format']
    meta = request['meta']
    if 'userACL' in request:
        meta['userACL'] = request['userACL']
    if 'groupACL' in request:
        meta['groupACL'] = request['groupACL']

    edir = CONFIG['ExpandDirectory']

    # initially write metadata to tempfile
    (fdesc, metafile) = tempfile.mkstemp(prefix=request['id'], suffix='meta',
                                         dir=edir)
    os.close(fdesc)
    request['metafile'] = metafile

    status = converters.writemeta(fmt, meta, metafile)

    # after success move to final name
    final_metafile = os.path.join(edir, '%s.meta' % (request['id']))
    shutil.move(metafile, final_metafile)
    request['metafile'] = final_metafile

    return status
Пример #4
0
    def test_writemeta(self):
        """
        Test Write meta function
        """

        meta = {'workdir': "/tmp/",
                'entrypoint': '/bin/sh',
                'env': ['a=b', 'c=d'],
                'private': True,
                'userACL': [1000, 1001],
                'groupACL': [1002, 1003],
                }
        output = '%s/test.meta' % (self.outdir)
        resp = converters.writemeta('squashfs', meta, output)
        assert resp is not None
        meta = {'ENV': []}
        with open(output) as f:
            for line in f:
                (k, v) = line.strip().split(": ", 2)
                if k == 'ENV':
                    meta['ENV'].append(v)
                else:
                    meta[k] = v
        keys = ['WORKDIR', 'FORMAT', 'ENTRY']
        if 'DISABLE_ACL_METADATA' not in os.environ:
            keys.extend(['USERACL', 'GROUPACL'])
        for key in keys:
            self.assertIn(key, meta)
        if 'DISABLE_ACL_METADATA' not in os.environ:
            self.assertEquals(meta['USERACL'].find("["), -1)
            self.assertEquals(meta['USERACL'].find("]"), -1)
        self.assertGreater(len(meta['ENV']), 0)