repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
saltstack/salt
salt/fileserver/roots.py
update
def update(): ''' When we are asked to update (regular interval) lets reap the cache ''' try: salt.fileserver.reap_fileserver_cache_dir( os.path.join(__opts__['cachedir'], 'roots', 'hash'), find_file ) except (IOError, OSError): # Hash file won't exist if no files have yet been served up pass mtime_map_path = os.path.join(__opts__['cachedir'], 'roots', 'mtime_map') # data to send on event data = {'changed': False, 'files': {'changed': []}, 'backend': 'roots'} # generate the new map new_mtime_map = salt.fileserver.generate_mtime_map(__opts__, __opts__['file_roots']) old_mtime_map = {} # if you have an old map, load that if os.path.exists(mtime_map_path): with salt.utils.files.fopen(mtime_map_path, 'rb') as fp_: for line in fp_: line = salt.utils.stringutils.to_unicode(line) try: file_path, mtime = line.replace('\n', '').split(':', 1) old_mtime_map[file_path] = mtime if mtime != new_mtime_map.get(file_path, mtime): data['files']['changed'].append(file_path) except ValueError: # Document the invalid entry in the log log.warning( 'Skipped invalid cache mtime entry in %s: %s', mtime_map_path, line ) # compare the maps, set changed to the return value data['changed'] = salt.fileserver.diff_mtime_map(old_mtime_map, new_mtime_map) # compute files that were removed and added old_files = set(old_mtime_map.keys()) new_files = set(new_mtime_map.keys()) data['files']['removed'] = list(old_files - new_files) data['files']['added'] = list(new_files - old_files) # write out the new map mtime_map_path_dir = os.path.dirname(mtime_map_path) if not os.path.exists(mtime_map_path_dir): os.makedirs(mtime_map_path_dir) with salt.utils.files.fopen(mtime_map_path, 'wb') as fp_: for file_path, mtime in six.iteritems(new_mtime_map): fp_.write( salt.utils.stringutils.to_bytes( '{0}:{1}\n'.format(file_path, mtime) ) ) if __opts__.get('fileserver_events', False): # if there is a change, fire an event event = salt.utils.event.get_event( 'master', __opts__['sock_dir'], __opts__['transport'], opts=__opts__, listen=False) event.fire_event(data, salt.utils.event.tagify(['roots', 'update'], prefix='fileserver'))
python
def update(): ''' When we are asked to update (regular interval) lets reap the cache ''' try: salt.fileserver.reap_fileserver_cache_dir( os.path.join(__opts__['cachedir'], 'roots', 'hash'), find_file ) except (IOError, OSError): # Hash file won't exist if no files have yet been served up pass mtime_map_path = os.path.join(__opts__['cachedir'], 'roots', 'mtime_map') # data to send on event data = {'changed': False, 'files': {'changed': []}, 'backend': 'roots'} # generate the new map new_mtime_map = salt.fileserver.generate_mtime_map(__opts__, __opts__['file_roots']) old_mtime_map = {} # if you have an old map, load that if os.path.exists(mtime_map_path): with salt.utils.files.fopen(mtime_map_path, 'rb') as fp_: for line in fp_: line = salt.utils.stringutils.to_unicode(line) try: file_path, mtime = line.replace('\n', '').split(':', 1) old_mtime_map[file_path] = mtime if mtime != new_mtime_map.get(file_path, mtime): data['files']['changed'].append(file_path) except ValueError: # Document the invalid entry in the log log.warning( 'Skipped invalid cache mtime entry in %s: %s', mtime_map_path, line ) # compare the maps, set changed to the return value data['changed'] = salt.fileserver.diff_mtime_map(old_mtime_map, new_mtime_map) # compute files that were removed and added old_files = set(old_mtime_map.keys()) new_files = set(new_mtime_map.keys()) data['files']['removed'] = list(old_files - new_files) data['files']['added'] = list(new_files - old_files) # write out the new map mtime_map_path_dir = os.path.dirname(mtime_map_path) if not os.path.exists(mtime_map_path_dir): os.makedirs(mtime_map_path_dir) with salt.utils.files.fopen(mtime_map_path, 'wb') as fp_: for file_path, mtime in six.iteritems(new_mtime_map): fp_.write( salt.utils.stringutils.to_bytes( '{0}:{1}\n'.format(file_path, mtime) ) ) if __opts__.get('fileserver_events', False): # if there is a change, fire an event event = salt.utils.event.get_event( 'master', __opts__['sock_dir'], __opts__['transport'], opts=__opts__, listen=False) event.fire_event(data, salt.utils.event.tagify(['roots', 'update'], prefix='fileserver'))
[ "def", "update", "(", ")", ":", "try", ":", "salt", ".", "fileserver", ".", "reap_fileserver_cache_dir", "(", "os", ".", "path", ".", "join", "(", "__opts__", "[", "'cachedir'", "]", ",", "'roots'", ",", "'hash'", ")", ",", "find_file", ")", "except", ...
When we are asked to update (regular interval) lets reap the cache
[ "When", "we", "are", "asked", "to", "update", "(", "regular", "interval", ")", "lets", "reap", "the", "cache" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/roots.py#L143-L213
train
saltstack/salt
salt/fileserver/roots.py
_file_lists
def _file_lists(load, form): ''' Return a dict containing the file lists for files, dirs, emtydirs and symlinks ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') saltenv = load['saltenv'] if saltenv not in __opts__['file_roots']: if '__env__' in __opts__['file_roots']: log.debug("salt environment '%s' maps to __env__ file_roots directory", saltenv) saltenv = '__env__' else: return [] list_cachedir = os.path.join(__opts__['cachedir'], 'file_lists', 'roots') if not os.path.isdir(list_cachedir): try: os.makedirs(list_cachedir) except os.error: log.critical('Unable to make cachedir %s', list_cachedir) return [] list_cache = os.path.join(list_cachedir, '{0}.p'.format(salt.utils.files.safe_filename_leaf(saltenv))) w_lock = os.path.join(list_cachedir, '.{0}.w'.format(salt.utils.files.safe_filename_leaf(saltenv))) cache_match, refresh_cache, save_cache = \ salt.fileserver.check_file_list_cache( __opts__, form, list_cache, w_lock ) if cache_match is not None: return cache_match if refresh_cache: ret = { 'files': set(), 'dirs': set(), 'empty_dirs': set(), 'links': {} } def _add_to(tgt, fs_root, parent_dir, items): ''' Add the files to the target set ''' def _translate_sep(path): ''' Translate path separators for Windows masterless minions ''' return path.replace('\\', '/') if os.path.sep == '\\' else path for item in items: abs_path = os.path.join(parent_dir, item) log.trace('roots: Processing %s', abs_path) is_link = salt.utils.path.islink(abs_path) log.trace( 'roots: %s is %sa link', abs_path, 'not ' if not is_link else '' ) if is_link and __opts__['fileserver_ignoresymlinks']: continue rel_path = _translate_sep(os.path.relpath(abs_path, fs_root)) log.trace('roots: %s relative path is %s', abs_path, rel_path) if salt.fileserver.is_file_ignored(__opts__, rel_path): continue tgt.add(rel_path) try: if not os.listdir(abs_path): ret['empty_dirs'].add(rel_path) except Exception: # Generic exception because running os.listdir() on a # non-directory path raises an OSError on *NIX and a # WindowsError on Windows. pass if is_link: link_dest = salt.utils.path.readlink(abs_path) log.trace( 'roots: %s symlink destination is %s', abs_path, link_dest ) if salt.utils.platform.is_windows() \ and link_dest.startswith('\\\\'): # Symlink points to a network path. Since you can't # join UNC and non-UNC paths, just assume the original # path. log.trace( 'roots: %s is a UNC path, using %s instead', link_dest, abs_path ) link_dest = abs_path if link_dest.startswith('..'): joined = os.path.join(abs_path, link_dest) else: joined = os.path.join( os.path.dirname(abs_path), link_dest ) rel_dest = _translate_sep( os.path.relpath( os.path.realpath(os.path.normpath(joined)), fs_root ) ) log.trace( 'roots: %s relative path is %s', abs_path, rel_dest ) if not rel_dest.startswith('..'): # Only count the link if it does not point # outside of the root dir of the fileserver # (i.e. the "path" variable) ret['links'][rel_path] = link_dest for path in __opts__['file_roots'][saltenv]: for root, dirs, files in salt.utils.path.os_walk( path, followlinks=__opts__['fileserver_followsymlinks']): _add_to(ret['dirs'], path, root, dirs) _add_to(ret['files'], path, root, files) ret['files'] = sorted(ret['files']) ret['dirs'] = sorted(ret['dirs']) ret['empty_dirs'] = sorted(ret['empty_dirs']) if save_cache: try: salt.fileserver.write_file_list_cache( __opts__, ret, list_cache, w_lock ) except NameError: # Catch msgpack error in salt-ssh pass return ret.get(form, []) # Shouldn't get here, but if we do, this prevents a TypeError return []
python
def _file_lists(load, form): ''' Return a dict containing the file lists for files, dirs, emtydirs and symlinks ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') saltenv = load['saltenv'] if saltenv not in __opts__['file_roots']: if '__env__' in __opts__['file_roots']: log.debug("salt environment '%s' maps to __env__ file_roots directory", saltenv) saltenv = '__env__' else: return [] list_cachedir = os.path.join(__opts__['cachedir'], 'file_lists', 'roots') if not os.path.isdir(list_cachedir): try: os.makedirs(list_cachedir) except os.error: log.critical('Unable to make cachedir %s', list_cachedir) return [] list_cache = os.path.join(list_cachedir, '{0}.p'.format(salt.utils.files.safe_filename_leaf(saltenv))) w_lock = os.path.join(list_cachedir, '.{0}.w'.format(salt.utils.files.safe_filename_leaf(saltenv))) cache_match, refresh_cache, save_cache = \ salt.fileserver.check_file_list_cache( __opts__, form, list_cache, w_lock ) if cache_match is not None: return cache_match if refresh_cache: ret = { 'files': set(), 'dirs': set(), 'empty_dirs': set(), 'links': {} } def _add_to(tgt, fs_root, parent_dir, items): ''' Add the files to the target set ''' def _translate_sep(path): ''' Translate path separators for Windows masterless minions ''' return path.replace('\\', '/') if os.path.sep == '\\' else path for item in items: abs_path = os.path.join(parent_dir, item) log.trace('roots: Processing %s', abs_path) is_link = salt.utils.path.islink(abs_path) log.trace( 'roots: %s is %sa link', abs_path, 'not ' if not is_link else '' ) if is_link and __opts__['fileserver_ignoresymlinks']: continue rel_path = _translate_sep(os.path.relpath(abs_path, fs_root)) log.trace('roots: %s relative path is %s', abs_path, rel_path) if salt.fileserver.is_file_ignored(__opts__, rel_path): continue tgt.add(rel_path) try: if not os.listdir(abs_path): ret['empty_dirs'].add(rel_path) except Exception: # Generic exception because running os.listdir() on a # non-directory path raises an OSError on *NIX and a # WindowsError on Windows. pass if is_link: link_dest = salt.utils.path.readlink(abs_path) log.trace( 'roots: %s symlink destination is %s', abs_path, link_dest ) if salt.utils.platform.is_windows() \ and link_dest.startswith('\\\\'): # Symlink points to a network path. Since you can't # join UNC and non-UNC paths, just assume the original # path. log.trace( 'roots: %s is a UNC path, using %s instead', link_dest, abs_path ) link_dest = abs_path if link_dest.startswith('..'): joined = os.path.join(abs_path, link_dest) else: joined = os.path.join( os.path.dirname(abs_path), link_dest ) rel_dest = _translate_sep( os.path.relpath( os.path.realpath(os.path.normpath(joined)), fs_root ) ) log.trace( 'roots: %s relative path is %s', abs_path, rel_dest ) if not rel_dest.startswith('..'): # Only count the link if it does not point # outside of the root dir of the fileserver # (i.e. the "path" variable) ret['links'][rel_path] = link_dest for path in __opts__['file_roots'][saltenv]: for root, dirs, files in salt.utils.path.os_walk( path, followlinks=__opts__['fileserver_followsymlinks']): _add_to(ret['dirs'], path, root, dirs) _add_to(ret['files'], path, root, files) ret['files'] = sorted(ret['files']) ret['dirs'] = sorted(ret['dirs']) ret['empty_dirs'] = sorted(ret['empty_dirs']) if save_cache: try: salt.fileserver.write_file_list_cache( __opts__, ret, list_cache, w_lock ) except NameError: # Catch msgpack error in salt-ssh pass return ret.get(form, []) # Shouldn't get here, but if we do, this prevents a TypeError return []
[ "def", "_file_lists", "(", "load", ",", "form", ")", ":", "if", "'env'", "in", "load", ":", "# \"env\" is not supported; Use \"saltenv\".", "load", ".", "pop", "(", "'env'", ")", "saltenv", "=", "load", "[", "'saltenv'", "]", "if", "saltenv", "not", "in", ...
Return a dict containing the file lists for files, dirs, emtydirs and symlinks
[ "Return", "a", "dict", "containing", "the", "file", "lists", "for", "files", "dirs", "emtydirs", "and", "symlinks" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/roots.py#L295-L426
train
saltstack/salt
salt/fileserver/roots.py
symlink_list
def symlink_list(load): ''' Return a dict of all symlinks based on a given path on the Master ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = {} if load['saltenv'] not in __opts__['file_roots'] and '__env__' not in __opts__['file_roots']: return ret if 'prefix' in load: prefix = load['prefix'].strip('/') else: prefix = '' symlinks = _file_lists(load, 'links') return dict([(key, val) for key, val in six.iteritems(symlinks) if key.startswith(prefix)])
python
def symlink_list(load): ''' Return a dict of all symlinks based on a given path on the Master ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = {} if load['saltenv'] not in __opts__['file_roots'] and '__env__' not in __opts__['file_roots']: return ret if 'prefix' in load: prefix = load['prefix'].strip('/') else: prefix = '' symlinks = _file_lists(load, 'links') return dict([(key, val) for key, val in six.iteritems(symlinks) if key.startswith(prefix)])
[ "def", "symlink_list", "(", "load", ")", ":", "if", "'env'", "in", "load", ":", "# \"env\" is not supported; Use \"saltenv\".", "load", ".", "pop", "(", "'env'", ")", "ret", "=", "{", "}", "if", "load", "[", "'saltenv'", "]", "not", "in", "__opts__", "[", ...
Return a dict of all symlinks based on a given path on the Master
[ "Return", "a", "dict", "of", "all", "symlinks", "based", "on", "a", "given", "path", "on", "the", "Master" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/roots.py#L451-L471
train
saltstack/salt
salt/beacons/load.py
validate
def validate(config): ''' Validate the beacon configuration ''' # Configuration for load beacon should be a list of dicts if not isinstance(config, list): return False, ('Configuration for load beacon must be a list.') else: _config = {} list(map(_config.update, config)) if 'emitatstartup' in _config: if not isinstance(_config['emitatstartup'], bool): return False, ('Configuration for load beacon option ' 'emitatstartup must be a boolean.') if 'onchangeonly' in _config: if not isinstance(_config['onchangeonly'], bool): return False, ('Configuration for load beacon option ' 'onchangeonly must be a boolean.') if 'averages' not in _config: return False, ('Averages configuration is required' ' for load beacon.') else: if not any(j in ['1m', '5m', '15m'] for j in _config.get('averages', {})): return False, ('Averages configuration for load beacon ' 'must contain 1m, 5m or 15m items.') for item in ['1m', '5m', '15m']: if not isinstance(_config['averages'][item], list): return False, ('Averages configuration for load beacon: ' '1m, 5m and 15m items must be ' 'a list of two items.') else: if len(_config['averages'][item]) != 2: return False, ('Configuration for load beacon: ' '1m, 5m and 15m items must be ' 'a list of two items.') return True, 'Valid beacon configuration'
python
def validate(config): ''' Validate the beacon configuration ''' # Configuration for load beacon should be a list of dicts if not isinstance(config, list): return False, ('Configuration for load beacon must be a list.') else: _config = {} list(map(_config.update, config)) if 'emitatstartup' in _config: if not isinstance(_config['emitatstartup'], bool): return False, ('Configuration for load beacon option ' 'emitatstartup must be a boolean.') if 'onchangeonly' in _config: if not isinstance(_config['onchangeonly'], bool): return False, ('Configuration for load beacon option ' 'onchangeonly must be a boolean.') if 'averages' not in _config: return False, ('Averages configuration is required' ' for load beacon.') else: if not any(j in ['1m', '5m', '15m'] for j in _config.get('averages', {})): return False, ('Averages configuration for load beacon ' 'must contain 1m, 5m or 15m items.') for item in ['1m', '5m', '15m']: if not isinstance(_config['averages'][item], list): return False, ('Averages configuration for load beacon: ' '1m, 5m and 15m items must be ' 'a list of two items.') else: if len(_config['averages'][item]) != 2: return False, ('Configuration for load beacon: ' '1m, 5m and 15m items must be ' 'a list of two items.') return True, 'Valid beacon configuration'
[ "def", "validate", "(", "config", ")", ":", "# Configuration for load beacon should be a list of dicts", "if", "not", "isinstance", "(", "config", ",", "list", ")", ":", "return", "False", ",", "(", "'Configuration for load beacon must be a list.'", ")", "else", ":", ...
Validate the beacon configuration
[ "Validate", "the", "beacon", "configuration" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/load.py#L32-L75
train
saltstack/salt
salt/beacons/load.py
beacon
def beacon(config): ''' Emit the load averages of this host. Specify thresholds for each load average and only emit a beacon if any of them are exceeded. `onchangeonly`: when `onchangeonly` is True the beacon will fire events only when the load average pass one threshold. Otherwise, it will fire an event at each beacon interval. The default is False. `emitatstartup`: when `emitatstartup` is False the beacon will not fire event when the minion is reload. Applicable only when `onchangeonly` is True. The default is True. .. code-block:: yaml beacons: load: - averages: 1m: - 0.0 - 2.0 5m: - 0.0 - 1.5 15m: - 0.1 - 1.0 - emitatstartup: True - onchangeonly: False ''' log.trace('load beacon starting') _config = {} list(map(_config.update, config)) # Default config if not present if 'emitatstartup' not in _config: _config['emitatstartup'] = True if 'onchangeonly' not in _config: _config['onchangeonly'] = False ret = [] avgs = os.getloadavg() avg_keys = ['1m', '5m', '15m'] avg_dict = dict(zip(avg_keys, avgs)) if _config['onchangeonly']: if not LAST_STATUS: for k in ['1m', '5m', '15m']: LAST_STATUS[k] = avg_dict[k] if not _config['emitatstartup']: log.debug("Don't emit because emitatstartup is False") return ret send_beacon = False # Check each entry for threshold for k in ['1m', '5m', '15m']: if k in _config.get('averages', {}): if _config['onchangeonly']: # Emit if current is more that threshold and old value less # that threshold if float(avg_dict[k]) > float(_config['averages'][k][1]) and \ float(LAST_STATUS[k]) < float(_config['averages'][k][1]): log.debug('Emit because %f > %f and last was ' '%f', float(avg_dict[k]), float(_config['averages'][k][1]), float(LAST_STATUS[k])) send_beacon = True break # Emit if current is less that threshold and old value more # that threshold if float(avg_dict[k]) < float(_config['averages'][k][0]) and \ float(LAST_STATUS[k]) > float(_config['averages'][k][0]): log.debug('Emit because %f < %f and last was' '%f', float(avg_dict[k]), float(_config['averages'][k][0]), float(LAST_STATUS[k])) send_beacon = True break else: # Emit no matter LAST_STATUS if float(avg_dict[k]) < float(_config['averages'][k][0]) or \ float(avg_dict[k]) > float(_config['averages'][k][1]): log.debug('Emit because %f < %f or > ' '%f', float(avg_dict[k]), float(_config['averages'][k][0]), float(_config['averages'][k][1])) send_beacon = True break if _config['onchangeonly']: for k in ['1m', '5m', '15m']: LAST_STATUS[k] = avg_dict[k] if send_beacon: ret.append(avg_dict) return ret
python
def beacon(config): ''' Emit the load averages of this host. Specify thresholds for each load average and only emit a beacon if any of them are exceeded. `onchangeonly`: when `onchangeonly` is True the beacon will fire events only when the load average pass one threshold. Otherwise, it will fire an event at each beacon interval. The default is False. `emitatstartup`: when `emitatstartup` is False the beacon will not fire event when the minion is reload. Applicable only when `onchangeonly` is True. The default is True. .. code-block:: yaml beacons: load: - averages: 1m: - 0.0 - 2.0 5m: - 0.0 - 1.5 15m: - 0.1 - 1.0 - emitatstartup: True - onchangeonly: False ''' log.trace('load beacon starting') _config = {} list(map(_config.update, config)) # Default config if not present if 'emitatstartup' not in _config: _config['emitatstartup'] = True if 'onchangeonly' not in _config: _config['onchangeonly'] = False ret = [] avgs = os.getloadavg() avg_keys = ['1m', '5m', '15m'] avg_dict = dict(zip(avg_keys, avgs)) if _config['onchangeonly']: if not LAST_STATUS: for k in ['1m', '5m', '15m']: LAST_STATUS[k] = avg_dict[k] if not _config['emitatstartup']: log.debug("Don't emit because emitatstartup is False") return ret send_beacon = False # Check each entry for threshold for k in ['1m', '5m', '15m']: if k in _config.get('averages', {}): if _config['onchangeonly']: # Emit if current is more that threshold and old value less # that threshold if float(avg_dict[k]) > float(_config['averages'][k][1]) and \ float(LAST_STATUS[k]) < float(_config['averages'][k][1]): log.debug('Emit because %f > %f and last was ' '%f', float(avg_dict[k]), float(_config['averages'][k][1]), float(LAST_STATUS[k])) send_beacon = True break # Emit if current is less that threshold and old value more # that threshold if float(avg_dict[k]) < float(_config['averages'][k][0]) and \ float(LAST_STATUS[k]) > float(_config['averages'][k][0]): log.debug('Emit because %f < %f and last was' '%f', float(avg_dict[k]), float(_config['averages'][k][0]), float(LAST_STATUS[k])) send_beacon = True break else: # Emit no matter LAST_STATUS if float(avg_dict[k]) < float(_config['averages'][k][0]) or \ float(avg_dict[k]) > float(_config['averages'][k][1]): log.debug('Emit because %f < %f or > ' '%f', float(avg_dict[k]), float(_config['averages'][k][0]), float(_config['averages'][k][1])) send_beacon = True break if _config['onchangeonly']: for k in ['1m', '5m', '15m']: LAST_STATUS[k] = avg_dict[k] if send_beacon: ret.append(avg_dict) return ret
[ "def", "beacon", "(", "config", ")", ":", "log", ".", "trace", "(", "'load beacon starting'", ")", "_config", "=", "{", "}", "list", "(", "map", "(", "_config", ".", "update", ",", "config", ")", ")", "# Default config if not present", "if", "'emitatstartup'...
Emit the load averages of this host. Specify thresholds for each load average and only emit a beacon if any of them are exceeded. `onchangeonly`: when `onchangeonly` is True the beacon will fire events only when the load average pass one threshold. Otherwise, it will fire an event at each beacon interval. The default is False. `emitatstartup`: when `emitatstartup` is False the beacon will not fire event when the minion is reload. Applicable only when `onchangeonly` is True. The default is True. .. code-block:: yaml beacons: load: - averages: 1m: - 0.0 - 2.0 5m: - 0.0 - 1.5 15m: - 0.1 - 1.0 - emitatstartup: True - onchangeonly: False
[ "Emit", "the", "load", "averages", "of", "this", "host", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/load.py#L78-L180
train
saltstack/salt
salt/modules/lxd.py
init
def init(storage_backend='dir', trust_password=None, network_address=None, network_port=None, storage_create_device=None, storage_create_loop=None, storage_pool=None): ''' Calls lxd init --auto -- opts storage_backend : Storage backend to use (zfs or dir, default: dir) trust_password : Password required to add new clients network_address : None Address to bind LXD to (default: none) network_port : None Port to bind LXD to (Default: 8443) storage_create_device : None Setup device based storage using this DEVICE storage_create_loop : None Setup loop based storage with this SIZE in GB storage_pool : None Storage pool to use or create CLI Examples: To listen on all IPv4/IPv6 Addresses: .. code-block:: bash salt '*' lxd.init dir PaSsW0rD [::] To not listen on Network: .. code-block:: bash salt '*' lxd.init ''' cmd = ('lxd init --auto' ' --storage-backend="{0}"').format( storage_backend ) if trust_password is not None: cmd = cmd + ' --trust-password="{0}"'.format(trust_password) if network_address is not None: cmd = cmd + ' --network-address="{0}"'.format(network_address) if network_port is not None: cmd = cmd + ' --network-port="{0}"'.format(network_port) if storage_create_device is not None: cmd = cmd + ' --storage-create-device="{0}"'.format( storage_create_device ) if storage_create_loop is not None: cmd = cmd + ' --storage-create-loop="{0}"'.format( storage_create_loop ) if storage_pool is not None: cmd = cmd + ' --storage-pool="{0}"'.format(storage_pool) try: output = __salt__['cmd.run'](cmd) except ValueError as e: raise CommandExecutionError( "Failed to call: '{0}', error was: {1}".format( cmd, six.text_type(e) ), ) if 'error:' in output: raise CommandExecutionError( output[output.index('error:') + 7:], ) return output
python
def init(storage_backend='dir', trust_password=None, network_address=None, network_port=None, storage_create_device=None, storage_create_loop=None, storage_pool=None): ''' Calls lxd init --auto -- opts storage_backend : Storage backend to use (zfs or dir, default: dir) trust_password : Password required to add new clients network_address : None Address to bind LXD to (default: none) network_port : None Port to bind LXD to (Default: 8443) storage_create_device : None Setup device based storage using this DEVICE storage_create_loop : None Setup loop based storage with this SIZE in GB storage_pool : None Storage pool to use or create CLI Examples: To listen on all IPv4/IPv6 Addresses: .. code-block:: bash salt '*' lxd.init dir PaSsW0rD [::] To not listen on Network: .. code-block:: bash salt '*' lxd.init ''' cmd = ('lxd init --auto' ' --storage-backend="{0}"').format( storage_backend ) if trust_password is not None: cmd = cmd + ' --trust-password="{0}"'.format(trust_password) if network_address is not None: cmd = cmd + ' --network-address="{0}"'.format(network_address) if network_port is not None: cmd = cmd + ' --network-port="{0}"'.format(network_port) if storage_create_device is not None: cmd = cmd + ' --storage-create-device="{0}"'.format( storage_create_device ) if storage_create_loop is not None: cmd = cmd + ' --storage-create-loop="{0}"'.format( storage_create_loop ) if storage_pool is not None: cmd = cmd + ' --storage-pool="{0}"'.format(storage_pool) try: output = __salt__['cmd.run'](cmd) except ValueError as e: raise CommandExecutionError( "Failed to call: '{0}', error was: {1}".format( cmd, six.text_type(e) ), ) if 'error:' in output: raise CommandExecutionError( output[output.index('error:') + 7:], ) return output
[ "def", "init", "(", "storage_backend", "=", "'dir'", ",", "trust_password", "=", "None", ",", "network_address", "=", "None", ",", "network_port", "=", "None", ",", "storage_create_device", "=", "None", ",", "storage_create_loop", "=", "None", ",", "storage_pool...
Calls lxd init --auto -- opts storage_backend : Storage backend to use (zfs or dir, default: dir) trust_password : Password required to add new clients network_address : None Address to bind LXD to (default: none) network_port : None Port to bind LXD to (Default: 8443) storage_create_device : None Setup device based storage using this DEVICE storage_create_loop : None Setup loop based storage with this SIZE in GB storage_pool : None Storage pool to use or create CLI Examples: To listen on all IPv4/IPv6 Addresses: .. code-block:: bash salt '*' lxd.init dir PaSsW0rD [::] To not listen on Network: .. code-block:: bash salt '*' lxd.init
[ "Calls", "lxd", "init", "--", "auto", "--", "opts" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L144-L227
train
saltstack/salt
salt/modules/lxd.py
config_set
def config_set(key, value): ''' Set an LXD daemon config option CLI Examples: To listen on IPv4 and IPv6 port 8443, you can omit the :8443 its the default: .. code-block:: bash salt '*' lxd.config_set core.https_address [::]:8443 To set the server trust password: .. code-block:: bash salt '*' lxd.config_set core.trust_password blah ''' cmd = 'lxc config set "{0}" "{1}"'.format( key, value, ) output = __salt__['cmd.run'](cmd) if 'error:' in output: raise CommandExecutionError( output[output.index('error:') + 7:], ) return 'Config value "{0}" successfully set.'.format(key),
python
def config_set(key, value): ''' Set an LXD daemon config option CLI Examples: To listen on IPv4 and IPv6 port 8443, you can omit the :8443 its the default: .. code-block:: bash salt '*' lxd.config_set core.https_address [::]:8443 To set the server trust password: .. code-block:: bash salt '*' lxd.config_set core.trust_password blah ''' cmd = 'lxc config set "{0}" "{1}"'.format( key, value, ) output = __salt__['cmd.run'](cmd) if 'error:' in output: raise CommandExecutionError( output[output.index('error:') + 7:], ) return 'Config value "{0}" successfully set.'.format(key),
[ "def", "config_set", "(", "key", ",", "value", ")", ":", "cmd", "=", "'lxc config set \"{0}\" \"{1}\"'", ".", "format", "(", "key", ",", "value", ",", ")", "output", "=", "__salt__", "[", "'cmd.run'", "]", "(", "cmd", ")", "if", "'error:'", "in", "output...
Set an LXD daemon config option CLI Examples: To listen on IPv4 and IPv6 port 8443, you can omit the :8443 its the default: .. code-block:: bash salt '*' lxd.config_set core.https_address [::]:8443 To set the server trust password: .. code-block:: bash salt '*' lxd.config_set core.trust_password blah
[ "Set", "an", "LXD", "daemon", "config", "option" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L232-L263
train
saltstack/salt
salt/modules/lxd.py
config_get
def config_get(key): ''' Get an LXD daemon config option key : The key of the config value to retrieve CLI Examples: .. code-block:: bash salt '*' lxd.config_get core.https_address ''' cmd = 'lxc config get "{0}"'.format( key ) output = __salt__['cmd.run'](cmd) if 'error:' in output: raise CommandExecutionError( output[output.index('error:') + 7:], ) return output
python
def config_get(key): ''' Get an LXD daemon config option key : The key of the config value to retrieve CLI Examples: .. code-block:: bash salt '*' lxd.config_get core.https_address ''' cmd = 'lxc config get "{0}"'.format( key ) output = __salt__['cmd.run'](cmd) if 'error:' in output: raise CommandExecutionError( output[output.index('error:') + 7:], ) return output
[ "def", "config_get", "(", "key", ")", ":", "cmd", "=", "'lxc config get \"{0}\"'", ".", "format", "(", "key", ")", "output", "=", "__salt__", "[", "'cmd.run'", "]", "(", "cmd", ")", "if", "'error:'", "in", "output", ":", "raise", "CommandExecutionError", "...
Get an LXD daemon config option key : The key of the config value to retrieve CLI Examples: .. code-block:: bash salt '*' lxd.config_get core.https_address
[ "Get", "an", "LXD", "daemon", "config", "option" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L268-L292
train
saltstack/salt
salt/modules/lxd.py
pylxd_client_get
def pylxd_client_get(remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get an pyxld client, this is not ment to be runned over the CLI. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. See the `requests-docs`_ for the SSL stuff. .. _requests-docs: http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification ''' pool_key = '|'.join((six.text_type(remote_addr), six.text_type(cert), six.text_type(key), six.text_type(verify_cert),)) if pool_key in _connection_pool: log.debug('Returning the client "%s" from our connection pool', remote_addr) return _connection_pool[pool_key] try: if remote_addr is None or remote_addr == '/var/lib/lxd/unix.socket': log.debug('Trying to connect to the local unix socket') client = pylxd.Client() else: if remote_addr.startswith('/'): client = pylxd.Client(remote_addr) else: if cert is None or key is None: raise SaltInvocationError( ('You have to give a Cert and ' 'Key file for remote endpoints.') ) cert = os.path.expanduser(cert) key = os.path.expanduser(key) if not os.path.isfile(cert): raise SaltInvocationError( ('You have given an invalid cert path: "{0}", ' 'the file does not exists or is not a file.').format( cert ) ) if not os.path.isfile(key): raise SaltInvocationError( ('You have given an invalid key path: "{0}", ' 'the file does not exists or is not a file.').format( key ) ) log.debug( 'Trying to connect to "%s" with cert "%s", key "%s" and ' 'verify_cert "%s"', remote_addr, cert, key, verify_cert ) client = pylxd.Client( endpoint=remote_addr, cert=(cert, key,), verify=verify_cert ) except pylxd.exceptions.ClientConnectionFailed: raise CommandExecutionError( "Failed to connect to '{0}'".format(remote_addr) ) except TypeError as e: # Happens when the verification failed. raise CommandExecutionError( ('Failed to connect to "{0}",' ' looks like the SSL verification failed, error was: {1}' ).format(remote_addr, six.text_type(e)) ) _connection_pool[pool_key] = client return client
python
def pylxd_client_get(remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get an pyxld client, this is not ment to be runned over the CLI. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. See the `requests-docs`_ for the SSL stuff. .. _requests-docs: http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification ''' pool_key = '|'.join((six.text_type(remote_addr), six.text_type(cert), six.text_type(key), six.text_type(verify_cert),)) if pool_key in _connection_pool: log.debug('Returning the client "%s" from our connection pool', remote_addr) return _connection_pool[pool_key] try: if remote_addr is None or remote_addr == '/var/lib/lxd/unix.socket': log.debug('Trying to connect to the local unix socket') client = pylxd.Client() else: if remote_addr.startswith('/'): client = pylxd.Client(remote_addr) else: if cert is None or key is None: raise SaltInvocationError( ('You have to give a Cert and ' 'Key file for remote endpoints.') ) cert = os.path.expanduser(cert) key = os.path.expanduser(key) if not os.path.isfile(cert): raise SaltInvocationError( ('You have given an invalid cert path: "{0}", ' 'the file does not exists or is not a file.').format( cert ) ) if not os.path.isfile(key): raise SaltInvocationError( ('You have given an invalid key path: "{0}", ' 'the file does not exists or is not a file.').format( key ) ) log.debug( 'Trying to connect to "%s" with cert "%s", key "%s" and ' 'verify_cert "%s"', remote_addr, cert, key, verify_cert ) client = pylxd.Client( endpoint=remote_addr, cert=(cert, key,), verify=verify_cert ) except pylxd.exceptions.ClientConnectionFailed: raise CommandExecutionError( "Failed to connect to '{0}'".format(remote_addr) ) except TypeError as e: # Happens when the verification failed. raise CommandExecutionError( ('Failed to connect to "{0}",' ' looks like the SSL verification failed, error was: {1}' ).format(remote_addr, six.text_type(e)) ) _connection_pool[pool_key] = client return client
[ "def", "pylxd_client_get", "(", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "pool_key", "=", "'|'", ".", "join", "(", "(", "six", ".", "text_type", "(", "remote_addr", ")", ...
Get an pyxld client, this is not ment to be runned over the CLI. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. See the `requests-docs`_ for the SSL stuff. .. _requests-docs: http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification
[ "Get", "an", "pyxld", "client", "this", "is", "not", "ment", "to", "be", "runned", "over", "the", "CLI", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L298-L399
train
saltstack/salt
salt/modules/lxd.py
pylxd_save_object
def pylxd_save_object(obj): ''' Saves an object (profile/image/container) and translate its execpetion on failure obj : The object to save This is an internal method, no CLI Example. ''' try: obj.save() except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError(six.text_type(e)) return True
python
def pylxd_save_object(obj): ''' Saves an object (profile/image/container) and translate its execpetion on failure obj : The object to save This is an internal method, no CLI Example. ''' try: obj.save() except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError(six.text_type(e)) return True
[ "def", "pylxd_save_object", "(", "obj", ")", ":", "try", ":", "obj", ".", "save", "(", ")", "except", "pylxd", ".", "exceptions", ".", "LXDAPIException", "as", "e", ":", "raise", "CommandExecutionError", "(", "six", ".", "text_type", "(", "e", ")", ")", ...
Saves an object (profile/image/container) and translate its execpetion on failure obj : The object to save This is an internal method, no CLI Example.
[ "Saves", "an", "object", "(", "profile", "/", "image", "/", "container", ")", "and", "translate", "its", "execpetion", "on", "failure" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L402-L416
train
saltstack/salt
salt/modules/lxd.py
authenticate
def authenticate(remote_addr, password, cert, key, verify_cert=True): ''' Authenticate with a remote LXDaemon. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 password : The password of the remote. cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.authenticate https://srv01:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false See the `requests-docs`_ for the SSL stuff. .. _requests-docs: http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) if client.trusted: return True try: client.authenticate(password) except pylxd.exceptions.LXDAPIException as e: # Wrong password raise CommandExecutionError(six.text_type(e)) return client.trusted
python
def authenticate(remote_addr, password, cert, key, verify_cert=True): ''' Authenticate with a remote LXDaemon. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 password : The password of the remote. cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.authenticate https://srv01:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false See the `requests-docs`_ for the SSL stuff. .. _requests-docs: http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) if client.trusted: return True try: client.authenticate(password) except pylxd.exceptions.LXDAPIException as e: # Wrong password raise CommandExecutionError(six.text_type(e)) return client.trusted
[ "def", "authenticate", "(", "remote_addr", ",", "password", ",", "cert", ",", "key", ",", "verify_cert", "=", "True", ")", ":", "client", "=", "pylxd_client_get", "(", "remote_addr", ",", "cert", ",", "key", ",", "verify_cert", ")", "if", "client", ".", ...
Authenticate with a remote LXDaemon. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 password : The password of the remote. cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.authenticate https://srv01:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false See the `requests-docs`_ for the SSL stuff. .. _requests-docs: http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification
[ "Authenticate", "with", "a", "remote", "LXDaemon", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L419-L472
train
saltstack/salt
salt/modules/lxd.py
container_list
def container_list(list_names=False, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Lists containers list_names : False Only return a list of names when True remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: Full dict with all available informations: .. code-block:: bash salt '*' lxd.container_list For a list of names: .. code-block:: bash salt '*' lxd.container_list true See also `container-attributes`_. .. _container-attributes: https://github.com/lxc/pylxd/blob/master/doc/source/containers.rst#container-attributes ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) containers = client.containers.all() if list_names: return [c.name for c in containers] return map(_pylxd_model_to_dict, containers)
python
def container_list(list_names=False, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Lists containers list_names : False Only return a list of names when True remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: Full dict with all available informations: .. code-block:: bash salt '*' lxd.container_list For a list of names: .. code-block:: bash salt '*' lxd.container_list true See also `container-attributes`_. .. _container-attributes: https://github.com/lxc/pylxd/blob/master/doc/source/containers.rst#container-attributes ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) containers = client.containers.all() if list_names: return [c.name for c in containers] return map(_pylxd_model_to_dict, containers)
[ "def", "container_list", "(", "list_names", "=", "False", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "client", "=", "pylxd_client_get", "(", "remote_addr", ",", "cert", "...
Lists containers list_names : False Only return a list of names when True remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: Full dict with all available informations: .. code-block:: bash salt '*' lxd.container_list For a list of names: .. code-block:: bash salt '*' lxd.container_list true See also `container-attributes`_. .. _container-attributes: https://github.com/lxc/pylxd/blob/master/doc/source/containers.rst#container-attributes
[ "Lists", "containers" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L478-L536
train
saltstack/salt
salt/modules/lxd.py
container_create
def container_create(name, source, profiles=None, config=None, devices=None, architecture='x86_64', ephemeral=False, wait=True, remote_addr=None, cert=None, key=None, verify_cert=True, _raw=False): ''' Create a container name : The name of the container source : Can be either a string containing an image alias: "xenial/amd64" or an dict with type "image" with alias: {"type": "image", "alias": "xenial/amd64"} or image with "fingerprint": {"type": "image", "fingerprint": "SHA-256"} or image with "properties": {"type": "image", "properties": { "os": "ubuntu", "release": "14.04", "architecture": "x86_64"}} or none: {"type": "none"} or copy: {"type": "copy", "source": "my-old-container"} profiles : ['default'] List of profiles to apply on this container config : A config dict or None (None = unset). Can also be a list: [{'key': 'boot.autostart', 'value': 1}, {'key': 'security.privileged', 'value': '1'}] devices : A device dict or None (None = unset). architecture : 'x86_64' Can be one of the following: * unknown * i686 * x86_64 * armv7l * aarch64 * ppc * ppc64 * ppc64le * s390x ephemeral : False Destroy this container after stop? remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : False Return the raw pyxld object or a dict? CLI Examples: .. code-block:: bash salt '*' lxd.container_create test xenial/amd64 See also the `rest-api-docs`_. .. _rest-api-docs: https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1 ''' if profiles is None: profiles = ['default'] if config is None: config = {} if devices is None: devices = {} client = pylxd_client_get(remote_addr, cert, key, verify_cert) if not isinstance(profiles, (list, tuple, set,)): raise SaltInvocationError( "'profiles' must be formatted as list/tuple/set." ) if architecture not in _architectures: raise SaltInvocationError( ("Unknown architecture '{0}' " "given for the container '{1}'").format(architecture, name) ) if isinstance(source, six.string_types): source = {'type': 'image', 'alias': source} config, devices = normalize_input_values( config, devices ) try: container = client.containers.create( { 'name': name, 'architecture': _architectures[architecture], 'profiles': profiles, 'source': source, 'config': config, 'ephemeral': ephemeral }, wait=wait ) except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError( six.text_type(e) ) if not wait: return container.json()['operation'] # Add devices if not wait and devices have been given. if devices: for dn, dargs in six.iteritems(devices): container_device_add(name, dn, **dargs) if _raw: return container return _pylxd_model_to_dict(container)
python
def container_create(name, source, profiles=None, config=None, devices=None, architecture='x86_64', ephemeral=False, wait=True, remote_addr=None, cert=None, key=None, verify_cert=True, _raw=False): ''' Create a container name : The name of the container source : Can be either a string containing an image alias: "xenial/amd64" or an dict with type "image" with alias: {"type": "image", "alias": "xenial/amd64"} or image with "fingerprint": {"type": "image", "fingerprint": "SHA-256"} or image with "properties": {"type": "image", "properties": { "os": "ubuntu", "release": "14.04", "architecture": "x86_64"}} or none: {"type": "none"} or copy: {"type": "copy", "source": "my-old-container"} profiles : ['default'] List of profiles to apply on this container config : A config dict or None (None = unset). Can also be a list: [{'key': 'boot.autostart', 'value': 1}, {'key': 'security.privileged', 'value': '1'}] devices : A device dict or None (None = unset). architecture : 'x86_64' Can be one of the following: * unknown * i686 * x86_64 * armv7l * aarch64 * ppc * ppc64 * ppc64le * s390x ephemeral : False Destroy this container after stop? remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : False Return the raw pyxld object or a dict? CLI Examples: .. code-block:: bash salt '*' lxd.container_create test xenial/amd64 See also the `rest-api-docs`_. .. _rest-api-docs: https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1 ''' if profiles is None: profiles = ['default'] if config is None: config = {} if devices is None: devices = {} client = pylxd_client_get(remote_addr, cert, key, verify_cert) if not isinstance(profiles, (list, tuple, set,)): raise SaltInvocationError( "'profiles' must be formatted as list/tuple/set." ) if architecture not in _architectures: raise SaltInvocationError( ("Unknown architecture '{0}' " "given for the container '{1}'").format(architecture, name) ) if isinstance(source, six.string_types): source = {'type': 'image', 'alias': source} config, devices = normalize_input_values( config, devices ) try: container = client.containers.create( { 'name': name, 'architecture': _architectures[architecture], 'profiles': profiles, 'source': source, 'config': config, 'ephemeral': ephemeral }, wait=wait ) except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError( six.text_type(e) ) if not wait: return container.json()['operation'] # Add devices if not wait and devices have been given. if devices: for dn, dargs in six.iteritems(devices): container_device_add(name, dn, **dargs) if _raw: return container return _pylxd_model_to_dict(container)
[ "def", "container_create", "(", "name", ",", "source", ",", "profiles", "=", "None", ",", "config", "=", "None", ",", "devices", "=", "None", ",", "architecture", "=", "'x86_64'", ",", "ephemeral", "=", "False", ",", "wait", "=", "True", ",", "remote_add...
Create a container name : The name of the container source : Can be either a string containing an image alias: "xenial/amd64" or an dict with type "image" with alias: {"type": "image", "alias": "xenial/amd64"} or image with "fingerprint": {"type": "image", "fingerprint": "SHA-256"} or image with "properties": {"type": "image", "properties": { "os": "ubuntu", "release": "14.04", "architecture": "x86_64"}} or none: {"type": "none"} or copy: {"type": "copy", "source": "my-old-container"} profiles : ['default'] List of profiles to apply on this container config : A config dict or None (None = unset). Can also be a list: [{'key': 'boot.autostart', 'value': 1}, {'key': 'security.privileged', 'value': '1'}] devices : A device dict or None (None = unset). architecture : 'x86_64' Can be one of the following: * unknown * i686 * x86_64 * armv7l * aarch64 * ppc * ppc64 * ppc64le * s390x ephemeral : False Destroy this container after stop? remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : False Return the raw pyxld object or a dict? CLI Examples: .. code-block:: bash salt '*' lxd.container_create test xenial/amd64 See also the `rest-api-docs`_. .. _rest-api-docs: https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-1
[ "Create", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L539-L701
train
saltstack/salt
salt/modules/lxd.py
container_get
def container_get(name=None, remote_addr=None, cert=None, key=None, verify_cert=True, _raw=False): ''' Gets a container from the LXD name : The name of the container to get. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : Return the pylxd object, this is internal and by states in use. ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) if name is None: containers = client.containers.all() if _raw: return containers else: containers = [] try: containers = [client.containers.get(name)] except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'Container \'{0}\' not found'.format(name) ) if _raw: return containers[0] infos = [] for container in containers: infos.append(dict([ (container.name, _pylxd_model_to_dict(container)) ])) return infos
python
def container_get(name=None, remote_addr=None, cert=None, key=None, verify_cert=True, _raw=False): ''' Gets a container from the LXD name : The name of the container to get. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : Return the pylxd object, this is internal and by states in use. ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) if name is None: containers = client.containers.all() if _raw: return containers else: containers = [] try: containers = [client.containers.get(name)] except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'Container \'{0}\' not found'.format(name) ) if _raw: return containers[0] infos = [] for container in containers: infos.append(dict([ (container.name, _pylxd_model_to_dict(container)) ])) return infos
[ "def", "container_get", "(", "name", "=", "None", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ",", "_raw", "=", "False", ")", ":", "client", "=", "pylxd_client_get", "(", "remote_...
Gets a container from the LXD name : The name of the container to get. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : Return the pylxd object, this is internal and by states in use.
[ "Gets", "a", "container", "from", "the", "LXD" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L704-L761
train
saltstack/salt
salt/modules/lxd.py
container_delete
def container_delete(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a container name : Name of the container to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.delete(wait=True) return True
python
def container_delete(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a container name : Name of the container to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.delete(wait=True) return True
[ "def", "container_delete", "(", "name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_addr", ",", "cert", ",", ...
Delete a container name : Name of the container to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Delete", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L764-L801
train
saltstack/salt
salt/modules/lxd.py
container_rename
def container_rename(name, newname, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Rename a container name : Name of the container to Rename newname : The new name of the contianer remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) if container.status_code == CONTAINER_STATUS_RUNNING: raise SaltInvocationError( "Can't rename the running container '{0}'.".format(name) ) container.rename(newname, wait=True) return _pylxd_model_to_dict(container)
python
def container_rename(name, newname, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Rename a container name : Name of the container to Rename newname : The new name of the contianer remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) if container.status_code == CONTAINER_STATUS_RUNNING: raise SaltInvocationError( "Can't rename the running container '{0}'.".format(name) ) container.rename(newname, wait=True) return _pylxd_model_to_dict(container)
[ "def", "container_rename", "(", "name", ",", "newname", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_addr", ","...
Rename a container name : Name of the container to Rename newname : The new name of the contianer remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Rename", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L804-L850
train
saltstack/salt
salt/modules/lxd.py
container_state
def container_state(name=None, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get container state remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) if name is None: containers = client.containers.all() else: try: containers = [client.containers.get(name)] except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'Container \'{0}\' not found'.format(name) ) states = [] for container in containers: state = {} state = container.state() states.append(dict([ ( container.name, dict([ (k, getattr(state, k)) for k in dir(state) if not k.startswith('_') ]) ) ])) return states
python
def container_state(name=None, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get container state remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) if name is None: containers = client.containers.all() else: try: containers = [client.containers.get(name)] except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'Container \'{0}\' not found'.format(name) ) states = [] for container in containers: state = {} state = container.state() states.append(dict([ ( container.name, dict([ (k, getattr(state, k)) for k in dir(state) if not k.startswith('_') ]) ) ])) return states
[ "def", "container_state", "(", "name", "=", "None", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "client", "=", "pylxd_client_get", "(", "remote_addr", ",", "cert", ",", ...
Get container state remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Get", "container", "state" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L853-L910
train
saltstack/salt
salt/modules/lxd.py
container_start
def container_start(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Start a container name : Name of the container to start remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.start(wait=True) return _pylxd_model_to_dict(container)
python
def container_start(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Start a container name : Name of the container to start remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.start(wait=True) return _pylxd_model_to_dict(container)
[ "def", "container_start", "(", "name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_addr", ",", "cert", ",", ...
Start a container name : Name of the container to start remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Start", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L913-L950
train
saltstack/salt
salt/modules/lxd.py
container_stop
def container_stop(name, timeout=30, force=True, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Stop a container name : Name of the container to stop remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.stop(timeout, force, wait=True) return _pylxd_model_to_dict(container)
python
def container_stop(name, timeout=30, force=True, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Stop a container name : Name of the container to stop remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.stop(timeout, force, wait=True) return _pylxd_model_to_dict(container)
[ "def", "container_stop", "(", "name", ",", "timeout", "=", "30", ",", "force", "=", "True", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get"...
Stop a container name : Name of the container to stop remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Stop", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L953-L990
train
saltstack/salt
salt/modules/lxd.py
container_restart
def container_restart(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Restart a container name : Name of the container to restart remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.restart(wait=True) return _pylxd_model_to_dict(container)
python
def container_restart(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Restart a container name : Name of the container to restart remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.restart(wait=True) return _pylxd_model_to_dict(container)
[ "def", "container_restart", "(", "name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_addr", ",", "cert", ",", ...
Restart a container name : Name of the container to restart remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Restart", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L993-L1030
train
saltstack/salt
salt/modules/lxd.py
container_freeze
def container_freeze(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Freeze a container name : Name of the container to freeze remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.freeze(wait=True) return _pylxd_model_to_dict(container)
python
def container_freeze(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Freeze a container name : Name of the container to freeze remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.freeze(wait=True) return _pylxd_model_to_dict(container)
[ "def", "container_freeze", "(", "name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_addr", ",", "cert", ",", ...
Freeze a container name : Name of the container to freeze remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Freeze", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1033-L1070
train
saltstack/salt
salt/modules/lxd.py
container_unfreeze
def container_unfreeze(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Unfreeze a container name : Name of the container to unfreeze remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.unfreeze(wait=True) return _pylxd_model_to_dict(container)
python
def container_unfreeze(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Unfreeze a container name : Name of the container to unfreeze remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) container.unfreeze(wait=True) return _pylxd_model_to_dict(container)
[ "def", "container_unfreeze", "(", "name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_addr", ",", "cert", ",",...
Unfreeze a container name : Name of the container to unfreeze remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Unfreeze", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1073-L1110
train
saltstack/salt
salt/modules/lxd.py
container_migrate
def container_migrate(name, stop_and_start=False, remote_addr=None, cert=None, key=None, verify_cert=True, src_remote_addr=None, src_cert=None, src_key=None, src_verify_cert=None): ''' Migrate a container. If the container is running, it either must be shut down first (use stop_and_start=True) or criu must be installed on the source and destination machines. For this operation both certs need to be authenticated, use :mod:`lxd.authenticate <salt.modules.lxd.authenticate` to authenticate your cert(s). name : Name of the container to migrate stop_and_start : Stop the container on the source and start it on dest remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash # Authorize salt '*' lxd.authenticate https://srv01:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false salt '*' lxd.authenticate https://srv02:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false # Migrate phpmyadmin from srv01 to srv02 salt '*' lxd.container_migrate phpmyadmin stop_and_start=true remote_addr=https://srv02:8443 cert=~/.config/lxc/client.crt key=~/.config/lxc/client.key verify_cert=False src_remote_addr=https://srv01:8443 ''' if src_cert is None: src_cert = cert if src_key is None: src_key = key if src_verify_cert is None: src_verify_cert = verify_cert container = container_get( name, src_remote_addr, src_cert, src_key, src_verify_cert, _raw=True ) dest_client = pylxd_client_get( remote_addr, cert, key, verify_cert ) for pname in container.profiles: try: dest_client.profiles.get(pname) except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'not all the profiles from the source exist on the target' ) was_running = container.status_code == CONTAINER_STATUS_RUNNING if stop_and_start and was_running: container.stop(wait=True) try: dest_container = container.migrate(dest_client, wait=True) dest_container.profiles = container.profiles dest_container.save() except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError(six.text_type(e)) # Remove the source container container.delete(wait=True) if stop_and_start and was_running: dest_container.start(wait=True) return _pylxd_model_to_dict(dest_container)
python
def container_migrate(name, stop_and_start=False, remote_addr=None, cert=None, key=None, verify_cert=True, src_remote_addr=None, src_cert=None, src_key=None, src_verify_cert=None): ''' Migrate a container. If the container is running, it either must be shut down first (use stop_and_start=True) or criu must be installed on the source and destination machines. For this operation both certs need to be authenticated, use :mod:`lxd.authenticate <salt.modules.lxd.authenticate` to authenticate your cert(s). name : Name of the container to migrate stop_and_start : Stop the container on the source and start it on dest remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash # Authorize salt '*' lxd.authenticate https://srv01:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false salt '*' lxd.authenticate https://srv02:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false # Migrate phpmyadmin from srv01 to srv02 salt '*' lxd.container_migrate phpmyadmin stop_and_start=true remote_addr=https://srv02:8443 cert=~/.config/lxc/client.crt key=~/.config/lxc/client.key verify_cert=False src_remote_addr=https://srv01:8443 ''' if src_cert is None: src_cert = cert if src_key is None: src_key = key if src_verify_cert is None: src_verify_cert = verify_cert container = container_get( name, src_remote_addr, src_cert, src_key, src_verify_cert, _raw=True ) dest_client = pylxd_client_get( remote_addr, cert, key, verify_cert ) for pname in container.profiles: try: dest_client.profiles.get(pname) except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'not all the profiles from the source exist on the target' ) was_running = container.status_code == CONTAINER_STATUS_RUNNING if stop_and_start and was_running: container.stop(wait=True) try: dest_container = container.migrate(dest_client, wait=True) dest_container.profiles = container.profiles dest_container.save() except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError(six.text_type(e)) # Remove the source container container.delete(wait=True) if stop_and_start and was_running: dest_container.start(wait=True) return _pylxd_model_to_dict(dest_container)
[ "def", "container_migrate", "(", "name", ",", "stop_and_start", "=", "False", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ",", "src_remote_addr", "=", "None", ",", "src_cert", "=", ...
Migrate a container. If the container is running, it either must be shut down first (use stop_and_start=True) or criu must be installed on the source and destination machines. For this operation both certs need to be authenticated, use :mod:`lxd.authenticate <salt.modules.lxd.authenticate` to authenticate your cert(s). name : Name of the container to migrate stop_and_start : Stop the container on the source and start it on dest remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash # Authorize salt '*' lxd.authenticate https://srv01:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false salt '*' lxd.authenticate https://srv02:8443 <yourpass> ~/.config/lxc/client.crt ~/.config/lxc/client.key false # Migrate phpmyadmin from srv01 to srv02 salt '*' lxd.container_migrate phpmyadmin stop_and_start=true remote_addr=https://srv02:8443 cert=~/.config/lxc/client.crt key=~/.config/lxc/client.key verify_cert=False src_remote_addr=https://srv01:8443
[ "Migrate", "a", "container", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1113-L1217
train
saltstack/salt
salt/modules/lxd.py
container_config_get
def container_config_get(name, config_key, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get a container config value name : Name of the container config_key : The config key to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _get_property_dict_item(container, 'config', config_key)
python
def container_config_get(name, config_key, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get a container config value name : Name of the container config_key : The config key to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _get_property_dict_item(container, 'config', config_key)
[ "def", "container_config_get", "(", "name", ",", "config_key", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_addr"...
Get a container config value name : Name of the container config_key : The config key to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Get", "a", "container", "config", "value" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1220-L1259
train
saltstack/salt
salt/modules/lxd.py
container_config_set
def container_config_set(name, config_key, config_value, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Set a container config value name : Name of the container config_key : The config key to set config_value : The config value to set remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _set_property_dict_item( container, 'config', config_key, config_value )
python
def container_config_set(name, config_key, config_value, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Set a container config value name : Name of the container config_key : The config key to set config_value : The config value to set remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _set_property_dict_item( container, 'config', config_key, config_value )
[ "def", "container_config_set", "(", "name", ",", "config_key", ",", "config_value", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name...
Set a container config value name : Name of the container config_key : The config key to set config_value : The config value to set remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Set", "a", "container", "config", "value" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1262-L1307
train
saltstack/salt
salt/modules/lxd.py
container_config_delete
def container_config_delete(name, config_key, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a container config value name : Name of the container config_key : The config key to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _delete_property_dict_item( container, 'config', config_key )
python
def container_config_delete(name, config_key, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a container config value name : Name of the container config_key : The config key to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _delete_property_dict_item( container, 'config', config_key )
[ "def", "container_config_delete", "(", "name", ",", "config_key", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_ad...
Delete a container config value name : Name of the container config_key : The config key to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Delete", "a", "container", "config", "value" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1310-L1352
train
saltstack/salt
salt/modules/lxd.py
container_device_get
def container_device_get(name, device_name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get a container device name : Name of the container device_name : The device name to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _get_property_dict_item(container, 'devices', device_name)
python
def container_device_get(name, device_name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get a container device name : Name of the container device_name : The device name to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _get_property_dict_item(container, 'devices', device_name)
[ "def", "container_device_get", "(", "name", ",", "device_name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_addr...
Get a container device name : Name of the container device_name : The device name to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Get", "a", "container", "device" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1355-L1395
train
saltstack/salt
salt/modules/lxd.py
container_device_add
def container_device_add(name, device_name, device_type='disk', remote_addr=None, cert=None, key=None, verify_cert=True, **kwargs): ''' Add a container device name : Name of the container device_name : The device name to add device_type : Type of the device ** kwargs : Additional device args remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) kwargs['type'] = device_type return _set_property_dict_item( container, 'devices', device_name, kwargs )
python
def container_device_add(name, device_name, device_type='disk', remote_addr=None, cert=None, key=None, verify_cert=True, **kwargs): ''' Add a container device name : Name of the container device_name : The device name to add device_type : Type of the device ** kwargs : Additional device args remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) kwargs['type'] = device_type return _set_property_dict_item( container, 'devices', device_name, kwargs )
[ "def", "container_device_add", "(", "name", ",", "device_name", ",", "device_type", "=", "'disk'", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ",", "*", "*", "kwargs", ")", ":", "...
Add a container device name : Name of the container device_name : The device name to add device_type : Type of the device ** kwargs : Additional device args remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Add", "a", "container", "device" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1398-L1449
train
saltstack/salt
salt/modules/lxd.py
container_device_delete
def container_device_delete(name, device_name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a container device name : Name of the container device_name : The device name to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _delete_property_dict_item( container, 'devices', device_name )
python
def container_device_delete(name, device_name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a container device name : Name of the container device_name : The device name to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _delete_property_dict_item( container, 'devices', device_name )
[ "def", "container_device_delete", "(", "name", ",", "device_name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_a...
Delete a container device name : Name of the container device_name : The device name to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Delete", "a", "container", "device" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1452-L1494
train
saltstack/salt
salt/modules/lxd.py
container_file_put
def container_file_put(name, src, dst, recursive=False, overwrite=False, mode=None, uid=None, gid=None, saltenv='base', remote_addr=None, cert=None, key=None, verify_cert=True): ''' Put a file into a container name : Name of the container src : The source file or directory dst : The destination file or directory recursive : Decent into src directory overwrite : Replace destination if it exists mode : Set file mode to octal number uid : Set file uid (owner) gid : Set file gid (group) remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash salt '*' lxd.container_file_put <container name> /var/tmp/foo /var/tmp/ ''' # Possibilities: # (src, dst, dir, dir1, and dir2 are directories) # cp /src/file1 /dst/file1 # cp /src/file1 /dst/file2 # cp /src/file1 /dst # cp /src/file1 /dst/ # cp -r /src/dir /dst/ # cp -r /src/dir/ /dst/ # cp -r /src/dir1 /dst/dir2 (which is not /src/dir1 /dst/dir2/) # cp -r /src/dir1 /dst/dir2/ # Fix mode. Salt commandline doesn't use octals, so 0600 will be # the decimal integer 600 (and not the octal 0600). So, it it's # and integer, handle it as if it where a octal representation. mode = six.text_type(mode) if not mode.startswith('0'): mode = '0{0}'.format(mode) container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) src = os.path.expanduser(src) if not os.path.isabs(src): if src.find('://') >= 0: cached_file = __salt__['cp.cache_file'](src, saltenv=saltenv) if not cached_file: raise SaltInvocationError("File '{0}' not found".format(src)) if not os.path.isabs(cached_file): raise SaltInvocationError('File path must be absolute.') src = cached_file # Make sure that src doesn't end with '/', unless it's '/' src = src.rstrip(os.path.sep) if not src: src = os.path.sep if not os.path.exists(src): raise CommandExecutionError( 'No such file or directory \'{0}\''.format(src) ) if os.path.isdir(src) and not recursive: raise SaltInvocationError( ("Cannot copy overwriting a directory " "without recursive flag set to true!") ) try: dst_is_directory = False container.files.get(os.path.join(dst, '.')) except pylxd.exceptions.NotFound: pass except pylxd.exceptions.LXDAPIException as why: if six.text_type(why).find('Is a directory') >= 0: dst_is_directory = True if os.path.isfile(src): # Source is a file if dst_is_directory: dst = os.path.join(dst, os.path.basename(src)) if not overwrite: found = True try: container.files.get(os.path.join(dst)) except pylxd.exceptions.NotFound: found = False except pylxd.exceptions.LXDAPIException as why: if six.text_type(why).find('not found') >= 0: # Old version of pylxd found = False else: raise if found: raise SaltInvocationError( "Destination exists and overwrite is false" ) if mode is not None or uid is not None or gid is not None: # Need to get file stats stat = os.stat(src) if mode is None: mode = oct(stat.st_mode) if uid is None: uid = stat.st_uid if gid is None: gid = stat.st_gid with salt.utils.files.fopen(src, 'rb') as src_fp: container.files.put( dst, src_fp.read(), mode=mode, uid=uid, gid=gid ) return True elif not os.path.isdir(src): raise SaltInvocationError( "Source is neither file nor directory" ) # Source is a directory # idx for dstdir = dst + src[idx:] if dst.endswith(os.sep): idx = len(os.path.dirname(src)) elif dst_is_directory: idx = len(src) else: # Destination is not a directory and doesn't end with '/' # Check that the parent directory of dst exists # and is a directory try: container.files.get(os.path.join(os.path.dirname(dst), '.')) except pylxd.exceptions.NotFound: pass except pylxd.exceptions.LXDAPIException as why: if six.text_type(why).find('Is a directory') >= 0: dst_is_directory = True # destination is non-existent # cp -r /src/dir1 /scr/dir1 # cp -r /src/dir1 /scr/dir2 idx = len(src) overwrite = True # Copy src directory recursive if not overwrite: raise SaltInvocationError( "Destination exists and overwrite is false" ) # Collect all directories first, to create them in one call # (for performance reasons) dstdirs = [] for path, _, files in os.walk(src): dstdir = os.path.join(dst, path[idx:].lstrip(os.path.sep)) dstdirs.append(dstdir) container.execute(['mkdir', '-p'] + dstdirs) set_mode = mode set_uid = uid set_gid = gid # Now transfer the files for path, _, files in os.walk(src): dstdir = os.path.join(dst, path[idx:].lstrip(os.path.sep)) for name in files: src_name = os.path.join(path, name) dst_name = os.path.join(dstdir, name) if mode is not None or uid is not None or gid is not None: # Need to get file stats stat = os.stat(src_name) if mode is None: set_mode = oct(stat.st_mode) if uid is None: set_uid = stat.st_uid if gid is None: set_gid = stat.st_gid with salt.utils.files.fopen(src_name, 'rb') as src_fp: container.files.put( dst_name, src_fp.read(), mode=set_mode, uid=set_uid, gid=set_gid ) return True
python
def container_file_put(name, src, dst, recursive=False, overwrite=False, mode=None, uid=None, gid=None, saltenv='base', remote_addr=None, cert=None, key=None, verify_cert=True): ''' Put a file into a container name : Name of the container src : The source file or directory dst : The destination file or directory recursive : Decent into src directory overwrite : Replace destination if it exists mode : Set file mode to octal number uid : Set file uid (owner) gid : Set file gid (group) remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash salt '*' lxd.container_file_put <container name> /var/tmp/foo /var/tmp/ ''' # Possibilities: # (src, dst, dir, dir1, and dir2 are directories) # cp /src/file1 /dst/file1 # cp /src/file1 /dst/file2 # cp /src/file1 /dst # cp /src/file1 /dst/ # cp -r /src/dir /dst/ # cp -r /src/dir/ /dst/ # cp -r /src/dir1 /dst/dir2 (which is not /src/dir1 /dst/dir2/) # cp -r /src/dir1 /dst/dir2/ # Fix mode. Salt commandline doesn't use octals, so 0600 will be # the decimal integer 600 (and not the octal 0600). So, it it's # and integer, handle it as if it where a octal representation. mode = six.text_type(mode) if not mode.startswith('0'): mode = '0{0}'.format(mode) container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) src = os.path.expanduser(src) if not os.path.isabs(src): if src.find('://') >= 0: cached_file = __salt__['cp.cache_file'](src, saltenv=saltenv) if not cached_file: raise SaltInvocationError("File '{0}' not found".format(src)) if not os.path.isabs(cached_file): raise SaltInvocationError('File path must be absolute.') src = cached_file # Make sure that src doesn't end with '/', unless it's '/' src = src.rstrip(os.path.sep) if not src: src = os.path.sep if not os.path.exists(src): raise CommandExecutionError( 'No such file or directory \'{0}\''.format(src) ) if os.path.isdir(src) and not recursive: raise SaltInvocationError( ("Cannot copy overwriting a directory " "without recursive flag set to true!") ) try: dst_is_directory = False container.files.get(os.path.join(dst, '.')) except pylxd.exceptions.NotFound: pass except pylxd.exceptions.LXDAPIException as why: if six.text_type(why).find('Is a directory') >= 0: dst_is_directory = True if os.path.isfile(src): # Source is a file if dst_is_directory: dst = os.path.join(dst, os.path.basename(src)) if not overwrite: found = True try: container.files.get(os.path.join(dst)) except pylxd.exceptions.NotFound: found = False except pylxd.exceptions.LXDAPIException as why: if six.text_type(why).find('not found') >= 0: # Old version of pylxd found = False else: raise if found: raise SaltInvocationError( "Destination exists and overwrite is false" ) if mode is not None or uid is not None or gid is not None: # Need to get file stats stat = os.stat(src) if mode is None: mode = oct(stat.st_mode) if uid is None: uid = stat.st_uid if gid is None: gid = stat.st_gid with salt.utils.files.fopen(src, 'rb') as src_fp: container.files.put( dst, src_fp.read(), mode=mode, uid=uid, gid=gid ) return True elif not os.path.isdir(src): raise SaltInvocationError( "Source is neither file nor directory" ) # Source is a directory # idx for dstdir = dst + src[idx:] if dst.endswith(os.sep): idx = len(os.path.dirname(src)) elif dst_is_directory: idx = len(src) else: # Destination is not a directory and doesn't end with '/' # Check that the parent directory of dst exists # and is a directory try: container.files.get(os.path.join(os.path.dirname(dst), '.')) except pylxd.exceptions.NotFound: pass except pylxd.exceptions.LXDAPIException as why: if six.text_type(why).find('Is a directory') >= 0: dst_is_directory = True # destination is non-existent # cp -r /src/dir1 /scr/dir1 # cp -r /src/dir1 /scr/dir2 idx = len(src) overwrite = True # Copy src directory recursive if not overwrite: raise SaltInvocationError( "Destination exists and overwrite is false" ) # Collect all directories first, to create them in one call # (for performance reasons) dstdirs = [] for path, _, files in os.walk(src): dstdir = os.path.join(dst, path[idx:].lstrip(os.path.sep)) dstdirs.append(dstdir) container.execute(['mkdir', '-p'] + dstdirs) set_mode = mode set_uid = uid set_gid = gid # Now transfer the files for path, _, files in os.walk(src): dstdir = os.path.join(dst, path[idx:].lstrip(os.path.sep)) for name in files: src_name = os.path.join(path, name) dst_name = os.path.join(dstdir, name) if mode is not None or uid is not None or gid is not None: # Need to get file stats stat = os.stat(src_name) if mode is None: set_mode = oct(stat.st_mode) if uid is None: set_uid = stat.st_uid if gid is None: set_gid = stat.st_gid with salt.utils.files.fopen(src_name, 'rb') as src_fp: container.files.put( dst_name, src_fp.read(), mode=set_mode, uid=set_uid, gid=set_gid ) return True
[ "def", "container_file_put", "(", "name", ",", "src", ",", "dst", ",", "recursive", "=", "False", ",", "overwrite", "=", "False", ",", "mode", "=", "None", ",", "uid", "=", "None", ",", "gid", "=", "None", ",", "saltenv", "=", "'base'", ",", "remote_...
Put a file into a container name : Name of the container src : The source file or directory dst : The destination file or directory recursive : Decent into src directory overwrite : Replace destination if it exists mode : Set file mode to octal number uid : Set file uid (owner) gid : Set file gid (group) remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash salt '*' lxd.container_file_put <container name> /var/tmp/foo /var/tmp/
[ "Put", "a", "file", "into", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1497-L1722
train
saltstack/salt
salt/modules/lxd.py
container_file_get
def container_file_get(name, src, dst, overwrite=False, mode=None, uid=None, gid=None, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get a file from a container name : Name of the container src : The source file or directory dst : The destination file or directory mode : Set file mode to octal number uid : Set file uid (owner) gid : Set file gid (group) remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' # Fix mode. Salt commandline doesn't use octals, so 0600 will be # the decimal integer 600 (and not the octal 0600). So, it it's # and integer, handle it as if it where a octal representation. # Do only if mode is not None, otherwise we get 0None if mode is not None: mode = six.text_type(mode) if not mode.startswith('0'): mode = '0{0}'.format(mode) container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) dst = os.path.expanduser(dst) if not os.path.isabs(dst): raise SaltInvocationError('File path must be absolute.') if os.path.isdir(dst): dst = os.path.join(dst, os.path.basename(src)) elif not os.path.isdir(os.path.dirname(dst)): raise SaltInvocationError( "Parent directory for destination doesn't exist." ) if os.path.exists(dst): if not overwrite: raise SaltInvocationError( 'Destination exists and overwrite is false.' ) if not os.path.isfile(dst): raise SaltInvocationError( 'Destination exists but is not a file.' ) else: dst_path = os.path.dirname(dst) if not os.path.isdir(dst_path): raise CommandExecutionError( 'No such file or directory \'{0}\''.format(dst_path) ) # Seems to be duplicate of line 1794, produces /path/file_name/file_name #dst = os.path.join(dst, os.path.basename(src)) with salt.utils.files.fopen(dst, 'wb') as df: df.write(container.files.get(src)) if mode: os.chmod(dst, mode) if uid or uid is '0': uid = int(uid) else: uid = -1 if gid or gid is '0': gid = int(gid) else: gid = -1 if uid != -1 or gid != -1: os.chown(dst, uid, gid) return True
python
def container_file_get(name, src, dst, overwrite=False, mode=None, uid=None, gid=None, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get a file from a container name : Name of the container src : The source file or directory dst : The destination file or directory mode : Set file mode to octal number uid : Set file uid (owner) gid : Set file gid (group) remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. ''' # Fix mode. Salt commandline doesn't use octals, so 0600 will be # the decimal integer 600 (and not the octal 0600). So, it it's # and integer, handle it as if it where a octal representation. # Do only if mode is not None, otherwise we get 0None if mode is not None: mode = six.text_type(mode) if not mode.startswith('0'): mode = '0{0}'.format(mode) container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) dst = os.path.expanduser(dst) if not os.path.isabs(dst): raise SaltInvocationError('File path must be absolute.') if os.path.isdir(dst): dst = os.path.join(dst, os.path.basename(src)) elif not os.path.isdir(os.path.dirname(dst)): raise SaltInvocationError( "Parent directory for destination doesn't exist." ) if os.path.exists(dst): if not overwrite: raise SaltInvocationError( 'Destination exists and overwrite is false.' ) if not os.path.isfile(dst): raise SaltInvocationError( 'Destination exists but is not a file.' ) else: dst_path = os.path.dirname(dst) if not os.path.isdir(dst_path): raise CommandExecutionError( 'No such file or directory \'{0}\''.format(dst_path) ) # Seems to be duplicate of line 1794, produces /path/file_name/file_name #dst = os.path.join(dst, os.path.basename(src)) with salt.utils.files.fopen(dst, 'wb') as df: df.write(container.files.get(src)) if mode: os.chmod(dst, mode) if uid or uid is '0': uid = int(uid) else: uid = -1 if gid or gid is '0': gid = int(gid) else: gid = -1 if uid != -1 or gid != -1: os.chown(dst, uid, gid) return True
[ "def", "container_file_get", "(", "name", ",", "src", ",", "dst", ",", "overwrite", "=", "False", ",", "mode", "=", "None", ",", "uid", "=", "None", ",", "gid", "=", "None", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "="...
Get a file from a container name : Name of the container src : The source file or directory dst : The destination file or directory mode : Set file mode to octal number uid : Set file uid (owner) gid : Set file gid (group) remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates.
[ "Get", "a", "file", "from", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1725-L1833
train
saltstack/salt
salt/modules/lxd.py
container_execute
def container_execute(name, cmd, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Execute a command list on a container. name : Name of the container cmd : Command to be executed (as a list) Example : '["ls", "-l"]' remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash salt '*' lxd.container_execute <container name> '["ls", "-l"]' ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) try: result = container.execute(cmd) saltresult = {} if not hasattr(result, 'exit_code'): saltresult = dict( exit_code=0, stdout=result[0], stderr=result[1], ) else: saltresult = dict( exit_code=result.exit_code, stdout=result.stdout, stderr=result.stderr, ) except pylxd.exceptions.NotFound as e: # TODO: Using exit_code 0 here is not always right, # in the most cases the command worked ok though. # See: https://github.com/lxc/pylxd/issues/280 saltresult = dict(exit_code=0, stdout="", stderr=six.text_type(e)) if int(saltresult['exit_code']) > 0: saltresult['result'] = False else: saltresult['result'] = True return saltresult
python
def container_execute(name, cmd, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Execute a command list on a container. name : Name of the container cmd : Command to be executed (as a list) Example : '["ls", "-l"]' remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash salt '*' lxd.container_execute <container name> '["ls", "-l"]' ''' container = container_get( name, remote_addr, cert, key, verify_cert, _raw=True ) try: result = container.execute(cmd) saltresult = {} if not hasattr(result, 'exit_code'): saltresult = dict( exit_code=0, stdout=result[0], stderr=result[1], ) else: saltresult = dict( exit_code=result.exit_code, stdout=result.stdout, stderr=result.stderr, ) except pylxd.exceptions.NotFound as e: # TODO: Using exit_code 0 here is not always right, # in the most cases the command worked ok though. # See: https://github.com/lxc/pylxd/issues/280 saltresult = dict(exit_code=0, stdout="", stderr=six.text_type(e)) if int(saltresult['exit_code']) > 0: saltresult['result'] = False else: saltresult['result'] = True return saltresult
[ "def", "container_execute", "(", "name", ",", "cmd", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "name", ",", "remote_addr", ",", ...
Execute a command list on a container. name : Name of the container cmd : Command to be executed (as a list) Example : '["ls", "-l"]' remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash salt '*' lxd.container_execute <container name> '["ls", "-l"]'
[ "Execute", "a", "command", "list", "on", "a", "container", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1836-L1911
train
saltstack/salt
salt/modules/lxd.py
profile_list
def profile_list(list_names=False, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Lists all profiles from the LXD. list_names : Return a list of names instead of full blown dicts. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash salt '*' lxd.profile_list true --out=json salt '*' lxd.profile_list --out=json ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) profiles = client.profiles.all() if list_names: return [p.name for p in profiles] return map(_pylxd_model_to_dict, profiles)
python
def profile_list(list_names=False, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Lists all profiles from the LXD. list_names : Return a list of names instead of full blown dicts. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash salt '*' lxd.profile_list true --out=json salt '*' lxd.profile_list --out=json ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) profiles = client.profiles.all() if list_names: return [p.name for p in profiles] return map(_pylxd_model_to_dict, profiles)
[ "def", "profile_list", "(", "list_names", "=", "False", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "client", "=", "pylxd_client_get", "(", "remote_addr", ",", "cert", ","...
Lists all profiles from the LXD. list_names : Return a list of names instead of full blown dicts. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash salt '*' lxd.profile_list true --out=json salt '*' lxd.profile_list --out=json
[ "Lists", "all", "profiles", "from", "the", "LXD", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1917-L1964
train
saltstack/salt
salt/modules/lxd.py
profile_create
def profile_create(name, config=None, devices=None, description=None, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Creates a profile. name : The name of the profile to get. config : A config dict or None (None = unset). Can also be a list: [{'key': 'boot.autostart', 'value': 1}, {'key': 'security.privileged', 'value': '1'}] devices : A device dict or None (None = unset). description : A description string or None (None = unset). remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.profile_create autostart config="{boot.autostart: 1, boot.autostart.delay: 2, boot.autostart.priority: 1}" $ salt '*' lxd.profile_create shared_mounts devices="{shared_mount: {type: 'disk', source: '/home/shared', path: '/home/shared'}}" See the `lxd-docs`_ for the details about the config and devices dicts. .. _lxd-docs: https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-10 ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) config, devices = normalize_input_values( config, devices ) try: profile = client.profiles.create(name, config, devices) except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError(six.text_type(e)) if description is not None: profile.description = description pylxd_save_object(profile) return _pylxd_model_to_dict(profile)
python
def profile_create(name, config=None, devices=None, description=None, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Creates a profile. name : The name of the profile to get. config : A config dict or None (None = unset). Can also be a list: [{'key': 'boot.autostart', 'value': 1}, {'key': 'security.privileged', 'value': '1'}] devices : A device dict or None (None = unset). description : A description string or None (None = unset). remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.profile_create autostart config="{boot.autostart: 1, boot.autostart.delay: 2, boot.autostart.priority: 1}" $ salt '*' lxd.profile_create shared_mounts devices="{shared_mount: {type: 'disk', source: '/home/shared', path: '/home/shared'}}" See the `lxd-docs`_ for the details about the config and devices dicts. .. _lxd-docs: https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-10 ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) config, devices = normalize_input_values( config, devices ) try: profile = client.profiles.create(name, config, devices) except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError(six.text_type(e)) if description is not None: profile.description = description pylxd_save_object(profile) return _pylxd_model_to_dict(profile)
[ "def", "profile_create", "(", "name", ",", "config", "=", "None", ",", "devices", "=", "None", ",", "description", "=", "None", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ...
Creates a profile. name : The name of the profile to get. config : A config dict or None (None = unset). Can also be a list: [{'key': 'boot.autostart', 'value': 1}, {'key': 'security.privileged', 'value': '1'}] devices : A device dict or None (None = unset). description : A description string or None (None = unset). remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.profile_create autostart config="{boot.autostart: 1, boot.autostart.delay: 2, boot.autostart.priority: 1}" $ salt '*' lxd.profile_create shared_mounts devices="{shared_mount: {type: 'disk', source: '/home/shared', path: '/home/shared'}}" See the `lxd-docs`_ for the details about the config and devices dicts. .. _lxd-docs: https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-10
[ "Creates", "a", "profile", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L1967-L2040
train
saltstack/salt
salt/modules/lxd.py
profile_get
def profile_get(name, remote_addr=None, cert=None, key=None, verify_cert=True, _raw=False): ''' Gets a profile from the LXD name : The name of the profile to get. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : Return the pylxd object, this is internal and by states in use. CLI Examples: .. code-block:: bash $ salt '*' lxd.profile_get autostart ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) profile = None try: profile = client.profiles.get(name) except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'Profile \'{0}\' not found'.format(name) ) if _raw: return profile return _pylxd_model_to_dict(profile)
python
def profile_get(name, remote_addr=None, cert=None, key=None, verify_cert=True, _raw=False): ''' Gets a profile from the LXD name : The name of the profile to get. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : Return the pylxd object, this is internal and by states in use. CLI Examples: .. code-block:: bash $ salt '*' lxd.profile_get autostart ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) profile = None try: profile = client.profiles.get(name) except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'Profile \'{0}\' not found'.format(name) ) if _raw: return profile return _pylxd_model_to_dict(profile)
[ "def", "profile_get", "(", "name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ",", "_raw", "=", "False", ")", ":", "client", "=", "pylxd_client_get", "(", "remote_addr", ",", "ce...
Gets a profile from the LXD name : The name of the profile to get. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : Return the pylxd object, this is internal and by states in use. CLI Examples: .. code-block:: bash $ salt '*' lxd.profile_get autostart
[ "Gets", "a", "profile", "from", "the", "LXD" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2043-L2097
train
saltstack/salt
salt/modules/lxd.py
profile_delete
def profile_delete(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Deletes a profile. name : The name of the profile to delete. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_delete shared_mounts ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) profile.delete() return True
python
def profile_delete(name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Deletes a profile. name : The name of the profile to delete. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_delete shared_mounts ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) profile.delete() return True
[ "def", "profile_delete", "(", "name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "profile", "=", "profile_get", "(", "name", ",", "remote_addr", ",", "cert", ",", "key"...
Deletes a profile. name : The name of the profile to delete. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_delete shared_mounts
[ "Deletes", "a", "profile", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2100-L2148
train
saltstack/salt
salt/modules/lxd.py
profile_config_get
def profile_config_get(name, config_key, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get a profile config item. name : The name of the profile to get the config item from. config_key : The key for the item to retrieve. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_config_get autostart boot.autostart ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _get_property_dict_item(profile, 'config', config_key)
python
def profile_config_get(name, config_key, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get a profile config item. name : The name of the profile to get the config item from. config_key : The key for the item to retrieve. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_config_get autostart boot.autostart ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _get_property_dict_item(profile, 'config', config_key)
[ "def", "profile_config_get", "(", "name", ",", "config_key", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "profile", "=", "profile_get", "(", "name", ",", "remote_addr", ",...
Get a profile config item. name : The name of the profile to get the config item from. config_key : The key for the item to retrieve. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_config_get autostart boot.autostart
[ "Get", "a", "profile", "config", "item", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2151-L2201
train
saltstack/salt
salt/modules/lxd.py
profile_config_set
def profile_config_set(name, config_key, config_value, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Set a profile config item. name : The name of the profile to set the config item to. config_key : The items key. config_value : Its items value. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_config_set autostart boot.autostart 0 ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _set_property_dict_item( profile, 'config', config_key, config_value )
python
def profile_config_set(name, config_key, config_value, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Set a profile config item. name : The name of the profile to set the config item to. config_key : The items key. config_value : Its items value. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_config_set autostart boot.autostart 0 ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _set_property_dict_item( profile, 'config', config_key, config_value )
[ "def", "profile_config_set", "(", "name", ",", "config_key", ",", "config_value", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "profile", "=", "profile_get", "(", "name", "...
Set a profile config item. name : The name of the profile to set the config item to. config_key : The items key. config_value : Its items value. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_config_set autostart boot.autostart 0
[ "Set", "a", "profile", "config", "item", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2204-L2260
train
saltstack/salt
salt/modules/lxd.py
profile_config_delete
def profile_config_delete(name, config_key, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a profile config item. name : The name of the profile to delete the config item. config_key : The config key for the value to retrieve. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_config_delete autostart boot.autostart.delay ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _delete_property_dict_item( profile, 'config', config_key )
python
def profile_config_delete(name, config_key, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a profile config item. name : The name of the profile to delete the config item. config_key : The config key for the value to retrieve. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_config_delete autostart boot.autostart.delay ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _delete_property_dict_item( profile, 'config', config_key )
[ "def", "profile_config_delete", "(", "name", ",", "config_key", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "profile", "=", "profile_get", "(", "name", ",", "remote_addr", ...
Delete a profile config item. name : The name of the profile to delete the config item. config_key : The config key for the value to retrieve. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_config_delete autostart boot.autostart.delay
[ "Delete", "a", "profile", "config", "item", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2263-L2315
train
saltstack/salt
salt/modules/lxd.py
profile_device_get
def profile_device_get(name, device_name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get a profile device. name : The name of the profile to get the device from. device_name : The name of the device to retrieve. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_device_get default eth0 ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _get_property_dict_item(profile, 'devices', device_name)
python
def profile_device_get(name, device_name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get a profile device. name : The name of the profile to get the device from. device_name : The name of the device to retrieve. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_device_get default eth0 ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _get_property_dict_item(profile, 'devices', device_name)
[ "def", "profile_device_get", "(", "name", ",", "device_name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "profile", "=", "profile_get", "(", "name", ",", "remote_addr", "...
Get a profile device. name : The name of the profile to get the device from. device_name : The name of the device to retrieve. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_device_get default eth0
[ "Get", "a", "profile", "device", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2318-L2368
train
saltstack/salt
salt/modules/lxd.py
profile_device_set
def profile_device_set(name, device_name, device_type='disk', remote_addr=None, cert=None, key=None, verify_cert=True, **kwargs): ''' Set a profile device. name : The name of the profile to set the device to. device_name : The name of the device to set. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_device_set autostart eth1 nic nictype=bridged parent=lxdbr0 ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) kwargs['type'] = device_type for k, v in six.iteritems(kwargs): kwargs[k] = six.text_type(v) return _set_property_dict_item( profile, 'devices', device_name, kwargs )
python
def profile_device_set(name, device_name, device_type='disk', remote_addr=None, cert=None, key=None, verify_cert=True, **kwargs): ''' Set a profile device. name : The name of the profile to set the device to. device_name : The name of the device to set. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_device_set autostart eth1 nic nictype=bridged parent=lxdbr0 ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) kwargs['type'] = device_type for k, v in six.iteritems(kwargs): kwargs[k] = six.text_type(v) return _set_property_dict_item( profile, 'devices', device_name, kwargs )
[ "def", "profile_device_set", "(", "name", ",", "device_name", ",", "device_type", "=", "'disk'", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ",", "*", "*", "kwargs", ")", ":", "pr...
Set a profile device. name : The name of the profile to set the device to. device_name : The name of the device to set. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_device_set autostart eth1 nic nictype=bridged parent=lxdbr0
[ "Set", "a", "profile", "device", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2371-L2430
train
saltstack/salt
salt/modules/lxd.py
profile_device_delete
def profile_device_delete(name, device_name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a profile device. name : The name of the profile to delete the device. device_name : The name of the device to delete. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_device_delete autostart eth1 ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _delete_property_dict_item( profile, 'devices', device_name )
python
def profile_device_delete(name, device_name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a profile device. name : The name of the profile to delete the device. device_name : The name of the device to delete. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_device_delete autostart eth1 ''' profile = profile_get( name, remote_addr, cert, key, verify_cert, _raw=True ) return _delete_property_dict_item( profile, 'devices', device_name )
[ "def", "profile_device_delete", "(", "name", ",", "device_name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "profile", "=", "profile_get", "(", "name", ",", "remote_addr", ...
Delete a profile device. name : The name of the profile to delete the device. device_name : The name of the device to delete. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Example: .. code-block:: bash $ salt '*' lxd.profile_device_delete autostart eth1
[ "Delete", "a", "profile", "device", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2433-L2486
train
saltstack/salt
salt/modules/lxd.py
image_list
def image_list(list_aliases=False, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Lists all images from the LXD. list_aliases : Return a dict with the fingerprint as key and a list of aliases as value instead. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.image_list true --out=json $ salt '*' lxd.image_list --out=json ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) images = client.images.all() if list_aliases: return {i.fingerprint: [a['name'] for a in i.aliases] for i in images} return map(_pylxd_model_to_dict, images)
python
def image_list(list_aliases=False, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Lists all images from the LXD. list_aliases : Return a dict with the fingerprint as key and a list of aliases as value instead. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.image_list true --out=json $ salt '*' lxd.image_list --out=json ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) images = client.images.all() if list_aliases: return {i.fingerprint: [a['name'] for a in i.aliases] for i in images} return map(_pylxd_model_to_dict, images)
[ "def", "image_list", "(", "list_aliases", "=", "False", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "client", "=", "pylxd_client_get", "(", "remote_addr", ",", "cert", ","...
Lists all images from the LXD. list_aliases : Return a dict with the fingerprint as key and a list of aliases as value instead. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.image_list true --out=json $ salt '*' lxd.image_list --out=json
[ "Lists", "all", "images", "from", "the", "LXD", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2492-L2539
train
saltstack/salt
salt/modules/lxd.py
image_get
def image_get(fingerprint, remote_addr=None, cert=None, key=None, verify_cert=True, _raw=False): ''' Get an image by its fingerprint fingerprint : The fingerprint of the image to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : False Return the raw pylxd object or a dict of it? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_get <fingerprint> ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) image = None try: image = client.images.get(fingerprint) except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'Image with fingerprint \'{0}\' not found'.format(fingerprint) ) if _raw: return image return _pylxd_model_to_dict(image)
python
def image_get(fingerprint, remote_addr=None, cert=None, key=None, verify_cert=True, _raw=False): ''' Get an image by its fingerprint fingerprint : The fingerprint of the image to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : False Return the raw pylxd object or a dict of it? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_get <fingerprint> ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) image = None try: image = client.images.get(fingerprint) except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'Image with fingerprint \'{0}\' not found'.format(fingerprint) ) if _raw: return image return _pylxd_model_to_dict(image)
[ "def", "image_get", "(", "fingerprint", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ",", "_raw", "=", "False", ")", ":", "client", "=", "pylxd_client_get", "(", "remote_addr", ",", ...
Get an image by its fingerprint fingerprint : The fingerprint of the image to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : False Return the raw pylxd object or a dict of it? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_get <fingerprint>
[ "Get", "an", "image", "by", "its", "fingerprint" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2542-L2600
train
saltstack/salt
salt/modules/lxd.py
image_get_by_alias
def image_get_by_alias(alias, remote_addr=None, cert=None, key=None, verify_cert=True, _raw=False): ''' Get an image by an alias alias : The alias of the image to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : False Return the raw pylxd object or a dict of it? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_get_by_alias xenial/amd64 ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) image = None try: image = client.images.get_by_alias(alias) except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'Image with alias \'{0}\' not found'.format(alias) ) if _raw: return image return _pylxd_model_to_dict(image)
python
def image_get_by_alias(alias, remote_addr=None, cert=None, key=None, verify_cert=True, _raw=False): ''' Get an image by an alias alias : The alias of the image to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : False Return the raw pylxd object or a dict of it? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_get_by_alias xenial/amd64 ''' client = pylxd_client_get(remote_addr, cert, key, verify_cert) image = None try: image = client.images.get_by_alias(alias) except pylxd.exceptions.LXDAPIException: raise SaltInvocationError( 'Image with alias \'{0}\' not found'.format(alias) ) if _raw: return image return _pylxd_model_to_dict(image)
[ "def", "image_get_by_alias", "(", "alias", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ",", "_raw", "=", "False", ")", ":", "client", "=", "pylxd_client_get", "(", "remote_addr", ",...
Get an image by an alias alias : The alias of the image to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. _raw : False Return the raw pylxd object or a dict of it? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_get_by_alias xenial/amd64
[ "Get", "an", "image", "by", "an", "alias" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2603-L2661
train
saltstack/salt
salt/modules/lxd.py
image_delete
def image_delete(image, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete an image by an alias or fingerprint name : The alias or fingerprint of the image to delete, can be a obj for the states. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: ..code-block:: bash $ salt '*' lxd.image_delete xenial/amd64 ''' image = _verify_image(image, remote_addr, cert, key, verify_cert) image.delete() return True
python
def image_delete(image, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete an image by an alias or fingerprint name : The alias or fingerprint of the image to delete, can be a obj for the states. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: ..code-block:: bash $ salt '*' lxd.image_delete xenial/amd64 ''' image = _verify_image(image, remote_addr, cert, key, verify_cert) image.delete() return True
[ "def", "image_delete", "(", "image", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "image", "=", "_verify_image", "(", "image", ",", "remote_addr", ",", "cert", ",", "key"...
Delete an image by an alias or fingerprint name : The alias or fingerprint of the image to delete, can be a obj for the states. remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: ..code-block:: bash $ salt '*' lxd.image_delete xenial/amd64
[ "Delete", "an", "image", "by", "an", "alias", "or", "fingerprint" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2664-L2710
train
saltstack/salt
salt/modules/lxd.py
image_from_simplestreams
def image_from_simplestreams(server, alias, remote_addr=None, cert=None, key=None, verify_cert=True, aliases=None, public=False, auto_update=False, _raw=False): ''' Create an image from simplestreams server : Simplestreams server URI alias : The alias of the image to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. aliases : [] List of aliases to append to the copied image public : False Make this image public available auto_update : False Should LXD auto update that image? _raw : False Return the raw pylxd object or a dict of the image? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_from_simplestreams "https://cloud-images.ubuntu.com/releases" "trusty/amd64" aliases='["t", "trusty/amd64"]' auto_update=True ''' if aliases is None: aliases = [] client = pylxd_client_get(remote_addr, cert, key, verify_cert) try: image = client.images.create_from_simplestreams( server, alias, public=public, auto_update=auto_update ) except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError(six.text_type(e)) # Aliases support for alias in aliases: image_alias_add(image, alias) if _raw: return image return _pylxd_model_to_dict(image)
python
def image_from_simplestreams(server, alias, remote_addr=None, cert=None, key=None, verify_cert=True, aliases=None, public=False, auto_update=False, _raw=False): ''' Create an image from simplestreams server : Simplestreams server URI alias : The alias of the image to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. aliases : [] List of aliases to append to the copied image public : False Make this image public available auto_update : False Should LXD auto update that image? _raw : False Return the raw pylxd object or a dict of the image? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_from_simplestreams "https://cloud-images.ubuntu.com/releases" "trusty/amd64" aliases='["t", "trusty/amd64"]' auto_update=True ''' if aliases is None: aliases = [] client = pylxd_client_get(remote_addr, cert, key, verify_cert) try: image = client.images.create_from_simplestreams( server, alias, public=public, auto_update=auto_update ) except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError(six.text_type(e)) # Aliases support for alias in aliases: image_alias_add(image, alias) if _raw: return image return _pylxd_model_to_dict(image)
[ "def", "image_from_simplestreams", "(", "server", ",", "alias", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ",", "aliases", "=", "None", ",", "public", "=", "False", ",", "auto_upda...
Create an image from simplestreams server : Simplestreams server URI alias : The alias of the image to retrieve remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. aliases : [] List of aliases to append to the copied image public : False Make this image public available auto_update : False Should LXD auto update that image? _raw : False Return the raw pylxd object or a dict of the image? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_from_simplestreams "https://cloud-images.ubuntu.com/releases" "trusty/amd64" aliases='["t", "trusty/amd64"]' auto_update=True
[ "Create", "an", "image", "from", "simplestreams" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2713-L2793
train
saltstack/salt
salt/modules/lxd.py
image_from_file
def image_from_file(filename, remote_addr=None, cert=None, key=None, verify_cert=True, aliases=None, public=False, saltenv='base', _raw=False): ''' Create an image from a file filename : The filename of the rootfs remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. aliases : [] List of aliases to append to the copied image public : False Make this image public available saltenv : base The saltenv to use for salt:// copies _raw : False Return the raw pylxd object or a dict of the image? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_from_file salt://lxd/files/busybox.tar.xz aliases=["busybox-amd64"] ''' if aliases is None: aliases = [] cached_file = __salt__['cp.cache_file'](filename, saltenv=saltenv) data = b'' with salt.utils.files.fopen(cached_file, 'r+b') as fp: data = fp.read() client = pylxd_client_get(remote_addr, cert, key, verify_cert) try: image = client.images.create(data, public=public, wait=True) except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError(six.text_type(e)) # Aliases support for alias in aliases: image_alias_add(image, alias) if _raw: return image return _pylxd_model_to_dict(image)
python
def image_from_file(filename, remote_addr=None, cert=None, key=None, verify_cert=True, aliases=None, public=False, saltenv='base', _raw=False): ''' Create an image from a file filename : The filename of the rootfs remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. aliases : [] List of aliases to append to the copied image public : False Make this image public available saltenv : base The saltenv to use for salt:// copies _raw : False Return the raw pylxd object or a dict of the image? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_from_file salt://lxd/files/busybox.tar.xz aliases=["busybox-amd64"] ''' if aliases is None: aliases = [] cached_file = __salt__['cp.cache_file'](filename, saltenv=saltenv) data = b'' with salt.utils.files.fopen(cached_file, 'r+b') as fp: data = fp.read() client = pylxd_client_get(remote_addr, cert, key, verify_cert) try: image = client.images.create(data, public=public, wait=True) except pylxd.exceptions.LXDAPIException as e: raise CommandExecutionError(six.text_type(e)) # Aliases support for alias in aliases: image_alias_add(image, alias) if _raw: return image return _pylxd_model_to_dict(image)
[ "def", "image_from_file", "(", "filename", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ",", "aliases", "=", "None", ",", "public", "=", "False", ",", "saltenv", "=", "'base'", ","...
Create an image from a file filename : The filename of the rootfs remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. aliases : [] List of aliases to append to the copied image public : False Make this image public available saltenv : base The saltenv to use for salt:// copies _raw : False Return the raw pylxd object or a dict of the image? CLI Examples: ..code-block:: bash $ salt '*' lxd.image_from_file salt://lxd/files/busybox.tar.xz aliases=["busybox-amd64"]
[ "Create", "an", "image", "from", "a", "file" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2875-L2954
train
saltstack/salt
salt/modules/lxd.py
image_copy_lxd
def image_copy_lxd(source, src_remote_addr, src_cert, src_key, src_verify_cert, remote_addr, cert, key, verify_cert=True, aliases=None, public=None, auto_update=None, _raw=False): ''' Copy an image from another LXD instance source : An alias or a fingerprint of the source. src_remote_addr : An URL to the source remote daemon Examples: https://mysourceserver.lan:8443 src_cert : PEM Formatted SSL Certificate for the source Examples: ~/.config/lxc/client.crt src_key : PEM Formatted SSL Key for the source Examples: ~/.config/lxc/client.key src_verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. remote_addr : Address of the destination daemon Examples: https://mydestserver.lan:8443 cert : PEM Formatted SSL Certificate for the destination Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key for the destination Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. aliases : [] List of aliases to append to the copied image public : None Make this image public available, None = copy source auto_update : None Wherever to auto-update from the original source, None = copy source _raw : False Return the raw pylxd object or a dict of the destination image? CLI Examples: .. code-block:: bash $ salt '*' lxd.image_copy_lxd xenial/amd64 https://srv01:8443 ~/.config/lxc/client.crt ~/.config/lxc/client.key false https://srv02:8443 ~/.config/lxc/client.crt ~/.config/lxc/client.key false aliases="['xenial/amd64']" ''' if aliases is None: aliases = [] log.debug('Trying to copy the image "%s" from "%s" to "%s"', source, src_remote_addr, remote_addr) # This will fail with a SaltInvocationError if # the image doesn't exists on the source and with a CommandExecutionError # on connection problems. src_image = None try: src_image = image_get_by_alias( source, src_remote_addr, src_cert, src_key, src_verify_cert, _raw=True ) except SaltInvocationError: src_image = image_get( source, src_remote_addr, src_cert, src_key, src_verify_cert, _raw=True ) # Will fail with a CommandExecutionError on connection problems. dest_client = pylxd_client_get(remote_addr, cert, key, verify_cert) dest_image = src_image.copy( dest_client, public=public, auto_update=auto_update, wait=True ) # Aliases support for alias in aliases: image_alias_add(dest_image, alias) if _raw: return dest_image return _pylxd_model_to_dict(dest_image)
python
def image_copy_lxd(source, src_remote_addr, src_cert, src_key, src_verify_cert, remote_addr, cert, key, verify_cert=True, aliases=None, public=None, auto_update=None, _raw=False): ''' Copy an image from another LXD instance source : An alias or a fingerprint of the source. src_remote_addr : An URL to the source remote daemon Examples: https://mysourceserver.lan:8443 src_cert : PEM Formatted SSL Certificate for the source Examples: ~/.config/lxc/client.crt src_key : PEM Formatted SSL Key for the source Examples: ~/.config/lxc/client.key src_verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. remote_addr : Address of the destination daemon Examples: https://mydestserver.lan:8443 cert : PEM Formatted SSL Certificate for the destination Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key for the destination Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. aliases : [] List of aliases to append to the copied image public : None Make this image public available, None = copy source auto_update : None Wherever to auto-update from the original source, None = copy source _raw : False Return the raw pylxd object or a dict of the destination image? CLI Examples: .. code-block:: bash $ salt '*' lxd.image_copy_lxd xenial/amd64 https://srv01:8443 ~/.config/lxc/client.crt ~/.config/lxc/client.key false https://srv02:8443 ~/.config/lxc/client.crt ~/.config/lxc/client.key false aliases="['xenial/amd64']" ''' if aliases is None: aliases = [] log.debug('Trying to copy the image "%s" from "%s" to "%s"', source, src_remote_addr, remote_addr) # This will fail with a SaltInvocationError if # the image doesn't exists on the source and with a CommandExecutionError # on connection problems. src_image = None try: src_image = image_get_by_alias( source, src_remote_addr, src_cert, src_key, src_verify_cert, _raw=True ) except SaltInvocationError: src_image = image_get( source, src_remote_addr, src_cert, src_key, src_verify_cert, _raw=True ) # Will fail with a CommandExecutionError on connection problems. dest_client = pylxd_client_get(remote_addr, cert, key, verify_cert) dest_image = src_image.copy( dest_client, public=public, auto_update=auto_update, wait=True ) # Aliases support for alias in aliases: image_alias_add(dest_image, alias) if _raw: return dest_image return _pylxd_model_to_dict(dest_image)
[ "def", "image_copy_lxd", "(", "source", ",", "src_remote_addr", ",", "src_cert", ",", "src_key", ",", "src_verify_cert", ",", "remote_addr", ",", "cert", ",", "key", ",", "verify_cert", "=", "True", ",", "aliases", "=", "None", ",", "public", "=", "None", ...
Copy an image from another LXD instance source : An alias or a fingerprint of the source. src_remote_addr : An URL to the source remote daemon Examples: https://mysourceserver.lan:8443 src_cert : PEM Formatted SSL Certificate for the source Examples: ~/.config/lxc/client.crt src_key : PEM Formatted SSL Key for the source Examples: ~/.config/lxc/client.key src_verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. remote_addr : Address of the destination daemon Examples: https://mydestserver.lan:8443 cert : PEM Formatted SSL Certificate for the destination Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key for the destination Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. aliases : [] List of aliases to append to the copied image public : None Make this image public available, None = copy source auto_update : None Wherever to auto-update from the original source, None = copy source _raw : False Return the raw pylxd object or a dict of the destination image? CLI Examples: .. code-block:: bash $ salt '*' lxd.image_copy_lxd xenial/amd64 https://srv01:8443 ~/.config/lxc/client.crt ~/.config/lxc/client.key false https://srv02:8443 ~/.config/lxc/client.crt ~/.config/lxc/client.key false aliases="['xenial/amd64']"
[ "Copy", "an", "image", "from", "another", "LXD", "instance" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L2957-L3074
train
saltstack/salt
salt/modules/lxd.py
image_alias_add
def image_alias_add(image, alias, description='', remote_addr=None, cert=None, key=None, verify_cert=True): ''' Create an alias on the given image image : An image alias, a fingerprint or a image object alias : The alias to add description : Description of the alias remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.image_alias_add xenial/amd64 x "Short version of xenial/amd64" ''' image = _verify_image(image, remote_addr, cert, key, verify_cert) for alias_info in image.aliases: if alias_info['name'] == alias: return True image.add_alias(alias, description) return True
python
def image_alias_add(image, alias, description='', remote_addr=None, cert=None, key=None, verify_cert=True): ''' Create an alias on the given image image : An image alias, a fingerprint or a image object alias : The alias to add description : Description of the alias remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.image_alias_add xenial/amd64 x "Short version of xenial/amd64" ''' image = _verify_image(image, remote_addr, cert, key, verify_cert) for alias_info in image.aliases: if alias_info['name'] == alias: return True image.add_alias(alias, description) return True
[ "def", "image_alias_add", "(", "image", ",", "alias", ",", "description", "=", "''", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "image", "=", "_verify_image", "(", "ima...
Create an alias on the given image image : An image alias, a fingerprint or a image object alias : The alias to add description : Description of the alias remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.image_alias_add xenial/amd64 x "Short version of xenial/amd64"
[ "Create", "an", "alias", "on", "the", "given", "image" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3077-L3133
train
saltstack/salt
salt/modules/lxd.py
image_alias_delete
def image_alias_delete(image, alias, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete an alias (this is currently not restricted to the image) image : An image alias, a fingerprint or a image object alias : The alias to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.image_alias_add xenial/amd64 x "Short version of xenial/amd64" ''' image = _verify_image(image, remote_addr, cert, key, verify_cert) try: image.delete_alias(alias) except pylxd.exceptions.LXDAPIException: return False return True
python
def image_alias_delete(image, alias, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete an alias (this is currently not restricted to the image) image : An image alias, a fingerprint or a image object alias : The alias to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.image_alias_add xenial/amd64 x "Short version of xenial/amd64" ''' image = _verify_image(image, remote_addr, cert, key, verify_cert) try: image.delete_alias(alias) except pylxd.exceptions.LXDAPIException: return False return True
[ "def", "image_alias_delete", "(", "image", ",", "alias", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "image", "=", "_verify_image", "(", "image", ",", "remote_addr", ",", ...
Delete an alias (this is currently not restricted to the image) image : An image alias, a fingerprint or a image object alias : The alias to delete remote_addr : An URL to a remote Server, you also have to give cert and key if you provide remote_addr and its a TCP Address! Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Wherever to verify the cert, this is by default True but in the most cases you want to set it off as LXD normaly uses self-signed certificates. CLI Examples: .. code-block:: bash $ salt '*' lxd.image_alias_add xenial/amd64 x "Short version of xenial/amd64"
[ "Delete", "an", "alias", "(", "this", "is", "currently", "not", "restricted", "to", "the", "image", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3136-L3188
train
saltstack/salt
salt/modules/lxd.py
snapshots_all
def snapshots_all(container, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get all snapshots for a container container : The name of the container to get. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_all test-container ''' containers = container_get( container, remote_addr, cert, key, verify_cert, _raw=True ) if container: containers = [containers] ret = {} for cont in containers: ret.update({cont.name: [{'name': c.name} for c in cont.snapshots.all()]}) return ret
python
def snapshots_all(container, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get all snapshots for a container container : The name of the container to get. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_all test-container ''' containers = container_get( container, remote_addr, cert, key, verify_cert, _raw=True ) if container: containers = [containers] ret = {} for cont in containers: ret.update({cont.name: [{'name': c.name} for c in cont.snapshots.all()]}) return ret
[ "def", "snapshots_all", "(", "container", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "containers", "=", "container_get", "(", "container", ",", "remote_addr", ",", "cert", ...
Get all snapshots for a container container : The name of the container to get. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_all test-container
[ "Get", "all", "snapshots", "for", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3195-L3241
train
saltstack/salt
salt/modules/lxd.py
snapshots_create
def snapshots_create(container, name=None, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Create a snapshot for a container container : The name of the container to get. name : The name of the snapshot. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_create test-container test-snapshot ''' cont = container_get( container, remote_addr, cert, key, verify_cert, _raw=True ) if not name: name = datetime.now().strftime('%Y%m%d%H%M%S') cont.snapshots.create(name) for c in snapshots_all(container).get(container): if c.get('name') == name: return {'name': name} return {'name': False}
python
def snapshots_create(container, name=None, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Create a snapshot for a container container : The name of the container to get. name : The name of the snapshot. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_create test-container test-snapshot ''' cont = container_get( container, remote_addr, cert, key, verify_cert, _raw=True ) if not name: name = datetime.now().strftime('%Y%m%d%H%M%S') cont.snapshots.create(name) for c in snapshots_all(container).get(container): if c.get('name') == name: return {'name': name} return {'name': False}
[ "def", "snapshots_create", "(", "container", ",", "name", "=", "None", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "cont", "=", "container_get", "(", "container", ",", "...
Create a snapshot for a container container : The name of the container to get. name : The name of the snapshot. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_create test-container test-snapshot
[ "Create", "a", "snapshot", "for", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3244-L3296
train
saltstack/salt
salt/modules/lxd.py
snapshots_delete
def snapshots_delete(container, name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a snapshot for a container container : The name of the container to get. name : The name of the snapshot. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_delete test-container test-snapshot ''' cont = container_get( container, remote_addr, cert, key, verify_cert, _raw=True ) try: for s in cont.snapshots.all(): if s.name == name: s.delete() return True except pylxd.exceptions.LXDAPIException: pass return False
python
def snapshots_delete(container, name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Delete a snapshot for a container container : The name of the container to get. name : The name of the snapshot. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_delete test-container test-snapshot ''' cont = container_get( container, remote_addr, cert, key, verify_cert, _raw=True ) try: for s in cont.snapshots.all(): if s.name == name: s.delete() return True except pylxd.exceptions.LXDAPIException: pass return False
[ "def", "snapshots_delete", "(", "container", ",", "name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "cont", "=", "container_get", "(", "container", ",", "remote_addr", "...
Delete a snapshot for a container container : The name of the container to get. name : The name of the snapshot. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_delete test-container test-snapshot
[ "Delete", "a", "snapshot", "for", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3299-L3351
train
saltstack/salt
salt/modules/lxd.py
snapshots_get
def snapshots_get(container, name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get information about snapshot for a container container : The name of the container to get. name : The name of the snapshot. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_get test-container test-snapshot ''' container = container_get( container, remote_addr, cert, key, verify_cert, _raw=True ) return container.snapshots.get(name)
python
def snapshots_get(container, name, remote_addr=None, cert=None, key=None, verify_cert=True): ''' Get information about snapshot for a container container : The name of the container to get. name : The name of the snapshot. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_get test-container test-snapshot ''' container = container_get( container, remote_addr, cert, key, verify_cert, _raw=True ) return container.snapshots.get(name)
[ "def", "snapshots_get", "(", "container", ",", "name", ",", "remote_addr", "=", "None", ",", "cert", "=", "None", ",", "key", "=", "None", ",", "verify_cert", "=", "True", ")", ":", "container", "=", "container_get", "(", "container", ",", "remote_addr", ...
Get information about snapshot for a container container : The name of the container to get. name : The name of the snapshot. remote_addr : An URL to a remote server. The 'cert' and 'key' fields must also be provided if 'remote_addr' is defined. Examples: https://myserver.lan:8443 /var/lib/mysocket.sock cert : PEM Formatted SSL Certificate. Examples: ~/.config/lxc/client.crt key : PEM Formatted SSL Key. Examples: ~/.config/lxc/client.key verify_cert : True Verify the ssl certificate. Default: True CLI Examples: .. code-block:: bash $ salt '*' lxd.snapshots_get test-container test-snapshot
[ "Get", "information", "about", "snapshot", "for", "a", "container" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3354-L3397
train
saltstack/salt
salt/modules/lxd.py
normalize_input_values
def normalize_input_values(config, devices): ''' normalize config input so returns can be put into mongodb, which doesn't like `.` This is not meant to be used on the commandline. CLI Examples: .. code-block:: bash salt '*' lxd.normalize_input_values config={} devices={} ''' if isinstance(config, list): if (config and 'key' in config[0] and 'value' in config[0]): config = {d['key']: d['value'] for d in config} else: config = {} if isinstance(config, six.string_types): raise SaltInvocationError( "config can't be a string, validate your YAML input." ) if isinstance(devices, six.string_types): raise SaltInvocationError( "devices can't be a string, validate your YAML input." ) # Golangs wants strings if config is not None: for k, v in six.iteritems(config): config[k] = six.text_type(v) if devices is not None: for dn in devices: for k, v in six.iteritems(devices[dn]): devices[dn][k] = v return (config, devices,)
python
def normalize_input_values(config, devices): ''' normalize config input so returns can be put into mongodb, which doesn't like `.` This is not meant to be used on the commandline. CLI Examples: .. code-block:: bash salt '*' lxd.normalize_input_values config={} devices={} ''' if isinstance(config, list): if (config and 'key' in config[0] and 'value' in config[0]): config = {d['key']: d['value'] for d in config} else: config = {} if isinstance(config, six.string_types): raise SaltInvocationError( "config can't be a string, validate your YAML input." ) if isinstance(devices, six.string_types): raise SaltInvocationError( "devices can't be a string, validate your YAML input." ) # Golangs wants strings if config is not None: for k, v in six.iteritems(config): config[k] = six.text_type(v) if devices is not None: for dn in devices: for k, v in six.iteritems(devices[dn]): devices[dn][k] = v return (config, devices,)
[ "def", "normalize_input_values", "(", "config", ",", "devices", ")", ":", "if", "isinstance", "(", "config", ",", "list", ")", ":", "if", "(", "config", "and", "'key'", "in", "config", "[", "0", "]", "and", "'value'", "in", "config", "[", "0", "]", "...
normalize config input so returns can be put into mongodb, which doesn't like `.` This is not meant to be used on the commandline. CLI Examples: .. code-block:: bash salt '*' lxd.normalize_input_values config={} devices={}
[ "normalize", "config", "input", "so", "returns", "can", "be", "put", "into", "mongodb", "which", "doesn", "t", "like", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3404-L3443
train
saltstack/salt
salt/modules/lxd.py
sync_config_devices
def sync_config_devices(obj, newconfig, newdevices, test=False): ''' Syncs the given config and devices with the object (a profile or a container) returns a changes dict with all changes made. obj : The object to sync with / or just test with. newconfig: The new config to check with the obj. newdevices: The new devices to check with the obj. test: Wherever to not change anything and give "Would change" message. ''' changes = {} # # config changes # if newconfig is None: newconfig = {} newconfig = dict(list(zip( map(six.text_type, newconfig.keys()), map(six.text_type, newconfig.values()) ))) cck = set(newconfig.keys()) obj.config = dict(list(zip( map(six.text_type, obj.config.keys()), map(six.text_type, obj.config.values()) ))) ock = set(obj.config.keys()) config_changes = {} # Removed keys for k in ock.difference(cck): # Ignore LXD internals. if k.startswith('volatile.') or k.startswith('image.'): continue if not test: config_changes[k] = ( 'Removed config key "{0}", its value was "{1}"' ).format(k, obj.config[k]) del obj.config[k] else: config_changes[k] = ( 'Would remove config key "{0} with value "{1}"' ).format(k, obj.config[k]) # same keys for k in cck.intersection(ock): # Ignore LXD internals. if k.startswith('volatile.') or k.startswith('image.'): continue if newconfig[k] != obj.config[k]: if not test: config_changes[k] = ( 'Changed config key "{0}" to "{1}", ' 'its value was "{2}"' ).format(k, newconfig[k], obj.config[k]) obj.config[k] = newconfig[k] else: config_changes[k] = ( 'Would change config key "{0}" to "{1}", ' 'its current value is "{2}"' ).format(k, newconfig[k], obj.config[k]) # New keys for k in cck.difference(ock): # Ignore LXD internals. if k.startswith('volatile.') or k.startswith('image.'): continue if not test: config_changes[k] = ( 'Added config key "{0}" = "{1}"' ).format(k, newconfig[k]) obj.config[k] = newconfig[k] else: config_changes[k] = ( 'Would add config key "{0}" = "{1}"' ).format(k, newconfig[k]) if config_changes: changes['config'] = config_changes # # devices changes # if newdevices is None: newdevices = {} dk = set(obj.devices.keys()) ndk = set(newdevices.keys()) devices_changes = {} # Removed devices for k in dk.difference(ndk): # Ignore LXD internals. if k == u'root': continue if not test: devices_changes[k] = ( 'Removed device "{0}"' ).format(k) del obj.devices[k] else: devices_changes[k] = ( 'Would remove device "{0}"' ).format(k) # Changed devices for k, v in six.iteritems(obj.devices): # Ignore LXD internals also for new devices. if k == u'root': continue if k not in newdevices: # In test mode we don't delete devices above. continue if newdevices[k] != v: if not test: devices_changes[k] = ( 'Changed device "{0}"' ).format(k) obj.devices[k] = newdevices[k] else: devices_changes[k] = ( 'Would change device "{0}"' ).format(k) # New devices for k in ndk.difference(dk): # Ignore LXD internals. if k == u'root': continue if not test: devices_changes[k] = ( 'Added device "{0}"' ).format(k) obj.devices[k] = newdevices[k] else: devices_changes[k] = ( 'Would add device "{0}"' ).format(k) if devices_changes: changes['devices'] = devices_changes return changes
python
def sync_config_devices(obj, newconfig, newdevices, test=False): ''' Syncs the given config and devices with the object (a profile or a container) returns a changes dict with all changes made. obj : The object to sync with / or just test with. newconfig: The new config to check with the obj. newdevices: The new devices to check with the obj. test: Wherever to not change anything and give "Would change" message. ''' changes = {} # # config changes # if newconfig is None: newconfig = {} newconfig = dict(list(zip( map(six.text_type, newconfig.keys()), map(six.text_type, newconfig.values()) ))) cck = set(newconfig.keys()) obj.config = dict(list(zip( map(six.text_type, obj.config.keys()), map(six.text_type, obj.config.values()) ))) ock = set(obj.config.keys()) config_changes = {} # Removed keys for k in ock.difference(cck): # Ignore LXD internals. if k.startswith('volatile.') or k.startswith('image.'): continue if not test: config_changes[k] = ( 'Removed config key "{0}", its value was "{1}"' ).format(k, obj.config[k]) del obj.config[k] else: config_changes[k] = ( 'Would remove config key "{0} with value "{1}"' ).format(k, obj.config[k]) # same keys for k in cck.intersection(ock): # Ignore LXD internals. if k.startswith('volatile.') or k.startswith('image.'): continue if newconfig[k] != obj.config[k]: if not test: config_changes[k] = ( 'Changed config key "{0}" to "{1}", ' 'its value was "{2}"' ).format(k, newconfig[k], obj.config[k]) obj.config[k] = newconfig[k] else: config_changes[k] = ( 'Would change config key "{0}" to "{1}", ' 'its current value is "{2}"' ).format(k, newconfig[k], obj.config[k]) # New keys for k in cck.difference(ock): # Ignore LXD internals. if k.startswith('volatile.') or k.startswith('image.'): continue if not test: config_changes[k] = ( 'Added config key "{0}" = "{1}"' ).format(k, newconfig[k]) obj.config[k] = newconfig[k] else: config_changes[k] = ( 'Would add config key "{0}" = "{1}"' ).format(k, newconfig[k]) if config_changes: changes['config'] = config_changes # # devices changes # if newdevices is None: newdevices = {} dk = set(obj.devices.keys()) ndk = set(newdevices.keys()) devices_changes = {} # Removed devices for k in dk.difference(ndk): # Ignore LXD internals. if k == u'root': continue if not test: devices_changes[k] = ( 'Removed device "{0}"' ).format(k) del obj.devices[k] else: devices_changes[k] = ( 'Would remove device "{0}"' ).format(k) # Changed devices for k, v in six.iteritems(obj.devices): # Ignore LXD internals also for new devices. if k == u'root': continue if k not in newdevices: # In test mode we don't delete devices above. continue if newdevices[k] != v: if not test: devices_changes[k] = ( 'Changed device "{0}"' ).format(k) obj.devices[k] = newdevices[k] else: devices_changes[k] = ( 'Would change device "{0}"' ).format(k) # New devices for k in ndk.difference(dk): # Ignore LXD internals. if k == u'root': continue if not test: devices_changes[k] = ( 'Added device "{0}"' ).format(k) obj.devices[k] = newdevices[k] else: devices_changes[k] = ( 'Would add device "{0}"' ).format(k) if devices_changes: changes['devices'] = devices_changes return changes
[ "def", "sync_config_devices", "(", "obj", ",", "newconfig", ",", "newdevices", ",", "test", "=", "False", ")", ":", "changes", "=", "{", "}", "#", "# config changes", "#", "if", "newconfig", "is", "None", ":", "newconfig", "=", "{", "}", "newconfig", "="...
Syncs the given config and devices with the object (a profile or a container) returns a changes dict with all changes made. obj : The object to sync with / or just test with. newconfig: The new config to check with the obj. newdevices: The new devices to check with the obj. test: Wherever to not change anything and give "Would change" message.
[ "Syncs", "the", "given", "config", "and", "devices", "with", "the", "object", "(", "a", "profile", "or", "a", "container", ")", "returns", "a", "changes", "dict", "with", "all", "changes", "made", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3446-L3604
train
saltstack/salt
salt/modules/lxd.py
_set_property_dict_item
def _set_property_dict_item(obj, prop, key, value): ''' Sets the dict item key of the attr from obj. Basicaly it does getattr(obj, prop)[key] = value. For the disk device we added some checks to make device changes on the CLI saver. ''' attr = getattr(obj, prop) if prop == 'devices': device_type = value['type'] if device_type == 'disk': if 'path' not in value: raise SaltInvocationError( "path must be given as parameter" ) if value['path'] != '/' and 'source' not in value: raise SaltInvocationError( "source must be given as parameter" ) for k in value.keys(): if k.startswith('__'): del value[k] attr[key] = value else: # config attr[key] = six.text_type(value) pylxd_save_object(obj) return _pylxd_model_to_dict(obj)
python
def _set_property_dict_item(obj, prop, key, value): ''' Sets the dict item key of the attr from obj. Basicaly it does getattr(obj, prop)[key] = value. For the disk device we added some checks to make device changes on the CLI saver. ''' attr = getattr(obj, prop) if prop == 'devices': device_type = value['type'] if device_type == 'disk': if 'path' not in value: raise SaltInvocationError( "path must be given as parameter" ) if value['path'] != '/' and 'source' not in value: raise SaltInvocationError( "source must be given as parameter" ) for k in value.keys(): if k.startswith('__'): del value[k] attr[key] = value else: # config attr[key] = six.text_type(value) pylxd_save_object(obj) return _pylxd_model_to_dict(obj)
[ "def", "_set_property_dict_item", "(", "obj", ",", "prop", ",", "key", ",", "value", ")", ":", "attr", "=", "getattr", "(", "obj", ",", "prop", ")", "if", "prop", "==", "'devices'", ":", "device_type", "=", "value", "[", "'type'", "]", "if", "device_ty...
Sets the dict item key of the attr from obj. Basicaly it does getattr(obj, prop)[key] = value. For the disk device we added some checks to make device changes on the CLI saver.
[ "Sets", "the", "dict", "item", "key", "of", "the", "attr", "from", "obj", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3607-L3643
train
saltstack/salt
salt/modules/lxd.py
_pylxd_model_to_dict
def _pylxd_model_to_dict(obj): '''Translates a plyxd model object to a dict''' marshalled = {} for key in obj.__attributes__.keys(): if hasattr(obj, key): marshalled[key] = getattr(obj, key) return marshalled
python
def _pylxd_model_to_dict(obj): '''Translates a plyxd model object to a dict''' marshalled = {} for key in obj.__attributes__.keys(): if hasattr(obj, key): marshalled[key] = getattr(obj, key) return marshalled
[ "def", "_pylxd_model_to_dict", "(", "obj", ")", ":", "marshalled", "=", "{", "}", "for", "key", "in", "obj", ".", "__attributes__", ".", "keys", "(", ")", ":", "if", "hasattr", "(", "obj", ",", "key", ")", ":", "marshalled", "[", "key", "]", "=", "...
Translates a plyxd model object to a dict
[ "Translates", "a", "plyxd", "model", "object", "to", "a", "dict" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxd.py#L3699-L3705
train
saltstack/salt
salt/modules/proxy.py
set_ftp_proxy
def set_ftp_proxy(server, port, user=None, password=None, network_service="Ethernet", bypass_hosts=None): ''' Sets the ftp proxy settings server The proxy server to use port The port used by the proxy server user The username to use for the proxy server if required password The password to use if required by the server network_service The network service to apply the changes to, this only necessary on macOS bypass_hosts The hosts that are allowed to by pass the proxy. Only used on Windows for other OS's use set_proxy_bypass to edit the bypass hosts. CLI Example: .. code-block:: bash salt '*' proxy.set_ftp_proxy example.com 1080 user=proxy_user password=proxy_pass network_service=Ethernet ''' if __grains__['os'] == 'Windows': return _set_proxy_windows(server=server, port=port, types=['ftp'], bypass_hosts=bypass_hosts) return _set_proxy_osx(cmd_function="setftpproxy", server=server, port=port, user=user, password=password, network_service=network_service)
python
def set_ftp_proxy(server, port, user=None, password=None, network_service="Ethernet", bypass_hosts=None): ''' Sets the ftp proxy settings server The proxy server to use port The port used by the proxy server user The username to use for the proxy server if required password The password to use if required by the server network_service The network service to apply the changes to, this only necessary on macOS bypass_hosts The hosts that are allowed to by pass the proxy. Only used on Windows for other OS's use set_proxy_bypass to edit the bypass hosts. CLI Example: .. code-block:: bash salt '*' proxy.set_ftp_proxy example.com 1080 user=proxy_user password=proxy_pass network_service=Ethernet ''' if __grains__['os'] == 'Windows': return _set_proxy_windows(server=server, port=port, types=['ftp'], bypass_hosts=bypass_hosts) return _set_proxy_osx(cmd_function="setftpproxy", server=server, port=port, user=user, password=password, network_service=network_service)
[ "def", "set_ftp_proxy", "(", "server", ",", "port", ",", "user", "=", "None", ",", "password", "=", "None", ",", "network_service", "=", "\"Ethernet\"", ",", "bypass_hosts", "=", "None", ")", ":", "if", "__grains__", "[", "'os'", "]", "==", "'Windows'", ...
Sets the ftp proxy settings server The proxy server to use port The port used by the proxy server user The username to use for the proxy server if required password The password to use if required by the server network_service The network service to apply the changes to, this only necessary on macOS bypass_hosts The hosts that are allowed to by pass the proxy. Only used on Windows for other OS's use set_proxy_bypass to edit the bypass hosts. CLI Example: .. code-block:: bash salt '*' proxy.set_ftp_proxy example.com 1080 user=proxy_user password=proxy_pass network_service=Ethernet
[ "Sets", "the", "ftp", "proxy", "settings" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/proxy.py#L306-L352
train
saltstack/salt
salt/modules/proxy.py
get_proxy_bypass
def get_proxy_bypass(network_service="Ethernet"): ''' Returns the current domains that can bypass the proxy network_service The network service to get the bypass domains from, this is only necessary on macOS CLI Example: .. code-block:: bash salt '*' proxy.get_proxy_bypass ''' if __grains__['os'] == 'Windows': reg_val = __utils__['reg.read_value']( hive='HKEY_CURRENT_USER', key=r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings', vname='ProxyOverride')['vdata'] # `reg.read_value` returns None if the key doesn't exist if reg_val is None: return [] return reg_val.replace('<local>', '').split(';') out = __salt__['cmd.run']('networksetup -getproxybypassdomains {0}'.format(network_service)) return out.split("\n")
python
def get_proxy_bypass(network_service="Ethernet"): ''' Returns the current domains that can bypass the proxy network_service The network service to get the bypass domains from, this is only necessary on macOS CLI Example: .. code-block:: bash salt '*' proxy.get_proxy_bypass ''' if __grains__['os'] == 'Windows': reg_val = __utils__['reg.read_value']( hive='HKEY_CURRENT_USER', key=r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings', vname='ProxyOverride')['vdata'] # `reg.read_value` returns None if the key doesn't exist if reg_val is None: return [] return reg_val.replace('<local>', '').split(';') out = __salt__['cmd.run']('networksetup -getproxybypassdomains {0}'.format(network_service)) return out.split("\n")
[ "def", "get_proxy_bypass", "(", "network_service", "=", "\"Ethernet\"", ")", ":", "if", "__grains__", "[", "'os'", "]", "==", "'Windows'", ":", "reg_val", "=", "__utils__", "[", "'reg.read_value'", "]", "(", "hive", "=", "'HKEY_CURRENT_USER'", ",", "key", "=",...
Returns the current domains that can bypass the proxy network_service The network service to get the bypass domains from, this is only necessary on macOS CLI Example: .. code-block:: bash salt '*' proxy.get_proxy_bypass
[ "Returns", "the", "current", "domains", "that", "can", "bypass", "the", "proxy" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/proxy.py#L355-L384
train
saltstack/salt
salt/modules/proxy.py
set_proxy_bypass
def set_proxy_bypass(domains, network_service="Ethernet"): ''' Sets the domains that can bypass the proxy domains An array of domains allowed to bypass the proxy network_service The network service to apply the changes to, this only necessary on macOS CLI Example: .. code-block:: bash salt '*' proxy.set_proxy_bypass "['127.0.0.1', 'localhost']" ''' servers_str = ' '.join(domains) cmd = 'networksetup -setproxybypassdomains {0} {1}'.format(network_service, servers_str,) out = __salt__['cmd.run'](cmd) return 'error' not in out
python
def set_proxy_bypass(domains, network_service="Ethernet"): ''' Sets the domains that can bypass the proxy domains An array of domains allowed to bypass the proxy network_service The network service to apply the changes to, this only necessary on macOS CLI Example: .. code-block:: bash salt '*' proxy.set_proxy_bypass "['127.0.0.1', 'localhost']" ''' servers_str = ' '.join(domains) cmd = 'networksetup -setproxybypassdomains {0} {1}'.format(network_service, servers_str,) out = __salt__['cmd.run'](cmd) return 'error' not in out
[ "def", "set_proxy_bypass", "(", "domains", ",", "network_service", "=", "\"Ethernet\"", ")", ":", "servers_str", "=", "' '", ".", "join", "(", "domains", ")", "cmd", "=", "'networksetup -setproxybypassdomains {0} {1}'", ".", "format", "(", "network_service", ",", ...
Sets the domains that can bypass the proxy domains An array of domains allowed to bypass the proxy network_service The network service to apply the changes to, this only necessary on macOS CLI Example: .. code-block:: bash salt '*' proxy.set_proxy_bypass "['127.0.0.1', 'localhost']"
[ "Sets", "the", "domains", "that", "can", "bypass", "the", "proxy" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/proxy.py#L387-L409
train
saltstack/salt
salt/modules/proxy.py
set_proxy_win
def set_proxy_win(server, port, types=None, bypass_hosts=None): ''' Sets the http proxy settings, only works with Windows. server The proxy server to use password The password to use if required by the server types The types of proxy connections should be setup with this server. Valid types are: - ``http`` - ``https`` - ``ftp`` bypass_hosts The hosts that are allowed to by pass the proxy. CLI Example: .. code-block:: bash salt '*' proxy.set_http_proxy example.com 1080 types="['http', 'https']" ''' if __grains__['os'] == 'Windows': return _set_proxy_windows(server=server, port=port, types=types, bypass_hosts=bypass_hosts)
python
def set_proxy_win(server, port, types=None, bypass_hosts=None): ''' Sets the http proxy settings, only works with Windows. server The proxy server to use password The password to use if required by the server types The types of proxy connections should be setup with this server. Valid types are: - ``http`` - ``https`` - ``ftp`` bypass_hosts The hosts that are allowed to by pass the proxy. CLI Example: .. code-block:: bash salt '*' proxy.set_http_proxy example.com 1080 types="['http', 'https']" ''' if __grains__['os'] == 'Windows': return _set_proxy_windows(server=server, port=port, types=types, bypass_hosts=bypass_hosts)
[ "def", "set_proxy_win", "(", "server", ",", "port", ",", "types", "=", "None", ",", "bypass_hosts", "=", "None", ")", ":", "if", "__grains__", "[", "'os'", "]", "==", "'Windows'", ":", "return", "_set_proxy_windows", "(", "server", "=", "server", ",", "p...
Sets the http proxy settings, only works with Windows. server The proxy server to use password The password to use if required by the server types The types of proxy connections should be setup with this server. Valid types are: - ``http`` - ``https`` - ``ftp`` bypass_hosts The hosts that are allowed to by pass the proxy. CLI Example: .. code-block:: bash salt '*' proxy.set_http_proxy example.com 1080 types="['http', 'https']"
[ "Sets", "the", "http", "proxy", "settings", "only", "works", "with", "Windows", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/proxy.py#L412-L443
train
saltstack/salt
salt/utils/smb.py
get_conn
def get_conn(host='', username=None, password=None, port=445): ''' Get an SMB connection ''' if HAS_IMPACKET and not HAS_SMBPROTOCOL: salt.utils.versions.warn_until( 'Sodium', 'Support of impacket has been depricated and will be ' 'removed in Sodium. Please install smbprotocol instead.' ) if HAS_SMBPROTOCOL: log.info('Get connection smbprotocol') return _get_conn_smbprotocol(host, username, password, port=port) elif HAS_IMPACKET: log.info('Get connection impacket') return _get_conn_impacket(host, username, password, port=port) return False
python
def get_conn(host='', username=None, password=None, port=445): ''' Get an SMB connection ''' if HAS_IMPACKET and not HAS_SMBPROTOCOL: salt.utils.versions.warn_until( 'Sodium', 'Support of impacket has been depricated and will be ' 'removed in Sodium. Please install smbprotocol instead.' ) if HAS_SMBPROTOCOL: log.info('Get connection smbprotocol') return _get_conn_smbprotocol(host, username, password, port=port) elif HAS_IMPACKET: log.info('Get connection impacket') return _get_conn_impacket(host, username, password, port=port) return False
[ "def", "get_conn", "(", "host", "=", "''", ",", "username", "=", "None", ",", "password", "=", "None", ",", "port", "=", "445", ")", ":", "if", "HAS_IMPACKET", "and", "not", "HAS_SMBPROTOCOL", ":", "salt", ".", "utils", ".", "versions", ".", "warn_unti...
Get an SMB connection
[ "Get", "an", "SMB", "connection" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/smb.py#L176-L192
train
saltstack/salt
salt/utils/smb.py
_mkdirs_impacket
def _mkdirs_impacket(path, share='C$', conn=None, host=None, username=None, password=None): ''' Recursively create a directory structure on an SMB share Paths should be passed in with forward-slash delimiters, and should not start with a forward-slash. ''' if conn is None: conn = get_conn(host, username, password) if conn is False: return False comps = path.split('/') pos = 1 for comp in comps: cwd = '\\'.join(comps[0:pos]) try: conn.listPath(share, cwd) except (smbSessionError, smb3SessionError): log.exception('Encountered error running conn.listPath') conn.createDirectory(share, cwd) pos += 1
python
def _mkdirs_impacket(path, share='C$', conn=None, host=None, username=None, password=None): ''' Recursively create a directory structure on an SMB share Paths should be passed in with forward-slash delimiters, and should not start with a forward-slash. ''' if conn is None: conn = get_conn(host, username, password) if conn is False: return False comps = path.split('/') pos = 1 for comp in comps: cwd = '\\'.join(comps[0:pos]) try: conn.listPath(share, cwd) except (smbSessionError, smb3SessionError): log.exception('Encountered error running conn.listPath') conn.createDirectory(share, cwd) pos += 1
[ "def", "_mkdirs_impacket", "(", "path", ",", "share", "=", "'C$'", ",", "conn", "=", "None", ",", "host", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "if", "conn", "is", "None", ":", "conn", "=", "get_conn", "...
Recursively create a directory structure on an SMB share Paths should be passed in with forward-slash delimiters, and should not start with a forward-slash.
[ "Recursively", "create", "a", "directory", "structure", "on", "an", "SMB", "share" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/smb.py#L195-L217
train
saltstack/salt
salt/utils/smb.py
put_str
def put_str(content, path, share='C$', conn=None, host=None, username=None, password=None): ''' Wrapper around impacket.smbconnection.putFile() that allows a string to be uploaded, without first writing it as a local file ''' if HAS_SMBPROTOCOL: return _put_str_smbprotocol( content, path, share, conn=conn, host=host, username=username, password=password ) elif HAS_IMPACKET: return _put_str_impacket( content, path, share, conn=conn, host=host, username=username, password=password ) raise MissingSmb("SMB library required (impacket or smbprotocol)")
python
def put_str(content, path, share='C$', conn=None, host=None, username=None, password=None): ''' Wrapper around impacket.smbconnection.putFile() that allows a string to be uploaded, without first writing it as a local file ''' if HAS_SMBPROTOCOL: return _put_str_smbprotocol( content, path, share, conn=conn, host=host, username=username, password=password ) elif HAS_IMPACKET: return _put_str_impacket( content, path, share, conn=conn, host=host, username=username, password=password ) raise MissingSmb("SMB library required (impacket or smbprotocol)")
[ "def", "put_str", "(", "content", ",", "path", ",", "share", "=", "'C$'", ",", "conn", "=", "None", ",", "host", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "if", "HAS_SMBPROTOCOL", ":", "return", "_put_str_smbpro...
Wrapper around impacket.smbconnection.putFile() that allows a string to be uploaded, without first writing it as a local file
[ "Wrapper", "around", "impacket", ".", "smbconnection", ".", "putFile", "()", "that", "allows", "a", "string", "to", "be", "uploaded", "without", "first", "writing", "it", "as", "a", "local", "file" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/smb.py#L281-L295
train
saltstack/salt
salt/utils/smb.py
_put_file_impacket
def _put_file_impacket(local_path, path, share='C$', conn=None, host=None, username=None, password=None): ''' Wrapper around impacket.smbconnection.putFile() that allows a file to be uploaded Example usage: import salt.utils.smb smb_conn = salt.utils.smb.get_conn('10.0.0.45', 'vagrant', 'vagrant') salt.utils.smb.put_file('/root/test.pdf', 'temp\\myfiles\\test1.pdf', conn=smb_conn) ''' if conn is None: conn = get_conn(host, username, password) if conn is False: return False if hasattr(local_path, 'read'): conn.putFile(share, path, local_path) return with salt.utils.files.fopen(local_path, 'rb') as fh_: conn.putFile(share, path, fh_.read)
python
def _put_file_impacket(local_path, path, share='C$', conn=None, host=None, username=None, password=None): ''' Wrapper around impacket.smbconnection.putFile() that allows a file to be uploaded Example usage: import salt.utils.smb smb_conn = salt.utils.smb.get_conn('10.0.0.45', 'vagrant', 'vagrant') salt.utils.smb.put_file('/root/test.pdf', 'temp\\myfiles\\test1.pdf', conn=smb_conn) ''' if conn is None: conn = get_conn(host, username, password) if conn is False: return False if hasattr(local_path, 'read'): conn.putFile(share, path, local_path) return with salt.utils.files.fopen(local_path, 'rb') as fh_: conn.putFile(share, path, fh_.read)
[ "def", "_put_file_impacket", "(", "local_path", ",", "path", ",", "share", "=", "'C$'", ",", "conn", "=", "None", ",", "host", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "if", "conn", "is", "None", ":", "conn",...
Wrapper around impacket.smbconnection.putFile() that allows a file to be uploaded Example usage: import salt.utils.smb smb_conn = salt.utils.smb.get_conn('10.0.0.45', 'vagrant', 'vagrant') salt.utils.smb.put_file('/root/test.pdf', 'temp\\myfiles\\test1.pdf', conn=smb_conn)
[ "Wrapper", "around", "impacket", ".", "smbconnection", ".", "putFile", "()", "that", "allows", "a", "file", "to", "be", "uploaded" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/smb.py#L298-L319
train
saltstack/salt
salt/utils/smb.py
put_file
def put_file(local_path, path, share='C$', conn=None, host=None, username=None, password=None): ''' Wrapper around impacket.smbconnection.putFile() that allows a file to be uploaded Example usage: import salt.utils.smb smb_conn = salt.utils.smb.get_conn('10.0.0.45', 'vagrant', 'vagrant') salt.utils.smb.put_file('/root/test.pdf', 'temp\\myfiles\\test1.pdf', conn=smb_conn) ''' if HAS_SMBPROTOCOL: return _put_file_smbprotocol( local_path, path, share, conn=conn, host=host, username=username, password=password ) elif HAS_IMPACKET: return _put_file_impacket( local_path, path, share, conn=conn, host=host, username=username, password=password ) raise MissingSmb("SMB library required (impacket or smbprotocol)")
python
def put_file(local_path, path, share='C$', conn=None, host=None, username=None, password=None): ''' Wrapper around impacket.smbconnection.putFile() that allows a file to be uploaded Example usage: import salt.utils.smb smb_conn = salt.utils.smb.get_conn('10.0.0.45', 'vagrant', 'vagrant') salt.utils.smb.put_file('/root/test.pdf', 'temp\\myfiles\\test1.pdf', conn=smb_conn) ''' if HAS_SMBPROTOCOL: return _put_file_smbprotocol( local_path, path, share, conn=conn, host=host, username=username, password=password ) elif HAS_IMPACKET: return _put_file_impacket( local_path, path, share, conn=conn, host=host, username=username, password=password ) raise MissingSmb("SMB library required (impacket or smbprotocol)")
[ "def", "put_file", "(", "local_path", ",", "path", ",", "share", "=", "'C$'", ",", "conn", "=", "None", ",", "host", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "if", "HAS_SMBPROTOCOL", ":", "return", "_put_file_s...
Wrapper around impacket.smbconnection.putFile() that allows a file to be uploaded Example usage: import salt.utils.smb smb_conn = salt.utils.smb.get_conn('10.0.0.45', 'vagrant', 'vagrant') salt.utils.smb.put_file('/root/test.pdf', 'temp\\myfiles\\test1.pdf', conn=smb_conn)
[ "Wrapper", "around", "impacket", ".", "smbconnection", ".", "putFile", "()", "that", "allows", "a", "file", "to", "be", "uploaded" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/smb.py#L345-L366
train
saltstack/salt
salt/utils/smb.py
StrHandle.string
def string(self, writesize=None): ''' Looks like a file handle ''' if not self.finished: self.finished = True return self.content return ''
python
def string(self, writesize=None): ''' Looks like a file handle ''' if not self.finished: self.finished = True return self.content return ''
[ "def", "string", "(", "self", ",", "writesize", "=", "None", ")", ":", "if", "not", "self", ".", "finished", ":", "self", ".", "finished", "=", "True", "return", "self", ".", "content", "return", "''" ]
Looks like a file handle
[ "Looks", "like", "a", "file", "handle" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/smb.py#L150-L157
train
saltstack/salt
salt/utils/extend.py
_get_template
def _get_template(path, option_key): ''' Get the contents of a template file and provide it as a module type :param path: path to the template.yml file :type path: ``str`` :param option_key: The unique key of this template :type option_key: ``str`` :returns: Details about the template :rtype: ``tuple`` ''' with salt.utils.files.fopen(path, 'r') as template_f: template = deserialize(template_f) info = (option_key, template.get('description', ''), template) return info
python
def _get_template(path, option_key): ''' Get the contents of a template file and provide it as a module type :param path: path to the template.yml file :type path: ``str`` :param option_key: The unique key of this template :type option_key: ``str`` :returns: Details about the template :rtype: ``tuple`` ''' with salt.utils.files.fopen(path, 'r') as template_f: template = deserialize(template_f) info = (option_key, template.get('description', ''), template) return info
[ "def", "_get_template", "(", "path", ",", "option_key", ")", ":", "with", "salt", ".", "utils", ".", "files", ".", "fopen", "(", "path", ",", "'r'", ")", "as", "template_f", ":", "template", "=", "deserialize", "(", "template_f", ")", "info", "=", "(",...
Get the contents of a template file and provide it as a module type :param path: path to the template.yml file :type path: ``str`` :param option_key: The unique key of this template :type option_key: ``str`` :returns: Details about the template :rtype: ``tuple``
[ "Get", "the", "contents", "of", "a", "template", "file", "and", "provide", "it", "as", "a", "module", "type" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/extend.py#L45-L61
train
saltstack/salt
salt/utils/extend.py
_fetch_templates
def _fetch_templates(src): ''' Fetch all of the templates in the src directory :param src: The source path :type src: ``str`` :rtype: ``list`` of ``tuple`` :returns: ``list`` of ('key', 'description') ''' templates = [] log.debug('Listing contents of %s', src) for item in os.listdir(src): s = os.path.join(src, item) if os.path.isdir(s): template_path = os.path.join(s, TEMPLATE_FILE_NAME) if os.path.isfile(template_path): templates.append(_get_template(template_path, item)) else: log.debug("Directory does not contain %s %s", template_path, TEMPLATE_FILE_NAME) return templates
python
def _fetch_templates(src): ''' Fetch all of the templates in the src directory :param src: The source path :type src: ``str`` :rtype: ``list`` of ``tuple`` :returns: ``list`` of ('key', 'description') ''' templates = [] log.debug('Listing contents of %s', src) for item in os.listdir(src): s = os.path.join(src, item) if os.path.isdir(s): template_path = os.path.join(s, TEMPLATE_FILE_NAME) if os.path.isfile(template_path): templates.append(_get_template(template_path, item)) else: log.debug("Directory does not contain %s %s", template_path, TEMPLATE_FILE_NAME) return templates
[ "def", "_fetch_templates", "(", "src", ")", ":", "templates", "=", "[", "]", "log", ".", "debug", "(", "'Listing contents of %s'", ",", "src", ")", "for", "item", "in", "os", ".", "listdir", "(", "src", ")", ":", "s", "=", "os", ".", "path", ".", "...
Fetch all of the templates in the src directory :param src: The source path :type src: ``str`` :rtype: ``list`` of ``tuple`` :returns: ``list`` of ('key', 'description')
[ "Fetch", "all", "of", "the", "templates", "in", "the", "src", "directory" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/extend.py#L64-L85
train
saltstack/salt
salt/utils/extend.py
_mergetree
def _mergetree(src, dst): ''' Akin to shutils.copytree but over existing directories, does a recursive merge copy. :param src: The source path :type src: ``str`` :param dst: The destination path :type dst: ``str`` ''' for item in os.listdir(src): s = os.path.join(src, item) d = os.path.join(dst, item) if os.path.isdir(s): log.info("Copying folder %s to %s", s, d) if os.path.exists(d): _mergetree(s, d) else: shutil.copytree(s, d) else: log.info("Copying file %s to %s", s, d) shutil.copy2(s, d)
python
def _mergetree(src, dst): ''' Akin to shutils.copytree but over existing directories, does a recursive merge copy. :param src: The source path :type src: ``str`` :param dst: The destination path :type dst: ``str`` ''' for item in os.listdir(src): s = os.path.join(src, item) d = os.path.join(dst, item) if os.path.isdir(s): log.info("Copying folder %s to %s", s, d) if os.path.exists(d): _mergetree(s, d) else: shutil.copytree(s, d) else: log.info("Copying file %s to %s", s, d) shutil.copy2(s, d)
[ "def", "_mergetree", "(", "src", ",", "dst", ")", ":", "for", "item", "in", "os", ".", "listdir", "(", "src", ")", ":", "s", "=", "os", ".", "path", ".", "join", "(", "src", ",", "item", ")", "d", "=", "os", ".", "path", ".", "join", "(", "...
Akin to shutils.copytree but over existing directories, does a recursive merge copy. :param src: The source path :type src: ``str`` :param dst: The destination path :type dst: ``str``
[ "Akin", "to", "shutils", ".", "copytree", "but", "over", "existing", "directories", "does", "a", "recursive", "merge", "copy", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/extend.py#L88-L109
train
saltstack/salt
salt/utils/extend.py
_mergetreejinja
def _mergetreejinja(src, dst, context): ''' Merge directory A to directory B, apply Jinja2 templating to both the file/folder names AND to the contents of the files :param src: The source path :type src: ``str`` :param dst: The destination path :type dst: ``str`` :param context: The dictionary to inject into the Jinja template as context :type context: ``dict`` ''' for item in os.listdir(src): s = os.path.join(src, item) d = os.path.join(dst, item) if os.path.isdir(s): log.info("Copying folder %s to %s", s, d) if os.path.exists(d): _mergetreejinja(s, d, context) else: os.mkdir(d) _mergetreejinja(s, d, context) else: if item != TEMPLATE_FILE_NAME: d = Template(d).render(context) log.info("Copying file %s to %s", s, d) with salt.utils.files.fopen(s, 'r') as source_file: src_contents = salt.utils.stringutils.to_unicode(source_file.read()) dest_contents = Template(src_contents).render(context) with salt.utils.files.fopen(d, 'w') as dest_file: dest_file.write(salt.utils.stringutils.to_str(dest_contents))
python
def _mergetreejinja(src, dst, context): ''' Merge directory A to directory B, apply Jinja2 templating to both the file/folder names AND to the contents of the files :param src: The source path :type src: ``str`` :param dst: The destination path :type dst: ``str`` :param context: The dictionary to inject into the Jinja template as context :type context: ``dict`` ''' for item in os.listdir(src): s = os.path.join(src, item) d = os.path.join(dst, item) if os.path.isdir(s): log.info("Copying folder %s to %s", s, d) if os.path.exists(d): _mergetreejinja(s, d, context) else: os.mkdir(d) _mergetreejinja(s, d, context) else: if item != TEMPLATE_FILE_NAME: d = Template(d).render(context) log.info("Copying file %s to %s", s, d) with salt.utils.files.fopen(s, 'r') as source_file: src_contents = salt.utils.stringutils.to_unicode(source_file.read()) dest_contents = Template(src_contents).render(context) with salt.utils.files.fopen(d, 'w') as dest_file: dest_file.write(salt.utils.stringutils.to_str(dest_contents))
[ "def", "_mergetreejinja", "(", "src", ",", "dst", ",", "context", ")", ":", "for", "item", "in", "os", ".", "listdir", "(", "src", ")", ":", "s", "=", "os", ".", "path", ".", "join", "(", "src", ",", "item", ")", "d", "=", "os", ".", "path", ...
Merge directory A to directory B, apply Jinja2 templating to both the file/folder names AND to the contents of the files :param src: The source path :type src: ``str`` :param dst: The destination path :type dst: ``str`` :param context: The dictionary to inject into the Jinja template as context :type context: ``dict``
[ "Merge", "directory", "A", "to", "directory", "B", "apply", "Jinja2", "templating", "to", "both", "the", "file", "/", "folder", "names", "AND", "to", "the", "contents", "of", "the", "files" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/extend.py#L112-L144
train
saltstack/salt
salt/utils/extend.py
_prompt_choice
def _prompt_choice(var_name, options): ''' Prompt the user to choose between a list of options, index each one by adding an enumerator based on https://github.com/audreyr/cookiecutter/blob/master/cookiecutter/prompt.py#L51 :param var_name: The question to ask the user :type var_name: ``str`` :param options: A list of options :type options: ``list`` of ``tupple`` :rtype: ``tuple`` :returns: The selected user ''' choice_map = OrderedDict( ('{0}'.format(i), value) for i, value in enumerate(options, 1) if value[0] != 'test' ) choices = choice_map.keys() default = '1' choice_lines = ['{0} - {1} - {2}'.format(c[0], c[1][0], c[1][1]) for c in choice_map.items()] prompt = '\n'.join(( 'Select {0}:'.format(var_name), '\n'.join(choice_lines), 'Choose from {0}'.format(', '.join(choices)) )) user_choice = click.prompt( prompt, type=click.Choice(choices), default=default ) return choice_map[user_choice]
python
def _prompt_choice(var_name, options): ''' Prompt the user to choose between a list of options, index each one by adding an enumerator based on https://github.com/audreyr/cookiecutter/blob/master/cookiecutter/prompt.py#L51 :param var_name: The question to ask the user :type var_name: ``str`` :param options: A list of options :type options: ``list`` of ``tupple`` :rtype: ``tuple`` :returns: The selected user ''' choice_map = OrderedDict( ('{0}'.format(i), value) for i, value in enumerate(options, 1) if value[0] != 'test' ) choices = choice_map.keys() default = '1' choice_lines = ['{0} - {1} - {2}'.format(c[0], c[1][0], c[1][1]) for c in choice_map.items()] prompt = '\n'.join(( 'Select {0}:'.format(var_name), '\n'.join(choice_lines), 'Choose from {0}'.format(', '.join(choices)) )) user_choice = click.prompt( prompt, type=click.Choice(choices), default=default ) return choice_map[user_choice]
[ "def", "_prompt_choice", "(", "var_name", ",", "options", ")", ":", "choice_map", "=", "OrderedDict", "(", "(", "'{0}'", ".", "format", "(", "i", ")", ",", "value", ")", "for", "i", ",", "value", "in", "enumerate", "(", "options", ",", "1", ")", "if"...
Prompt the user to choose between a list of options, index each one by adding an enumerator based on https://github.com/audreyr/cookiecutter/blob/master/cookiecutter/prompt.py#L51 :param var_name: The question to ask the user :type var_name: ``str`` :param options: A list of options :type options: ``list`` of ``tupple`` :rtype: ``tuple`` :returns: The selected user
[ "Prompt", "the", "user", "to", "choose", "between", "a", "list", "of", "options", "index", "each", "one", "by", "adding", "an", "enumerator", "based", "on", "https", ":", "//", "github", ".", "com", "/", "audreyr", "/", "cookiecutter", "/", "blob", "/", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/extend.py#L163-L193
train
saltstack/salt
salt/utils/extend.py
run
def run(extension=None, name=None, description=None, salt_dir=None, merge=False, temp_dir=None): ''' A template factory for extending the salt ecosystem :param extension: The extension type, e.g. 'module', 'state', if omitted, user will be prompted :type extension: ``str`` :param name: Python-friendly name for the module, if omitted, user will be prompted :type name: ``str`` :param description: A description of the extension, if omitted, user will be prompted :type description: ``str`` :param salt_dir: The targeted Salt source directory :type salt_dir: ``str`` :param merge: Merge with salt directory, `False` to keep separate, `True` to merge trees. :type merge: ``bool`` :param temp_dir: The directory for generated code, if omitted, system temp will be used :type temp_dir: ``str`` ''' if not HAS_CLICK: print("click is not installed, please install using pip") sys.exit(1) if salt_dir is None: salt_dir = '.' MODULE_OPTIONS = _fetch_templates(os.path.join(salt_dir, 'templates')) if extension is None: print('Choose which type of extension you are developing for SaltStack') extension_type = 'Extension type' chosen_extension = _prompt_choice(extension_type, MODULE_OPTIONS) else: if extension not in list(zip(*MODULE_OPTIONS))[0]: print("Module extension option not valid") sys.exit(1) chosen_extension = [m for m in MODULE_OPTIONS if m[0] == extension][0] extension_type = chosen_extension[0] extension_context = chosen_extension[2] if name is None: print('Enter the short name for the module (e.g. mymodule)') name = _prompt_user_variable('Module name', '') if description is None: description = _prompt_user_variable('Short description of the module', '') template_dir = 'templates/{0}'.format(extension_type) module_name = name param_dict = { "version": salt.version.SaltStackVersion.next_release().name, "module_name": module_name, "short_description": description, "release_date": date.today().strftime('%Y-%m-%d'), "year": date.today().strftime('%Y'), } # get additional questions from template additional_context = {} for key, val in extension_context.get('questions', {}).items(): # allow templates to be used in default values. default = Template(val.get('default', '')).render(param_dict) prompt_var = _prompt_user_variable(val['question'], default) additional_context[key] = prompt_var context = param_dict.copy() context.update(extension_context) context.update(additional_context) if temp_dir is None: temp_dir = tempfile.mkdtemp() apply_template( template_dir, temp_dir, context) if not merge: path = temp_dir else: _mergetree(temp_dir, salt_dir) path = salt_dir log.info('New module stored in %s', path) return path
python
def run(extension=None, name=None, description=None, salt_dir=None, merge=False, temp_dir=None): ''' A template factory for extending the salt ecosystem :param extension: The extension type, e.g. 'module', 'state', if omitted, user will be prompted :type extension: ``str`` :param name: Python-friendly name for the module, if omitted, user will be prompted :type name: ``str`` :param description: A description of the extension, if omitted, user will be prompted :type description: ``str`` :param salt_dir: The targeted Salt source directory :type salt_dir: ``str`` :param merge: Merge with salt directory, `False` to keep separate, `True` to merge trees. :type merge: ``bool`` :param temp_dir: The directory for generated code, if omitted, system temp will be used :type temp_dir: ``str`` ''' if not HAS_CLICK: print("click is not installed, please install using pip") sys.exit(1) if salt_dir is None: salt_dir = '.' MODULE_OPTIONS = _fetch_templates(os.path.join(salt_dir, 'templates')) if extension is None: print('Choose which type of extension you are developing for SaltStack') extension_type = 'Extension type' chosen_extension = _prompt_choice(extension_type, MODULE_OPTIONS) else: if extension not in list(zip(*MODULE_OPTIONS))[0]: print("Module extension option not valid") sys.exit(1) chosen_extension = [m for m in MODULE_OPTIONS if m[0] == extension][0] extension_type = chosen_extension[0] extension_context = chosen_extension[2] if name is None: print('Enter the short name for the module (e.g. mymodule)') name = _prompt_user_variable('Module name', '') if description is None: description = _prompt_user_variable('Short description of the module', '') template_dir = 'templates/{0}'.format(extension_type) module_name = name param_dict = { "version": salt.version.SaltStackVersion.next_release().name, "module_name": module_name, "short_description": description, "release_date": date.today().strftime('%Y-%m-%d'), "year": date.today().strftime('%Y'), } # get additional questions from template additional_context = {} for key, val in extension_context.get('questions', {}).items(): # allow templates to be used in default values. default = Template(val.get('default', '')).render(param_dict) prompt_var = _prompt_user_variable(val['question'], default) additional_context[key] = prompt_var context = param_dict.copy() context.update(extension_context) context.update(additional_context) if temp_dir is None: temp_dir = tempfile.mkdtemp() apply_template( template_dir, temp_dir, context) if not merge: path = temp_dir else: _mergetree(temp_dir, salt_dir) path = salt_dir log.info('New module stored in %s', path) return path
[ "def", "run", "(", "extension", "=", "None", ",", "name", "=", "None", ",", "description", "=", "None", ",", "salt_dir", "=", "None", ",", "merge", "=", "False", ",", "temp_dir", "=", "None", ")", ":", "if", "not", "HAS_CLICK", ":", "print", "(", "...
A template factory for extending the salt ecosystem :param extension: The extension type, e.g. 'module', 'state', if omitted, user will be prompted :type extension: ``str`` :param name: Python-friendly name for the module, if omitted, user will be prompted :type name: ``str`` :param description: A description of the extension, if omitted, user will be prompted :type description: ``str`` :param salt_dir: The targeted Salt source directory :type salt_dir: ``str`` :param merge: Merge with salt directory, `False` to keep separate, `True` to merge trees. :type merge: ``bool`` :param temp_dir: The directory for generated code, if omitted, system temp will be used :type temp_dir: ``str``
[ "A", "template", "factory", "for", "extending", "the", "salt", "ecosystem" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/extend.py#L213-L304
train
saltstack/salt
salt/states/win_snmp.py
agent_settings
def agent_settings(name, contact, location, services=None): ''' Manage the SNMP sysContact, sysLocation, and sysServices settings. :param str contact: The SNMP contact. :param str location: The SNMP location. :param str services: A list of selected services. Example of usage: .. code-block:: yaml snmp-agent-settings: win_snmp.agent_settings: - contact: Test Contact - location: Test Location - services: - Physical - Internet ''' ret = {'name': name, 'changes': {}, 'comment': six.text_type(), 'result': None} ret_settings = {'changes': dict(), 'failures': dict()} if not services: services = ['None'] # Filter services for unique items, and sort them for comparison purposes. services = sorted(set(services)) settings = {'contact': contact, 'location': location, 'services': services} current_settings = __salt__['win_snmp.get_agent_settings']() for setting in settings: if six.text_type(settings[setting]) != six.text_type(current_settings[setting]): ret_settings['changes'][setting] = {'old': current_settings[setting], 'new': settings[setting]} if not ret_settings['changes']: ret['comment'] = 'Agent settings already contain the provided values.' ret['result'] = True return ret elif __opts__['test']: ret['comment'] = 'Agent settings will be changed.' ret['changes'] = ret_settings return ret __salt__['win_snmp.set_agent_settings'](**settings) new_settings = __salt__['win_snmp.get_agent_settings']() for setting in settings: if settings[setting] != new_settings[setting]: ret_settings['failures'][setting] = {'old': current_settings[setting], 'new': new_settings[setting]} ret_settings['changes'].pop(setting, None) if ret_settings['failures']: ret['comment'] = 'Some agent settings failed to change.' ret['changes'] = ret_settings ret['result'] = False else: ret['comment'] = 'Set agent settings to contain the provided values.' ret['changes'] = ret_settings['changes'] ret['result'] = True return ret
python
def agent_settings(name, contact, location, services=None): ''' Manage the SNMP sysContact, sysLocation, and sysServices settings. :param str contact: The SNMP contact. :param str location: The SNMP location. :param str services: A list of selected services. Example of usage: .. code-block:: yaml snmp-agent-settings: win_snmp.agent_settings: - contact: Test Contact - location: Test Location - services: - Physical - Internet ''' ret = {'name': name, 'changes': {}, 'comment': six.text_type(), 'result': None} ret_settings = {'changes': dict(), 'failures': dict()} if not services: services = ['None'] # Filter services for unique items, and sort them for comparison purposes. services = sorted(set(services)) settings = {'contact': contact, 'location': location, 'services': services} current_settings = __salt__['win_snmp.get_agent_settings']() for setting in settings: if six.text_type(settings[setting]) != six.text_type(current_settings[setting]): ret_settings['changes'][setting] = {'old': current_settings[setting], 'new': settings[setting]} if not ret_settings['changes']: ret['comment'] = 'Agent settings already contain the provided values.' ret['result'] = True return ret elif __opts__['test']: ret['comment'] = 'Agent settings will be changed.' ret['changes'] = ret_settings return ret __salt__['win_snmp.set_agent_settings'](**settings) new_settings = __salt__['win_snmp.get_agent_settings']() for setting in settings: if settings[setting] != new_settings[setting]: ret_settings['failures'][setting] = {'old': current_settings[setting], 'new': new_settings[setting]} ret_settings['changes'].pop(setting, None) if ret_settings['failures']: ret['comment'] = 'Some agent settings failed to change.' ret['changes'] = ret_settings ret['result'] = False else: ret['comment'] = 'Set agent settings to contain the provided values.' ret['changes'] = ret_settings['changes'] ret['result'] = True return ret
[ "def", "agent_settings", "(", "name", ",", "contact", ",", "location", ",", "services", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'comment'", ":", "six", ".", "text_type", "(", ")", ",", "...
Manage the SNMP sysContact, sysLocation, and sysServices settings. :param str contact: The SNMP contact. :param str location: The SNMP location. :param str services: A list of selected services. Example of usage: .. code-block:: yaml snmp-agent-settings: win_snmp.agent_settings: - contact: Test Contact - location: Test Location - services: - Physical - Internet
[ "Manage", "the", "SNMP", "sysContact", "sysLocation", "and", "sysServices", "settings", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_snmp.py#L24-L92
train
saltstack/salt
salt/states/win_snmp.py
auth_traps_enabled
def auth_traps_enabled(name, status=True): ''' Manage the sending of authentication traps. :param bool status: The enabled status. Example of usage: .. code-block:: yaml snmp-auth-traps: win_snmp.auth_traps_enabled: - status: True ''' ret = {'name': name, 'changes': {}, 'comment': six.text_type(), 'result': None} vname = 'EnableAuthenticationTraps' current_status = __salt__['win_snmp.get_auth_traps_enabled']() if status == current_status: ret['comment'] = '{0} already contains the provided value.'.format(vname) ret['result'] = True elif __opts__['test']: ret['comment'] = '{0} will be changed.'.format(vname) ret['changes'] = {'old': current_status, 'new': status} else: ret['comment'] = 'Set {0} to contain the provided value.'.format(vname) ret['changes'] = {'old': current_status, 'new': status} ret['result'] = __salt__['win_snmp.set_auth_traps_enabled'](status=status) return ret
python
def auth_traps_enabled(name, status=True): ''' Manage the sending of authentication traps. :param bool status: The enabled status. Example of usage: .. code-block:: yaml snmp-auth-traps: win_snmp.auth_traps_enabled: - status: True ''' ret = {'name': name, 'changes': {}, 'comment': six.text_type(), 'result': None} vname = 'EnableAuthenticationTraps' current_status = __salt__['win_snmp.get_auth_traps_enabled']() if status == current_status: ret['comment'] = '{0} already contains the provided value.'.format(vname) ret['result'] = True elif __opts__['test']: ret['comment'] = '{0} will be changed.'.format(vname) ret['changes'] = {'old': current_status, 'new': status} else: ret['comment'] = 'Set {0} to contain the provided value.'.format(vname) ret['changes'] = {'old': current_status, 'new': status} ret['result'] = __salt__['win_snmp.set_auth_traps_enabled'](status=status) return ret
[ "def", "auth_traps_enabled", "(", "name", ",", "status", "=", "True", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'comment'", ":", "six", ".", "text_type", "(", ")", ",", "'result'", ":", "None", "}", "v...
Manage the sending of authentication traps. :param bool status: The enabled status. Example of usage: .. code-block:: yaml snmp-auth-traps: win_snmp.auth_traps_enabled: - status: True
[ "Manage", "the", "sending", "of", "authentication", "traps", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_snmp.py#L95-L130
train
saltstack/salt
salt/states/win_snmp.py
community_names
def community_names(name, communities=None): ''' Manage the SNMP accepted community names and their permissions. :param str communities: A dictionary of SNMP communities and permissions. Example of usage: .. code-block:: yaml snmp-community-names: win_snmp.community_names: - communities: TestCommunity: Read Only OtherCommunity: Read Write ''' ret = {'name': name, 'changes': dict(), 'comment': six.text_type(), 'result': None} ret_communities = {'changes': dict(), 'failures': dict()} if not communities: communities = dict() current_communities = __salt__['win_snmp.get_community_names']() # Note any existing communities that should be removed. for current_vname in current_communities: if current_vname not in communities: ret_communities['changes'][current_vname] = {'old': current_communities[current_vname], 'new': None} # Note any new communities or existing communities that should be changed. for vname in communities: current_vdata = None if vname in current_communities: current_vdata = current_communities[vname] if communities[vname] != current_vdata: ret_communities['changes'][vname] = {'old': current_vdata, 'new': communities[vname]} if not ret_communities['changes']: ret['comment'] = 'Communities already contain the provided values.' ret['result'] = True return ret elif __opts__['test']: ret['comment'] = 'Communities will be changed.' ret['changes'] = ret_communities return ret __salt__['win_snmp.set_community_names'](communities=communities) new_communities = __salt__['win_snmp.get_community_names']() # Verify that any communities that needed to be removed were removed. for new_vname in new_communities: if new_vname not in communities: ret_communities['failures'][new_vname] = {'old': current_communities[new_vname], 'new': new_communities[new_vname]} ret_communities['changes'].pop(new_vname, None) # Verify that any new communities or existing communities that # needed to be changed were changed. for vname in communities: new_vdata = None if vname in new_communities: new_vdata = new_communities[vname] if communities[vname] != new_vdata: ret_communities['failures'][vname] = {'old': current_communities[vname], 'new': new_vdata} ret_communities['changes'].pop(vname, None) if ret_communities['failures']: ret['comment'] = 'Some communities failed to change.' ret['changes'] = ret_communities ret['result'] = False else: ret['comment'] = 'Set communities to contain the provided values.' ret['changes'] = ret_communities['changes'] ret['result'] = True return ret
python
def community_names(name, communities=None): ''' Manage the SNMP accepted community names and their permissions. :param str communities: A dictionary of SNMP communities and permissions. Example of usage: .. code-block:: yaml snmp-community-names: win_snmp.community_names: - communities: TestCommunity: Read Only OtherCommunity: Read Write ''' ret = {'name': name, 'changes': dict(), 'comment': six.text_type(), 'result': None} ret_communities = {'changes': dict(), 'failures': dict()} if not communities: communities = dict() current_communities = __salt__['win_snmp.get_community_names']() # Note any existing communities that should be removed. for current_vname in current_communities: if current_vname not in communities: ret_communities['changes'][current_vname] = {'old': current_communities[current_vname], 'new': None} # Note any new communities or existing communities that should be changed. for vname in communities: current_vdata = None if vname in current_communities: current_vdata = current_communities[vname] if communities[vname] != current_vdata: ret_communities['changes'][vname] = {'old': current_vdata, 'new': communities[vname]} if not ret_communities['changes']: ret['comment'] = 'Communities already contain the provided values.' ret['result'] = True return ret elif __opts__['test']: ret['comment'] = 'Communities will be changed.' ret['changes'] = ret_communities return ret __salt__['win_snmp.set_community_names'](communities=communities) new_communities = __salt__['win_snmp.get_community_names']() # Verify that any communities that needed to be removed were removed. for new_vname in new_communities: if new_vname not in communities: ret_communities['failures'][new_vname] = {'old': current_communities[new_vname], 'new': new_communities[new_vname]} ret_communities['changes'].pop(new_vname, None) # Verify that any new communities or existing communities that # needed to be changed were changed. for vname in communities: new_vdata = None if vname in new_communities: new_vdata = new_communities[vname] if communities[vname] != new_vdata: ret_communities['failures'][vname] = {'old': current_communities[vname], 'new': new_vdata} ret_communities['changes'].pop(vname, None) if ret_communities['failures']: ret['comment'] = 'Some communities failed to change.' ret['changes'] = ret_communities ret['result'] = False else: ret['comment'] = 'Set communities to contain the provided values.' ret['changes'] = ret_communities['changes'] ret['result'] = True return ret
[ "def", "community_names", "(", "name", ",", "communities", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "dict", "(", ")", ",", "'comment'", ":", "six", ".", "text_type", "(", ")", ",", "'result'", ":", "None",...
Manage the SNMP accepted community names and their permissions. :param str communities: A dictionary of SNMP communities and permissions. Example of usage: .. code-block:: yaml snmp-community-names: win_snmp.community_names: - communities: TestCommunity: Read Only OtherCommunity: Read Write
[ "Manage", "the", "SNMP", "accepted", "community", "names", "and", "their", "permissions", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_snmp.py#L133-L215
train
saltstack/salt
salt/modules/npm.py
_check_valid_version
def _check_valid_version(): ''' Check the version of npm to ensure this module will work. Currently npm must be at least version 1.2. ''' # Locate the full path to npm npm_path = salt.utils.path.which('npm') # pylint: disable=no-member res = salt.modules.cmdmod.run('{npm} --version'.format(npm=npm_path), output_loglevel='quiet') npm_version, valid_version = _LooseVersion(res), _LooseVersion('1.2') # pylint: enable=no-member if npm_version < valid_version: raise CommandExecutionError( '\'npm\' is not recent enough({0} < {1}). Please Upgrade.'.format( npm_version, valid_version ) )
python
def _check_valid_version(): ''' Check the version of npm to ensure this module will work. Currently npm must be at least version 1.2. ''' # Locate the full path to npm npm_path = salt.utils.path.which('npm') # pylint: disable=no-member res = salt.modules.cmdmod.run('{npm} --version'.format(npm=npm_path), output_loglevel='quiet') npm_version, valid_version = _LooseVersion(res), _LooseVersion('1.2') # pylint: enable=no-member if npm_version < valid_version: raise CommandExecutionError( '\'npm\' is not recent enough({0} < {1}). Please Upgrade.'.format( npm_version, valid_version ) )
[ "def", "_check_valid_version", "(", ")", ":", "# Locate the full path to npm", "npm_path", "=", "salt", ".", "utils", ".", "path", ".", "which", "(", "'npm'", ")", "# pylint: disable=no-member", "res", "=", "salt", ".", "modules", ".", "cmdmod", ".", "run", "(...
Check the version of npm to ensure this module will work. Currently npm must be at least version 1.2.
[ "Check", "the", "version", "of", "npm", "to", "ensure", "this", "module", "will", "work", ".", "Currently", "npm", "must", "be", "at", "least", "version", "1", ".", "2", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/npm.py#L47-L65
train
saltstack/salt
salt/modules/npm.py
install
def install(pkg=None, pkgs=None, dir=None, runas=None, registry=None, env=None, dry_run=False, silent=True): ''' Install an NPM package. If no directory is specified, the package will be installed globally. If no package is specified, the dependencies (from package.json) of the package in the given directory will be installed. pkg A package name in any format accepted by NPM, including a version identifier pkgs A list of package names in the same format as the ``name`` parameter .. versionadded:: 2014.7.0 dir The target directory in which to install the package, or None for global installation runas The user to run NPM with registry The NPM registry to install the package from. .. versionadded:: 2014.7.0 env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. .. versionadded:: 2014.7.0 silent Whether or not to run NPM install with --silent flag. .. versionadded:: 2016.3.0 dry_run Whether or not to run NPM install with --dry-run flag. .. versionadded:: 2015.8.4 silent Whether or not to run NPM install with --silent flag. .. versionadded:: 2015.8.5 CLI Example: .. code-block:: bash salt '*' npm.install coffee-script salt '*' npm.install coffee-script@1.0.1 ''' # Protect against injection if pkg: pkgs = [_cmd_quote(pkg)] elif pkgs: pkgs = [_cmd_quote(v) for v in pkgs] else: pkgs = [] if registry: registry = _cmd_quote(registry) cmd = ['npm', 'install', '--json'] if silent: cmd.append('--silent') if not dir: cmd.append('--global') if registry: cmd.append('--registry="{0}"'.format(registry)) if dry_run: cmd.append('--dry-run') cmd.extend(pkgs) env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ' '.join(cmd) result = __salt__['cmd.run_all'](cmd, python_shell=True, cwd=dir, runas=runas, env=env) if result['retcode'] != 0: raise CommandExecutionError(result['stderr']) # npm >1.2.21 is putting the output to stderr even though retcode is 0 npm_output = result['stdout'] or result['stderr'] try: return salt.utils.json.find_json(npm_output) except ValueError: return npm_output
python
def install(pkg=None, pkgs=None, dir=None, runas=None, registry=None, env=None, dry_run=False, silent=True): ''' Install an NPM package. If no directory is specified, the package will be installed globally. If no package is specified, the dependencies (from package.json) of the package in the given directory will be installed. pkg A package name in any format accepted by NPM, including a version identifier pkgs A list of package names in the same format as the ``name`` parameter .. versionadded:: 2014.7.0 dir The target directory in which to install the package, or None for global installation runas The user to run NPM with registry The NPM registry to install the package from. .. versionadded:: 2014.7.0 env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. .. versionadded:: 2014.7.0 silent Whether or not to run NPM install with --silent flag. .. versionadded:: 2016.3.0 dry_run Whether or not to run NPM install with --dry-run flag. .. versionadded:: 2015.8.4 silent Whether or not to run NPM install with --silent flag. .. versionadded:: 2015.8.5 CLI Example: .. code-block:: bash salt '*' npm.install coffee-script salt '*' npm.install coffee-script@1.0.1 ''' # Protect against injection if pkg: pkgs = [_cmd_quote(pkg)] elif pkgs: pkgs = [_cmd_quote(v) for v in pkgs] else: pkgs = [] if registry: registry = _cmd_quote(registry) cmd = ['npm', 'install', '--json'] if silent: cmd.append('--silent') if not dir: cmd.append('--global') if registry: cmd.append('--registry="{0}"'.format(registry)) if dry_run: cmd.append('--dry-run') cmd.extend(pkgs) env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ' '.join(cmd) result = __salt__['cmd.run_all'](cmd, python_shell=True, cwd=dir, runas=runas, env=env) if result['retcode'] != 0: raise CommandExecutionError(result['stderr']) # npm >1.2.21 is putting the output to stderr even though retcode is 0 npm_output = result['stdout'] or result['stderr'] try: return salt.utils.json.find_json(npm_output) except ValueError: return npm_output
[ "def", "install", "(", "pkg", "=", "None", ",", "pkgs", "=", "None", ",", "dir", "=", "None", ",", "runas", "=", "None", ",", "registry", "=", "None", ",", "env", "=", "None", ",", "dry_run", "=", "False", ",", "silent", "=", "True", ")", ":", ...
Install an NPM package. If no directory is specified, the package will be installed globally. If no package is specified, the dependencies (from package.json) of the package in the given directory will be installed. pkg A package name in any format accepted by NPM, including a version identifier pkgs A list of package names in the same format as the ``name`` parameter .. versionadded:: 2014.7.0 dir The target directory in which to install the package, or None for global installation runas The user to run NPM with registry The NPM registry to install the package from. .. versionadded:: 2014.7.0 env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. .. versionadded:: 2014.7.0 silent Whether or not to run NPM install with --silent flag. .. versionadded:: 2016.3.0 dry_run Whether or not to run NPM install with --dry-run flag. .. versionadded:: 2015.8.4 silent Whether or not to run NPM install with --silent flag. .. versionadded:: 2015.8.5 CLI Example: .. code-block:: bash salt '*' npm.install coffee-script salt '*' npm.install coffee-script@1.0.1
[ "Install", "an", "NPM", "package", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/npm.py#L68-L182
train
saltstack/salt
salt/modules/npm.py
uninstall
def uninstall(pkg, dir=None, runas=None, env=None): ''' Uninstall an NPM package. If no directory is specified, the package will be uninstalled globally. pkg A package name in any format accepted by NPM dir The target directory from which to uninstall the package, or None for global installation runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. .. versionadded:: 2015.5.3 CLI Example: .. code-block:: bash salt '*' npm.uninstall coffee-script ''' # Protect against injection if pkg: pkg = _cmd_quote(pkg) env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'uninstall', '"{0}"'.format(pkg)] if not dir: cmd.append('--global') cmd = ' '.join(cmd) result = __salt__['cmd.run_all'](cmd, python_shell=True, cwd=dir, runas=runas, env=env) if result['retcode'] != 0: log.error(result['stderr']) return False return True
python
def uninstall(pkg, dir=None, runas=None, env=None): ''' Uninstall an NPM package. If no directory is specified, the package will be uninstalled globally. pkg A package name in any format accepted by NPM dir The target directory from which to uninstall the package, or None for global installation runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. .. versionadded:: 2015.5.3 CLI Example: .. code-block:: bash salt '*' npm.uninstall coffee-script ''' # Protect against injection if pkg: pkg = _cmd_quote(pkg) env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'uninstall', '"{0}"'.format(pkg)] if not dir: cmd.append('--global') cmd = ' '.join(cmd) result = __salt__['cmd.run_all'](cmd, python_shell=True, cwd=dir, runas=runas, env=env) if result['retcode'] != 0: log.error(result['stderr']) return False return True
[ "def", "uninstall", "(", "pkg", ",", "dir", "=", "None", ",", "runas", "=", "None", ",", "env", "=", "None", ")", ":", "# Protect against injection", "if", "pkg", ":", "pkg", "=", "_cmd_quote", "(", "pkg", ")", "env", "=", "env", "or", "{", "}", "i...
Uninstall an NPM package. If no directory is specified, the package will be uninstalled globally. pkg A package name in any format accepted by NPM dir The target directory from which to uninstall the package, or None for global installation runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. .. versionadded:: 2015.5.3 CLI Example: .. code-block:: bash salt '*' npm.uninstall coffee-script
[ "Uninstall", "an", "NPM", "package", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/npm.py#L185-L237
train
saltstack/salt
salt/modules/npm.py
list_
def list_(pkg=None, dir=None, runas=None, env=None, depth=None): ''' List installed NPM packages. If no directory is specified, this will return the list of globally- installed packages. pkg Limit package listing by name dir The directory whose packages will be listed, or None for global installation runas The user to run NPM with .. versionadded:: 2014.7.0 env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. .. versionadded:: 2014.7.0 depth Limit the depth of the packages listed .. versionadded:: 2016.11.6,2017.7.0 CLI Example: .. code-block:: bash salt '*' npm.list ''' env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'list', '--json', '--silent'] if not dir: cmd.append('--global') if depth is not None: if not isinstance(depth, (int, float)): raise salt.exceptions.SaltInvocationError('Error: depth {0} must be a number'.format(depth)) cmd.append('--depth={0}'.format(int(depth))) if pkg: # Protect against injection pkg = _cmd_quote(pkg) cmd.append('"{0}"'.format(pkg)) cmd = ' '.join(cmd) result = __salt__['cmd.run_all']( cmd, cwd=dir, runas=runas, env=env, python_shell=True, ignore_retcode=True) # npm will return error code 1 for both no packages found and an actual # error. The only difference between the two cases are if stderr is empty if result['retcode'] != 0 and result['stderr']: raise CommandExecutionError(result['stderr']) return salt.utils.json.loads(result['stdout']).get('dependencies', {})
python
def list_(pkg=None, dir=None, runas=None, env=None, depth=None): ''' List installed NPM packages. If no directory is specified, this will return the list of globally- installed packages. pkg Limit package listing by name dir The directory whose packages will be listed, or None for global installation runas The user to run NPM with .. versionadded:: 2014.7.0 env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. .. versionadded:: 2014.7.0 depth Limit the depth of the packages listed .. versionadded:: 2016.11.6,2017.7.0 CLI Example: .. code-block:: bash salt '*' npm.list ''' env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'list', '--json', '--silent'] if not dir: cmd.append('--global') if depth is not None: if not isinstance(depth, (int, float)): raise salt.exceptions.SaltInvocationError('Error: depth {0} must be a number'.format(depth)) cmd.append('--depth={0}'.format(int(depth))) if pkg: # Protect against injection pkg = _cmd_quote(pkg) cmd.append('"{0}"'.format(pkg)) cmd = ' '.join(cmd) result = __salt__['cmd.run_all']( cmd, cwd=dir, runas=runas, env=env, python_shell=True, ignore_retcode=True) # npm will return error code 1 for both no packages found and an actual # error. The only difference between the two cases are if stderr is empty if result['retcode'] != 0 and result['stderr']: raise CommandExecutionError(result['stderr']) return salt.utils.json.loads(result['stdout']).get('dependencies', {})
[ "def", "list_", "(", "pkg", "=", "None", ",", "dir", "=", "None", ",", "runas", "=", "None", ",", "env", "=", "None", ",", "depth", "=", "None", ")", ":", "env", "=", "env", "or", "{", "}", "if", "runas", ":", "uid", "=", "salt", ".", "utils"...
List installed NPM packages. If no directory is specified, this will return the list of globally- installed packages. pkg Limit package listing by name dir The directory whose packages will be listed, or None for global installation runas The user to run NPM with .. versionadded:: 2014.7.0 env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. .. versionadded:: 2014.7.0 depth Limit the depth of the packages listed .. versionadded:: 2016.11.6,2017.7.0 CLI Example: .. code-block:: bash salt '*' npm.list
[ "List", "installed", "NPM", "packages", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/npm.py#L240-L309
train
saltstack/salt
salt/modules/npm.py
cache_clean
def cache_clean(path=None, runas=None, env=None, force=False): ''' Clean cached NPM packages. If no path for a specific package is provided the entire cache will be cleared. path The cache subpath to delete, or None to clear the entire cache runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. force Force cleaning of cache. Required for npm@5 and greater .. versionadded:: 2016.11.6 CLI Example: .. code-block:: bash salt '*' npm.cache_clean force=True ''' env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'cache', 'clean'] if path: cmd.append(path) if force is True: cmd.append('--force') cmd = ' '.join(cmd) result = __salt__['cmd.run_all']( cmd, cwd=None, runas=runas, env=env, python_shell=True, ignore_retcode=True) if result['retcode'] != 0: log.error(result['stderr']) return False return True
python
def cache_clean(path=None, runas=None, env=None, force=False): ''' Clean cached NPM packages. If no path for a specific package is provided the entire cache will be cleared. path The cache subpath to delete, or None to clear the entire cache runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. force Force cleaning of cache. Required for npm@5 and greater .. versionadded:: 2016.11.6 CLI Example: .. code-block:: bash salt '*' npm.cache_clean force=True ''' env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'cache', 'clean'] if path: cmd.append(path) if force is True: cmd.append('--force') cmd = ' '.join(cmd) result = __salt__['cmd.run_all']( cmd, cwd=None, runas=runas, env=env, python_shell=True, ignore_retcode=True) if result['retcode'] != 0: log.error(result['stderr']) return False return True
[ "def", "cache_clean", "(", "path", "=", "None", ",", "runas", "=", "None", ",", "env", "=", "None", ",", "force", "=", "False", ")", ":", "env", "=", "env", "or", "{", "}", "if", "runas", ":", "uid", "=", "salt", ".", "utils", ".", "user", ".",...
Clean cached NPM packages. If no path for a specific package is provided the entire cache will be cleared. path The cache subpath to delete, or None to clear the entire cache runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. force Force cleaning of cache. Required for npm@5 and greater .. versionadded:: 2016.11.6 CLI Example: .. code-block:: bash salt '*' npm.cache_clean force=True
[ "Clean", "cached", "NPM", "packages", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/npm.py#L312-L361
train
saltstack/salt
salt/modules/npm.py
cache_list
def cache_list(path=None, runas=None, env=None): ''' List NPM cached packages. If no path for a specific package is provided this will list all the cached packages. path The cache subpath to list, or None to list the entire cache runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. CLI Example: .. code-block:: bash salt '*' npm.cache_clean ''' env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'cache', 'ls'] if path: cmd.append(path) cmd = ' '.join(cmd) result = __salt__['cmd.run_all']( cmd, cwd=None, runas=runas, env=env, python_shell=True, ignore_retcode=True) if result['retcode'] != 0 and result['stderr']: raise CommandExecutionError(result['stderr']) return result['stdout']
python
def cache_list(path=None, runas=None, env=None): ''' List NPM cached packages. If no path for a specific package is provided this will list all the cached packages. path The cache subpath to list, or None to list the entire cache runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. CLI Example: .. code-block:: bash salt '*' npm.cache_clean ''' env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = ['npm', 'cache', 'ls'] if path: cmd.append(path) cmd = ' '.join(cmd) result = __salt__['cmd.run_all']( cmd, cwd=None, runas=runas, env=env, python_shell=True, ignore_retcode=True) if result['retcode'] != 0 and result['stderr']: raise CommandExecutionError(result['stderr']) return result['stdout']
[ "def", "cache_list", "(", "path", "=", "None", ",", "runas", "=", "None", ",", "env", "=", "None", ")", ":", "env", "=", "env", "or", "{", "}", "if", "runas", ":", "uid", "=", "salt", ".", "utils", ".", "user", ".", "get_uid", "(", "runas", ")"...
List NPM cached packages. If no path for a specific package is provided this will list all the cached packages. path The cache subpath to list, or None to list the entire cache runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. CLI Example: .. code-block:: bash salt '*' npm.cache_clean
[ "List", "NPM", "cached", "packages", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/npm.py#L364-L406
train
saltstack/salt
salt/modules/npm.py
cache_path
def cache_path(runas=None, env=None): ''' List path of the NPM cache directory. runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. CLI Example: .. code-block:: bash salt '*' npm.cache_path ''' env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = 'npm config get cache' result = __salt__['cmd.run_all']( cmd, cwd=None, runas=runas, env=env, python_shell=True, ignore_retcode=True) return result.get('stdout') or result.get('stderr')
python
def cache_path(runas=None, env=None): ''' List path of the NPM cache directory. runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. CLI Example: .. code-block:: bash salt '*' npm.cache_path ''' env = env or {} if runas: uid = salt.utils.user.get_uid(runas) if uid: env.update({'SUDO_UID': uid, 'SUDO_USER': ''}) cmd = 'npm config get cache' result = __salt__['cmd.run_all']( cmd, cwd=None, runas=runas, env=env, python_shell=True, ignore_retcode=True) return result.get('stdout') or result.get('stderr')
[ "def", "cache_path", "(", "runas", "=", "None", ",", "env", "=", "None", ")", ":", "env", "=", "env", "or", "{", "}", "if", "runas", ":", "uid", "=", "salt", ".", "utils", ".", "user", ".", "get_uid", "(", "runas", ")", "if", "uid", ":", "env",...
List path of the NPM cache directory. runas The user to run NPM with env Environment variables to set when invoking npm. Uses the same ``env`` format as the :py:func:`cmd.run <salt.modules.cmdmod.run>` execution function. CLI Example: .. code-block:: bash salt '*' npm.cache_path
[ "List", "path", "of", "the", "NPM", "cache", "directory", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/npm.py#L409-L440
train
saltstack/salt
salt/modules/ipmi.py
raw_command
def raw_command(netfn, command, bridge_request=None, data=(), retry=True, delay_xmit=None, **kwargs): ''' Send raw ipmi command This allows arbitrary IPMI bytes to be issued. This is commonly used for certain vendor specific commands. :param netfn: Net function number :param command: Command value :param bridge_request: The target slave address and channel number for the bridge request. :param data: Command data as a tuple or list :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :returns: dict -- The response from IPMI device CLI Examples: .. code-block:: bash salt-call ipmi.raw_command netfn=0x06 command=0x46 data=[0x02] # this will return the name of the user with id 2 in bytes ''' with _IpmiSession(**kwargs) as s: r = s.raw_command(netfn=int(netfn), command=int(command), bridge_request=bridge_request, data=data, retry=retry, delay_xmit=delay_xmit) return r
python
def raw_command(netfn, command, bridge_request=None, data=(), retry=True, delay_xmit=None, **kwargs): ''' Send raw ipmi command This allows arbitrary IPMI bytes to be issued. This is commonly used for certain vendor specific commands. :param netfn: Net function number :param command: Command value :param bridge_request: The target slave address and channel number for the bridge request. :param data: Command data as a tuple or list :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :returns: dict -- The response from IPMI device CLI Examples: .. code-block:: bash salt-call ipmi.raw_command netfn=0x06 command=0x46 data=[0x02] # this will return the name of the user with id 2 in bytes ''' with _IpmiSession(**kwargs) as s: r = s.raw_command(netfn=int(netfn), command=int(command), bridge_request=bridge_request, data=data, retry=retry, delay_xmit=delay_xmit) return r
[ "def", "raw_command", "(", "netfn", ",", "command", ",", "bridge_request", "=", "None", ",", "data", "=", "(", ")", ",", "retry", "=", "True", ",", "delay_xmit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "with", "_IpmiSession", "(", "*", "*", ...
Send raw ipmi command This allows arbitrary IPMI bytes to be issued. This is commonly used for certain vendor specific commands. :param netfn: Net function number :param command: Command value :param bridge_request: The target slave address and channel number for the bridge request. :param data: Command data as a tuple or list :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :returns: dict -- The response from IPMI device CLI Examples: .. code-block:: bash salt-call ipmi.raw_command netfn=0x06 command=0x46 data=[0x02] # this will return the name of the user with id 2 in bytes
[ "Send", "raw", "ipmi", "command" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L121-L156
train
saltstack/salt
salt/modules/ipmi.py
set_channel_access
def set_channel_access(channel=14, access_update_mode='non_volatile', alerting=False, per_msg_auth=False, user_level_auth=False, access_mode='always', privilege_update_mode='non_volatile', privilege_level='administrator', **kwargs): ''' Set channel access :param channel: number [1:7] :param access_update_mode: - 'dont_change' = don't set or change Channel Access - 'non_volatile' = set non-volatile Channel Access - 'volatile' = set volatile (active) setting of Channel Access :param alerting: PEF Alerting Enable/Disable - True = enable PEF Alerting - False = disable PEF Alerting on this channel (Alert Immediate command can still be used to generate alerts) :param per_msg_auth: Per-message Authentication - True = enable - False = disable Per-message Authentication. [Authentication required to activate any session on this channel, but authentication not used on subsequent packets for the session.] :param user_level_auth: User Level Authentication Enable/Disable - True = enable User Level Authentication. All User Level commands are to be authenticated per the Authentication Type that was negotiated when the session was activated. - False = disable User Level Authentication. Allow User Level commands to be executed without being authenticated. If the option to disable User Level Command authentication is accepted, the BMC will accept packets with Authentication Type set to None if they contain user level commands. For outgoing packets, the BMC returns responses with the same Authentication Type that was used for the request. :param access_mode: Access Mode for IPMI messaging (PEF Alerting is enabled/disabled separately from IPMI messaging) - disabled = disabled for IPMI messaging - pre_boot = pre-boot only channel only available when system is in a powered down state or in BIOS prior to start of boot. - always = channel always available regardless of system mode. BIOS typically dedicates the serial connection to the BMC. - shared = same as always available, but BIOS typically leaves the serial port available for software use. :param privilege_update_mode: Channel Privilege Level Limit. This value sets the maximum privilege level that can be accepted on the specified channel. - dont_change = don't set or change channel Privilege Level Limit - non_volatile = non-volatile Privilege Level Limit according - volatile = volatile setting of Privilege Level Limit :param privilege_level: Channel Privilege Level Limit - reserved = unused - callback - user - operator - administrator - proprietary = used by OEM :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_channel_access privilege_level='administrator' ''' with _IpmiCommand(**kwargs) as s: return s.set_channel_access(channel, access_update_mode, alerting, per_msg_auth, user_level_auth, access_mode, privilege_update_mode, privilege_level)
python
def set_channel_access(channel=14, access_update_mode='non_volatile', alerting=False, per_msg_auth=False, user_level_auth=False, access_mode='always', privilege_update_mode='non_volatile', privilege_level='administrator', **kwargs): ''' Set channel access :param channel: number [1:7] :param access_update_mode: - 'dont_change' = don't set or change Channel Access - 'non_volatile' = set non-volatile Channel Access - 'volatile' = set volatile (active) setting of Channel Access :param alerting: PEF Alerting Enable/Disable - True = enable PEF Alerting - False = disable PEF Alerting on this channel (Alert Immediate command can still be used to generate alerts) :param per_msg_auth: Per-message Authentication - True = enable - False = disable Per-message Authentication. [Authentication required to activate any session on this channel, but authentication not used on subsequent packets for the session.] :param user_level_auth: User Level Authentication Enable/Disable - True = enable User Level Authentication. All User Level commands are to be authenticated per the Authentication Type that was negotiated when the session was activated. - False = disable User Level Authentication. Allow User Level commands to be executed without being authenticated. If the option to disable User Level Command authentication is accepted, the BMC will accept packets with Authentication Type set to None if they contain user level commands. For outgoing packets, the BMC returns responses with the same Authentication Type that was used for the request. :param access_mode: Access Mode for IPMI messaging (PEF Alerting is enabled/disabled separately from IPMI messaging) - disabled = disabled for IPMI messaging - pre_boot = pre-boot only channel only available when system is in a powered down state or in BIOS prior to start of boot. - always = channel always available regardless of system mode. BIOS typically dedicates the serial connection to the BMC. - shared = same as always available, but BIOS typically leaves the serial port available for software use. :param privilege_update_mode: Channel Privilege Level Limit. This value sets the maximum privilege level that can be accepted on the specified channel. - dont_change = don't set or change channel Privilege Level Limit - non_volatile = non-volatile Privilege Level Limit according - volatile = volatile setting of Privilege Level Limit :param privilege_level: Channel Privilege Level Limit - reserved = unused - callback - user - operator - administrator - proprietary = used by OEM :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_channel_access privilege_level='administrator' ''' with _IpmiCommand(**kwargs) as s: return s.set_channel_access(channel, access_update_mode, alerting, per_msg_auth, user_level_auth, access_mode, privilege_update_mode, privilege_level)
[ "def", "set_channel_access", "(", "channel", "=", "14", ",", "access_update_mode", "=", "'non_volatile'", ",", "alerting", "=", "False", ",", "per_msg_auth", "=", "False", ",", "user_level_auth", "=", "False", ",", "access_mode", "=", "'always'", ",", "privilege...
Set channel access :param channel: number [1:7] :param access_update_mode: - 'dont_change' = don't set or change Channel Access - 'non_volatile' = set non-volatile Channel Access - 'volatile' = set volatile (active) setting of Channel Access :param alerting: PEF Alerting Enable/Disable - True = enable PEF Alerting - False = disable PEF Alerting on this channel (Alert Immediate command can still be used to generate alerts) :param per_msg_auth: Per-message Authentication - True = enable - False = disable Per-message Authentication. [Authentication required to activate any session on this channel, but authentication not used on subsequent packets for the session.] :param user_level_auth: User Level Authentication Enable/Disable - True = enable User Level Authentication. All User Level commands are to be authenticated per the Authentication Type that was negotiated when the session was activated. - False = disable User Level Authentication. Allow User Level commands to be executed without being authenticated. If the option to disable User Level Command authentication is accepted, the BMC will accept packets with Authentication Type set to None if they contain user level commands. For outgoing packets, the BMC returns responses with the same Authentication Type that was used for the request. :param access_mode: Access Mode for IPMI messaging (PEF Alerting is enabled/disabled separately from IPMI messaging) - disabled = disabled for IPMI messaging - pre_boot = pre-boot only channel only available when system is in a powered down state or in BIOS prior to start of boot. - always = channel always available regardless of system mode. BIOS typically dedicates the serial connection to the BMC. - shared = same as always available, but BIOS typically leaves the serial port available for software use. :param privilege_update_mode: Channel Privilege Level Limit. This value sets the maximum privilege level that can be accepted on the specified channel. - dont_change = don't set or change channel Privilege Level Limit - non_volatile = non-volatile Privilege Level Limit according - volatile = volatile setting of Privilege Level Limit :param privilege_level: Channel Privilege Level Limit - reserved = unused - callback - user - operator - administrator - proprietary = used by OEM :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_channel_access privilege_level='administrator'
[ "Set", "channel", "access" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L189-L277
train
saltstack/salt
salt/modules/ipmi.py
get_channel_access
def get_channel_access(channel=14, read_mode='non_volatile', **kwargs): ''' :param kwargs:api_host='127.0.0.1' api_user='admin' api_pass='example' api_port=623 :param channel: number [1:7] :param read_mode: - non_volatile = get non-volatile Channel Access - volatile = get present volatile (active) setting of Channel Access :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None Return Data A Python dict with the following keys/values: .. code-block:: python { alerting: per_msg_auth: user_level_auth: access_mode:{ (ONE OF) 0: 'disabled', 1: 'pre_boot', 2: 'always', 3: 'shared' } privilege_level: { (ONE OF) 1: 'callback', 2: 'user', 3: 'operator', 4: 'administrator', 5: 'proprietary', } } CLI Examples: .. code-block:: bash salt-call ipmi.get_channel_access channel=1 ''' with _IpmiCommand(**kwargs) as s: return s.get_channel_access(channel)
python
def get_channel_access(channel=14, read_mode='non_volatile', **kwargs): ''' :param kwargs:api_host='127.0.0.1' api_user='admin' api_pass='example' api_port=623 :param channel: number [1:7] :param read_mode: - non_volatile = get non-volatile Channel Access - volatile = get present volatile (active) setting of Channel Access :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None Return Data A Python dict with the following keys/values: .. code-block:: python { alerting: per_msg_auth: user_level_auth: access_mode:{ (ONE OF) 0: 'disabled', 1: 'pre_boot', 2: 'always', 3: 'shared' } privilege_level: { (ONE OF) 1: 'callback', 2: 'user', 3: 'operator', 4: 'administrator', 5: 'proprietary', } } CLI Examples: .. code-block:: bash salt-call ipmi.get_channel_access channel=1 ''' with _IpmiCommand(**kwargs) as s: return s.get_channel_access(channel)
[ "def", "get_channel_access", "(", "channel", "=", "14", ",", "read_mode", "=", "'non_volatile'", ",", "*", "*", "kwargs", ")", ":", "with", "_IpmiCommand", "(", "*", "*", "kwargs", ")", "as", "s", ":", "return", "s", ".", "get_channel_access", "(", "chan...
:param kwargs:api_host='127.0.0.1' api_user='admin' api_pass='example' api_port=623 :param channel: number [1:7] :param read_mode: - non_volatile = get non-volatile Channel Access - volatile = get present volatile (active) setting of Channel Access :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None Return Data A Python dict with the following keys/values: .. code-block:: python { alerting: per_msg_auth: user_level_auth: access_mode:{ (ONE OF) 0: 'disabled', 1: 'pre_boot', 2: 'always', 3: 'shared' } privilege_level: { (ONE OF) 1: 'callback', 2: 'user', 3: 'operator', 4: 'administrator', 5: 'proprietary', } } CLI Examples: .. code-block:: bash salt-call ipmi.get_channel_access channel=1
[ ":", "param", "kwargs", ":", "api_host", "=", "127", ".", "0", ".", "0", ".", "1", "api_user", "=", "admin", "api_pass", "=", "example", "api_port", "=", "623" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L280-L329
train
saltstack/salt
salt/modules/ipmi.py
set_user_access
def set_user_access(uid, channel=14, callback=True, link_auth=True, ipmi_msg=True, privilege_level='administrator', **kwargs): ''' Set user access :param uid: user number [1:16] :param channel: number [1:7] :param callback: User Restricted to Callback - False = User Privilege Limit is determined by the User Privilege Limit parameter, below, for both callback and non-callback connections. - True = User Privilege Limit is determined by the User Privilege Limit parameter for callback connections, but is restricted to Callback level for non-callback connections. Thus, a user can only initiate a Callback when they 'call in' to the BMC, but once the callback connection has been made, the user could potentially establish a session as an Operator. :param link_auth: User Link authentication enable/disable (used to enable whether this user's name and password information will be used for link authentication, e.g. PPP CHAP) for the given channel. Link authentication itself is a global setting for the channel and is enabled/disabled via the serial/modem configuration parameters. :param ipmi_msg: User IPMI Messaging: (used to enable/disable whether this user's name and password information will be used for IPMI Messaging. In this case, 'IPMI Messaging' refers to the ability to execute generic IPMI commands that are not associated with a particular payload type. For example, if IPMI Messaging is disabled for a user, but that user is enabled for activating the SOL payload type, then IPMI commands associated with SOL and session management, such as Get SOL Configuration Parameters and Close Session are available, but generic IPMI commands such as Get SEL Time are unavailable.) :param privilege_level: User Privilege Limit. (Determines the maximum privilege level that the user is allowed to switch to on the specified channel.) - callback - user - operator - administrator - proprietary - no_access :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_user_access uid=2 privilege_level='operator' ''' with _IpmiCommand(**kwargs) as s: return s.set_user_access(uid, channel, callback, link_auth, ipmi_msg, privilege_level)
python
def set_user_access(uid, channel=14, callback=True, link_auth=True, ipmi_msg=True, privilege_level='administrator', **kwargs): ''' Set user access :param uid: user number [1:16] :param channel: number [1:7] :param callback: User Restricted to Callback - False = User Privilege Limit is determined by the User Privilege Limit parameter, below, for both callback and non-callback connections. - True = User Privilege Limit is determined by the User Privilege Limit parameter for callback connections, but is restricted to Callback level for non-callback connections. Thus, a user can only initiate a Callback when they 'call in' to the BMC, but once the callback connection has been made, the user could potentially establish a session as an Operator. :param link_auth: User Link authentication enable/disable (used to enable whether this user's name and password information will be used for link authentication, e.g. PPP CHAP) for the given channel. Link authentication itself is a global setting for the channel and is enabled/disabled via the serial/modem configuration parameters. :param ipmi_msg: User IPMI Messaging: (used to enable/disable whether this user's name and password information will be used for IPMI Messaging. In this case, 'IPMI Messaging' refers to the ability to execute generic IPMI commands that are not associated with a particular payload type. For example, if IPMI Messaging is disabled for a user, but that user is enabled for activating the SOL payload type, then IPMI commands associated with SOL and session management, such as Get SOL Configuration Parameters and Close Session are available, but generic IPMI commands such as Get SEL Time are unavailable.) :param privilege_level: User Privilege Limit. (Determines the maximum privilege level that the user is allowed to switch to on the specified channel.) - callback - user - operator - administrator - proprietary - no_access :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_user_access uid=2 privilege_level='operator' ''' with _IpmiCommand(**kwargs) as s: return s.set_user_access(uid, channel, callback, link_auth, ipmi_msg, privilege_level)
[ "def", "set_user_access", "(", "uid", ",", "channel", "=", "14", ",", "callback", "=", "True", ",", "link_auth", "=", "True", ",", "ipmi_msg", "=", "True", ",", "privilege_level", "=", "'administrator'", ",", "*", "*", "kwargs", ")", ":", "with", "_IpmiC...
Set user access :param uid: user number [1:16] :param channel: number [1:7] :param callback: User Restricted to Callback - False = User Privilege Limit is determined by the User Privilege Limit parameter, below, for both callback and non-callback connections. - True = User Privilege Limit is determined by the User Privilege Limit parameter for callback connections, but is restricted to Callback level for non-callback connections. Thus, a user can only initiate a Callback when they 'call in' to the BMC, but once the callback connection has been made, the user could potentially establish a session as an Operator. :param link_auth: User Link authentication enable/disable (used to enable whether this user's name and password information will be used for link authentication, e.g. PPP CHAP) for the given channel. Link authentication itself is a global setting for the channel and is enabled/disabled via the serial/modem configuration parameters. :param ipmi_msg: User IPMI Messaging: (used to enable/disable whether this user's name and password information will be used for IPMI Messaging. In this case, 'IPMI Messaging' refers to the ability to execute generic IPMI commands that are not associated with a particular payload type. For example, if IPMI Messaging is disabled for a user, but that user is enabled for activating the SOL payload type, then IPMI commands associated with SOL and session management, such as Get SOL Configuration Parameters and Close Session are available, but generic IPMI commands such as Get SEL Time are unavailable.) :param privilege_level: User Privilege Limit. (Determines the maximum privilege level that the user is allowed to switch to on the specified channel.) - callback - user - operator - administrator - proprietary - no_access :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_user_access uid=2 privilege_level='operator'
[ "Set", "user", "access" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L366-L429
train
saltstack/salt
salt/modules/ipmi.py
get_user_access
def get_user_access(uid, channel=14, **kwargs): ''' Get user access :param uid: user number [1:16] :param channel: number [1:7] :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None Return Data .. code-block:: none channel_info: - max_user_count = maximum number of user IDs on this channel - enabled_users = count of User ID slots presently in use - users_with_fixed_names = count of user IDs with fixed names access: - callback - link_auth - ipmi_msg - privilege_level: [reserved, callback, user, operator administrator, proprietary, no_access] CLI Examples: .. code-block:: bash salt-call ipmi.get_user_access uid=2 ''' ## user access available during call-in or callback direct connection with _IpmiCommand(**kwargs) as s: return s.get_user_access(uid, channel=channel)
python
def get_user_access(uid, channel=14, **kwargs): ''' Get user access :param uid: user number [1:16] :param channel: number [1:7] :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None Return Data .. code-block:: none channel_info: - max_user_count = maximum number of user IDs on this channel - enabled_users = count of User ID slots presently in use - users_with_fixed_names = count of user IDs with fixed names access: - callback - link_auth - ipmi_msg - privilege_level: [reserved, callback, user, operator administrator, proprietary, no_access] CLI Examples: .. code-block:: bash salt-call ipmi.get_user_access uid=2 ''' ## user access available during call-in or callback direct connection with _IpmiCommand(**kwargs) as s: return s.get_user_access(uid, channel=channel)
[ "def", "get_user_access", "(", "uid", ",", "channel", "=", "14", ",", "*", "*", "kwargs", ")", ":", "## user access available during call-in or callback direct connection", "with", "_IpmiCommand", "(", "*", "*", "kwargs", ")", "as", "s", ":", "return", "s", ".",...
Get user access :param uid: user number [1:16] :param channel: number [1:7] :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None Return Data .. code-block:: none channel_info: - max_user_count = maximum number of user IDs on this channel - enabled_users = count of User ID slots presently in use - users_with_fixed_names = count of user IDs with fixed names access: - callback - link_auth - ipmi_msg - privilege_level: [reserved, callback, user, operator administrator, proprietary, no_access] CLI Examples: .. code-block:: bash salt-call ipmi.get_user_access uid=2
[ "Get", "user", "access" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L432-L468
train
saltstack/salt
salt/modules/ipmi.py
set_user_name
def set_user_name(uid, name, **kwargs): ''' Set user name :param uid: user number [1:16] :param name: username (limit of 16bytes) :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_user_name uid=2 name='steverweber' ''' with _IpmiCommand(**kwargs) as s: return s.set_user_name(uid, name)
python
def set_user_name(uid, name, **kwargs): ''' Set user name :param uid: user number [1:16] :param name: username (limit of 16bytes) :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_user_name uid=2 name='steverweber' ''' with _IpmiCommand(**kwargs) as s: return s.set_user_name(uid, name)
[ "def", "set_user_name", "(", "uid", ",", "name", ",", "*", "*", "kwargs", ")", ":", "with", "_IpmiCommand", "(", "*", "*", "kwargs", ")", "as", "s", ":", "return", "s", ".", "set_user_name", "(", "uid", ",", "name", ")" ]
Set user name :param uid: user number [1:16] :param name: username (limit of 16bytes) :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_user_name uid=2 name='steverweber'
[ "Set", "user", "name" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L471-L491
train
saltstack/salt
salt/modules/ipmi.py
get_user_name
def get_user_name(uid, return_none_on_error=True, **kwargs): ''' Get user name :param uid: user number [1:16] :param return_none_on_error: return None on error :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.get_user_name uid=2 ''' with _IpmiCommand(**kwargs) as s: return s.get_user_name(uid, return_none_on_error=True)
python
def get_user_name(uid, return_none_on_error=True, **kwargs): ''' Get user name :param uid: user number [1:16] :param return_none_on_error: return None on error :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.get_user_name uid=2 ''' with _IpmiCommand(**kwargs) as s: return s.get_user_name(uid, return_none_on_error=True)
[ "def", "get_user_name", "(", "uid", ",", "return_none_on_error", "=", "True", ",", "*", "*", "kwargs", ")", ":", "with", "_IpmiCommand", "(", "*", "*", "kwargs", ")", "as", "s", ":", "return", "s", ".", "get_user_name", "(", "uid", ",", "return_none_on_e...
Get user name :param uid: user number [1:16] :param return_none_on_error: return None on error :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.get_user_name uid=2
[ "Get", "user", "name" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L494-L514
train
saltstack/salt
salt/modules/ipmi.py
set_user_password
def set_user_password(uid, mode='set_password', password=None, **kwargs): ''' Set user password and (modes) :param uid: id number of user. see: get_names_uid()['name'] :param mode: - disable = disable user connections - enable = enable user connections - set_password = set or ensure password - test_password = test password is correct :param password: max 16 char string (optional when mode is [disable or enable]) :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :return: True on success when mode = test_password, return False on bad password CLI Example: .. code-block:: bash salt-call ipmi.set_user_password api_host=127.0.0.1 api_user=admin api_pass=pass uid=1 password=newPass salt-call ipmi.set_user_password uid=1 mode=enable ''' with _IpmiCommand(**kwargs) as s: s.set_user_password(uid, mode='set_password', password=password) return True
python
def set_user_password(uid, mode='set_password', password=None, **kwargs): ''' Set user password and (modes) :param uid: id number of user. see: get_names_uid()['name'] :param mode: - disable = disable user connections - enable = enable user connections - set_password = set or ensure password - test_password = test password is correct :param password: max 16 char string (optional when mode is [disable or enable]) :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :return: True on success when mode = test_password, return False on bad password CLI Example: .. code-block:: bash salt-call ipmi.set_user_password api_host=127.0.0.1 api_user=admin api_pass=pass uid=1 password=newPass salt-call ipmi.set_user_password uid=1 mode=enable ''' with _IpmiCommand(**kwargs) as s: s.set_user_password(uid, mode='set_password', password=password) return True
[ "def", "set_user_password", "(", "uid", ",", "mode", "=", "'set_password'", ",", "password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "with", "_IpmiCommand", "(", "*", "*", "kwargs", ")", "as", "s", ":", "s", ".", "set_user_password", "(", "uid"...
Set user password and (modes) :param uid: id number of user. see: get_names_uid()['name'] :param mode: - disable = disable user connections - enable = enable user connections - set_password = set or ensure password - test_password = test password is correct :param password: max 16 char string (optional when mode is [disable or enable]) :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :return: True on success when mode = test_password, return False on bad password CLI Example: .. code-block:: bash salt-call ipmi.set_user_password api_host=127.0.0.1 api_user=admin api_pass=pass uid=1 password=newPass salt-call ipmi.set_user_password uid=1 mode=enable
[ "Set", "user", "password", "and", "(", "modes", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L517-L551
train
saltstack/salt
salt/modules/ipmi.py
get_sensor_data
def get_sensor_data(**kwargs): ''' Get sensor readings Iterates sensor reading objects :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Example: .. code-block:: bash salt-call ipmi.get_sensor_data api_host=127.0.0.1 api_user=admin api_pass=pass ''' import ast with _IpmiCommand(**kwargs) as s: data = {} for reading in s.get_sensor_data(): if reading: r = ast.literal_eval(repr(reading)) data[r.pop('name')] = r return data
python
def get_sensor_data(**kwargs): ''' Get sensor readings Iterates sensor reading objects :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Example: .. code-block:: bash salt-call ipmi.get_sensor_data api_host=127.0.0.1 api_user=admin api_pass=pass ''' import ast with _IpmiCommand(**kwargs) as s: data = {} for reading in s.get_sensor_data(): if reading: r = ast.literal_eval(repr(reading)) data[r.pop('name')] = r return data
[ "def", "get_sensor_data", "(", "*", "*", "kwargs", ")", ":", "import", "ast", "with", "_IpmiCommand", "(", "*", "*", "kwargs", ")", "as", "s", ":", "data", "=", "{", "}", "for", "reading", "in", "s", ".", "get_sensor_data", "(", ")", ":", "if", "re...
Get sensor readings Iterates sensor reading objects :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Example: .. code-block:: bash salt-call ipmi.get_sensor_data api_host=127.0.0.1 api_user=admin api_pass=pass
[ "Get", "sensor", "readings" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L605-L631
train
saltstack/salt
salt/modules/ipmi.py
set_power
def set_power(state='power_on', wait=True, **kwargs): ''' Request power state change :param name: * power_on -- system turn on * power_off -- system turn off (without waiting for OS) * shutdown -- request OS proper shutdown * reset -- reset (without waiting for OS) * boot -- If system is off, then 'on', else 'reset' :param ensure: If (bool True), do not return until system actually completes requested state change for 300 seconds. If a non-zero (int), adjust the wait time to the requested number of seconds :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :returns: dict -- A dict describing the response retrieved CLI Examples: .. code-block:: bash salt-call ipmi.set_power state=shutdown wait=True ''' if state is True or state == 'power_on': state = 'on' if state is False or state == 'power_off': state = 'off' with _IpmiCommand(**kwargs) as s: return s.set_power(state, wait=wait)
python
def set_power(state='power_on', wait=True, **kwargs): ''' Request power state change :param name: * power_on -- system turn on * power_off -- system turn off (without waiting for OS) * shutdown -- request OS proper shutdown * reset -- reset (without waiting for OS) * boot -- If system is off, then 'on', else 'reset' :param ensure: If (bool True), do not return until system actually completes requested state change for 300 seconds. If a non-zero (int), adjust the wait time to the requested number of seconds :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :returns: dict -- A dict describing the response retrieved CLI Examples: .. code-block:: bash salt-call ipmi.set_power state=shutdown wait=True ''' if state is True or state == 'power_on': state = 'on' if state is False or state == 'power_off': state = 'off' with _IpmiCommand(**kwargs) as s: return s.set_power(state, wait=wait)
[ "def", "set_power", "(", "state", "=", "'power_on'", ",", "wait", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "state", "is", "True", "or", "state", "==", "'power_on'", ":", "state", "=", "'on'", "if", "state", "is", "False", "or", "state", ...
Request power state change :param name: * power_on -- system turn on * power_off -- system turn off (without waiting for OS) * shutdown -- request OS proper shutdown * reset -- reset (without waiting for OS) * boot -- If system is off, then 'on', else 'reset' :param ensure: If (bool True), do not return until system actually completes requested state change for 300 seconds. If a non-zero (int), adjust the wait time to the requested number of seconds :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :returns: dict -- A dict describing the response retrieved CLI Examples: .. code-block:: bash salt-call ipmi.set_power state=shutdown wait=True
[ "Request", "power", "state", "change" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L660-L695
train
saltstack/salt
salt/modules/ipmi.py
set_bootdev
def set_bootdev(bootdev='default', persist=False, uefiboot=False, **kwargs): ''' Set boot device to use on next reboot :param bootdev: - network: Request network boot - hd: Boot from hard drive - safe: Boot from hard drive, requesting 'safe mode' - optical: boot from CD/DVD/BD drive - setup: Boot into setup utility - default: remove any IPMI directed boot device request :param persist: If true, ask that system firmware use this device beyond next boot. Be aware many systems do not honor this :param uefiboot: If true, request UEFI boot explicitly. Strictly speaking, the spec suggests that if not set, the system should BIOS boot and offers no "don't care" option. In practice, this flag not being set does not preclude UEFI boot on any system I've encountered. :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :returns: dict or True -- If callback is not provided, the response CLI Examples: .. code-block:: bash salt-call ipmi.set_bootdev bootdev=network persist=True ''' with _IpmiCommand(**kwargs) as s: return s.set_bootdev(bootdev)
python
def set_bootdev(bootdev='default', persist=False, uefiboot=False, **kwargs): ''' Set boot device to use on next reboot :param bootdev: - network: Request network boot - hd: Boot from hard drive - safe: Boot from hard drive, requesting 'safe mode' - optical: boot from CD/DVD/BD drive - setup: Boot into setup utility - default: remove any IPMI directed boot device request :param persist: If true, ask that system firmware use this device beyond next boot. Be aware many systems do not honor this :param uefiboot: If true, request UEFI boot explicitly. Strictly speaking, the spec suggests that if not set, the system should BIOS boot and offers no "don't care" option. In practice, this flag not being set does not preclude UEFI boot on any system I've encountered. :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :returns: dict or True -- If callback is not provided, the response CLI Examples: .. code-block:: bash salt-call ipmi.set_bootdev bootdev=network persist=True ''' with _IpmiCommand(**kwargs) as s: return s.set_bootdev(bootdev)
[ "def", "set_bootdev", "(", "bootdev", "=", "'default'", ",", "persist", "=", "False", ",", "uefiboot", "=", "False", ",", "*", "*", "kwargs", ")", ":", "with", "_IpmiCommand", "(", "*", "*", "kwargs", ")", "as", "s", ":", "return", "s", ".", "set_boo...
Set boot device to use on next reboot :param bootdev: - network: Request network boot - hd: Boot from hard drive - safe: Boot from hard drive, requesting 'safe mode' - optical: boot from CD/DVD/BD drive - setup: Boot into setup utility - default: remove any IPMI directed boot device request :param persist: If true, ask that system firmware use this device beyond next boot. Be aware many systems do not honor this :param uefiboot: If true, request UEFI boot explicitly. Strictly speaking, the spec suggests that if not set, the system should BIOS boot and offers no "don't care" option. In practice, this flag not being set does not preclude UEFI boot on any system I've encountered. :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :returns: dict or True -- If callback is not provided, the response CLI Examples: .. code-block:: bash salt-call ipmi.set_bootdev bootdev=network persist=True
[ "Set", "boot", "device", "to", "use", "on", "next", "reboot" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L698-L737
train
saltstack/salt
salt/modules/ipmi.py
set_identify
def set_identify(on=True, duration=600, **kwargs): ''' Request identify light Request the identify light to turn off, on for a duration, or on indefinitely. Other than error exceptions, :param on: Set to True to force on or False to force off :param duration: Set if wanting to request turn on for a duration in seconds, None = indefinitely. :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_identify ''' with _IpmiCommand(**kwargs) as s: return s.set_identify(on=on, duration=duration)
python
def set_identify(on=True, duration=600, **kwargs): ''' Request identify light Request the identify light to turn off, on for a duration, or on indefinitely. Other than error exceptions, :param on: Set to True to force on or False to force off :param duration: Set if wanting to request turn on for a duration in seconds, None = indefinitely. :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_identify ''' with _IpmiCommand(**kwargs) as s: return s.set_identify(on=on, duration=duration)
[ "def", "set_identify", "(", "on", "=", "True", ",", "duration", "=", "600", ",", "*", "*", "kwargs", ")", ":", "with", "_IpmiCommand", "(", "*", "*", "kwargs", ")", "as", "s", ":", "return", "s", ".", "set_identify", "(", "on", "=", "on", ",", "d...
Request identify light Request the identify light to turn off, on for a duration, or on indefinitely. Other than error exceptions, :param on: Set to True to force on or False to force off :param duration: Set if wanting to request turn on for a duration in seconds, None = indefinitely. :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.set_identify
[ "Request", "identify", "light" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L740-L764
train
saltstack/salt
salt/modules/ipmi.py
get_channel_max_user_count
def get_channel_max_user_count(channel=14, **kwargs): ''' Get max users in channel :param channel: number [1:7] :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :return: int -- often 16 CLI Examples: .. code-block:: bash salt-call ipmi.get_channel_max_user_count ''' access = get_user_access(channel=channel, uid=1, **kwargs) return access['channel_info']['max_user_count']
python
def get_channel_max_user_count(channel=14, **kwargs): ''' Get max users in channel :param channel: number [1:7] :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :return: int -- often 16 CLI Examples: .. code-block:: bash salt-call ipmi.get_channel_max_user_count ''' access = get_user_access(channel=channel, uid=1, **kwargs) return access['channel_info']['max_user_count']
[ "def", "get_channel_max_user_count", "(", "channel", "=", "14", ",", "*", "*", "kwargs", ")", ":", "access", "=", "get_user_access", "(", "channel", "=", "channel", ",", "uid", "=", "1", ",", "*", "*", "kwargs", ")", "return", "access", "[", "'channel_in...
Get max users in channel :param channel: number [1:7] :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None :return: int -- often 16 CLI Examples: .. code-block:: bash salt-call ipmi.get_channel_max_user_count
[ "Get", "max", "users", "in", "channel" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L767-L787
train
saltstack/salt
salt/modules/ipmi.py
get_user
def get_user(uid, channel=14, **kwargs): ''' Get user from uid and access on channel :param uid: user number [1:16] :param channel: number [1:7] :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None Return Data .. code-block:: none name: (str) uid: (int) channel: (int) access: - callback (bool) - link_auth (bool) - ipmi_msg (bool) - privilege_level: (str)[callback, user, operatorm administrator, proprietary, no_access] CLI Examples: .. code-block:: bash salt-call ipmi.get_user uid=2 ''' name = get_user_name(uid, **kwargs) access = get_user_access(uid, channel, **kwargs) data = {'name': name, 'uid': uid, 'channel': channel, 'access': access['access']} return data
python
def get_user(uid, channel=14, **kwargs): ''' Get user from uid and access on channel :param uid: user number [1:16] :param channel: number [1:7] :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None Return Data .. code-block:: none name: (str) uid: (int) channel: (int) access: - callback (bool) - link_auth (bool) - ipmi_msg (bool) - privilege_level: (str)[callback, user, operatorm administrator, proprietary, no_access] CLI Examples: .. code-block:: bash salt-call ipmi.get_user uid=2 ''' name = get_user_name(uid, **kwargs) access = get_user_access(uid, channel, **kwargs) data = {'name': name, 'uid': uid, 'channel': channel, 'access': access['access']} return data
[ "def", "get_user", "(", "uid", ",", "channel", "=", "14", ",", "*", "*", "kwargs", ")", ":", "name", "=", "get_user_name", "(", "uid", ",", "*", "*", "kwargs", ")", "access", "=", "get_user_access", "(", "uid", ",", "channel", ",", "*", "*", "kwarg...
Get user from uid and access on channel :param uid: user number [1:16] :param channel: number [1:7] :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None Return Data .. code-block:: none name: (str) uid: (int) channel: (int) access: - callback (bool) - link_auth (bool) - ipmi_msg (bool) - privilege_level: (str)[callback, user, operatorm administrator, proprietary, no_access] CLI Examples: .. code-block:: bash salt-call ipmi.get_user uid=2
[ "Get", "user", "from", "uid", "and", "access", "on", "channel" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L790-L826
train
saltstack/salt
salt/modules/ipmi.py
create_user
def create_user(uid, name, password, channel=14, callback=False, link_auth=True, ipmi_msg=True, privilege_level='administrator', **kwargs): ''' create/ensure a user is created with provided settings. :param privilege_level: User Privilege Limit. (Determines the maximum privilege level that the user is allowed to switch to on the specified channel.) * callback * user * operator * administrator * proprietary * no_access :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.create_user uid=2 name=steverweber api_host=172.168.0.7 api_pass=nevertell ''' with _IpmiCommand(**kwargs) as c: return c.create_user(uid, name, password, channel, callback, link_auth, ipmi_msg, privilege_level)
python
def create_user(uid, name, password, channel=14, callback=False, link_auth=True, ipmi_msg=True, privilege_level='administrator', **kwargs): ''' create/ensure a user is created with provided settings. :param privilege_level: User Privilege Limit. (Determines the maximum privilege level that the user is allowed to switch to on the specified channel.) * callback * user * operator * administrator * proprietary * no_access :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.create_user uid=2 name=steverweber api_host=172.168.0.7 api_pass=nevertell ''' with _IpmiCommand(**kwargs) as c: return c.create_user(uid, name, password, channel, callback, link_auth, ipmi_msg, privilege_level)
[ "def", "create_user", "(", "uid", ",", "name", ",", "password", ",", "channel", "=", "14", ",", "callback", "=", "False", ",", "link_auth", "=", "True", ",", "ipmi_msg", "=", "True", ",", "privilege_level", "=", "'administrator'", ",", "*", "*", "kwargs"...
create/ensure a user is created with provided settings. :param privilege_level: User Privilege Limit. (Determines the maximum privilege level that the user is allowed to switch to on the specified channel.) * callback * user * operator * administrator * proprietary * no_access :param kwargs: - api_host=127.0.0.1 - api_user=admin - api_pass=example - api_port=623 - api_kg=None CLI Examples: .. code-block:: bash salt-call ipmi.create_user uid=2 name=steverweber api_host=172.168.0.7 api_pass=nevertell
[ "create", "/", "ensure", "a", "user", "is", "created", "with", "provided", "settings", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ipmi.py#L863-L892
train