idx int64 0 251k | question stringlengths 53 3.53k | target stringlengths 5 1.23k | len_question int64 20 893 | len_target int64 3 238 |
|---|---|---|---|---|
243,000 | def info ( gandi , resource ) : output_keys = [ 'fqdn' , 'nameservers' , 'services' , 'zone_id' , 'tags' , 'created' , 'expires' , 'updated' ] contact_field = [ 'owner' , 'admin' , 'bill' , 'tech' , 'reseller' ] result = gandi . domain . info ( resource ) output_contact_info ( gandi , result [ 'contacts' ] , contact_fi... | Display information about a domain . | 134 | 6 |
243,001 | def create ( gandi , resource , domain , duration , owner , admin , tech , bill , nameserver , extra_parameter , background ) : if domain : gandi . echo ( '/!\ --domain option is deprecated and will be removed ' 'upon next release.' ) gandi . echo ( "You should use 'gandi domain create %s' instead." % domain ) if ( dom... | Buy a domain . | 206 | 4 |
243,002 | def api ( gandi ) : key_name = 'API version' result = gandi . api . info ( ) result [ key_name ] = result . pop ( 'api_version' ) output_generic ( gandi , result , [ key_name ] ) return result | Display information about API used . | 59 | 6 |
243,003 | def help ( ctx , command ) : command = ' ' . join ( command ) if not command : click . echo ( cli . get_help ( ctx ) ) return cmd = cli . get_command ( ctx , command ) if cmd : click . echo ( cmd . get_help ( ctx ) ) else : click . echo ( cli . get_help ( ctx ) ) | Display help for a command . | 86 | 6 |
243,004 | def status ( gandi , service ) : if not service : global_status = gandi . status . status ( ) if global_status [ 'status' ] == 'FOGGY' : # something is going on but not affecting services filters = { 'category' : 'Incident' , 'current' : True , } events = gandi . status . events ( filters ) for event in events : if eve... | Display current status from status . gandi . net . | 356 | 11 |
243,005 | def list ( gandi , domain , limit ) : options = { 'items_per_page' : limit } result = gandi . forward . list ( domain , options ) for forward in result : output_forward ( gandi , domain , forward ) return result | List mail forwards for a domain . | 55 | 7 |
243,006 | def update ( gandi , address , dest_add , dest_del ) : source , domain = address if not dest_add and not dest_del : gandi . echo ( 'Nothing to update: you must provide destinations to ' 'update, use --dest-add/-a or -dest-del/-d parameters.' ) return result = gandi . forward . update ( domain , source , dest_add , dest... | Update a domain mail forward . | 93 | 6 |
243,007 | def delete ( gandi , address , force ) : source , domain = address if not force : proceed = click . confirm ( 'Are you sure to delete the domain ' 'mail forward %s@%s ?' % ( source , domain ) ) if not proceed : return result = gandi . forward . delete ( domain , source ) return result | Delete a domain mail forward . | 72 | 6 |
243,008 | def list ( gandi , domain , zone_id , output , format , limit ) : options = { 'items_per_page' : limit , } output_keys = [ 'name' , 'type' , 'value' , 'ttl' ] if not zone_id : result = gandi . domain . info ( domain ) zone_id = result [ 'zone_id' ] if not zone_id : gandi . echo ( 'No zone records found, domain %s doesn... | List DNS zone records for a domain . | 458 | 8 |
243,009 | def create ( gandi , domain , zone_id , name , type , value , ttl ) : if not zone_id : result = gandi . domain . info ( domain ) zone_id = result [ 'zone_id' ] if not zone_id : gandi . echo ( 'No zone records found, domain %s doesn\'t seems to be ' 'managed at Gandi.' % domain ) return record = { 'type' : type , 'name'... | Create new DNS zone record entry for a domain . | 140 | 10 |
243,010 | def delete ( gandi , domain , zone_id , name , type , value ) : if not zone_id : result = gandi . domain . info ( domain ) zone_id = result [ 'zone_id' ] if not zone_id : gandi . echo ( 'No zone records found, domain %s doesn\'t seems to be ' 'managed at Gandi.' % domain ) return if not name and not type and not value ... | Delete a record entry for a domain | 183 | 7 |
243,011 | def update ( gandi , domain , zone_id , file , record , new_record ) : if not zone_id : result = gandi . domain . info ( domain ) zone_id = result [ 'zone_id' ] if not zone_id : gandi . echo ( 'No zone records found, domain %s doesn\'t seems to be' ' managed at Gandi.' % domain ) return if file : records = file . read ... | Update records entries for a domain . | 178 | 7 |
243,012 | def set_alias ( cls , domain , login , aliases ) : return cls . call ( 'domain.mailbox.alias.set' , domain , login , aliases ) | Update aliases on a mailbox . | 38 | 6 |
243,013 | def list ( cls , zone_id , options = None ) : options = options if options else { } return cls . call ( 'domain.zone.record.list' , zone_id , 0 , options ) | List zone records for a zone . | 47 | 7 |
243,014 | def add ( cls , zone_id , version_id , record ) : return cls . call ( 'domain.zone.record.add' , zone_id , version_id , record ) | Add record to a zone . | 43 | 6 |
243,015 | def create ( cls , zone_id , record ) : cls . echo ( 'Creating new zone version' ) new_version_id = Zone . new ( zone_id ) cls . echo ( 'Updating zone version' ) cls . add ( zone_id , new_version_id , record ) cls . echo ( 'Activation of new zone version' ) Zone . set ( zone_id , new_version_id ) return new_version_id | Create a new zone version for record . | 102 | 8 |
243,016 | def delete ( cls , zone_id , record ) : cls . echo ( 'Creating new zone record' ) new_version_id = Zone . new ( zone_id ) cls . echo ( 'Deleting zone record' ) cls . call ( 'domain.zone.record.delete' , zone_id , new_version_id , record ) cls . echo ( 'Activation of new zone version' ) Zone . set ( zone_id , new_versio... | Delete a record for a zone | 113 | 6 |
243,017 | def zone_update ( cls , zone_id , records ) : cls . echo ( 'Creating new zone file' ) new_version_id = Zone . new ( zone_id ) cls . echo ( 'Updating zone records' ) cls . call ( 'domain.zone.record.set' , zone_id , new_version_id , records ) cls . echo ( 'Activation of new zone version' ) Zone . set ( zone_id , new_ver... | Update records for a zone | 114 | 5 |
243,018 | def update ( cls , zone_id , old_record , new_record ) : cls . echo ( 'Creating new zone file' ) new_version_id = Zone . new ( zone_id ) new_record = new_record . replace ( ' IN' , '' ) new_record = new_record . split ( ' ' , 4 ) params_newrecord = { 'name' : new_record [ 0 ] , 'ttl' : int ( new_record [ 1 ] ) , 'type'... | Update a record in a zone file | 447 | 7 |
243,019 | def list ( gandi , limit , id , names ) : options = { 'items_per_page' : limit , } output_keys = [ 'name' , 'state' , 'date_creation' ] if id : # When we will have more than paas vhost, we will append rproxy_id output_keys . append ( 'paas_id' ) paas_names = { } if names : output_keys . append ( 'paas_name' ) paas_name... | List vhosts . | 197 | 5 |
243,020 | def info ( gandi , resource , id ) : output_keys = [ 'name' , 'state' , 'date_creation' , 'paas_name' , 'ssl' ] if id : # When we will have more than paas vhost, we will append rproxy_id output_keys . append ( 'paas_id' ) paas_names = gandi . paas . list_names ( ) ret = [ ] paas = None for num , item in enumerate ( res... | Display information about a vhost . | 237 | 7 |
243,021 | def update ( gandi , resource , ssl , private_key , poll_cert ) : gandi . hostedcert . activate_ssl ( resource , ssl , private_key , poll_cert ) | Update a vhost . | 43 | 5 |
243,022 | def option ( * param_decls , * * attrs ) : def decorator ( f ) : _param_memo ( f , GandiOption ( param_decls , * * attrs ) ) return f return decorator | Attach an option to the command . | 50 | 7 |
243,023 | def choices ( self ) : if not self . _choices : gandi = self . gandi or GandiContextHelper ( ) self . _choices = self . _get_choices ( gandi ) if not self . _choices : api = gandi . get_api_connector ( ) gandi . echo ( 'Please check that you are connecting to the good ' "api '%s' and that it's running." % ( api . host ... | Retrieve choices from API if possible | 113 | 7 |
243,024 | def convert ( self , value , param , ctx ) : self . gandi = ctx . obj # remove deprecated * prefix choices = [ choice . replace ( '*' , '' ) for choice in self . choices ] value = value . replace ( '*' , '' ) # Exact match if value in choices : return value # Try to find 64 bits version new_value = '%s 64 bits' % value... | Try to find correct disk image regarding version . | 185 | 9 |
243,025 | def convert ( self , value , param , ctx ) : self . gandi = ctx . obj # Exact match first if value in self . choices : return value # Also try with x86-64 suffix new_value = '%s-x86_64' % value if new_value in self . choices : return new_value self . fail ( 'invalid choice: %s. (choose from %s)' % ( value , ', ' . join... | Try to find correct kernel regarding version . | 112 | 8 |
243,026 | def convert ( self , value , param , ctx ) : self . gandi = ctx . obj value = click . Choice . convert ( self , value , param , ctx ) return int ( value ) | Convert value to int . | 44 | 6 |
243,027 | def display_value ( self , ctx , value ) : gandi = ctx . obj gandi . log ( '%s: %s' % ( self . name , ( value if value is not None else 'Not found' ) ) ) | Display value to be used for this parameter . | 53 | 9 |
243,028 | def get_default ( self , ctx ) : value = click . Option . get_default ( self , ctx ) if not self . prompt : # value found in default display it self . display_value ( ctx , value ) return value | Retrieve default value and display it when prompt disabled . | 52 | 11 |
243,029 | def consume_value ( self , ctx , opts ) : value = click . Option . consume_value ( self , ctx , opts ) if not value : # value not found by click on command line # now check using our context helper in order into # local configuration # global configuration gandi = ctx . obj value = gandi . get ( self . name ) if value ... | Retrieve default value and display it when prompt is disabled . | 179 | 12 |
243,030 | def create ( cls , fqdn , duration , owner , admin , tech , bill , nameserver , extra_parameter , background ) : fqdn = fqdn . lower ( ) if not background and not cls . intty ( ) : background = True result = cls . call ( 'domain.available' , [ fqdn ] ) while result [ fqdn ] == 'pending' : time . sleep ( 1 ) result = cl... | Create a domain . | 398 | 4 |
243,031 | def from_fqdn ( cls , fqdn ) : result = cls . list ( { 'fqdn' : fqdn } ) if len ( result ) > 0 : return result [ 0 ] [ 'id' ] | Retrieve domain id associated to a FQDN . | 52 | 11 |
243,032 | def list ( gandi , only_data , only_snapshot , attached , detached , type , id , vm , snapshotprofile , datacenter , limit ) : options = { 'items_per_page' : limit , } if attached and detached : raise UsageError ( 'You cannot use both --attached and --detached.' ) if only_data : options . setdefault ( 'type' , [ ] ) . ... | List disks . | 381 | 3 |
243,033 | def info ( gandi , resource ) : output_keys = [ 'name' , 'state' , 'size' , 'type' , 'id' , 'dc' , 'vm' , 'profile' , 'kernel' , 'cmdline' ] resource = sorted ( tuple ( set ( resource ) ) ) vms = dict ( [ ( vm [ 'id' ] , vm ) for vm in gandi . iaas . list ( ) ] ) datacenters = gandi . datacenter . list ( ) result = [ ]... | Display information about a disk . | 181 | 6 |
243,034 | def detach ( gandi , resource , background , force ) : resource = sorted ( tuple ( set ( resource ) ) ) if not force : proceed = click . confirm ( 'Are you sure you want to detach %s?' % ', ' . join ( resource ) ) if not proceed : return result = gandi . disk . detach ( resource , background ) if background : gandi . p... | Detach disks from currectly attached vm . | 87 | 10 |
243,035 | def attach ( gandi , disk , vm , position , read_only , background , force ) : if not force : proceed = click . confirm ( "Are you sure you want to attach disk '%s'" " to vm '%s'?" % ( disk , vm ) ) if not proceed : return disk_info = gandi . disk . info ( disk ) attached = disk_info . get ( 'vms_id' , False ) if attac... | Attach disk to vm . | 175 | 5 |
243,036 | def update ( gandi , resource , cmdline , kernel , name , size , snapshotprofile , delete_snapshotprofile , background ) : if snapshotprofile and delete_snapshotprofile : raise UsageError ( 'You must not set snapshotprofile and ' 'delete-snapshotprofile.' ) if delete_snapshotprofile : snapshotprofile = '' if kernel : s... | Update a disk . | 171 | 4 |
243,037 | def delete ( gandi , resource , force , background ) : output_keys = [ 'id' , 'type' , 'step' ] resource = sorted ( tuple ( set ( resource ) ) ) if not force : disk_info = "'%s'" % ', ' . join ( resource ) proceed = click . confirm ( 'Are you sure you want to delete disk %s?' % disk_info ) if not proceed : return opers... | Delete a disk . | 129 | 4 |
243,038 | def create ( gandi , name , vm , size , snapshotprofile , datacenter , source , background ) : try : gandi . datacenter . is_opened ( datacenter , 'iaas' ) except DatacenterLimited as exc : gandi . echo ( '/!\ Datacenter %s will be closed on %s, ' 'please consider using another datacenter.' % ( datacenter , exc . date ... | Create a new disk . | 288 | 5 |
243,039 | def snapshot ( gandi , name , resource , background ) : name = name or randomstring ( 'snp' ) source_info = gandi . disk . info ( resource ) datacenter = source_info [ 'datacenter_id' ] result = gandi . disk . create ( name , None , None , None , datacenter , resource , 'snapshot' , background ) if background : gandi .... | Create a snapshot on the fly . | 98 | 7 |
243,040 | def format_list ( data ) : if isinstance ( data , ( list , tuple ) ) : to_clean = [ '[' , ']' , '(' , ')' , "'" ] for item in to_clean : data = str ( data ) . replace ( "u\"" , "\"" ) . replace ( "u\'" , "\'" ) data = str ( data ) . replace ( item , '' ) return data | Remove useless characters to output a clean list . | 92 | 9 |
243,041 | def output_account ( gandi , account , output_keys , justify = 17 ) : output_generic ( gandi , account , output_keys , justify ) if 'prepaid' in output_keys : prepaid = '%s %s' % ( account [ 'prepaid_info' ] [ 'amount' ] , account [ 'prepaid_info' ] [ 'currency' ] ) output_line ( gandi , 'prepaid' , prepaid , justify )... | Helper to output an account information . | 293 | 7 |
243,042 | def output_vm ( gandi , vm , datacenters , output_keys , justify = 10 ) : output_generic ( gandi , vm , output_keys , justify ) if 'datacenter' in output_keys : for dc in datacenters : if dc [ 'id' ] == vm [ 'datacenter_id' ] : dc_name = dc . get ( 'dc_code' , dc . get ( 'iso' , '' ) ) break output_line ( gandi , 'data... | Helper to output a vm information . | 220 | 7 |
243,043 | def output_metric ( gandi , metrics , key , justify = 10 ) : for metric in metrics : key_name = metric [ key ] . pop ( ) values = [ point . get ( 'value' , 0 ) for point in metric [ 'points' ] ] graph = sparks ( values ) if max ( values ) else '' # need to encode in utf-8 to work in python2.X if sys . version_info < ( ... | Helper to output metrics . | 127 | 5 |
243,044 | def output_vhost ( gandi , vhost , paas , output_keys , justify = 14 ) : output_generic ( gandi , vhost , output_keys , justify ) if 'paas_name' in output_keys : output_line ( gandi , 'paas_name' , paas , justify ) | Helper to output a vhost information . | 71 | 8 |
243,045 | def output_paas ( gandi , paas , datacenters , vhosts , output_keys , justify = 11 ) : output_generic ( gandi , paas , output_keys , justify ) if 'sftp_server' in output_keys : output_line ( gandi , 'sftp_server' , paas [ 'ftp_server' ] , justify ) if 'vhost' in output_keys : for entry in vhosts : output_line ( gandi ,... | Helper to output a paas information . | 433 | 8 |
243,046 | def output_image ( gandi , image , datacenters , output_keys , justify = 14 , warn_deprecated = True ) : for key in output_keys : if key in image : if ( key == 'label' and image [ 'visibility' ] == 'deprecated' and warn_deprecated ) : image [ key ] = '%s /!\ DEPRECATED' % image [ key ] output_line ( gandi , key , image... | Helper to output a disk image . | 194 | 7 |
243,047 | def output_kernels ( gandi , flavor , name_list , justify = 14 ) : output_line ( gandi , 'flavor' , flavor , justify ) for name in name_list : output_line ( gandi , 'version' , name , justify ) | Helper to output kernel flavor versions . | 58 | 7 |
243,048 | def output_datacenter ( gandi , datacenter , output_keys , justify = 14 ) : output_generic ( gandi , datacenter , output_keys , justify ) if 'dc_name' in output_keys : output_line ( gandi , 'datacenter' , datacenter [ 'name' ] , justify ) if 'status' in output_keys : deactivate_at = datacenter . get ( 'deactivate_at' )... | Helper to output datacenter information . | 259 | 8 |
243,049 | def output_disk ( gandi , disk , datacenters , vms , profiles , output_keys , justify = 10 ) : output_generic ( gandi , disk , output_keys , justify ) if 'kernel' in output_keys and disk . get ( 'kernel_version' ) : output_line ( gandi , 'kernel' , disk [ 'kernel_version' ] , justify ) if 'cmdline' in output_keys and d... | Helper to output a disk . | 408 | 6 |
243,050 | def output_sshkey ( gandi , sshkey , output_keys , justify = 12 ) : output_generic ( gandi , sshkey , output_keys , justify ) | Helper to output an ssh key information . | 37 | 8 |
243,051 | def output_snapshot_profile ( gandi , profile , output_keys , justify = 13 ) : schedules = 'schedules' in output_keys if schedules : output_keys . remove ( 'schedules' ) output_generic ( gandi , profile , output_keys , justify ) if schedules : schedule_keys = [ 'name' , 'kept_version' ] for schedule in profile [ 'sched... | Helper to output a snapshot_profile . | 117 | 8 |
243,052 | def output_contact_info ( gandi , data , output_keys , justify = 10 ) : for key in output_keys : if data [ key ] : output_line ( gandi , key , data [ key ] [ 'handle' ] , justify ) | Helper to output chosen contacts info . | 55 | 7 |
243,053 | def output_cert ( gandi , cert , output_keys , justify = 13 ) : output = list ( output_keys ) display_altnames = False if 'altnames' in output : display_altnames = True output . remove ( 'altnames' ) display_output = False if 'cert' in output : display_output = True output . remove ( 'cert' ) output_generic ( gandi , c... | Helper to output a certificate information . | 175 | 7 |
243,054 | def output_vlan ( gandi , vlan , datacenters , output_keys , justify = 10 ) : output_generic ( gandi , vlan , output_keys , justify ) if 'dc' in output_keys : for dc in datacenters : if dc [ 'id' ] == vlan . get ( 'datacenter_id' , vlan . get ( 'datacenter' , { } ) . get ( 'id' ) ) : dc_name = dc . get ( 'dc_code' , dc... | Helper to output a vlan information . | 146 | 8 |
243,055 | def output_iface ( gandi , iface , datacenters , vms , output_keys , justify = 10 ) : output_generic ( gandi , iface , output_keys , justify ) if 'vm' in output_keys : vm_name = vms . get ( iface [ 'vm_id' ] , { } ) . get ( 'hostname' ) if vm_name : output_line ( gandi , 'vm' , vm_name , justify ) if 'dc' in output_key... | Helper to output an iface information . | 264 | 8 |
243,056 | def output_ip ( gandi , ip , datacenters , vms , ifaces , output_keys , justify = 11 ) : output_generic ( gandi , ip , output_keys , justify ) if 'type' in output_keys : iface = ifaces . get ( ip [ 'iface_id' ] ) type_ = 'private' if iface . get ( 'vlan' ) else 'public' output_line ( gandi , 'type' , type_ , justify ) ... | Helper to output an ip information . | 340 | 7 |
243,057 | def output_json ( gandi , format , value ) : if format == 'json' : gandi . echo ( json . dumps ( value , default = date_handler , sort_keys = True ) ) elif format == 'pretty-json' : gandi . echo ( json . dumps ( value , default = date_handler , sort_keys = True , indent = 2 , separators = ( ',' , ': ' ) ) ) | Helper to show json output | 94 | 5 |
243,058 | def output_service ( gandi , service , status , justify = 10 ) : output_line ( gandi , service , status , justify ) | Helper to output a status service information . | 30 | 8 |
243,059 | def output_domain ( gandi , domain , output_keys , justify = 12 ) : if 'nameservers' in domain : domain [ 'nameservers' ] = format_list ( domain [ 'nameservers' ] ) if 'services' in domain : domain [ 'services' ] = format_list ( domain [ 'services' ] ) if 'tags' in domain : domain [ 'tags' ] = format_list ( domain [ 't... | Helper to output a domain information . | 261 | 7 |
243,060 | def output_mailbox ( gandi , mailbox , output_keys , justify = 16 ) : quota = 'quota' in output_keys responder = 'responder' in output_keys if quota : output_keys . pop ( output_keys . index ( 'quota' ) ) if responder : output_keys . pop ( output_keys . index ( 'responder' ) ) if 'aliases' in output_keys : mailbox [ 'a... | Helper to output a mailbox information . | 322 | 7 |
243,061 | def output_forward ( gandi , domain , forward , justify = 14 ) : for dest in forward [ 'destinations' ] : output_line ( gandi , forward [ 'source' ] , dest , justify ) | Helper to output a mail forward information . | 46 | 8 |
243,062 | def output_dns_records ( gandi , records , output_keys , justify = 12 ) : for key in output_keys : real_key = 'rrset_%s' % key if real_key in records : val = records [ real_key ] if key == 'values' : val = format_list ( records [ real_key ] ) output_line ( gandi , key , val , justify ) | Helper to output a dns records information . | 91 | 9 |
243,063 | def list ( gandi , datacenter , type , id , attached , detached , version , reverse , vm , vlan ) : if attached and detached : gandi . echo ( "You can't set --attached and --detached at the same time." ) return output_keys = [ 'ip' , 'state' , 'dc' , 'type' ] if id : output_keys . append ( 'id' ) if version : output_ke... | List ips . | 485 | 4 |
243,064 | def info ( gandi , resource ) : output_keys = [ 'ip' , 'state' , 'dc' , 'type' , 'vm' , 'reverse' ] datacenters = gandi . datacenter . list ( ) ip = gandi . ip . info ( resource ) iface = gandi . iface . info ( ip [ 'iface_id' ] ) vms = None if iface . get ( 'vm_id' ) : vm = gandi . iaas . info ( iface [ 'vm_id' ] ) vm... | Display information about an ip . | 170 | 6 |
243,065 | def update ( gandi , ip , reverse , background ) : if not reverse : return return gandi . ip . update ( ip , { 'reverse' : reverse } , background ) | Update an ip . | 38 | 4 |
243,066 | def attach ( gandi , ip , vm , background , force ) : try : ip_ = gandi . ip . info ( ip ) vm_ = gandi . iaas . info ( vm ) except UsageError : gandi . error ( "Can't find this ip %s" % ip ) iface = gandi . iface . info ( ip_ [ 'iface_id' ] ) if iface . get ( 'vm_id' ) : if vm_ and iface [ 'vm_id' ] == vm_ . get ( 'id'... | Attach an ip to a vm . | 209 | 7 |
243,067 | def create ( gandi , datacenter , bandwidth , ip_version , vlan , ip , attach , background ) : if ip_version != 4 and vlan : gandi . echo ( 'You must have an --ip-version to 4 when having a vlan.' ) return if ip and not vlan : gandi . echo ( 'You must have a --vlan when giving an --ip.' ) return vm_ = gandi . iaas . in... | Create a public or private ip | 308 | 6 |
243,068 | def detach ( gandi , resource , background , force ) : if not force : proceed = click . confirm ( 'Are you sure you want to detach ip %s?' % resource ) if not proceed : return return gandi . ip . detach ( resource , background , force ) | Detach an ip from it s currently attached vm . | 57 | 11 |
243,069 | def get ( gandi , g , key ) : val = gandi . get ( key = key , global_ = g ) if not val : gandi . echo ( "No value found." ) sys . exit ( 1 ) gandi . echo ( val ) | Display value of a given config key . | 55 | 8 |
243,070 | def edit ( gandi , g ) : config_file = gandi . home_config if g else gandi . local_config path = os . path . expanduser ( config_file ) editor = gandi . get ( 'editor' ) if not editor : try : editor = click . prompt ( "Please enter the path of your prefered " "editor. eg: '/usr/bin/vi' or 'vi'" ) except Abort : gandi .... | Edit config file with prefered text editor | 155 | 8 |
243,071 | def delete ( cls , name ) : result = cls . call ( 'hosting.rproxy.delete' , cls . usable_id ( name ) ) cls . echo ( 'Deleting your webaccelerator named %s' % name ) cls . display_progress ( result ) cls . echo ( 'Webaccelerator have been deleted' ) return result | Delete a webaccelerator | 83 | 6 |
243,072 | def backend_add ( cls , name , backend ) : oper = cls . call ( 'hosting.rproxy.server.create' , cls . usable_id ( name ) , backend ) cls . echo ( 'Adding backend %s:%s into webaccelerator' % ( backend [ 'ip' ] , backend [ 'port' ] ) ) cls . display_progress ( oper ) cls . echo ( 'Backend added' ) return oper | Add a backend into a webaccelerator | 102 | 9 |
243,073 | def backend_disable ( cls , backend ) : server = cls . backend_list ( backend ) oper = cls . call ( 'hosting.rproxy.server.disable' , server [ 0 ] [ 'id' ] ) cls . echo ( 'Desactivating backend on server %s' % server [ 0 ] [ 'ip' ] ) cls . display_progress ( oper ) cls . echo ( 'Backend desactivated' ) return oper | Disable a backend for a server | 100 | 6 |
243,074 | def vhost_add ( cls , resource , params ) : try : oper = cls . call ( 'hosting.rproxy.vhost.create' , cls . usable_id ( resource ) , params ) cls . echo ( 'Adding your virtual host (%s) into %s' % ( params [ 'vhost' ] , resource ) ) cls . display_progress ( oper ) cls . echo ( 'Your virtual host habe been added' ) retu... | Add a vhost into a webaccelerator | 427 | 10 |
243,075 | def vhost_remove ( cls , name ) : oper = cls . call ( 'hosting.rproxy.vhost.delete' , name ) cls . echo ( 'Deleting your virtual host %s' % name ) cls . display_progress ( oper ) cls . echo ( 'Your virtual host have been removed' ) return oper | Delete a vhost in a webaccelerator | 77 | 10 |
243,076 | def probe ( cls , resource , enable , disable , test , host , interval , http_method , http_response , threshold , timeout , url , window ) : params = { 'host' : host , 'interval' : interval , 'method' : http_method , 'response' : http_response , 'threshold' : threshold , 'timeout' : timeout , 'url' : url , 'window' : ... | Set a probe for a webaccelerator | 195 | 9 |
243,077 | def probe_enable ( cls , resource ) : oper = cls . call ( 'hosting.rproxy.probe.enable' , cls . usable_id ( resource ) ) cls . echo ( 'Activating probe on %s' % resource ) cls . display_progress ( oper ) cls . echo ( 'The probe have been activated' ) return oper | Activate a probe on a webaccelerator | 81 | 10 |
243,078 | def probe_disable ( cls , resource ) : oper = cls . call ( 'hosting.rproxy.probe.disable' , cls . usable_id ( resource ) ) cls . echo ( 'Desactivating probe on %s' % resource ) cls . display_progress ( oper ) cls . echo ( 'The probe have been desactivated' ) return oper | Disable a probe on a webaccelerator | 83 | 9 |
243,079 | def usable_id ( cls , id ) : try : # id is maybe a hostname qry_id = cls . from_name ( id ) if not qry_id : # id is maybe an ip qry_id = cls . from_ip ( id ) if not qry_id : qry_id = cls . from_vhost ( id ) except Exception : qry_id = None if not qry_id : msg = 'unknown identifier %s' % id cls . error ( msg ) return qr... | Retrieve id from input which can be hostname vhost id . | 121 | 14 |
243,080 | def from_name ( cls , name ) : result = cls . list ( { 'items_per_page' : 500 } ) webaccs = { } for webacc in result : webaccs [ webacc [ 'name' ] ] = webacc [ 'id' ] return webaccs . get ( name ) | Retrieve webacc id associated to a webacc name . | 71 | 12 |
243,081 | def from_ip ( cls , ip ) : result = cls . list ( { 'items_per_page' : 500 } ) webaccs = { } for webacc in result : for server in webacc [ 'servers' ] : webaccs [ server [ 'ip' ] ] = webacc [ 'id' ] return webaccs . get ( ip ) | Retrieve webacc id associated to a webacc ip | 82 | 11 |
243,082 | def from_vhost ( cls , vhost ) : result = cls . list ( { 'items_per_page' : 500 } ) webaccs = { } for webacc in result : for vhost in webacc [ 'vhosts' ] : webaccs [ vhost [ 'name' ] ] = webacc [ 'id' ] return webaccs . get ( vhost ) | Retrieve webbacc id associated to a webacc vhost | 88 | 13 |
243,083 | def descriptions ( cls ) : schema = cls . json_get ( '%s/status/schema' % cls . api_url , empty_key = True , send_key = False ) descs = { } for val in schema [ 'fields' ] [ 'status' ] [ 'value' ] : descs . update ( val ) return descs | Retrieve status descriptions from status . gandi . net . | 80 | 12 |
243,084 | def services ( cls ) : return cls . json_get ( '%s/services' % cls . api_url , empty_key = True , send_key = False ) | Retrieve services statuses from status . gandi . net . | 41 | 13 |
243,085 | def status ( cls ) : return cls . json_get ( '%s/status' % cls . api_url , empty_key = True , send_key = False ) | Retrieve global status from status . gandi . net . | 41 | 12 |
243,086 | def events ( cls , filters ) : current = filters . pop ( 'current' , False ) current_params = [ ] if current : current_params = [ ( 'current' , 'true' ) ] filter_url = uparse . urlencode ( sorted ( list ( filters . items ( ) ) ) + current_params ) # noqa events = cls . json_get ( '%s/events?%s' % ( cls . api_url , filt... | Retrieve events details from status . gandi . net . | 121 | 12 |
243,087 | def list ( gandi , state , id , vhosts , type , limit ) : options = { 'items_per_page' : limit , } if state : options [ 'state' ] = state output_keys = [ 'name' , 'state' ] if id : output_keys . append ( 'id' ) if vhosts : output_keys . append ( 'vhost' ) if type : output_keys . append ( 'type' ) paas_hosts = { } resul... | List PaaS instances . | 262 | 6 |
243,088 | def info ( gandi , resource , stat ) : output_keys = [ 'name' , 'type' , 'size' , 'memory' , 'console' , 'vhost' , 'dc' , 'sftp_server' , 'git_server' , 'snapshot' ] paas = gandi . paas . info ( resource ) paas_hosts = [ ] list_vhost = gandi . vhost . list ( { 'paas_id' : paas [ 'id' ] } ) df = gandi . paas . quota ( p... | Display information about a PaaS instance . | 230 | 9 |
243,089 | def clone ( gandi , name , vhost , directory , origin ) : if vhost != 'default' : directory = vhost else : directory = name if not directory else directory return gandi . paas . clone ( name , vhost , directory , origin ) | Clone a remote vhost in a local git repository . | 56 | 12 |
243,090 | def attach ( gandi , name , vhost , remote ) : return gandi . paas . attach ( name , vhost , remote ) | Add remote for an instance s default vhost to the local git repository . | 30 | 15 |
243,091 | def create ( gandi , name , size , type , quantity , duration , datacenter , vhosts , password , snapshotprofile , background , sshkey , ssl , private_key , poll_cert ) : try : gandi . datacenter . is_opened ( datacenter , 'paas' ) except DatacenterLimited as exc : gandi . echo ( '/!\ Datacenter %s will be closed on %s... | Create a new PaaS instance and initialize associated git repository . | 231 | 13 |
243,092 | def restart ( gandi , resource , background , force ) : output_keys = [ 'id' , 'type' , 'step' ] possible_resources = gandi . paas . resource_list ( ) for item in resource : if item not in possible_resources : gandi . echo ( 'Sorry PaaS instance %s does not exist' % item ) gandi . echo ( 'Please use one of the followin... | Restart a PaaS instance . | 189 | 8 |
243,093 | def types ( gandi ) : options = { } types = gandi . paas . type_list ( options ) for type_ in types : gandi . echo ( type_ [ 'name' ] ) return types | List types PaaS instances . | 46 | 7 |
243,094 | def info ( gandi , resource , id , value ) : output_keys = [ 'name' , 'fingerprint' ] if id : output_keys . append ( 'id' ) if value : output_keys . append ( 'value' ) ret = [ ] for item in resource : sshkey = gandi . sshkey . info ( item ) ret . append ( output_sshkey ( gandi , sshkey , output_keys ) ) return ret | Display information about an SSH key . | 97 | 7 |
243,095 | def create ( gandi , name , value = None , filename = None ) : if not value and not filename : raise UsageError ( 'You must set value OR filename.' ) if value and filename : raise UsageError ( 'You must not set value AND filename.' ) if filename : value = filename . read ( ) ret = gandi . sshkey . create ( name , value... | Create a new SSH key . | 113 | 6 |
243,096 | def creditusage ( cls ) : rating = cls . call ( 'hosting.rating.list' ) if not rating : return 0 rating = rating . pop ( ) usage = [ sum ( resource . values ( ) ) for resource in rating . values ( ) if isinstance ( resource , dict ) ] return sum ( usage ) | Get credit usage per hour | 70 | 5 |
243,097 | def all ( cls ) : account = cls . info ( ) creditusage = cls . creditusage ( ) if not creditusage : return account left = account [ 'credits' ] / creditusage years , hours = divmod ( left , 365 * 24 ) months , hours = divmod ( hours , 31 * 24 ) days , hours = divmod ( hours , 24 ) account . update ( { 'credit_usage' : ... | Get all informations about this account | 112 | 7 |
243,098 | def list ( gandi , only_paas , only_vm ) : target = None if only_paas and not only_vm : target = 'paas' if only_vm and not only_paas : target = 'vm' output_keys = [ 'id' , 'name' , 'kept_total' , 'target' ] result = gandi . snapshotprofile . list ( { } , target = target ) for num , profile in enumerate ( result ) : if ... | List snapshot profiles . | 133 | 4 |
243,099 | def list ( gandi , id , altnames , csr , cert , all_status , status , dates , limit ) : options = { 'items_per_page' : limit } if not all_status : options [ 'status' ] = [ 'valid' , 'pending' ] output_keys = [ 'cn' , 'plan' ] if id : output_keys . append ( 'id' ) if status : output_keys . append ( 'status' ) if dates :... | List certificates . | 238 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.