INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
List networks
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.list_networks
salt '*' neutronng.list_networks \
filters='{"tenant_id": "1dcac318a83b4610b7a7f7ba01465548"}' | def list_networks(auth=None, **kwargs):
'''
List networks
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.list_networks
salt '*' neutronng.list_networks \
filters='{"tenant_id": "1dcac318a83b4610... |
Get a single network
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.network_get name=XLB4 | def network_get(auth=None, **kwargs):
'''
Get a single network
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.network_get name=XLB4
'''
cloud = get_operator_cloud(auth)
kwargs = _clean_kwargs(**kwarg... |
Create a subnet
network_name_or_id
The unique name or ID of the attached network. If a non-unique name is
supplied, an exception is raised.
cidr
The CIDR
ip_version
The IP version, which is 4 or 6.
enable_dhcp : False
Set to ``True`` if DHCP is enabled and ``F... | def subnet_create(auth=None, **kwargs):
'''
Create a subnet
network_name_or_id
The unique name or ID of the attached network. If a non-unique name is
supplied, an exception is raised.
cidr
The CIDR
ip_version
The IP version, which is 4 or 6.
enable_dhcp : Fals... |
Update a subnet
name_or_id
Name or ID of the subnet to update
subnet_name
The new name of the subnet
enable_dhcp
Set to ``True`` if DHCP is enabled and ``False`` if disabled
gateway_ip
The gateway IP address. When you specify both allocation_pools and
gateway_... | def subnet_update(auth=None, **kwargs):
'''
Update a subnet
name_or_id
Name or ID of the subnet to update
subnet_name
The new name of the subnet
enable_dhcp
Set to ``True`` if DHCP is enabled and ``False`` if disabled
gateway_ip
The gateway IP address. When yo... |
Delete a subnet
name
Name or ID of the subnet to update
CLI Example:
.. code-block:: bash
salt '*' neutronng.subnet_delete name=subnet1
salt '*' neutronng.subnet_delete \
name=1dcac318a83b4610b7a7f7ba01465548 | def subnet_delete(auth=None, **kwargs):
'''
Delete a subnet
name
Name or ID of the subnet to update
CLI Example:
.. code-block:: bash
salt '*' neutronng.subnet_delete name=subnet1
salt '*' neutronng.subnet_delete \
name=1dcac318a83b4610b7a7f7ba01465548
'''
... |
List subnets
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.list_subnets
salt '*' neutronng.list_subnets \
filters='{"tenant_id": "1dcac318a83b4610b7a7f7ba01465548"}' | def list_subnets(auth=None, **kwargs):
'''
List subnets
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.list_subnets
salt '*' neutronng.list_subnets \
filters='{"tenant_id": "1dcac318a83b4610b7a7... |
Get a single subnet
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.subnet_get name=subnet1 | def subnet_get(auth=None, **kwargs):
'''
Get a single subnet
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.subnet_get name=subnet1
'''
cloud = get_operator_cloud(auth)
kwargs = _clean_kwargs(**kwarg... |
Create a security group. Use security_group_get to create default.
project_id
The project ID on which this security group will be created
CLI Example:
.. code-block:: bash
salt '*' neutronng.security_group_create name=secgroup1 \
description="Very secure security group"
... | def security_group_create(auth=None, **kwargs):
'''
Create a security group. Use security_group_get to create default.
project_id
The project ID on which this security group will be created
CLI Example:
.. code-block:: bash
salt '*' neutronng.security_group_create name=secgroup1 ... |
Update a security group
secgroup
Name, ID or Raw Object of the security group to update
name
New name for the security group
description
New description for the security group
CLI Example:
.. code-block:: bash
salt '*' neutronng.security_group_update secgroup=se... | def security_group_update(secgroup=None, auth=None, **kwargs):
'''
Update a security group
secgroup
Name, ID or Raw Object of the security group to update
name
New name for the security group
description
New description for the security group
CLI Example:
.. code... |
Delete a security group
name_or_id
The name or unique ID of the security group
CLI Example:
.. code-block:: bash
salt '*' neutronng.security_group_delete name_or_id=secgroup1 | def security_group_delete(auth=None, **kwargs):
'''
Delete a security group
name_or_id
The name or unique ID of the security group
CLI Example:
.. code-block:: bash
salt '*' neutronng.security_group_delete name_or_id=secgroup1
'''
cloud = get_operator_cloud(auth)
kwa... |
Create a rule in a security group
secgroup_name_or_id
The security group name or ID to associate with this security group
rule. If a non-unique group name is given, an exception is raised.
port_range_min
The minimum port number in the range that is matched by the security
group... | def security_group_rule_create(auth=None, **kwargs):
'''
Create a rule in a security group
secgroup_name_or_id
The security group name or ID to associate with this security group
rule. If a non-unique group name is given, an exception is raised.
port_range_min
The minimum port ... |
Get a single security group. This will create a default security group
if one does not exist yet for a particular project id.
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt '*' neutronng.security_group_get \
name=1dcac31... | def security_group_get(auth=None, **kwargs):
'''
Get a single security group. This will create a default security group
if one does not exist yet for a particular project id.
filters
A Python dictionary of filter conditions to push down
CLI Example:
.. code-block:: bash
salt ... |
Delete a security group
name_or_id
The unique ID of the security group rule
CLI Example:
.. code-block:: bash
salt '*' neutronng.security_group_rule_delete name_or_id=1dcac318a83b4610b7a7f7ba01465548 | def security_group_rule_delete(auth=None, **kwargs):
'''
Delete a security group
name_or_id
The unique ID of the security group rule
CLI Example:
.. code-block:: bash
salt '*' neutronng.security_group_rule_delete name_or_id=1dcac318a83b4610b7a7f7ba01465548
'''
cloud = ge... |
Return a dict of all available VM locations on the cloud provider with
relevant data | def avail_locations(call=None):
'''
Return a dict of all available VM locations on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_locations function must be called with '
'-f or --function, or with the --list-locat... |
Return a list of the images that are on the provider | def avail_images(kwargs=None, call=None):
'''
Return a list of the images that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_images function must be called with '
'-f or --function, or with the --list-images option'
)
if n... |
Return a list of the image sizes that are on the provider | def avail_sizes(call=None):
'''
Return a list of the image sizes that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_sizes function must be called with '
'-f or --function, or with the --list-sizes option'
)
params = {'Acti... |
List all availability zones in the current region | def list_availability_zones(call=None):
'''
List all availability zones in the current region
'''
ret = {}
params = {'Action': 'DescribeZones',
'RegionId': get_location()}
items = query(params)
for zone in items['Zones']['Zone']:
ret[zone['ZoneId']] = {}
for i... |
Return a list of the VMs that are on the provider. Only a list of VM names,
and their state, is returned. This is the minimum amount of information
needed to check for existing VMs. | def list_nodes_min(call=None):
'''
Return a list of the VMs that are on the provider. Only a list of VM names,
and their state, is returned. This is the minimum amount of information
needed to check for existing VMs.
'''
if call == 'action':
raise SaltCloudSystemExit(
'The li... |
Return a list of the VMs that are on the provider | def list_nodes(call=None):
'''
Return a list of the VMs that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes function must be called with -f or --function.'
)
nodes = list_nodes_full()
ret = {}
for instanceId in nodes:
... |
Return a list of the VMs that are on the provider | def list_nodes_full(call=None):
'''
Return a list of the VMs that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_full function must be called with -f '
'or --function.'
)
ret = {}
location = get_location()
para... |
Return a list of security group | def list_securitygroup(call=None):
'''
Return a list of security group
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes function must be called with -f or --function.'
)
params = {
'Action': 'DescribeSecurityGroups',
'RegionId': get_loc... |
Return the image object to use | def get_image(vm_):
'''
Return the image object to use
'''
images = avail_images()
vm_image = six.text_type(config.get_cloud_config_value(
'image', vm_, __opts__, search_global=False
))
if not vm_image:
raise SaltCloudNotFound('No image specified for this VM.')
if vm_im... |
Return the security group | def get_securitygroup(vm_):
'''
Return the security group
'''
sgs = list_securitygroup()
securitygroup = config.get_cloud_config_value(
'securitygroup', vm_, __opts__, search_global=False
)
if not securitygroup:
raise SaltCloudNotFound('No securitygroup ID specified for this... |
Return the VM's size. Used by create_node(). | def get_size(vm_):
'''
Return the VM's size. Used by create_node().
'''
sizes = avail_sizes()
vm_size = six.text_type(config.get_cloud_config_value(
'size', vm_, __opts__, search_global=False
))
if not vm_size:
raise SaltCloudNotFound('No size specified for this VM.')
i... |
Return the VM's location | def __get_location(vm_):
'''
Return the VM's location
'''
locations = avail_locations()
vm_location = six.text_type(config.get_cloud_config_value(
'location', vm_, __opts__, search_global=False
))
if not vm_location:
raise SaltCloudNotFound('No location specified for this VM... |
Start a node
CLI Examples:
.. code-block:: bash
salt-cloud -a start myinstance | def start(name, call=None):
'''
Start a node
CLI Examples:
.. code-block:: bash
salt-cloud -a start myinstance
'''
if call != 'action':
raise SaltCloudSystemExit(
'The stop action must be called with -a or --action.'
)
log.info('Starting node %s', name... |
Stop a node
CLI Examples:
.. code-block:: bash
salt-cloud -a stop myinstance
salt-cloud -a stop myinstance force=True | def stop(name, force=False, call=None):
'''
Stop a node
CLI Examples:
.. code-block:: bash
salt-cloud -a stop myinstance
salt-cloud -a stop myinstance force=True
'''
if call != 'action':
raise SaltCloudSystemExit(
'The stop action must be called with -a or ... |
Reboot a node
CLI Examples:
.. code-block:: bash
salt-cloud -a reboot myinstance | def reboot(name, call=None):
'''
Reboot a node
CLI Examples:
.. code-block:: bash
salt-cloud -a reboot myinstance
'''
if call != 'action':
raise SaltCloudSystemExit(
'The stop action must be called with -a or --action.'
)
log.info('Rebooting node %s', ... |
Convenience function to make the rest api call for node creation. | def create_node(kwargs):
'''
Convenience function to make the rest api call for node creation.
'''
if not isinstance(kwargs, dict):
kwargs = {}
# Required parameters
params = {
'Action': 'CreateInstance',
'InstanceType': kwargs.get('size_id', ''),
'RegionId': kwa... |
Create a single VM from a data dict | def create(vm_):
'''
Create a single VM from a data dict
'''
try:
# Check for required profile parameters before sending any API calls.
if vm_['profile'] and config.is_profile_configured(__opts__,
__active_provider_name__ or 'ali... |
Generate aliyun request signature | def _compute_signature(parameters, access_key_secret):
'''
Generate aliyun request signature
'''
def percent_encode(line):
if not isinstance(line, six.string_types):
return line
s = line
if sys.stdin.encoding is None:
s = line.decode().encode('utf8')
... |
Make a web call to aliyun ECS REST API | def query(params=None):
'''
Make a web call to aliyun ECS REST API
'''
path = 'https://ecs-cn-hangzhou.aliyuncs.com'
access_key_id = config.get_cloud_config_value(
'id', get_configured_provider(), __opts__, search_global=False
)
access_key_secret = config.get_cloud_config_value(
... |
Show the disk details of the instance
CLI Examples:
.. code-block:: bash
salt-cloud -a show_disk aliyun myinstance | def show_disk(name, call=None):
'''
Show the disk details of the instance
CLI Examples:
.. code-block:: bash
salt-cloud -a show_disk aliyun myinstance
'''
if call != 'action':
raise SaltCloudSystemExit(
'The show_disks action must be called with -a or --action.'
... |
Get monitor data of the instance. If instance name is
missing, will show all the instance monitor data on the region.
CLI Examples:
.. code-block:: bash
salt-cloud -f list_monitor_data aliyun
salt-cloud -f list_monitor_data aliyun name=AY14051311071990225bd | def list_monitor_data(kwargs=None, call=None):
'''
Get monitor data of the instance. If instance name is
missing, will show all the instance monitor data on the region.
CLI Examples:
.. code-block:: bash
salt-cloud -f list_monitor_data aliyun
salt-cloud -f list_monitor_data aliyun... |
Show the details from aliyun image | def show_image(kwargs, call=None):
'''
Show the details from aliyun image
'''
if call != 'function':
raise SaltCloudSystemExit(
'The show_images function must be called with '
'-f or --function'
)
if not isinstance(kwargs, dict):
kwargs = {}
loca... |
Destroy a node.
CLI Example:
.. code-block:: bash
salt-cloud -a destroy myinstance
salt-cloud -d myinstance | def destroy(name, call=None):
'''
Destroy a node.
CLI Example:
.. code-block:: bash
salt-cloud -a destroy myinstance
salt-cloud -d myinstance
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -d, --destroy, '
... |
Create a temporary adminfile based on the keyword arguments passed to
pkg.install. | def _write_adminfile(kwargs):
'''
Create a temporary adminfile based on the keyword arguments passed to
pkg.install.
'''
# Set the adminfile default variables
email = kwargs.get('email', '')
instance = kwargs.get('instance', 'quit')
partial = kwargs.get('partial', 'nocheck')
runlevel... |
List the packages currently installed as a dict:
.. code-block:: python
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs | def list_pkgs(versions_as_list=False, **kwargs):
'''
List the packages currently installed as a dict:
.. code-block:: python
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs
'''
versions_as_list = salt.utils.data.is_true(versions_a... |
Install the passed package. Can install packages from the following
sources:
* Locally (package already exists on the minion
* HTTP/HTTPS server
* FTP server
* Salt master
Returns a dict containing the new package names and versions:
.. code-block:: python
{'<package>': {'old': '... | def install(name=None, sources=None, saltenv='base', **kwargs):
'''
Install the passed package. Can install packages from the following
sources:
* Locally (package already exists on the minion
* HTTP/HTTPS server
* FTP server
* Salt master
Returns a dict containing the new package name... |
Remove packages with pkgrm
name
The name of the package to be deleted
By default salt automatically provides an adminfile, to automate package
removal, with these options set::
email=
instance=quit
partial=nocheck
runlevel=nocheck
idepend=nocheck
rd... | def remove(name=None, pkgs=None, saltenv='base', **kwargs):
'''
Remove packages with pkgrm
name
The name of the package to be deleted
By default salt automatically provides an adminfile, to automate package
removal, with these options set::
email=
instance=quit
par... |
Ensure trail exists.
name
The name of the state definition
Name
Name of the trail.
S3BucketName
Specifies the name of the Amazon S3 bucket designated for publishing log
files.
S3KeyPrefix
Specifies the Amazon S3 key prefix that comes after the name of the
... | def present(name, Name,
S3BucketName, S3KeyPrefix=None,
SnsTopicName=None,
IncludeGlobalServiceEvents=True,
IsMultiRegionTrail=None,
EnableLogFileValidation=False,
CloudWatchLogsLogGroupArn=None,
CloudWatchLogsRoleArn=None,
KmsKeyId... |
Ensure trail with passed properties is absent.
name
The name of the state definition.
Name
Name of the trail.
region
Region to connect to.
key
Secret key to be used.
keyid
Access key to be used.
profile
A dict with region, key and keyid, or a... | def absent(name, Name,
region=None, key=None, keyid=None, profile=None):
'''
Ensure trail with passed properties is absent.
name
The name of the state definition.
Name
Name of the trail.
region
Region to connect to.
key
Secret key to be used.... |
Yield transport, opts for all master configured transports | def iter_transport_opts(opts):
'''
Yield transport, opts for all master configured transports
'''
transports = set()
for transport, opts_overrides in six.iteritems(opts.get('transport_opts', {})):
t_opts = dict(opts)
t_opts.update(opts_overrides)
t_opts['transport'] = transp... |
Only succeed if the value in the given register location is greater or equal
than the given value
USAGE:
.. code-block:: yaml
foo:
check.gte:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | def gte(name, value):
'''
Only succeed if the value in the given register location is greater or equal
than the given value
USAGE:
.. code-block:: yaml
foo:
check.gte:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func:... |
Only succeed if the value in the given register location is greater than
the given value
USAGE:
.. code-block:: yaml
foo:
check.gt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | def gt(name, value):
'''
Only succeed if the value in the given register location is greater than
the given value
USAGE:
.. code-block:: yaml
foo:
check.gt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
... |
Only succeed if the value in the given register location is less than
the given value
USAGE:
.. code-block:: yaml
foo:
check.lt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | def lt(name, value):
'''
Only succeed if the value in the given register location is less than
the given value
USAGE:
.. code-block:: yaml
foo:
check.lt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
... |
Only succeed if the value in the given register location is less than
or equal the given value
USAGE:
.. code-block:: yaml
foo:
check.lte:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | def lte(name, value):
'''
Only succeed if the value in the given register location is less than
or equal the given value
USAGE:
.. code-block:: yaml
foo:
check.lte:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: te... |
Only succeed if the value in the given register location is equal to
the given value
USAGE:
.. code-block:: yaml
foo:
check.eq:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | def eq(name, value):
'''
Only succeed if the value in the given register location is equal to
the given value
USAGE:
.. code-block:: yaml
foo:
check.eq:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
... |
Only succeed if the value in the given register location is not equal to
the given value
USAGE:
.. code-block:: yaml
foo:
check.ne:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | def ne(name, value):
'''
Only succeed if the value in the given register location is not equal to
the given value
USAGE:
.. code-block:: yaml
foo:
check.ne:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
... |
Only succeed if the value in the given register location contains
the given value
USAGE:
.. code-block:: yaml
foo:
check.contains:
- value: itni
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | def contains(name,
value,
count_lt=None,
count_lte=None,
count_eq=None,
count_gte=None,
count_gt=None,
count_ne=None):
'''
Only succeed if the value in the given register location contains
the given value
USAGE:
... |
Chekcs for a specific event match and returns result True if the match
happens
USAGE:
.. code-block:: yaml
salt/foo/*/bar:
check.event
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
- check: salt/foo... | def event(name):
'''
Chekcs for a specific event match and returns result True if the match
happens
USAGE:
.. code-block:: yaml
salt/foo/*/bar:
check.event
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... |
Only succeed if length of the given register location is greater than
the given value.
USAGE:
.. code-block:: yaml
foo:
check.len_gt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test.ping
- require:
... | def len_gt(name, value):
'''
Only succeed if length of the given register location is greater than
the given value.
USAGE:
.. code-block:: yaml
foo:
check.len_gt:
- value: 42
run_remote_ex:
local.cmd:
- tgt: '*'
- func: test... |
Configures users on network devices.
:param users: Dictionary formatted as the output of the function config()
:param test: Dry run? If set as True, will apply the config, discard and
return the changes. Default: False
:param commit: Commit? (default: True) Sometimes it is not needed to commit
... | def set_users(users, test=False, commit=True, **kwargs): # pylint: disable=unused-argument
'''
Configures users on network devices.
:param users: Dictionary formatted as the output of the function config()
:param test: Dry run? If set as True, will apply the config, discard and
return the ch... |
Convert the virtualbox config file values for clone_mode into the integers the API requires | def map_clonemode(vm_info):
"""
Convert the virtualbox config file values for clone_mode into the integers the API requires
"""
mode_map = {
'state': 0,
'child': 1,
'all': 2
}
if not vm_info:
return DEFAULT_CLONE_MODE
if 'clonemode' not in vm_info:
retur... |
Creates a virtual machine from the given VM information
This is what is used to request a virtual machine to be created by the
cloud provider, wait for it to become available, and then (optionally) log
in and install Salt on it.
Events fired:
This function fires the event ``salt/cloud/vm_name/cre... | def create(vm_info):
'''
Creates a virtual machine from the given VM information
This is what is used to request a virtual machine to be created by the
cloud provider, wait for it to become available, and then (optionally) log
in and install Salt on it.
Events fired:
This function fires t... |
All information available about all nodes should be returned in this function.
The fields in the list_nodes() function should also be returned,
even if they would not normally be provided by the cloud provider.
This is because some functions both within Salt and 3rd party will break if an expected field is... | def list_nodes_full(kwargs=None, call=None):
"""
All information available about all nodes should be returned in this function.
The fields in the list_nodes() function should also be returned,
even if they would not normally be provided by the cloud provider.
This is because some functions both wit... |
This function returns a list of nodes available on this cloud provider, using the following fields:
id (str)
image (str)
size (str)
state (str)
private_ips (list)
public_ips (list)
No other fields should be returned in this function, and all of these fields should be returned, even if empt... | def list_nodes(kwargs=None, call=None):
"""
This function returns a list of nodes available on this cloud provider, using the following fields:
id (str)
image (str)
size (str)
state (str)
private_ips (list)
public_ips (list)
No other fields should be returned in this function, and ... |
This function irreversibly destroys a virtual machine on the cloud provider.
Before doing so, it should fire an event on the Salt event bus.
The tag for this event is `salt/cloud/<vm name>/destroying`.
Once the virtual machine has been destroyed, another event is fired.
The tag for that event is `salt/... | def destroy(name, call=None):
"""
This function irreversibly destroys a virtual machine on the cloud provider.
Before doing so, it should fire an event on the Salt event bus.
The tag for this event is `salt/cloud/<vm name>/destroying`.
Once the virtual machine has been destroyed, another event is f... |
Start a machine.
@param name: Machine to start
@type name: str
@param call: Must be "action"
@type call: str | def start(name, call=None):
'''
Start a machine.
@param name: Machine to start
@type name: str
@param call: Must be "action"
@type call: str
'''
if call != 'action':
raise SaltCloudSystemExit(
'The instance action must be called with -a or --action.'
)
lo... |
Stop a running machine.
@param name: Machine to stop
@type name: str
@param call: Must be "action"
@type call: str | def stop(name, call=None):
"""
Stop a running machine.
@param name: Machine to stop
@type name: str
@param call: Must be "action"
@type call: str
"""
if call != 'action':
raise SaltCloudSystemExit(
'The instance action must be called with -a or --action.'
)
... |
Show the details of an image | def show_image(kwargs, call=None):
"""
Show the details of an image
"""
if call != 'function':
raise SaltCloudSystemExit(
'The show_image action must be called with -f or --function.'
)
name = kwargs['image']
log.info("Showing image %s", name)
machine = vb_get_ma... |
Verify that a device is mapped
name
The name under which the device is to be mapped
device
The device name, typically the device node, such as ``/dev/sdb1``
or ``UUID=066e0200-2867-4ebe-b9e6-f30026ca2314``.
keyfile
Either ``None`` if the password is to be entered manually ... | def mapped(name,
device,
keyfile=None,
opts=None,
config='/etc/crypttab',
persist=True,
immediate=False,
match_on='name'):
'''
Verify that a device is mapped
name
The name under which the device is to be mapped
device... |
Ensure that a device is unmapped
name
The name to ensure is not mapped
config
Set an alternative location for the crypttab, if the map is persistent,
Default is ``/etc/crypttab``
persist
Set if the map should be removed from the crypttab. Default is ``True``
immediate... | def unmapped(name,
config='/etc/crypttab',
persist=True,
immediate=False):
'''
Ensure that a device is unmapped
name
The name to ensure is not mapped
config
Set an alternative location for the crypttab, if the map is persistent,
Default is... |
Returns the compiled top data for pillar for a specific minion. If no
minion is specified, we use the first minion we find.
CLI Example:
.. code-block:: bash
salt-run pillar.show_top | def show_top(minion=None, saltenv='base'):
'''
Returns the compiled top data for pillar for a specific minion. If no
minion is specified, we use the first minion we find.
CLI Example:
.. code-block:: bash
salt-run pillar.show_top
'''
id_, grains, _ = salt.utils.minions.get_minion... |
Returns the compiled pillar either of a specific minion
or just the global available pillars. This function assumes
that no minion has the id ``*``.
Function also accepts pillarenv as attribute in order to limit to a specific pillar branch of git
CLI Example:
shows minion specific pillar:
.. ... | def show_pillar(minion='*', **kwargs):
'''
Returns the compiled pillar either of a specific minion
or just the global available pillars. This function assumes
that no minion has the id ``*``.
Function also accepts pillarenv as attribute in order to limit to a specific pillar branch of git
CLI E... |
Install RVM system-wide
runas
The user under which to run the rvm installer script. If not specified,
then it be run as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.install | def install(runas=None):
'''
Install RVM system-wide
runas
The user under which to run the rvm installer script. If not specified,
then it be run as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.install
'''
# RVM dependencies... |
Install a ruby implementation.
ruby
The version of ruby to install
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
env
Environment to set for the install command. Useful for exporting compilation
... | def install_ruby(ruby, runas=None, opts=None, env=None):
'''
Install a ruby implementation.
ruby
The version of ruby to install
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
env
Environment to... |
Reinstall a ruby implementation
ruby
The version of ruby to reinstall
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.reinstall_ruby 1.9.3-p385 | def reinstall_ruby(ruby, runas=None, env=None):
'''
Reinstall a ruby implementation
ruby
The version of ruby to reinstall
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:... |
List all rvm-installed rubies
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.list | def list_(runas=None):
'''
List all rvm-installed rubies
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.list
'''
rubies = []
output = _rvm(['... |
Install RVM wrapper scripts
ruby_string
Ruby/gemset to install wrappers for
wrapper_prefix
What to prepend to the name of the generated wrapper binaries
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
... | def wrapper(ruby_string, wrapper_prefix, runas=None, *binaries):
'''
Install RVM wrapper scripts
ruby_string
Ruby/gemset to install wrappers for
wrapper_prefix
What to prepend to the name of the generated wrapper binaries
runas
The user under which to run rvm. If not speci... |
List all gemsets for the given ruby.
ruby : default
The ruby version for which to list the gemsets
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.ge... | def gemset_list(ruby='default', runas=None):
'''
List all gemsets for the given ruby.
ruby : default
The ruby version for which to list the gemsets
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Ex... |
List all gemsets for all installed rubies.
Note that you must have set a default ruby before this can work.
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
.. code-block:: bash
salt '*' rvm.g... | def gemset_list_all(runas=None):
'''
List all gemsets for all installed rubies.
Note that you must have set a default ruby before this can work.
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
CLI Example:
... |
Execute a command in an RVM controlled environment.
ruby
Which ruby to use
command
The rvm command to execute
runas
The user under which to run rvm. If not specified, then rvm will be run
as the user under which Salt is running.
cwd
The directory from which to... | def do(ruby, command, runas=None, cwd=None, env=None): # pylint: disable=C0103
'''
Execute a command in an RVM controlled environment.
ruby
Which ruby to use
command
The rvm command to execute
runas
The user under which to run rvm. If not specified, then rvm will be run
... |
Read a file on the file system (relative to salt's base project dir)
:returns: A file-like object.
:raises IOError: If the file cannot be found or read. | def parse_file(self, fpath):
'''
Read a file on the file system (relative to salt's base project dir)
:returns: A file-like object.
:raises IOError: If the file cannot be found or read.
'''
sdir = os.path.abspath(os.path.join(os.path.dirname(salt.__file__),
... |
Parse a string line-by-line delineating comments and code
:returns: An tuple of boolean/list-of-string pairs. True designates a
comment; False designates code. | def parse_lit(self, lines):
'''
Parse a string line-by-line delineating comments and code
:returns: An tuple of boolean/list-of-string pairs. True designates a
comment; False designates code.
'''
comment_char = '#' # TODO: move this into a directive option
co... |
Given a typical Salt SLS path (e.g.: apache.vhosts.standard), find the
file on the file system and parse it | def parse_file(self, sls_path):
'''
Given a typical Salt SLS path (e.g.: apache.vhosts.standard), find the
file on the file system and parse it
'''
config = self.state.document.settings.env.config
formulas_dirs = config.formulas_dirs
fpath = sls_path.replace('.', ... |
Return the minions found by looking via pillar | def mmatch(expr, delimiter, greedy, opts=None):
'''
Return the minions found by looking via pillar
'''
if not opts:
opts = __opts__
ckminions = salt.utils.minions.CkMinions(opts)
return ckminions._check_compound_minions(expr, delimiter, greedy,
... |
Access/write a SysFS attribute.
If the attribute is a symlink, it's destination is returned
:return: value or bool
CLI example:
.. code-block:: bash
salt '*' sysfs.attr block/sda/queue/logical_block_size | def attr(key, value=None):
'''
Access/write a SysFS attribute.
If the attribute is a symlink, it's destination is returned
:return: value or bool
CLI example:
.. code-block:: bash
salt '*' sysfs.attr block/sda/queue/logical_block_size
'''
key = target(key)
if key is Fals... |
Write a SysFS attribute/action
CLI example:
.. code-block:: bash
salt '*' sysfs.write devices/system/cpu/cpu0/cpufreq/scaling_governor 'performance' | def write(key, value):
'''
Write a SysFS attribute/action
CLI example:
.. code-block:: bash
salt '*' sysfs.write devices/system/cpu/cpu0/cpufreq/scaling_governor 'performance'
'''
try:
key = target(key)
log.trace('Writing %s to %s', value, key)
with salt.utils.... |
Read from SysFS
:param key: file or path in SysFS; if key is a list then root will be prefixed on each key
:return: the full (tree of) SysFS attributes under key
CLI example:
.. code-block:: bash
salt '*' sysfs.read class/net/em1/statistics | def read(key, root=''):
'''
Read from SysFS
:param key: file or path in SysFS; if key is a list then root will be prefixed on each key
:return: the full (tree of) SysFS attributes under key
CLI example:
.. code-block:: bash
salt '*' sysfs.read class/net/em1/statistics
'''
i... |
Return the basename of a SysFS key path
:param key: the location to resolve within SysFS
:param full: full path instead of basename
:return: fullpath or basename of path
CLI example:
.. code-block:: bash
salt '*' sysfs.read class/ttyS0 | def target(key, full=True):
'''
Return the basename of a SysFS key path
:param key: the location to resolve within SysFS
:param full: full path instead of basename
:return: fullpath or basename of path
CLI example:
.. code-block:: bash
salt '*' sysfs.read class/ttyS0
'''
... |
Generate a dictionary with all available interfaces relative to root.
Symlinks are not followed.
CLI example:
.. code-block:: bash
salt '*' sysfs.interfaces block/bcache0/bcache
Output example:
.. code-block:: json
{
"r": [
"state",
"partial_str... | def interfaces(root):
'''
Generate a dictionary with all available interfaces relative to root.
Symlinks are not followed.
CLI example:
.. code-block:: bash
salt '*' sysfs.interfaces block/bcache0/bcache
Output example:
.. code-block:: json
{
"r": [
... |
Return a Librato connection object. | def _get_librato(ret=None):
'''
Return a Librato connection object.
'''
_options = _get_options(ret)
conn = librato.connect(
_options.get('email'),
_options.get('api_token'),
sanitizer=librato.sanitize_metric_name,
hostname=_options.get('api_url'))
log.info("Conn... |
Parse the return data and return metrics to Librato. | def returner(ret):
'''
Parse the return data and return metrics to Librato.
'''
librato_conn = _get_librato(ret)
q = librato_conn.new_queue()
if ret['fun'] == 'state.highstate':
log.debug('Found returned Highstate data.')
# Calculate the runtimes and number of failed states.
... |
Returns: tuple whose first element is a bool indicating success or failure
and the second element is either a ret dict for salt or an object | def _common(ret, name, service_name, kwargs):
'''
Returns: tuple whose first element is a bool indicating success or failure
and the second element is either a ret dict for salt or an object
'''
if 'interface' not in kwargs and 'public_url' not in kwargs:
kwargs['interface'] = name
... |
Ensure an endpoint exists and is up-to-date
name
Interface name
url
URL of the endpoint
service_name
Service name or ID
region
The region name to assign the endpoint
enabled
Boolean to control if endpoint is enabled | def present(name, service_name, auth=None, **kwargs):
'''
Ensure an endpoint exists and is up-to-date
name
Interface name
url
URL of the endpoint
service_name
Service name or ID
region
The region name to assign the endpoint
enabled
Boolean to cont... |
Ensure an endpoint does not exists
name
Interface name
url
URL of the endpoint
service_name
Service name or ID
region
The region name to assign the endpoint | def absent(name, service_name, auth=None, **kwargs):
'''
Ensure an endpoint does not exists
name
Interface name
url
URL of the endpoint
service_name
Service name or ID
region
The region name to assign the endpoint
'''
ret = {'name': name,
'c... |
Return the bgp runner options. | def _get_bgp_runner_opts():
'''
Return the bgp runner options.
'''
runner_opts = __opts__.get('runners', {}).get('bgp', {})
return {
'tgt': runner_opts.get('tgt', _DEFAULT_TARGET),
'tgt_type': runner_opts.get('tgt_type', _DEFAULT_EXPR_FORM),
'display': runner_opts.get('displa... |
Compare two dictionaries and return a boolean value if their values match. | def _compare_match(dict1, dict2):
'''
Compare two dictionaries and return a boolean value if their values match.
'''
for karg, warg in six.iteritems(dict1):
if karg in dict2 and dict2[karg] != warg:
return False
return True |
Display or return the rows. | def _display_runner(rows,
labels,
title,
display=_DEFAULT_DISPLAY,
outputter=_DEFAULT_OUTPUTTER):
'''
Display or return the rows.
'''
if display:
if outputter == 'table':
ret = salt.output.out_format({'ro... |
Search for BGP neighbors details in the mines of the ``bgp.neighbors`` function.
Arguments:
asns
A list of AS numbers to search for.
The runner will return only the neighbors of these AS numbers.
device
Filter by device name (minion ID).
ip
Search BGP neighbor using t... | def neighbors(*asns, **kwargs):
'''
Search for BGP neighbors details in the mines of the ``bgp.neighbors`` function.
Arguments:
asns
A list of AS numbers to search for.
The runner will return only the neighbors of these AS numbers.
device
Filter by device name (minion ID).... |
Return a mongodb connection object | def _get_conn(ret):
'''
Return a mongodb connection object
'''
_options = _get_options(ret)
host = _options.get('host')
port = _options.get('port')
uri = _options.get('uri')
db_ = _options.get('db')
user = _options.get('user')
password = _options.get('password')
indexes = _o... |
Return data to a mongodb server | def returner(ret):
'''
Return data to a mongodb server
'''
conn, mdb = _get_conn(ret)
if isinstance(ret['return'], dict):
back = _remove_dots(ret['return'])
else:
back = ret['return']
if isinstance(ret, dict):
full_ret = _remove_dots(ret)
else:
full_ret ... |
mongodb doesn't allow '.' in keys, but does allow unicode equivs.
Apparently the docs suggest using escaped unicode full-width
encodings. *sigh*
\\ --> \\\\
$ --> \\\\u0024
. --> \\\\u002e
Personally, I prefer URL encodings,
\\ --> %5c
... | def _safe_copy(dat):
''' mongodb doesn't allow '.' in keys, but does allow unicode equivs.
Apparently the docs suggest using escaped unicode full-width
encodings. *sigh*
\\ --> \\\\
$ --> \\\\u0024
. --> \\\\u002e
Personally, I prefer URL encoding... |
Return the load associated with a given job id | def get_load(jid):
'''
Return the load associated with a given job id
'''
conn, mdb = _get_conn(ret=None)
return mdb.jobs.find_one({'jid': jid}, {'_id': 0}) |
Save the load for a given job id | def save_load(jid, load, minions=None):
'''
Save the load for a given job id
'''
conn, mdb = _get_conn(ret=None)
to_save = _safe_copy(load)
if PYMONGO_VERSION > _LooseVersion('2.3'):
#using .copy() to ensure original data for load is unchanged
mdb.jobs.insert_one(to_save)
el... |
Return a list of minions | def get_minions():
'''
Return a list of minions
'''
conn, mdb = _get_conn(ret=None)
ret = []
name = mdb.saltReturns.distinct('minion')
ret.append(name)
return ret |
Return a list of job ids | def get_jids():
'''
Return a list of job ids
'''
conn, mdb = _get_conn(ret=None)
map = "function() { emit(this.jid, this); }"
reduce = "function (key, values) { return values[0]; }"
result = mdb.jobs.inline_map_reduce(map, reduce)
ret = {}
for r in result:
jid = r['_id']
... |
Return events to Mongodb server | def event_return(events):
'''
Return events to Mongodb server
'''
conn, mdb = _get_conn(ret=None)
if isinstance(events, list):
events = events[0]
if isinstance(events, dict):
log.debug(events)
if PYMONGO_VERSION > _LooseVersion('2.3'):
mdb.events.insert_one... |
Create a list of file ref objects to reconcile | def lowstate_file_refs(chunks):
'''
Create a list of file ref objects to reconcile
'''
refs = {}
for chunk in chunks:
saltenv = 'base'
crefs = []
for state in chunk:
if state == '__env__':
saltenv = chunk[state]
elif state == 'saltenv':... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.