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']), ]
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 + '=')
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 + '=')
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']) ]
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), ]
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 + '=')
def complete(self, context, **kwargs): return [ NullComplete('name='), EnumComplete('type=', ['CERT_EXISTING', 'CA_EXISTING']), NullComplete('certificate_path='), NullComplete('privatekey_path='), ]
def complete(self, context, **kwargs): return [ EnumComplete( 'host=', context.entity_subscribers['docker.host'].query( ('id', 'in', self.parent.entity['hosts']), select='name' ) ) ]
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='), ]
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 []
def complete(self, context, **kwargs): return [EnumComplete('reboot=', ['yes', 'no'])]
def complete(self, context): return [ EnumComplete('snapshot=', ['yes', 'no']), EnumComplete('dry_run=', ['yes', 'no']) ]
def complete(self, context): return [ NullComplete('name='), EnumComplete('type=', ['CERT_EXISTING']) ]
def complete(self, context, **kwargs): return [ EnumComplete('name=', q.query(DockerImageNamespace.default_images, select='name')), EntitySubscriberComplete('host=', 'docker.host', lambda d: d['name']) ]
def complete(self, context): return [ EnumComplete(0, [p.name for p in self.parent.property_mappings]) ]