partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | purge | 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... | salt/modules/virt.py | def purge(vm_, dirs=False, removables=None, **kwargs):
'''
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 ... | def purge(vm_, dirs=False, removables=None, **kwargs):
'''
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 ... | [
"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",
"CA... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3350-L3421 | [
"def",
"purge",
"(",
"vm_",
",",
"dirs",
"=",
"False",
",",
"removables",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"dom",
"=",
"_get_domain",
"(",
"conn",
",",
"vm_",
")",
"disks",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _is_kvm_hyper | Returns a bool whether or not this node is a KVM hypervisor | salt/modules/virt.py | 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()):
return False
except IOError:
# No /proc/modul... | 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()):
return False
except IOError:
# No /proc/modul... | [
"Returns",
"a",
"bool",
"whether",
"or",
"not",
"this",
"node",
"is",
"a",
"KVM",
"hypervisor"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3437-L3448 | [
"def",
"_is_kvm_hyper",
"(",
")",
":",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"'/proc/modules'",
")",
"as",
"fp_",
":",
"if",
"'kvm_'",
"not",
"in",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_unicode",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_hypervisor | 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... | salt/modules/virt.py | def get_hypervisor():
'''
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... | def get_hypervisor():
'''
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... | [
"Returns",
"the",
"name",
"of",
"the",
"hypervisor",
"running",
"on",
"this",
"node",
"or",
"None",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3511-L3534 | [
"def",
"get_hypervisor",
"(",
")",
":",
"# To add a new 'foo' hypervisor, add the _is_foo_hyper function,",
"# add 'foo' to the list below and add it to the docstring with a .. versionadded::",
"hypervisors",
"=",
"[",
"'kvm'",
",",
"'xen'",
",",
"'bhyve'",
"]",
"result",
"=",
"[... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _is_bhyve_hyper | Returns a bool whether or not this node is a bhyve hypervisor | salt/modules/virt.py | 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,
shell=True,
stdout=subproces... | 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,
shell=True,
stdout=subproces... | [
"Returns",
"a",
"bool",
"whether",
"or",
"not",
"this",
"node",
"is",
"a",
"bhyve",
"hypervisor"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3537-L3550 | [
"def",
"_is_bhyve_hyper",
"(",
")",
":",
"sysctl_cmd",
"=",
"'sysctl hw.vmm.create'",
"vmm_enabled",
"=",
"False",
"try",
":",
"stdout",
"=",
"subprocess",
".",
"Popen",
"(",
"sysctl_cmd",
",",
"shell",
"=",
"True",
",",
"stdout",
"=",
"subprocess",
".",
"PI... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | vm_cputime | 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... | salt/modules/virt.py | def vm_cputime(vm_=None, **kwargs):
'''
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
... | def vm_cputime(vm_=None, **kwargs):
'''
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
... | [
"Return",
"cputime",
"used",
"by",
"the",
"vms",
"on",
"this",
"hyper",
"in",
"a",
"list",
"of",
"dicts",
":"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3568-L3628 | [
"def",
"vm_cputime",
"(",
"vm_",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"host_cpus",
"=",
"conn",
".",
"getInfo",
"(",
")",
"[",
"2",
"]",
"def",
"_info",
"(",
"dom",
")",
":",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | vm_netstats | 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.... | salt/modules/virt.py | def vm_netstats(vm_=None, **kwargs):
'''
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, overr... | def vm_netstats(vm_=None, **kwargs):
'''
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, overr... | [
"Return",
"combined",
"network",
"counters",
"used",
"by",
"the",
"vms",
"on",
"this",
"hyper",
"in",
"a",
"list",
"of",
"dicts",
":"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3631-L3709 | [
"def",
"vm_netstats",
"(",
"vm_",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"_info",
"(",
"dom",
")",
":",
"'''\n Compute network stats of a domain\n '''",
"nics",
"=",
"_get_nics",
"(",
"dom",
")",
"ret",
"=",
"{",
"'rx_bytes'",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | vm_diskstats | 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
... | salt/modules/virt.py | def vm_diskstats(vm_=None, **kwargs):
'''
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... | def vm_diskstats(vm_=None, **kwargs):
'''
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... | [
"Return",
"disk",
"usage",
"counters",
"used",
"by",
"the",
"vms",
"on",
"this",
"hyper",
"in",
"a",
"list",
"of",
"dicts",
":"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3712-L3788 | [
"def",
"vm_diskstats",
"(",
"vm_",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"get_disk_devs",
"(",
"dom",
")",
":",
"'''\n Extract the disk devices names from the domain XML definition\n '''",
"doc",
"=",
"ElementTree",
".",
"fromstring",
"(... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_snapshot_description | Parse XML doc and return a dict with the status values.
:param xmldoc:
:return: | salt/modules/virt.py | 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_snapshot.getXMLDesc())
for node in tree:
if node.tag == 'name':
ret['n... | 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_snapshot.getXMLDesc())
for node in tree:
if node.tag == 'name':
ret['n... | [
"Parse",
"XML",
"doc",
"and",
"return",
"a",
"dict",
"with",
"the",
"status",
"values",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3791-L3811 | [
"def",
"_parse_snapshot_description",
"(",
"vm_snapshot",
",",
"unix_time",
"=",
"False",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"tree",
"=",
"ElementTree",
".",
"fromstring",
"(",
"vm_snapshot",
".",
"getXMLDesc",
"(",
")",
")",
"for",
"node",
"in",
"tre... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_snapshots | 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 ... | salt/modules/virt.py | def list_snapshots(domain=None, **kwargs):
'''
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
..... | def list_snapshots(domain=None, **kwargs):
'''
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
..... | [
"List",
"available",
"snapshots",
"for",
"certain",
"vm",
"or",
"for",
"all",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3814-L3844 | [
"def",
"list_snapshots",
"(",
"domain",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"for",
"vm_domain",
"in",
"_get_domain",
"(",
"conn",
",",
"*",
"(",
"dom... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | snapshot | 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... | salt/modules/virt.py | def snapshot(domain, name=None, suffix=None, **kwargs):
'''
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... | def snapshot(domain, name=None, suffix=None, **kwargs):
'''
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... | [
"Create",
"a",
"snapshot",
"of",
"a",
"VM",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3847-L3894 | [
"def",
"snapshot",
"(",
"domain",
",",
"name",
"=",
"None",
",",
"suffix",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"and",
"name",
".",
"lower",
"(",
")",
"==",
"domain",
".",
"lower",
"(",
")",
":",
"raise",
"CommandExecutionE... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | delete_snapshots | 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... | salt/modules/virt.py | def delete_snapshots(name, *names, **kwargs):
'''
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... | def delete_snapshots(name, *names, **kwargs):
'''
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... | [
"Delete",
"one",
"or",
"more",
"snapshots",
"of",
"the",
"given",
"VM",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3897-L3934 | [
"def",
"delete_snapshots",
"(",
"name",
",",
"*",
"names",
",",
"*",
"*",
"kwargs",
")",
":",
"deleted",
"=",
"dict",
"(",
")",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"domain",
"=",
"_get_domain",
"(",
"conn",
",",
"name",
")",
"f... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | revert_snapshot | 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... | salt/modules/virt.py | def revert_snapshot(name, vm_snapshot=None, cleanup=False, **kwargs):
'''
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: Tru... | def revert_snapshot(name, vm_snapshot=None, cleanup=False, **kwargs):
'''
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: Tru... | [
"Revert",
"snapshot",
"to",
"the",
"previous",
"from",
"current",
"(",
"if",
"available",
")",
"or",
"to",
"the",
"specific",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L3937-L4016 | [
"def",
"revert_snapshot",
"(",
"name",
",",
"vm_snapshot",
"=",
"None",
",",
"cleanup",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"domain",
"=",
"_get_domai... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _caps_add_machine | Parse the <machine> element of the host capabilities and add it
to the machines list. | salt/modules/virt.py | 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 = node.text
alternate_name = ""
if canonical:
alternate_name = name
... | 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 = node.text
alternate_name = ""
if canonical:
alternate_name = name
... | [
"Parse",
"the",
"<machine",
">",
"element",
"of",
"the",
"host",
"capabilities",
"and",
"add",
"it",
"to",
"the",
"machines",
"list",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4019-L4040 | [
"def",
"_caps_add_machine",
"(",
"machines",
",",
"node",
")",
":",
"maxcpus",
"=",
"node",
".",
"get",
"(",
"'maxCpus'",
")",
"canonical",
"=",
"node",
".",
"get",
"(",
"'canonical'",
")",
"name",
"=",
"node",
".",
"text",
"alternate_name",
"=",
"\"\"",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_caps_guest | Parse the <guest> element of the connection capabilities XML | salt/modules/virt.py | 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.get('name'),
'machines': {},
'domains': ... | 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.get('name'),
'machines': {},
'domains': ... | [
"Parse",
"the",
"<guest",
">",
"element",
"of",
"the",
"connection",
"capabilities",
"XML"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4043-L4087 | [
"def",
"_parse_caps_guest",
"(",
"guest",
")",
":",
"arch_node",
"=",
"guest",
".",
"find",
"(",
"'arch'",
")",
"result",
"=",
"{",
"'os_type'",
":",
"guest",
".",
"find",
"(",
"'os_type'",
")",
".",
"text",
",",
"'arch'",
":",
"{",
"'name'",
":",
"a... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_caps_cell | Parse the <cell> nodes of the connection capabilities XML output. | salt/modules/virt.py | 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_node.get('unit', 'KiB')
memory = mem_node.text
resu... | 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_node.get('unit', 'KiB')
memory = mem_node.text
resu... | [
"Parse",
"the",
"<cell",
">",
"nodes",
"of",
"the",
"connection",
"capabilities",
"XML",
"output",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4090-L4134 | [
"def",
"_parse_caps_cell",
"(",
"cell",
")",
":",
"result",
"=",
"{",
"'id'",
":",
"int",
"(",
"cell",
".",
"get",
"(",
"'id'",
")",
")",
"}",
"mem_node",
"=",
"cell",
".",
"find",
"(",
"'memory'",
")",
"if",
"mem_node",
"is",
"not",
"None",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_caps_bank | Parse the <bank> element of the connection capabilities XML. | salt/modules/virt.py | 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': "{} {}".format(bank.get('size'), bank.get('unit')),
'cpus': ba... | 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': "{} {}".format(bank.get('size'), bank.get('unit')),
'cpus': ba... | [
"Parse",
"the",
"<bank",
">",
"element",
"of",
"the",
"connection",
"capabilities",
"XML",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4137-L4165 | [
"def",
"_parse_caps_bank",
"(",
"bank",
")",
":",
"result",
"=",
"{",
"'id'",
":",
"int",
"(",
"bank",
".",
"get",
"(",
"'id'",
")",
")",
",",
"'level'",
":",
"int",
"(",
"bank",
".",
"get",
"(",
"'level'",
")",
")",
",",
"'type'",
":",
"bank",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_caps_host | Parse the <host> element of the connection capabilities XML. | salt/modules/virt.py | 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':
cpu = {
'arch': child.find('arch').te... | 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':
cpu = {
'arch': child.find('arch').te... | [
"Parse",
"the",
"<host",
">",
"element",
"of",
"the",
"connection",
"capabilities",
"XML",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4168-L4226 | [
"def",
"_parse_caps_host",
"(",
"host",
")",
":",
"result",
"=",
"{",
"}",
"for",
"child",
"in",
"host",
":",
"if",
"child",
".",
"tag",
"==",
"'uuid'",
":",
"result",
"[",
"'uuid'",
"]",
"=",
"child",
".",
"text",
"elif",
"child",
".",
"tag",
"=="... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | capabilities | 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:: ... | salt/modules/virt.py | def capabilities(**kwargs):
'''
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... | def capabilities(**kwargs):
'''
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... | [
"Return",
"the",
"hypervisor",
"connection",
"capabilities",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4229-L4252 | [
"def",
"capabilities",
"(",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"caps",
"=",
"ElementTree",
".",
"fromstring",
"(",
"conn",
".",
"getCapabilities",
"(",
")",
")",
"conn",
".",
"close",
"(",
")",
"ret... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_caps_cpu | Parse the <cpu> element of the domain capabilities | salt/modules/virt.py | 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 == 'host-passthrough':
result[name] = T... | 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 == 'host-passthrough':
result[name] = T... | [
"Parse",
"the",
"<cpu",
">",
"element",
"of",
"the",
"domain",
"capabilities"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4262-L4309 | [
"def",
"_parse_caps_cpu",
"(",
"node",
")",
":",
"result",
"=",
"{",
"}",
"for",
"mode",
"in",
"node",
".",
"findall",
"(",
"'mode'",
")",
":",
"if",
"not",
"mode",
".",
"get",
"(",
"'supported'",
")",
"==",
"'yes'",
":",
"continue",
"name",
"=",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_caps_devices_features | Parse the devices or features list of the domain capatilities | salt/modules/virt.py | 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 in child.findall('enum')]
result[child.tag] = {ite... | 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 in child.findall('enum')]
result[child.tag] = {ite... | [
"Parse",
"the",
"devices",
"or",
"features",
"list",
"of",
"the",
"domain",
"capatilities"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4312-L4321 | [
"def",
"_parse_caps_devices_features",
"(",
"node",
")",
":",
"result",
"=",
"{",
"}",
"for",
"child",
"in",
"node",
":",
"if",
"child",
".",
"get",
"(",
"'supported'",
")",
"==",
"'yes'",
":",
"enums",
"=",
"[",
"_parse_caps_enum",
"(",
"node",
")",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_caps_loader | Parse the <loader> element of the domain capabilities. | salt/modules/virt.py | 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 for child in node.findall('value')]
if values:
... | 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 for child in node.findall('value')]
if values:
... | [
"Parse",
"the",
"<loader",
">",
"element",
"of",
"the",
"domain",
"capabilities",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4324-L4336 | [
"def",
"_parse_caps_loader",
"(",
"node",
")",
":",
"enums",
"=",
"[",
"_parse_caps_enum",
"(",
"enum",
")",
"for",
"enum",
"in",
"node",
".",
"findall",
"(",
"'enum'",
")",
"]",
"result",
"=",
"{",
"item",
"[",
"0",
"]",
":",
"item",
"[",
"1",
"]"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_domain_caps | 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... | salt/modules/virt.py | def _parse_domain_caps(caps):
'''
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
:p... | def _parse_domain_caps(caps):
'''
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
:p... | [
"Parse",
"the",
"XML",
"document",
"of",
"domain",
"capabilities",
"into",
"a",
"structure",
".",
"Return",
"the",
"domain",
"capabilities",
"given",
"an",
"emulator",
"architecture",
"machine",
"or",
"virtualization",
"type",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4339-L4402 | [
"def",
"_parse_domain_caps",
"(",
"caps",
")",
":",
"result",
"=",
"{",
"'emulator'",
":",
"caps",
".",
"find",
"(",
"'path'",
")",
".",
"text",
"if",
"caps",
".",
"find",
"(",
"'path'",
")",
"is",
"not",
"None",
"else",
"None",
",",
"'domain'",
":",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | domain_capabilities | 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 ... | salt/modules/virt.py | def domain_capabilities(emulator=None, arch=None, machine=None, domain=None, **kwargs):
'''
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:... | def domain_capabilities(emulator=None, arch=None, machine=None, domain=None, **kwargs):
'''
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",
"domain",
"capabilities",
"given",
"an",
"emulator",
"architecture",
"machine",
"or",
"virtualization",
"type",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4405-L4439 | [
"def",
"domain_capabilities",
"(",
"emulator",
"=",
"None",
",",
"arch",
"=",
"None",
",",
"machine",
"=",
"None",
",",
"domain",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"result",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | all_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... | salt/modules/virt.py | def all_capabilities(**kwargs):
'''
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, overridi... | def all_capabilities(**kwargs):
'''
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, overridi... | [
"Return",
"the",
"host",
"and",
"domain",
"capabilities",
"in",
"a",
"single",
"call",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4442-L4478 | [
"def",
"all_capabilities",
"(",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"result",
"=",
"{",
"}",
"try",
":",
"host_caps",
"=",
"ElementTree",
".",
"fromstring",
"(",
"conn",
".",
"getCapabilities",
"(",
")... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | cpu_baseline | 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... | salt/modules/virt.py | def cpu_baseline(full=False, migratable=False, out='libvirt', **kwargs):
'''
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 f... | def cpu_baseline(full=False, migratable=False, out='libvirt', **kwargs):
'''
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 f... | [
"Return",
"the",
"optimal",
"custom",
"CPU",
"baseline",
"config",
"for",
"VM",
"s",
"on",
"this",
"minion"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4481-L4562 | [
"def",
"cpu_baseline",
"(",
"full",
"=",
"False",
",",
"migratable",
"=",
"False",
",",
"out",
"=",
"'libvirt'",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"caps",
"=",
"ElementTree",
".",
"fromstring",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | network_define | 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... | salt/modules/virt.py | def network_define(name, bridge, forward, **kwargs):
'''
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)
... | def network_define(name, bridge, forward, **kwargs):
'''
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)
... | [
"Create",
"libvirt",
"network",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4565-L4628 | [
"def",
"network_define",
"(",
"name",
",",
"bridge",
",",
"forward",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"vport",
"=",
"kwargs",
".",
"get",
"(",
"'vport'",
",",
"None",
")",
"tag",
"=",
"kwar... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_networks | 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 '*... | salt/modules/virt.py | def list_networks(**kwargs):
'''
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:
... | def list_networks(**kwargs):
'''
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:
... | [
"List",
"all",
"virtual",
"networks",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4631-L4651 | [
"def",
"list_networks",
"(",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"return",
"[",
"net",
".",
"name",
"(",
")",
"for",
"net",
"in",
"conn",
".",
"listAllNetworks",
"(",
")",
"]",
"finally... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | network_info | 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... | salt/modules/virt.py | def network_info(name=None, **kwargs):
'''
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 con... | def network_info(name=None, **kwargs):
'''
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 con... | [
"Return",
"informations",
"on",
"a",
"virtual",
"network",
"provided",
"its",
"name",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4654-L4703 | [
"def",
"network_info",
"(",
"name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"{",
"}",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"def",
"_net_get_leases",
"(",
"net",
")",
":",
"'''\n Get all DHCP leases for a ne... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | network_start | 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... | salt/modules/virt.py | def network_start(name, **kwargs):
'''
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
... | def network_start(name, **kwargs):
'''
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
... | [
"Start",
"a",
"defined",
"virtual",
"network",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4706-L4728 | [
"def",
"network_start",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"net",
"=",
"conn",
".",
"networkLookupByName",
"(",
"name",
")",
"return",
"not",
"bool",
"(",
"net",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | network_stop | 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... | salt/modules/virt.py | def network_stop(name, **kwargs):
'''
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
... | def network_stop(name, **kwargs):
'''
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
... | [
"Stop",
"a",
"defined",
"virtual",
"network",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4731-L4753 | [
"def",
"network_stop",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"net",
"=",
"conn",
".",
"networkLookupByName",
"(",
"name",
")",
"return",
"not",
"bool",
"(",
"net",
".",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | network_undefine | 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
.... | salt/modules/virt.py | def network_undefine(name, **kwargs):
'''
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: pa... | def network_undefine(name, **kwargs):
'''
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: pa... | [
"Remove",
"a",
"defined",
"virtual",
"network",
".",
"This",
"does",
"not",
"stop",
"the",
"virtual",
"network",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4756-L4778 | [
"def",
"network_undefine",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"net",
"=",
"conn",
".",
"networkLookupByName",
"(",
"name",
")",
"return",
"not",
"bool",
"(",
"net",
"."... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | network_set_autostart | 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:... | salt/modules/virt.py | def network_set_autostart(name, state='on', **kwargs):
'''
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 n... | def network_set_autostart(name, state='on', **kwargs):
'''
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 n... | [
"Set",
"the",
"autostart",
"flag",
"on",
"a",
"virtual",
"network",
"so",
"that",
"the",
"network",
"will",
"start",
"with",
"the",
"host",
"system",
"on",
"reboot",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4781-L4806 | [
"def",
"network_set_autostart",
"(",
"name",
",",
"state",
"=",
"'on'",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"net",
"=",
"conn",
".",
"networkLookupByName",
"(",
"name",
")",
"return",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_define | 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
... | salt/modules/virt.py | def pool_define(name,
ptype,
target=None,
permissions=None,
source_devices=None,
source_dir=None,
source_adapter=None,
source_hosts=None,
source_auth=None,
source_name=None,
... | def pool_define(name,
ptype,
target=None,
permissions=None,
source_devices=None,
source_dir=None,
source_adapter=None,
source_hosts=None,
source_auth=None,
source_name=None,
... | [
"Create",
"libvirt",
"pool",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4809-L4979 | [
"def",
"pool_define",
"(",
"name",
",",
"ptype",
",",
"target",
"=",
"None",
",",
"permissions",
"=",
"None",
",",
"source_devices",
"=",
"None",
",",
"source_dir",
"=",
"None",
",",
"source_adapter",
"=",
"None",
",",
"source_hosts",
"=",
"None",
",",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_pools | 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 '*' ... | salt/modules/virt.py | def list_pools(**kwargs):
'''
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:
.... | def list_pools(**kwargs):
'''
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:
.... | [
"List",
"all",
"storage",
"pools",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L4982-L5002 | [
"def",
"list_pools",
"(",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"return",
"[",
"pool",
".",
"name",
"(",
")",
"for",
"pool",
"in",
"conn",
".",
"listAllStoragePools",
"(",
")",
"]",
"fina... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_info | 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... | salt/modules/virt.py | def pool_info(name=None, **kwargs):
'''
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 conn... | def pool_info(name=None, **kwargs):
'''
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 conn... | [
"Return",
"informations",
"on",
"a",
"storage",
"pool",
"provided",
"its",
"name",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5005-L5057 | [
"def",
"pool_info",
"(",
"name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"{",
"}",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"def",
"_pool_extract_infos",
"(",
"pool",
")",
":",
"'''\n Format the pool info dicti... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_start | 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
... | salt/modules/virt.py | def pool_start(name, **kwargs):
'''
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 de... | def pool_start(name, **kwargs):
'''
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 de... | [
"Start",
"a",
"defined",
"libvirt",
"storage",
"pool",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5060-L5082 | [
"def",
"pool_start",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"pool",
"=",
"conn",
".",
"storagePoolLookupByName",
"(",
"name",
")",
"return",
"not",
"bool",
"(",
"pool",
"."... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_build | 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
... | salt/modules/virt.py | def pool_build(name, **kwargs):
'''
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 de... | def pool_build(name, **kwargs):
'''
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 de... | [
"Build",
"a",
"defined",
"libvirt",
"storage",
"pool",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5085-L5107 | [
"def",
"pool_build",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"pool",
"=",
"conn",
".",
"storagePoolLookupByName",
"(",
"name",
")",
"return",
"not",
"bool",
"(",
"pool",
"."... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_stop | 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... | salt/modules/virt.py | def pool_stop(name, **kwargs):
'''
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 defa... | def pool_stop(name, **kwargs):
'''
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 defa... | [
"Stop",
"a",
"defined",
"libvirt",
"storage",
"pool",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5110-L5132 | [
"def",
"pool_stop",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"pool",
"=",
"conn",
".",
"storagePoolLookupByName",
"(",
"name",
")",
"return",
"not",
"bool",
"(",
"pool",
".",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_undefine | 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 ... | salt/modules/virt.py | def pool_undefine(name, **kwargs):
'''
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 ... | def pool_undefine(name, **kwargs):
'''
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 ... | [
"Remove",
"a",
"defined",
"libvirt",
"storage",
"pool",
".",
"The",
"pool",
"needs",
"to",
"be",
"stopped",
"before",
"calling",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5135-L5157 | [
"def",
"pool_undefine",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"pool",
"=",
"conn",
".",
"storagePoolLookupByName",
"(",
"name",
")",
"return",
"not",
"bool",
"(",
"pool",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_delete | 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... | salt/modules/virt.py | def pool_delete(name, fast=True, **kwargs):
'''
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 default... | def pool_delete(name, fast=True, **kwargs):
'''
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 default... | [
"Delete",
"the",
"resources",
"of",
"a",
"defined",
"libvirt",
"storage",
"pool",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5160-L5187 | [
"def",
"pool_delete",
"(",
"name",
",",
"fast",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"pool",
"=",
"conn",
".",
"storagePoolLookupByName",
"(",
"name",
")",
"flags",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_refresh | 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
... | salt/modules/virt.py | def pool_refresh(name, **kwargs):
'''
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, overridin... | def pool_refresh(name, **kwargs):
'''
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, overridin... | [
"Refresh",
"a",
"defined",
"libvirt",
"storage",
"pool",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5190-L5212 | [
"def",
"pool_refresh",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"pool",
"=",
"conn",
".",
"storagePoolLookupByName",
"(",
"name",
")",
"return",
"not",
"bool",
"(",
"pool",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_set_autostart | 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... | salt/modules/virt.py | def pool_set_autostart(name, state='on', **kwargs):
'''
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
... | def pool_set_autostart(name, state='on', **kwargs):
'''
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
... | [
"Set",
"the",
"autostart",
"flag",
"on",
"a",
"libvirt",
"storage",
"pool",
"so",
"that",
"the",
"storage",
"pool",
"will",
"start",
"with",
"the",
"host",
"system",
"on",
"reboot",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5215-L5240 | [
"def",
"pool_set_autostart",
"(",
"name",
",",
"state",
"=",
"'on'",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"pool",
"=",
"conn",
".",
"storagePoolLookupByName",
"(",
"name",
")",
"return"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | pool_list_volumes | 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... | salt/modules/virt.py | def pool_list_volumes(name, **kwargs):
'''
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... | def pool_list_volumes(name, **kwargs):
'''
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... | [
"List",
"the",
"volumes",
"contained",
"in",
"a",
"defined",
"libvirt",
"storage",
"pool",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5243-L5265 | [
"def",
"pool_list_volumes",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"pool",
"=",
"conn",
".",
"storagePoolLookupByName",
"(",
"name",
")",
"return",
"pool",
".",
"listVolumes",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_storage_vol | Helper function getting a storage volume. Will throw a libvirtError
if the pool or the volume couldn't be found. | salt/modules/virt.py | 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.storagePoolLookupByName(pool)
return pool_obj.storageVolLookupByName(vol) | 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.storagePoolLookupByName(pool)
return pool_obj.storageVolLookupByName(vol) | [
"Helper",
"function",
"getting",
"a",
"storage",
"volume",
".",
"Will",
"throw",
"a",
"libvirtError",
"if",
"the",
"pool",
"or",
"the",
"volume",
"couldn",
"t",
"be",
"found",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5268-L5274 | [
"def",
"_get_storage_vol",
"(",
"conn",
",",
"pool",
",",
"vol",
")",
":",
"pool_obj",
"=",
"conn",
".",
"storagePoolLookupByName",
"(",
"pool",
")",
"return",
"pool_obj",
".",
"storageVolLookupByName",
"(",
"vol",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_all_volumes_paths | Extract the path and backing stores path of all volumes.
:param conn: libvirt connection to use | salt/modules/virt.py | 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 conn.listAllStoragePools()] for vol in l]
return {vol.path(): [path.text for path in ElementTree.fro... | 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 conn.listAllStoragePools()] for vol in l]
return {vol.path(): [path.text for path in ElementTree.fro... | [
"Extract",
"the",
"path",
"and",
"backing",
"stores",
"path",
"of",
"all",
"volumes",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5290-L5298 | [
"def",
"_get_all_volumes_paths",
"(",
"conn",
")",
":",
"volumes",
"=",
"[",
"vol",
"for",
"l",
"in",
"[",
"obj",
".",
"listAllVolumes",
"(",
")",
"for",
"obj",
"in",
"conn",
".",
"listAllStoragePools",
"(",
")",
"]",
"for",
"vol",
"in",
"l",
"]",
"r... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | volume_infos | 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... | salt/modules/virt.py | def volume_infos(pool=None, volume=None, **kwargs):
'''
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 ... | def volume_infos(pool=None, volume=None, **kwargs):
'''
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 ... | [
"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",
"in... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5301-L5367 | [
"def",
"volume_infos",
"(",
"pool",
"=",
"None",
",",
"volume",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"{",
"}",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"backing_stores",
"=",
"_get_all_volumes_paths... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | volume_delete | 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... | salt/modules/virt.py | def volume_delete(pool, volume, **kwargs):
'''
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
:p... | def volume_delete(pool, volume, **kwargs):
'''
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
:p... | [
"Delete",
"a",
"libvirt",
"managed",
"volume",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/virt.py#L5370-L5393 | [
"def",
"volume_delete",
"(",
"pool",
",",
"volume",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__get_conn",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"vol",
"=",
"_get_storage_vol",
"(",
"conn",
",",
"pool",
",",
"volume",
")",
"return",
"not",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_ | List available metadata
CLI Example:
.. code-block:: bash
salt '*' mdata.list | salt/modules/mdata.py | def list_():
'''
List available metadata
CLI Example:
.. code-block:: bash
salt '*' mdata.list
'''
mdata = _check_mdata_list()
if mdata:
cmd = '{0}'.format(mdata)
return __salt__['cmd.run'](cmd, ignore_retcode=True).splitlines()
return {} | def list_():
'''
List available metadata
CLI Example:
.. code-block:: bash
salt '*' mdata.list
'''
mdata = _check_mdata_list()
if mdata:
cmd = '{0}'.format(mdata)
return __salt__['cmd.run'](cmd, ignore_retcode=True).splitlines()
return {} | [
"List",
"available",
"metadata"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdata.py#L81-L95 | [
"def",
"list_",
"(",
")",
":",
"mdata",
"=",
"_check_mdata_list",
"(",
")",
"if",
"mdata",
":",
"cmd",
"=",
"'{0}'",
".",
"format",
"(",
"mdata",
")",
"return",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"cmd",
",",
"ignore_retcode",
"=",
"True",
")",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_ | 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 | salt/modules/mdata.py | def get_(*keyname):
'''
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
'''
mdata... | def get_(*keyname):
'''
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
'''
mdata... | [
"Get",
"metadata"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdata.py#L98-L130 | [
"def",
"get_",
"(",
"*",
"keyname",
")",
":",
"mdata",
"=",
"_check_mdata_get",
"(",
")",
"ret",
"=",
"{",
"}",
"if",
"not",
"keyname",
":",
"keyname",
"=",
"list_",
"(",
")",
"for",
"k",
"in",
"keyname",
":",
"if",
"mdata",
":",
"cmd",
"=",
"'{0... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | put_ | Put metadata
prop : string
name of property
val : string
value to set
CLI Example:
.. code-block:: bash
salt '*' mdata.list | salt/modules/mdata.py | def put_(keyname, val):
'''
Put metadata
prop : string
name of property
val : string
value to set
CLI Example:
.. code-block:: bash
salt '*' mdata.list
'''
mdata = _check_mdata_put()
ret = {}
if mdata:
cmd = 'echo {2} | {0} {1}'.format(mdata, ... | def put_(keyname, val):
'''
Put metadata
prop : string
name of property
val : string
value to set
CLI Example:
.. code-block:: bash
salt '*' mdata.list
'''
mdata = _check_mdata_put()
ret = {}
if mdata:
cmd = 'echo {2} | {0} {1}'.format(mdata, ... | [
"Put",
"metadata"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdata.py#L133-L155 | [
"def",
"put_",
"(",
"keyname",
",",
"val",
")",
":",
"mdata",
"=",
"_check_mdata_put",
"(",
")",
"ret",
"=",
"{",
"}",
"if",
"mdata",
":",
"cmd",
"=",
"'echo {2} | {0} {1}'",
".",
"format",
"(",
"mdata",
",",
"keyname",
",",
"val",
")",
"ret",
"=",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | delete_ | Delete metadata
prop : string
name of property
CLI Example:
.. code-block:: bash
salt '*' mdata.get salt:role
salt '*' mdata.get user-script salt:role | salt/modules/mdata.py | def delete_(*keyname):
'''
Delete metadata
prop : string
name of property
CLI Example:
.. code-block:: bash
salt '*' mdata.get salt:role
salt '*' mdata.get user-script salt:role
'''
mdata = _check_mdata_delete()
valid_keynames = list_()
ret = {}
for k... | def delete_(*keyname):
'''
Delete metadata
prop : string
name of property
CLI Example:
.. code-block:: bash
salt '*' mdata.get salt:role
salt '*' mdata.get user-script salt:role
'''
mdata = _check_mdata_delete()
valid_keynames = list_()
ret = {}
for k... | [
"Delete",
"metadata"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mdata.py#L158-L183 | [
"def",
"delete_",
"(",
"*",
"keyname",
")",
":",
"mdata",
"=",
"_check_mdata_delete",
"(",
")",
"valid_keynames",
"=",
"list_",
"(",
")",
"ret",
"=",
"{",
"}",
"for",
"k",
"in",
"keyname",
":",
"if",
"mdata",
"and",
"k",
"in",
"valid_keynames",
":",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | show_instance | List the a single node, return dict of grains. | salt/cloud/clouds/saltify.py | 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 | 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 | [
"List",
"the",
"a",
"single",
"node",
"return",
"dict",
"of",
"grains",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/saltify.py#L203-L210 | [
"def",
"show_instance",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"local",
"=",
"salt",
".",
"client",
".",
"LocalClient",
"(",
")",
"ret",
"=",
"local",
".",
"cmd",
"(",
"name",
",",
"'grains.items'",
")",
"ret",
".",
"update",
"(",
"_build_r... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create | 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... | salt/cloud/clouds/saltify.py | def create(vm_):
'''
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.provid... | def create(vm_):
'''
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.provid... | [
"if",
"configuration",
"parameter",
"deploy",
"is",
"True"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/saltify.py#L213-L291 | [
"def",
"create",
"(",
"vm_",
")",
":",
"deploy_config",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'deploy'",
",",
"vm_",
",",
"__opts__",
",",
"default",
"=",
"False",
")",
"# If ssh_host is not set, default to the minion name",
"if",
"not",
"config",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _verify | Verify credentials for an existing system | salt/cloud/clouds/saltify.py | 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('Testing Windows authentication method for %s', ... | 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('Testing Windows authentication method for %s', ... | [
"Verify",
"credentials",
"for",
"an",
"existing",
"system"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/saltify.py#L305-L396 | [
"def",
"_verify",
"(",
"vm_",
")",
":",
"log",
".",
"info",
"(",
"'Verifying credentials for %s'",
",",
"vm_",
"[",
"'name'",
"]",
")",
"win_installer",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'win_installer'",
",",
"vm_",
",",
"__opts__",
")",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | destroy | 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_... | salt/cloud/clouds/saltify.py | def destroy(name, call=None):
''' 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 i... | def destroy(name, call=None):
''' 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 i... | [
"Destroy",
"a",
"node",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/saltify.py#L399-L485 | [
"def",
"destroy",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'function'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The destroy action must be called with -d, --destroy, '",
"'-a, or --action.'",
")",
"opts",
"=",
"__opts__",
"__utils__",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | reboot | 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 | salt/cloud/clouds/saltify.py | def reboot(name, call=None):
'''
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
'''
if call != 'action':
raise SaltCloudException(
'The reboot a... | def reboot(name, call=None):
'''
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
'''
if call != 'action':
raise SaltCloudException(
'The reboot a... | [
"Reboot",
"a",
"saltify",
"minion",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/saltify.py#L488-L510 | [
"def",
"reboot",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'action'",
":",
"raise",
"SaltCloudException",
"(",
"'The reboot action must be called with -a or --action.'",
")",
"local",
"=",
"salt",
".",
"client",
".",
"LocalClient",
"(... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | present | 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 | salt/states/jenkins.py | def present(name,
config=None,
**kwargs):
'''
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
'''
ret = {'name': name,
'result':... | def present(name,
config=None,
**kwargs):
'''
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
'''
ret = {'name': name,
'result':... | [
"Ensure",
"the",
"job",
"is",
"present",
"in",
"the",
"Jenkins",
"configured",
"jobs"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/jenkins.py#L47-L101 | [
"def",
"present",
"(",
"name",
",",
"config",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"[",
"'Job {0} is up to date.'... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | absent | Ensure the job is absent from the Jenkins configured jobs
name
The name of the Jenkins job to remove | salt/states/jenkins.py | 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,
'result': True,
'changes': {},
'comment': []}
if __salt__['jenkins.job_exists'](name... | 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,
'result': True,
'changes': {},
'comment': []}
if __salt__['jenkins.job_exists'](name... | [
"Ensure",
"the",
"job",
"is",
"absent",
"from",
"the",
"Jenkins",
"configured",
"jobs"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/jenkins.py#L104-L126 | [
"def",
"absent",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"[",
"]",
"}",
"if",
"__salt__",
"[",
"'jenkins.job_exist... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _run_proxy_processes | Iterate over a list of proxy
names and restart any that
aren't running | salt/beacons/salt_proxy.py | 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'](proxy)['result']:
__salt__['salt_proxy.configure_proxy'](proxy, st... | 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'](proxy)['result']:
__salt__['salt_proxy.configure_proxy'](proxy, st... | [
"Iterate",
"over",
"a",
"list",
"of",
"proxy",
"names",
"and",
"restart",
"any",
"that",
"aren",
"t",
"running"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/salt_proxy.py#L17-L34 | [
"def",
"_run_proxy_processes",
"(",
"proxies",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"proxy",
"in",
"proxies",
":",
"result",
"=",
"{",
"}",
"if",
"not",
"__salt__",
"[",
"'salt_proxy.is_running'",
"]",
"(",
"proxy",
")",
"[",
"'result'",
"]",
":",
"_... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | beacon | Handle configured proxies
.. code-block:: yaml
beacons:
salt_proxy:
- proxies:
p8000: {}
p8001: {} | salt/beacons/salt_proxy.py | def beacon(config):
'''
Handle configured proxies
.. code-block:: yaml
beacons:
salt_proxy:
- proxies:
p8000: {}
p8001: {}
'''
log.trace('salt proxy beacon called')
_config = {}
list(map(_config.update, config))
return _ru... | def beacon(config):
'''
Handle configured proxies
.. code-block:: yaml
beacons:
salt_proxy:
- proxies:
p8000: {}
p8001: {}
'''
log.trace('salt proxy beacon called')
_config = {}
list(map(_config.update, config))
return _ru... | [
"Handle",
"configured",
"proxies"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/salt_proxy.py#L60-L77 | [
"def",
"beacon",
"(",
"config",
")",
":",
"log",
".",
"trace",
"(",
"'salt proxy beacon called'",
")",
"_config",
"=",
"{",
"}",
"list",
"(",
"map",
"(",
"_config",
".",
"update",
",",
"config",
")",
")",
"return",
"_run_proxy_processes",
"(",
"_config",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_licenses | returns a list of applied powerpath license keys | salt/modules/powerpath.py | 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(line)
if not match:
continue
... | 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(line)
if not match:
continue
... | [
"returns",
"a",
"list",
"of",
"applied",
"powerpath",
"license",
"keys"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/powerpath.py#L54-L70 | [
"def",
"list_licenses",
"(",
")",
":",
"KEY_PATTERN",
"=",
"re",
".",
"compile",
"(",
"'Key (.*)'",
")",
"keys",
"=",
"[",
"]",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"'/sbin/emcpreg -list'",
")",
"for",
"line",
"in",
"out",
".",
"splitlines... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | add_license | Add a license | salt/modules/powerpath.py | 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)
ret = __salt__[... | 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)
ret = __salt__[... | [
"Add",
"a",
"license"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/powerpath.py#L73-L98 | [
"def",
"add_license",
"(",
"key",
")",
":",
"result",
"=",
"{",
"'result'",
":",
"False",
",",
"'retcode'",
":",
"-",
"1",
",",
"'output'",
":",
"''",
"}",
"if",
"not",
"has_powerpath",
"(",
")",
":",
"result",
"[",
"'output'",
"]",
"=",
"'PowerPath ... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | managed | 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, ... | salt/states/openvswitch_db.py | def managed(name, table, data, record=None):
'''
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 name... | def managed(name, table, data, record=None):
'''
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 name... | [
"Ensures",
"that",
"the",
"specified",
"columns",
"of",
"the",
"named",
"record",
"have",
"the",
"specified",
"values",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/openvswitch_db.py#L17-L69 | [
"def",
"managed",
"(",
"name",
",",
"table",
",",
"data",
",",
"record",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'changes'",
":",
"{",
"}",
",",
"'result'",
":",
"False",
",",
"'comment'",
":",
"''",
"}",
"if",
"recor... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _fix_ctx | This is part of an ugly hack to fix an ancient bug in M2Crypto
https://bugzilla.osafoundation.org/show_bug.cgi?id=7530#c13 | salt/modules/x509.py | 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 = _Ctx.from_address(int(m2_ctx)) # pylint: disable=no-member
ctx.flags = 0
ctx.subject_cert = None
ctx.subject_req =... | 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 = _Ctx.from_address(int(m2_ctx)) # pylint: disable=no-member
ctx.flags = 0
ctx.subject_cert = None
ctx.subject_req =... | [
"This",
"is",
"part",
"of",
"an",
"ugly",
"hack",
"to",
"fix",
"an",
"ancient",
"bug",
"in",
"M2Crypto",
"https",
":",
"//",
"bugzilla",
".",
"osafoundation",
".",
"org",
"/",
"show_bug",
".",
"cgi?id",
"=",
"7530#c13"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L105-L119 | [
"def",
"_fix_ctx",
"(",
"m2_ctx",
",",
"issuer",
"=",
"None",
")",
":",
"ctx",
"=",
"_Ctx",
".",
"from_address",
"(",
"int",
"(",
"m2_ctx",
")",
")",
"# pylint: disable=no-member",
"ctx",
".",
"flags",
"=",
"0",
"ctx",
".",
"subject_cert",
"=",
"None",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _new_extension | Create new X509_Extension, This is required because M2Crypto
doesn't support getting the publickeyidentifier from the issuer
to create the authoritykeyidentifier extension. | salt/modules/x509.py | def _new_extension(name, value, critical=0, issuer=None, _pyfree=1):
'''
Create new X509_Extension, This is required because M2Crypto
doesn't support getting the publickeyidentifier from the issuer
to create the authoritykeyidentifier extension.
'''
if name == 'subjectKeyIdentifier' and value.st... | def _new_extension(name, value, critical=0, issuer=None, _pyfree=1):
'''
Create new X509_Extension, This is required because M2Crypto
doesn't support getting the publickeyidentifier from the issuer
to create the authoritykeyidentifier extension.
'''
if name == 'subjectKeyIdentifier' and value.st... | [
"Create",
"new",
"X509_Extension",
"This",
"is",
"required",
"because",
"M2Crypto",
"doesn",
"t",
"support",
"getting",
"the",
"publickeyidentifier",
"from",
"the",
"issuer",
"to",
"create",
"the",
"authoritykeyidentifier",
"extension",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L122-L158 | [
"def",
"_new_extension",
"(",
"name",
",",
"value",
",",
"critical",
"=",
"0",
",",
"issuer",
"=",
"None",
",",
"_pyfree",
"=",
"1",
")",
":",
"if",
"name",
"==",
"'subjectKeyIdentifier'",
"and",
"value",
".",
"strip",
"(",
"'0123456789abcdefABCDEF:'",
")"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_openssl_req | Parses openssl command line output, this is a workaround for M2Crypto's
inability to get them from CSR objects. | salt/modules/x509.py | 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.which('openssl'):
raise salt.exceptions.SaltInvocationError(
'openssl binary not found in path'
... | 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.which('openssl'):
raise salt.exceptions.SaltInvocationError(
'openssl binary not found in path'
... | [
"Parses",
"openssl",
"command",
"line",
"output",
"this",
"is",
"a",
"workaround",
"for",
"M2Crypto",
"s",
"inability",
"to",
"get",
"them",
"from",
"CSR",
"objects",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L164-L180 | [
"def",
"_parse_openssl_req",
"(",
"csr_filename",
")",
":",
"if",
"not",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'openssl'",
")",
":",
"raise",
"salt",
".",
"exceptions",
".",
"SaltInvocationError",
"(",
"'openssl binary not found in path'",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_csr_extensions | Returns a list of dicts containing the name, value and critical value of
any extension contained in a csr object. | salt/modules/x509.py | 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()
csrtempfile = tempfile.NamedTemporaryFile()
csrtempfile.write(csr.as_pem())
csrtempfile.flush()
csryaml = _pars... | 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()
csrtempfile = tempfile.NamedTemporaryFile()
csrtempfile.write(csr.as_pem())
csrtempfile.flush()
csryaml = _pars... | [
"Returns",
"a",
"list",
"of",
"dicts",
"containing",
"the",
"name",
"value",
"and",
"critical",
"value",
"of",
"any",
"extension",
"contained",
"in",
"a",
"csr",
"object",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L183-L206 | [
"def",
"_get_csr_extensions",
"(",
"csr",
")",
":",
"ret",
"=",
"OrderedDict",
"(",
")",
"csrtempfile",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
")",
"csrtempfile",
".",
"write",
"(",
"csr",
".",
"as_pem",
"(",
")",
")",
"csrtempfile",
".",
"flush"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_openssl_crl | Parses openssl command line output, this is a workaround for M2Crypto's
inability to get them from CSR objects. | salt/modules/x509.py | 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.which('openssl'):
raise salt.exceptions.SaltInvocationError(
'openssl binary not found in path'
... | 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.which('openssl'):
raise salt.exceptions.SaltInvocationError(
'openssl binary not found in path'
... | [
"Parses",
"openssl",
"command",
"line",
"output",
"this",
"is",
"a",
"workaround",
"for",
"M2Crypto",
"s",
"inability",
"to",
"get",
"them",
"from",
"CSR",
"objects",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L212-L282 | [
"def",
"_parse_openssl_crl",
"(",
"crl_filename",
")",
":",
"if",
"not",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'openssl'",
")",
":",
"raise",
"salt",
".",
"exceptions",
".",
"SaltInvocationError",
"(",
"'openssl binary not found in path'",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _pretty_hex | Nicely formats hex strings | salt/modules/x509.py | 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() | 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() | [
"Nicely",
"formats",
"hex",
"strings"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L295-L302 | [
"def",
"_pretty_hex",
"(",
"hex_str",
")",
":",
"if",
"len",
"(",
"hex_str",
")",
"%",
"2",
"!=",
"0",
":",
"hex_str",
"=",
"'0'",
"+",
"hex_str",
"return",
"':'",
".",
"join",
"(",
"[",
"hex_str",
"[",
"i",
":",
"i",
"+",
"2",
"]",
"for",
"i",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _text_or_file | Determines if input is a path to a file, or a string with the
content to be parsed. | salt/modules/x509.py | 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 = salt.utils.stringutils.to_str(fp_.read())
else:
out = salt.utils.stringutils.to... | 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 = salt.utils.stringutils.to_str(fp_.read())
else:
out = salt.utils.stringutils.to... | [
"Determines",
"if",
"input",
"is",
"a",
"path",
"to",
"a",
"file",
"or",
"a",
"string",
"with",
"the",
"content",
"to",
"be",
"parsed",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L324-L335 | [
"def",
"_text_or_file",
"(",
"input_",
")",
":",
"if",
"_isfile",
"(",
"input_",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"input_",
")",
"as",
"fp_",
":",
"out",
"=",
"salt",
".",
"utils",
".",
"stringutils",
".",
"t... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _parse_subject | Returns a dict containing all values in an X509 Subject | salt/modules/x509.py | 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:
val = getattr(subject, nid_name)
if val:
... | 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:
val = getattr(subject, nid_name)
if val:
... | [
"Returns",
"a",
"dict",
"containing",
"all",
"values",
"in",
"an",
"X509",
"Subject"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L338-L355 | [
"def",
"_parse_subject",
"(",
"subject",
")",
":",
"ret",
"=",
"{",
"}",
"nids",
"=",
"[",
"]",
"for",
"nid_name",
",",
"nid_num",
"in",
"six",
".",
"iteritems",
"(",
"subject",
".",
"nid",
")",
":",
"if",
"nid_num",
"in",
"nids",
":",
"continue",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_certificate_obj | Returns a certificate object based on PEM text. | salt/modules/x509.py | 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.X509.load_cert_string(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.X509.load_cert_string(text) | [
"Returns",
"a",
"certificate",
"object",
"based",
"on",
"PEM",
"text",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L358-L367 | [
"def",
"_get_certificate_obj",
"(",
"cert",
")",
":",
"if",
"isinstance",
"(",
"cert",
",",
"M2Crypto",
".",
"X509",
".",
"X509",
")",
":",
"return",
"cert",
"text",
"=",
"_text_or_file",
"(",
"cert",
")",
"text",
"=",
"get_pem_entry",
"(",
"text",
",",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_private_key_obj | Returns a private key object based on PEM text. | salt/modules/x509.py | 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 = M2Crypto.RSA.load_key_string(
private_key, callb... | 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 = M2Crypto.RSA.load_key_string(
private_key, callb... | [
"Returns",
"a",
"private",
"key",
"object",
"based",
"on",
"PEM",
"text",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L370-L380 | [
"def",
"_get_private_key_obj",
"(",
"private_key",
",",
"passphrase",
"=",
"None",
")",
":",
"private_key",
"=",
"_text_or_file",
"(",
"private_key",
")",
"private_key",
"=",
"get_pem_entry",
"(",
"private_key",
",",
"pem_type",
"=",
"'(?:RSA )?PRIVATE KEY'",
")",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _passphrase_callback | Returns a callback function used to supply a passphrase for private keys | salt/modules/x509.py | 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 | 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",
"callback",
"function",
"used",
"to",
"supply",
"a",
"passphrase",
"for",
"private",
"keys"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L383-L389 | [
"def",
"_passphrase_callback",
"(",
"passphrase",
")",
":",
"def",
"f",
"(",
"*",
"args",
")",
":",
"return",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_bytes",
"(",
"passphrase",
")",
"return",
"f"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_request_obj | Returns a CSR object based on PEM text. | salt/modules/x509.py | 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) | 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",
"a",
"CSR",
"object",
"based",
"on",
"PEM",
"text",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L392-L398 | [
"def",
"_get_request_obj",
"(",
"csr",
")",
":",
"text",
"=",
"_text_or_file",
"(",
"csr",
")",
"text",
"=",
"get_pem_entry",
"(",
"text",
",",
"pem_type",
"=",
"'CERTIFICATE REQUEST'",
")",
"return",
"M2Crypto",
".",
"X509",
".",
"load_request_string",
"(",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _get_pubkey_hash | Returns the sha1 hash of the modulus of a public key in a cert
Used for generating subject key identifiers | salt/modules/x509.py | 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_modulus()).hexdigest()
return _pretty_hex(sha_hash) | 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_modulus()).hexdigest()
return _pretty_hex(sha_hash) | [
"Returns",
"the",
"sha1",
"hash",
"of",
"the",
"modulus",
"of",
"a",
"public",
"key",
"in",
"a",
"cert",
"Used",
"for",
"generating",
"subject",
"key",
"identifiers"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L401-L407 | [
"def",
"_get_pubkey_hash",
"(",
"cert",
")",
":",
"sha_hash",
"=",
"hashlib",
".",
"sha1",
"(",
"cert",
".",
"get_pubkey",
"(",
")",
".",
"get_modulus",
"(",
")",
")",
".",
"hexdigest",
"(",
")",
"return",
"_pretty_hex",
"(",
"sha_hash",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | _make_regex | Dynamically generate a regex to match pem_type | salt/modules/x509.py | def _make_regex(pem_type):
'''
Dynamically generate a regex to match pem_type
'''
return re.compile(
r"\s*(?P<pem_header>-----BEGIN {0}-----)\s+"
r"(?:(?P<proc_type>Proc-Type: 4,ENCRYPTED)\s*)?"
r"(?:(?P<dek_info>DEK-Info: (?:DES-[3A-Z\-]+,[0-9A-F]{{16}}|[0-9A-Z\-]+,[0-9A-F]{{32}... | def _make_regex(pem_type):
'''
Dynamically generate a regex to match pem_type
'''
return re.compile(
r"\s*(?P<pem_header>-----BEGIN {0}-----)\s+"
r"(?:(?P<proc_type>Proc-Type: 4,ENCRYPTED)\s*)?"
r"(?:(?P<dek_info>DEK-Info: (?:DES-[3A-Z\-]+,[0-9A-F]{{16}}|[0-9A-Z\-]+,[0-9A-F]{{32}... | [
"Dynamically",
"generate",
"a",
"regex",
"to",
"match",
"pem_type"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L418-L429 | [
"def",
"_make_regex",
"(",
"pem_type",
")",
":",
"return",
"re",
".",
"compile",
"(",
"r\"\\s*(?P<pem_header>-----BEGIN {0}-----)\\s+\"",
"r\"(?:(?P<proc_type>Proc-Type: 4,ENCRYPTED)\\s*)?\"",
"r\"(?:(?P<dek_info>DEK-Info: (?:DES-[3A-Z\\-]+,[0-9A-F]{{16}}|[0-9A-Z\\-]+,[0-9A-F]{{32}}))\\s*)... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_pem_entry | Returns a properly formatted PEM string from the input text fixing
any whitespace or line-break issues
text:
Text containing the X509 PEM entry to be returned or path to
a file containing the text.
pem_type:
If specified, this function will only return a pem of a certain type,
... | salt/modules/x509.py | def get_pem_entry(text, pem_type=None):
'''
Returns a properly formatted PEM string from the input text fixing
any whitespace or line-break issues
text:
Text containing the X509 PEM entry to be returned or path to
a file containing the text.
pem_type:
If specified, this fun... | def get_pem_entry(text, pem_type=None):
'''
Returns a properly formatted PEM string from the input text fixing
any whitespace or line-break issues
text:
Text containing the X509 PEM entry to be returned or path to
a file containing the text.
pem_type:
If specified, this fun... | [
"Returns",
"a",
"properly",
"formatted",
"PEM",
"string",
"from",
"the",
"input",
"text",
"fixing",
"any",
"whitespace",
"or",
"line",
"-",
"break",
"issues"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L432-L509 | [
"def",
"get_pem_entry",
"(",
"text",
",",
"pem_type",
"=",
"None",
")",
":",
"text",
"=",
"_text_or_file",
"(",
"text",
")",
"# Replace encoded newlines",
"text",
"=",
"text",
".",
"replace",
"(",
"'\\\\n'",
",",
"'\\n'",
")",
"_match",
"=",
"None",
"if",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_pem_entries | Returns a dict containing PEM entries in files matching a glob
glob_path:
A path to certificates to be read and returned.
CLI Example:
.. code-block:: bash
salt '*' x509.get_pem_entries "/etc/pki/*.crt" | salt/modules/x509.py | def get_pem_entries(glob_path):
'''
Returns a dict containing PEM entries in files matching a glob
glob_path:
A path to certificates to be read and returned.
CLI Example:
.. code-block:: bash
salt '*' x509.get_pem_entries "/etc/pki/*.crt"
'''
ret = {}
for path in glo... | def get_pem_entries(glob_path):
'''
Returns a dict containing PEM entries in files matching a glob
glob_path:
A path to certificates to be read and returned.
CLI Example:
.. code-block:: bash
salt '*' x509.get_pem_entries "/etc/pki/*.crt"
'''
ret = {}
for path in glo... | [
"Returns",
"a",
"dict",
"containing",
"PEM",
"entries",
"in",
"files",
"matching",
"a",
"glob"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L512-L534 | [
"def",
"get_pem_entries",
"(",
"glob_path",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"path",
"in",
"glob",
".",
"glob",
"(",
"glob_path",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"try",
":",
"ret",
"[",
"path",
"]",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | read_certificate | Returns a dict containing details of a certificate. Input can be a PEM
string or file path.
certificate:
The certificate to be read. Can be a path to a certificate file, or
a string containing the PEM formatted text of the certificate.
CLI Example:
.. code-block:: bash
salt '... | salt/modules/x509.py | def read_certificate(certificate):
'''
Returns a dict containing details of a certificate. Input can be a PEM
string or file path.
certificate:
The certificate to be read. Can be a path to a certificate file, or
a string containing the PEM formatted text of the certificate.
CLI Exa... | def read_certificate(certificate):
'''
Returns a dict containing details of a certificate. Input can be a PEM
string or file path.
certificate:
The certificate to be read. Can be a path to a certificate file, or
a string containing the PEM formatted text of the certificate.
CLI Exa... | [
"Returns",
"a",
"dict",
"containing",
"details",
"of",
"a",
"certificate",
".",
"Input",
"can",
"be",
"a",
"PEM",
"string",
"or",
"file",
"path",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L537-L588 | [
"def",
"read_certificate",
"(",
"certificate",
")",
":",
"cert",
"=",
"_get_certificate_obj",
"(",
"certificate",
")",
"ret",
"=",
"{",
"# X509 Version 3 has a value of 2 in the field.",
"# Version 2 has a value of 1.",
"# https://tools.ietf.org/html/rfc5280#section-4.1.2.1",
"'V... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | read_certificates | Returns a dict containing details of a all certificates matching a glob
glob_path:
A path to certificates to be read and returned.
CLI Example:
.. code-block:: bash
salt '*' x509.read_certificates "/etc/pki/*.crt" | salt/modules/x509.py | def read_certificates(glob_path):
'''
Returns a dict containing details of a all certificates matching a glob
glob_path:
A path to certificates to be read and returned.
CLI Example:
.. code-block:: bash
salt '*' x509.read_certificates "/etc/pki/*.crt"
'''
ret = {}
fo... | def read_certificates(glob_path):
'''
Returns a dict containing details of a all certificates matching a glob
glob_path:
A path to certificates to be read and returned.
CLI Example:
.. code-block:: bash
salt '*' x509.read_certificates "/etc/pki/*.crt"
'''
ret = {}
fo... | [
"Returns",
"a",
"dict",
"containing",
"details",
"of",
"a",
"all",
"certificates",
"matching",
"a",
"glob"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L591-L613 | [
"def",
"read_certificates",
"(",
"glob_path",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"path",
"in",
"glob",
".",
"glob",
"(",
"glob_path",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"try",
":",
"ret",
"[",
"path",
"]"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | read_csr | Returns a dict containing details of a certificate request.
:depends: - OpenSSL command line tool
csr:
A path or PEM encoded string containing the CSR to read.
CLI Example:
.. code-block:: bash
salt '*' x509.read_csr /etc/pki/mycert.csr | salt/modules/x509.py | def read_csr(csr):
'''
Returns a dict containing details of a certificate request.
:depends: - OpenSSL command line tool
csr:
A path or PEM encoded string containing the CSR to read.
CLI Example:
.. code-block:: bash
salt '*' x509.read_csr /etc/pki/mycert.csr
'''
c... | def read_csr(csr):
'''
Returns a dict containing details of a certificate request.
:depends: - OpenSSL command line tool
csr:
A path or PEM encoded string containing the CSR to read.
CLI Example:
.. code-block:: bash
salt '*' x509.read_csr /etc/pki/mycert.csr
'''
c... | [
"Returns",
"a",
"dict",
"containing",
"details",
"of",
"a",
"certificate",
"request",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L616-L644 | [
"def",
"read_csr",
"(",
"csr",
")",
":",
"csr",
"=",
"_get_request_obj",
"(",
"csr",
")",
"ret",
"=",
"{",
"# X509 Version 3 has a value of 2 in the field.",
"# Version 2 has a value of 1.",
"# https://tools.ietf.org/html/rfc5280#section-4.1.2.1",
"'Version'",
":",
"csr",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | read_crl | Returns a dict containing details of a certificate revocation list.
Input can be a PEM string or file path.
:depends: - OpenSSL command line tool
csl:
A path or PEM encoded string containing the CSL to read.
CLI Example:
.. code-block:: bash
salt '*' x509.read_crl /etc/pki/myc... | salt/modules/x509.py | def read_crl(crl):
'''
Returns a dict containing details of a certificate revocation list.
Input can be a PEM string or file path.
:depends: - OpenSSL command line tool
csl:
A path or PEM encoded string containing the CSL to read.
CLI Example:
.. code-block:: bash
salt... | def read_crl(crl):
'''
Returns a dict containing details of a certificate revocation list.
Input can be a PEM string or file path.
:depends: - OpenSSL command line tool
csl:
A path or PEM encoded string containing the CSL to read.
CLI Example:
.. code-block:: bash
salt... | [
"Returns",
"a",
"dict",
"containing",
"details",
"of",
"a",
"certificate",
"revocation",
"list",
".",
"Input",
"can",
"be",
"a",
"PEM",
"string",
"or",
"file",
"path",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L647-L672 | [
"def",
"read_crl",
"(",
"crl",
")",
":",
"text",
"=",
"_text_or_file",
"(",
"crl",
")",
"text",
"=",
"get_pem_entry",
"(",
"text",
",",
"pem_type",
"=",
"'X509 CRL'",
")",
"crltempfile",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
")",
"crltempfile",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_public_key | Returns a string containing the public key in PEM format.
key:
A path or PEM encoded string containing a CSR, Certificate or
Private Key from which a public key can be retrieved.
CLI Example:
.. code-block:: bash
salt '*' x509.get_public_key /etc/pki/mycert.cer | salt/modules/x509.py | def get_public_key(key, passphrase=None, asObj=False):
'''
Returns a string containing the public key in PEM format.
key:
A path or PEM encoded string containing a CSR, Certificate or
Private Key from which a public key can be retrieved.
CLI Example:
.. code-block:: bash
... | def get_public_key(key, passphrase=None, asObj=False):
'''
Returns a string containing the public key in PEM format.
key:
A path or PEM encoded string containing a CSR, Certificate or
Private Key from which a public key can be retrieved.
CLI Example:
.. code-block:: bash
... | [
"Returns",
"a",
"string",
"containing",
"the",
"public",
"key",
"in",
"PEM",
"format",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L675-L722 | [
"def",
"get_public_key",
"(",
"key",
",",
"passphrase",
"=",
"None",
",",
"asObj",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"M2Crypto",
".",
"X509",
".",
"X509",
")",
":",
"rsa",
"=",
"key",
".",
"get_pubkey",
"(",
")",
".",
"ge... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | write_pem | Writes out a PEM string fixing any formatting or whitespace
issues before writing.
text:
PEM string input to be written out.
path:
Path of the file to write the pem out to.
overwrite:
If True(default), write_pem will overwrite the entire pem file.
Set False to preserve... | salt/modules/x509.py | def write_pem(text, path, overwrite=True, pem_type=None):
'''
Writes out a PEM string fixing any formatting or whitespace
issues before writing.
text:
PEM string input to be written out.
path:
Path of the file to write the pem out to.
overwrite:
If True(default), write... | def write_pem(text, path, overwrite=True, pem_type=None):
'''
Writes out a PEM string fixing any formatting or whitespace
issues before writing.
text:
PEM string input to be written out.
path:
Path of the file to write the pem out to.
overwrite:
If True(default), write... | [
"Writes",
"out",
"a",
"PEM",
"string",
"fixing",
"any",
"formatting",
"or",
"whitespace",
"issues",
"before",
"writing",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L741-L790 | [
"def",
"write_pem",
"(",
"text",
",",
"path",
",",
"overwrite",
"=",
"True",
",",
"pem_type",
"=",
"None",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"set_umask",
"(",
"0o077",
")",
":",
"text",
"=",
"get_pem_entry",
"(",
"text",
",",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create_private_key | Creates a private key in PEM format.
path:
The path to write the file to, either ``path`` or ``text``
are required.
text:
If ``True``, return the PEM text without writing to a file.
Default ``False``.
bits:
Length of the private key in bits. Default 2048
passp... | salt/modules/x509.py | def create_private_key(path=None,
text=False,
bits=2048,
passphrase=None,
cipher='aes_128_cbc',
verbose=True):
'''
Creates a private key in PEM format.
path:
The path to write the file... | def create_private_key(path=None,
text=False,
bits=2048,
passphrase=None,
cipher='aes_128_cbc',
verbose=True):
'''
Creates a private key in PEM format.
path:
The path to write the file... | [
"Creates",
"a",
"private",
"key",
"in",
"PEM",
"format",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L793-L860 | [
"def",
"create_private_key",
"(",
"path",
"=",
"None",
",",
"text",
"=",
"False",
",",
"bits",
"=",
"2048",
",",
"passphrase",
"=",
"None",
",",
"cipher",
"=",
"'aes_128_cbc'",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"not",
"path",
"and",
"not",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create_crl | Create a CRL
:depends: - PyOpenSSL Python module
path:
Path to write the crl to.
text:
If ``True``, return the PEM text without writing to a file.
Default ``False``.
signing_private_key:
A path or string of the private key in PEM format that will be used
to ... | salt/modules/x509.py | def create_crl( # pylint: disable=too-many-arguments,too-many-locals
path=None, text=False, signing_private_key=None,
signing_private_key_passphrase=None,
signing_cert=None, revoked=None, include_expired=False,
days_valid=100, digest=''):
'''
Create a CRL
:depends: - PyOp... | def create_crl( # pylint: disable=too-many-arguments,too-many-locals
path=None, text=False, signing_private_key=None,
signing_private_key_passphrase=None,
signing_cert=None, revoked=None, include_expired=False,
days_valid=100, digest=''):
'''
Create a CRL
:depends: - PyOp... | [
"Create",
"a",
"CRL"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L863-L1017 | [
"def",
"create_crl",
"(",
"# pylint: disable=too-many-arguments,too-many-locals",
"path",
"=",
"None",
",",
"text",
"=",
"False",
",",
"signing_private_key",
"=",
"None",
",",
"signing_private_key_passphrase",
"=",
"None",
",",
"signing_cert",
"=",
"None",
",",
"revok... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | sign_remote_certificate | Request a certificate to be remotely signed according to a signing policy.
argdic:
A dict containing all the arguments to be passed into the
create_certificate function. This will become kwargs when passed
to create_certificate.
kwargs:
kwargs delivered from publish.publish
... | salt/modules/x509.py | def sign_remote_certificate(argdic, **kwargs):
'''
Request a certificate to be remotely signed according to a signing policy.
argdic:
A dict containing all the arguments to be passed into the
create_certificate function. This will become kwargs when passed
to create_certificate.
... | def sign_remote_certificate(argdic, **kwargs):
'''
Request a certificate to be remotely signed according to a signing policy.
argdic:
A dict containing all the arguments to be passed into the
create_certificate function. This will become kwargs when passed
to create_certificate.
... | [
"Request",
"a",
"certificate",
"to",
"be",
"remotely",
"signed",
"according",
"to",
"a",
"signing",
"policy",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L1020-L1070 | [
"def",
"sign_remote_certificate",
"(",
"argdic",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'signing_policy'",
"not",
"in",
"argdic",
":",
"return",
"'signing_policy must be specified'",
"if",
"not",
"isinstance",
"(",
"argdic",
",",
"dict",
")",
":",
"argdic",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_signing_policy | Returns the details of a names signing policy, including the text of
the public key that will be used to sign it. Does not return the
private key.
CLI Example:
.. code-block:: bash
salt '*' x509.get_signing_policy www | salt/modules/x509.py | def get_signing_policy(signing_policy_name):
'''
Returns the details of a names signing policy, including the text of
the public key that will be used to sign it. Does not return the
private key.
CLI Example:
.. code-block:: bash
salt '*' x509.get_signing_policy www
'''
signin... | def get_signing_policy(signing_policy_name):
'''
Returns the details of a names signing policy, including the text of
the public key that will be used to sign it. Does not return the
private key.
CLI Example:
.. code-block:: bash
salt '*' x509.get_signing_policy www
'''
signin... | [
"Returns",
"the",
"details",
"of",
"a",
"names",
"signing",
"policy",
"including",
"the",
"text",
"of",
"the",
"public",
"key",
"that",
"will",
"be",
"used",
"to",
"sign",
"it",
".",
"Does",
"not",
"return",
"the",
"private",
"key",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L1073-L1105 | [
"def",
"get_signing_policy",
"(",
"signing_policy_name",
")",
":",
"signing_policy",
"=",
"_get_signing_policy",
"(",
"signing_policy_name",
")",
"if",
"not",
"signing_policy",
":",
"return",
"'Signing policy {0} does not exist.'",
".",
"format",
"(",
"signing_policy_name",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create_certificate | Create an X509 certificate.
path:
Path to write the certificate to.
text:
If ``True``, return the PEM text without writing to a file.
Default ``False``.
overwrite:
If True(default), create_certificate will overwrite the entire pem
file. Set False to preserve existi... | salt/modules/x509.py | def create_certificate(
path=None, text=False, overwrite=True, ca_server=None, **kwargs):
'''
Create an X509 certificate.
path:
Path to write the certificate to.
text:
If ``True``, return the PEM text without writing to a file.
Default ``False``.
overwrite:
... | def create_certificate(
path=None, text=False, overwrite=True, ca_server=None, **kwargs):
'''
Create an X509 certificate.
path:
Path to write the certificate to.
text:
If ``True``, return the PEM text without writing to a file.
Default ``False``.
overwrite:
... | [
"Create",
"an",
"X509",
"certificate",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L1109-L1585 | [
"def",
"create_certificate",
"(",
"path",
"=",
"None",
",",
"text",
"=",
"False",
",",
"overwrite",
"=",
"True",
",",
"ca_server",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"path",
"and",
"not",
"text",
"and",
"(",
"'testrun'",
"no... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | create_csr | Create a certificate signing request.
path:
Path to write the certificate to.
text:
If ``True``, return the PEM text without writing to a file.
Default ``False``.
algorithm:
The hashing algorithm to be used for signing this request. Defaults to sha256.
kwargs:
... | salt/modules/x509.py | def create_csr(path=None, text=False, **kwargs):
'''
Create a certificate signing request.
path:
Path to write the certificate to.
text:
If ``True``, return the PEM text without writing to a file.
Default ``False``.
algorithm:
The hashing algorithm to be used for s... | def create_csr(path=None, text=False, **kwargs):
'''
Create a certificate signing request.
path:
Path to write the certificate to.
text:
If ``True``, return the PEM text without writing to a file.
Default ``False``.
algorithm:
The hashing algorithm to be used for s... | [
"Create",
"a",
"certificate",
"signing",
"request",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L1589-L1704 | [
"def",
"create_csr",
"(",
"path",
"=",
"None",
",",
"text",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"path",
"and",
"not",
"text",
":",
"raise",
"salt",
".",
"exceptions",
".",
"SaltInvocationError",
"(",
"'Either path or text must be ... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | verify_signature | Verify that ``certificate`` has been signed by ``signing_pub_key``
certificate:
The certificate to verify. Can be a path or string containing a
PEM formatted certificate.
signing_pub_key:
The public key to verify, can be a string or path to a PEM formatted
certificate, csr, or ... | salt/modules/x509.py | def verify_signature(certificate, signing_pub_key=None,
signing_pub_key_passphrase=None):
'''
Verify that ``certificate`` has been signed by ``signing_pub_key``
certificate:
The certificate to verify. Can be a path or string containing a
PEM formatted certificate.
... | def verify_signature(certificate, signing_pub_key=None,
signing_pub_key_passphrase=None):
'''
Verify that ``certificate`` has been signed by ``signing_pub_key``
certificate:
The certificate to verify. Can be a path or string containing a
PEM formatted certificate.
... | [
"Verify",
"that",
"certificate",
"has",
"been",
"signed",
"by",
"signing_pub_key"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L1732-L1761 | [
"def",
"verify_signature",
"(",
"certificate",
",",
"signing_pub_key",
"=",
"None",
",",
"signing_pub_key_passphrase",
"=",
"None",
")",
":",
"cert",
"=",
"_get_certificate_obj",
"(",
"certificate",
")",
"if",
"signing_pub_key",
":",
"signing_pub_key",
"=",
"get_pub... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | verify_crl | Validate a CRL against a certificate.
Parses openssl command line output, this is a workaround for M2Crypto's
inability to get them from CSR objects.
crl:
The CRL to verify
cert:
The certificate to verify the CRL against
CLI Example:
.. code-block:: bash
salt '*' x50... | salt/modules/x509.py | def verify_crl(crl, cert):
'''
Validate a CRL against a certificate.
Parses openssl command line output, this is a workaround for M2Crypto's
inability to get them from CSR objects.
crl:
The CRL to verify
cert:
The certificate to verify the CRL against
CLI Example:
.. ... | def verify_crl(crl, cert):
'''
Validate a CRL against a certificate.
Parses openssl command line output, this is a workaround for M2Crypto's
inability to get them from CSR objects.
crl:
The CRL to verify
cert:
The certificate to verify the CRL against
CLI Example:
.. ... | [
"Validate",
"a",
"CRL",
"against",
"a",
"certificate",
".",
"Parses",
"openssl",
"command",
"line",
"output",
"this",
"is",
"a",
"workaround",
"for",
"M2Crypto",
"s",
"inability",
"to",
"get",
"them",
"from",
"CSR",
"objects",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L1764-L1805 | [
"def",
"verify_crl",
"(",
"crl",
",",
"cert",
")",
":",
"if",
"not",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'openssl'",
")",
":",
"raise",
"salt",
".",
"exceptions",
".",
"SaltInvocationError",
"(",
"'External command \"openssl\" not found'",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | expired | Returns a dict containing limited details of a
certificate and whether the certificate has expired.
.. versionadded:: 2016.11.0
certificate:
The certificate to be read. Can be a path to a certificate file,
or a string containing the PEM formatted text of the certificate.
CLI Example:
... | salt/modules/x509.py | def expired(certificate):
'''
Returns a dict containing limited details of a
certificate and whether the certificate has expired.
.. versionadded:: 2016.11.0
certificate:
The certificate to be read. Can be a path to a certificate file,
or a string containing the PEM formatted text ... | def expired(certificate):
'''
Returns a dict containing limited details of a
certificate and whether the certificate has expired.
.. versionadded:: 2016.11.0
certificate:
The certificate to be read. Can be a path to a certificate file,
or a string containing the PEM formatted text ... | [
"Returns",
"a",
"dict",
"containing",
"limited",
"details",
"of",
"a",
"certificate",
"and",
"whether",
"the",
"certificate",
"has",
"expired",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L1808-L1846 | [
"def",
"expired",
"(",
"certificate",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"certificate",
")",
":",
"try",
":",
"ret",
"[",
"'path'",
"]",
"=",
"certificate",
"cert",
"=",
"_get_certificate_obj",
"(",
"certificat... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | will_expire | Returns a dict containing details of a certificate and whether
the certificate will expire in the specified number of days.
Input can be a PEM string or file path.
.. versionadded:: 2016.11.0
certificate:
The certificate to be read. Can be a path to a certificate file,
or a string cont... | salt/modules/x509.py | def will_expire(certificate, days):
'''
Returns a dict containing details of a certificate and whether
the certificate will expire in the specified number of days.
Input can be a PEM string or file path.
.. versionadded:: 2016.11.0
certificate:
The certificate to be read. Can be a path... | def will_expire(certificate, days):
'''
Returns a dict containing details of a certificate and whether
the certificate will expire in the specified number of days.
Input can be a PEM string or file path.
.. versionadded:: 2016.11.0
certificate:
The certificate to be read. Can be a path... | [
"Returns",
"a",
"dict",
"containing",
"details",
"of",
"a",
"certificate",
"and",
"whether",
"the",
"certificate",
"will",
"expire",
"in",
"the",
"specified",
"number",
"of",
"days",
".",
"Input",
"can",
"be",
"a",
"PEM",
"string",
"or",
"file",
"path",
".... | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/x509.py#L1849-L1886 | [
"def",
"will_expire",
"(",
"certificate",
",",
"days",
")",
":",
"ts_pt",
"=",
"\"%Y-%m-%d %H:%M:%S\"",
"ret",
"=",
"{",
"}",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"certificate",
")",
":",
"try",
":",
"ret",
"[",
"'path'",
"]",
"=",
"certificate... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | ext_pillar | Connect to a Django database through the ORM and retrieve model fields
:type pillar_name: str
:param pillar_name: The name of the pillar to be returned
:type project_path: str
:param project_path: The full path to your Django project (the directory
manage.py is in)
:type settings_module: ... | salt/pillar/django_orm.py | def ext_pillar(minion_id, # pylint: disable=W0613
pillar, # pylint: disable=W0613
pillar_name,
project_path,
settings_module,
django_app,
env=None,
env_file=None,
*args, # pylint: disable=W0613
... | def ext_pillar(minion_id, # pylint: disable=W0613
pillar, # pylint: disable=W0613
pillar_name,
project_path,
settings_module,
django_app,
env=None,
env_file=None,
*args, # pylint: disable=W0613
... | [
"Connect",
"to",
"a",
"Django",
"database",
"through",
"the",
"ORM",
"and",
"retrieve",
"model",
"fields"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/django_orm.py#L120-L243 | [
"def",
"ext_pillar",
"(",
"minion_id",
",",
"# pylint: disable=W0613",
"pillar",
",",
"# pylint: disable=W0613",
"pillar_name",
",",
"project_path",
",",
"settings_module",
",",
"django_app",
",",
"env",
"=",
"None",
",",
"env_file",
"=",
"None",
",",
"*",
"args",... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | list_domains | Return a list of virtual machine names on the minion
CLI Example:
.. code-block:: bash
salt '*' virt.list_domains | salt/modules/smartos_virt.py | def list_domains():
'''
Return a list of virtual machine names on the minion
CLI Example:
.. code-block:: bash
salt '*' virt.list_domains
'''
data = __salt__['vmadm.list'](keyed=True)
vms = ["UUID TYPE RAM STATE ALIAS"]
for vm... | def list_domains():
'''
Return a list of virtual machine names on the minion
CLI Example:
.. code-block:: bash
salt '*' virt.list_domains
'''
data = __salt__['vmadm.list'](keyed=True)
vms = ["UUID TYPE RAM STATE ALIAS"]
for vm... | [
"Return",
"a",
"list",
"of",
"virtual",
"machine",
"names",
"on",
"the",
"minion"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smartos_virt.py#L49-L69 | [
"def",
"list_domains",
"(",
")",
":",
"data",
"=",
"__salt__",
"[",
"'vmadm.list'",
"]",
"(",
"keyed",
"=",
"True",
")",
"vms",
"=",
"[",
"\"UUID TYPE RAM STATE ALIAS\"",
"]",
"for",
"vm",
"in",
"data",
":",
"vms"... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | vm_virt_type | Return VM virtualization type : OS or KVM
CLI Example:
.. code-block:: bash
salt '*' virt.vm_virt_type <domain> | salt/modules/smartos_virt.py | def vm_virt_type(domain):
'''
Return VM virtualization type : OS or KVM
CLI Example:
.. code-block:: bash
salt '*' virt.vm_virt_type <domain>
'''
ret = __salt__['vmadm.lookup'](search="uuid={uuid}".format(uuid=domain), order='type')
if not ret:
raise CommandExecutionError(... | def vm_virt_type(domain):
'''
Return VM virtualization type : OS or KVM
CLI Example:
.. code-block:: bash
salt '*' virt.vm_virt_type <domain>
'''
ret = __salt__['vmadm.lookup'](search="uuid={uuid}".format(uuid=domain), order='type')
if not ret:
raise CommandExecutionError(... | [
"Return",
"VM",
"virtualization",
"type",
":",
"OS",
"or",
"KVM"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smartos_virt.py#L181-L195 | [
"def",
"vm_virt_type",
"(",
"domain",
")",
":",
"ret",
"=",
"__salt__",
"[",
"'vmadm.lookup'",
"]",
"(",
"search",
"=",
"\"uuid={uuid}\"",
".",
"format",
"(",
"uuid",
"=",
"domain",
")",
",",
"order",
"=",
"'type'",
")",
"if",
"not",
"ret",
":",
"raise... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | setmem | Change the amount of memory allocated to VM.
<memory> is to be specified in MB.
Note for KVM : this would require a restart of the VM.
CLI Example:
.. code-block:: bash
salt '*' virt.setmem <domain> 512 | salt/modules/smartos_virt.py | def setmem(domain, memory):
'''
Change the amount of memory allocated to VM.
<memory> is to be specified in MB.
Note for KVM : this would require a restart of the VM.
CLI Example:
.. code-block:: bash
salt '*' virt.setmem <domain> 512
'''
vmtype = vm_virt_type(domain)
if ... | def setmem(domain, memory):
'''
Change the amount of memory allocated to VM.
<memory> is to be specified in MB.
Note for KVM : this would require a restart of the VM.
CLI Example:
.. code-block:: bash
salt '*' virt.setmem <domain> 512
'''
vmtype = vm_virt_type(domain)
if ... | [
"Change",
"the",
"amount",
"of",
"memory",
"allocated",
"to",
"VM",
".",
"<memory",
">",
"is",
"to",
"be",
"specified",
"in",
"MB",
"."
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smartos_virt.py#L198-L222 | [
"def",
"setmem",
"(",
"domain",
",",
"memory",
")",
":",
"vmtype",
"=",
"vm_virt_type",
"(",
"domain",
")",
"if",
"vmtype",
"==",
"'OS'",
":",
"return",
"__salt__",
"[",
"'vmadm.update'",
"]",
"(",
"vm",
"=",
"domain",
",",
"max_physical_memory",
"=",
"m... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
train | get_macs | Return a list off MAC addresses from the named VM
CLI Example:
.. code-block:: bash
salt '*' virt.get_macs <domain> | salt/modules/smartos_virt.py | def get_macs(domain):
'''
Return a list off MAC addresses from the named VM
CLI Example:
.. code-block:: bash
salt '*' virt.get_macs <domain>
'''
macs = []
ret = __salt__['vmadm.lookup'](search="uuid={uuid}".format(uuid=domain), order='nics')
if not ret:
raise CommandE... | def get_macs(domain):
'''
Return a list off MAC addresses from the named VM
CLI Example:
.. code-block:: bash
salt '*' virt.get_macs <domain>
'''
macs = []
ret = __salt__['vmadm.lookup'](search="uuid={uuid}".format(uuid=domain), order='nics')
if not ret:
raise CommandE... | [
"Return",
"a",
"list",
"off",
"MAC",
"addresses",
"from",
"the",
"named",
"VM"
] | saltstack/salt | python | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/smartos_virt.py#L225-L242 | [
"def",
"get_macs",
"(",
"domain",
")",
":",
"macs",
"=",
"[",
"]",
"ret",
"=",
"__salt__",
"[",
"'vmadm.lookup'",
"]",
"(",
"search",
"=",
"\"uuid={uuid}\"",
".",
"format",
"(",
"uuid",
"=",
"domain",
")",
",",
"order",
"=",
"'nics'",
")",
"if",
"not... | e8541fd6e744ab0df786c0f76102e41631f45d46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.