mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #2676 from bclermont/small-fixes
Small fixes and code cleanup
This commit is contained in:
commit
b8b11e2691
@ -76,7 +76,6 @@ class LoadAuth(object):
|
||||
err = 'Authentication module threw an exception: {0}'.format(exc)
|
||||
log.critical(err)
|
||||
return False
|
||||
return False
|
||||
|
||||
def time_auth(self, load):
|
||||
'''
|
||||
|
@ -114,7 +114,7 @@ def auth(username, password):
|
||||
# Attempt bind with user dn and password
|
||||
log.debug('Attempting LDAP bind with user dn: {0}'.format(authdn))
|
||||
try:
|
||||
_ldap = _LDAPConnection(**connargs).LDAP
|
||||
_LDAPConnection(**connargs).LDAP
|
||||
except:
|
||||
log.warn('Failed to authenticate user dn via LDAP: {0}'.format(authdn))
|
||||
return False
|
||||
|
@ -94,7 +94,7 @@ class Caller(object):
|
||||
for returner in self.opts['return'].split(','):
|
||||
try:
|
||||
self.minion.returners['{0}.returner'.format(returner)](ret)
|
||||
except Exception as exc:
|
||||
except Exception:
|
||||
pass
|
||||
return ret
|
||||
|
||||
|
@ -29,7 +29,6 @@ class SaltCP(object):
|
||||
err = 'The referenced file, {0} is not available.'.format(fn_)
|
||||
sys.stderr.write(err + '\n')
|
||||
sys.exit(42)
|
||||
data = ''
|
||||
with salt.utils.fopen(fn_, 'r') as fp_:
|
||||
data = fp_.read()
|
||||
return {fn_: data}
|
||||
|
@ -485,7 +485,6 @@ class LocalClient(object):
|
||||
# Sometimes the ret data is read at the wrong
|
||||
# time and returns None, do a quick re-read
|
||||
if check:
|
||||
check = False
|
||||
continue
|
||||
ret[fn_] = {'ret': ret_data}
|
||||
if os.path.isfile(outp):
|
||||
|
@ -89,7 +89,6 @@ class MasterKeys(dict):
|
||||
'''
|
||||
Returns a key objects for the master
|
||||
'''
|
||||
key = None
|
||||
if os.path.exists(self.rsa_path):
|
||||
try:
|
||||
key = RSA.load_key(self.rsa_path)
|
||||
@ -143,7 +142,6 @@ class Auth(object):
|
||||
'''
|
||||
Returns a key objects for the minion
|
||||
'''
|
||||
key = None
|
||||
# Make sure all key parent directories are accessible
|
||||
user = self.opts.get('user', 'root')
|
||||
salt.utils.verify.check_path_traversal(self.opts['pki_dir'], user)
|
||||
@ -229,9 +227,6 @@ class Auth(object):
|
||||
else:
|
||||
salt.utils.fopen(m_pub_fn, 'w+').write(master_pub)
|
||||
return True
|
||||
log.error('The salt master has failed verification for an unknown '
|
||||
'reason, verify your salt keys')
|
||||
return False
|
||||
|
||||
def sign_in(self):
|
||||
'''
|
||||
|
@ -336,7 +336,6 @@ class Client(object):
|
||||
*BaseHTTPServer.BaseHTTPRequestHandler.responses[ex.code]))
|
||||
except URLError as ex:
|
||||
raise MinionError('Error reading {0}: {1}'.format(url, ex.reason))
|
||||
return ''
|
||||
|
||||
def get_template(
|
||||
self,
|
||||
|
@ -145,12 +145,11 @@ def _sunos_cpudata(osdata):
|
||||
# cpuarch
|
||||
# num_cpus
|
||||
# cpu_model
|
||||
grains = {'num_cpus': 0}
|
||||
grains = {}
|
||||
|
||||
grains['cpuarch'] = __salt__['cmd.run']('uname -p')
|
||||
psrinfo = '/usr/sbin/psrinfo 2>/dev/null'
|
||||
for line in __salt__['cmd.run'](psrinfo).splitlines():
|
||||
grains['num_cpus'] += 1
|
||||
grains['num_cpus'] = len(__salt__['cmd.run'](psrinfo).splitlines())
|
||||
kstat_info = 'kstat -p cpu_info:*:*:implementation'
|
||||
grains['cpu_model'] = __salt__['cmd.run'](kstat_info).split()[1].strip()
|
||||
return grains
|
||||
|
@ -383,7 +383,7 @@ class Loader(object):
|
||||
except ImportError as exc:
|
||||
log.debug('Failed to import module {0}: {1}'.format(name, exc))
|
||||
return mod
|
||||
except Exception as exc:
|
||||
except Exception:
|
||||
trb = traceback.format_exc()
|
||||
log.warning('Failed to import module {0}, this is due most likely '
|
||||
'to a syntax error: {1}'.format(name, trb))
|
||||
@ -523,7 +523,7 @@ class Loader(object):
|
||||
log.debug('Failed to import module {0}, this is most likely '
|
||||
'NOT a problem: {1}'.format(name, exc))
|
||||
continue
|
||||
except Exception as exc:
|
||||
except Exception:
|
||||
trb = traceback.format_exc()
|
||||
log.warning('Failed to import module {0}, this is due most '
|
||||
'likely to a syntax error: {1}'.format(name, trb))
|
||||
|
@ -468,7 +468,6 @@ class MWorker(multiprocessing.Process):
|
||||
The _handle_payload method is the key method used to figure out what
|
||||
needs to be done with communication to the server
|
||||
'''
|
||||
key = load = None
|
||||
try:
|
||||
key = payload['enc']
|
||||
load = payload['load']
|
||||
|
@ -238,7 +238,6 @@ class Minion(object):
|
||||
Takes the aes encrypted load, decrypts is and runs the encapsulated
|
||||
instructions
|
||||
'''
|
||||
data = None
|
||||
try:
|
||||
data = self.crypticle.loads(load)
|
||||
except AuthenticationError:
|
||||
@ -365,7 +364,7 @@ class Minion(object):
|
||||
ret['return'] = 'ERROR executing {0}: {1}'.format(
|
||||
function_name, exc
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception:
|
||||
trb = traceback.format_exc()
|
||||
msg = 'The minion function caused an exception: {0}'
|
||||
log.warning(msg.format(trb))
|
||||
@ -739,7 +738,6 @@ class Syndic(salt.client.LocalClient, Minion):
|
||||
Takes the aes encrypted load, decrypts is and runs the encapsulated
|
||||
instructions
|
||||
'''
|
||||
data = None
|
||||
# If the AES authentication has changed, re-authenticate
|
||||
try:
|
||||
data = self.crypticle.loads(load)
|
||||
|
@ -148,7 +148,6 @@ def atrm(*args):
|
||||
salt '*' at.atrm all
|
||||
salt '*' at.atrm all [tag]
|
||||
'''
|
||||
opts = ''
|
||||
|
||||
# Need to do this here also since we use atq()
|
||||
if not salt.utils.which('at'):
|
||||
@ -191,7 +190,6 @@ def at(*args, **kwargs):
|
||||
salt '*' at.at 12:05am '/sbin/reboot' tag=reboot
|
||||
salt '*' at.at '3:05am +3 days' 'bin/myscript' tag=nightly runas=jim
|
||||
'''
|
||||
echo_cmd = ''
|
||||
|
||||
if len(args) < 2:
|
||||
return {'jobs': []}
|
||||
|
@ -115,7 +115,6 @@ def setvalue(*args):
|
||||
|
||||
%wheel ALL = PASSWD : ALL , NOPASSWD : /usr/bin/apt-get , /usr/bin/aptitude
|
||||
'''
|
||||
prefix = None
|
||||
aug = Augeas()
|
||||
ret = {'retval': False}
|
||||
|
||||
|
@ -22,7 +22,6 @@ def recv(files, dest):
|
||||
'''
|
||||
ret = {}
|
||||
for path, data in files.items():
|
||||
final = ''
|
||||
if os.path.basename(path) == os.path.basename(dest)\
|
||||
and not os.path.isdir(dest):
|
||||
final = dest
|
||||
|
@ -217,12 +217,6 @@ def rm_job(user, minute, hour, dom, month, dow, cmd):
|
||||
|
||||
salt '*' cron.rm_job root \* \* \* \* 1 /usr/local/weekly
|
||||
'''
|
||||
# Scrub the types
|
||||
minute = str(minute)
|
||||
hour = str(hour)
|
||||
dom = str(dom)
|
||||
month = str(month)
|
||||
dow = str(dow)
|
||||
lst = list_tab(user)
|
||||
ret = 'absent'
|
||||
rm_ = None
|
||||
|
@ -68,9 +68,6 @@ def show(name):
|
||||
|
||||
salt '*' debconf.show <package name>
|
||||
'''
|
||||
|
||||
result = None
|
||||
|
||||
selections = get_selections()
|
||||
|
||||
result = selections.get(name)
|
||||
|
@ -156,7 +156,6 @@ def tune(device, **kwargs):
|
||||
'journal': 'j',
|
||||
'journal_opts': 'J',
|
||||
'label': 'L',
|
||||
'reserved': 'm',
|
||||
'last_dir': 'M',
|
||||
'opts': 'o',
|
||||
'feature': 'O',
|
||||
@ -216,7 +215,6 @@ def dump(device, args=None):
|
||||
ret = {'attributes': {}, 'blocks': {}}
|
||||
out = __salt__['cmd.run'](cmd).splitlines()
|
||||
mode = 'opts'
|
||||
blkgrp = None
|
||||
group = None
|
||||
for line in out:
|
||||
if not line:
|
||||
|
@ -291,9 +291,9 @@ def get_sum(path, form='md5'):
|
||||
return getattr(hashlib, form)(f.read()).hexdigest()
|
||||
except (IOError, OSError) as e:
|
||||
return 'File Error: {0}'.format(e)
|
||||
except AttributeError as e:
|
||||
except AttributeError:
|
||||
return 'Hash {0} not supported'.format(form)
|
||||
except NameError as e:
|
||||
except NameError:
|
||||
return 'Hashlib unavailable - please fix your python install'
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
@ -748,7 +748,7 @@ def touch(name, atime=None, mtime=None):
|
||||
times = (atime, mtime)
|
||||
os.utime(name, times)
|
||||
|
||||
except TypeError as exc:
|
||||
except TypeError:
|
||||
raise SaltInvocationError('atime and mtime must be integers')
|
||||
except (IOError, OSError) as exc:
|
||||
raise CommandExecutionError(exc.strerror)
|
||||
@ -981,7 +981,6 @@ def get_managed(
|
||||
|
||||
if data['result']:
|
||||
sfn = data['data']
|
||||
hsum = ''
|
||||
with salt.utils.fopen(sfn, 'r') as source:
|
||||
hsum = hashlib.md5(source.read()).hexdigest()
|
||||
source_sum = {'hash_type': 'md5',
|
||||
@ -1135,7 +1134,6 @@ def check_managed(
|
||||
'''
|
||||
Check to see what changes need to be made for a file
|
||||
'''
|
||||
changes = {}
|
||||
# If the source is a list then find which file exists
|
||||
source, source_hash = source_list(source, source_hash, env)
|
||||
|
||||
@ -1408,153 +1406,6 @@ def manage_file(name,
|
||||
ret['comment'] = 'File ' + name + ' is in the correct state'
|
||||
__clean_tmp(sfn)
|
||||
return ret
|
||||
# Check changes if the target file exists
|
||||
if os.path.isfile(name):
|
||||
# Only test the checksums on files with managed contents
|
||||
if source:
|
||||
name_sum = ''
|
||||
hash_func = getattr(hashlib, source_sum['hash_type'])
|
||||
with salt.utils.fopen(name, 'rb') as namefile:
|
||||
name_sum = hash_func(namefile.read()).hexdigest()
|
||||
|
||||
# Check if file needs to be replaced
|
||||
if source and source_sum['hsum'] != name_sum:
|
||||
if not sfn:
|
||||
sfn = __salt__['cp.cache_file'](source, env)
|
||||
if not sfn:
|
||||
return _error(
|
||||
ret, 'Source file {0} not found'.format(source))
|
||||
# If the downloaded file came from a non salt server source verify
|
||||
# that it matches the intended sum value
|
||||
if urlparse(source).scheme != 'salt':
|
||||
with salt.utils.fopen(sfn, 'rb') as dlfile:
|
||||
dl_sum = hash_func(dlfile.read()).hexdigest()
|
||||
if dl_sum != source_sum['hsum']:
|
||||
ret['comment'] = ('File sum set for file {0} of {1} does '
|
||||
'not match real sum of {2}'
|
||||
).format(
|
||||
name,
|
||||
source_sum['hsum'],
|
||||
dl_sum
|
||||
)
|
||||
ret['result'] = False
|
||||
return ret
|
||||
|
||||
# Check to see if the files are bins
|
||||
if _is_bin(sfn) or _is_bin(name):
|
||||
ret['changes']['diff'] = 'Replace binary file'
|
||||
else:
|
||||
with nested(salt.utils.fopen(sfn, 'rb'),
|
||||
salt.utils.fopen(name, 'rb')) as (src, name_):
|
||||
slines = src.readlines()
|
||||
nlines = name_.readlines()
|
||||
# Print a diff equivalent to diff -u old new
|
||||
ret['changes']['diff'] = (''.join(difflib
|
||||
.unified_diff(nlines,
|
||||
slines)))
|
||||
# Pre requisites are met, and the file needs to be replaced, do it
|
||||
try:
|
||||
salt.utils.copyfile(
|
||||
sfn,
|
||||
name,
|
||||
__salt__['config.backup_mode'](backup),
|
||||
__opts__['cachedir'])
|
||||
except IOError:
|
||||
__clean_tmp(sfn)
|
||||
return _error(
|
||||
ret, 'Failed to commit change, permission error')
|
||||
|
||||
ret, perms = check_perms(name, ret, user, group, mode)
|
||||
|
||||
if ret['changes']:
|
||||
ret['comment'] = 'File {0} updated'.format(name)
|
||||
|
||||
elif not ret['changes'] and ret['result']:
|
||||
ret['comment'] = 'File {0} is in the correct state'.format(name)
|
||||
__clean_tmp(sfn)
|
||||
return ret
|
||||
else:
|
||||
# Only set the diff if the file contents is managed
|
||||
if source:
|
||||
# It is a new file, set the diff accordingly
|
||||
ret['changes']['diff'] = 'New file'
|
||||
# Apply the new file
|
||||
if not sfn:
|
||||
sfn = __salt__['cp.cache_file'](source, env)
|
||||
if not sfn:
|
||||
return ret.error(
|
||||
ret, 'Source file {0} not found'.format(source))
|
||||
# If the downloaded file came from a non salt server source verify
|
||||
# that it matches the intended sum value
|
||||
if urlparse(source).scheme != 'salt':
|
||||
hash_func = getattr(hashlib, source_sum['hash_type'])
|
||||
with salt.utils.fopen(sfn, 'rb') as dlfile:
|
||||
dl_sum = hash_func(dlfile.read()).hexdigest()
|
||||
if dl_sum != source_sum['hsum']:
|
||||
ret['comment'] = ('File sum set for file {0} of {1} does '
|
||||
'not match real sum of {2}'
|
||||
).format(
|
||||
name,
|
||||
source_sum['hsum'],
|
||||
dl_sum
|
||||
)
|
||||
ret['result'] = False
|
||||
return ret
|
||||
|
||||
if not os.path.isdir(os.path.dirname(name)):
|
||||
if makedirs:
|
||||
makedirs(name, user=user, group=group, mode=mode)
|
||||
else:
|
||||
__clean_tmp(sfn)
|
||||
return _error(ret, 'Parent directory not present')
|
||||
else:
|
||||
if not os.path.isdir(os.path.dirname(name)):
|
||||
if makedirs:
|
||||
makedirs(name, user=user, group=group, mode=mode)
|
||||
else:
|
||||
__clean_tmp(sfn)
|
||||
return _error(ret, 'Parent directory not present')
|
||||
|
||||
# Create the file, user rw-only if mode will be set to prevent
|
||||
# a small security race problem before the permissions are set
|
||||
if mode:
|
||||
current_umask = os.umask(63)
|
||||
|
||||
# Create a new file when test is False and source is None
|
||||
if not __opts__['test']:
|
||||
if touch(name):
|
||||
ret['changes']['new'] = 'file {0} created'.format(name)
|
||||
ret['comment'] = 'Empty file'
|
||||
else:
|
||||
return _error(
|
||||
ret, 'Empty file {0} not created'.format(name)
|
||||
)
|
||||
|
||||
if mode:
|
||||
os.umask(current_umask)
|
||||
|
||||
# Now copy the file contents if there is a source file
|
||||
if sfn:
|
||||
salt.utils.copyfile(
|
||||
sfn,
|
||||
name,
|
||||
__salt__['config.backup_mode'](backup),
|
||||
__opts__['cachedir'])
|
||||
__clean_tmp(sfn)
|
||||
|
||||
# Check and set the permissions if necessary
|
||||
ret, perms = check_perms(name, ret, user, group, mode)
|
||||
|
||||
if not ret['comment']:
|
||||
ret['comment'] = 'File ' + name + ' updated'
|
||||
|
||||
if __opts__['test']:
|
||||
ret['comment'] = 'File ' + name + ' not updated'
|
||||
elif not ret['changes'] and ret['result']:
|
||||
ret['comment'] = 'File ' + name + ' is in the correct state'
|
||||
__clean_tmp(sfn)
|
||||
return ret
|
||||
|
||||
|
||||
def makedirs(path, user=None, group=None, mode=None):
|
||||
'''
|
||||
|
@ -231,7 +231,7 @@ def remove(name):
|
||||
if _check_pkgng():
|
||||
pkg_command = '{0} delete -y'.format(_cmd('pkg'))
|
||||
else:
|
||||
pkg_command - '{0}'.format(_cmd('pkg_delete'))
|
||||
pkg_command = '{0}'.format(_cmd('pkg_delete'))
|
||||
__salt__['cmd.retcode']('{0} {1}'.format(pkg_command, name))
|
||||
new = list_pkgs()
|
||||
return _list_removed(old, new)
|
||||
|
@ -176,7 +176,6 @@ def _item_list():
|
||||
salt '*' nova.item_list
|
||||
'''
|
||||
nt = _auth()
|
||||
ret = {}
|
||||
ret = []
|
||||
for item in nt.items.list():
|
||||
ret.append(item.__dict__)
|
||||
@ -185,14 +184,11 @@ def _item_list():
|
||||
# }
|
||||
return ret
|
||||
|
||||
'''
|
||||
The following is a list of functions that need to be incorporated in the
|
||||
nova module. This list should be updated as functions are added.
|
||||
#The following is a list of functions that need to be incorporated in the
|
||||
#nova module. This list should be updated as functions are added.
|
||||
|
||||
image-download Download a specific image.
|
||||
image-update Update a specific image.
|
||||
member-create Share a specific image with a tenant.
|
||||
member-delete Remove a shared image from a tenant.
|
||||
member-list Describe sharing permissions by image or tenant.
|
||||
|
||||
'''
|
||||
#image-download Download a specific image.
|
||||
#image-update Update a specific image.
|
||||
#member-create Share a specific image with a tenant.
|
||||
#member-delete Remove a shared image from a tenant.
|
||||
#member-list Describe sharing permissions by image or tenant.
|
||||
|
@ -391,7 +391,6 @@ def user_delete(id=None, name=None):
|
||||
salt '*' keystone.user_delete name=nova
|
||||
'''
|
||||
ks = auth()
|
||||
ret = {}
|
||||
if name:
|
||||
for user in ks.users.list():
|
||||
if user.name == name:
|
||||
@ -418,7 +417,6 @@ def user_update(id=None, name=None, email=None, enabled=None):
|
||||
salt '*' keystone.user_update c965f79c4f864eaaa9c3b41904e67082 name=newname email=newemail@domain.com
|
||||
'''
|
||||
ks = auth()
|
||||
ret = {}
|
||||
if not id:
|
||||
return {'Error': 'Unable to resolve user id'}
|
||||
ks.users.update(user=id, name=name, email=email, enabled=enabled)
|
||||
@ -437,7 +435,6 @@ def user_password_update(id=None, name=None, password=None):
|
||||
salt '*' keystone.user_delete name=nova pasword=12345
|
||||
'''
|
||||
ks = auth()
|
||||
ret = {}
|
||||
if name:
|
||||
for user in ks.users.list():
|
||||
if user.name == name:
|
||||
@ -499,7 +496,6 @@ def _item_list():
|
||||
salt '*' keystone.item_list
|
||||
'''
|
||||
ks = auth()
|
||||
ret = {}
|
||||
ret = []
|
||||
for item in ks.items.list():
|
||||
ret.append(item.__dict__)
|
||||
@ -510,27 +506,25 @@ def _item_list():
|
||||
return ret
|
||||
|
||||
|
||||
'''
|
||||
The following is a list of functions that need to be incorporated in the
|
||||
keystone module. This list should be updated as functions are added.
|
||||
|
||||
ec2-credentials-create
|
||||
Create EC2-compatibile credentials for user per tenant
|
||||
ec2-credentials-delete
|
||||
Delete EC2-compatibile credentials
|
||||
endpoint-create Create a new endpoint associated with a service
|
||||
endpoint-delete Delete a service endpoint
|
||||
role-create Create new role
|
||||
role-delete Delete role
|
||||
service-create Add service to Service Catalog
|
||||
service-delete Delete service from Service Catalog
|
||||
tenant-create Create new tenant
|
||||
tenant-delete Delete tenant
|
||||
tenant-update Update tenant name, description, enabled status
|
||||
user-role-add Add role to user
|
||||
user-role-remove Remove role from user
|
||||
discover Discover Keystone servers and show authentication
|
||||
protocols and
|
||||
bootstrap Grants a new role to a new user on a new tenant, after
|
||||
creating each.
|
||||
'''
|
||||
#The following is a list of functions that need to be incorporated in the
|
||||
#keystone module. This list should be updated as functions are added.
|
||||
#
|
||||
#ec2-credentials-create
|
||||
# Create EC2-compatibile credentials for user per tenant
|
||||
#ec2-credentials-delete
|
||||
# Delete EC2-compatibile credentials
|
||||
#endpoint-create Create a new endpoint associated with a service
|
||||
#endpoint-delete Delete a service endpoint
|
||||
#role-create Create new role
|
||||
#role-delete Delete role
|
||||
#service-create Add service to Service Catalog
|
||||
#service-delete Delete service from Service Catalog
|
||||
#tenant-create Create new tenant
|
||||
#tenant-delete Delete tenant
|
||||
#tenant-update Update tenant name, description, enabled status
|
||||
#user-role-add Add role to user
|
||||
#user-role-remove Remove role from user
|
||||
#discover Discover Keystone servers and show authentication
|
||||
# protocols and
|
||||
#bootstrap Grants a new role to a new user on a new tenant, after
|
||||
# creating each.
|
||||
|
@ -107,7 +107,7 @@ def persist(name, value, config='/etc/sysctl.conf'):
|
||||
try:
|
||||
with salt.utils.fopen(config, 'w+') as _fh:
|
||||
_fh.write('#\n# Kernel sysctl configuration\n#\n')
|
||||
except (IOError, OSError) as exc:
|
||||
except (IOError, OSError):
|
||||
msg = 'Could not write to file: {0}'
|
||||
raise CommandExecutionError(msg.format(config))
|
||||
|
||||
|
@ -231,7 +231,7 @@ def set_fstab(
|
||||
with salt.utils.fopen(config, 'w+') as fh:
|
||||
# The line was changed, commit it!
|
||||
fh.writelines(lines)
|
||||
except (IOError, OSError) as exc:
|
||||
except (IOError, OSError):
|
||||
msg = 'File not writable {0}'
|
||||
raise CommandExecutionError(msg.format(config))
|
||||
|
||||
@ -251,7 +251,7 @@ def set_fstab(
|
||||
with salt.utils.fopen(config, 'w+') as fh:
|
||||
# The line was changed, commit it!
|
||||
fh.writelines(lines)
|
||||
except (IOError, OSError) as exc:
|
||||
except (IOError, OSError):
|
||||
msg = 'File not writable {0}'
|
||||
raise CommandExecutionError(msg.format(config))
|
||||
if present and not change:
|
||||
|
@ -251,7 +251,6 @@ def _item_list():
|
||||
salt '*' nova.item_list
|
||||
'''
|
||||
nt = _auth()
|
||||
ret = {}
|
||||
ret = []
|
||||
for item in nt.items.list():
|
||||
ret.append(item.__dict__)
|
||||
@ -260,113 +259,111 @@ def _item_list():
|
||||
# }
|
||||
return ret
|
||||
|
||||
'''
|
||||
The following is a list of functions that need to be incorporated in the
|
||||
nova module. This list should be updated as functions are added.
|
||||
|
||||
absolute-limits Print a list of absolute limits for a user
|
||||
actions Retrieve server actions.
|
||||
add-fixed-ip Add new IP address to network.
|
||||
add-floating-ip Add a floating IP address to a server.
|
||||
aggregate-add-host Add the host to the specified aggregate.
|
||||
aggregate-create Create a new aggregate with the specified details.
|
||||
aggregate-delete Delete the aggregate by its id.
|
||||
aggregate-details Show details of the specified aggregate.
|
||||
aggregate-list Print a list of all aggregates.
|
||||
aggregate-remove-host
|
||||
Remove the specified host from the specfied aggregate.
|
||||
aggregate-set-metadata
|
||||
Update the metadata associated with the aggregate.
|
||||
aggregate-update Update the aggregate's name and optionally
|
||||
availability zone.
|
||||
boot Boot a new server.
|
||||
cloudpipe-create Create a cloudpipe instance for the given project
|
||||
cloudpipe-list Print a list of all cloudpipe instances.
|
||||
console-log Get console log output of a server.
|
||||
credentials Show user credentials returned from auth
|
||||
delete Immediately shut down and delete a server.
|
||||
describe-resource Show details about a resource
|
||||
diagnostics Retrieve server diagnostics.
|
||||
dns-create Create a DNS entry for domain, name and ip.
|
||||
dns-create-private-domain
|
||||
Create the specified DNS domain.
|
||||
dns-create-public-domain
|
||||
Create the specified DNS domain.
|
||||
dns-delete Delete the specified DNS entry.
|
||||
dns-delete-domain Delete the specified DNS domain.
|
||||
dns-domains Print a list of available dns domains.
|
||||
dns-list List current DNS entries for domain and ip or domain
|
||||
and name.
|
||||
endpoints Discover endpoints that get returned from the
|
||||
authenticate services
|
||||
floating-ip-create Allocate a floating IP for the current tenant.
|
||||
floating-ip-delete De-allocate a floating IP.
|
||||
floating-ip-list List floating ips for this tenant.
|
||||
floating-ip-pool-list
|
||||
List all floating ip pools.
|
||||
get-vnc-console Get a vnc console to a server.
|
||||
host-action Perform a power action on a host.
|
||||
host-update Update host settings.
|
||||
image-create Create a new image by taking a snapshot of a running
|
||||
server.
|
||||
image-delete Delete an image.
|
||||
list List active servers.
|
||||
live-migration Migrates a running instance to a new machine.
|
||||
lock Lock a server.
|
||||
meta Set or Delete metadata on a server.
|
||||
migrate Migrate a server.
|
||||
pause Pause a server.
|
||||
rate-limits Print a list of rate limits for a user
|
||||
reboot Reboot a server.
|
||||
rebuild Shutdown, re-image, and re-boot a server.
|
||||
remove-fixed-ip Remove an IP address from a server.
|
||||
remove-floating-ip Remove a floating IP address from a server.
|
||||
rename Rename a server.
|
||||
rescue Rescue a server.
|
||||
resize Resize a server.
|
||||
resize-confirm Confirm a previous resize.
|
||||
resize-revert Revert a previous resize (and return to the previous
|
||||
VM).
|
||||
resume Resume a server.
|
||||
root-password Change the root password for a server.
|
||||
secgroup-add-group-rule
|
||||
Add a source group rule to a security group.
|
||||
secgroup-add-rule Add a rule to a security group.
|
||||
secgroup-create Create a security group.
|
||||
secgroup-delete Delete a security group.
|
||||
secgroup-delete-group-rule
|
||||
Delete a source group rule from a security group.
|
||||
secgroup-delete-rule
|
||||
Delete a rule from a security group.
|
||||
secgroup-list List security groups for the curent tenant.
|
||||
secgroup-list-rules
|
||||
List rules for a security group.
|
||||
show Show details about the given server.
|
||||
ssh SSH into a server.
|
||||
suspend Suspend a server.
|
||||
unlock Unlock a server.
|
||||
unpause Unpause a server.
|
||||
unrescue Unrescue a server.
|
||||
usage-list List usage data for all tenants
|
||||
volume-attach Attach a volume to a server.
|
||||
volume-create Add a new volume.
|
||||
volume-delete Remove a volume.
|
||||
volume-detach Detach a volume from a server.
|
||||
volume-list List all the volumes.
|
||||
volume-show Show details about a volume.
|
||||
volume-snapshot-create
|
||||
Add a new snapshot.
|
||||
volume-snapshot-delete
|
||||
Remove a snapshot.
|
||||
volume-snapshot-list
|
||||
List all the snapshots.
|
||||
volume-snapshot-show
|
||||
Show details about a snapshot.
|
||||
volume-type-create Create a new volume type.
|
||||
volume-type-delete Delete a specific flavor
|
||||
volume-type-list Print a list of available 'volume types'.
|
||||
x509-create-cert Create x509 cert for a user in tenant
|
||||
x509-get-root-cert Fetches the x509 root cert.
|
||||
bash-completion Prints all of the commands and options to stdout so
|
||||
that the
|
||||
'''
|
||||
#The following is a list of functions that need to be incorporated in the
|
||||
#nova module. This list should be updated as functions are added.
|
||||
#
|
||||
#absolute-limits Print a list of absolute limits for a user
|
||||
#actions Retrieve server actions.
|
||||
#add-fixed-ip Add new IP address to network.
|
||||
#add-floating-ip Add a floating IP address to a server.
|
||||
#aggregate-add-host Add the host to the specified aggregate.
|
||||
#aggregate-create Create a new aggregate with the specified details.
|
||||
#aggregate-delete Delete the aggregate by its id.
|
||||
#aggregate-details Show details of the specified aggregate.
|
||||
#aggregate-list Print a list of all aggregates.
|
||||
#aggregate-remove-host
|
||||
# Remove the specified host from the specfied aggregate.
|
||||
#aggregate-set-metadata
|
||||
# Update the metadata associated with the aggregate.
|
||||
#aggregate-update Update the aggregate's name and optionally
|
||||
# availability zone.
|
||||
#boot Boot a new server.
|
||||
#cloudpipe-create Create a cloudpipe instance for the given project
|
||||
#cloudpipe-list Print a list of all cloudpipe instances.
|
||||
#console-log Get console log output of a server.
|
||||
#credentials Show user credentials returned from auth
|
||||
#delete Immediately shut down and delete a server.
|
||||
#describe-resource Show details about a resource
|
||||
#diagnostics Retrieve server diagnostics.
|
||||
#dns-create Create a DNS entry for domain, name and ip.
|
||||
#dns-create-private-domain
|
||||
# Create the specified DNS domain.
|
||||
#dns-create-public-domain
|
||||
# Create the specified DNS domain.
|
||||
#dns-delete Delete the specified DNS entry.
|
||||
#dns-delete-domain Delete the specified DNS domain.
|
||||
#dns-domains Print a list of available dns domains.
|
||||
#dns-list List current DNS entries for domain and ip or domain
|
||||
# and name.
|
||||
#endpoints Discover endpoints that get returned from the
|
||||
# authenticate services
|
||||
#floating-ip-create Allocate a floating IP for the current tenant.
|
||||
#floating-ip-delete De-allocate a floating IP.
|
||||
#floating-ip-list List floating ips for this tenant.
|
||||
#floating-ip-pool-list
|
||||
# List all floating ip pools.
|
||||
#get-vnc-console Get a vnc console to a server.
|
||||
#host-action Perform a power action on a host.
|
||||
#host-update Update host settings.
|
||||
#image-create Create a new image by taking a snapshot of a running
|
||||
# server.
|
||||
#image-delete Delete an image.
|
||||
#list List active servers.
|
||||
#live-migration Migrates a running instance to a new machine.
|
||||
#lock Lock a server.
|
||||
#meta Set or Delete metadata on a server.
|
||||
#migrate Migrate a server.
|
||||
#pause Pause a server.
|
||||
#rate-limits Print a list of rate limits for a user
|
||||
#reboot Reboot a server.
|
||||
#rebuild Shutdown, re-image, and re-boot a server.
|
||||
#remove-fixed-ip Remove an IP address from a server.
|
||||
#remove-floating-ip Remove a floating IP address from a server.
|
||||
#rename Rename a server.
|
||||
#rescue Rescue a server.
|
||||
#resize Resize a server.
|
||||
#resize-confirm Confirm a previous resize.
|
||||
#resize-revert Revert a previous resize (and return to the previous
|
||||
# VM).
|
||||
#resume Resume a server.
|
||||
#root-password Change the root password for a server.
|
||||
#secgroup-add-group-rule
|
||||
# Add a source group rule to a security group.
|
||||
#secgroup-add-rule Add a rule to a security group.
|
||||
#secgroup-create Create a security group.
|
||||
#secgroup-delete Delete a security group.
|
||||
#secgroup-delete-group-rule
|
||||
# Delete a source group rule from a security group.
|
||||
#secgroup-delete-rule
|
||||
# Delete a rule from a security group.
|
||||
#secgroup-list List security groups for the curent tenant.
|
||||
#secgroup-list-rules
|
||||
# List rules for a security group.
|
||||
#show Show details about the given server.
|
||||
#ssh SSH into a server.
|
||||
#suspend Suspend a server.
|
||||
#unlock Unlock a server.
|
||||
#unpause Unpause a server.
|
||||
#unrescue Unrescue a server.
|
||||
#usage-list List usage data for all tenants
|
||||
#volume-attach Attach a volume to a server.
|
||||
#volume-create Add a new volume.
|
||||
#volume-delete Remove a volume.
|
||||
#volume-detach Detach a volume from a server.
|
||||
#volume-list List all the volumes.
|
||||
#volume-show Show details about a volume.
|
||||
#volume-snapshot-create
|
||||
# Add a new snapshot.
|
||||
#volume-snapshot-delete
|
||||
# Remove a snapshot.
|
||||
#volume-snapshot-list
|
||||
# List all the snapshots.
|
||||
#volume-snapshot-show
|
||||
# Show details about a snapshot.
|
||||
#volume-type-create Create a new volume type.
|
||||
#volume-type-delete Delete a specific flavor
|
||||
#volume-type-list Print a list of available 'volume types'.
|
||||
#x509-create-cert Create x509 cert for a user in tenant
|
||||
#x509-get-root-cert Fetches the x509 root cert.
|
||||
#bash-completion Prints all of the commands and options to stdout so
|
||||
# that the
|
||||
|
@ -58,10 +58,8 @@ def list():
|
||||
pecls = {}
|
||||
lines = _pecl('list').splitlines()
|
||||
lines.pop(0)
|
||||
'''
|
||||
Only one line if no package installed:
|
||||
(no packages installed from channel pecl.php.net)
|
||||
'''
|
||||
# Only one line if no package installed:
|
||||
# (no packages installed from channel pecl.php.net)
|
||||
if not lines:
|
||||
return pecls
|
||||
|
||||
|
@ -364,11 +364,9 @@ def _pre_index_check(handler, host=None, core_name=None):
|
||||
err = [
|
||||
'solr.pre_indexing_check can only be called by "master" minions']
|
||||
return _get_return_dict(False, err)
|
||||
'''
|
||||
solr can run out of memory quickly if the dih is processing multiple
|
||||
handlers at the same time, so if it's a multicore setup require a
|
||||
core_name param.
|
||||
'''
|
||||
#solr can run out of memory quickly if the dih is processing multiple
|
||||
#handlers at the same time, so if it's a multicore setup require a
|
||||
#core_name param.
|
||||
if _get_none_or_value(core_name) is None and _check_for_cores():
|
||||
errors = ['solr.full_import is not safe to multiple handlers at once']
|
||||
return _get_return_dict(False, errors=errors)
|
||||
@ -640,12 +638,10 @@ def is_replication_enabled(host=None, core_name=None):
|
||||
else:
|
||||
enabled = slave['masterDetails']['master'][
|
||||
'replicationEnabled']
|
||||
'''
|
||||
if replication is turned off on the master, or polling is
|
||||
disabled we need to return false. These may not not errors,
|
||||
but the purpose of this call is to check to see if the slaves
|
||||
can replicate.
|
||||
'''
|
||||
#if replication is turned off on the master, or polling is
|
||||
#disabled we need to return false. These may not not errors,
|
||||
#but the purpose of this call is to check to see if the slaves
|
||||
#can replicate.
|
||||
if enabled == 'false':
|
||||
resp['warnings'].append("Replication is disabled on master.")
|
||||
success = False
|
||||
|
@ -160,7 +160,7 @@ def _validate_keys(key_file):
|
||||
'comment': comment,
|
||||
'options': options,
|
||||
'fingerprint': fingerprint}
|
||||
except (IOError, OSError) as exc:
|
||||
except (IOError, OSError):
|
||||
msg = 'Problem reading ssh key file {0}'
|
||||
raise CommandExecutionError(msg.format(key_file))
|
||||
|
||||
@ -360,7 +360,6 @@ def set_auth_key_from_file(
|
||||
msg = 'Failed to pull key file from salt file server'
|
||||
raise CommandExecutionError(msg)
|
||||
|
||||
newkey = {}
|
||||
rval = ''
|
||||
newkey = _validate_keys(lfile)
|
||||
for k in newkey:
|
||||
@ -613,15 +612,9 @@ def set_known_host(user, hostname,
|
||||
try:
|
||||
with salt.utils.fopen(full, 'a') as fd:
|
||||
fd.write(line)
|
||||
except (IOError, OSError) as exc:
|
||||
except (IOError, OSError):
|
||||
raise CommandExecutionError("Couldn't append to known hosts file")
|
||||
|
||||
if os.geteuid() == 0:
|
||||
os.chown(full, uinfo['uid'], uinfo['gid'])
|
||||
return {'status': 'updated', 'old': stored_host, 'new': remote_host}
|
||||
|
||||
# TODO: The lines below this are dead code, fix the above return and make these work
|
||||
status = check_known_host(user, hostname, fingerprint=fingerprint,
|
||||
config=config)
|
||||
if status == 'exists':
|
||||
return None
|
||||
|
@ -260,9 +260,9 @@ def get_sum(path, form='md5'):
|
||||
).hexdigest()
|
||||
except (IOError, OSError) as e:
|
||||
return 'File Error: {0}'.format(e)
|
||||
except AttributeError as e:
|
||||
except AttributeError:
|
||||
return 'Hash {0} not supported'.format(form)
|
||||
except NameError as e:
|
||||
except NameError:
|
||||
return 'Hashlib unavailable - please fix your python install'
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
@ -248,7 +248,6 @@ def _get_reg_value(reg_hive, reg_key, value_name=''):
|
||||
Read one value from Windows registry.
|
||||
If 'name' is empty string, reads default value.
|
||||
'''
|
||||
value_data = ''
|
||||
try:
|
||||
key_handle = win32api.RegOpenKeyEx(
|
||||
reg_hive, reg_key, 0, win32con.KEY_ALL_ACCESS)
|
||||
|
@ -341,7 +341,7 @@ def install(name=None, refresh=False, repo='', skip_verify=False, pkgs=None,
|
||||
log.debug('Added {0} transactions'.format(len(a)))
|
||||
if len(a) == 0 and target not in old.keys():
|
||||
log.info('Upgrade failed, trying local downgrade')
|
||||
a = yb.downgradeLocal(target)
|
||||
yb.downgradeLocal(target)
|
||||
else:
|
||||
log.info('Selecting "{0}" for installation'.format(target))
|
||||
# Changed to pattern to allow specific package versions
|
||||
@ -350,7 +350,7 @@ def install(name=None, refresh=False, repo='', skip_verify=False, pkgs=None,
|
||||
log.debug('Added {0} transactions'.format(len(a)))
|
||||
if len(a) == 0 and target not in old.keys():
|
||||
log.info('Upgrade failed, trying downgrade')
|
||||
a = yb.downgrade(pattern=target)
|
||||
yb.downgrade(pattern=target)
|
||||
except Exception:
|
||||
log.exception('Package "{0}" failed to install'.format(target))
|
||||
# Resolve Deps before attempting install. This needs to be improved by
|
||||
|
@ -144,8 +144,6 @@ class SREQ(object):
|
||||
while True:
|
||||
if not self.poller.poll(timeout * 1000) and tried >= tries:
|
||||
raise SaltReqTimeoutError('Waited {0} seconds'.format(timeout))
|
||||
else:
|
||||
break
|
||||
tried += 1
|
||||
try:
|
||||
return self.serial.loads(self.socket.recv())
|
||||
|
@ -111,7 +111,7 @@ def render(template_file, env='', sls='', argline='', **kws):
|
||||
render_template = renderers[name] # eg, the mako renderer
|
||||
except KeyError, e:
|
||||
raise SaltRenderError('Renderer: {0} is not available!'.format(e))
|
||||
except IndexError, e:
|
||||
except IndexError:
|
||||
raise INVALID_USAGE_ERROR
|
||||
|
||||
def process_sls_data(data, context=None, extract=False):
|
||||
|
@ -71,7 +71,6 @@ def returner(ret):
|
||||
'''
|
||||
conn, db = _get_conn()
|
||||
col = db[ret['id']]
|
||||
back = {}
|
||||
|
||||
if isinstance(ret['return'], dict):
|
||||
back = _remove_dots(ret['return'])
|
||||
|
@ -68,7 +68,6 @@ def returner(ret):
|
||||
'''
|
||||
conn, db = _get_conn()
|
||||
col = db[ret['id']]
|
||||
back = {}
|
||||
|
||||
if isinstance(ret['return'], dict):
|
||||
back = _remove_dots(ret['return'])
|
||||
|
@ -534,11 +534,12 @@ class State(object):
|
||||
self.functions = salt.loader.minion_mods(self.opts, self.state_con)
|
||||
if isinstance(data, dict):
|
||||
if data.get('provider', False):
|
||||
provider = {}
|
||||
if isinstance(data['provider'], str):
|
||||
providers = [{data['state']: data['provider']}]
|
||||
elif isinstance(data['provider'], list):
|
||||
providers = data['provider']
|
||||
else:
|
||||
providers = {}
|
||||
for provider in providers:
|
||||
for mod in provider:
|
||||
funcs = salt.loader.raw_mod(self.opts,
|
||||
@ -2023,8 +2024,8 @@ class BaseHighState(object):
|
||||
high, errors = self.render_highstate(matches)
|
||||
err += errors
|
||||
|
||||
if errors:
|
||||
return errors
|
||||
if err:
|
||||
return err
|
||||
|
||||
return high
|
||||
|
||||
|
@ -498,7 +498,7 @@ def script(name,
|
||||
pgid = os.getegid()
|
||||
|
||||
cmd_kwargs = copy.deepcopy(kwargs)
|
||||
cmd_kwargs.update({'cwd': cwd,
|
||||
cmd_kwargs.update({
|
||||
'runas': user,
|
||||
'shell': shell or __grains__['shell'],
|
||||
'env': env,
|
||||
|
@ -369,7 +369,6 @@ def _check_include_exclude(path_str,include_pat=None,exclude_pat=None):
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def symlink(
|
||||
name,
|
||||
target,
|
||||
@ -1671,7 +1670,6 @@ def rename(name, source, force=False, makedirs=False):
|
||||
except (IOError, OSError):
|
||||
return _error(
|
||||
ret, 'Failed to move "{0}" to "{1}"'.format(source, name))
|
||||
return ret
|
||||
|
||||
ret['comment'] = 'Moved "{0}" to "{1}"'.format(source, name)
|
||||
ret['changes'] = {name: source}
|
||||
|
@ -233,7 +233,6 @@ def which(exe=None):
|
||||
Python clone of POSIX's /usr/bin/which
|
||||
'''
|
||||
if exe:
|
||||
(path, name) = os.path.split(exe)
|
||||
if os.access(exe, os.X_OK):
|
||||
return exe
|
||||
|
||||
|
@ -81,8 +81,6 @@ def verify_socket(interface, pub_port, ret_port):
|
||||
'''
|
||||
Attempt to bind to the sockets to verify that they are available
|
||||
'''
|
||||
result = None
|
||||
|
||||
pubsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
retsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user