Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def get_configured_providers(self): ''' Return the configured providers ''' providers = set() for alias, drivers in six.iteritems(self.opts['providers']): if len(drivers) > 1: for driver in drivers: ...
[]
Please provide a description of the function:def lookup_providers(self, lookup): ''' Get a dict describing the configured providers ''' if lookup is None: lookup = 'all' if lookup == 'all': providers = set() for alias, drivers in six.iteritems(...
[]
Please provide a description of the function:def lookup_profiles(self, provider, lookup): ''' Return a dictionary describing the configured profiles ''' if provider is None: provider = 'all' if lookup is None: lookup = 'all' if lookup == 'all': ...
[]
Please provide a description of the function:def map_providers_parallel(self, query='list_nodes', cached=False): ''' Return a mapping of what named VMs are running on what VM providers based on what providers are defined in the configuration and VMs Same as map_providers but query in pa...
[]
Please provide a description of the function:def _optimize_providers(self, providers): ''' Return an optimized mapping of available providers ''' new_providers = {} provider_by_driver = {} for alias, driver in six.iteritems(providers): for name, data in six.i...
[]
Please provide a description of the function:def image_list(self, lookup='all'): ''' Return a mapping of all image data for available providers ''' data = {} lookups = self.lookup_providers(lookup) if not lookups: return data for alias, driver in loo...
[]
Please provide a description of the function:def provider_list(self, lookup='all'): ''' Return a mapping of all image data for available providers ''' data = {} lookups = self.lookup_providers(lookup) if not lookups: return data for alias, driver in l...
[]
Please provide a description of the function:def profile_list(self, provider, lookup='all'): ''' Return a mapping of all configured profiles ''' data = {} lookups = self.lookup_profiles(provider, lookup) if not lookups: return data for alias, driver ...
[]
Please provide a description of the function:def create_all(self): ''' Create/Verify the VMs in the VM data ''' ret = [] for vm_name, vm_details in six.iteritems(self.opts['profiles']): ret.append( {vm_name: self.create(vm_details)} ) ...
[]
Please provide a description of the function:def destroy(self, names, cached=False): ''' Destroy the named VMs ''' processed = {} names = set(names) matching = self.get_running_by_names(names, cached=cached) vms_to_destroy = set() parallel_data = [] ...
[]
Please provide a description of the function:def reboot(self, names): ''' Reboot the named VMs ''' ret = [] pmap = self.map_providers_parallel() acts = {} for prov, nodes in six.iteritems(pmap): acts[prov] = [] for node in nodes: ...
[]
Please provide a description of the function:def create(self, vm_, local_master=True): ''' Create a single VM ''' output = {} minion_dict = salt.config.get_cloud_config_value( 'minion', vm_, self.opts, default={} ) alias, driver = vm_['provider'].spl...
[]
Please provide a description of the function:def vm_config(name, main, provider, profile, overrides): ''' Create vm config. :param str name: The name of the vm :param dict main: The main cloud config :param dict provider: The provider config :param dict profile: The prof...
[]
Please provide a description of the function:def extras(self, extra_): ''' Extra actions ''' output = {} alias, driver = extra_['provider'].split(':') fun = '{0}.{1}'.format(driver, extra_['action']) if fun not in self.clouds: log.error( ...
[]
Please provide a description of the function:def run_profile(self, profile, names, vm_overrides=None): ''' Parse over the options passed on the command line and determine how to handle them ''' if profile not in self.opts['profiles']: msg = 'Profile {0} is not defined...
[]
Please provide a description of the function:def do_action(self, names, kwargs): ''' Perform an action on a VM which may be specific to this cloud provider ''' ret = {} invalid_functions = {} names = set(names) for alias, drivers in six.iteritems(self.map_provide...
[]
Please provide a description of the function:def do_function(self, prov, func, kwargs): ''' Perform a function against a cloud provider ''' matches = self.lookup_providers(prov) if len(matches) > 1: raise SaltCloudSystemExit( 'More than one results mat...
[]
Please provide a description of the function:def __filter_non_working_providers(self): ''' Remove any mis-configured cloud providers from the available listing ''' for alias, drivers in six.iteritems(self.opts['providers'].copy()): for driver in drivers.copy(): ...
[]
Please provide a description of the function:def read(self): ''' Read in the specified map and return the map structure ''' map_ = None if self.opts.get('map', None) is None: if self.opts.get('map_data', None) is None: if self.opts.get('map_pillar', No...
[]
Please provide a description of the function:def map_data(self, cached=False): ''' Create a data map of what to execute on ''' ret = {'create': {}} pmap = self.map_providers_parallel(cached=cached) exist = set() defined = set() rendered_map = copy.deepcopy...
[]
Please provide a description of the function:def run_map(self, dmap): ''' Execute the contents of the VM map ''' if self._has_loop(dmap): msg = 'Uh-oh, that cloud map has a dependency loop!' log.error(msg) raise SaltCloudException(msg) # Go thr...
[]
Please provide a description of the function:def _get_user_info(user=None): ''' Wrapper for user.info Salt function ''' if not user: # Get user Salt runnining as user = __salt__['config.option']('user') userinfo = __salt__['user.info'](user) if not userinfo: if user == ...
[]
Please provide a description of the function:def _get_user_gnupghome(user): ''' Return default GnuPG home directory path for a user ''' if user == 'salt': gnupghome = os.path.join(__salt__['config.get']('config_dir'), 'gpgkeys') else: gnupghome = os.path.join(_get_user_info(user)['ho...
[]
Please provide a description of the function:def _create_gpg(user=None, gnupghome=None): ''' Create the GPG object ''' if not gnupghome: gnupghome = _get_user_gnupghome(user) if GPG_1_3_1: gpg = gnupg.GPG(homedir=gnupghome) else: gpg = gnupg.GPG(gnupghome=gnupghome) ...
[]
Please provide a description of the function:def _list_keys(user=None, gnupghome=None, secret=False): ''' Helper function for Listing keys ''' gpg = _create_gpg(user, gnupghome) _keys = gpg.list_keys(secret) return _keys
[]
Please provide a description of the function:def _search_keys(text, keyserver, user=None): ''' Helper function for searching keys from keyserver ''' gpg = _create_gpg(user) if keyserver: _keys = gpg.search_keys(text, keyserver) else: _keys = gpg.search_keys(text) return _keys
[]
Please provide a description of the function:def search_keys(text, keyserver=None, user=None): ''' Search keys from keyserver text Text to search the keyserver for, e.g. email address, keyID or fingerprint. keyserver Keyserver to use for searching for GPG keys, defaults to pgp.mit.edu....
[]
Please provide a description of the function:def list_keys(user=None, gnupghome=None): ''' List keys in GPG keychain user Which user's keychain to access, defaults to user Salt is running as. Passing the user as ``salt`` will set the GnuPG home directory to the ``/etc/salt/gpgkeys``...
[]
Please provide a description of the function:def create_key(key_type='RSA', key_length=1024, name_real='Autogenerated Key', name_comment='Generated by SaltStack', name_email=None, subkey_type=None, subkey_length=None, ...
[]
Please provide a description of the function:def delete_key(keyid=None, fingerprint=None, delete_secret=False, user=None, gnupghome=None): ''' Get a key from the GPG keychain keyid The keyid of the key to be deleted. fingerprint ...
[]
Please provide a description of the function:def get_key(keyid=None, fingerprint=None, user=None, gnupghome=None): ''' Get a key from the GPG keychain keyid The key ID (short or long) of the key to be retrieved. fingerprint The fingerprint of the key to be retrieved. user ...
[]
Please provide a description of the function:def import_key(text=None, filename=None, user=None, gnupghome=None): r''' Import a key from text or file text The text containing to import. filename The filename containing the key to import. ...
[]
Please provide a description of the function:def export_key(keyids=None, secret=False, user=None, gnupghome=None): ''' Export a key from the GPG keychain keyids The key ID(s) of the key(s) to be exported. Can be specified as a comma separated string or a list. Anything which GnuPG itself ac...
[]
Please provide a description of the function:def receive_keys(keyserver=None, keys=None, user=None, gnupghome=None): ''' Receive key(s) from keyserver and add them to keychain keyserver Keyserver to use for searching for GPG keys, defaults to pgp.mit.edu keys The keyID(s) to retrieve f...
[]
Please provide a description of the function:def trust_key(keyid=None, fingerprint=None, trust_level=None, user=None): ''' Set the trust level for a key in GPG keychain keyid The keyid of the key to set the trust level for. fingerprint The fing...
[]
Please provide a description of the function:def sign(user=None, keyid=None, text=None, filename=None, output=None, use_passphrase=False, gnupghome=None): ''' Sign message or file user Which user's keychain to access, defaults to user Salt is ru...
[]
Please provide a description of the function:def verify(text=None, user=None, filename=None, gnupghome=None, signature=None, trustmodel=None): ''' Verify a message or file text The text to verify. filename The filename to verify. ...
[]
Please provide a description of the function:def encrypt(user=None, recipients=None, text=None, filename=None, output=None, sign=None, use_passphrase=False, gnupghome=None, bare=False): ''' Encrypt a message or file ...
[]
Please provide a description of the function:def decrypt(user=None, text=None, filename=None, output=None, use_passphrase=False, gnupghome=None, bare=False): ''' Decrypt a message or file user Which user's keychain to access, d...
[]
Please provide a description of the function:def pack(o, stream, **kwargs): ''' .. versionadded:: 2018.3.4 Wraps msgpack.pack and ensures that the passed object is unwrapped if it is a proxy. By default, this function uses the msgpack module and falls back to msgpack_pure, if the msgpack is no...
[]
Please provide a description of the function:def unpack(stream, **kwargs): ''' .. versionadded:: 2018.3.4 Wraps msgpack.unpack. By default, this function uses the msgpack module and falls back to msgpack_pure, if the msgpack is not available. You can pass an alternate msgpack module using the ...
[]
Please provide a description of the function:def unpackb(packed, **kwargs): ''' .. versionadded:: 2018.3.4 Wraps msgpack.unpack. By default, this function uses the msgpack module and falls back to msgpack_pure, if the msgpack is not available. You can pass an alternate msgpack module using the...
[]
Please provide a description of the function:def _get_notifier(config): ''' Check the context for the notifier and construct it if not present ''' if 'inotify.notifier' not in __context__: __context__['inotify.queue'] = collections.deque() wm = pyinotify.WatchManager() __context_...
[]
Please provide a description of the function:def validate(config): ''' Validate the beacon configuration ''' VALID_MASK = [ 'access', 'attrib', 'close_nowrite', 'close_write', 'create', 'delete', 'delete_self', 'excl_unlink', 'igno...
[]
Please provide a description of the function:def beacon(config): ''' Watch the configured files Example Config .. code-block:: yaml beacons: inotify: - files: /path/to/file/or/dir: mask: - open - c...
[]
Please provide a description of the function:def _gem(command, ruby=None, runas=None, gem_bin=None): ''' Run the actual gem command. If rvm or rbenv is installed, run the command using the corresponding module. rbenv is not available on windows, so don't try. :param command: string Command to r...
[]
Please provide a description of the function:def install(gems, # pylint: disable=C0103 ruby=None, gem_bin=None, runas=None, version=None, rdoc=False, ri=False, pre_releases=False, proxy=None, source=Non...
[]
Please provide a description of the function:def uninstall(gems, ruby=None, runas=None, gem_bin=None): ''' Uninstall one or several gems. :param gems: string The gems to uninstall. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None I...
[]
Please provide a description of the function:def update(gems, ruby=None, runas=None, gem_bin=None): ''' Update one or several gems. :param gems: string The gems to update. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or ...
[]
Please provide a description of the function:def update_system(version='', ruby=None, runas=None, gem_bin=None): ''' Update rubygems. :param version: string : (newest) The version of rubygems to install. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: ...
[]
Please provide a description of the function:def version(ruby=None, runas=None, gem_bin=None): ''' Print out the version of gem :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemset to use....
[]
Please provide a description of the function:def list_(prefix='', ruby=None, runas=None, gem_bin=None): ''' List locally installed gems. :param prefix: string : Only list gems when the name matches this prefix. :param gem_bin: string : None Full path to ``gem`` binary to use. :param...
[]
Please provide a description of the function:def list_upgrades(ruby=None, runas=None, gem_bin=None): ''' .. versionadded:: 2015.8.0 Check if an upgrade is available for installed gems gem_bin : None Full path to ``gem`` binary to use. ruby : None ...
[]
Please provide a description of the function:def sources_add(source_uri, ruby=None, runas=None, gem_bin=None): ''' Add a gem source. :param source_uri: string The source URI to add. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None ...
[]
Please provide a description of the function:def sources_remove(source_uri, ruby=None, runas=None, gem_bin=None): ''' Remove a gem source. :param source_uri: string The source URI to remove. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None...
[]
Please provide a description of the function:def sources_list(ruby=None, runas=None, gem_bin=None): ''' List the configured gem sources. :param gem_bin: string : None Full path to ``gem`` binary to use. :param ruby: string : None If RVM or rbenv are installed, the ruby version and gemse...
[]
Please provide a description of the function:def generate_ticket(name, output=None, grain=None, key=None, overwrite=True): ''' Generate an icinga2 ticket on the master. name The domain name for which this ticket will be generated output grain: output in a grain other: the file ...
[]
Please provide a description of the function:def generate_cert(name): ''' Generate an icinga2 certificate and key on the client. name The domain name for which this certificate and key will be generated ''' ret = {'name': name, 'changes': {}, 'result': True, ...
[]
Please provide a description of the function:def save_cert(name, master): ''' Save the certificate on master icinga2 node. name The domain name for which this certificate will be saved master Icinga2 master node for which this certificate will be saved ''' ret = {'name': name, ...
[]
Please provide a description of the function:def request_cert(name, master, ticket, port="5665"): ''' Request CA certificate from master icinga2 node. name The domain name for which this certificate will be saved master Icinga2 master node for which this certificate will be saved ...
[]
Please provide a description of the function:def node_setup(name, master, ticket): ''' Setup the icinga2 node. name The domain name for which this certificate will be saved master Icinga2 master node for which this certificate will be saved ticket Authentication ticket gen...
[]
Please provide a description of the function:def avail_images(call=None): ''' Return available Linode images. CLI Example: .. code-block:: bash salt-cloud --list-images my-linode-config salt-cloud -f avail_images my-linode-config ''' if call == 'action': raise SaltClou...
[]
Please provide a description of the function:def avail_locations(call=None): ''' Return available Linode datacenter locations. CLI Example: .. code-block:: bash salt-cloud --list-locations my-linode-config salt-cloud -f avail_locations my-linode-config ''' if call == 'action':...
[]
Please provide a description of the function:def avail_sizes(call=None): ''' Return available Linode sizes. CLI Example: .. code-block:: bash salt-cloud --list-sizes my-linode-config salt-cloud -f avail_sizes my-linode-config ''' if call == 'action': raise SaltCloudExc...
[]
Please provide a description of the function:def boot(name=None, kwargs=None, call=None): ''' Boot a Linode. name The name of the Linode to boot. Can be used instead of ``linode_id``. linode_id The ID of the Linode to boot. If provided, will be used as an alternative to ``name`...
[]
Please provide a description of the function:def clone(kwargs=None, call=None): ''' Clone a Linode. linode_id The ID of the Linode to clone. Required. datacenter_id The ID of the Datacenter where the Linode will be placed. Required. plan_id The ID of the plan (size) of the...
[]
Please provide a description of the function:def create(vm_): ''' Create a single Linode VM. ''' name = vm_['name'] try: # Check for required profile parameters before sending any API calls. if vm_['profile'] and config.is_profile_configured(__opts__, ...
[]
Please provide a description of the function:def create_config(kwargs=None, call=None): ''' Creates a Linode Configuration Profile. name The name of the VM to create the config for. linode_id The ID of the Linode to create the configuration for. root_disk_id The Root Disk ...
[]
Please provide a description of the function:def create_disk_from_distro(vm_, linode_id, swap_size=None): r''' Creates the disk for the Linode from the distribution. vm\_ The VM profile to create the disk for. linode_id The ID of the Linode to create the distribution disk for. Required...
[]
Please provide a description of the function:def create_swap_disk(vm_, linode_id, swap_size=None): r''' Creates the disk for the specified Linode. vm\_ The VM profile to create the swap disk for. linode_id The ID of the Linode to create the swap disk for. swap_size The siz...
[]
Please provide a description of the function:def create_data_disk(vm_=None, linode_id=None, data_size=None): r''' Create a data disk for the linode (type is hardcoded to ext4 at the moment) .. versionadded:: 2016.3.0 vm\_ The VM profile to create the data disk for. linode_id The I...
[]
Please provide a description of the function:def create_private_ip(linode_id): r''' Creates a private IP for the specified Linode. linode_id The ID of the Linode to create the IP address for. ''' kwargs = {'LinodeID': linode_id} result = _query('linode', 'ip.addprivate', args=kwargs) ...
[]
Please provide a description of the function:def get_config_id(kwargs=None, call=None): ''' Returns a config_id for a given linode. .. versionadded:: 2015.8.0 name The name of the Linode for which to get the config_id. Can be used instead of ``linode_id``.h linode_id The I...
[]
Please provide a description of the function:def get_disk_size(vm_, swap, linode_id): r''' Returns the size of of the root disk in MB. vm\_ The VM to get the disk size for. ''' disk_size = get_linode(kwargs={'linode_id': linode_id})['TOTALHD'] return config.get_cloud_config_value( ...
[]
Please provide a description of the function:def get_data_disk_size(vm_, swap, linode_id): ''' Return the size of of the data disk in MB .. versionadded:: 2016.3.0 ''' disk_size = get_linode(kwargs={'linode_id': linode_id})['TOTALHD'] root_disk_size = config.get_cloud_config_value( 'dis...
[]
Please provide a description of the function:def get_distribution_id(vm_): r''' Returns the distribution ID for a VM vm\_ The VM to get the distribution ID for ''' distributions = _query('avail', 'distributions')['DATA'] vm_image_name = config.get_cloud_config_value('image', vm_, __opts...
[]
Please provide a description of the function:def get_ips(linode_id=None): ''' Returns public and private IP addresses. linode_id Limits the IP addresses returned to the specified Linode ID. ''' if linode_id: ips = _query('linode', 'ip.list', args={'LinodeID': linode_id}) else: ...
[]
Please provide a description of the function:def get_linode(kwargs=None, call=None): ''' Returns data for a single named Linode. name The name of the Linode for which to get data. Can be used instead ``linode_id``. Note this will induce an additional API call compared to using ``lin...
[]
Please provide a description of the function:def get_linode_id_from_name(name): ''' Returns the Linode ID for a VM from the provided name. name The name of the Linode from which to get the Linode ID. Required. ''' nodes = _query('linode', 'list')['DATA'] linode_id = '' for node in ...
[]
Please provide a description of the function:def get_password(vm_): r''' Return the password to use for a VM. vm\_ The configuration to obtain the password from. ''' return config.get_cloud_config_value( 'password', vm_, __opts__, default=config.get_cloud_config_value( ...
[]
Please provide a description of the function:def _decode_linode_plan_label(label): ''' Attempts to decode a user-supplied Linode plan label into the format in Linode API output label The label, or name, of the plan to decode. Example: `Linode 2048` will decode to `Linode 2GB` '...
[]
Please provide a description of the function:def get_plan_id(kwargs=None, call=None): ''' Returns the Linode Plan ID. label The label, or name, of the plan to get the ID from. CLI Example: .. code-block:: bash salt-cloud -f get_plan_id linode label="Linode 1024" ''' if ca...
[]
Please provide a description of the function:def get_vm_size(vm_): r''' Returns the VM's size. vm\_ The VM to get the size for. ''' vm_size = config.get_cloud_config_value('size', vm_, __opts__) ram = avail_sizes()[vm_size]['RAM'] if vm_size.startswith('Linode'): vm_size = ...
[]
Please provide a description of the function:def list_nodes_min(call=None): ''' Return a list of the VMs that are on the provider. Only a list of VM names and their state is returned. This is the minimum amount of information needed to check for existing VMs. .. versionadded:: 2015.8.0 CLI Exa...
[]
Please provide a description of the function:def reboot(name, call=None): ''' Reboot a linode. .. versionadded:: 2015.8.0 name The name of the VM to reboot. CLI Example: .. code-block:: bash salt-cloud -a reboot vm_name ''' if call != 'action': raise SaltClou...
[]
Please provide a description of the function:def show_instance(name, call=None): ''' Displays details about a particular Linode VM. Either a name or a linode_id must be provided. .. versionadded:: 2015.8.0 name The name of the VM for which to display details. CLI Example: .. code...
[]
Please provide a description of the function:def show_pricing(kwargs=None, call=None): ''' Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt-cloud -f show_pricing my-...
[]
Please provide a description of the function:def start(name, call=None): ''' Start a VM in Linode. name The name of the VM to start. CLI Example: .. code-block:: bash salt-cloud -a stop vm_name ''' if call != 'action': raise SaltCloudException( 'The st...
[]
Please provide a description of the function:def update_linode(linode_id, update_args=None): ''' Updates a Linode's properties. linode_id The ID of the Linode to shutdown. Required. update_args The args to update the Linode with. Must be in dictionary form. ''' update_args.upda...
[]
Please provide a description of the function:def _clean_data(api_response): ''' Returns the DATA response from a Linode API query as a single pre-formatted dictionary api_response The query to be cleaned. ''' data = {} data.update(api_response['DATA']) if not data: response...
[]
Please provide a description of the function:def _list_linodes(full=False): ''' Helper function to format and parse linode data ''' nodes = _query('linode', 'list')['DATA'] ips = get_ips() ret = {} for node in nodes: this_node = {} linode_id = six.text_type(node['LINODEID'])...
[]
Please provide a description of the function:def _query(action=None, command=None, args=None, method='GET', header_dict=None, data=None, url='https://api.linode.com/'): ''' Make a web call to the Linode API. ''' global LASTCALL vm_ = ...
[]
Please provide a description of the function:def _wait_for_job(linode_id, job_id, timeout=300, quiet=True): ''' Wait for a Job to return. linode_id The ID of the Linode to wait on. Required. job_id The ID of the job to wait for. timeout The amount of time to wait for a sta...
[]
Please provide a description of the function:def _wait_for_status(linode_id, status=None, timeout=300, quiet=True): ''' Wait for a certain status from Linode. linode_id The ID of the Linode to wait on. Required. status The status to look for to update. timeout The amount o...
[]
Please provide a description of the function:def _get_status_descr_by_id(status_id): ''' Return linode status by ID status_id linode VM status ID ''' for status_name, status_data in six.iteritems(LINODE_STATUS): if status_data['code'] == int(status_id): return status_dat...
[]
Please provide a description of the function:def _validate_name(name): ''' Checks if the provided name fits Linode's labeling parameters. .. versionadded:: 2015.5.6 name The VM name to validate ''' name = six.text_type(name) name_length = len(name) regex = re.compile(r'^[a-zA-Z...
[]
Please provide a description of the function:def _get_capirca_platform(): # pylint: disable=too-many-return-statements ''' Given the following NAPALM grains, we can determine the Capirca platform name: - vendor - device model - operating system Not the most optimal. ''' vendor = __gra...
[]
Please provide a description of the function:def load_term_config(filter_name, term_name, filter_options=None, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True, ...
[]
Please provide a description of the function:def load_filter_config(filter_name, filter_options=None, terms=None, prepend=True, pillar_key='acl', pillarenv=None, saltenv=None, ...
[]
Please provide a description of the function:def load_policy_config(filters=None, prepend=True, pillar_key='acl', pillarenv=None, saltenv=None, merge_pillar=True, only_lower_merge=Fa...
[]