repository_name
stringclasses
316 values
func_path_in_repository
stringlengths
6
223
func_name
stringlengths
1
134
language
stringclasses
1 value
func_code_string
stringlengths
57
65.5k
func_documentation_string
stringlengths
1
46.3k
split_name
stringclasses
1 value
func_code_url
stringlengths
91
315
called_functions
listlengths
1
156
enclosing_scope
stringlengths
2
1.48M
saltstack/salt
salt/modules/nilrt_ip.py
get_interfaces_details
python
def get_interfaces_details(): ''' Get details about all the interfaces on the minion :return: information about all interfaces omitting loopback :rtype: dictionary CLI Example: .. code-block:: bash salt '*' ip.get_interfaces_details ''' _interfaces = [interface for interface ...
Get details about all the interfaces on the minion :return: information about all interfaces omitting loopback :rtype: dictionary CLI Example: .. code-block:: bash salt '*' ip.get_interfaces_details
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L494-L512
null
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
_change_state_legacy
python
def _change_state_legacy(interface, new_state): ''' Enable or disable an interface on a legacy distro Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot. :param interface: interface label :param new_state: up or down :return: True if the service w...
Enable or disable an interface on a legacy distro Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot. :param interface: interface label :param new_state: up or down :return: True if the service was enabled, otherwise an exception will be thrown. :rtyp...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L515-L536
null
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
_change_state
python
def _change_state(interface, new_state): ''' Enable or disable an interface Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot. :param interface: interface label :param new_state: up or down :return: True if the service was enabled, otherwise an e...
Enable or disable an interface Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot. :param interface: interface label :param new_state: up or down :return: True if the service was enabled, otherwise an exception will be thrown. :rtype: bool
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L539-L564
[ "def _connected(service):\n '''\n Verify if a connman service is connected\n '''\n state = pyconnman.ConnService(os.path.join(SERVICE_PATH, service)).get_property('State')\n return state == 'online' or state == 'ready'\n", "def _interface_to_service(iface):\n '''\n returns the coresponding se...
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
_save_config
python
def _save_config(section, token, value): ''' Helper function to persist a configuration in the ini file ''' cmd = NIRTCFG_PATH cmd += ' --set section={0},token=\'{1}\',value=\'{2}\''.format(section, token, value) if __salt__['cmd.run_all'](cmd)['retcode'] != 0: exc_msg = 'Error: could no...
Helper function to persist a configuration in the ini file
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L643-L651
null
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
set_ethercat
python
def set_ethercat(interface, master_id): ''' Configure specified adapter to use EtherCAT adapter mode. If successful, the target will need reboot if it doesn't already use EtherCAT adapter mode, otherwise will return true. :param interface: interface label :param master_id: EtherCAT Master ID :r...
Configure specified adapter to use EtherCAT adapter mode. If successful, the target will need reboot if it doesn't already use EtherCAT adapter mode, otherwise will return true. :param interface: interface label :param master_id: EtherCAT Master ID :return: True if the settings were applied, otherwise ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L654-L676
[ "def _get_adapter_mode_info(interface):\n '''\n return adaptermode for given interface\n '''\n mode = _load_config(interface, ['mode'])['mode'].lower()\n return mode if mode in ['disabled', 'ethercat'] else 'tcpip'\n", "def _save_config(section, token, value):\n '''\n Helper function to persi...
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
set_dhcp_linklocal_all
python
def set_dhcp_linklocal_all(interface): ''' Configure specified adapter to use DHCP with linklocal fallback Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot. :param str interface: interface label :return: True if the settings were applied, otherwise ...
Configure specified adapter to use DHCP with linklocal fallback Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot. :param str interface: interface label :return: True if the settings were applied, otherwise an exception will be thrown. :rtype: bool ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L687-L728
[ "def _interface_to_service(iface):\n '''\n returns the coresponding service to given interface if exists, otherwise return None\n '''\n for _service in _get_services():\n service_info = pyconnman.ConnService(os.path.join(SERVICE_PATH, _service))\n if service_info.get_property('Ethernet')['...
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
set_dhcp_only_all
python
def set_dhcp_only_all(interface): ''' Configure specified adapter to use DHCP only Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot. :param str interface: interface label :return: True if the settings were applied, otherwise an exception will be thr...
Configure specified adapter to use DHCP only Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot. :param str interface: interface label :return: True if the settings were applied, otherwise an exception will be thrown. :rtype: bool CLI Example: ....
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L731-L757
[ "def _get_adapter_mode_info(interface):\n '''\n return adaptermode for given interface\n '''\n mode = _load_config(interface, ['mode'])['mode'].lower()\n return mode if mode in ['disabled', 'ethercat'] else 'tcpip'\n", "def _save_config(section, token, value):\n '''\n Helper function to persi...
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
_configure_static_interface
python
def _configure_static_interface(interface, **settings): ''' Configure an interface that is not detected as a service by Connman (i.e. link is down) :param interface: interface label :param settings: - ip - netmask - gateway - dns - name :r...
Configure an interface that is not detected as a service by Connman (i.e. link is down) :param interface: interface label :param settings: - ip - netmask - gateway - dns - name :return: True if settings were applied successfully. :rtype: bool
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L789-L828
null
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
set_static_all
python
def set_static_all(interface, address, netmask, gateway, nameservers=None): ''' Configure specified adapter to use ipv4 manual settings Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot. :param str interface: interface label :param str address: ipv4 ...
Configure specified adapter to use ipv4 manual settings Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot. :param str interface: interface label :param str address: ipv4 address :param str netmask: ipv4 netmask :param str gateway: ipv4 gateway :p...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L831-L895
[ "def _space_delimited_list(value):\n '''\n validate that a value contains one or more space-delimited values\n '''\n if isinstance(value, six.string_types):\n items = value.split(' ')\n valid = items and all(items)\n else:\n valid = hasattr(value, '__iter__') and (value != [])\n\...
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
get_interface
python
def get_interface(iface): ''' Returns details about given interface. CLI Example: .. code-block:: bash salt '*' ip.get_interface eth0 ''' _interfaces = get_interfaces_details() for _interface in _interfaces['interfaces']: if _interface['connectionid'] == iface: ...
Returns details about given interface. CLI Example: .. code-block:: bash salt '*' ip.get_interface eth0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L898-L912
[ "def _dict_to_string(dictionary):\n '''\n converts a dictionary object into a list of strings\n '''\n ret = ''\n for key, val in sorted(dictionary.items()):\n if isinstance(val, dict):\n for line in _dict_to_string(val):\n ret += six.text_type(key) + '-' + line + '\\n...
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
build_interface
python
def build_interface(iface, iface_type, enabled, **settings): ''' Build an interface script for a network interface. CLI Example: .. code-block:: bash salt '*' ip.build_interface eth0 eth <settings> ''' if __grains__['lsb_distrib_id'] == 'nilrt': raise salt.exceptions.CommandEx...
Build an interface script for a network interface. CLI Example: .. code-block:: bash salt '*' ip.build_interface eth0 eth <settings>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L915-L948
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def up(interface, iface_type=None): # pylint: disable=invalid-name,unused-argument\n '''\n Enable the specified interface\n\n Change adapter mode to TCP/IP. If previous adapter mode was EtherCAT, the target will need reboot.\n\n :param str i...
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
build_network_settings
python
def build_network_settings(**settings): ''' Build the global network script. CLI Example: .. code-block:: bash salt '*' ip.build_network_settings <settings> ''' if __grains__['lsb_distrib_id'] == 'nilrt': raise salt.exceptions.CommandExecutionError('Not supported in this versi...
Build the global network script. CLI Example: .. code-block:: bash salt '*' ip.build_network_settings <settings>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L951-L978
null
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
get_network_settings
python
def get_network_settings(): ''' Return the contents of the global network script. CLI Example: .. code-block:: bash salt '*' ip.get_network_settings ''' if __grains__['lsb_distrib_id'] == 'nilrt': raise salt.exceptions.CommandExecutionError('Not supported in this version.') ...
Return the contents of the global network script. CLI Example: .. code-block:: bash salt '*' ip.get_network_settings
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L981-L998
[ "def _get_state():\n '''\n Returns the state of connman\n '''\n try:\n return pyconnman.ConnManager().get_property('State')\n except KeyError:\n return 'offline'\n except dbus.DBusException as exc:\n raise salt.exceptions.CommandExecutionError('Connman daemon error: {0}'.forma...
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/modules/nilrt_ip.py
apply_network_settings
python
def apply_network_settings(**settings): ''' Apply global network configuration. CLI Example: .. code-block:: bash salt '*' ip.apply_network_settings ''' if __grains__['lsb_distrib_id'] == 'nilrt': raise salt.exceptions.CommandExecutionError('Not supported in this version.') ...
Apply global network configuration. CLI Example: .. code-block:: bash salt '*' ip.apply_network_settings
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/nilrt_ip.py#L1001-L1042
null
# -*- coding: utf-8 -*- ''' The networking module for NI Linux Real-Time distro ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import time import os import re # Import salt libs import salt.exceptions import salt.utils.files import salt.utils.validate...
saltstack/salt
salt/utils/event.py
get_event
python
def get_event( node, sock_dir=None, transport='zeromq', opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False): ''' Return an event object suitable for the named transport :param IOLoop io_loop: Pass in an io_loop if you want asynchronous opera...
Return an event object suitable for the named transport :param IOLoop io_loop: Pass in an io_loop if you want asynchronous operation for obtaining events. Eg use of set_event_handler() API. Otherwise, operation will be synchronous.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L119-L145
null
# -*- coding: utf-8 -*- ''' Manage events Events are all fired off via a zeromq 'pub' socket, and listened to with local zeromq 'sub' sockets All of the formatting is self contained in the event module, so we should be able to modify the structure in the future since the same module used to read events is the same m...
saltstack/salt
salt/utils/event.py
get_master_event
python
def get_master_event(opts, sock_dir, listen=True, io_loop=None, raise_errors=False, keep_loop=False): ''' Return an event object suitable for the named transport ''' # TODO: AIO core is separate from transport if opts['transport'] in ('zeromq', 'tcp', 'detect'): return MasterEvent(sock_dir, ...
Return an event object suitable for the named transport
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L148-L154
null
# -*- coding: utf-8 -*- ''' Manage events Events are all fired off via a zeromq 'pub' socket, and listened to with local zeromq 'sub' sockets All of the formatting is self contained in the event module, so we should be able to modify the structure in the future since the same module used to read events is the same m...
saltstack/salt
salt/utils/event.py
fire_args
python
def fire_args(opts, jid, tag_data, prefix=''): ''' Fire an event containing the arguments passed to an orchestration job ''' try: tag_suffix = [jid, 'args'] except NameError: pass else: tag = tagify(tag_suffix, prefix) try: _event = get_master_event(op...
Fire an event containing the arguments passed to an orchestration job
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L157-L175
[ "def get_master_event(opts, sock_dir, listen=True, io_loop=None, raise_errors=False, keep_loop=False):\n '''\n Return an event object suitable for the named transport\n '''\n # TODO: AIO core is separate from transport\n if opts['transport'] in ('zeromq', 'tcp', 'detect'):\n return MasterEvent...
# -*- coding: utf-8 -*- ''' Manage events Events are all fired off via a zeromq 'pub' socket, and listened to with local zeromq 'sub' sockets All of the formatting is self contained in the event module, so we should be able to modify the structure in the future since the same module used to read events is the same m...
saltstack/salt
salt/utils/event.py
tagify
python
def tagify(suffix='', prefix='', base=SALT): ''' convenience function to build a namespaced event tag string from joining with the TABPART character the base, prefix and suffix If string prefix is a valid key in TAGS Then use the value of key prefix Else use prefix string If suffix is a list T...
convenience function to build a namespaced event tag string from joining with the TABPART character the base, prefix and suffix If string prefix is a valid key in TAGS Then use the value of key prefix Else use prefix string If suffix is a list Then join all string elements of suffix individually E...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L178-L201
[ "def to_str(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str, bytes, bytearray, or unicode (py2), return str\n '''\n def _normalize(s):\n try:\n return unicodedata.normalize('NFC', s) if normalize else s\n except TypeError:\n return s\n\n if e...
# -*- coding: utf-8 -*- ''' Manage events Events are all fired off via a zeromq 'pub' socket, and listened to with local zeromq 'sub' sockets All of the formatting is self contained in the event module, so we should be able to modify the structure in the future since the same module used to read events is the same m...
saltstack/salt
salt/utils/event.py
update_stats
python
def update_stats(stats, start_time, data): ''' Calculate the master stats and return the updated stat info ''' end_time = time.time() cmd = data['cmd'] # the jid is used as the create time try: jid = data['jid'] except KeyError: try: jid = data['data']['__pub_...
Calculate the master stats and return the updated stat info
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L204-L227
null
# -*- coding: utf-8 -*- ''' Manage events Events are all fired off via a zeromq 'pub' socket, and listened to with local zeromq 'sub' sockets All of the formatting is self contained in the event module, so we should be able to modify the structure in the future since the same module used to read events is the same m...
saltstack/salt
salt/utils/event.py
SaltEvent.__load_uri
python
def __load_uri(self, sock_dir, node): ''' Return the string URI for the location of the pull and pub sockets to use for firing and listening to events ''' if node == 'master': if self.opts['ipc_mode'] == 'tcp': puburi = int(self.opts['tcp_master_pub_po...
Return the string URI for the location of the pull and pub sockets to use for firing and listening to events
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L302-L339
null
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.subscribe
python
def subscribe(self, tag=None, match_type=None): ''' Subscribe to events matching the passed tag. If you do not subscribe to a tag, events will be discarded by calls to get_event that request a different tag. In contexts where many different jobs are outstanding it is important t...
Subscribe to events matching the passed tag. If you do not subscribe to a tag, events will be discarded by calls to get_event that request a different tag. In contexts where many different jobs are outstanding it is important to subscribe to prevent one call to get_event from discarding...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L341-L354
[ "def _get_match_func(self, match_type=None):\n if match_type is None:\n match_type = self.opts['event_match_type']\n return getattr(self, '_match_tag_{0}'.format(match_type), None)\n" ]
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.unsubscribe
python
def unsubscribe(self, tag, match_type=None): ''' Un-subscribe to events matching the passed tag. ''' if tag is None: return match_func = self._get_match_func(match_type) self.pending_tags.remove([tag, match_func]) old_events = self.pending_events ...
Un-subscribe to events matching the passed tag.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L356-L370
[ "def _get_match_func(self, match_type=None):\n if match_type is None:\n match_type = self.opts['event_match_type']\n return getattr(self, '_match_tag_{0}'.format(match_type), None)\n" ]
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.connect_pub
python
def connect_pub(self, timeout=None): ''' Establish the publish connection ''' if self.cpub: return True if self._run_io_loop_sync: with salt.utils.asynchronous.current_ioloop(self.io_loop): if self.subscriber is None: s...
Establish the publish connection
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L372-L402
null
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.close_pub
python
def close_pub(self): ''' Close the publish connection (if established) ''' if not self.cpub: return self.subscriber.close() self.subscriber = None self.pending_events = [] self.cpub = False
Close the publish connection (if established)
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L404-L414
[ "def close(self):\n '''\n Routines to handle any cleanup before the instance shuts down.\n Sockets and filehandles should be closed explicitly, to prevent\n leaks.\n '''\n if not self._closing:\n IPCClient.close(self)\n if self._closing:\n # This will prevent this message ...
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.connect_pull
python
def connect_pull(self, timeout=1): ''' Establish a connection with the event pull socket Default timeout is 1 s ''' if self.cpush: return True if self._run_io_loop_sync: with salt.utils.asynchronous.current_ioloop(self.io_loop): if...
Establish a connection with the event pull socket Default timeout is 1 s
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L416-L446
null
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent._check_pending
python
def _check_pending(self, tag, match_func=None): if match_func is None: match_func = self._get_match_func() old_events = self.pending_events self.pending_events = [] ret = None for evt in old_events: if match_func(evt['tag'], tag): if ret is...
Check the pending_events list for events that match the tag :param tag: The tag to search for :type tag: str :param tags_regex: List of re expressions to search for also :type tags_regex: list[re.compile()] :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L467-L492
[ "def _get_match_func(self, match_type=None):\n if match_type is None:\n match_type = self.opts['event_match_type']\n return getattr(self, '_match_tag_{0}'.format(match_type), None)\n" ]
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent._match_tag_regex
python
def _match_tag_regex(self, event_tag, search_tag): ''' Check if the event_tag matches the search check. Uses regular expression search to check. Return True (matches) or False (no match) ''' return self.cache_regex.get(search_tag).search(event_tag) is not None
Check if the event_tag matches the search check. Uses regular expression search to check. Return True (matches) or False (no match)
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L521-L527
null
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.get_event
python
def get_event(self, wait=5, tag='', full=False, match_type=None, no_block=False, auto_reconnect=False): ''' Get a single publication. If no publication is available, then block for up to `...
Get a single publication. If no publication is available, then block for up to ``wait`` seconds. Return publication if it is available or ``None`` if no publication is available. If wait is 0, then block forever. tag Only return events matching the given tag. If not...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L590-L667
[ "def connect_pub(self, timeout=None):\n '''\n Establish the publish connection\n '''\n if self.cpub:\n return True\n\n if self._run_io_loop_sync:\n with salt.utils.asynchronous.current_ioloop(self.io_loop):\n if self.subscriber is None:\n self.subscriber = salt...
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.get_event_noblock
python
def get_event_noblock(self): ''' Get the raw event without blocking or any other niceties ''' assert self._run_io_loop_sync if not self.cpub: if not self.connect_pub(): return None raw = self.subscriber.read_sync(timeout=0) if raw is N...
Get the raw event without blocking or any other niceties
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L669-L682
[ "def connect_pub(self, timeout=None):\n '''\n Establish the publish connection\n '''\n if self.cpub:\n return True\n\n if self._run_io_loop_sync:\n with salt.utils.asynchronous.current_ioloop(self.io_loop):\n if self.subscriber is None:\n self.subscriber = salt...
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.iter_events
python
def iter_events(self, tag='', full=False, match_type=None, auto_reconnect=False): ''' Creates a generator that continuously listens for events ''' while True: data = self.get_event(tag=tag, full=full, match_type=match_type, auto_reconnect=aut...
Creates a generator that continuously listens for events
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L700-L709
[ "def get_event(self,\n wait=5,\n tag='',\n full=False,\n match_type=None,\n no_block=False,\n auto_reconnect=False):\n '''\n Get a single publication.\n If no publication is available, then block for up to ``wait`` seconds.\n ...
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.fire_event
python
def fire_event(self, data, tag, timeout=1000): ''' Send a single event into the publisher with payload dict "data" and event identifier "tag" The default is 1000 ms ''' if not six.text_type(tag): # no empty tags allowed raise ValueError('Empty tag.') ...
Send a single event into the publisher with payload dict "data" and event identifier "tag" The default is 1000 ms
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L711-L767
[ "def trim_dict(\n data,\n max_dict_bytes,\n percent=50.0,\n stepper_size=10,\n replace_with='VALUE_TRIMMED',\n is_msgpacked=False,\n use_bin_type=False):\n '''\n Takes a dictionary and iterates over its keys, looking for\n large values and replacing them wit...
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.fire_master
python
def fire_master(self, data, tag, timeout=1000): '''' Send a single event to the master, with the payload "data" and the event identifier "tag". Default timeout is 1000ms ''' msg = { 'tag': tag, 'data': data, 'events': None, ...
Send a single event to the master, with the payload "data" and the event identifier "tag". Default timeout is 1000ms
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L769-L782
[ "def fire_event(self, data, tag, timeout=1000):\n '''\n Send a single event into the publisher with payload dict \"data\" and\n event identifier \"tag\"\n\n The default is 1000 ms\n '''\n if not six.text_type(tag): # no empty tags allowed\n raise ValueError('Empty tag.')\n\n if not isin...
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent._fire_ret_load_specific_fun
python
def _fire_ret_load_specific_fun(self, load, fun_index=0): ''' Helper function for fire_ret_load ''' if isinstance(load['fun'], list): # Multi-function job fun = load['fun'][fun_index] # 'retcode' was already validated to exist and be non-zero ...
Helper function for fire_ret_load
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L792-L844
null
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.fire_ret_load
python
def fire_ret_load(self, load): ''' Fire events based on information in the return load ''' if load.get('retcode') and load.get('fun'): if isinstance(load['fun'], list): # Multi-function job if isinstance(load['retcode'], list): ...
Fire events based on information in the return load
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L846-L874
null
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
SaltEvent.set_event_handler
python
def set_event_handler(self, event_handler): ''' Invoke the event_handler callback each time an event arrives. ''' assert not self._run_io_loop_sync if not self.cpub: self.connect_pub() self.subscriber.callbacks.add(event_handler) if not self.subscrib...
Invoke the event_handler callback each time an event arrives.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L880-L892
[ "def connect_pub(self, timeout=None):\n '''\n Establish the publish connection\n '''\n if self.cpub:\n return True\n\n if self._run_io_loop_sync:\n with salt.utils.asynchronous.current_ioloop(self.io_loop):\n if self.subscriber is None:\n self.subscriber = salt...
class SaltEvent(object): ''' Warning! Use the get_event function or the code will not be RAET compatible The base class used to manage salt events ''' def __init__( self, node, sock_dir=None, opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=...
saltstack/salt
salt/utils/event.py
EventPublisher.run
python
def run(self): ''' Bind the pub and pull sockets for events ''' salt.utils.process.appendproctitle(self.__class__.__name__) self.io_loop = tornado.ioloop.IOLoop() with salt.utils.asynchronous.current_ioloop(self.io_loop): if self.opts['ipc_mode'] == 'tcp': ...
Bind the pub and pull sockets for events
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1100-L1147
[ "def appendproctitle(name):\n '''\n Append \"name\" to the current process title\n '''\n if HAS_SETPROCTITLE:\n setproctitle.setproctitle(setproctitle.getproctitle() + ' ' + name)\n", "def start(self):\n '''\n Perform the work necessary to start up a Tornado IPC server\n\n Blocks until...
class EventPublisher(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' The interface that takes master events and republishes them out to anyone who wants to listen ''' def __init__(self, opts, **kwargs): super(EventPublisher, self).__init__(**kwargs) self.opts = salt.con...
saltstack/salt
salt/utils/event.py
EventPublisher.handle_publish
python
def handle_publish(self, package, _): ''' Get something from epull, publish it out epub, and return the package (or None) ''' try: self.publisher.publish(package) return package # Add an extra fallback in case a forked process leeks through except ...
Get something from epull, publish it out epub, and return the package (or None)
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1149-L1160
null
class EventPublisher(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' The interface that takes master events and republishes them out to anyone who wants to listen ''' def __init__(self, opts, **kwargs): super(EventPublisher, self).__init__(**kwargs) self.opts = salt.con...
saltstack/salt
salt/utils/event.py
EventReturn.run
python
def run(self): ''' Spin up the multiprocess event returner ''' salt.utils.process.appendproctitle(self.__class__.__name__) self.event = get_event('master', opts=self.opts, listen=True) events = self.event.iter_events(full=True) self.event.fire_event({}, 'salt/even...
Spin up the multiprocess event returner
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1270-L1290
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
class EventReturn(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A dedicated process which listens to the master event bus and queues and forwards events to the specified returner. ''' def __new__(cls, *args, **kwargs): if sys.platform.startswith('win'): # This is ...
saltstack/salt
salt/utils/event.py
EventReturn._filter
python
def _filter(self, event): ''' Take an event and run it through configured filters. Returns True if event should be stored, else False ''' tag = event['tag'] if self.opts['event_return_whitelist']: ret = False else: ret = True for w...
Take an event and run it through configured filters. Returns True if event should be stored, else False
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1292-L1311
null
class EventReturn(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A dedicated process which listens to the master event bus and queues and forwards events to the specified returner. ''' def __new__(cls, *args, **kwargs): if sys.platform.startswith('win'): # This is ...
saltstack/salt
salt/utils/event.py
StateFire.fire_master
python
def fire_master(self, data, tag, preload=None): ''' Fire an event off on the master server CLI Example: .. code-block:: bash salt '*' event.fire_master 'stuff to be in the event' 'tag' ''' load = {} if preload: load.update(preload) ...
Fire an event off on the master server CLI Example: .. code-block:: bash salt '*' event.fire_master 'stuff to be in the event' 'tag'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1327-L1356
[ "def factory(opts, **kwargs):\n # All Sync interfaces are just wrappers around the Async ones\n sync = SyncWrapper(AsyncReqChannel.factory, (opts,), kwargs)\n return sync\n" ]
class StateFire(object): ''' Evaluate the data from a state run and fire events on the master and minion for each returned chunk that is not "green" This object is made to only run on a minion ''' def __init__(self, opts, auth=None): self.opts = opts if not auth: self...
saltstack/salt
salt/utils/event.py
StateFire.fire_running
python
def fire_running(self, running): ''' Pass in a state "running" dict, this is the return dict from a state call. The dict will be processed and fire events. By default yellows and reds fire events on the master and minion, but this can be configured. ''' load = {'...
Pass in a state "running" dict, this is the return dict from a state call. The dict will be processed and fire events. By default yellows and reds fire events on the master and minion, but this can be configured.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/event.py#L1358-L1388
[ "def factory(opts, **kwargs):\n # All Sync interfaces are just wrappers around the Async ones\n sync = SyncWrapper(AsyncReqChannel.factory, (opts,), kwargs)\n return sync\n" ]
class StateFire(object): ''' Evaluate the data from a state run and fire events on the master and minion for each returned chunk that is not "green" This object is made to only run on a minion ''' def __init__(self, opts, auth=None): self.opts = opts if not auth: self...
saltstack/salt
salt/modules/inspectlib/kiwiproc.py
KiwiExporter.load
python
def load(self, **descr): ''' Load data by keys. :param data: :return: ''' for obj, data in descr.items(): setattr(self._data, obj, data) return self
Load data by keys. :param data: :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L50-L60
null
class KiwiExporter(object): ''' Exports system description as Kiwi configuration. ''' def __init__(self, grains, format): self.__grains__ = grains self.format = format self._data = type('data', (), {}) self.name = None def export(self, name): ''' Exp...
saltstack/salt
salt/modules/inspectlib/kiwiproc.py
KiwiExporter.export
python
def export(self, name): ''' Export to the Kiwi config.xml as text. :return: ''' self.name = name root = self._create_doc() self._set_description(root) self._set_preferences(root) self._set_repositories(root) self._set_users(root) ...
Export to the Kiwi config.xml as text. :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L62-L79
[ "def _set_preferences(self, node):\n '''\n Set preferences.\n\n :return:\n '''\n pref = etree.SubElement(node, 'preferences')\n pacman = etree.SubElement(pref, 'packagemanager')\n pacman.text = self._get_package_manager()\n p_version = etree.SubElement(pref, 'version')\n p_version.text = ...
class KiwiExporter(object): ''' Exports system description as Kiwi configuration. ''' def __init__(self, grains, format): self.__grains__ = grains self.format = format self._data = type('data', (), {}) self.name = None def load(self, **descr): ''' Loa...
saltstack/salt
salt/modules/inspectlib/kiwiproc.py
KiwiExporter._get_package_manager
python
def _get_package_manager(self): ''' Get package manager. :return: ''' ret = None if self.__grains__.get('os_family') in ('Kali', 'Debian'): ret = 'apt-get' elif self.__grains__.get('os_family', '') == 'Suse': ret = 'zypper' elif se...
Get package manager. :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L81-L98
null
class KiwiExporter(object): ''' Exports system description as Kiwi configuration. ''' def __init__(self, grains, format): self.__grains__ = grains self.format = format self._data = type('data', (), {}) self.name = None def load(self, **descr): ''' Loa...
saltstack/salt
salt/modules/inspectlib/kiwiproc.py
KiwiExporter._set_preferences
python
def _set_preferences(self, node): ''' Set preferences. :return: ''' pref = etree.SubElement(node, 'preferences') pacman = etree.SubElement(pref, 'packagemanager') pacman.text = self._get_package_manager() p_version = etree.SubElement(pref, 'version') ...
Set preferences. :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L100-L126
[ "def _get_package_manager(self):\n '''\n Get package manager.\n\n :return:\n '''\n ret = None\n if self.__grains__.get('os_family') in ('Kali', 'Debian'):\n ret = 'apt-get'\n elif self.__grains__.get('os_family', '') == 'Suse':\n ret = 'zypper'\n elif self.__grains__.get('os_fa...
class KiwiExporter(object): ''' Exports system description as Kiwi configuration. ''' def __init__(self, grains, format): self.__grains__ = grains self.format = format self._data = type('data', (), {}) self.name = None def load(self, **descr): ''' Loa...
saltstack/salt
salt/modules/inspectlib/kiwiproc.py
KiwiExporter._get_user_groups
python
def _get_user_groups(self, user): ''' Get user groups. :param user: :return: ''' return [g.gr_name for g in grp.getgrall() if user in g.gr_mem] + [grp.getgrgid(pwd.getpwnam(user).pw_gid).gr_name]
Get user groups. :param user: :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L128-L136
null
class KiwiExporter(object): ''' Exports system description as Kiwi configuration. ''' def __init__(self, grains, format): self.__grains__ = grains self.format = format self._data = type('data', (), {}) self.name = None def load(self, **descr): ''' Loa...
saltstack/salt
salt/modules/inspectlib/kiwiproc.py
KiwiExporter._set_users
python
def _set_users(self, node): ''' Create existing local users. <users group="root"> <user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/> </users> :param node: :return: ''' # Get real local users with the local passwords ...
Create existing local users. <users group="root"> <user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root"/> </users> :param node: :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L138-L177
[ "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ...
class KiwiExporter(object): ''' Exports system description as Kiwi configuration. ''' def __init__(self, grains, format): self.__grains__ = grains self.format = format self._data = type('data', (), {}) self.name = None def load(self, **descr): ''' Loa...
saltstack/salt
salt/modules/inspectlib/kiwiproc.py
KiwiExporter._set_repositories
python
def _set_repositories(self, node): ''' Create repositories. :param node: :return: ''' priority = 99 for repo_id, repo_data in self._data.software.get('repositories', {}).items(): if type(repo_data) == list: repo_data = repo_data[0] ...
Create repositories. :param node: :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L179-L206
null
class KiwiExporter(object): ''' Exports system description as Kiwi configuration. ''' def __init__(self, grains, format): self.__grains__ = grains self.format = format self._data = type('data', (), {}) self.name = None def load(self, **descr): ''' Loa...
saltstack/salt
salt/modules/inspectlib/kiwiproc.py
KiwiExporter._set_packages
python
def _set_packages(self, node): ''' Set packages and collections. :param node: :return: ''' pkgs = etree.SubElement(node, 'packages') for pkg_name, pkg_version in sorted(self._data.software.get('packages', {}).items()): pkg = etree.SubElement(pkgs, 'pa...
Set packages and collections. :param node: :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L208-L227
null
class KiwiExporter(object): ''' Exports system description as Kiwi configuration. ''' def __init__(self, grains, format): self.__grains__ = grains self.format = format self._data = type('data', (), {}) self.name = None def load(self, **descr): ''' Loa...
saltstack/salt
salt/modules/inspectlib/kiwiproc.py
KiwiExporter._set_description
python
def _set_description(self, node): ''' Create a system description. :return: ''' hostname = socket.getfqdn() or platform.node() descr = etree.SubElement(node, 'description') author = etree.SubElement(descr, 'author') author.text = "salt.modules.node on {0...
Create a system description. :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L229-L245
null
class KiwiExporter(object): ''' Exports system description as Kiwi configuration. ''' def __init__(self, grains, format): self.__grains__ = grains self.format = format self._data = type('data', (), {}) self.name = None def load(self, **descr): ''' Loa...
saltstack/salt
salt/modules/inspectlib/kiwiproc.py
KiwiExporter._create_doc
python
def _create_doc(self): ''' Create document. :return: ''' root = etree.Element('image') root.set('schemaversion', '6.3') root.set('name', self.name) return root
Create document. :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/kiwiproc.py#L247-L257
null
class KiwiExporter(object): ''' Exports system description as Kiwi configuration. ''' def __init__(self, grains, format): self.__grains__ = grains self.format = format self._data = type('data', (), {}) self.name = None def load(self, **descr): ''' Loa...
saltstack/salt
salt/sdb/vault.py
set_
python
def set_(key, value, profile=None): ''' Set a key/value pair in the vault service ''' if '?' in key: __utils__['versions.warn_until']( 'Neon', ( 'Using ? to seperate between the path and key for vault has been deprecated ' 'and will be remo...
Set a key/value pair in the vault service
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/sdb/vault.py#L55-L85
null
# -*- coding: utf-8 -*- ''' Vault SDB Module :maintainer: SaltStack :maturity: New :platform: all .. versionadded:: 2016.11.0 This module allows access to Hashicorp Vault using an ``sdb://`` URI. Base configuration instructions are documented in the execution module docs. Below are noted extra configur...
saltstack/salt
salt/thorium/timer.py
hold
python
def hold(name, seconds): ''' Wait for a given period of time, then fire a result of True, requiring this state allows for an action to be blocked for evaluation based on time USAGE: .. code-block:: yaml hold_on_a_moment: timer.hold: - seconds: 30 ''' ret ...
Wait for a given period of time, then fire a result of True, requiring this state allows for an action to be blocked for evaluation based on time USAGE: .. code-block:: yaml hold_on_a_moment: timer.hold: - seconds: 30
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/timer.py#L11-L37
null
# -*- coding: utf-8 -*- ''' Allow for flow based timers. These timers allow for a sleep to exist across multiple runs of the flow ''' from __future__ import absolute_import, print_function, unicode_literals import time
saltstack/salt
salt/modules/mongodb.py
_connect
python
def _connect(user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' Returns a tuple of (user, host, port) with config, pillar, or default values assigned to missing values. ''' if not user: user = __salt__['config.option']('mongodb.user') if not password: ...
Returns a tuple of (user, host, port) with config, pillar, or default values assigned to missing values.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L49-L74
null
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
_to_dict
python
def _to_dict(objects): ''' Potentially interprets a string as JSON for usage with mongo ''' try: if isinstance(objects, six.string_types): objects = salt.utils.json.loads(objects) except ValueError as err: log.error("Could not parse objects: %s", err) raise err ...
Potentially interprets a string as JSON for usage with mongo
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L77-L88
[ "def loads(s, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.loads and prevents a traceback in the event that a bytestring is\n passed to the function. (Python < 3.6 cannot load bytestrings)\n\n You can pass an alternate json module (loaded via import_json() above)\n using the _json_...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
db_list
python
def db_list(user=None, password=None, host=None, port=None, authdb=None): ''' List all MongoDB databases CLI Example: .. code-block:: bash salt '*' mongodb.db_list <user> <password> <host> <port> ''' conn = _connect(user, password, host, port, authdb=authdb) if not conn: r...
List all MongoDB databases CLI Example: .. code-block:: bash salt '*' mongodb.db_list <user> <password> <host> <port>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L91-L110
[ "def _connect(user=None, password=None, host=None, port=None, database='admin', authdb=None):\n '''\n Returns a tuple of (user, host, port) with config, pillar, or default\n values assigned to missing values.\n '''\n if not user:\n user = __salt__['config.option']('mongodb.user')\n if not p...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
db_exists
python
def db_exists(name, user=None, password=None, host=None, port=None, authdb=None): ''' Checks if a database exists in MongoDB CLI Example: .. code-block:: bash salt '*' mongodb.db_exists <name> <user> <password> <host> <port> ''' dbs = db_list(user, password, host, port, authdb=authdb)...
Checks if a database exists in MongoDB CLI Example: .. code-block:: bash salt '*' mongodb.db_exists <name> <user> <password> <host> <port>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L113-L128
[ "def db_list(user=None, password=None, host=None, port=None, authdb=None):\n '''\n List all MongoDB databases\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' mongodb.db_list <user> <password> <host> <port>\n '''\n conn = _connect(user, password, host, port, authdb=authdb)\n if not...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
db_remove
python
def db_remove(name, user=None, password=None, host=None, port=None, authdb=None): ''' Remove a MongoDB database CLI Example: .. code-block:: bash salt '*' mongodb.db_remove <name> <user> <password> <host> <port> ''' conn = _connect(user, password, host, port, authdb=authdb) if not...
Remove a MongoDB database CLI Example: .. code-block:: bash salt '*' mongodb.db_remove <name> <user> <password> <host> <port>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L131-L152
[ "def _connect(user=None, password=None, host=None, port=None, database='admin', authdb=None):\n '''\n Returns a tuple of (user, host, port) with config, pillar, or default\n values assigned to missing values.\n '''\n if not user:\n user = __salt__['config.option']('mongodb.user')\n if not p...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
version
python
def version(user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' Get MongoDB instance version CLI Example: .. code-block:: bash salt '*' mongodb.version <user> <password> <host> <port> <database> ''' conn = _connect(user, password, host, port, authdb=aut...
Get MongoDB instance version CLI Example: .. code-block:: bash salt '*' mongodb.version <user> <password> <host> <port> <database>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L159-L180
[ "def _version(mdb):\n return mdb.command('buildInfo')['version']\n", "def _connect(user=None, password=None, host=None, port=None, database='admin', authdb=None):\n '''\n Returns a tuple of (user, host, port) with config, pillar, or default\n values assigned to missing values.\n '''\n if not use...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
user_list
python
def user_list(user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' List users of a MongoDB database CLI Example: .. code-block:: bash salt '*' mongodb.user_list <user> <password> <host> <port> <database> ''' conn = _connect(user, password, host, port, au...
List users of a MongoDB database CLI Example: .. code-block:: bash salt '*' mongodb.user_list <user> <password> <host> <port> <database>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L208-L245
[ "def _version(mdb):\n return mdb.command('buildInfo')['version']\n", "def _connect(user=None, password=None, host=None, port=None, database='admin', authdb=None):\n '''\n Returns a tuple of (user, host, port) with config, pillar, or default\n values assigned to missing values.\n '''\n if not use...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
user_exists
python
def user_exists(name, user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' Checks if a user exists in MongoDB CLI Example: .. code-block:: bash salt '*' mongodb.user_exists <name> <user> <password> <host> <port> <database> ''' users = use...
Checks if a user exists in MongoDB CLI Example: .. code-block:: bash salt '*' mongodb.user_exists <name> <user> <password> <host> <port> <database>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L248-L268
[ "def user_list(user=None, password=None, host=None, port=None, database='admin', authdb=None):\n '''\n List users of a MongoDB database\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' mongodb.user_list <user> <password> <host> <port> <database>\n '''\n conn = _connect(user, password,...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
user_create
python
def user_create(name, passwd, user=None, password=None, host=None, port=None, database='admin', authdb=None, roles=None): ''' Create a MongoDB user CLI Example: .. code-block:: bash salt '*' mongodb.user_create <user_name> <user_password> <roles> <user> <password> <host> <port...
Create a MongoDB user CLI Example: .. code-block:: bash salt '*' mongodb.user_create <user_name> <user_password> <roles> <user> <password> <host> <port> <database>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L271-L296
[ "def _connect(user=None, password=None, host=None, port=None, database='admin', authdb=None):\n '''\n Returns a tuple of (user, host, port) with config, pillar, or default\n values assigned to missing values.\n '''\n if not user:\n user = __salt__['config.option']('mongodb.user')\n if not p...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
user_remove
python
def user_remove(name, user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' Remove a MongoDB user CLI Example: .. code-block:: bash salt '*' mongodb.user_remove <name> <user> <password> <host> <port> <database> ''' conn = _connect(user, pa...
Remove a MongoDB user CLI Example: .. code-block:: bash salt '*' mongodb.user_remove <name> <user> <password> <host> <port> <database>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L299-L322
[ "def _connect(user=None, password=None, host=None, port=None, database='admin', authdb=None):\n '''\n Returns a tuple of (user, host, port) with config, pillar, or default\n values assigned to missing values.\n '''\n if not user:\n user = __salt__['config.option']('mongodb.user')\n if not p...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
user_roles_exists
python
def user_roles_exists(name, roles, database, user=None, password=None, host=None, port=None, authdb=None): ''' Checks if a user of a MongoDB database has specified roles CLI Examples: .. code-block:: bash salt '*' mongodb.user_roles_exists johndoe '["readWrite"]' dbname ...
Checks if a user of a MongoDB database has specified roles CLI Examples: .. code-block:: bash salt '*' mongodb.user_roles_exists johndoe '["readWrite"]' dbname admin adminpwd localhost 27017 .. code-block:: bash salt '*' mongodb.user_roles_exists johndoe '[{"role": "readWrite", "db": "d...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L325-L360
[ "def _to_dict(objects):\n '''\n Potentially interprets a string as JSON for usage with mongo\n '''\n try:\n if isinstance(objects, six.string_types):\n objects = salt.utils.json.loads(objects)\n except ValueError as err:\n log.error(\"Could not parse objects: %s\", err)\n ...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
user_grant_roles
python
def user_grant_roles(name, roles, database, user=None, password=None, host=None, port=None, authdb=None): ''' Grant one or many roles to a MongoDB user CLI Examples: .. code-block:: bash salt '*' mongodb.user_grant_roles johndoe '["readWrite"]' dbname admin adminpwd local...
Grant one or many roles to a MongoDB user CLI Examples: .. code-block:: bash salt '*' mongodb.user_grant_roles johndoe '["readWrite"]' dbname admin adminpwd localhost 27017 .. code-block:: bash salt '*' mongodb.user_grant_roles janedoe '[{"role": "readWrite", "db": "dbname" }, {"role": ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L363-L395
[ "def _to_dict(objects):\n '''\n Potentially interprets a string as JSON for usage with mongo\n '''\n try:\n if isinstance(objects, six.string_types):\n objects = salt.utils.json.loads(objects)\n except ValueError as err:\n log.error(\"Could not parse objects: %s\", err)\n ...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
insert
python
def insert(objects, collection, user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' Insert an object or list of objects into a collection CLI Example: .. code-block:: bash salt '*' mongodb.insert '[{"foo": "FOO", "bar": "BAR"}, {"foo": "BAZ", "bar": ...
Insert an object or list of objects into a collection CLI Example: .. code-block:: bash salt '*' mongodb.insert '[{"foo": "FOO", "bar": "BAR"}, {"foo": "BAZ", "bar": "BAM"}]' mycollection <user> <password> <host> <port> <database>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L433-L462
[ "def _to_dict(objects):\n '''\n Potentially interprets a string as JSON for usage with mongo\n '''\n try:\n if isinstance(objects, six.string_types):\n objects = salt.utils.json.loads(objects)\n except ValueError as err:\n log.error(\"Could not parse objects: %s\", err)\n ...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
update_one
python
def update_one(objects, collection, user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' Update an object into a collection http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.update_one .. versionadded:: 2016.11.0 CLI Exam...
Update an object into a collection http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.update_one .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' mongodb.update_one '{"_id": "my_minion"} {"bar": "BAR"}' mycollection <user> <p...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L465-L530
[ "def find(collection, query=None, user=None, password=None,\n host=None, port=None, database='admin', authdb=None):\n '''\n Find an object or list of objects in a collection\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' mongodb.find mycollection '[{\"foo\": \"FOO\", \"bar\": \"BA...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/modules/mongodb.py
find
python
def find(collection, query=None, user=None, password=None, host=None, port=None, database='admin', authdb=None): ''' Find an object or list of objects in a collection CLI Example: .. code-block:: bash salt '*' mongodb.find mycollection '[{"foo": "FOO", "bar": "BAR"}]' <user> <passwor...
Find an object or list of objects in a collection CLI Example: .. code-block:: bash salt '*' mongodb.find mycollection '[{"foo": "FOO", "bar": "BAR"}]' <user> <password> <host> <port> <database>
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mongodb.py#L533-L562
[ "def _to_dict(objects):\n '''\n Potentially interprets a string as JSON for usage with mongo\n '''\n try:\n if isinstance(objects, six.string_types):\n objects = salt.utils.json.loads(objects)\n except ValueError as err:\n log.error(\"Could not parse objects: %s\", err)\n ...
# -*- coding: utf-8 -*- ''' Module to provide MongoDB functionality to Salt :configuration: This module uses PyMongo, and accepts configuration details as parameters as well as configuration settings:: mongodb.host: 'localhost' mongodb.port: 27017 mongodb.user: '' mongodb.password:...
saltstack/salt
salt/states/infoblox_host_record.py
present
python
def present(name=None, data=None, ensure_data=True, **api_opts): ''' This will ensure that a host with the provided name exists. This will try to ensure that the state of the host matches the given data If the host is not found then one will be created. When trying to update a hostname ensure `name...
This will ensure that a host with the provided name exists. This will try to ensure that the state of the host matches the given data If the host is not found then one will be created. When trying to update a hostname ensure `name` is set to the hostname of the current record. You can give a new name i...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/infoblox_host_record.py#L17-L128
null
# -*- coding: utf-8 -*- ''' Infoblox host record managment. functions accept api_opts: api_verifyssl: verify SSL [default to True or pillar value] api_url: server to connect to [default to pillar value] api_username: [default to pillar value] api_password: [default to pillar value] ''' # Import Pyt...
saltstack/salt
salt/proxy/marathon.py
init
python
def init(opts): ''' Perform any needed setup. ''' if CONFIG_BASE_URL in opts['proxy']: CONFIG[CONFIG_BASE_URL] = opts['proxy'][CONFIG_BASE_URL] else: log.error('missing proxy property %s', CONFIG_BASE_URL) log.debug('CONFIG: %s', CONFIG)
Perform any needed setup.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/marathon.py#L43-L51
null
# -*- coding: utf-8 -*- ''' Marathon ======== Proxy minion for managing a Marathon cluster. Dependencies ------------ - :mod:`marathon execution module (salt.modules.marathon) <salt.modules.marathon>` Pillar ------ The marathon proxy configuration requires a 'base_url' property that points to the marathon endpoint...
saltstack/salt
salt/proxy/marathon.py
ping
python
def ping(): ''' Is the marathon api responding? ''' try: response = salt.utils.http.query( "{0}/ping".format(CONFIG[CONFIG_BASE_URL]), decode_type='plain', decode=True, ) log.debug( 'marathon.info returned successfully: %s', ...
Is the marathon api responding?
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/marathon.py#L54-L76
null
# -*- coding: utf-8 -*- ''' Marathon ======== Proxy minion for managing a Marathon cluster. Dependencies ------------ - :mod:`marathon execution module (salt.modules.marathon) <salt.modules.marathon>` Pillar ------ The marathon proxy configuration requires a 'base_url' property that points to the marathon endpoint...
saltstack/salt
salt/modules/glance.py
_auth
python
def _auth(profile=None, api_version=2, **connection_args): ''' Set up glance credentials, returns `glanceclient.client.Client`. Optional parameter "api_version" defaults to 2. Only intended to be used within glance-enabled modules ''' __utils__['versions.warn_until']( 'Neon', ...
Set up glance credentials, returns `glanceclient.client.Client`. Optional parameter "api_version" defaults to 2. Only intended to be used within glance-enabled modules
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L98-L182
[ "def get(key, default=None):\n '''\n Checks connection_args, then salt-minion config,\n falls back to specified default value.\n '''\n return connection_args.get('connection_' + key,\n __salt__['config.get'](prefix + key, default))\n" ]
# -*- coding: utf-8 -*- ''' Module for handling openstack glance calls. :optdepends: - glanceclient Python adapter :configuration: This module is not usable until the following are specified either in a pillar or in the minion's config file:: keystone.user: admin keystone.password: verybadpass ...
saltstack/salt
salt/modules/glance.py
_add_image
python
def _add_image(collection, image): ''' Add image to given dictionary ''' image_prep = { 'id': image.id, 'name': image.name, 'created_at': image.created_at, 'file': image.file, 'min_disk': image.min_disk, 'min_ram': image.min_ram, ...
Add image to given dictionary
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L185-L216
null
# -*- coding: utf-8 -*- ''' Module for handling openstack glance calls. :optdepends: - glanceclient Python adapter :configuration: This module is not usable until the following are specified either in a pillar or in the minion's config file:: keystone.user: admin keystone.password: verybadpass ...
saltstack/salt
salt/modules/glance.py
image_create
python
def image_create(name, location=None, profile=None, visibility=None, container_format='bare', disk_format='raw', protected=None,): ''' Create an image (glance image-create) CLI Example, old format: .....
Create an image (glance image-create) CLI Example, old format: .. code-block:: bash salt '*' glance.image_create name=f16-jeos \\ disk_format=qcow2 container_format=ovf CLI Example, new format resembling Glance API v2: .. code-block:: bash salt '*' glance.image_cre...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L219-L282
[ "def _auth(profile=None, api_version=2, **connection_args):\n '''\n Set up glance credentials, returns\n `glanceclient.client.Client`. Optional parameter\n \"api_version\" defaults to 2.\n\n Only intended to be used within glance-enabled modules\n '''\n __utils__['versions.warn_until'](\n ...
# -*- coding: utf-8 -*- ''' Module for handling openstack glance calls. :optdepends: - glanceclient Python adapter :configuration: This module is not usable until the following are specified either in a pillar or in the minion's config file:: keystone.user: admin keystone.password: verybadpass ...
saltstack/salt
salt/modules/glance.py
image_delete
python
def image_delete(id=None, name=None, profile=None): # pylint: disable=C0103 ''' Delete an image (glance image-delete) CLI Examples: .. code-block:: bash salt '*' glance.image_delete c2eb2eb0-53e1-4a80-b990-8ec887eae7df salt '*' glance.image_delete id=c2eb2eb0-53e1-4a80-b990-8ec887eae...
Delete an image (glance image-delete) CLI Examples: .. code-block:: bash salt '*' glance.image_delete c2eb2eb0-53e1-4a80-b990-8ec887eae7df salt '*' glance.image_delete id=c2eb2eb0-53e1-4a80-b990-8ec887eae7df salt '*' glance.image_delete name=f16-jeos
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L285-L329
[ "def _auth(profile=None, api_version=2, **connection_args):\n '''\n Set up glance credentials, returns\n `glanceclient.client.Client`. Optional parameter\n \"api_version\" defaults to 2.\n\n Only intended to be used within glance-enabled modules\n '''\n __utils__['versions.warn_until'](\n ...
# -*- coding: utf-8 -*- ''' Module for handling openstack glance calls. :optdepends: - glanceclient Python adapter :configuration: This module is not usable until the following are specified either in a pillar or in the minion's config file:: keystone.user: admin keystone.password: verybadpass ...
saltstack/salt
salt/modules/glance.py
image_show
python
def image_show(id=None, name=None, profile=None): # pylint: disable=C0103 ''' Return details about a specific image (glance image-show) CLI Example: .. code-block:: bash salt '*' glance.image_show ''' g_client = _auth(profile) ret = {} if name: for image in g_client.i...
Return details about a specific image (glance image-show) CLI Example: .. code-block:: bash salt '*' glance.image_show
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L332-L374
[ "def _auth(profile=None, api_version=2, **connection_args):\n '''\n Set up glance credentials, returns\n `glanceclient.client.Client`. Optional parameter\n \"api_version\" defaults to 2.\n\n Only intended to be used within glance-enabled modules\n '''\n __utils__['versions.warn_until'](\n ...
# -*- coding: utf-8 -*- ''' Module for handling openstack glance calls. :optdepends: - glanceclient Python adapter :configuration: This module is not usable until the following are specified either in a pillar or in the minion's config file:: keystone.user: admin keystone.password: verybadpass ...
saltstack/salt
salt/modules/glance.py
image_list
python
def image_list(id=None, profile=None, name=None): # pylint: disable=C0103 ''' Return a list of available images (glance image-list) CLI Example: .. code-block:: bash salt '*' glance.image_list ''' g_client = _auth(profile) ret = [] for image in g_client.images.list(): ...
Return a list of available images (glance image-list) CLI Example: .. code-block:: bash salt '*' glance.image_list
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L377-L407
[ "def _auth(profile=None, api_version=2, **connection_args):\n '''\n Set up glance credentials, returns\n `glanceclient.client.Client`. Optional parameter\n \"api_version\" defaults to 2.\n\n Only intended to be used within glance-enabled modules\n '''\n __utils__['versions.warn_until'](\n ...
# -*- coding: utf-8 -*- ''' Module for handling openstack glance calls. :optdepends: - glanceclient Python adapter :configuration: This module is not usable until the following are specified either in a pillar or in the minion's config file:: keystone.user: admin keystone.password: verybadpass ...
saltstack/salt
salt/modules/glance.py
image_update
python
def image_update(id=None, name=None, profile=None, **kwargs): # pylint: disable=C0103 ''' Update properties of given image. Known to work for: - min_ram (in MB) - protected (bool) - visibility ('public' or 'private') CLI Example: .. code-block:: bash salt '*' glance.image_upd...
Update properties of given image. Known to work for: - min_ram (in MB) - protected (bool) - visibility ('public' or 'private') CLI Example: .. code-block:: bash salt '*' glance.image_update id=c2eb2eb0-53e1-4a80-b990-8ec887eae7df salt '*' glance.image_update name=f16-jeos
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L424-L473
[ "def image_list(id=None, profile=None, name=None): # pylint: disable=C0103\n '''\n Return a list of available images (glance image-list)\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' glance.image_list\n '''\n g_client = _auth(profile)\n ret = []\n for image in g_client.image...
# -*- coding: utf-8 -*- ''' Module for handling openstack glance calls. :optdepends: - glanceclient Python adapter :configuration: This module is not usable until the following are specified either in a pillar or in the minion's config file:: keystone.user: admin keystone.password: verybadpass ...
saltstack/salt
salt/modules/glance.py
schema_get
python
def schema_get(name, profile=None): ''' Known valid names of schemas are: - image - images - member - members CLI Example: .. code-block:: bash salt '*' glance.schema_get name=f16-jeos ''' g_client = _auth(profile) schema_props = {} for prop in g_client...
Known valid names of schemas are: - image - images - member - members CLI Example: .. code-block:: bash salt '*' glance.schema_get name=f16-jeos
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L476-L498
[ "def _auth(profile=None, api_version=2, **connection_args):\n '''\n Set up glance credentials, returns\n `glanceclient.client.Client`. Optional parameter\n \"api_version\" defaults to 2.\n\n Only intended to be used within glance-enabled modules\n '''\n __utils__['versions.warn_until'](\n ...
# -*- coding: utf-8 -*- ''' Module for handling openstack glance calls. :optdepends: - glanceclient Python adapter :configuration: This module is not usable until the following are specified either in a pillar or in the minion's config file:: keystone.user: admin keystone.password: verybadpass ...
saltstack/salt
salt/modules/glance.py
_item_list
python
def _item_list(profile=None): ''' Template for writing list functions Return a list of available items (glance items-list) CLI Example: .. code-block:: bash salt '*' glance.item_list ''' g_client = _auth(profile) ret = [] for item in g_client.items.list(): ret.appe...
Template for writing list functions Return a list of available items (glance items-list) CLI Example: .. code-block:: bash salt '*' glance.item_list
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glance.py#L501-L519
null
# -*- coding: utf-8 -*- ''' Module for handling openstack glance calls. :optdepends: - glanceclient Python adapter :configuration: This module is not usable until the following are specified either in a pillar or in the minion's config file:: keystone.user: admin keystone.password: verybadpass ...
saltstack/salt
salt/states/loop.py
until
python
def until(name, m_args=None, m_kwargs=None, condition=None, period=0, timeout=604800): ''' Loop over an execution module until a condition is met. name The name of the execution module m_args The execution module's positional arguments ...
Loop over an execution module until a condition is met. name The name of the execution module m_args The execution module's positional arguments m_kwargs The execution module's keyword arguments condition The condition which must be met for the loop to break. This ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/loop.py#L47-L118
[ "def timed_out():\n if time.time() >= timeout:\n return True\n return False\n" ]
# -*- coding: utf-8 -*- ''' Loop state Allows for looping over execution modules. .. versionadded:: 2017.7.0 .. code-block:: yaml wait_for_service_to_be_healthy: loop.until: - name: boto_elb.get_instance_health - condition: m_ret[0]['state'] == 'InService' - period: 5 - tim...
saltstack/salt
salt/cloud/clouds/proxmox.py
_authenticate
python
def _authenticate(): ''' Retrieve CSRF and API tickets for the Proxmox API ''' global url, port, ticket, csrf, verify_ssl url = config.get_cloud_config_value( 'url', get_configured_provider(), __opts__, search_global=False ) port = config.get_cloud_config_value( 'port', get_c...
Retrieve CSRF and API tickets for the Proxmox API
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L116-L146
null
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
query
python
def query(conn_type, option, post_data=None): ''' Execute the HTTP request to the API ''' if ticket is None or csrf is None or url is None: log.debug('Not authenticated yet, doing that now..') _authenticate() full_url = 'https://{0}:{1}/api2/json/{2}'.format(url, port, option) ...
Execute the HTTP request to the API
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L149-L196
[ "def _authenticate():\n '''\n Retrieve CSRF and API tickets for the Proxmox API\n '''\n global url, port, ticket, csrf, verify_ssl\n url = config.get_cloud_config_value(\n 'url', get_configured_provider(), __opts__, search_global=False\n )\n port = config.get_cloud_config_value(\n ...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
_get_vm_by_name
python
def _get_vm_by_name(name, allDetails=False): ''' Since Proxmox works based op id's rather than names as identifiers this requires some filtering to retrieve the required information. ''' vms = get_resources_vms(includeConfig=allDetails) if name in vms: return vms[name] log.info('VM ...
Since Proxmox works based op id's rather than names as identifiers this requires some filtering to retrieve the required information.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L199-L209
[ "def get_resources_vms(call=None, resFilter=None, includeConfig=True):\n '''\n Retrieve all VMs available on this environment\n\n CLI Example:\n\n .. code-block:: bash\n\n salt-cloud -f get_resources_vms my-proxmox-config\n '''\n\n timeoutTime = time.time() + 60\n while True:\n lo...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
_get_vm_by_id
python
def _get_vm_by_id(vmid, allDetails=False): ''' Retrieve a VM based on the ID. ''' for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=allDetails)): if six.text_type(vm_details['vmid']) == six.text_type(vmid): return vm_details log.info('VM with ID "%s" could...
Retrieve a VM based on the ID.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L212-L221
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def get_resources_vms(call=None, resFilter=None, includeConfig=True):\n '''\n Retrieve all VMs available on this environment\n\n CLI Example:\n\n .. code-block:: bash\n\n salt-cloud -f get_resources_vms my-proxmox-config\n '''\n\n ...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
_check_ip_available
python
def _check_ip_available(ip_addr): ''' Proxmox VMs refuse to start when the IP is already being used. This function can be used to prevent VMs being created with duplicate IP's or to generate a warning. ''' for vm_name, vm_details in six.iteritems(get_resources_vms(includeConfig=True)): v...
Proxmox VMs refuse to start when the IP is already being used. This function can be used to prevent VMs being created with duplicate IP's or to generate a warning.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L232-L245
null
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
_parse_proxmox_upid
python
def _parse_proxmox_upid(node, vm_=None): ''' Upon requesting a task that runs for a longer period of time a UPID is given. This includes information about the job and can be used to lookup information in the log. ''' ret = {} upid = node # Parse node response node = node.split(':') ...
Upon requesting a task that runs for a longer period of time a UPID is given. This includes information about the job and can be used to lookup information in the log.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L248-L272
null
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
_lookup_proxmox_task
python
def _lookup_proxmox_task(upid): ''' Retrieve the (latest) logs and retrieve the status for a UPID. This can be used to verify whether a task has completed. ''' log.debug('Getting creation status for upid: %s', upid) tasks = query('get', 'cluster/tasks') if tasks: for task in tasks: ...
Retrieve the (latest) logs and retrieve the status for a UPID. This can be used to verify whether a task has completed.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L275-L289
[ "def query(conn_type, option, post_data=None):\n '''\n Execute the HTTP request to the API\n '''\n if ticket is None or csrf is None or url is None:\n log.debug('Not authenticated yet, doing that now..')\n _authenticate()\n\n full_url = 'https://{0}:{1}/api2/json/{2}'.format(url, port, ...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
get_resources_nodes
python
def get_resources_nodes(call=None, resFilter=None): ''' Retrieve all hypervisors (nodes) available on this environment CLI Example: .. code-block:: bash salt-cloud -f get_resources_nodes my-proxmox-config ''' log.debug('Getting resource: nodes.. (filter: %s)', resFilter) resources ...
Retrieve all hypervisors (nodes) available on this environment CLI Example: .. code-block:: bash salt-cloud -f get_resources_nodes my-proxmox-config
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L292-L316
[ "def query(conn_type, option, post_data=None):\n '''\n Execute the HTTP request to the API\n '''\n if ticket is None or csrf is None or url is None:\n log.debug('Not authenticated yet, doing that now..')\n _authenticate()\n\n full_url = 'https://{0}:{1}/api2/json/{2}'.format(url, port, ...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
get_resources_vms
python
def get_resources_vms(call=None, resFilter=None, includeConfig=True): ''' Retrieve all VMs available on this environment CLI Example: .. code-block:: bash salt-cloud -f get_resources_vms my-proxmox-config ''' timeoutTime = time.time() + 60 while True: log.debug('Getting r...
Retrieve all VMs available on this environment CLI Example: .. code-block:: bash salt-cloud -f get_resources_vms my-proxmox-config
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L319-L372
[ "def query(conn_type, option, post_data=None):\n '''\n Execute the HTTP request to the API\n '''\n if ticket is None or csrf is None or url is None:\n log.debug('Not authenticated yet, doing that now..')\n _authenticate()\n\n full_url = 'https://{0}:{1}/api2/json/{2}'.format(url, port, ...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
script
python
def script(vm_): ''' Return the script deployment object ''' script_name = config.get_cloud_config_value('script', vm_, __opts__) if not script_name: script_name = 'bootstrap-salt' return salt.utils.cloud.os_script( script_name, vm_, __opts__, salt.utils....
Return the script deployment object
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L375-L390
[ "def get_cloud_config_value(name, vm_, opts, default=None, search_global=True):\n '''\n Search and return a setting in a known order:\n\n 1. In the virtual machine's configuration\n 2. In the virtual machine's profile configuration\n 3. In the virtual machine's provider configuration\n ...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
avail_locations
python
def avail_locations(call=None): ''' Return a list of the hypervisors (nodes) which this Proxmox PVE machine manages CLI Example: .. code-block:: bash salt-cloud --list-locations my-proxmox-config ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_locati...
Return a list of the hypervisors (nodes) which this Proxmox PVE machine manages CLI Example: .. code-block:: bash salt-cloud --list-locations my-proxmox-config
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L393-L417
[ "def query(conn_type, option, post_data=None):\n '''\n Execute the HTTP request to the API\n '''\n if ticket is None or csrf is None or url is None:\n log.debug('Not authenticated yet, doing that now..')\n _authenticate()\n\n full_url = 'https://{0}:{1}/api2/json/{2}'.format(url, port, ...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
avail_images
python
def avail_images(call=None, location='local'): ''' Return a list of the images that are on the provider CLI Example: .. code-block:: bash salt-cloud --list-images my-proxmox-config ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_images function must ...
Return a list of the images that are on the provider CLI Example: .. code-block:: bash salt-cloud --list-images my-proxmox-config
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L420-L440
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def query(conn_type, option, post_data=None):\n '''\n Execute the HTTP request to the API\n '''\n if ticket is None or csrf is None or url is None:\n log.debug('Not authenticated yet, doing that now..')\n _authenticate()\n\n ...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
list_nodes
python
def list_nodes(call=None): ''' Return a list of the VMs that are managed by the provider CLI Example: .. code-block:: bash salt-cloud -Q my-proxmox-config ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes function must be called with -f or --funct...
Return a list of the VMs that are managed by the provider CLI Example: .. code-block:: bash salt-cloud -Q my-proxmox-config
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L443-L485
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def get_resources_vms(call=None, resFilter=None, includeConfig=True):\n '''\n Retrieve all VMs available on this environment\n\n CLI Example:\n\n .. code-block:: bash\n\n salt-cloud -f get_resources_vms my-proxmox-config\n '''\n\n ...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
_stringlist_to_dictionary
python
def _stringlist_to_dictionary(input_string): ''' Convert a stringlist (comma separated settings) to a dictionary The result of the string setting1=value1,setting2=value2 will be a python dictionary: {'setting1':'value1','setting2':'value2'} ''' li = str(input_string).split(',') ret = {} ...
Convert a stringlist (comma separated settings) to a dictionary The result of the string setting1=value1,setting2=value2 will be a python dictionary: {'setting1':'value1','setting2':'value2'}
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L521-L538
null
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
_dictionary_to_stringlist
python
def _dictionary_to_stringlist(input_dict): ''' Convert a dictionary to a stringlist (comma separated settings) The result of the dictionary {'setting1':'value1','setting2':'value2'} will be: setting1=value1,setting2=value2 ''' string_value = "" for s in input_dict: string_value += ...
Convert a dictionary to a stringlist (comma separated settings) The result of the dictionary {'setting1':'value1','setting2':'value2'} will be: setting1=value1,setting2=value2
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L541-L553
null
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
create
python
def create(vm_): ''' Create a single VM from a data dict CLI Example: .. code-block:: bash salt-cloud -p proxmox-ubuntu vmhostname ''' try: # Check for required profile parameters before sending any API calls. if vm_['profile'] and config.is_profile_configured(__opts__...
Create a single VM from a data dict CLI Example: .. code-block:: bash salt-cloud -p proxmox-ubuntu vmhostname
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L556-L867
[ "def start(name, vmid=None, call=None):\n '''\n Start a node.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt-cloud -a start mymachine\n '''\n if call != 'action':\n raise SaltCloudSystemExit(\n 'The start action must be called with -a or --action.'\n )\n\n lo...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
_import_api
python
def _import_api(): ''' Download https://<url>/pve-docs/api-viewer/apidoc.js Extract content of pveapi var (json formated) Load this json content into global variable "api" ''' global api full_url = 'https://{0}:{1}/pve-docs/api-viewer/apidoc.js'.format(url, port) returned_data = requests...
Download https://<url>/pve-docs/api-viewer/apidoc.js Extract content of pveapi var (json formated) Load this json content into global variable "api"
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L870-L882
null
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
_get_properties
python
def _get_properties(path="", method="GET", forced_params=None): ''' Return the parameter list from api for defined path and HTTP method ''' if api is None: _import_api() sub = api path_levels = [level for level in path.split('/') if level != ''] search_path = '' props = [] p...
Return the parameter list from api for defined path and HTTP method
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L885-L919
null
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...
saltstack/salt
salt/cloud/clouds/proxmox.py
create_node
python
def create_node(vm_, newid): ''' Build and submit the requestdata to create a new node ''' newnode = {} if 'technology' not in vm_: vm_['technology'] = 'openvz' # default virt tech if none is given if vm_['technology'] not in ['qemu', 'openvz', 'lxc']: # Wrong VM type given ...
Build and submit the requestdata to create a new node
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/proxmox.py#L922-L1042
[ "def query(conn_type, option, post_data=None):\n '''\n Execute the HTTP request to the API\n '''\n if ticket is None or csrf is None or url is None:\n log.debug('Not authenticated yet, doing that now..')\n _authenticate()\n\n full_url = 'https://{0}:{1}/api2/json/{2}'.format(url, port, ...
# -*- coding: utf-8 -*- ''' Proxmox Cloud Module ====================== .. versionadded:: 2014.7.0 The Proxmox cloud module is used to control access to cloud providers using the Proxmox system (KVM / OpenVZ / LXC). Set up the cloud configuration at ``/etc/salt/cloud.providers`` or ``/etc/salt/cloud.providers.d/pro...