INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Make sure znode is absent
name
path to znode
version
Specify the version which should be deleted
Default: -1 (always match)
recursive
Boolean to indicate if children should be recursively deleted
Default: False
profile
Configured Zookeeper profile to a... | def absent(name, version=-1, recursive=False, profile=None, hosts=None, scheme=None,
username=None, password=None, default_acl=None):
'''
Make sure znode is absent
name
path to znode
version
Specify the version which should be deleted
Default: -1 (always match)
... |
Update acls on a znode
name
path to znode
acls
list of acl dictionaries to set on znode
version
Specify the version which should be deleted
Default: -1 (always match)
profile
Configured Zookeeper profile to authenticate with (Default: None)
hosts
... | def acls(name, acls, version=-1, profile=None, hosts=None, scheme=None,
username=None, password=None, default_acl=None):
'''
Update acls on a znode
name
path to znode
acls
list of acl dictionaries to set on znode
version
Specify the version which should be deleted... |
get the output of timedatectl | def _timedatectl():
'''
get the output of timedatectl
'''
ret = __salt__['cmd.run_all'](['timedatectl'], python_shell=False)
if ret['retcode'] != 0:
msg = 'timedatectl failed: {0}'.format(ret['stderr'])
raise CommandExecutionError(msg)
return ret |
Return the timezone in /etc/adjtime of the system clock | def _get_adjtime_timezone():
'''
Return the timezone in /etc/adjtime of the system clock
'''
adjtime_file = '/etc/adjtime'
if os.path.exists(adjtime_file):
cmd = ['tail', '-n', '1', adjtime_file]
return __salt__['cmd.run'](cmd, python_shell=False)
elif os.path.exists('/dev/rtc'):... |
Get current timezone (i.e. America/Denver)
.. versionchanged:: 2016.11.4
.. note::
On AIX operating systems, Posix values can also be returned
'CST6CDT,M3.2.0/2:00:00,M11.1.0/2:00:00'
CLI Example:
.. code-block:: bash
salt '*' timezone.get_zone | def get_zone():
'''
Get current timezone (i.e. America/Denver)
.. versionchanged:: 2016.11.4
.. note::
On AIX operating systems, Posix values can also be returned
'CST6CDT,M3.2.0/2:00:00,M11.1.0/2:00:00'
CLI Example:
.. code-block:: bash
salt '*' timezone.get_zone
... |
Get current numeric timezone offset from UCT (i.e. -0700)
CLI Example:
.. code-block:: bash
salt '*' timezone.get_offset | def get_offset():
'''
Get current numeric timezone offset from UCT (i.e. -0700)
CLI Example:
.. code-block:: bash
salt '*' timezone.get_offset
'''
if 'AIX' not in __grains__['os_family']:
return __salt__['cmd.run'](['date', '+%z'], python_shell=False)
salt_path = '/opt/sa... |
Unlinks, then symlinks /etc/localtime to the set timezone.
The timezone is crucial to several system processes, each of which SHOULD
be restarted (for instance, whatever you system uses as its cron and
syslog daemons). This will not be automagically done and must be done
manually!
CLI Example:
... | def set_zone(timezone):
'''
Unlinks, then symlinks /etc/localtime to the set timezone.
The timezone is crucial to several system processes, each of which SHOULD
be restarted (for instance, whatever you system uses as its cron and
syslog daemons). This will not be automagically done and must be done... |
Compares the given timezone name with the system timezone name.
Checks the hash sum between the given timezone, and the one set in
/etc/localtime. Returns True if names and hash sums match, and False if not.
Mostly useful for running state checks.
.. versionchanged:: 2016.3.0
.. note::
On... | def zone_compare(timezone):
'''
Compares the given timezone name with the system timezone name.
Checks the hash sum between the given timezone, and the one set in
/etc/localtime. Returns True if names and hash sums match, and False if not.
Mostly useful for running state checks.
.. versionchang... |
Get current hardware clock setting (UTC or localtime)
CLI Example:
.. code-block:: bash
salt '*' timezone.get_hwclock | def get_hwclock():
'''
Get current hardware clock setting (UTC or localtime)
CLI Example:
.. code-block:: bash
salt '*' timezone.get_hwclock
'''
if salt.utils.path.which('timedatectl'):
ret = _timedatectl()
for line in (x.strip() for x in ret['stdout'].splitlines()):
... |
Sets the hardware clock to be either UTC or localtime
CLI Example:
.. code-block:: bash
salt '*' timezone.set_hwclock UTC | def set_hwclock(clock):
'''
Sets the hardware clock to be either UTC or localtime
CLI Example:
.. code-block:: bash
salt '*' timezone.set_hwclock UTC
'''
if salt.utils.path.which('timedatectl'):
cmd = ['timedatectl', 'set-local-rtc',
'true' if clock == 'localtim... |
Installs a package if not already installed
Args:
name (str):
The name of the package to be installed. Required.
version (str):
Install a specific version of the package. Defaults to latest
version. If the version is different to the one installed then the
... | def installed(name, version=None, source=None, force=False, pre_versions=False,
install_args=None, override_args=False, force_x86=False,
package_args=None, allow_multiple=False, execution_timeout=None):
'''
Installs a package if not already installed
Args:
name (str):
... |
Uninstalls a package
name
The name of the package to be uninstalled
version
Uninstalls a specific version of the package. Defaults to latest
version installed.
uninstall_args
A list of uninstall arguments you want to pass to the uninstallation
process i.e product key or feat... | def uninstalled(name, version=None, uninstall_args=None, override_args=False):
'''
Uninstalls a package
name
The name of the package to be uninstalled
version
Uninstalls a specific version of the package. Defaults to latest
version installed.
uninstall_args
A list of unins... |
Store job information using the configured master_job_cache | def store_job(opts, load, event=None, mminion=None):
'''
Store job information using the configured master_job_cache
'''
# Generate EndTime
endtime = salt.utils.jid.jid_to_time(salt.utils.jid.gen_jid(opts))
# If the return data is invalid, just ignore it
if any(key not in load for key in ('r... |
Store additional minions matched on lower-level masters using the configured
master_job_cache | def store_minions(opts, jid, minions, mminion=None, syndic_id=None):
'''
Store additional minions matched on lower-level masters using the configured
master_job_cache
'''
if mminion is None:
mminion = salt.minion.MasterMinion(opts, states=False, rend=False)
job_cache = opts['master_job_c... |
Determine a retcode for a given return | def get_retcode(ret):
'''
Determine a retcode for a given return
'''
retcode = 0
# if there is a dict with retcode, use that
if isinstance(ret, dict) and ret.get('retcode', 0) != 0:
return ret['retcode']
# if its a boolean, False means 1
elif isinstance(ret, bool) and not ret:
... |
Checks for locked accounts due to too many invalid login attempts, 3 or higher.
.. code-block:: yaml
beacons:
aix_account:
user: ALL
interval: 120 | def beacon(config):
'''
Checks for locked accounts due to too many invalid login attempts, 3 or higher.
.. code-block:: yaml
beacons:
aix_account:
user: ALL
interval: 120
'''
ret = []
user = config['user']
locked_accounts = __salt__['shadow.log... |
Post data to OpsGenie. It's designed for Salt's Event Reactor.
After configuring the sls reaction file as shown above, you can trigger the
module with your designated tag (og-tag in this case).
CLI Example:
.. code-block:: bash
salt-call event.send 'og-tag' '{"reason" : "Overheating CPU!"}'
... | def post_data(api_key=None, name='OpsGenie Execution Module', reason=None,
action_type=None):
'''
Post data to OpsGenie. It's designed for Salt's Event Reactor.
After configuring the sls reaction file as shown above, you can trigger the
module with your designated tag (og-tag in this case... |
Install a Mac OS Package from a pkg or dmg file, if given a dmg file it
will first be mounted in a temporary location
name
The pkg or dmg file to install
target
The location in which to install the package. This can be a path or LocalSystem
dmg
Is the given file a dmg file?
... | def installed(name, target="LocalSystem", dmg=False, store=False, app=False, mpkg=False, user=None, onlyif=None,
unless=None, force=False, allow_untrusted=False, version_check=None):
'''
Install a Mac OS Package from a pkg or dmg file, if given a dmg file it
will first be mounted in a temporar... |
Execute the onlyif and unless logic.
Return a result dict if:
* onlyif failed (onlyif != 0)
* unless succeeded (unless == 0)
else return True | def _mod_run_check(cmd_kwargs, onlyif, unless):
'''
Execute the onlyif and unless logic.
Return a result dict if:
* onlyif failed (onlyif != 0)
* unless succeeded (unless == 0)
else return True
'''
if onlyif:
if __salt__['cmd.retcode'](onlyif, **cmd_kwargs) != 0:
retu... |
Return the status for a service via rest_sample.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionadded:: 2015.8.0
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
Args:
name (str): The name of t... | def status(name, sig=None):
'''
Return the status for a service via rest_sample.
If the name contains globbing, a dict mapping service name to True/False
values is returned.
.. versionadded:: 2015.8.0
.. versionchanged:: 2018.3.0
The service name can now be a glob (e.g. ``salt*``)
... |
Loop through jid files in the minion proc directory (default /var/cache/salt/minion/proc)
and remove any that refer to processes that no longer exist | def clean_proc_dir(opts):
'''
Loop through jid files in the minion proc directory (default /var/cache/salt/minion/proc)
and remove any that refer to processes that no longer exist
'''
for basefilename in os.listdir(salt.minion.get_proc_dir(opts['cachedir'])):
fn_ = os.path.join(salt.minion... |
Return options merged from config and pillar | def option(self, opt):
'''
Return options merged from config and pillar
'''
if 'config.merge' in self.functions:
return self.functions['config.merge'](opt, {}, omit_master=True)
return self.opts.get(opt, {}) |
Return the schedule data structure | def _get_schedule(self,
include_opts=True,
include_pillar=True,
remove_hidden=False):
'''
Return the schedule data structure
'''
schedule = {}
if include_pillar:
pillar_schedule = self.opts.get('pillar'... |
Return the schedule data structure | def _check_max_running(self, func, data, opts, now):
'''
Return the schedule data structure
'''
# Check to see if there are other jobs with this
# signature running. If there are more than maxrunning
# jobs present then don't start another.
# If jid_include is Fa... |
Persist the modified schedule into <<configdir>>/<<default_include>>/_schedule.conf | def persist(self):
'''
Persist the modified schedule into <<configdir>>/<<default_include>>/_schedule.conf
'''
config_dir = self.opts.get('conf_dir', None)
if config_dir is None and 'conf_file' in self.opts:
config_dir = os.path.dirname(self.opts['conf_file'])
... |
Deletes a job from the scheduler. Ignore jobs from pillar | def delete_job(self, name, persist=True):
'''
Deletes a job from the scheduler. Ignore jobs from pillar
'''
# ensure job exists, then delete it
if name in self.opts['schedule']:
del self.opts['schedule'][name]
elif name in self._get_schedule(include_opts=False... |
Reset the scheduler to defaults | def reset(self):
'''
Reset the scheduler to defaults
'''
self.skip_function = None
self.skip_during_range = None
self.enabled = True
self.splay = None
self.opts['schedule'] = {} |
Deletes a job from the scheduler. Ignores jobs from pillar | def delete_job_prefix(self, name, persist=True):
'''
Deletes a job from the scheduler. Ignores jobs from pillar
'''
# ensure job exists, then delete it
for job in list(self.opts['schedule'].keys()):
if job.startswith(name):
del self.opts['schedule'][jo... |
Adds a new job to the scheduler. The format is the same as required in
the configuration file. See the docs on how YAML is interpreted into
python data-structures to make sure, you pass correct dictionaries. | def add_job(self, data, persist=True):
'''
Adds a new job to the scheduler. The format is the same as required in
the configuration file. See the docs on how YAML is interpreted into
python data-structures to make sure, you pass correct dictionaries.
'''
# we don't do an... |
Modify a job in the scheduler. Ignores jobs from pillar | def modify_job(self, name, schedule, persist=True):
'''
Modify a job in the scheduler. Ignores jobs from pillar
'''
# ensure job exists, then replace it
if name in self.opts['schedule']:
self.delete_job(name, persist)
elif name in self._get_schedule(include_op... |
Run a schedule job now | def run_job(self, name):
'''
Run a schedule job now
'''
data = self._get_schedule().get(name, {})
if 'function' in data:
func = data['function']
elif 'func' in data:
func = data['func']
elif 'fun' in data:
func = data['fun']
... |
Enable the scheduler. | def enable_schedule(self):
'''
Enable the scheduler.
'''
self.opts['schedule']['enabled'] = True
# Fire the complete event back along with updated list of schedule
evt = salt.utils.event.get_event('minion', opts=self.opts, listen=False)
evt.fire_event({'complete'... |
Reload the schedule from saved schedule file. | def reload(self, schedule):
'''
Reload the schedule from saved schedule file.
'''
# Remove all jobs from self.intervals
self.intervals = {}
if 'schedule' in schedule:
schedule = schedule['schedule']
self.opts.setdefault('schedule', {}).update(schedule... |
List the current schedule items | def list(self, where):
'''
List the current schedule items
'''
if where == 'pillar':
schedule = self._get_schedule(include_opts=False)
elif where == 'opts':
schedule = self._get_schedule(include_pillar=False)
else:
schedule = self._get_... |
Save the current schedule | def save_schedule(self):
'''
Save the current schedule
'''
self.persist()
# Fire the complete event back along with the list of schedule
evt = salt.utils.event.get_event('minion', opts=self.opts, listen=False)
evt.fire_event({'complete': True},
... |
Skip a job at a specific time in the scheduler.
Ignores jobs from pillar | def skip_job(self, name, data):
'''
Skip a job at a specific time in the scheduler.
Ignores jobs from pillar
'''
time = data['time']
time_fmt = data.get('time_fmt', '%Y-%m-%dT%H:%M:%S')
# ensure job exists, then disable it
if name in self.opts['schedule']... |
Return the next fire time for the specified job | def get_next_fire_time(self, name, fmt='%Y-%m-%dT%H:%M:%S'):
'''
Return the next fire time for the specified job
'''
schedule = self._get_schedule()
_next_fire_time = None
if schedule:
_next_fire_time = schedule.get(name, {}).get('_next_fire_time', None)
... |
Execute this method in a multiprocess or thread | def handle_func(self, multiprocessing_enabled, func, data):
'''
Execute this method in a multiprocess or thread
'''
if salt.utils.platform.is_windows() \
or self.opts.get('transport') == 'zeromq':
# Since function references can't be pickled and pickling
... |
Evaluate and execute the schedule
:param datetime now: Override current time with a datetime object instance`` | def eval(self, now=None):
'''
Evaluate and execute the schedule
:param datetime now: Override current time with a datetime object instance``
'''
log.trace('==== evaluating schedule now %s =====', now)
loop_interval = self.opts['loop_interval']
if not isinstanc... |
Runs the given command against AWS.
cmd
Command to run
region
Region to execute cmd in
opts
Pass in from salt
user
Pass in from salt
kwargs
Key-value arguments to pass to the command | def _run_aws(cmd, region, opts, user, **kwargs):
'''
Runs the given command against AWS.
cmd
Command to run
region
Region to execute cmd in
opts
Pass in from salt
user
Pass in from salt
kwargs
Key-value arguments to pass to the command
'''
# Th... |
Receive one or more messages from a queue in a region
queue
The name of the queue to receive messages from
region
Region where SQS queues exists
num : 1
The max number of messages to receive
opts : None
Any additional options to add to the command line
user : Non... | def receive_message(queue, region, num=1, opts=None, user=None):
'''
Receive one or more messages from a queue in a region
queue
The name of the queue to receive messages from
region
Region where SQS queues exists
num : 1
The max number of messages to receive
opts : N... |
Delete one or more messages from a queue in a region
queue
The name of the queue to delete messages from
region
Region where SQS queues exists
receipthandle
The ReceiptHandle of the message to delete. The ReceiptHandle
is obtained in the return from receive_message
op... | def delete_message(queue, region, receipthandle, opts=None, user=None):
'''
Delete one or more messages from a queue in a region
queue
The name of the queue to delete messages from
region
Region where SQS queues exists
receipthandle
The ReceiptHandle of the message to dele... |
List the queues in the selected region.
region
Region to list SQS queues for
opts : None
Any additional options to add to the command line
user : None
Run hg as a user other than what the minion runs as
CLI Example:
salt '*' aws_sqs.list_queues <region> | def list_queues(region, opts=None, user=None):
'''
List the queues in the selected region.
region
Region to list SQS queues for
opts : None
Any additional options to add to the command line
user : None
Run hg as a user other than what the minion runs as
CLI Example:
... |
Creates a queue with the correct name.
name
Name of the SQS queue to create
region
Region to create the SQS queue in
opts : None
Any additional options to add to the command line
user : None
Run hg as a user other than what the minion runs as
CLI Example:
... | def create_queue(name, region, opts=None, user=None):
'''
Creates a queue with the correct name.
name
Name of the SQS queue to create
region
Region to create the SQS queue in
opts : None
Any additional options to add to the command line
user : None
Run hg as a... |
Deletes a queue in the region.
name
Name of the SQS queue to deletes
region
Name of the region to delete the queue from
opts : None
Any additional options to add to the command line
user : None
Run hg as a user other than what the minion runs as
CLI Example:
... | def delete_queue(name, region, opts=None, user=None):
'''
Deletes a queue in the region.
name
Name of the SQS queue to deletes
region
Name of the region to delete the queue from
opts : None
Any additional options to add to the command line
user : None
Run hg as... |
Returns True or False on whether the queue exists in the region
name
Name of the SQS queue to search for
region
Name of the region to search for the queue in
opts : None
Any additional options to add to the command line
user : None
Run hg as a user other than what the... | def queue_exists(name, region, opts=None, user=None):
'''
Returns True or False on whether the queue exists in the region
name
Name of the SQS queue to search for
region
Name of the region to search for the queue in
opts : None
Any additional options to add to the command ... |
Parse the queue to get a dict of name -> URL | def _parse_queue_list(list_output):
'''
Parse the queue to get a dict of name -> URL
'''
queues = dict((q.split('/')[-1], q) for q in list_output['stdout'])
return queues |
Get a connection to the XenServer host | def _get_session():
'''
Get a connection to the XenServer host
'''
api_version = '1.0'
originator = 'salt_cloud_{}_driver'.format(__virtualname__)
url = config.get_cloud_config_value(
'url',
get_configured_provider(),
__opts__,
search_global=False
)
user =... |
List virtual machines
.. code-block:: bash
salt-cloud -Q | def list_nodes():
'''
List virtual machines
.. code-block:: bash
salt-cloud -Q
'''
session = _get_session()
vms = session.xenapi.VM.get_all_records()
ret = {}
for vm in vms:
record = session.xenapi.VM.get_record(vm)
if not record['is_a_template'] and not re... |
Get the IP address of the VM
.. code-block:: bash
salt-cloud -a get_vm_ip xenvm01
.. note:: Requires xen guest tools to be installed in VM | def get_vm_ip(name=None, session=None, call=None):
'''
Get the IP address of the VM
.. code-block:: bash
salt-cloud -a get_vm_ip xenvm01
.. note:: Requires xen guest tools to be installed in VM
'''
if call == 'function':
raise SaltCloudException(
'This function mu... |
Set the IP address on a virtual interface (vif) | def set_vm_ip(name=None,
ipv4_cidr=None,
ipv4_gw=None,
session=None,
call=None):
'''
Set the IP address on a virtual interface (vif)
'''
mode = 'static'
# TODO: Need to add support for IPv6
if call == 'function':
raise SaltCloudExc... |
List full virtual machines
.. code-block:: bash
salt-cloud -F | def list_nodes_full(session=None):
'''
List full virtual machines
.. code-block:: bash
salt-cloud -F
'''
if session is None:
session = _get_session()
ret = {}
vms = session.xenapi.VM.get_all()
for vm in vms:
record = session.xenapi.VM.get_record(vm)
... |
Return available Xen VDI images
If this function is called with the ``-f`` or ``--function`` then
it can return a list with minimal deatil using the ``terse=True`` keyword
argument.
.. code-block:: bash
salt-cloud -f vdi_list myxen terse=True | def vdi_list(call=None, kwargs=None):
'''
Return available Xen VDI images
If this function is called with the ``-f`` or ``--function`` then
it can return a list with minimal deatil using the ``terse=True`` keyword
argument.
.. code-block:: bash
salt-cloud -f vdi_list myxen terse=True
... |
Return available Xen template information.
This returns the details of
each template to show number cores, memory sizes, etc..
.. code-block:: bash
salt-cloud -f template_list myxen | def template_list(call=None):
'''
Return available Xen template information.
This returns the details of
each template to show number cores, memory sizes, etc..
.. code-block:: bash
salt-cloud -f template_list myxen
'''
templates = {}
session = _get_session()
vms = session... |
Show information about a specific VM or template
.. code-block:: bash
salt-cloud -a show_instance xenvm01
.. note:: memory is memory_dynamic_max | def show_instance(name, session=None, call=None):
'''
Show information about a specific VM or template
.. code-block:: bash
salt-cloud -a show_instance xenvm01
.. note:: memory is memory_dynamic_max
'''
if call == 'function':
raise SaltCloudException(
'The... |
Called by create() used to determine resource pool | def _determine_resource_pool(session, vm_):
'''
Called by create() used to determine resource pool
'''
resource_pool = ''
if 'resource_pool' in vm_.keys():
resource_pool = _get_pool(vm_['resource_pool'], session)
else:
pool = session.xenapi.pool.get_all()
if not pool:
... |
Called by create() used to determine storage repo for create | def _determine_storage_repo(session, resource_pool, vm_):
'''
Called by create() used to determine storage repo for create
'''
storage_repo = ''
if 'storage_repo' in vm_.keys():
storage_repo = _get_sr(vm_['storage_repo'], session)
else:
storage_repo = None
if resource_poo... |
Create a VM in Xen
The configuration for this function is read from the profile settings.
.. code-block:: bash
salt-cloud -p some_profile xenvm01 | def create(vm_):
'''
Create a VM in Xen
The configuration for this function is read from the profile settings.
.. code-block:: bash
salt-cloud -p some_profile xenvm01
'''
name = vm_['name']
record = {}
ret = {}
# fire creating event
__utils__['cloud.fire_event'](
... |
Deploy salt minion during create() | def _deploy_salt_minion(name, session, vm_):
'''
Deploy salt minion during create()
'''
# Get bootstrap values
vm_['ssh_host'] = get_vm_ip(name, session)
vm_['user'] = vm_.get('user', 'root')
vm_['password'] = vm_.get('password', 'p@ssw0rd!')
vm_['provider'] = vm_.get('provider', 'xen')
... |
Set static IP during create() if defined | def _set_static_ip(name, session, vm_):
'''
Set static IP during create() if defined
'''
ipv4_cidr = ''
ipv4_gw = ''
if 'ipv4_gw' in vm_.keys():
log.debug('ipv4_gw is found in keys')
ipv4_gw = vm_['ipv4_gw']
if 'ipv4_cidr' in vm_.keys():
log.debug('ipv4_cidr is found ... |
Wait for IP to be available during create() | def _wait_for_ip(name, session):
'''
Wait for IP to be available during create()
'''
start_time = datetime.now()
status = None
while status is None:
status = get_vm_ip(name, session)
if status is not None:
# ignore APIPA address
if status.startswith('169'... |
Run XenAPI task in asynchronous mode to prevent timeouts | def _run_async_task(task=None, session=None):
'''
Run XenAPI task in asynchronous mode to prevent timeouts
'''
if task is None or session is None:
return None
task_name = session.xenapi.task.get_name_label(task)
log.debug('Running %s', task_name)
while session.xenapi.task.get_status... |
Create VM by cloning
This is faster and should be used if source and target are
in the same storage repository | def _clone_vm(image=None, name=None, session=None):
'''
Create VM by cloning
This is faster and should be used if source and target are
in the same storage repository
'''
if session is None:
session = _get_session()
log.debug('Creating VM %s by cloning %s', name, image)
source ... |
Create VM by copy
This is slower and should be used if source and target are
NOT in the same storage repository
template = object reference
name = string name of new VM
session = object reference
sr = object reference | def _copy_vm(template=None, name=None, session=None, sr=None):
'''
Create VM by copy
This is slower and should be used if source and target are
NOT in the same storage repository
template = object reference
name = string name of new VM
session = object reference
sr = object reference
... |
Provision vm right after clone/copy | def _provision_vm(name=None, session=None):
'''
Provision vm right after clone/copy
'''
if session is None:
session = _get_session()
log.info('Provisioning VM %s', name)
vm = _get_vm(name, session)
task = session.xenapi.Async.VM.provision(vm)
_run_async_task(task, session) |
UnPause a vm
.. code-block:: bash
salt-cloud -a unpause xenvm01 | def unpause(name, call=None, session=None):
'''
UnPause a vm
.. code-block:: bash
salt-cloud -a unpause xenvm01
'''
if call == 'function':
raise SaltCloudException(
'The show_instnce function must be called with -a or --action.'
)
if session is None:
... |
Resume a vm from disk
.. code-block:: bash
salt-cloud -a resume xenvm01 | def resume(name, call=None, session=None):
'''
Resume a vm from disk
.. code-block:: bash
salt-cloud -a resume xenvm01
'''
if call == 'function':
raise SaltCloudException(
'The show_instnce function must be called with -a or --action.'
)
if session is None:... |
Stop a vm
.. code-block:: bash
salt-cloud -a stop xenvm01 | def stop(name, call=None, session=None):
'''
Stop a vm
.. code-block:: bash
salt-cloud -a stop xenvm01
'''
if call == 'function':
raise SaltCloudException(
'The show_instnce function must be called with -a or --action.'
)
return shutdown(name, call, sessio... |
Reboot a vm
.. code-block:: bash
salt-cloud -a reboot xenvm01 | def reboot(name, call=None, session=None):
'''
Reboot a vm
.. code-block:: bash
salt-cloud -a reboot xenvm01
'''
if call == 'function':
raise SaltCloudException(
'The show_instnce function must be called with -a or --action.'
)
if session is None:
s... |
Get XEN vm instance object reference | def _get_vm(name=None, session=None):
'''
Get XEN vm instance object reference
'''
if session is None:
session = _get_session()
vms = session.xenapi.VM.get_by_name_label(name)
if len(vms) == 1:
return vms[0]
return None |
Get XEN sr (storage repo) object reference | def _get_sr(name=None, session=None):
'''
Get XEN sr (storage repo) object reference
'''
if session is None:
session = _get_session()
srs = session.xenapi.SR.get_by_name_label(name)
if len(srs) == 1:
return srs[0]
return None |
Get XEN resource pool object reference | def _get_pool(name=None, session=None):
'''
Get XEN resource pool object reference
'''
if session is None:
session = _get_session()
pools = session.xenapi.pool.get_all()
for pool in pools:
pool_record = session.xenapi.pool.get_record(pool)
if name in pool_record.get('name... |
Destroy Xen VM or template instance
.. code-block:: bash
salt-cloud -d xenvm01 | def destroy(name=None, call=None):
'''
Destroy Xen VM or template instance
.. code-block:: bash
salt-cloud -d xenvm01
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -d, --destroy, '
'-a or --action.'
)
... |
Geta list of storage repositories
.. code-block:: bash
salt-cloud -f sr_list myxen | def sr_list(call=None):
'''
Geta list of storage repositories
.. code-block:: bash
salt-cloud -f sr_list myxen
'''
if call != 'function':
raise SaltCloudSystemExit(
'This function must be called with -f, --function argument.'
)
ret = {}
session = _get_s... |
Get a list of Xen Servers
.. code-block:: bash
salt-cloud -f host_list myxen | def host_list(call=None):
'''
Get a list of Xen Servers
.. code-block:: bash
salt-cloud -f host_list myxen
'''
if call == 'action':
raise SaltCloudSystemExit(
'This function must be called with -f, --function argument.'
)
ret = {}
session = _get_session(... |
Get a list of Resource Pools
.. code-block:: bash
salt-cloud -f pool_list myxen | def pool_list(call=None):
'''
Get a list of Resource Pools
.. code-block:: bash
salt-cloud -f pool_list myxen
'''
if call == 'action':
raise SaltCloudSystemExit(
'This function must be called with -f, --function argument.'
)
ret = {}
session = _get_sess... |
Get a list of Resource Pools
.. code-block:: bash
salt-cloud -f pool_list myxen | def pif_list(call=None):
'''
Get a list of Resource Pools
.. code-block:: bash
salt-cloud -f pool_list myxen
'''
if call != 'function':
raise SaltCloudSystemExit(
'This function must be called with -f, --function argument.'
)
ret = {}
session = _get_sess... |
Get a list of virtual network interfaces on a VM
**requires**: the name of the vm with the vbd definition
.. code-block:: bash
salt-cloud -a vif_list xenvm01 | def vif_list(name, call=None, kwargs=None):
'''
Get a list of virtual network interfaces on a VM
**requires**: the name of the vm with the vbd definition
.. code-block:: bash
salt-cloud -a vif_list xenvm01
'''
if call == 'function':
raise SaltCloudSystemExit(
'Th... |
Get a list of VBDs on a VM
**requires**: the name of the vm with the vbd definition
.. code-block:: bash
salt-cloud -a vbd_list xenvm01 | def vbd_list(name=None, call=None):
'''
Get a list of VBDs on a VM
**requires**: the name of the vm with the vbd definition
.. code-block:: bash
salt-cloud -a vbd_list xenvm01
'''
if call == 'function':
raise SaltCloudSystemExit(
'This function must be called with... |
Get virtual block devices on VM
.. code-block:: bash
salt-cloud -a destroy_vm_vdis xenvm01 | def destroy_vm_vdis(name=None, session=None, call=None):
'''
Get virtual block devices on VM
.. code-block:: bash
salt-cloud -a destroy_vm_vdis xenvm01
'''
if session is None:
session = _get_session()
ret = {}
# get vm object
vms = session.xenapi.VM.get_by_name_label(... |
Destroy Xen VM or template instance
.. code-block:: bash
salt-cloud -f destroy_template myxen name=testvm2 | def destroy_template(name=None, call=None, kwargs=None):
'''
Destroy Xen VM or template instance
.. code-block:: bash
salt-cloud -f destroy_template myxen name=testvm2
'''
if call == 'action':
raise SaltCloudSystemExit(
'The destroy_template function must be ca... |
Get PV arguments for a VM
.. code-block:: bash
salt-cloud -a get_pv_args xenvm01 | def get_pv_args(name, session=None, call=None):
'''
Get PV arguments for a VM
.. code-block:: bash
salt-cloud -a get_pv_args xenvm01
'''
if call == 'function':
raise SaltCloudException(
'This function must be called with -a or --action.'
)
if session is Non... |
Set PV arguments for a VM
.. code-block:: bash
salt-cloud -a set_pv_args xenvm01 pv_args="utf-8 graphical" | def set_pv_args(name, kwargs=None, session=None, call=None):
'''
Set PV arguments for a VM
.. code-block:: bash
salt-cloud -a set_pv_args xenvm01 pv_args="utf-8 graphical"
'''
if call == 'function':
raise SaltCloudException(
'This function must be called with -a or --a... |
Checks to see if the given service is in the given services.
:param str name: Service label, file name, or full path
:param dict services: The currently available services.
:return: The service information for the service, otherwise
an empty dictionary
:rtype: dict | def _name_in_services(name, services):
'''
Checks to see if the given service is in the given services.
:param str name: Service label, file name, or full path
:param dict services: The currently available services.
:return: The service information for the service, otherwise
an empty dictiona... |
Get information about a service. If the service is not found, raise an
error
:param str name: Service label, file name, or full path
:return: The service information for the service, otherwise an Error
:rtype: dict | def _get_service(name):
'''
Get information about a service. If the service is not found, raise an
error
:param str name: Service label, file name, or full path
:return: The service information for the service, otherwise an Error
:rtype: dict
'''
services = __utils__['mac_utils.availa... |
Check if the service should always be running based on the KeepAlive Key
in the service plist.
:param str name: Service label, file name, or full path
:return: True if the KeepAlive key is set to True, False if set to False or
not set in the plist at all.
:rtype: bool
.. versionadded:: 2... | def _always_running_service(name):
'''
Check if the service should always be running based on the KeepAlive Key
in the service plist.
:param str name: Service label, file name, or full path
:return: True if the KeepAlive key is set to True, False if set to False or
not set in the plist at ... |
Returns the domain/service target and path for a service. This is used to
determine whether or not a service should be loaded in a user space or
system space.
:param str name: Service label, file name, or full path
:param bool service_target: Whether to return a full
service target. This is needed... | def _get_domain_target(name, service_target=False):
'''
Returns the domain/service target and path for a service. This is used to
determine whether or not a service should be loaded in a user space or
system space.
:param str name: Service label, file name, or full path
:param bool service_tar... |
Run launchctl list and return the output
:param str name: The name of the service to list
:param str runas: User to run launchctl commands
:return: If a name is passed returns information about the named service,
otherwise returns a list of all services and pids
:rtype: str
CLI Example:
... | def list_(name=None, runas=None):
'''
Run launchctl list and return the output
:param str name: The name of the service to list
:param str runas: User to run launchctl commands
:return: If a name is passed returns information about the named service,
otherwise returns a list of all servic... |
Enable a launchd service. Raises an error if the service fails to be enabled
:param str name: Service label, file name, or full path
:param str runas: User to run launchctl commands
:return: ``True`` if successful or if the service is already enabled
:rtype: bool
CLI Example:
.. code-block:... | def enable(name, runas=None):
'''
Enable a launchd service. Raises an error if the service fails to be enabled
:param str name: Service label, file name, or full path
:param str runas: User to run launchctl commands
:return: ``True`` if successful or if the service is already enabled
:rtype: ... |
Disable a launchd service. Raises an error if the service fails to be
disabled
:param str name: Service label, file name, or full path
:param str runas: User to run launchctl commands
:return: ``True`` if successful or if the service is already disabled
:rtype: bool
CLI Example:
.. code... | def disable(name, runas=None):
'''
Disable a launchd service. Raises an error if the service fails to be
disabled
:param str name: Service label, file name, or full path
:param str runas: User to run launchctl commands
:return: ``True`` if successful or if the service is already disabled
... |
Start a launchd service. Raises an error if the service fails to start
.. note::
To start a service in macOS the service must be enabled first. Use
``service.enable`` to enable the service.
:param str name: Service label, file name, or full path
:param str runas: User to run launchctl co... | def start(name, runas=None):
'''
Start a launchd service. Raises an error if the service fails to start
.. note::
To start a service in macOS the service must be enabled first. Use
``service.enable`` to enable the service.
:param str name: Service label, file name, or full path
:... |
Stop a launchd service. Raises an error if the service fails to stop
.. note::
Though ``service.stop`` will unload a service in macOS, the service
will start on next boot unless it is disabled. Use ``service.disable``
to disable the service
:param str name: Service label, file name, o... | def stop(name, runas=None):
'''
Stop a launchd service. Raises an error if the service fails to stop
.. note::
Though ``service.stop`` will unload a service in macOS, the service
will start on next boot unless it is disabled. Use ``service.disable``
to disable the service
:par... |
Unloads and reloads a launchd service. Raises an error if the service
fails to reload
:param str name: Service label, file name, or full path
:param str runas: User to run launchctl commands
:return: ``True`` if successful
:rtype: bool
CLI Example:
.. code-block:: bash
salt '*... | def restart(name, runas=None):
'''
Unloads and reloads a launchd service. Raises an error if the service
fails to reload
:param str name: Service label, file name, or full path
:param str runas: User to run launchctl commands
:return: ``True`` if successful
:rtype: bool
CLI Example:... |
Return the status for a service.
:param str name: Used to find the service from launchctl. Can be any part
of the service name or a regex expression.
:param str sig: Find the service with status.pid instead. Note that
``name`` must still be provided.
:param str runas: User to run launch... | def status(name, sig=None, runas=None):
'''
Return the status for a service.
:param str name: Used to find the service from launchctl. Can be any part
of the service name or a regex expression.
:param str sig: Find the service with status.pid instead. Note that
``name`` must still be... |
Check if the specified service is enabled
:param str name: The name of the service to look up
:param str runas: User to run launchctl commands
:return: True if the specified service enabled, otherwise False
:rtype: bool
CLI Example:
.. code-block:: bash
salt '*' service.enabled org... | def enabled(name, runas=None):
'''
Check if the specified service is enabled
:param str name: The name of the service to look up
:param str runas: User to run launchctl commands
:return: True if the specified service enabled, otherwise False
:rtype: bool
CLI Example:
.. code-block::... |
Check if the specified service is not enabled. This is the opposite of
``service.enabled``
:param str name: The name to look up
:param str runas: User to run launchctl commands
:param str domain: domain to check for disabled services. Default is system.
:return: True if the specified service is ... | def disabled(name, runas=None, domain='system'):
'''
Check if the specified service is not enabled. This is the opposite of
``service.enabled``
:param str name: The name to look up
:param str runas: User to run launchctl commands
:param str domain: domain to check for disabled services. Defau... |
Return a list of services that are enabled or available. Can be used to
find the name of a service.
:param str runas: User to run launchctl commands
:return: A list of all the services available or enabled
:rtype: list
CLI Example:
.. code-block:: bash
salt '*' service.get_all | def get_all(runas=None):
'''
Return a list of services that are enabled or available. Can be used to
find the name of a service.
:param str runas: User to run launchctl commands
:return: A list of all the services available or enabled
:rtype: list
CLI Example:
.. code-block:: bash
... |
Return a list of all services that are enabled. Can be used to find the
name of a service.
:param str runas: User to run launchctl commands
:return: A list of all the services enabled on the system
:rtype: list
CLI Example:
.. code-block:: bash
salt '*' service.get_enabled | def get_enabled(runas=None):
'''
Return a list of all services that are enabled. Can be used to find the
name of a service.
:param str runas: User to run launchctl commands
:return: A list of all the services enabled on the system
:rtype: list
CLI Example:
.. code-block:: bash
... |
Return a conn object for the passed VM data | def get_conn():
'''
Return a conn object for the passed VM data
'''
vm_ = get_configured_provider()
kwargs = vm_.copy() # pylint: disable=E1103
kwargs['username'] = vm_['user']
kwargs['project_id'] = vm_['tenant']
kwargs['auth_url'] = vm_['identity_url']
kwargs['region_name'] = vm... |
Return a list of locations | def avail_locations(conn=None, call=None):
'''
Return a list of locations
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_locations function must be called with '
'-f or --function, or with the --list-locations option'
)
if conn is None:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.