示例#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']),
        ]
示例#2
0
文件: commands.py 项目: mactanxin/cli
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 + '=')
示例#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 + '=')
示例#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'])
     ]
示例#5
0
文件: volumes.py 项目: caymanowl/cli
 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),
     ]
示例#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 + '=')
示例#7
0
文件: crypto.py 项目: surajrav/cli
 def complete(self, context, **kwargs):
     return [
         NullComplete('name='),
         EnumComplete('type=', ['CERT_EXISTING', 'CA_EXISTING']),
         NullComplete('certificate_path='),
         NullComplete('privatekey_path='),
     ]
示例#8
0
 def complete(self, context, **kwargs):
     return [
         EnumComplete(
             'host=',
             context.entity_subscribers['docker.host'].query(
                 ('id', 'in', self.parent.entity['hosts']),
                 select='name'
             )
         )
     ]
示例#9
0
    def complete(self, context, **kwargs):
        props = []
        username = q.get(kwargs, 'kwargs.username')
        password = q.get(kwargs, 'kwargs.password')
        if username and password:
            if not self.ticket_categories:
                self.ticket_categories.update(
                    context.call_sync('support.categories', str(username),
                                      str(password)))

        if self.ticket_categories:
            props += [
                EnumComplete('category=', list(self.ticket_categories.keys()))
            ]
            props += [NullComplete('subject=')]
            props += [NullComplete('description=')]
            props += [EnumComplete('type=', ['bug', 'feature'])]
            props += [EnumComplete('attach_debug_data=', ['yes', 'no'])]
            props += [NullComplete('attachments=')]

        return props + [
            NullComplete('username='******'password='),
        ]
示例#10
0
文件: namespace.py 项目: zoot/cli
        def complete(self, context, **kwargs):
            if 'kwargs' in kwargs:
                ns = self.parent
                kwargs = collections.OrderedDict(kwargs)
                mappings = map(lambda i: (self.parent.get_mapping(i[0]), i[1]),
                               kwargs['kwargs'].items())

                for prop, v in sorted(mappings, key=lambda i: i[0].index):
                    with contextlib.suppress(BaseException):
                        prop.do_set(ns.entity, v)

                return [
                    EnumComplete(0, [
                        x.name for x in self.parent.property_mappings
                        if x.can_set(ns.entity)
                    ])
                ]

            return []
示例#11
0
文件: update.py 项目: jceel/cli
 def complete(self, context, **kwargs):
     return [EnumComplete('reboot=', ['yes', 'no'])]
示例#12
0
文件: backup.py 项目: caymanowl/cli
 def complete(self, context):
     return [
         EnumComplete('snapshot=', ['yes', 'no']),
         EnumComplete('dry_run=', ['yes', 'no'])
     ]
示例#13
0
文件: crypto.py 项目: caymanowl/cli
 def complete(self, context):
     return [
         NullComplete('name='),
         EnumComplete('type=', ['CERT_EXISTING'])
     ]
示例#14
0
 def complete(self, context, **kwargs):
     return [
         EnumComplete('name=', q.query(DockerImageNamespace.default_images, select='name')),
         EntitySubscriberComplete('host=', 'docker.host', lambda d: d['name'])
     ]
示例#15
0
 def complete(self, context):
     return [
         EnumComplete(0,
                      [p.name for p in self.parent.property_mappings])
     ]