text stringlengths 81 112k |
|---|
Changes the amount of vcpus allocated to VM. The VM must be shutdown
for this to work.
If config is True then we ask libvirt to modify the config as well
:param vm_: name of the domain
:param vcpus: integer representing the number of CPUs to be assigned
:param config: if True then libvirt will be ... |
Internal variant of freemem taking a libvirt connection as parameter
def _freemem(conn):
'''
Internal variant of freemem taking a libvirt connection as parameter
'''
mem = conn.getInfo()[1]
# Take off just enough to sustain the hypervisor
mem -= 256
for dom in _get_domain(conn, iterable=Tru... |
Return an int representing the amount of memory (in MB) that has not
been given to virtual machines on this node
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.... |
Internal variant of freecpu taking a libvirt connection as parameter
def _freecpu(conn):
'''
Internal variant of freecpu taking a libvirt connection as parameter
'''
cpus = conn.getInfo()[2]
for dom in _get_domain(conn, iterable=True):
if dom.ID() > 0:
cpus -= dom.info()[3]
... |
Return an int representing the number of unallocated cpus on this
hypervisor
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to... |
Return the node_info, vm_info and freemem
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to connect with, overriding defaults
... |
Returns the XML for a given vm
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to connect with, overrid... |
Return the virt profiles for hypervisor.
Currently there are profiles for:
- nic
- disk
:param hypervisor: override the default machine type.
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overridin... |
Pause the named vm
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to connect with, overriding defaults... |
Start a defined domain
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to connect with, overriding defa... |
Hard power down the virtual machine, this is equivalent to pulling the power.
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:pa... |
Reboot a domain via ACPI request
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to connect with, overr... |
Reset a VM by emulating the reset button on a physical machine
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: p... |
Sends CTRL+ALT+DEL to a VM
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password to connect with, overriding ... |
Start a transient domain based on the XML passed to the function
:param xml: libvirt XML definition of the domain
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019... |
Start a transient domain based on the XML-file path passed to the function
:param path: path to a file containing the libvirt XML definition of the domain
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding... |
Define a persistent domain based on the XML passed to the function
:param xml: libvirt XML definition of the domain
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 20... |
Define a persistent domain based on the XML-file path passed to the function
:param path: path to a file containing the libvirt XML definition of the domain
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overridi... |
Define a volume based on the XML passed to the function
:param xml: libvirt XML definition of the storage volume
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.... |
Define a volume based on the XML-file path passed to the function
:param path: path to a file containing the libvirt XML definition of the volume
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults... |
Attempt to execute non-shared storage "all" migration
:param vm_: domain name
:param target: target libvirt host name
:param ssh: True to connect over ssh
CLI Example:
.. code-block:: bash
salt '*' virt.migrate_non_shared <vm name> <target hypervisor>
A tunnel data migration can be ... |
Non shared migration requires that the disks be present on the migration
destination, pass the disks information via this function, to the
migration destination before executing the migration.
:param disks: the list of disk data as provided by virt.get_disks
:param force: skip checking the compatibilit... |
Set the autostart flag on a VM so that the VM will start with the host
system on reboot.
:param vm_: domain name
:param state: 'on' to auto start the pool, anything else to mark the
pool not to be started when the host boots
:param connection: libvirt connection URI, overriding defaul... |
Remove a defined vm, this does not purge the virtual machine image, and
this only works if the vm is powered down
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
... |
Recursively destroy and delete a persistent virtual machine, pass True for
dir's to also delete the directories containing the virtual machine disk
images - USE WITH EXTREME CAUTION!
Pass removables=False to avoid deleting cdrom and floppy images. To avoid
disruption, the default but dangerous value is... |
Returns a bool whether or not this node is a KVM hypervisor
def _is_kvm_hyper():
'''
Returns a bool whether or not this node is a KVM hypervisor
'''
try:
with salt.utils.files.fopen('/proc/modules') as fp_:
if 'kvm_' not in salt.utils.stringutils.to_unicode(fp_.read()):
... |
Returns the name of the hypervisor running on this node or ``None``.
Detected hypervisors:
- kvm
- xen
- bhyve
CLI Example:
.. code-block:: bash
salt '*' virt.get_hypervisor
.. versionadded:: 2019.2.0
the function and the ``kvm``, ``xen`` and ``bhyve`` hypervisors suppo... |
Returns a bool whether or not this node is a bhyve hypervisor
def _is_bhyve_hyper():
'''
Returns a bool whether or not this node is a bhyve hypervisor
'''
sysctl_cmd = 'sysctl hw.vmm.create'
vmm_enabled = False
try:
stdout = subprocess.Popen(sysctl_cmd,
... |
Return cputime used by the vms on this hyper in a
list of dicts:
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param passw... |
Return combined network counters used by the vms on this hyper in a
list of dicts:
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.... |
Return disk usage counters used by the vms on this hyper in a
list of dicts:
:param vm_: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
... |
Parse XML doc and return a dict with the status values.
:param xmldoc:
:return:
def _parse_snapshot_description(vm_snapshot, unix_time=False):
'''
Parse XML doc and return a dict with the status values.
:param xmldoc:
:return:
'''
ret = dict()
tree = ElementTree.fromstring(vm_snap... |
List available snapshots for certain vm or for all.
:param domain: domain name
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadded:: 2019.2.0
:param password: password ... |
Create a snapshot of a VM.
:param domain: domain name
:param name: Name of the snapshot. If the name is omitted, then will be used original domain
name with ISO 8601 time as a suffix.
:param suffix: Add suffix for the new name. Useful in states, where such snapshots
can... |
Delete one or more snapshots of the given VM.
:param name: domain name
:param names: names of the snapshots to remove
:param connection: libvirt connection URI, overriding defaults
.. versionadded:: 2019.2.0
:param username: username to connect with, overriding defaults
.. versionadde... |
Revert snapshot to the previous from current (if available) or to the specific.
:param name: domain name
:param vm_snapshot: name of the snapshot to revert
:param cleanup: Remove all newer than reverted snapshots. Values: True or False (default False).
:param connection: libvirt connection URI, overrid... |
Parse the <machine> element of the host capabilities and add it
to the machines list.
def _caps_add_machine(machines, node):
'''
Parse the <machine> element of the host capabilities and add it
to the machines list.
'''
maxcpus = node.get('maxCpus')
canonical = node.get('canonical')
name... |
Parse the <guest> element of the connection capabilities XML
def _parse_caps_guest(guest):
'''
Parse the <guest> element of the connection capabilities XML
'''
arch_node = guest.find('arch')
result = {
'os_type': guest.find('os_type').text,
'arch': {
'name': arch_node.ge... |
Parse the <cell> nodes of the connection capabilities XML output.
def _parse_caps_cell(cell):
'''
Parse the <cell> nodes of the connection capabilities XML output.
'''
result = {
'id': int(cell.get('id'))
}
mem_node = cell.find('memory')
if mem_node is not None:
unit = mem_... |
Parse the <bank> element of the connection capabilities XML.
def _parse_caps_bank(bank):
'''
Parse the <bank> element of the connection capabilities XML.
'''
result = {
'id': int(bank.get('id')),
'level': int(bank.get('level')),
'type': bank.get('type'),
'size': "{} {}".... |
Parse the <host> element of the connection capabilities XML.
def _parse_caps_host(host):
'''
Parse the <host> element of the connection capabilities XML.
'''
result = {}
for child in host:
if child.tag == 'uuid':
result['uuid'] = child.text
elif child.tag == 'cpu':
... |
Return the hypervisor connection capabilities.
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: 2019.2.0
CLI Example:
.. code-block:: ... |
Parse the <cpu> element of the domain capabilities
def _parse_caps_cpu(node):
'''
Parse the <cpu> element of the domain capabilities
'''
result = {}
for mode in node.findall('mode'):
if not mode.get('supported') == 'yes':
continue
name = mode.get('name')
if name... |
Parse the devices or features list of the domain capatilities
def _parse_caps_devices_features(node):
'''
Parse the devices or features list of the domain capatilities
'''
result = {}
for child in node:
if child.get('supported') == 'yes':
enums = [_parse_caps_enum(node) for node... |
Parse the <loader> element of the domain capabilities.
def _parse_caps_loader(node):
'''
Parse the <loader> element of the domain capabilities.
'''
enums = [_parse_caps_enum(enum) for enum in node.findall('enum')]
result = {item[0]: item[1] for item in enums if item[0]}
values = [child.text fo... |
Parse the XML document of domain capabilities into a structure.
Return the domain capabilities given an emulator, architecture, machine or virtualization type.
.. versionadded:: 2019.2.0
:param emulator: return the capabilities for the given emulator binary
:param arch: return the capabilities for the... |
Return the domain capabilities given an emulator, architecture, machine or virtualization type.
.. versionadded:: 2019.2.0
:param emulator: return the capabilities for the given emulator binary
:param arch: return the capabilities for the given CPU architecture
:param machine: return the capabilities ... |
Return the host and domain capabilities in a single call.
.. versionadded:: Neon
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
CLI Example:
.. code-b... |
Return the optimal 'custom' CPU baseline config for VM's on this minion
.. versionadded:: 2016.3.0
:param full: Return all CPU features rather than the ones on top of the closest CPU model
:param migratable: Exclude CPU features that are unmigratable (libvirt 2.13+)
:param out: 'libvirt' (default) for... |
Create libvirt network.
:param name: Network name
:param bridge: Bridge name
:param forward: Forward mode(bridge, router, nat)
:param vport: Virtualport type
:param tag: Vlan tag
:param autostart: Network autostart (default True)
:param start: Network start (default True)
:param connect... |
List all virtual networks.
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: 2019.2.0
CLI Example:
.. code-block:: bash
salt '*... |
Return informations on a virtual network provided its name.
:param name: virtual network name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
If no name is p... |
Start a defined virtual network.
:param name: virtual network name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: 2019.2.0
CLI Exampl... |
Stop a defined virtual network.
:param name: virtual network name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: 2019.2.0
CLI Example... |
Remove a defined virtual network. This does not stop the virtual network.
:param name: virtual network name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.... |
Set the autostart flag on a virtual network so that the network
will start with the host system on reboot.
:param name: virtual network name
:param state: 'on' to auto start the network, anything else to mark the
virtual network not to be started when the host boots
:param connection:... |
Create libvirt pool.
:param name: Pool name
:param ptype: Pool type. See `libvirt documentation
<https://libvirt.org/storage.html>`_ for the possible values.
:param target: Pool full path target
:param permissions:
Permissions to set on the target folder. This is mostly used for
... |
List all storage pools.
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: 2019.2.0
CLI Example:
.. code-block:: bash
salt '*' ... |
Return informations on a storage pool provided its name.
:param name: libvirt storage pool name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
If no name is... |
Start a defined libvirt storage pool.
:param name: libvirt storage pool name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: 2019.2.0
... |
Build a defined libvirt storage pool.
:param name: libvirt storage pool name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: 2019.2.0
... |
Stop a defined libvirt storage pool.
:param name: libvirt storage pool name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: 2019.2.0
C... |
Remove a defined libvirt storage pool. The pool needs to be stopped before calling.
:param name: libvirt storage pool name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding ... |
Delete the resources of a defined libvirt storage pool.
:param name: libvirt storage pool name
:param fast: if set to False, zeroes out all the data.
Default value is True.
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overrid... |
Refresh a defined libvirt storage pool.
:param name: libvirt storage pool name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versionadded:: 2019.2.0
... |
Set the autostart flag on a libvirt storage pool so that the storage pool
will start with the host system on reboot.
:param name: libvirt storage pool name
:param state: 'on' to auto start the pool, anything else to mark the
pool not to be started when the host boots
:param connection... |
List the volumes contained in a defined libvirt storage pool.
:param name: libvirt storage pool name
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding defaults
.. versi... |
Helper function getting a storage volume. Will throw a libvirtError
if the pool or the volume couldn't be found.
def _get_storage_vol(conn, pool, vol):
'''
Helper function getting a storage volume. Will throw a libvirtError
if the pool or the volume couldn't be found.
'''
pool_obj = conn.storag... |
Extract the path and backing stores path of all volumes.
:param conn: libvirt connection to use
def _get_all_volumes_paths(conn):
'''
Extract the path and backing stores path of all volumes.
:param conn: libvirt connection to use
'''
volumes = [vol for l in [obj.listAllVolumes() for obj in co... |
Provide details on a storage volume. If no volume name is provided, the infos
all the volumes contained in the pool are provided. If no pool is provided,
the infos of the volumes of all pools are output.
:param pool: libvirt storage pool name (default: ``None``)
:param volume: name of the volume to get... |
Delete a libvirt managed volume.
:param pool: libvirt storage pool name
:param volume: name of the volume to delete
:param connection: libvirt connection URI, overriding defaults
:param username: username to connect with, overriding defaults
:param password: password to connect with, overriding def... |
List available metadata
CLI Example:
.. code-block:: bash
salt '*' mdata.list
def list_():
'''
List available metadata
CLI Example:
.. code-block:: bash
salt '*' mdata.list
'''
mdata = _check_mdata_list()
if mdata:
cmd = '{0}'.format(mdata)
retu... |
Get metadata
keyname : string
name of key
.. note::
If no keynames are specified, we get all (public) properties
CLI Example:
.. code-block:: bash
salt '*' mdata.get salt:role
salt '*' mdata.get user-script salt:role
def get_(*keyname):
'''
Get metadata
... |
Put metadata
prop : string
name of property
val : string
value to set
CLI Example:
.. code-block:: bash
salt '*' mdata.list
def put_(keyname, val):
'''
Put metadata
prop : string
name of property
val : string
value to set
CLI Example:
... |
Delete metadata
prop : string
name of property
CLI Example:
.. code-block:: bash
salt '*' mdata.get salt:role
salt '*' mdata.get user-script salt:role
def delete_(*keyname):
'''
Delete metadata
prop : string
name of property
CLI Example:
.. code-bl... |
List the a single node, return dict of grains.
def show_instance(name, call=None):
'''
List the a single node, return dict of grains.
'''
local = salt.client.LocalClient()
ret = local.cmd(name, 'grains.items')
ret.update(_build_required_items(ret))
return ret |
if configuration parameter ``deploy`` is ``True``,
Provision a single machine, adding its keys to the salt master
else,
Test ssh connections to the machine
Configuration parameters:
- deploy: (see above)
- provider: name of entry in ``salt/cloud.providers.d/???`` file
- ssh_ho... |
Verify credentials for an existing system
def _verify(vm_):
'''
Verify credentials for an existing system
'''
log.info('Verifying credentials for %s', vm_['name'])
win_installer = config.get_cloud_config_value(
'win_installer', vm_, __opts__)
if win_installer:
log.debug('Test... |
Destroy a node.
.. versionadded:: 2018.3.0
Disconnect a minion from the master, and remove its keys.
Optionally, (if ``remove_config_on_destroy`` is ``True``),
disables salt-minion from running on the minion, and
erases the Salt configuration files from it.
Optionally, (if ``shutdown_on_... |
Reboot a saltify minion.
..versionadded:: 2018.3.0
name
The name of the VM to reboot.
CLI Example:
.. code-block:: bash
salt-cloud -a reboot vm_name
def reboot(name, call=None):
'''
Reboot a saltify minion.
..versionadded:: 2018.3.0
name
The name of the VM... |
Ensure the job is present in the Jenkins configured jobs
name
The unique name for the Jenkins job
config
The Salt URL for the file to use for configuring the job
def present(name,
config=None,
**kwargs):
'''
Ensure the job is present in the Jenkins configured j... |
Ensure the job is absent from the Jenkins configured jobs
name
The name of the Jenkins job to remove
def absent(name,
**kwargs):
'''
Ensure the job is absent from the Jenkins configured jobs
name
The name of the Jenkins job to remove
'''
ret = {'name': name,
... |
Iterate over a list of proxy
names and restart any that
aren't running
def _run_proxy_processes(proxies):
'''
Iterate over a list of proxy
names and restart any that
aren't running
'''
ret = []
for proxy in proxies:
result = {}
if not __salt__['salt_proxy.is_running'... |
Handle configured proxies
.. code-block:: yaml
beacons:
salt_proxy:
- proxies:
p8000: {}
p8001: {}
def beacon(config):
'''
Handle configured proxies
.. code-block:: yaml
beacons:
salt_proxy:
- proxies:
... |
returns a list of applied powerpath license keys
def list_licenses():
'''
returns a list of applied powerpath license keys
'''
KEY_PATTERN = re.compile('Key (.*)')
keys = []
out = __salt__['cmd.run']('/sbin/emcpreg -list')
for line in out.splitlines():
match = KEY_PATTERN.match(lin... |
Add a license
def add_license(key):
'''
Add a license
'''
result = {
'result': False,
'retcode': -1,
'output': ''
}
if not has_powerpath():
result['output'] = 'PowerPath is not installed'
return result
cmd = '/sbin/emcpreg -add {0}'.format(key)
... |
Ensures that the specified columns of the named record have the specified
values.
Args:
name: The name of the record.
table: The name of the table to which the record belongs.
data: Dictionary containing a mapping from column names to the desired
values. Columns that exist, ... |
This is part of an ugly hack to fix an ancient bug in M2Crypto
https://bugzilla.osafoundation.org/show_bug.cgi?id=7530#c13
def _fix_ctx(m2_ctx, issuer=None):
'''
This is part of an ugly hack to fix an ancient bug in M2Crypto
https://bugzilla.osafoundation.org/show_bug.cgi?id=7530#c13
'''
ctx = ... |
Create new X509_Extension, This is required because M2Crypto
doesn't support getting the publickeyidentifier from the issuer
to create the authoritykeyidentifier extension.
def _new_extension(name, value, critical=0, issuer=None, _pyfree=1):
'''
Create new X509_Extension, This is required because M2Cry... |
Parses openssl command line output, this is a workaround for M2Crypto's
inability to get them from CSR objects.
def _parse_openssl_req(csr_filename):
'''
Parses openssl command line output, this is a workaround for M2Crypto's
inability to get them from CSR objects.
'''
if not salt.utils.path.wh... |
Returns a list of dicts containing the name, value and critical value of
any extension contained in a csr object.
def _get_csr_extensions(csr):
'''
Returns a list of dicts containing the name, value and critical value of
any extension contained in a csr object.
'''
ret = OrderedDict()
csrt... |
Parses openssl command line output, this is a workaround for M2Crypto's
inability to get them from CSR objects.
def _parse_openssl_crl(crl_filename):
'''
Parses openssl command line output, this is a workaround for M2Crypto's
inability to get them from CSR objects.
'''
if not salt.utils.path.wh... |
Nicely formats hex strings
def _pretty_hex(hex_str):
'''
Nicely formats hex strings
'''
if len(hex_str) % 2 != 0:
hex_str = '0' + hex_str
return ':'.join(
[hex_str[i:i + 2] for i in range(0, len(hex_str), 2)]).upper() |
Determines if input is a path to a file, or a string with the
content to be parsed.
def _text_or_file(input_):
'''
Determines if input is a path to a file, or a string with the
content to be parsed.
'''
if _isfile(input_):
with salt.utils.files.fopen(input_) as fp_:
out = sa... |
Returns a dict containing all values in an X509 Subject
def _parse_subject(subject):
'''
Returns a dict containing all values in an X509 Subject
'''
ret = {}
nids = []
for nid_name, nid_num in six.iteritems(subject.nid):
if nid_num in nids:
continue
try:
... |
Returns a certificate object based on PEM text.
def _get_certificate_obj(cert):
'''
Returns a certificate object based on PEM text.
'''
if isinstance(cert, M2Crypto.X509.X509):
return cert
text = _text_or_file(cert)
text = get_pem_entry(text, pem_type='CERTIFICATE')
return M2Crypto... |
Returns a private key object based on PEM text.
def _get_private_key_obj(private_key, passphrase=None):
'''
Returns a private key object based on PEM text.
'''
private_key = _text_or_file(private_key)
private_key = get_pem_entry(private_key, pem_type='(?:RSA )?PRIVATE KEY')
rsaprivkey = M2Crypt... |
Returns a callback function used to supply a passphrase for private keys
def _passphrase_callback(passphrase):
'''
Returns a callback function used to supply a passphrase for private keys
'''
def f(*args):
return salt.utils.stringutils.to_bytes(passphrase)
return f |
Returns a CSR object based on PEM text.
def _get_request_obj(csr):
'''
Returns a CSR object based on PEM text.
'''
text = _text_or_file(csr)
text = get_pem_entry(text, pem_type='CERTIFICATE REQUEST')
return M2Crypto.X509.load_request_string(text) |
Returns the sha1 hash of the modulus of a public key in a cert
Used for generating subject key identifiers
def _get_pubkey_hash(cert):
'''
Returns the sha1 hash of the modulus of a public key in a cert
Used for generating subject key identifiers
'''
sha_hash = hashlib.sha1(cert.get_pubkey().get... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.