idx int64 0 251k | question stringlengths 53 3.53k | target stringlengths 5 1.23k | len_question int64 20 893 | len_target int64 3 238 |
|---|---|---|---|---|
242,900 | 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 = { 'name' : name , 'datacenter_id' : datacenter_id_ , } if subnet : vlan_params [ 'subn... | Create a new vlan . | 199 | 6 |
242,901 | 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 . | 55 | 6 |
242,902 | 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 . | 60 | 10 |
242,903 | 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 . | 60 | 12 |
242,904 | 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 . | 47 | 8 |
242,905 | 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 = { 'ip_version' : ip_version , 'datacenter_id' : datacenter_id_ , 'bandwidth' : bandwidth , ... | Create a new iface | 362 | 5 |
242,906 | 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.' ) opers . append ( cls . call ( 'hosting.vm.iface_detach' , vm_id , iface_id ) ) return opers | Detach an iface from a vm . | 123 | 9 |
242,907 | 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 if iface_params : result = cls . call ( 'hosting.iface.update' , iface_id , iface_params ) if... | Update this iface . | 243 | 5 |
242,908 | 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 . | 64 | 5 |
242,909 | 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 : for dest in dest_add : if dest not in fwds : fwds . append ( dest ) if dest_del : for dest in dest_del : ... | Update a domain mail forward destinations . | 203 | 7 |
242,910 | 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 . | 64 | 8 |
242,911 | 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 . | 72 | 6 |
242,912 | 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 = gandi . mail . delete ( domain , login ) return result | Delete a mailbox . | 71 | 4 |
242,913 | 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 . | 66 | 10 |
242,914 | 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 # implement a filter by label as API doesn't handle it images = cls . safe_call ( 'hosting.... | List available disks for vm creation . | 141 | 7 |
242,915 | 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_params [ 'name' ] = name if snapshot_profile is not None : disk_params [ 'snapshot_profile' ] = snapshot_pr... | Return disk parameter structure . | 111 | 5 |
242,916 | def update ( cls , resource , name , size , snapshot_profile , background , cmdline = None , kernel = None ) : if isinstance ( size , tuple ) : prefix , size = size if prefix == '+' : disk_info = cls . info ( resource ) current_size = disk_info [ 'size' ] size = current_size + size disk_params = cls . disk_param ( name... | Update this disk . | 167 | 4 |
242,917 | def _detach ( cls , disk_id ) : disk = cls . _info ( disk_id ) opers = [ ] if disk . get ( 'vms_id' ) : for vm_id in disk [ 'vms_id' ] : cls . echo ( 'The disk is still attached to the vm %s.' % vm_id ) cls . echo ( 'Will detach it.' ) opers . append ( cls . call ( 'hosting.vm.disk_detach' , vm_id , disk_id ) ) return ... | Detach a disk from a vm . | 125 | 8 |
242,918 | def delete ( cls , resources , background = False ) : if not isinstance ( resources , ( list , tuple ) ) : resources = [ resources ] resources = [ cls . usable_id ( item ) for item in resources ] opers = [ ] for disk_id in resources : opers . extend ( cls . _detach ( disk_id ) ) if opers : cls . echo ( 'Detaching your ... | Delete this disk . | 178 | 4 |
242,919 | def _attach ( cls , disk_id , vm_id , options = None ) : options = options or { } oper = cls . call ( 'hosting.vm.disk_attach' , vm_id , disk_id , options ) return oper | Attach a disk to a vm . | 56 | 7 |
242,920 | def create ( cls , name , vm , size , snapshotprofile , datacenter , source , disk_type = 'data' , background = False ) : if isinstance ( size , tuple ) : prefix , size = size if source : size = None disk_params = cls . disk_param ( name , size , snapshotprofile ) disk_params [ 'datacenter_id' ] = int ( Datacenter . us... | Create a disk and attach it to a vm . | 293 | 10 |
242,921 | def compatcallback ( f ) : if getattr ( click , '__version__' , '0.0' ) >= '2.0' : return f return update_wrapper ( lambda ctx , value : f ( ctx , None , value ) , f ) | Compatibility callback decorator for older click version . | 57 | 10 |
242,922 | def list_sub_commmands ( self , cmd_name , cmd ) : ret = { } if isinstance ( cmd , click . core . Group ) : for sub_cmd_name in cmd . commands : sub_cmd = cmd . commands [ sub_cmd_name ] sub = self . list_sub_commmands ( sub_cmd_name , sub_cmd ) if sub : if isinstance ( sub , dict ) : for n , c in sub . items ( ) : ret... | Return all commands for a group | 175 | 6 |
242,923 | def load_commands ( self ) : command_folder = os . path . join ( os . path . dirname ( __file__ ) , '..' , 'commands' ) command_dirs = { 'gandi.cli' : command_folder } if 'GANDICLI_PATH' in os . environ : for _path in os . environ . get ( 'GANDICLI_PATH' ) . split ( ':' ) : # remove trailing separator if any path = _pa... | Load cli commands from submodules . | 244 | 8 |
242,924 | def invoke ( self , ctx ) : ctx . obj = GandiContextHelper ( verbose = ctx . obj [ 'verbose' ] ) click . Group . invoke ( self , ctx ) | Invoke command in context . | 44 | 6 |
242,925 | def from_name ( cls , name ) : sshkeys = cls . list ( { 'name' : name } ) if len ( sshkeys ) == 1 : return sshkeys [ 0 ] [ 'id' ] elif not sshkeys : return raise DuplicateResults ( 'sshkey name %s is ambiguous.' % name ) | Retrieve a sshkey id associated to a name . | 71 | 11 |
242,926 | def usable_id ( cls , id ) : try : # id is maybe a sshkey name qry_id = cls . from_name ( id ) if not qry_id : qry_id = int ( id ) except DuplicateResults as exc : cls . error ( exc . errors ) 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 name or id . | 105 | 12 |
242,927 | def create ( cls , name , value ) : sshkey_params = { 'name' : name , 'value' : value , } result = cls . call ( 'hosting.ssh.create' , sshkey_params ) return result | Create a new ssh key . | 53 | 6 |
242,928 | def get_api_connector ( cls ) : if cls . _api is None : # pragma: no cover cls . load_config ( ) cls . debug ( 'initialize connection to remote server' ) apihost = cls . get ( 'api.host' ) if not apihost : raise MissingConfiguration ( ) apienv = cls . get ( 'api.env' ) if apienv and apienv in cls . apienvs : apihost = ... | Initialize an api connector for future use . | 152 | 9 |
242,929 | def call ( cls , method , * args , * * kwargs ) : api = None empty_key = kwargs . pop ( 'empty_key' , False ) try : api = cls . get_api_connector ( ) apikey = cls . get ( 'api.key' ) if not apikey and not empty_key : cls . echo ( "No apikey found, please use 'gandi setup' " "command" ) sys . exit ( 1 ) except MissingCo... | Call a remote api method and return the result . | 538 | 10 |
242,930 | def safe_call ( cls , method , * args ) : return cls . call ( method , * args , safe = True ) | Call a remote api method but don t raise if an error occurred . | 29 | 14 |
242,931 | def json_call ( cls , method , url , * * kwargs ) : # retrieve api key if needed empty_key = kwargs . pop ( 'empty_key' , False ) send_key = kwargs . pop ( 'send_key' , True ) return_header = kwargs . pop ( 'return_header' , False ) try : apikey = cls . get ( 'apirest.key' ) if not apikey and not empty_key : cls . echo... | Call a remote api using json format | 349 | 7 |
242,932 | def intty ( cls ) : # XXX: temporary hack until we can detect if we are in a pipe or not return True if hasattr ( sys . stdout , 'isatty' ) and sys . stdout . isatty ( ) : return True return False | Check if we are in a tty . | 58 | 9 |
242,933 | def pretty_echo ( cls , message ) : if cls . intty ( ) : if message : from pprint import pprint pprint ( message ) | Display message using pretty print formatting . | 34 | 7 |
242,934 | def dump ( cls , message ) : if cls . verbose > 2 : msg = '[DUMP] %s' % message cls . echo ( msg ) | Display dump message if verbose level allows it . | 36 | 10 |
242,935 | def debug ( cls , message ) : if cls . verbose > 1 : msg = '[DEBUG] %s' % message cls . echo ( msg ) | Display debug message if verbose level allows it . | 35 | 10 |
242,936 | def log ( cls , message ) : if cls . verbose > 0 : msg = '[INFO] %s' % message cls . echo ( msg ) | Display info message if verbose level allows it . | 35 | 10 |
242,937 | def exec_output ( cls , command , shell = True , encoding = 'utf-8' ) : proc = Popen ( command , shell = shell , stdout = PIPE ) stdout , _stderr = proc . communicate ( ) if proc . returncode == 0 : return stdout . decode ( encoding ) return '' | Return execution output | 72 | 3 |
242,938 | def update_progress ( cls , progress , starttime ) : width , _height = click . get_terminal_size ( ) if not width : return duration = datetime . utcnow ( ) - starttime hours , remainder = divmod ( duration . seconds , 3600 ) minutes , seconds = divmod ( remainder , 60 ) size = int ( width * .6 ) status = "" if isinstan... | Display an ascii progress bar while processing operation . | 272 | 11 |
242,939 | def display_progress ( cls , operations ) : start_crea = datetime . utcnow ( ) # count number of operations, 3 steps per operation if not isinstance ( operations , ( list , tuple ) ) : operations = [ operations ] count_operations = len ( operations ) * 3 updating_done = False while not updating_done : op_score = 0 for ... | Display progress of Gandi operations . | 321 | 7 |
242,940 | def load_modules ( self ) : module_folder = os . path . join ( os . path . dirname ( __file__ ) , '..' , 'modules' ) module_dirs = { 'gandi.cli' : module_folder } if 'GANDICLI_PATH' in os . environ : for _path in os . environ . get ( 'GANDICLI_PATH' ) . split ( ':' ) : # remove trailing separator if any path = _path . ... | Import CLI commands modules . | 279 | 5 |
242,941 | def request ( self , method , apikey , * args , * * kwargs ) : dry_run = kwargs . get ( 'dry_run' , False ) return_dry_run = kwargs . get ( 'return_dry_run' , False ) if return_dry_run : args [ - 1 ] [ '--dry-run' ] = True try : func = getattr ( self . endpoint , method ) return func ( apikey , * args ) except ( socket... | Make a xml - rpc call to remote API . | 255 | 11 |
242,942 | def request ( cls , method , url , * * kwargs ) : user_agent = 'gandi.cli/%s' % __version__ headers = { 'User-Agent' : user_agent , 'Content-Type' : 'application/json; charset=utf-8' } if kwargs . get ( 'headers' ) : headers . update ( kwargs . pop ( 'headers' ) ) try : response = requests . request ( method , url , he... | Make a http call to a remote API and return a json response . | 323 | 14 |
242,943 | def docker ( gandi , vm , args ) : if not [ basedir for basedir in os . getenv ( 'PATH' , '.:/usr/bin' ) . split ( ':' ) if os . path . exists ( '%s/docker' % basedir ) ] : gandi . echo ( """'docker' not found in $PATH, required for this command \ to work See https://docs.docker.com/installation/#installation to instal... | Manage docker instance | 283 | 4 |
242,944 | def query ( cls , resources , time_range , query , resource_type , sampler ) : if not isinstance ( resources , ( list , tuple ) ) : resources = [ resources ] now = time . time ( ) start_utc = datetime . utcfromtimestamp ( now - time_range ) end_utc = datetime . utcfromtimestamp ( now ) date_format = '%Y-%m-%d %H:%M:%S'... | Query statistics for given resources . | 199 | 6 |
242,945 | def required_max_memory ( cls , id , memory ) : best = int ( max ( 2 ** math . ceil ( math . log ( memory , 2 ) ) , 2048 ) ) actual_vm = cls . info ( id ) if ( actual_vm [ 'state' ] == 'running' and actual_vm [ 'vm_max_memory' ] != best ) : return best | Recommend a max_memory setting for this vm given memory . If the VM already has a nice setting return None . The max_memory param cannot be fixed too high because page table allocation would cost too much for small memory profile . Use a range as below . | 85 | 52 |
242,946 | def need_finalize ( cls , resource ) : vm_id = cls . usable_id ( resource ) params = { 'type' : 'hosting_migration_vm' , 'step' : 'RUN' , 'vm_id' : vm_id } result = cls . call ( 'operation.list' , params ) if not result or len ( result ) > 1 : raise MigrationNotFinalized ( 'Cannot find VM %s ' 'migration operation.' % ... | Check if vm migration need to be finalized . | 166 | 9 |
242,947 | def check_can_migrate ( cls , resource ) : vm_id = cls . usable_id ( resource ) result = cls . call ( 'hosting.vm.can_migrate' , vm_id ) if not result [ 'can_migrate' ] : if result [ 'matched' ] : matched = result [ 'matched' ] [ 0 ] cls . echo ( 'Your VM %s cannot be migrated yet. Migration will ' 'be available when d... | Check if virtual machine can be migrated to another datacenter . | 141 | 13 |
242,948 | def from_hostname ( cls , hostname ) : result = cls . list ( { 'hostname' : str ( hostname ) } ) if result : return result [ 0 ] [ 'id' ] | Retrieve virtual machine id associated to a hostname . | 46 | 11 |
242,949 | def wait_for_sshd ( cls , vm_id ) : cls . echo ( 'Waiting for the vm to come online' ) version , ip_addr = cls . vm_ip ( vm_id ) give_up = time . time ( ) + 300 last_error = None while time . time ( ) < give_up : try : inet = socket . AF_INET if version == 6 : inet = socket . AF_INET6 sd = socket . socket ( inet , sock... | Insist on having the vm booted and sshd listening | 261 | 10 |
242,950 | def ssh_keyscan ( cls , vm_id ) : cls . echo ( 'Wiping old key and learning the new one' ) _version , ip_addr = cls . vm_ip ( vm_id ) cls . execute ( 'ssh-keygen -R "%s"' % ip_addr ) for _ in range ( 5 ) : output = cls . exec_output ( 'ssh-keyscan "%s"' % ip_addr ) if output : with open ( os . path . expanduser ( '~/.s... | Wipe this old key and learn the new one from a freshly created vm . This is a security risk for this VM however we dont have another way to learn the key yet so do this for the user . | 146 | 42 |
242,951 | def scp ( cls , vm_id , login , identity , local_file , remote_file ) : cmd = [ 'scp' ] if identity : cmd . extend ( ( '-i' , identity , ) ) version , ip_addr = cls . vm_ip ( vm_id ) if version == 6 : ip_addr = '[%s]' % ip_addr cmd . extend ( ( local_file , '%s@%s:%s' % ( login , ip_addr , remote_file ) , ) ) cls . ech... | Copy file to remote VM . | 168 | 6 |
242,952 | def ssh ( cls , vm_id , login , identity , args = None ) : cmd = [ 'ssh' ] if identity : cmd . extend ( ( '-i' , identity , ) ) version , ip_addr = cls . vm_ip ( vm_id ) if version == 6 : cmd . append ( '-6' ) if not ip_addr : cls . echo ( 'No IP address found for vm %s, aborting.' % vm_id ) return cmd . append ( '%s@%... | Spawn an ssh session to virtual machine . | 168 | 8 |
242,953 | def is_deprecated ( cls , label , datacenter = None ) : images = cls . list ( datacenter , label ) images_visibility = dict ( [ ( image [ 'label' ] , image [ 'visibility' ] ) for image in images ] ) return images_visibility . get ( label , 'all' ) == 'deprecated' | Check if image if flagged as deprecated . | 80 | 8 |
242,954 | def from_label ( cls , label , datacenter = None ) : result = cls . list ( datacenter = datacenter ) image_labels = dict ( [ ( image [ 'label' ] , image [ 'disk_id' ] ) for image in result ] ) return image_labels . get ( label ) | Retrieve disk image id associated to a label . | 73 | 10 |
242,955 | def from_sysdisk ( cls , label ) : disks = cls . safe_call ( 'hosting.disk.list' , { 'name' : label } ) if len ( disks ) : return disks [ 0 ] [ 'id' ] | Retrieve disk id from available system disks | 54 | 8 |
242,956 | def usable_id ( cls , id , datacenter = None ) : try : qry_id = int ( id ) except Exception : # if id is a string, prefer a system disk then a label qry_id = cls . from_sysdisk ( id ) or cls . from_label ( id , datacenter ) if not qry_id : msg = 'unknown identifier %s' % id cls . error ( msg ) return qry_id | Retrieve id from input which can be label or id . | 103 | 12 |
242,957 | def list ( cls , datacenter = None , flavor = None , match = '' , exact_match = False ) : if not datacenter : dc_ids = [ dc [ 'id' ] for dc in Datacenter . filtered_list ( ) ] kmap = { } for dc_id in dc_ids : vals = cls . safe_call ( 'hosting.disk.list_kernels' , dc_id ) for key in vals : kmap . setdefault ( key , [ ] ... | List available kernels for datacenter . | 302 | 8 |
242,958 | def is_available ( cls , disk , kernel ) : kmap = cls . list ( disk [ 'datacenter_id' ] , None , kernel , True ) for flavor in kmap : if kernel in kmap [ flavor ] : return True return False | Check if kernel is available for disk . | 57 | 8 |
242,959 | def clone ( cls , name , vhost , directory , origin ) : paas_info = cls . info ( name ) if 'php' in paas_info [ 'type' ] and not vhost : cls . error ( 'PHP instances require indicating the VHOST to clone ' 'with --vhost <vhost>' ) paas_access = '%s@%s' % ( paas_info [ 'user' ] , paas_info [ 'git_server' ] ) remote_url ... | Clone a PaaS instance s vhost into a local git repository . | 231 | 16 |
242,960 | def attach ( cls , name , vhost , remote_name ) : paas_access = cls . get ( 'paas_access' ) if not paas_access : paas_info = cls . info ( name ) paas_access = '%s@%s' % ( paas_info [ 'user' ] , paas_info [ 'git_server' ] ) remote_url = 'ssh+git://%s/%s.git' % ( paas_access , vhost ) ret = cls . execute ( 'git remote ad... | Attach an instance s vhost to a remote from the local repository . | 225 | 14 |
242,961 | def cache ( cls , id ) : sampler = { 'unit' : 'days' , 'value' : 1 , 'function' : 'sum' } query = 'webacc.requests.cache.all' metrics = Metric . query ( id , 60 * 60 * 24 , query , 'paas' , sampler ) cache = { 'hit' : 0 , 'miss' : 0 , 'not' : 0 , 'pass' : 0 } for metric in metrics : what = metric [ 'cache' ] . pop ( ) ... | return the number of query cache for the last 24H | 147 | 11 |
242,962 | def create ( cls , name , size , type , quantity , duration , datacenter , vhosts , password , snapshot_profile , background , sshkey ) : if not background and not cls . intty ( ) : background = True datacenter_id_ = int ( Datacenter . usable_id ( datacenter ) ) paas_params = { 'name' : name , 'size' : size , 'type' : ... | Create a new PaaS instance . | 300 | 8 |
242,963 | def console ( cls , id ) : oper = cls . call ( 'paas.update' , cls . usable_id ( id ) , { 'console' : 1 } ) cls . echo ( 'Activation of the console on your PaaS instance' ) cls . display_progress ( oper ) console_url = Paas . info ( cls . usable_id ( id ) ) [ 'console' ] access = 'ssh %s' % console_url cls . execute ( ... | Open a console to a PaaS instance . | 111 | 10 |
242,964 | def from_vhost ( cls , vhost ) : result = Vhost ( ) . list ( ) paas_hosts = { } for host in result : paas_hosts [ host [ 'name' ] ] = host [ 'paas_id' ] return paas_hosts . get ( vhost ) | Retrieve paas instance id associated to a vhost . | 71 | 12 |
242,965 | def from_hostname ( cls , hostname ) : result = cls . list ( { 'items_per_page' : 500 } ) paas_hosts = { } for host in result : paas_hosts [ host [ 'name' ] ] = host [ 'id' ] return paas_hosts . get ( hostname ) | Retrieve paas instance id associated to a host . | 77 | 11 |
242,966 | def list_names ( cls ) : ret = dict ( [ ( item [ 'id' ] , item [ 'name' ] ) for item in cls . list ( { 'items_per_page' : 500 } ) ] ) return ret | Retrieve paas id and names . | 53 | 8 |
242,967 | def from_cn ( cls , common_name ) : # search with cn result_cn = [ ( cert [ 'id' ] , [ cert [ 'cn' ] ] + cert [ 'altnames' ] ) for cert in cls . list ( { 'status' : [ 'pending' , 'valid' ] , 'items_per_page' : 500 , 'cn' : common_name } ) ] # search with altname result_alt = [ ( cert [ 'id' ] , [ cert [ 'cn' ] ] + cert... | Retrieve a certificate by its common name . | 247 | 9 |
242,968 | def usable_ids ( cls , id , accept_multi = True ) : try : qry_id = [ int ( id ) ] except ValueError : try : qry_id = cls . from_cn ( id ) except Exception : qry_id = None if not qry_id or not accept_multi and len ( qry_id ) != 1 : msg = 'unknown identifier %s' % id cls . error ( msg ) return qry_id if accept_multi else... | Retrieve id from input which can be an id or a cn . | 115 | 15 |
242,969 | def package_list ( cls , options = None ) : options = options or { } try : return cls . safe_call ( 'cert.package.list' , options ) except UsageError as err : if err . code == 150020 : return [ ] raise | List possible certificate packages . | 57 | 5 |
242,970 | def advice_dcv_method ( cls , csr , package , altnames , dcv_method , cert_id = None ) : params = { 'csr' : csr , 'package' : package , 'dcv_method' : dcv_method } if cert_id : params [ 'cert_id' ] = cert_id result = cls . call ( 'cert.get_dcv_params' , params ) if dcv_method == 'dns' : cls . echo ( 'You have to add th... | Display dcv_method information . | 147 | 7 |
242,971 | def create_csr ( cls , common_name , private_key = None , params = None ) : params = params or [ ] params = [ ( key , val ) for key , val in params if val ] subj = '/' + '/' . join ( [ '=' . join ( value ) for value in params ] ) cmd , private_key = cls . gen_pk ( common_name , private_key ) if private_key . endswith (... | Create CSR . | 236 | 4 |
242,972 | def get_common_name ( cls , csr ) : from tempfile import NamedTemporaryFile fhandle = NamedTemporaryFile ( ) fhandle . write ( csr . encode ( 'latin1' ) ) fhandle . flush ( ) output = cls . exec_output ( 'openssl req -noout -subject -in %s' % fhandle . name ) if not output : return common_name = output . split ( '=' ) ... | Read information from CSR . | 117 | 6 |
242,973 | def process_csr ( cls , common_name , csr = None , private_key = None , country = None , state = None , city = None , organisation = None , branch = None ) : if csr : if branch or organisation or city or state or country : cls . echo ( 'Following options are only used to generate' ' the CSR.' ) else : params = ( ( 'CN'... | Create a PK and a CSR if needed . | 211 | 10 |
242,974 | def pretty_format_cert ( cls , cert ) : crt = cert . get ( 'cert' ) if crt : crt = ( '-----BEGIN CERTIFICATE-----\n' + '\n' . join ( [ crt [ index * 64 : ( index + 1 ) * 64 ] for index in range ( int ( len ( crt ) / 64 ) + 1 ) ] ) . rstrip ( '\n' ) + # noqa '\n-----END CERTIFICATE-----' ) return crt | Pretty display of a certificate . | 116 | 6 |
242,975 | def info ( gandi , resource , format ) : result = gandi . webacc . info ( resource ) if format : output_json ( gandi , format , result ) return result output_base = { 'name' : result [ 'name' ] , 'algorithm' : result [ 'lb' ] [ 'algorithm' ] , 'datacenter' : result [ 'datacenter' ] [ 'name' ] , 'state' : result [ 'stat... | Display information about a webaccelerator | 615 | 8 |
242,976 | def delete ( gandi , webacc , vhost , backend , port ) : result = [ ] if webacc : result = gandi . webacc . delete ( webacc ) if backend : backends = backend for backend in backends : if 'port' not in backend : if not port : backend [ 'port' ] = click . prompt ( 'Please set a port for ' 'backends. If you want to ' ' di... | Delete a webaccelerator a vhost or a backend | 175 | 12 |
242,977 | def add ( gandi , resource , vhost , zone_alter , backend , port , ssl , private_key , poll_cert ) : result = [ ] if backend : backends = backend for backend in backends : # Check if a port is set for each backend, else set a default port if 'port' not in backend : if not port : backend [ 'port' ] = click . prompt ( 'P... | Add a backend or a vhost on a webaccelerator | 247 | 13 |
242,978 | def enable ( gandi , resource , backend , port , probe ) : result = [ ] if backend : backends = backend for backend in backends : if 'port' not in backend : if not port : backend [ 'port' ] = click . prompt ( 'Please set a port for ' 'backends. If you want to ' ' different port for ' 'each backend, use `-b ' 'ip:port`'... | Enable a backend or a probe on a webaccelerator | 162 | 12 |
242,979 | def disable ( gandi , resource , backend , port , probe ) : result = [ ] if backend : backends = backend for backend in backends : if 'port' not in backend : if not port : backend [ 'port' ] = click . prompt ( 'Please set a port for ' 'backends. If you want to ' ' different port for ' 'each backend, use `-b ' 'ip:port`... | Disable a backend or a probe on a webaccelerator | 162 | 12 |
242,980 | def probe ( gandi , resource , enable , disable , test , host , interval , http_method , http_response , threshold , timeout , url , window ) : result = gandi . webacc . probe ( resource , enable , disable , test , host , interval , http_method , http_response , threshold , timeout , url , window ) output_keys = [ 'sta... | Manage a probe for a webaccelerator | 105 | 10 |
242,981 | def domain_list ( gandi ) : domains = gandi . dns . list ( ) for domain in domains : gandi . echo ( domain [ 'fqdn' ] ) return domains | List domains manageable by REST API . | 41 | 7 |
242,982 | def list ( gandi , fqdn , name , sort , type , rrset_type , text ) : domains = gandi . dns . list ( ) domains = [ domain [ 'fqdn' ] for domain in domains ] if fqdn not in domains : gandi . echo ( 'Sorry domain %s does not exist' % fqdn ) gandi . echo ( 'Please use one of the following: %s' % ', ' . join ( domains ) ) r... | Display records for a domain . | 261 | 6 |
242,983 | def create ( gandi , fqdn , name , type , value , ttl ) : domains = gandi . dns . list ( ) domains = [ domain [ 'fqdn' ] for domain in domains ] if fqdn not in domains : gandi . echo ( 'Sorry domain %s does not exist' % fqdn ) gandi . echo ( 'Please use one of the following: %s' % ', ' . join ( domains ) ) return resul... | Create new record entry for a domain . | 137 | 8 |
242,984 | def update ( gandi , fqdn , name , type , value , ttl , file ) : domains = gandi . dns . list ( ) domains = [ domain [ 'fqdn' ] for domain in domains ] if fqdn not in domains : gandi . echo ( 'Sorry domain %s does not exist' % fqdn ) gandi . echo ( 'Please use one of the following: %s' % ', ' . join ( domains ) ) retur... | Update record entry for a domain . | 248 | 7 |
242,985 | def delete ( gandi , fqdn , name , type , force ) : domains = gandi . dns . list ( ) domains = [ domain [ 'fqdn' ] for domain in domains ] if fqdn not in domains : gandi . echo ( 'Sorry domain %s does not exist' % fqdn ) gandi . echo ( 'Please use one of the following: %s' % ', ' . join ( domains ) ) return if not forc... | Delete record entry for a domain . | 255 | 7 |
242,986 | def keys_list ( gandi , fqdn ) : keys = gandi . dns . keys ( fqdn ) output_keys = [ 'uuid' , 'algorithm' , 'algorithm_name' , 'ds' , 'flags' , 'status' ] for num , key in enumerate ( keys ) : if num : gandi . separator_line ( ) output_generic ( gandi , key , output_keys , justify = 15 ) return keys | List domain keys . | 103 | 4 |
242,987 | def keys_info ( gandi , fqdn , key ) : key_info = gandi . dns . keys_info ( fqdn , key ) output_keys = [ 'uuid' , 'algorithm' , 'algorithm_name' , 'ds' , 'fingerprint' , 'public_key' , 'flags' , 'tag' , 'status' ] output_generic ( gandi , key_info , output_keys , justify = 15 ) return key_info | Display information about a domain key . | 107 | 7 |
242,988 | def keys_create ( gandi , fqdn , flag ) : key_info = gandi . dns . keys_create ( fqdn , int ( flag ) ) output_keys = [ 'uuid' , 'algorithm' , 'algorithm_name' , 'ds' , 'fingerprint' , 'public_key' , 'flags' , 'tag' , 'status' ] output_generic ( gandi , key_info , output_keys , justify = 15 ) return key_info | Create key for a domain . | 110 | 6 |
242,989 | def handle ( cls , vm , args ) : docker = Iaas . info ( vm ) if not docker : raise Exception ( 'docker vm %s not found' % vm ) if docker [ 'state' ] != 'running' : Iaas . start ( vm ) # XXX remote_addr = docker [ 'ifaces' ] [ 0 ] [ 'ips' ] [ 0 ] [ 'ip' ] port = unixpipe . setup ( remote_addr , 'root' , '/var/run/docker... | Setup forwarding connection to given VM and pipe docker cmds over SSH . | 190 | 14 |
242,990 | def list ( gandi , state , id , limit , datacenter ) : options = { 'items_per_page' : limit , } if state : options [ 'state' ] = state if datacenter : options [ 'datacenter_id' ] = gandi . datacenter . usable_id ( datacenter ) output_keys = [ 'hostname' , 'state' ] if id : output_keys . append ( 'id' ) result = gandi .... | List virtual machines . | 154 | 4 |
242,991 | def info ( gandi , resource , stat ) : output_keys = [ 'hostname' , 'state' , 'cores' , 'memory' , 'console' , 'datacenter' , 'ip' ] justify = 14 if stat is True : sampler = { 'unit' : 'hours' , 'value' : 1 , 'function' : 'max' } time_range = 3600 * 24 query_vif = 'vif.bytes.all' query_vbd = 'vbd.bytes.all' resource = ... | Display information about a virtual machine . | 422 | 7 |
242,992 | def ssh ( gandi , resource , login , identity , wipe_key , wait , args ) : if '@' in resource : ( login , resource ) = resource . split ( '@' , 1 ) if wipe_key : gandi . iaas . ssh_keyscan ( resource ) if wait : gandi . iaas . wait_for_sshd ( resource ) gandi . iaas . ssh ( resource , login , identity , args ) | Spawn an SSH session to virtual machine . | 99 | 8 |
242,993 | def images ( gandi , label , datacenter ) : output_keys = [ 'label' , 'os_arch' , 'kernel_version' , 'disk_id' , 'dc' , 'name' ] datacenters = gandi . datacenter . list ( ) result = gandi . image . list ( datacenter , label ) for num , image in enumerate ( result ) : if num : gandi . separator_line ( ) output_image ( g... | List available system images for virtual machines . | 172 | 8 |
242,994 | def kernels ( gandi , vm , datacenter , flavor , match ) : if vm : vm = gandi . iaas . info ( vm ) dc_list = gandi . datacenter . filtered_list ( datacenter , vm ) for num , dc in enumerate ( dc_list ) : if num : gandi . echo ( '\n' ) output_datacenter ( gandi , dc , [ 'dc_name' ] ) kmap = gandi . kernel . list ( dc [ ... | List available kernels . | 157 | 4 |
242,995 | def datacenters ( gandi , id ) : output_keys = [ 'iso' , 'name' , 'country' , 'dc_code' , 'status' ] if id : output_keys . append ( 'id' ) result = gandi . datacenter . list ( ) for num , dc in enumerate ( result ) : if num : gandi . separator_line ( ) output_datacenter ( gandi , dc , output_keys , justify = 10 ) retur... | List available datacenters . | 107 | 6 |
242,996 | def usable_id ( cls , id ) : hcs = cls . from_fqdn ( id ) if hcs : return [ hc_ [ 'id' ] for hc_ in hcs ] try : return int ( id ) except ( TypeError , ValueError ) : pass | Retrieve id from single input . | 64 | 7 |
242,997 | def infos ( cls , fqdn ) : if isinstance ( fqdn , ( list , tuple ) ) : ids = [ ] for fqd_ in fqdn : ids . extend ( cls . infos ( fqd_ ) ) return ids ids = cls . usable_id ( fqdn ) if not ids : return [ ] if not isinstance ( ids , ( list , tuple ) ) : ids = [ ids ] return [ cls . info ( id_ ) for id_ in ids ] | Display information about hosted certificates for a fqdn . | 123 | 11 |
242,998 | def create ( cls , key , crt ) : options = { 'crt' : crt , 'key' : key } return cls . call ( 'cert.hosted.create' , options ) | Add a new crt in the hosted cert store . | 46 | 11 |
242,999 | def list ( gandi , limit ) : options = { 'items_per_page' : limit } domains = gandi . domain . list ( options ) for domain in domains : gandi . echo ( domain [ 'fqdn' ] ) return domains | List domains . | 54 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.