Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def submit(func, *args, **kwargs): child = _createFuture(func, *args, **kwargs) control.futureDict[control.current.id].children[child] = None control.execQueue.append(child) return child
[ "Submit an independent asynchronous :class:`~scoop._types.Future` that will\n either run locally or remotely as `func(*args)`.\n\n :param func: Any picklable callable object (function or class object with\n *__call__* method); this object will be called to execute the Future.\n The callable must...
Please provide a description of the function:def _waitAny(*children): n = len(children) # check for available results and index those unavailable for index, future in enumerate(children): if future.exceptionValue: raise future.exceptionValue if future._ended(): f...
[ "Waits on any child Future created by the calling Future.\n\n :param children: A tuple of children Future objects spawned by the calling\n Future.\n\n :return: A generator function that iterates on futures that are done.\n\n The generator produces results of the children in a non deterministic order...
Please provide a description of the function:def wait(fs, timeout=-1, return_when=ALL_COMPLETED): DoneAndNotDoneFutures = namedtuple('DoneAndNotDoneFutures', 'done not_done') if timeout < 0: # Negative timeout means blocking. if return_when == FIRST_COMPLETED: next(_waitAny(*fs...
[ "Wait for the futures in the given sequence to complete.\n Using this function may prevent a worker from executing.\n\n :param fs: The sequence of Futures to wait upon.\n :param timeout: The maximum number of seconds to wait. If negative or not\n specified, then there is no limit on the wait time.\n...
Please provide a description of the function:def advertiseBrokerWorkerDown(exctype, value, traceback): if not scoop.SHUTDOWN_REQUESTED: execQueue.shutdown() sys.__excepthook__(exctype, value, traceback)
[ "Hook advertizing the broker if an impromptu shutdown is occuring." ]
Please provide a description of the function:def init_debug(): global debug_stats global QueueLength if debug_stats is None: list_defaultdict = partial(defaultdict, list) debug_stats = defaultdict(list_defaultdict) QueueLength = []
[ "Initialise debug_stats and QueueLength (this is not a reset)" ]
Please provide a description of the function:def delFutureById(futureId, parentId): try: del futureDict[futureId] except KeyError: pass try: toDel = [a for a in futureDict[parentId].children if a.id == futureId] for f in toDel: del futureDict[parentId].childr...
[ "Delete future on id basis" ]
Please provide a description of the function:def delFuture(afuture): try: del futureDict[afuture.id] except KeyError: pass try: del futureDict[afuture.parentId].children[afuture] except KeyError: pass
[ "Delete future afuture" ]
Please provide a description of the function:def runFuture(future): global debug_stats global QueueLength if scoop.DEBUG: init_debug() # in case _control is imported before scoop.DEBUG was set debug_stats[future.id]['start_time'].append(time.time()) future.waitTime = future.stopWat...
[ "Callable greenlet in charge of running tasks." ]
Please provide a description of the function:def runController(callable_, *args, **kargs): global execQueue # initialize and run root future rootId = (-1, 0) # initialise queue if execQueue is None: execQueue = FutureQueue() sys.excepthook = advertiseBrokerWorkerDown ...
[ "Callable greenlet implementing controller logic." ]
Please provide a description of the function:def mode(self): mu = self.mean() sigma = self.std() ret_val = math.exp(mu - sigma**2) if math.isnan(ret_val): ret_val = float("inf") return ret_val
[ "Computes the mode of a log-normal distribution built with the stats data." ]
Please provide a description of the function:def median(self): mu = self.mean() ret_val = math.exp(mu) if math.isnan(ret_val): ret_val = float("inf") return ret_val
[ "Computes the median of a log-normal distribution built with the stats data." ]
Please provide a description of the function:def _parse_packet(rawdata): if (len(rawdata) < len(_MAGIC) + 1) or (_MAGIC != rawdata[:len(_MAGIC)]): # Wrong protocol return (None, None) opcode = rawdata[len(_MAGIC):len(_MAGIC)+1] payload = rawdata[len(_MAGIC)+1:] return (opcode, pa...
[ " Returns a tupel (opcode, minusconf-data). opcode is None if this isn't a -conf packet." ]
Please provide a description of the function:def _decode_string(buf, pos): for i in range(pos, len(buf)): if buf[i:i+1] == _compat_bytes('\x00'): try: return (buf[pos:i].decode(_CHARSET), i+1) # Uncomment the following two lines for detailled information ...
[ " Decodes a string in the buffer buf, starting at position pos.\n Returns a tupel of the read string and the next byte to read.\n " ]
Please provide a description of the function:def _resolve_addrs(straddrs, port, ignore_unavailable=False, protocols=[socket.AF_INET, socket.AF_INET6]): res = [] for sa in straddrs: try: ais = socket.getaddrinfo(sa, port) for ai in ais: if ai[0] in protocols:...
[ " Returns a tupel of tupels of (family, to, original_addr_family, original_addr).\n\n If ignore_unavailable is set, addresses for unavailable protocols are ignored.\n protocols determines the protocol family indices supported by the socket in use. " ]
Please provide a description of the function:def _find_sock(): if socket.has_ipv6: try: return socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) except socket.gaierror: pass # Platform lied about IPv6 support return socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
[ " Create a UDP socket " ]
Please provide a description of the function:def _main(): import sys if len(sys.argv) < 2: _usage('Expected at least one parameter!') sc = sys.argv[1] options = sys.argv[2:] if sc == 'a' or sc == 'advertise': if len(options) > 5 or len(options) < 2: _usage() ...
[ " CLI interface " ]
Please provide a description of the function:def _compat_inet_pton(family, addr): if family == socket.AF_INET: # inet_aton accepts some strange forms, so we use our own res = _compat_bytes('') parts = addr.split('.') if len(parts) != 4: raise ValueError('Expected 4 ...
[ " socket.inet_pton for platforms that don't have it " ]
Please provide a description of the function:def start_blocking(self): self._cav_started.clear() self.start() self._cav_started.wait()
[ " Start the advertiser in the background, but wait until it is ready " ]
Please provide a description of the function:def _send_queries(self): res = 0 addrs = _resolve_addrs(self.addresses, self.port, self.ignore_senderrors, [self._sock.family]) for addr in addrs: try: self._send_query(addr[1]) res += 1 ...
[ " Sends queries to multiple addresses. Returns the number of successful queries. " ]
Please provide a description of the function:def executeTree(address=[]): global nodeDone # Get tree subsection localTree = getTree(address) # Execute tasks localTree.intCalc() localTree.floatCalc() # Select next nodes to be executed nextAddresses = [address + [i] for i in range(len...
[ "This function executes a tree. To limit the size of the arguments passed\n to the function, the tree must be loaded in memory in every worker. To do\n this, simply call \"Tree = importTree(filename)\" before using the startup\n method of the parralisation library you are using" ]
Please provide a description of the function:def clean(self): raise forms.ValidationError( self.error_messages['invalid_login'], code='invalid_login', params={'username': self.username_field.verbose_name} )
[ "\n Always raise the default error message, because we don't\n care what they entered here.\n " ]
Please provide a description of the function:def build_call(func, *args, **kwargs): func = get_wrapped_func(func) named, vargs, _, defs, kwonly, kwonlydefs, _ = getfullargspec(func) nonce = object() actual = dict((name, nonce) for name in named) defs = defs or () kwonlydefs = kwonlydefs ...
[ "\n Build an argument dictionary suitable for passing via `**` expansion given\n function `f`, positional arguments `args`, and keyword arguments `kwargs`.\n " ]
Please provide a description of the function:def types(**requirements): def predicate(args): for name, kind in sorted(requirements.items()): assert hasattr(args, name), "missing required argument `%s`" % name if not isinstance(kind, tuple): kind = (kind,) ...
[ "\n Specify a precondition based on the types of the function's\n arguments.\n " ]
Please provide a description of the function:def ensure(arg1, arg2=None): assert (isinstance(arg1, str) and isfunction(arg2)) or (isfunction(arg1) and arg2 is None) description = "" predicate = lambda x: x if isinstance(arg1, str): description = arg1 predicate = arg2 else: ...
[ "\n Specify a precondition described by `description` and tested by\n `predicate`.\n " ]
Please provide a description of the function:def invariant(arg1, arg2=None): desc = "" predicate = lambda x: x if isinstance(arg1, str): desc = arg1 predicate = arg2 else: desc = get_function_source(arg1) predicate = arg1 def invariant(c): def check(na...
[ "\n Specify a class invariant described by `description` and tested\n by `predicate`.\n " ]
Please provide a description of the function:def mkpassword(length=16, chars=None, punctuation=None): if chars is None: chars = string.ascii_letters + string.digits # Generate string from population data = [random.choice(chars) for _ in range(length)] # If punctuation: # - remove n ch...
[ "Generates a random ascii string - useful to generate authinfos\n\n :param length: string wanted length\n :type length: ``int``\n\n :param chars: character population,\n defaults to alphabet (lower & upper) + numbers\n :type chars: ``str``, ``list``, ``set`` (sequence)\n\n :param pun...
Please provide a description of the function:def disk_check_size(ctx, param, value): if value: # if we've got a prefix if isinstance(value, tuple): val = value[1] else: val = value if val % 1024: raise click.ClickException('Size must be a mult...
[ " Validation callback for disk size parameter." ]
Please provide a description of the function:def create(cls, fqdn, flags, algorithm, public_key): fqdn = fqdn.lower() params = { 'flags': flags, 'algorithm': algorithm, 'public_key': public_key, } result = cls.call('domain.dnssec.create', fq...
[ "Create a dnssec key." ]
Please provide a description of the function:def from_name(cls, name): snps = cls.list({'name': name}) if len(snps) == 1: return snps[0]['id'] elif not snps: return raise DuplicateResults('snapshot profile name %s is ambiguous.' % name)
[ " Retrieve a snapshot profile accsociated to a name." ]
Please provide a description of the function:def list(cls, options=None, target=None): options = options or {} result = [] if not target or target == 'paas': for profile in cls.safe_call('paas.snapshotprofile.list', options): profile['target'] = 'paas' ...
[ " List all snapshot profiles." ]
Please provide a description of the function:def info(cls, resource): snps = cls.list({'id': cls.usable_id(resource)}) if len(snps) == 1: return snps[0] elif not snps: return raise DuplicateResults('snapshot profile %s is ambiguous.' % resource)
[ "Display information about a snapshot profile." ]
Please provide a description of the function:def records(cls, fqdn, sort_by=None, text=False): meta = cls.get_fqdn_info(fqdn) url = meta['domain_records_href'] kwargs = {} if text: kwargs = {'headers': {'Accept': 'text/plain'}} return cls.json_get(cls.get_sor...
[ "Display records information about a domain." ]
Please provide a description of the function:def add_record(cls, fqdn, name, type, value, ttl): data = { "rrset_name": name, "rrset_type": type, "rrset_values": value, } if ttl: data['rrset_ttl'] = int(ttl) meta = cls.get_fqdn_info...
[ "Create record for a domain." ]
Please provide a description of the function:def update_record(cls, fqdn, name, type, value, ttl, content): data = { "rrset_name": name, "rrset_type": type, "rrset_values": value, } if ttl: data['rrset_ttl'] = int(ttl) meta = cls.g...
[ "Update all records for a domain." ]
Please provide a description of the function:def del_record(cls, fqdn, name, type): meta = cls.get_fqdn_info(fqdn) url = meta['domain_records_href'] delete_url = url if name: delete_url = '%s/%s' % (delete_url, name) if type: delete_url = '%s/%s' ...
[ "Delete record for a domain." ]
Please provide a description of the function:def keys(cls, fqdn, sort_by=None): meta = cls.get_fqdn_info(fqdn) url = meta['domain_keys_href'] return cls.json_get(cls.get_sort_url(url, sort_by))
[ "Display keys information about a domain." ]
Please provide a description of the function:def keys_info(cls, fqdn, key): return cls.json_get('%s/domains/%s/keys/%s' % (cls.api_url, fqdn, key))
[ "Retrieve key information." ]
Please provide a description of the function:def keys_create(cls, fqdn, flag): data = { "flags": flag, } meta = cls.get_fqdn_info(fqdn) url = meta['domain_keys_href'] ret, headers = cls.json_post(url, data=json.dumps(data), ...
[ "Create new key entry for a domain." ]
Please provide a description of the function:def keys_delete(cls, fqdn, key): return cls.json_delete('%s/domains/%s/keys/%s' % (cls.api_url, fqdn, key))
[ "Delete a key for a domain." ]
Please provide a description of the function:def keys_recover(cls, fqdn, key): data = { "deleted": False, } return cls.json_put('%s/domains/%s/keys/%s' % (cls.api_url, fqdn, key), data=json.dumps(data),)
[ "Recover deleted key for a domain." ]
Please provide a description of the function:def list(gandi, datacenter, id, subnet, gateway): output_keys = ['name', 'state', 'dc'] if id: output_keys.append('id') if subnet: output_keys.append('subnet') if gateway: output_keys.append('gateway') datacenters = gandi.dat...
[ "List vlans." ]
Please provide a description of the function:def info(gandi, resource, ip): output_keys = ['name', 'state', 'dc', 'subnet', 'gateway'] datacenters = gandi.datacenter.list() vlan = gandi.vlan.info(resource) gateway = vlan['gateway'] if not ip: output_vlan(gandi, vlan, datacenters, out...
[ "Display information about a vlan." ]
Please provide a description of the function:def create(gandi, name, datacenter, subnet, gateway, background): try: gandi.datacenter.is_opened(datacenter, 'iaas') except DatacenterLimited as exc: gandi.echo('/!\ Datacenter %s will be closed on %s, ' 'please consider using...
[ " Create a new vlan " ]
Please provide a description of the function:def update(gandi, resource, name, gateway, create, bandwidth): params = {} if name: params['name'] = name vlan_id = gandi.vlan.usable_id(resource) try: if gateway: IP(gateway) params['gateway'] = gateway exce...
[ " Update a vlan\n\n ``gateway`` can be a vm name or id, or an ip.\n " ]
Please provide a description of the function:def list_migration_choice(cls, datacenter): datacenter_id = cls.usable_id(datacenter) dc_list = cls.list() available_dcs = [dc for dc in dc_list if dc['id'] == datacenter_id][0]['can_migrate_to'] choices = [dc...
[ "List available datacenters for migration from given datacenter." ]
Please provide a description of the function:def is_opened(cls, dc_code, type_): options = {'dc_code': dc_code, '%s_opened' % type_: True} datacenters = cls.safe_call('hosting.datacenter.list', options) if not datacenters: # try with ISO code options = {'iso': dc...
[ "List opened datacenters for given type." ]
Please provide a description of the function:def filtered_list(cls, name=None, obj=None): options = {} if name: options['id'] = cls.usable_id(name) def obj_ok(dc, obj): if not obj or obj['datacenter_id'] == dc['id']: return True retur...
[ "List datacenters matching name and compatible\n with obj" ]
Please provide a description of the function:def from_iso(cls, iso): result = cls.list({'sort_by': 'id ASC'}) dc_isos = {} for dc in result: if dc['iso'] not in dc_isos: dc_isos[dc['iso']] = dc['id'] return dc_isos.get(iso)
[ "Retrieve the first datacenter id associated to an ISO." ]
Please provide a description of the function:def from_name(cls, name): result = cls.list() dc_names = {} for dc in result: dc_names[dc['name']] = dc['id'] return dc_names.get(name)
[ "Retrieve datacenter id associated to a name." ]
Please provide a description of the function:def from_country(cls, country): result = cls.list({'sort_by': 'id ASC'}) dc_countries = {} for dc in result: if dc['country'] not in dc_countries: dc_countries[dc['country']] = dc['id'] return dc_countries...
[ "Retrieve the first datacenter id associated to a country." ]
Please provide a description of the function:def from_dc_code(cls, dc_code): result = cls.list() dc_codes = {} for dc in result: if dc.get('dc_code'): dc_codes[dc['dc_code']] = dc['id'] return dc_codes.get(dc_code)
[ "Retrieve the datacenter id associated to a dc_code" ]
Please provide a description of the function:def usable_id(cls, id): try: # id is maybe a dc_code qry_id = cls.from_dc_code(id) if not qry_id: # id is maybe a ISO qry_id = cls.from_iso(id) if qry_id: ...
[ " Retrieve id from input which can be ISO, name, country, dc_code." ]
Please provide a description of the function:def find_port(addr, user): import pwd home = pwd.getpwuid(os.getuid()).pw_dir for name in os.listdir('%s/.ssh/' % home): if name.startswith('unixpipe_%s@%s_' % (user, addr,)): return int(name.split('_')[2])
[ "Find local port in existing tunnels" ]
Please provide a description of the function:def new_port(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP) for i in range(12042, 16042): try: s.bind(('127.0.0.1', i)) s.close() return i except socket.error: pass ...
[ "Find a free local port and allocate it" ]
Please provide a description of the function:def _ssh_master_cmd(addr, user, command, local_key=None): ssh_call = ['ssh', '-qNfL%d:127.0.0.1:12042' % find_port(addr, user), '-o', 'ControlPath=~/.ssh/unixpipe_%%r@%%h_%d' % find_port(addr, user), '-O', comma...
[ "Exit or check ssh mux" ]
Please provide a description of the function:def setup(addr, user, remote_path, local_key=None): port = find_port(addr, user) if not port or not is_alive(addr, user): port = new_port() scp(addr, user, __file__, '~/unixpipe', local_key) ssh_call = ['ssh', '-fL%d:127.0.0.1:12042' %...
[ "Setup the tunnel" ]
Please provide a description of the function:def list(gandi, limit, step): output_keys = ['id', 'type', 'step'] options = { 'step': step, 'items_per_page': limit, 'sort_by': 'date_created DESC' } result = gandi.oper.list(options) for num, oper in enumerate(reversed(res...
[ "List operations." ]
Please provide a description of the function:def info(gandi, id): output_keys = ['id', 'type', 'step', 'last_error'] oper = gandi.oper.info(id) output_generic(gandi, oper, output_keys) return oper
[ "Display information about an operation." ]
Please provide a description of the function:def create(gandi, resource, flags, algorithm, public_key): result = gandi.dnssec.create(resource, flags, algorithm, public_key) return result
[ "Create DNSSEC key." ]
Please provide a description of the function:def list(gandi, resource): keys = gandi.dnssec.list(resource) gandi.pretty_echo(keys) return keys
[ "List DNSSEC keys." ]
Please provide a description of the function:def delete(gandi, resource): result = gandi.dnssec.delete(resource) gandi.echo('Delete successful.') return result
[ "Delete DNSSEC key.\n " ]
Please provide a description of the function:def load_config(cls): config_file = os.path.expanduser(cls.home_config) global_conf = cls.load(config_file, 'global') cls.load(cls.local_config, 'local') # update global configuration if needed cls.update_config(config_file, g...
[ " Load global and local configuration files and update if needed." ]
Please provide a description of the function:def update_config(cls, config_file, config): need_save = False # delete old env key if 'api' in config and 'env' in config['api']: del config['api']['env'] need_save = True # convert old ssh_key configuration e...
[ " Update configuration if needed. " ]
Please provide a description of the function:def load(cls, filename, name=None): if not os.path.exists(filename): return {} name = name or filename if name not in cls._conffiles: with open(filename) as fdesc: content = yaml.load(fdesc, YAMLLoader...
[ " Load yaml configuration from filename. " ]
Please provide a description of the function:def save(cls, filename, config): mode = os.O_WRONLY | os.O_TRUNC | os.O_CREAT with os.fdopen(os.open(filename, mode, 0o600), 'w') as fname: yaml.safe_dump(config, fname, indent=4, default_flow_style=False)
[ " Save configuration to yaml file. " ]
Please provide a description of the function:def delete(cls, global_, key): # first retrieve current configuration scope = 'global' if global_ else 'local' config = cls._conffiles.get(scope, {}) cls._del(scope, key) conf_file = cls.home_config if global_ else cls.local_c...
[ " Delete key/value pair from configuration file. " ]
Please provide a description of the function:def get(cls, key, default=None, separator='.', global_=False): # first check environnment variables # if we're not in global scope if not global_: ret = os.environ.get(key.upper().replace('.', '_')) if ret is not None:...
[ " Retrieve a key value from loaded configuration.\n\n Order of search if global_=False:\n 1/ environnment variables\n 2/ local configuration\n 3/ global configuration\n " ]
Please provide a description of the function:def configure(cls, global_, key, val): # first retrieve current configuration scope = 'global' if global_ else 'local' if scope not in cls._conffiles: cls._conffiles[scope] = {} config = cls._conffiles.get(scope, {}) ...
[ " Update and save configuration value to file. " ]
Please provide a description of the function:def init_config(cls): try: # first load current conf and only overwrite needed params # we don't want to reset everything config_file = os.path.expanduser(cls.home_config) config = cls.load(config_file, 'global...
[ " Initialize Gandi CLI configuration.\n\n Create global configuration directory with API credentials\n\n " ]
Please provide a description of the function:def info(gandi): output_keys = ['handle', 'credit', 'prepaid'] account = gandi.account.all() account['prepaid_info'] = gandi.contact.balance().get('prepaid', {}) output_account(gandi, account, output_keys) return account
[ "Display information about hosting account.\n " ]
Please provide a description of the function:def create(cls, ip_version, datacenter, bandwidth, vm=None, vlan=None, ip=None, background=False): return Iface.create(ip_version, datacenter, bandwidth, vlan, vm, ip, background)
[ " Create a public ip and attach it if vm is given. " ]
Please provide a description of the function:def update(cls, resource, params, background=False): cls.echo('Updating your IP') result = cls.call('hosting.ip.update', cls.usable_id(resource), params) if not background: cls.display_progress(result) ...
[ " Update this IP " ]
Please provide a description of the function:def resource_list(cls): items = cls.list({'items_per_page': 500}) ret = [str(ip['id']) for ip in items] ret.extend([ip['ip'] for ip in items]) return ret
[ " Get the possible list of resources (name, id). " ]
Please provide a description of the function:def attach(cls, ip, vm, background=False, force=False): vm_ = Iaas.info(vm) ip_ = cls.info(ip) if not cls._check_and_detach(ip_, vm_): return # then we should attach the ip to the vm attach = Iface._attach(ip_['if...
[ " Attach " ]
Please provide a description of the function:def delete(cls, resources, background=False, force=False): if not isinstance(resources, (list, tuple)): resources = [resources] ifaces = [] for item in resources: try: ip_ = cls.info(item) ...
[ "Delete an ip by deleting the iface" ]
Please provide a description of the function:def from_ip(cls, ip): ips = dict([(ip_['ip'], ip_['id']) for ip_ in cls.list({'items_per_page': 500})]) return ips.get(ip)
[ "Retrieve ip id associated to an ip." ]
Please provide a description of the function:def list(cls, datacenter=None): options = {} if datacenter: datacenter_id = int(Datacenter.usable_id(datacenter)) options['datacenter_id'] = datacenter_id return cls.call('hosting.vlan.list', options)
[ "List virtual machine vlan\n\n (in the future it should also handle PaaS vlan)." ]
Please provide a description of the function:def resource_list(cls): items = cls.list() ret = [vlan['name'] for vlan in items] ret.extend([str(vlan['id']) for vlan in items]) return ret
[ " Get the possible list of resources (name, id). " ]
Please provide a description of the function:def ifaces(cls, name): ifaces = Iface.list({'vlan_id': cls.usable_id(name)}) ret = [] for iface in ifaces: ret.append(Iface.info(iface['id'])) return ret
[ " Get vlan attached ifaces. " ]
Please provide a description of the function:def delete(cls, resources, background=False): if not isinstance(resources, (list, tuple)): resources = [resources] opers = [] for item in resources: oper = cls.call('hosting.vlan.delete', cls.usable_id(item)) ...
[ "Delete a vlan." ]
Please provide a description of the function:def create(cls, name, datacenter, subnet=None, gateway=None, background=False): if not background and not cls.intty(): background = True datacenter_id_ = int(Datacenter.usable_id(datacenter)) vlan_params = { ...
[ "Create a new vlan." ]
Please provide a description of the function:def update(cls, id, params): cls.echo('Updating your vlan.') result = cls.call('hosting.vlan.update', cls.usable_id(id), params) return result
[ "Update an existing vlan." ]
Please provide a description of the function:def from_name(cls, name): result = cls.list() vlans = {} for vlan in result: vlans[vlan['name']] = vlan['id'] return vlans.get(name)
[ "Retrieve vlan id associated to a name." ]
Please provide a description of the function:def usable_id(cls, id): try: qry_id = int(id) except Exception: qry_id = None if not qry_id: msg = 'unknown identifier %s' % id cls.error(msg) return qry_id
[ " Retrieve id from input which can be num or id." ]
Please provide a description of the function:def _attach(cls, iface_id, vm_id): oper = cls.call('hosting.vm.iface_attach', vm_id, iface_id) return oper
[ " Attach an iface to a vm. " ]
Please provide a description of the function:def create(cls, ip_version, datacenter, bandwidth, vlan, vm, ip, background): if not background and not cls.intty(): background = True datacenter_id_ = int(Datacenter.usable_id(datacenter)) iface_params = { ...
[ " Create a new iface " ]
Please provide a description of the function:def _detach(cls, iface_id): iface = cls._info(iface_id) opers = [] vm_id = iface.get('vm_id') if vm_id: cls.echo('The iface is still attached to the vm %s.' % vm_id) cls.echo('Will detach it.') oper...
[ " Detach an iface from a vm. " ]
Please provide a description of the function:def update(cls, id, bandwidth, vm, background): if not background and not cls.intty(): background = True iface_params = {} iface_id = cls.usable_id(id) if bandwidth: iface_params['bandwidth'] = bandwidth ...
[ " Update this iface. " ]
Please provide a description of the function:def create(cls, domain, source, destinations): cls.echo('Creating mail forward %s@%s' % (source, domain)) options = {'destinations': list(destinations)} result = cls.call('domain.forward.create', domain, source, options) return resul...
[ "Create a domain mail forward." ]
Please provide a description of the function:def get_destinations(cls, domain, source): forwards = cls.list(domain, {'items_per_page': 500}) for fwd in forwards: if fwd['source'] == source: return fwd['destinations'] return []
[ "Retrieve forward information." ]
Please provide a description of the function:def update(cls, domain, source, dest_add, dest_del): result = None if dest_add or dest_del: current_destinations = cls.get_destinations(domain, source) fwds = current_destinations[:] if dest_add: f...
[ "Update a domain mail forward destinations." ]
Please provide a description of the function:def list(gandi, domain, limit): options = {'items_per_page': limit} mailboxes = gandi.mail.list(domain, options) output_list(gandi, [mbox['login'] for mbox in mailboxes]) return mailboxes
[ "List mailboxes created on a domain." ]
Please provide a description of the function:def info(gandi, email): login, domain = email output_keys = ['login', 'aliases', 'fallback', 'quota', 'responder'] mailbox = gandi.mail.info(domain, login) output_mailbox(gandi, mailbox, output_keys) return mailbox
[ "Display information about a mailbox." ]
Please provide a description of the function:def create(gandi, email, quota, fallback, alias, password): login, domain = email options = {} if not password: password = click.prompt('password', hide_input=True, confirmation_prompt=True) options['password'] = ...
[ "Create a mailbox." ]
Please provide a description of the function:def delete(gandi, email, force): login, domain = email if not force: proceed = click.confirm('Are you sure to delete the ' 'mailbox %s@%s ?' % (login, domain)) if not proceed: return result = gan...
[ "Delete a mailbox." ]
Please provide a description of the function:def update(gandi, email, password, quota, fallback, alias_add, alias_del): options = {} if password: password = click.prompt('password', hide_input=True, confirmation_prompt=True) options['password'] = password ...
[ "Update a mailbox." ]
Please provide a description of the function:def purge(gandi, email, background, force, alias): login, domain = email if alias: if not force: proceed = click.confirm('Are you sure to purge all aliases for ' 'mailbox %s@%s ?' % (login, domain)) ...
[ "Purge a mailbox." ]
Please provide a description of the function:def from_name(cls, name): disks = cls.list({'name': name}) if len(disks) == 1: return disks[0]['id'] elif not disks: return raise DuplicateResults('disk name %s is ambiguous.' % name)
[ " Retrieve a disk id associated to a name. " ]
Please provide a description of the function:def list_create(cls, datacenter=None, label=None): options = { 'items_per_page': DISK_MAXLIST } if datacenter: datacenter_id = int(Datacenter.usable_id(datacenter)) options['datacenter_id'] = datacenter_id ...
[ "List available disks for vm creation." ]
Please provide a description of the function:def disk_param(name, size, snapshot_profile, cmdline=None, kernel=None): disk_params = {} if cmdline: disk_params['cmdline'] = cmdline if kernel: disk_params['kernel'] = kernel if name: disk_para...
[ " Return disk parameter structure. " ]