INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Bind the pub and pull sockets for events
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': ...
Get something from epull publish it out epub and return the package ( or None )
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 ...
Spin up the multiprocess event returner
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...
Take an event and run it through configured filters.
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...
Fire an event off on the master server
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) ...
Pass in a state running dict this is the return dict from a state call. The dict will be processed and fire events.
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 = {'...
Load data by keys.
def load(self, **descr): ''' Load data by keys. :param data: :return: ''' for obj, data in descr.items(): setattr(self._data, obj, data) return self
Export to the Kiwi config. xml as text.
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) ...
Get package manager.
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...
Set preferences.
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') ...
Get user groups.
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]
Create existing local users.
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 repositories.
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] ...
Set packages and collections.
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...
Create a system description.
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 document.
def _create_doc(self): ''' Create document. :return: ''' root = etree.Element('image') root.set('schemaversion', '6.3') root.set('name', self.name) return root
Set a key/ value pair in the vault service
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...
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
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 ...
Returns a tuple of ( user host port ) with config pillar or default values assigned to missing values.
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: ...
Potentially interprets a string as JSON for usage with mongo
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 ...
List all MongoDB databases
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...
Checks if a database exists in MongoDB
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)...
Remove a MongoDB database
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...
Get MongoDB instance version
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...
List users of a MongoDB database
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...
Checks if a user exists in MongoDB
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...
Create a MongoDB user
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...
Remove a MongoDB user
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...
Checks if a user of a MongoDB database has specified roles
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 ...
Grant one or many roles to a MongoDB user
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...
Insert an object or list of objects into a collection
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": ...
Update an object into a collection http:// api. mongodb. com/ python/ current/ api/ pymongo/ collection. html#pymongo. collection. Collection. update_one
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...
Find an object or list of objects in a collection
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...
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.
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...
Perform any needed setup.
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)
Is the marathon api responding?
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', ...
Set up glance credentials returns glanceclient. client. Client. Optional parameter api_version defaults to 2.
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', ...
Add image to given dictionary
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, ...
Create an image ( glance image - create )
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: .....
Delete an image ( glance image - delete )
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...
Return details about a specific image ( glance image - show )
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 a list of available images ( glance image - list )
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(): ...
Update properties of given image. Known to work for: - min_ram ( in MB ) - protected ( bool ) - visibility ( public or private )
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...
Known valid names of schemas are: - image - images - member - members
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...
Template for writing list functions Return a list of available items ( glance items - list )
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...
Loop over an execution module until a condition is met.
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 ...
Retrieve CSRF and API tickets for the Proxmox API
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...
Execute the HTTP request to the API
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) ...
Since Proxmox works based op id s rather than names as identifiers this requires some filtering to retrieve the required information.
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 ...
Retrieve a VM based on the ID.
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...
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.
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...
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.
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(':') ...
Retrieve the ( latest ) logs and retrieve the status for a UPID. This can be used to verify whether a task has completed.
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 all hypervisors ( nodes ) available on this environment CLI Example:
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 VMs available on this environment
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...
Return the script deployment object
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 a list of the hypervisors ( nodes ) which this Proxmox PVE machine manages
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 images that are on the provider
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 VMs that are managed by the provider
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...
Convert a stringlist ( comma separated settings ) to a dictionary
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 dictionary to a stringlist ( comma separated settings )
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 += ...
Create a single VM from a data dict
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__...
Download https:// <url >/ pve - docs/ api - viewer/ apidoc. js Extract content of pveapi var ( json formated ) Load this json content into global variable api
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...
Return the parameter list from api for defined path and HTTP method
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...
Build and submit the requestdata to create a new node
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 ...
Get VM configuration
def get_vmconfig(vmid, node=None, node_type='openvz'): ''' Get VM configuration ''' if node is None: # We need to figure out which node this VM is on. for host_name, host_details in six.iteritems(avail_locations()): for item in query('get', 'nodes/{0}/{1}'.format(host_name, n...
Wait until a specific state has been reached on a node
def wait_for_state(vmid, state, timeout=300): ''' Wait until a specific state has been reached on a node ''' start_time = time.time() node = get_vm_status(vmid=vmid) if not node: log.error('wait_for_state: No VM retrieved based on given criteria.') raise SaltCloudExecutionFailure...
Wait until a the task has been finished successfully
def wait_for_task(upid, timeout=300): ''' Wait until a the task has been finished successfully ''' start_time = time.time() info = _lookup_proxmox_task(upid) if not info: log.error('wait_for_task: No task information ' 'retrieved based on given criteria.') raise...
Destroy a node.
def destroy(name, call=None): ''' Destroy a node. CLI Example: .. code-block:: bash salt-cloud --destroy mymachine ''' if call == 'function': raise SaltCloudSystemExit( 'The destroy action must be called with -d, --destroy, ' '-a or --action.' )...
Convenience function for setting VM status
def set_vm_status(status, name=None, vmid=None): ''' Convenience function for setting VM status ''' log.debug('Set status to %s for %s (%s)', status, name, vmid) if vmid is not None: log.debug('set_vm_status: via ID - VMID %s (%s): %s', vmid, name, status) vmobj = ...
Get the status for a VM either via the ID or the hostname
def get_vm_status(vmid=None, name=None): ''' Get the status for a VM, either via the ID or the hostname ''' if vmid is not None: log.debug('get_vm_status: VMID %s', vmid) vmobj = _get_vm_by_id(vmid) elif name is not None: log.debug('get_vm_status: name %s', name) vmob...
Start a node.
def start(name, vmid=None, call=None): ''' Start a node. CLI Example: .. code-block:: bash salt-cloud -a start mymachine ''' if call != 'action': raise SaltCloudSystemExit( 'The start action must be called with -a or --action.' ) log.debug('Start: %s (...
Stop a node ( pulling the plug ).
def stop(name, vmid=None, call=None): ''' Stop a node ("pulling the plug"). CLI Example: .. code-block:: bash salt-cloud -a stop mymachine ''' if call != 'action': raise SaltCloudSystemExit( 'The stop action must be called with -a or --action.' ) if no...
Get summary from the rsync successful output.
def _get_summary(rsync_out): ''' Get summary from the rsync successful output. ''' return "- " + "\n- ".join([elm for elm in rsync_out.split("\n\n")[-1].replace(" ", "\n").split("\n") if elm])
Get changes from the rsync successful output.
def _get_changes(rsync_out): ''' Get changes from the rsync successful output. ''' copied = list() deleted = list() for line in rsync_out.split("\n\n")[0].split("\n")[1:]: if line.startswith("deleting "): deleted.append(line.split(" ", 1)[-1]) else: copie...
Guarantees that the source directory is always copied to the target.
def synchronized(name, source, delete=False, force=False, update=False, passwordfile=None, exclude=None, excludefrom=None, prepare=False, dryrun=False, additional_opts...
Get the configuration of the device tree at the given path
def get_data(datastore, path): ''' Get the configuration of the device tree at the given path :param datastore: The datastore, e.g. running, operational. One of the NETCONF store IETF types :type datastore: :class:`DatastoreType` (``str`` enum). :param path: The device path to set the val...
Set a data entry in a datastore
def set_data_value(datastore, path, data): ''' Set a data entry in a datastore :param datastore: The datastore, e.g. running, operational. One of the NETCONF store IETF types :type datastore: :class:`DatastoreType` (``str`` enum). :param path: The device path to set the value at, ...
Initialize the PostgreSQL data directory
def present(name, user=None, password=None, auth='password', encoding='UTF8', locale=None, runas=None, waldir=None, checksums=False): ''' Initialize the PostgreSQL data directory name The name of the directory to initialize user ...
List plugins in an installed wordpress path
def list_plugins(path, user): ''' List plugins in an installed wordpress path path path to wordpress install location user user to run the command as CLI Example: .. code-block:: bash salt '*' wordpress.list_plugins /var/www/html apache ''' ret = [] resp ...
Show a plugin in a wordpress install and check if it is installed
def show_plugin(name, path, user): ''' Show a plugin in a wordpress install and check if it is installed name Wordpress plugin name path path to wordpress install location user user to run the command as CLI Example: .. code-block:: bash salt '*' wordpre...
Activate a wordpress plugin
def activate(name, path, user): ''' Activate a wordpress plugin name Wordpress plugin name path path to wordpress install location user user to run the command as CLI Example: .. code-block:: bash salt '*' wordpress.activate HyperDB /var/www/html apache ...
Check if wordpress is installed and setup
def is_installed(path, user=None): ''' Check if wordpress is installed and setup path path to wordpress install location user user to run the command as CLI Example: .. code-block:: bash salt '*' wordpress.is_installed /var/www/html apache ''' retcode = __sal...
Run the initial setup functions for a wordpress install
def install(path, user, admin_user, admin_password, admin_email, title, url): ''' Run the initial setup functions for a wordpress install path path to wordpress install location user user to run the command as admin_user Username for the Administrative user for the wordpre...
Matches a grain based on regex
def match(tgt, delimiter=DEFAULT_TARGET_DELIM, opts=None): ''' Matches a grain based on regex ''' if not opts: opts = __opts__ log.debug('grains pcre target: %s', tgt) if delimiter not in tgt: log.error('Got insufficient arguments for grains pcre match ' 'statem...
.. versionadded:: 2018. 3. 0
def dump(data, stream=None, **kwargs): ''' .. versionadded:: 2018.3.0 Helper that wraps yaml.dump and ensures that we encode unicode strings unless explicitly told not to. ''' if 'allow_unicode' not in kwargs: kwargs['allow_unicode'] = True return yaml.dump(data, stream, **kwargs)
Use a custom dumper to ensure that defaultdict and OrderedDict are represented properly. Ensure that unicode strings are encoded unless explicitly told not to.
def safe_dump(data, stream=None, **kwargs): ''' Use a custom dumper to ensure that defaultdict and OrderedDict are represented properly. Ensure that unicode strings are encoded unless explicitly told not to. ''' if 'allow_unicode' not in kwargs: kwargs['allow_unicode'] = True return ...
Return available OpenNebula images.
def avail_images(call=None): ''' Return available OpenNebula images. CLI Example: .. code-block:: bash salt-cloud --list-images opennebula salt-cloud --function avail_images opennebula salt-cloud -f avail_images opennebula ''' if call == 'action': raise SaltCl...
Return available OpenNebula locations.
def avail_locations(call=None): ''' Return available OpenNebula locations. CLI Example: .. code-block:: bash salt-cloud --list-locations opennebula salt-cloud --function avail_locations opennebula salt-cloud -f avail_locations opennebula ''' if call == 'action': ...
Returns a list of clusters in OpenNebula.
def list_clusters(call=None): ''' Returns a list of clusters in OpenNebula. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt-cloud -f list_clusters opennebula ''' if call == 'action': raise SaltCloudSystemExit( 'The list_clusters function must...
Returns a list of data stores on OpenNebula.
def list_datastores(call=None): ''' Returns a list of data stores on OpenNebula. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt-cloud -f list_datastores opennebula ''' if call == 'action': raise SaltCloudSystemExit( 'The list_datastores func...
Lists all security groups available to the user and the user s groups.
def list_security_groups(call=None): ''' Lists all security groups available to the user and the user's groups. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt-cloud -f list_security_groups opennebula ''' if call == 'action': raise SaltCloudSystemExit( ...
Lists all templates available to the user and the user s groups.
def list_templates(call=None): ''' Lists all templates available to the user and the user's groups. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt-cloud -f list_templates opennebula ''' if call == 'action': raise SaltCloudSystemExit( 'The li...
Lists all virtual networks available to the user and the user s groups.
def list_vns(call=None): ''' Lists all virtual networks available to the user and the user's groups. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt-cloud -f list_vns opennebula ''' if call == 'action': raise SaltCloudSystemExit( 'The list_vn...
Reboot a VM.
def reboot(name, call=None): ''' Reboot a VM. .. versionadded:: 2016.3.0 name The name of the VM to reboot. CLI Example: .. code-block:: bash salt-cloud -a reboot my-vm ''' if call != 'action': raise SaltCloudSystemExit( 'The start action must be ...
Start a VM.
def start(name, call=None): ''' Start a VM. .. versionadded:: 2016.3.0 name The name of the VM to start. CLI Example: .. code-block:: bash salt-cloud -a start my-vm ''' if call != 'action': raise SaltCloudSystemExit( 'The start action must be call...
Stop a VM.
def stop(name, call=None): ''' Stop a VM. .. versionadded:: 2016.3.0 name The name of the VM to stop. CLI Example: .. code-block:: bash salt-cloud -a stop my-vm ''' if call != 'action': raise SaltCloudSystemExit( 'The start action must be called w...
Returns the OpenNebula version.
def get_one_version(kwargs=None, call=None): ''' Returns the OpenNebula version. .. versionadded:: 2016.3.5 CLI Example: .. code-block:: bash salt-cloud -f get_one_version one_provider_name ''' if call == 'action': raise SaltCloudSystemExit( 'The get_cluster_...
Returns a cluster s ID from the given cluster name.
def get_cluster_id(kwargs=None, call=None): ''' Returns a cluster's ID from the given cluster name. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt-cloud -f get_cluster_id opennebula name=my-cluster-name ''' if call == 'action': raise SaltCloudSystemExit...
Returns a data store s ID from the given data store name.
def get_datastore_id(kwargs=None, call=None): ''' Returns a data store's ID from the given data store name. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt-cloud -f get_datastore_id opennebula name=my-datastore-name ''' if call == 'action': raise SaltClo...