Exemplo n.º 1
0
    def complete(self, context, **kwargs):
        props = []
        name = q.get(kwargs, 'kwargs.image')
        if name:
            image = context.entity_subscribers['docker.image'].query(('names', 'in', name), single=True)
            if not image:
                image = q.query(DockerImageNamespace.default_images, ('name', '=', name), single=True)

            if image and image['presets']:
                presets = image['presets']
                props += [NullComplete('{id}='.format(**i)) for i in presets['settings']]
                props += [NullComplete('volume:{container_path}='.format(**v)) for v in presets['volumes']]
                props += [NullComplete('port:{container_port}/{protocol}='.format(**v)) for v in presets['ports']]

        available_images = q.query(DockerImageNamespace.default_images, select='name')
        available_images += context.entity_subscribers['docker.image'].query(select='names.0')
        available_images = list(set(available_images))

        return props + [
            NullComplete('name='),
            NullComplete('command='),
            NullComplete('hostname='),
            NullComplete('volume:'),
            NullComplete('port:'),
            EnumComplete('image=', available_images),
            EntitySubscriberComplete('host=', 'docker.host', lambda i: q.get(i, 'name')),
            EnumComplete('interactive=', ['yes', 'no']),
            EnumComplete('autostart=', ['yes', 'no']),
            EnumComplete('expose_ports=', ['yes', 'no']),
        ]
Exemplo n.º 2
0
def create_variable_completer(name, var):
    if var.type == ValueType.BOOLEAN:
        return EnumComplete(name + '=', ['yes', 'no'])

    if var.choices:
        return EnumComplete(name + '=', var.choices)

    return NullComplete(name + '=')
Exemplo n.º 3
0
def create_completer(prop):
    if prop.enum:
        enum_val = prop.enum() if callable(prop.enum) else prop.enum
        return EnumComplete(prop.name + '=', enum_val)

    if prop.type == ValueType.BOOLEAN:
        return EnumComplete(prop.name + '=', ['yes', 'no'])

    return NullComplete(prop.name + '=')
Exemplo n.º 4
0
 def complete(self, context):
     return [
         NullComplete('name='),
         NullComplete('master='),
         NullComplete('slave='),
         NullComplete('datasets='),
         EnumComplete('recursive=', ['yes', 'no']),
         EnumComplete('bidirectional=', ['yes', 'no']),
         EnumComplete('replicate_services=', ['yes', 'no'])
     ]
Exemplo n.º 5
0
 def complete(self, context):
     return [
         NullComplete('name='),
         EnumComplete('layout=', VOLUME_LAYOUTS.keys()),
         EnumComplete('type=', VOLUME_LAYOUTS.keys()),
         EnumComplete('encryption=', ['yes', 'no']),
         NullComplete('password='******'disks=', 'disk', lambda d: d['name'], ['auto'], list=True),
         EntitySubscriberComplete('cache=', 'disk', lambda d: d['name'], ['auto'], list=True),
         EntitySubscriberComplete('log=', 'disk', lambda d: d['name'], ['auto'], list=True),
     ]
Exemplo n.º 6
0
def create_completer(prop, obj=None):
    if prop.complete:
        return prop.complete
    else:
        if prop.enum:
            if callable(prop.enum):
                enum_val = prop.enum(obj) if obj else []
            else:
                enum_val = prop.enum
            return EnumComplete(prop.name + '=', enum_val)

        if prop.type == ValueType.BOOLEAN:
            return EnumComplete(prop.name + '=', ['yes', 'no'])

        return NullComplete(prop.name + '=')
Exemplo n.º 7
0
 def complete(self, context, **kwargs):
     return [
         NullComplete('name='),
         EnumComplete('type=', ['CERT_EXISTING', 'CA_EXISTING']),
         NullComplete('certificate_path='),
         NullComplete('privatekey_path='),
     ]
Exemplo n.º 8
0
 def complete(self, context, **kwargs):
     return [
         EnumComplete(
             'host=',
             context.entity_subscribers['docker.host'].query(
                 ('id', 'in', self.parent.entity['hosts']),
                 select='name'
             )
         )
     ]
Exemplo n.º 9
0
 def complete(self, context):
     return [
         NullComplete('name='),
         EnumComplete('type=', ['CERT_EXISTING'])
     ]
Exemplo n.º 10
0
 def complete(self, context, **kwargs):
     return [
         EnumComplete('name=', q.query(DockerImageNamespace.default_images, select='name')),
         EntitySubscriberComplete('host=', 'docker.host', lambda d: d['name'])
     ]
Exemplo n.º 11
0
 def complete(self, context):
     return [
         EnumComplete(0,
                      [p.name for p in self.parent.property_mappings])
     ]