idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
28,700 | async def connect ( url , * , apikey = None , insecure = False ) : from . facade import Client from . viscera import Origin profile , origin = await Origin . connect ( url , apikey = apikey , insecure = insecure ) return Client ( origin ) | Connect to MAAS at url using a previously obtained API key . |
28,701 | async def login ( url , * , username = None , password = None , insecure = False ) : from . facade import Client from . viscera import Origin profile , origin = await Origin . login ( url , username = username , password = password , insecure = insecure ) return Client ( origin ) | Connect to MAAS at url with a user name and password . |
28,702 | async def read ( cls , * , hostnames : typing . Sequence [ str ] = None ) : params = { } if hostnames : params [ "hostname" ] = [ normalize_hostname ( hostname ) for hostname in hostnames ] data = await cls . _handler . read ( ** params ) return cls ( map ( cls . _object , data ) ) | List nodes . |
28,703 | def as_machine ( self ) : if self . node_type != NodeType . MACHINE : raise ValueError ( 'Cannot convert to `Machine`, node_type is not a machine.' ) return self . _origin . Machine ( self . _data ) | Convert to a Machine object . |
28,704 | def as_device ( self ) : if self . node_type != NodeType . DEVICE : raise ValueError ( 'Cannot convert to `Device`, node_type is not a device.' ) return self . _origin . Device ( self . _data ) | Convert to a Device object . |
28,705 | def as_rack_controller ( self ) : if self . node_type not in [ NodeType . RACK_CONTROLLER , NodeType . REGION_AND_RACK_CONTROLLER ] : raise ValueError ( 'Cannot convert to `RackController`, node_type is not a ' 'rack controller.' ) return self . _origin . RackController ( self . _data ) | Convert to a RackController object . |
28,706 | def as_region_controller ( self ) : if self . node_type not in [ NodeType . REGION_CONTROLLER , NodeType . REGION_AND_RACK_CONTROLLER ] : raise ValueError ( 'Cannot convert to `RegionController`, node_type is not a ' 'region controller.' ) return self . _origin . RegionController ( self . _data ) | Convert to a RegionController object . |
28,707 | async def get_power_parameters ( self ) : data = await self . _handler . power_parameters ( system_id = self . system_id ) return data | Get the power paramters for this node . |
28,708 | async def set_power ( self , power_type : str , power_parameters : typing . Mapping [ str , typing . Any ] = { } ) : data = await self . _handler . update ( system_id = self . system_id , power_type = power_type , power_parameters = power_parameters ) self . power_type = data [ 'power_type' ] | Set the power type and power parameters for this node . |
28,709 | async def create ( cls , boot_source , os , release , * , arches = None , subarches = None , labels = None ) : if not isinstance ( boot_source , BootSource ) : raise TypeError ( "boot_source must be a BootSource, not %s" % type ( boot_source ) . __name__ ) if arches is None : arches = [ '*' ] if subarches is None : sub... | Create a new BootSourceSelection . |
28,710 | async def read ( cls , boot_source , id ) : if isinstance ( boot_source , int ) : boot_source_id = boot_source elif isinstance ( boot_source , BootSource ) : boot_source_id = boot_source . id else : raise TypeError ( "boot_source must be a BootSource or int, not %s" % type ( boot_source ) . __name__ ) data = await cls ... | Get BootSourceSelection by id . |
28,711 | async def delete ( self ) : await self . _handler . delete ( boot_source_id = self . boot_source . id , id = self . id ) | Delete boot source selection . |
28,712 | def calc_size_and_sha265 ( content : io . IOBase , chunk_size : int ) : size = 0 sha256 = hashlib . sha256 ( ) content . seek ( 0 , io . SEEK_SET ) while True : buf = content . read ( chunk_size ) length = len ( buf ) size += length sha256 . update ( buf ) if length != chunk_size : break return size , sha256 . hexdiges... | Calculates the size and the sha2566 value of the content . |
28,713 | async def create ( cls , name : str , architecture : str , content : io . IOBase , * , title : str = "" , filetype : BootResourceFileType = BootResourceFileType . TGZ , chunk_size = ( 1 << 22 ) , progress_callback = None ) : if '/' not in name : raise ValueError ( "name must be in format os/release; missing '/'" ) if '... | Create a BootResource . |
28,714 | async def _upload_chunks ( cls , rfile : BootResourceFile , content : io . IOBase , chunk_size : int , progress_callback = None ) : content . seek ( 0 , io . SEEK_SET ) upload_uri = urlparse ( cls . _handler . uri ) . _replace ( path = rfile . _data [ 'upload_uri' ] ) . geturl ( ) uploaded_size = 0 insecure = cls . _ha... | Upload the content to rfile in chunks using chunk_size . |
28,715 | async def _put_chunk ( cls , session : aiohttp . ClientSession , upload_uri : str , buf : bytes ) : headers = { 'Content-Type' : 'application/octet-stream' , 'Content-Length' : '%s' % len ( buf ) , } credentials = cls . _handler . session . credentials if credentials is not None : utils . sign ( upload_uri , headers , ... | Upload one chunk to upload_uri . |
28,716 | async def read ( cls , id : int ) : data = await cls . _handler . read ( id = id ) return cls ( data ) | Get BootResource by id . |
28,717 | async def read ( cls , node , id ) : if isinstance ( node , str ) : system_id = node elif isinstance ( node , Node ) : system_id = node . system_id else : raise TypeError ( "node must be a Node or str, not %s" % type ( node ) . __name__ ) return cls ( await cls . _handler . read ( system_id = system_id , id = id ) ) | Get Bcache by id . |
28,718 | async def delete ( self ) : await self . _handler . delete ( system_id = self . node . system_id , id = self . id ) | Delete this Bcache . |
28,719 | async def read ( cls , node ) : if isinstance ( node , str ) : system_id = node elif isinstance ( node , Node ) : system_id = node . system_id else : raise TypeError ( "node must be a Node or str, not %s" % type ( node ) . __name__ ) data = await cls . _handler . read ( system_id = system_id ) return cls ( cls . _objec... | Get list of Bcache s for node . |
28,720 | async def create ( cls , node : Union [ Node , str ] , name : str , backing_device : Union [ BlockDevice , Partition ] , cache_set : Union [ BcacheCacheSet , int ] , cache_mode : CacheMode , * , uuid : str = None ) : params = { 'name' : name , } if isinstance ( node , str ) : params [ 'system_id' ] = node elif isinstan... | Create a Bcache on a Node . |
28,721 | def get_param_arg ( param , idx , klass , arg , attr = 'id' ) : if isinstance ( arg , klass ) : return getattr ( arg , attr ) elif isinstance ( arg , ( int , str ) ) : return arg else : raise TypeError ( "%s[%d] must be int, str, or %s, not %s" % ( param , idx , klass . __name__ , type ( arg ) . __name__ ) ) | Return the correct value for a fabric from arg . |
28,722 | async def create ( cls , architecture : str , mac_addresses : typing . Sequence [ str ] , power_type : str , power_parameters : typing . Mapping [ str , typing . Any ] = None , * , subarchitecture : str = None , min_hwe_kernel : str = None , hostname : str = None , domain : typing . Union [ int , str ] = None ) : param... | Create a new machine . |
28,723 | async def save ( self ) : orig_owner_data = self . _orig_data [ 'owner_data' ] new_owner_data = dict ( self . _data [ 'owner_data' ] ) self . _changed_data . pop ( 'owner_data' , None ) await super ( Machine , self ) . save ( ) params_diff = calculate_dict_diff ( orig_owner_data , new_owner_data ) if len ( params_diff ... | Save the machine in MAAS . |
28,724 | async def abort ( self , * , comment : str = None ) : params = { "system_id" : self . system_id } if comment : params [ "comment" ] = comment self . _data = await self . _handler . abort ( ** params ) return self | Abort the current action . |
28,725 | async def clear_default_gateways ( self ) : self . _data = await self . _handler . clear_default_gateways ( system_id = self . system_id ) return self | Clear default gateways . |
28,726 | async def commission ( self , * , enable_ssh : bool = None , skip_networking : bool = None , skip_storage : bool = None , commissioning_scripts : typing . Sequence [ str ] = None , testing_scripts : typing . Sequence [ str ] = None , wait : bool = False , wait_interval : int = 5 ) : params = { "system_id" : self . syst... | Commission this machine . |
28,727 | async def deploy ( self , * , user_data : typing . Union [ bytes , str ] = None , distro_series : str = None , hwe_kernel : str = None , comment : str = None , wait : bool = False , wait_interval : int = 5 ) : params = { "system_id" : self . system_id } if user_data is not None : if isinstance ( user_data , bytes ) : p... | Deploy this machine . |
28,728 | async def enter_rescue_mode ( self , wait : bool = False , wait_interval : int = 5 ) : try : self . _data = await self . _handler . rescue_mode ( system_id = self . system_id ) except CallError as error : if error . status == HTTPStatus . FORBIDDEN : message = "Not allowed to enter rescue mode" raise OperationNotAllowe... | Send this machine into rescue mode . |
28,729 | async def exit_rescue_mode ( self , wait : bool = False , wait_interval : int = 5 ) : try : self . _data = await self . _handler . exit_rescue_mode ( system_id = self . system_id ) except CallError as error : if error . status == HTTPStatus . FORBIDDEN : message = "Not allowed to exit rescue mode." raise OperationNotAl... | Exit rescue mode . |
28,730 | async def get_details ( self ) : data = await self . _handler . details ( system_id = self . system_id ) return bson . decode_all ( data ) [ 0 ] | Get machine details information . |
28,731 | async def mark_broken ( self , * , comment : str = None ) : params = { "system_id" : self . system_id } if comment : params [ "comment" ] = comment self . _data = await self . _handler . mark_broken ( ** params ) return self | Mark broken . |
28,732 | async def mark_fixed ( self , * , comment : str = None ) : params = { "system_id" : self . system_id } if comment : params [ "comment" ] = comment self . _data = await self . _handler . mark_fixed ( ** params ) return self | Mark fixes . |
28,733 | async def release ( self , * , comment : str = None , erase : bool = None , secure_erase : bool = None , quick_erase : bool = None , wait : bool = False , wait_interval : int = 5 ) : params = remove_None ( { "system_id" : self . system_id , "comment" : comment , "erase" : erase , "secure_erase" : secure_erase , "quick_... | Release the machine . |
28,734 | async def power_on ( self , comment : str = None , wait : bool = False , wait_interval : int = 5 ) : params = { "system_id" : self . system_id } if comment is not None : params [ "comment" ] = comment try : self . _data = await self . _handler . power_on ( ** params ) except CallError as error : if error . status == HT... | Power on . |
28,735 | async def power_off ( self , stop_mode : PowerStopMode = PowerStopMode . HARD , comment : str = None , wait : bool = False , wait_interval : int = 5 ) : params = { "system_id" : self . system_id , 'stop_mode' : stop_mode . value } if comment is not None : params [ "comment" ] = comment try : self . _data = await self .... | Power off . |
28,736 | async def query_power_state ( self ) : power_data = await self . _handler . query_power_state ( system_id = self . system_id ) self . _data [ 'power_state' ] = power_data [ 'state' ] return PowerState ( power_data [ 'state' ] ) | Query the machine s BMC for the current power state . |
28,737 | async def restore_default_configuration ( self ) : self . _data = await self . _handler . restore_default_configuration ( system_id = self . system_id ) | Restore machine s configuration to its initial state . |
28,738 | async def restore_networking_configuration ( self ) : self . _data = await self . _handler . restore_networking_configuration ( system_id = self . system_id ) | Restore machine s networking configuration to its initial state . |
28,739 | async def restore_storage_configuration ( self ) : self . _data = await self . _handler . restore_storage_configuration ( system_id = self . system_id ) | Restore machine s storage configuration to its initial state . |
28,740 | async def create ( cls , * , name : str = None , description : str = None ) : params = { } if name is not None : params [ "name" ] = name if description is not None : params [ "description" ] = description return cls . _object ( await cls . _handler . create ( ** params ) ) | Create a Space in MAAS . |
28,741 | async def get_default ( cls ) : data = await cls . _handler . read ( id = cls . _default_space_id ) return cls ( data ) | Get the default Space for the MAAS . |
28,742 | async def delete ( self ) : if self . id == self . _origin . Space . _default_space_id : raise DeleteDefaultSpace ( "Cannot delete default space." ) await self . _handler . delete ( id = self . id ) | Delete this Space . |
28,743 | async def read ( cls , fabric : Union [ Fabric , int ] , vid : int ) : if isinstance ( fabric , int ) : fabric_id = fabric elif isinstance ( fabric , Fabric ) : fabric_id = fabric . id else : raise TypeError ( "fabric must be a Fabric or int, not %s" % type ( fabric ) . __name__ ) data = await cls . _handler . read ( f... | Get Vlan by vid . |
28,744 | async def delete ( self ) : await self . _handler . delete ( fabric_id = self . fabric . id , vid = self . _orig_data [ 'vid' ] ) | Delete this VLAN . |
28,745 | async def read ( cls , fabric : Union [ Fabric , int ] ) : if isinstance ( fabric , int ) : fabric_id = fabric elif isinstance ( fabric , Fabric ) : fabric_id = fabric . id else : raise TypeError ( "fabric must be a Fabric or int, not %s" % type ( fabric ) . __name__ ) data = await cls . _handler . read ( fabric_id = f... | Get list of Vlan s for fabric . |
28,746 | async def create ( cls , fabric : Union [ Fabric , int ] , vid : int , * , name : str = None , description : str = None , mtu : int = None , relay_vlan : Union [ Vlan , int ] = None , dhcp_on : bool = False , primary_rack : Union [ RackController , str ] = None , secondary_rack : Union [ RackController , str ] = None ,... | Create a Vlan in MAAS . |
28,747 | def get_default ( self ) : length = len ( self ) if length == 0 : return None elif length == 1 : return self [ 0 ] else : return sorted ( self , key = attrgetter ( 'id' ) ) [ 0 ] | Return the default VLAN from the set . |
28,748 | def get_content_type ( * names ) : for name in names : if name is not None : mimetype , encoding = mimetypes . guess_type ( name ) if mimetype is not None : if isinstance ( mimetype , bytes ) : return mimetype . decode ( "ascii" ) else : return mimetype else : return "application/octet-stream" | Return the MIME content type for the file with the given name . |
28,749 | async def set_http_proxy ( cls , url : typing . Optional [ str ] ) : await cls . set_config ( "http_proxy" , "" if url is None else url ) | See get_http_proxy . |
28,750 | async def get_kernel_options ( cls ) -> typing . Optional [ str ] : data = await cls . get_config ( "kernel_opts" ) return None if data is None or data == "" else data | Kernel options . |
28,751 | async def set_kernel_options ( cls , options : typing . Optional [ str ] ) : await cls . set_config ( "kernel_opts" , "" if options is None else options ) | See get_kernel_options . |
28,752 | async def get_upstream_dns ( cls ) -> list : data = await cls . get_config ( "upstream_dns" ) return [ ] if data is None else re . split ( r'[,\s]+' , data ) | Upstream DNS server addresses . |
28,753 | async def set_upstream_dns ( cls , addresses : typing . Optional [ typing . Sequence [ str ] ] ) : await cls . set_config ( "upstream_dns" , ( "" if addresses is None else "," . join ( addresses ) ) ) | See get_upstream_dns . |
28,754 | async def get_dnssec_validation ( cls ) -> DNSSEC : data = await cls . get_config ( "dnssec_validation" ) return cls . DNSSEC . lookup ( data ) | Enable DNSSEC validation of upstream zones . |
28,755 | async def get_windows_kms_host ( cls ) -> typing . Optional [ str ] : data = await cls . get_config ( "windows_kms_host" ) return None if data is None or data == "" else data | Windows KMS activation host . |
28,756 | async def set_windows_kms_host ( cls , host : typing . Optional [ str ] ) : await cls . set_config ( "windows_kms_host" , "" if host is None else host ) | See get_windows_kms_host . |
28,757 | async def get_default_storage_layout ( cls ) -> StorageLayout : data = await cls . get_config ( "default_storage_layout" ) return cls . StorageLayout . lookup ( data ) | Default storage layout . |
28,758 | async def get_default_min_hwe_kernel ( cls ) -> typing . Optional [ str ] : data = await cls . get_config ( "default_min_hwe_kernel" ) return None if data is None or data == "" else data | Default minimum kernel version . |
28,759 | async def set_default_min_hwe_kernel ( cls , version : typing . Optional [ str ] ) : await cls . set_config ( "default_min_hwe_kernel" , "" if version is None else version ) | See get_default_min_hwe_kernel . |
28,760 | async def set_config ( cls , name : str , value ) : return await cls . _handler . set_config ( name = [ name ] , value = [ value ] ) | Set a configuration value in MAAS . |
28,761 | async def create ( cls , node : Union [ Node , str ] , name : str , devices : Iterable [ Union [ BlockDevice , Partition ] ] , * , uuid : str = None ) : params = { 'name' : name , } if isinstance ( node , str ) : params [ 'system_id' ] = node elif isinstance ( node , Node ) : params [ 'system_id' ] = node . system_id e... | Create a volume group on a Node . |
28,762 | def schema_create ( conn ) : conn . execute ( dedent ( ) ) if sqlite3 . sqlite_version_info >= ( 3 , 9 , 0 ) : conn . execute ( dedent ( ) ) | Create the index for storing profiles . |
28,763 | def schema_import ( conn , dbpath ) : conn . execute ( "ATTACH DATABASE ? AS source" , ( str ( dbpath ) , ) ) conn . execute ( "INSERT OR IGNORE INTO profiles (name, data)" " SELECT name, data FROM source.profiles" " WHERE data IS NOT NULL" ) conn . commit ( ) conn . execute ( "DETACH DATABASE source" ) | Import profiles from another database . |
28,764 | def replace ( self , ** updates ) : state = self . dump ( ) state . update ( updates ) return self . __class__ ( ** state ) | Return a new profile with the given updates . |
28,765 | def dump ( self ) : return dict ( self . other , name = self . name , url = self . url , credentials = self . credentials , description = self . description , ) | Return a dict of fields that can be used to recreate this profile . |
28,766 | def default ( self ) -> typing . Optional [ Profile ] : found = self . database . execute ( "SELECT name, data FROM profiles WHERE selected" " ORDER BY name LIMIT 1" ) . fetchone ( ) if found is None : return None else : state = json . loads ( found [ 1 ] ) state [ "name" ] = found [ 0 ] return Profile ( ** state ) | The name of the default profile to use or None . |
28,767 | def open ( cls , dbpath = Path ( "~/.maas.db" ) . expanduser ( ) , migrate_from = Path ( "~/.maascli.db" ) . expanduser ( ) ) : dbpath = Path ( dbpath ) migrate_from = Path ( migrate_from ) migrate = migrate_from . is_file ( ) and not dbpath . exists ( ) dbpath . touch ( mode = 0o600 , exist_ok = True ) migrate = migra... | Load a profiles database . |
28,768 | def print_with_pager ( output ) : if sys . stdout . isatty ( ) : try : pager = subprocess . Popen ( [ 'less' , '-F' , '-r' , '-S' , '-X' , '-K' ] , stdin = subprocess . PIPE , stdout = sys . stdout ) except subprocess . CalledProcessError : print ( output ) return else : pager . stdin . write ( output . encode ( 'utf-8... | Print the output to stdout using less when in a tty . |
28,769 | def get_profile_names_and_default ( ) -> ( typing . Tuple [ typing . Sequence [ str ] , typing . Optional [ Profile ] ] ) : with ProfileStore . open ( ) as config : return sorted ( config ) , config . default | Return the list of profile names and the default profile object . |
28,770 | def prepare_parser ( program ) : parser = ArgumentParser ( description = PROG_DESCRIPTION , prog = program , formatter_class = HelpFormatter , add_help = False ) parser . add_argument ( "-h" , "--help" , action = MinimalHelpAction , help = argparse . SUPPRESS ) submodules = ( "nodes" , "machines" , "devices" , "control... | Create and populate an argument parser . |
28,771 | def post_mortem ( traceback ) : try : from ipdb import post_mortem except ImportError : from pdb import post_mortem message = "Entering post-mortem debugger. Type `help` for help." redline = colorized ( "{autored}%s{/autored}" ) % "{0:=^{1}}" print ( ) print ( redline . format ( " CRASH! " , len ( message ) ) ) print (... | Work with an exception in a post - mortem debugger . |
28,772 | def subparsers ( self ) : try : return self . __subparsers except AttributeError : parent = super ( ArgumentParser , self ) self . __subparsers = parent . add_subparsers ( title = "drill down" ) self . __subparsers . metavar = "COMMAND" return self . __subparsers | Obtain the subparser s object . |
28,773 | def add_argument_group ( self , title , description = None ) : try : groups = self . __groups except AttributeError : groups = self . __groups = { } if title not in groups : groups [ title ] = super ( ) . add_argument_group ( title = title , description = description ) return groups [ title ] | Add an argument group or return a pre - existing one . |
28,774 | def print_minized_help ( self , * , no_pager = False ) : formatter = self . _get_formatter ( ) formatter . add_usage ( self . usage , self . _actions , self . _mutually_exclusive_groups ) formatter . add_text ( self . description ) if no_pager : print ( formatter . format_help ( ) ) else : print_with_pager ( formatter ... | Return the formatted help text . |
28,775 | def name ( cls ) : name = cls . __name__ . replace ( "_" , "-" ) . lower ( ) name = name [ 4 : ] if name . startswith ( "cmd-" ) else name return name | Return the preferred name as which this command will be known . |
28,776 | def register ( cls , parser , name = None ) : help_title , help_body = utils . parse_docstring ( cls ) command_parser = parser . subparsers . add_parser ( cls . name ( ) if name is None else name , help = help_title , description = help_title , epilog = help_body , add_help = False , formatter_class = HelpFormatter ) c... | Register this command as a sub - parser of parser . |
28,777 | def print_all_commands ( self , * , no_pager = False ) : formatter = self . parent_parser . _get_formatter ( ) command_names = sorted ( self . parent_parser . subparsers . choices . keys ( ) ) max_name_len = max ( [ len ( name ) for name in command_names ] ) + 1 commands = "" for name in command_names : command = self ... | Print help for all commands . |
28,778 | async def query ( cls , * , hostnames : typing . Iterable [ str ] = None , domains : typing . Iterable [ str ] = None , zones : typing . Iterable [ str ] = None , macs : typing . Iterable [ str ] = None , system_ids : typing . Iterable [ str ] = None , agent_name : str = None , level : typing . Union [ Level , int , st... | Query MAAS for matching events . |
28,779 | async def create ( cls , key : str ) : return cls . _object ( await cls . _handler . create ( key = key ) ) | Create an SSH key in MAAS with the content in key . |
28,780 | async def save ( self ) : old_tags = list ( self . _orig_data [ 'tags' ] ) new_tags = list ( self . tags ) self . _changed_data . pop ( 'tags' , None ) await super ( BlockDevice , self ) . save ( ) for tag_name in new_tags : if tag_name not in old_tags : await self . _handler . add_tag ( system_id = self . node . syste... | Save this block device . |
28,781 | async def set_as_boot_disk ( self ) : await self . _handler . set_boot_disk ( system_id = self . node . system_id , id = self . id ) | Set as boot disk for this node . |
28,782 | async def format ( self , fstype , * , uuid = None ) : self . _data = await self . _handler . format ( system_id = self . node . system_id , id = self . id , fstype = fstype , uuid = uuid ) | Format this block device . |
28,783 | async def unformat ( self ) : self . _data = await self . _handler . unformat ( system_id = self . node . system_id , id = self . id ) | Unformat this block device . |
28,784 | async def unmount ( self ) : self . _data = await self . _handler . unmount ( system_id = self . node . system_id , id = self . id ) | Unmount this block device . |
28,785 | async def create ( cls , node : Union [ Node , str ] , name : str , * , model : str = None , serial : str = None , id_path : str = None , size : int = None , block_size : int = 512 , tags : Iterable [ str ] = None ) : params = { } if isinstance ( node , str ) : params [ 'system_id' ] = node elif isinstance ( node , Nod... | Create a physical block device on a Node . |
28,786 | def read ( filename ) : path = join ( here , filename ) with open ( path , "r" ) as fin : return fin . read ( ) . strip ( ) | Return the whitespace - stripped content of filename . |
28,787 | def get_subnets ( self , vlan ) : return vlan . _origin . Subnets ( [ subnet for subnet in self . subnets if subnet . vlan . id == vlan . id ] ) | Return the subnets for the vlan . |
28,788 | async def create ( cls , url , * , keyring_filename = None , keyring_data = None ) : data = await cls . _handler . create ( url = url , keyring_filename = coalesce ( keyring_filename , "" ) , keyring_data = coalesce ( keyring_data , "" ) ) return cls . _object ( data ) | Create a new BootSource . |
28,789 | async def fetch_api_description ( url : typing . Union [ str , ParseResult , SplitResult ] , insecure : bool = False ) : url_describe = urljoin ( _ensure_url_string ( url ) , "describe/" ) connector = aiohttp . TCPConnector ( verify_ssl = ( not insecure ) ) session = aiohttp . ClientSession ( connector = connector ) as... | Fetch the API description from the remote MAAS instance . |
28,790 | def _ensure_url_string ( url ) : if isinstance ( url , str ) : return url elif isinstance ( url , ( ParseResult , SplitResult ) ) : return url . geturl ( ) else : raise TypeError ( "Could not convert %r to a string URL." % ( url , ) ) | Convert url to a string URL if it isn t one already . |
28,791 | def derive_resource_name ( name ) : if name . startswith ( "Anon" ) : name = name [ 4 : ] if name . endswith ( "Handler" ) : name = name [ : - 7 ] if name == "Maas" : name = "MAAS" return name | A stable human - readable name and identifier for a resource . |
28,792 | async def connect ( url , * , apikey = None , insecure = False ) : url = api_url ( url ) url = urlparse ( url ) if url . username is not None : raise ConnectError ( "Cannot provide user-name explicitly in URL (%r) when connecting; " "use login instead." % url . username ) if url . password is not None : raise ConnectEr... | Connect to a remote MAAS instance with apikey . |
28,793 | async def login ( url , * , anonymous = False , username = None , password = None , insecure = False ) : url = api_url ( url ) url = urlparse ( url ) if username is None : username = url . username else : if url . username is None : pass else : raise LoginError ( "User-name provided explicitly (%r) and in URL (%r); " "... | Log - in to a remote MAAS instance . |
28,794 | async def authenticate_with_macaroon ( url , insecure = False ) : executor = futures . ThreadPoolExecutor ( max_workers = 1 ) def get_token ( ) : client = httpbakery . Client ( ) resp = client . request ( 'POST' , '{}/account/?op=create_authorisation_token' . format ( url ) , verify = not insecure ) if resp . status_co... | Login via macaroons and generate and return new API keys . |
28,795 | async def authenticate ( url , username , password , * , insecure = False ) : url_versn = urljoin ( url , "version/" ) url_authn = urljoin ( url , "../../accounts/authenticate/" ) def check_response_is_okay ( response ) : if response . status != HTTPStatus . OK : raise RemoteError ( "{0} -> {1.status} {1.reason}" . for... | Obtain a new API key by logging into MAAS . |
28,796 | async def create ( cls , * , type : str , power_address : str , power_user : str = None , power_pass : str = None , name : str = None , zone : typing . Union [ str , Zone ] = None , tags : typing . Sequence [ str ] = None ) : params = remove_None ( { 'type' : type , 'power_address' : power_address , 'power_user' : powe... | Create a Pod in MAAS . |
28,797 | async def compose ( self , * , cores : int = None , memory : int = None , cpu_speed : int = None , architecture : str = None , storage : typing . Sequence [ str ] = None , hostname : str = None , domain : typing . Union [ int , str ] = None , zone : typing . Union [ int , str , Zone ] = None , interfaces : typing . Seq... | Compose a machine from Pod . |
28,798 | async def create ( cls , start_ip : str , end_ip : str , * , type : IPRangeType = IPRangeType . RESERVED , comment : str = None , subnet : Union [ Subnet , int ] = None ) : if not isinstance ( type , IPRangeType ) : raise TypeError ( "type must be an IPRangeType, not %s" % TYPE ( type ) . __name__ ) params = { 'start_i... | Create a IPRange in MAAS . |
28,799 | def gen_parents ( parents ) : for idx , parent in enumerate ( parents ) : if isinstance ( parent , Interface ) : parent = parent . id elif isinstance ( parent , int ) : pass else : raise TypeError ( 'parent[%d] must be an Interface or int, not %s' % ( idx , type ( parent ) . __name__ ) ) yield parent | Generate the parents to send to the handler . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.