test_registry = True
if args.test_registry or test_registry:
    branch, use_registry = registry.getBranchRegistry()
else:
    use_registry = labtainer_config.default_registry
print('registry is: %s' % use_registry)
config_list = [
    'base', 'network', 'firefox', 'wireshark', 'java', 'centos', 'lamp',
    'netmon', 'tap'
]
if args.metasploit:
    config_list.append('metasploitable')
    config_list.append('kali')
for config in config_list:
    image_name = '%s/labtainer.%s' % (use_registry, config)
    local_created, local_user, local_version = labutils.inspectImage(
        image_name)
    if args.force or local_created is None:
        cmd = 'docker pull %s/labtainer.%s' % (use_registry, config)
        print(cmd)
        os.system(cmd)
    '''
    else:
        if test_registry:
            reg_created, reg_user, reg_version = InspectLocalReg.inspectLocal(image_name, registry)
        else:
            reg_created, reg_user, reg_version = InspectRemoteReg.inspectRemote(image_name)
    if local_created < reg_created:
        print(cmd)
        #os.system(cmd)
    '''
Beispiel #2
0
tdir = '/tmp/nonet'
try:
    os.mkdir(tdir)
except:
    pass

labtainer_lab = os.path.join(labtainers_path, args.labname)
labtainer_config, start_config = labutils.GetBothConfigs(
    labtainer_lab, labutils.logger)
created_images = []
for name, container in start_config.containers.items():
    os.system('rm -fr /tmp/nonet/*')
    fname = 'Dockerfile.%s-%s' % (args.labname, name)
    full = os.path.join(tdir, fname)
    from_image = container.image_name
    created, user, version = labutils.inspectImage(from_image)
    if created is None:
        labutils.logger.error(
            "Running noNet.py and cannot find image %s locally." % from_image)
        from_image = '%s/%s' % (container.registry, container.image_name)
        created, user, version = labutils.inspectImage(from_image)
        if created is None:
            labutils.logger.error(
                "Running noNet.py and cannot find image %s in remote registry."
                % from_image)

    print('container image for %s is %s' % (name, from_image))
    with open(full, 'w') as fh:
        line = 'FROM %s' % from_image
        fh.write(line + '\n')
        fh.write('USER root\n')