Example #1
0
def parametric(lists, yaml):
    if "global" not in lists:
        lists["global"] = []
    scriptname = "%s/runme.sh" % target
    f = open(scriptname,'w')
    f.write("#!/bin/bash\n")

    # the default
    filename = "%s/default.ceph.conf" % target
    writefile(lists, filename)
    writescript(f, "default", "", filename)

    for param,value in sorted(yaml.iteritems()):
        if (isinstance(value, dict)):
            lc = copy.deepcopy(lists)
            for k,v in sorted(value.iteritems()):
                populate(lc.get("global"), k, v)
            filename = "%s/%s.ceph.conf" % (target, param)
            writefile(lc, filename)
            writescript(f, param, "", filename) 
        elif (isinstance(value, list)):
            for vi in value:
                lc = copy.deepcopy(lists)
                populate(lc.get("global"), param, vi)
                filename = "%s/%s_%s.ceph.conf" % (target, param, vi)
                writefile(lc, filename)
                writescript(f, param, vi, filename)
        else:
            lc = copy.deepcopy(lists)
            populate(lc.get("global"), param, value)
            filename = "%s/%s_%s.ceph.conf" % (target, param, value)
            writefile(lc, filename)
            writescript(f, param, value, filename)
    f.close()
    os.chmod(scriptname, 0755)
Example #2
0
 def clipsettings_gui(instance=None, yaml=None):
     """GUI for setting the width of the grid."""
     width = 16
     if instance is not None:
         width = instance.width
     if yaml is not None:
         for key, value in yaml.iteritems():
             if key == 'width':
                 width = value
     return (gui.Counter((300, 2), 30, 'Width', 4, 30, width), )
Example #3
0
 def clipsettings_gui(instance=None, yaml=None):
     """GUI for setting the width of the grid."""
     width = 16
     if instance is not None:
         width = instance.width
     if yaml is not None:
         for key, value in yaml.iteritems():
             if key == 'width':
                 width = value
     return (gui.Counter((300, 2), 30,
                         'Width', 4, 30, width),)
Example #4
0
def service_dependent_paths(yaml):
    for service_name, definition in yaml.iteritems():
        build = definition.get('build')
        paths = []
        if build:
            if isinstance(build, basestring):
                paths.append(build)
            else:
                context = build['context']
                paths.append(context)
                dockerfile = build.get('dockerfile')
                if dockerfile and not dockerfile.startswith(context):
                    paths.append(dockerfile)
        yield service_name, paths
Example #5
0
 def clipsettings_gui(instance=None, yaml=None):
     width = 4
     height = 4
     if instance is not None:
         width = len(instance.grid)
         height = len(instance.grid[0])
     if yaml is not None:
         for key, value in yaml.iteritems():
             if key == 'width':
                 width = value
             elif key == 'height':
                 height = value
     return (gui.Counter((300, 2), 30,
                         'Width', 1, 16, width),
             gui.Counter((300, 34), 30,
                         'Height', 1, 16, height))
def expand(yaml):
    if not type(yaml) in [list, dict]:
        return yaml
    if type(yaml) == list:
        iter = enumerate(yaml)
    else:
        iter = yaml.iteritems()
    for k, v in iter:
        if type(v) is str:
            value = os.path.expandvars(v)
            if value.startswith("PATH_BASE64|"):
                path = value[len("PATH_BASE64|"):]
                contents = open(path, "r").read()
                from base64 import b64encode
                base64_contents = b64encode(contents)
                value = base64_contents
            yaml[k] = value
        else:
            yaml[k] = expand(v)
    
    return yaml