repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/utils/cloud.py | rename_key | def rename_key(pki_dir, id_, new_id):
'''
Rename a key, when an instance has also been renamed
'''
oldkey = os.path.join(pki_dir, 'minions', id_)
newkey = os.path.join(pki_dir, 'minions', new_id)
if os.path.isfile(oldkey):
os.rename(oldkey, newkey) | python | def rename_key(pki_dir, id_, new_id):
'''
Rename a key, when an instance has also been renamed
'''
oldkey = os.path.join(pki_dir, 'minions', id_)
newkey = os.path.join(pki_dir, 'minions', new_id)
if os.path.isfile(oldkey):
os.rename(oldkey, newkey) | [
"def",
"rename_key",
"(",
"pki_dir",
",",
"id_",
",",
"new_id",
")",
":",
"oldkey",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pki_dir",
",",
"'minions'",
",",
"id_",
")",
"newkey",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pki_dir",
",",
"'minion... | Rename a key, when an instance has also been renamed | [
"Rename",
"a",
"key",
"when",
"an",
"instance",
"has",
"also",
"been",
"renamed"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L291-L298 | train |
saltstack/salt | salt/utils/cloud.py | minion_config | def minion_config(opts, vm_):
'''
Return a minion's configuration for the provided options and VM
'''
# Don't start with a copy of the default minion opts; they're not always
# what we need. Some default options are Null, let's set a reasonable default
minion = {
'master': 'salt',
... | python | def minion_config(opts, vm_):
'''
Return a minion's configuration for the provided options and VM
'''
# Don't start with a copy of the default minion opts; they're not always
# what we need. Some default options are Null, let's set a reasonable default
minion = {
'master': 'salt',
... | [
"def",
"minion_config",
"(",
"opts",
",",
"vm_",
")",
":",
"# Don't start with a copy of the default minion opts; they're not always",
"# what we need. Some default options are Null, let's set a reasonable default",
"minion",
"=",
"{",
"'master'",
":",
"'salt'",
",",
"'log_level'",... | Return a minion's configuration for the provided options and VM | [
"Return",
"a",
"minion",
"s",
"configuration",
"for",
"the",
"provided",
"options",
"and",
"VM"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L301-L344 | train |
saltstack/salt | salt/utils/cloud.py | master_config | def master_config(opts, vm_):
'''
Return a master's configuration for the provided options and VM
'''
# Let's get a copy of the salt master default options
master = copy.deepcopy(salt.config.DEFAULT_MASTER_OPTS)
# Some default options are Null, let's set a reasonable default
master.update(
... | python | def master_config(opts, vm_):
'''
Return a master's configuration for the provided options and VM
'''
# Let's get a copy of the salt master default options
master = copy.deepcopy(salt.config.DEFAULT_MASTER_OPTS)
# Some default options are Null, let's set a reasonable default
master.update(
... | [
"def",
"master_config",
"(",
"opts",
",",
"vm_",
")",
":",
"# Let's get a copy of the salt master default options",
"master",
"=",
"copy",
".",
"deepcopy",
"(",
"salt",
".",
"config",
".",
"DEFAULT_MASTER_OPTS",
")",
"# Some default options are Null, let's set a reasonable ... | Return a master's configuration for the provided options and VM | [
"Return",
"a",
"master",
"s",
"configuration",
"for",
"the",
"provided",
"options",
"and",
"VM"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L347-L369 | train |
saltstack/salt | salt/utils/cloud.py | salt_config_to_yaml | def salt_config_to_yaml(configuration, line_break='\n'):
'''
Return a salt configuration dictionary, master or minion, as a yaml dump
'''
return salt.utils.yaml.safe_dump(
configuration,
line_break=line_break,
default_flow_style=False) | python | def salt_config_to_yaml(configuration, line_break='\n'):
'''
Return a salt configuration dictionary, master or minion, as a yaml dump
'''
return salt.utils.yaml.safe_dump(
configuration,
line_break=line_break,
default_flow_style=False) | [
"def",
"salt_config_to_yaml",
"(",
"configuration",
",",
"line_break",
"=",
"'\\n'",
")",
":",
"return",
"salt",
".",
"utils",
".",
"yaml",
".",
"safe_dump",
"(",
"configuration",
",",
"line_break",
"=",
"line_break",
",",
"default_flow_style",
"=",
"False",
"... | Return a salt configuration dictionary, master or minion, as a yaml dump | [
"Return",
"a",
"salt",
"configuration",
"dictionary",
"master",
"or",
"minion",
"as",
"a",
"yaml",
"dump"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L372-L379 | train |
saltstack/salt | salt/utils/cloud.py | bootstrap | def bootstrap(vm_, opts=None):
'''
This is the primary entry point for logging into any system (POSIX or
Windows) to install Salt. It will make the decision on its own as to which
deploy function to call.
'''
if opts is None:
opts = __opts__
deploy_config = salt.config.get_cloud_conf... | python | def bootstrap(vm_, opts=None):
'''
This is the primary entry point for logging into any system (POSIX or
Windows) to install Salt. It will make the decision on its own as to which
deploy function to call.
'''
if opts is None:
opts = __opts__
deploy_config = salt.config.get_cloud_conf... | [
"def",
"bootstrap",
"(",
"vm_",
",",
"opts",
"=",
"None",
")",
":",
"if",
"opts",
"is",
"None",
":",
"opts",
"=",
"__opts__",
"deploy_config",
"=",
"salt",
".",
"config",
".",
"get_cloud_config_value",
"(",
"'deploy'",
",",
"vm_",
",",
"opts",
",",
"de... | This is the primary entry point for logging into any system (POSIX or
Windows) to install Salt. It will make the decision on its own as to which
deploy function to call. | [
"This",
"is",
"the",
"primary",
"entry",
"point",
"for",
"logging",
"into",
"any",
"system",
"(",
"POSIX",
"or",
"Windows",
")",
"to",
"install",
"Salt",
".",
"It",
"will",
"make",
"the",
"decision",
"on",
"its",
"own",
"as",
"to",
"which",
"deploy",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L382-L668 | train |
saltstack/salt | salt/utils/cloud.py | ssh_usernames | def ssh_usernames(vm_, opts, default_users=None):
'''
Return the ssh_usernames. Defaults to a built-in list of users for trying.
'''
if default_users is None:
default_users = ['root']
usernames = salt.config.get_cloud_config_value(
'ssh_username', vm_, opts
)
if not isinsta... | python | def ssh_usernames(vm_, opts, default_users=None):
'''
Return the ssh_usernames. Defaults to a built-in list of users for trying.
'''
if default_users is None:
default_users = ['root']
usernames = salt.config.get_cloud_config_value(
'ssh_username', vm_, opts
)
if not isinsta... | [
"def",
"ssh_usernames",
"(",
"vm_",
",",
"opts",
",",
"default_users",
"=",
"None",
")",
":",
"if",
"default_users",
"is",
"None",
":",
"default_users",
"=",
"[",
"'root'",
"]",
"usernames",
"=",
"salt",
".",
"config",
".",
"get_cloud_config_value",
"(",
"... | Return the ssh_usernames. Defaults to a built-in list of users for trying. | [
"Return",
"the",
"ssh_usernames",
".",
"Defaults",
"to",
"a",
"built",
"-",
"in",
"list",
"of",
"users",
"for",
"trying",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L671-L699 | train |
saltstack/salt | salt/utils/cloud.py | wait_for_fun | def wait_for_fun(fun, timeout=900, **kwargs):
'''
Wait until a function finishes, or times out
'''
start = time.time()
log.debug('Attempting function %s', fun)
trycount = 0
while True:
trycount += 1
try:
response = fun(**kwargs)
if not isinstance(respo... | python | def wait_for_fun(fun, timeout=900, **kwargs):
'''
Wait until a function finishes, or times out
'''
start = time.time()
log.debug('Attempting function %s', fun)
trycount = 0
while True:
trycount += 1
try:
response = fun(**kwargs)
if not isinstance(respo... | [
"def",
"wait_for_fun",
"(",
"fun",
",",
"timeout",
"=",
"900",
",",
"*",
"*",
"kwargs",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"log",
".",
"debug",
"(",
"'Attempting function %s'",
",",
"fun",
")",
"trycount",
"=",
"0",
"while",
"True... | Wait until a function finishes, or times out | [
"Wait",
"until",
"a",
"function",
"finishes",
"or",
"times",
"out"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L702-L721 | train |
saltstack/salt | salt/utils/cloud.py | wait_for_port | def wait_for_port(host, port=22, timeout=900, gateway=None):
'''
Wait until a connection to the specified port can be made on a specified
host. This is usually port 22 (for SSH), but in the case of Windows
installations, it might be port 445 (for psexec). It may also be an
alternate port for SSH, de... | python | def wait_for_port(host, port=22, timeout=900, gateway=None):
'''
Wait until a connection to the specified port can be made on a specified
host. This is usually port 22 (for SSH), but in the case of Windows
installations, it might be port 445 (for psexec). It may also be an
alternate port for SSH, de... | [
"def",
"wait_for_port",
"(",
"host",
",",
"port",
"=",
"22",
",",
"timeout",
"=",
"900",
",",
"gateway",
"=",
"None",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"# Assign test ports because if a gateway is defined",
"# we first want to test the gateway... | Wait until a connection to the specified port can be made on a specified
host. This is usually port 22 (for SSH), but in the case of Windows
installations, it might be port 445 (for psexec). It may also be an
alternate port for SSH, depending on the base image. | [
"Wait",
"until",
"a",
"connection",
"to",
"the",
"specified",
"port",
"can",
"be",
"made",
"on",
"a",
"specified",
"host",
".",
"This",
"is",
"usually",
"port",
"22",
"(",
"for",
"SSH",
")",
"but",
"in",
"the",
"case",
"of",
"Windows",
"installations",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L724-L860 | train |
saltstack/salt | salt/utils/cloud.py | run_winexe_command | def run_winexe_command(cmd, args, host, username, password, port=445):
'''
Run a command remotly via the winexe executable
'''
creds = "-U '{0}%{1}' //{2}".format(
username,
password,
host
)
logging_creds = "-U '{0}%XXX-REDACTED-XXX' //{1}".format(
username,
... | python | def run_winexe_command(cmd, args, host, username, password, port=445):
'''
Run a command remotly via the winexe executable
'''
creds = "-U '{0}%{1}' //{2}".format(
username,
password,
host
)
logging_creds = "-U '{0}%XXX-REDACTED-XXX' //{1}".format(
username,
... | [
"def",
"run_winexe_command",
"(",
"cmd",
",",
"args",
",",
"host",
",",
"username",
",",
"password",
",",
"port",
"=",
"445",
")",
":",
"creds",
"=",
"\"-U '{0}%{1}' //{2}\"",
".",
"format",
"(",
"username",
",",
"password",
",",
"host",
")",
"logging_cred... | Run a command remotly via the winexe executable | [
"Run",
"a",
"command",
"remotly",
"via",
"the",
"winexe",
"executable"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L938-L953 | train |
saltstack/salt | salt/utils/cloud.py | run_psexec_command | def run_psexec_command(cmd, args, host, username, password, port=445):
'''
Run a command remotly using the psexec protocol
'''
if has_winexe() and not HAS_PSEXEC:
ret_code = run_winexe_command(cmd, args, host, username, password, port)
return None, None, ret_code
service_name = 'PS-E... | python | def run_psexec_command(cmd, args, host, username, password, port=445):
'''
Run a command remotly using the psexec protocol
'''
if has_winexe() and not HAS_PSEXEC:
ret_code = run_winexe_command(cmd, args, host, username, password, port)
return None, None, ret_code
service_name = 'PS-E... | [
"def",
"run_psexec_command",
"(",
"cmd",
",",
"args",
",",
"host",
",",
"username",
",",
"password",
",",
"port",
"=",
"445",
")",
":",
"if",
"has_winexe",
"(",
")",
"and",
"not",
"HAS_PSEXEC",
":",
"ret_code",
"=",
"run_winexe_command",
"(",
"cmd",
",",... | Run a command remotly using the psexec protocol | [
"Run",
"a",
"command",
"remotly",
"using",
"the",
"psexec",
"protocol"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L956-L973 | train |
saltstack/salt | salt/utils/cloud.py | wait_for_winexe | def wait_for_winexe(host, port, username, password, timeout=900):
'''
Wait until winexe connection can be established.
'''
start = time.time()
log.debug(
'Attempting winexe connection to host %s on port %s',
host, port
)
try_count = 0
while True:
try_count += 1
... | python | def wait_for_winexe(host, port, username, password, timeout=900):
'''
Wait until winexe connection can be established.
'''
start = time.time()
log.debug(
'Attempting winexe connection to host %s on port %s',
host, port
)
try_count = 0
while True:
try_count += 1
... | [
"def",
"wait_for_winexe",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"timeout",
"=",
"900",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"log",
".",
"debug",
"(",
"'Attempting winexe connection to host %s on port %s'",
",",
"h... | Wait until winexe connection can be established. | [
"Wait",
"until",
"winexe",
"connection",
"can",
"be",
"established",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L976-L1002 | train |
saltstack/salt | salt/utils/cloud.py | wait_for_psexecsvc | def wait_for_psexecsvc(host, port, username, password, timeout=900):
'''
Wait until psexec connection can be established.
'''
if has_winexe() and not HAS_PSEXEC:
return wait_for_winexe(host, port, username, password, timeout)
start = time.time()
try_count = 0
while True:
try_... | python | def wait_for_psexecsvc(host, port, username, password, timeout=900):
'''
Wait until psexec connection can be established.
'''
if has_winexe() and not HAS_PSEXEC:
return wait_for_winexe(host, port, username, password, timeout)
start = time.time()
try_count = 0
while True:
try_... | [
"def",
"wait_for_psexecsvc",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"timeout",
"=",
"900",
")",
":",
"if",
"has_winexe",
"(",
")",
"and",
"not",
"HAS_PSEXEC",
":",
"return",
"wait_for_winexe",
"(",
"host",
",",
"port",
",",
"use... | Wait until psexec connection can be established. | [
"Wait",
"until",
"psexec",
"connection",
"can",
"be",
"established",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1005-L1031 | train |
saltstack/salt | salt/utils/cloud.py | wait_for_winrm | def wait_for_winrm(host, port, username, password, timeout=900, use_ssl=True, verify=True):
'''
Wait until WinRM connection can be established.
'''
# Ensure the winrm service is listening before attempting to connect
wait_for_port(host=host, port=port, timeout=timeout)
start = time.time()
l... | python | def wait_for_winrm(host, port, username, password, timeout=900, use_ssl=True, verify=True):
'''
Wait until WinRM connection can be established.
'''
# Ensure the winrm service is listening before attempting to connect
wait_for_port(host=host, port=port, timeout=timeout)
start = time.time()
l... | [
"def",
"wait_for_winrm",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"timeout",
"=",
"900",
",",
"use_ssl",
"=",
"True",
",",
"verify",
"=",
"True",
")",
":",
"# Ensure the winrm service is listening before attempting to connect",
"wait_for_port... | Wait until WinRM connection can be established. | [
"Wait",
"until",
"WinRM",
"connection",
"can",
"be",
"established",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1034-L1096 | train |
saltstack/salt | salt/utils/cloud.py | validate_windows_cred_winexe | def validate_windows_cred_winexe(host,
username='Administrator',
password=None,
retries=10,
retry_delay=1):
'''
Check if the windows credentials are valid
'''
cmd = "winexe -U '{0}%{1}' //{2} \"hostna... | python | def validate_windows_cred_winexe(host,
username='Administrator',
password=None,
retries=10,
retry_delay=1):
'''
Check if the windows credentials are valid
'''
cmd = "winexe -U '{0}%{1}' //{2} \"hostna... | [
"def",
"validate_windows_cred_winexe",
"(",
"host",
",",
"username",
"=",
"'Administrator'",
",",
"password",
"=",
"None",
",",
"retries",
"=",
"10",
",",
"retry_delay",
"=",
"1",
")",
":",
"cmd",
"=",
"\"winexe -U '{0}%{1}' //{2} \\\"hostname\\\"\"",
".",
"format... | Check if the windows credentials are valid | [
"Check",
"if",
"the",
"windows",
"credentials",
"are",
"valid"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1099-L1121 | train |
saltstack/salt | salt/utils/cloud.py | validate_windows_cred | def validate_windows_cred(host,
username='Administrator',
password=None,
retries=10,
retry_delay=1):
'''
Check if the windows credentials are valid
'''
for i in range(retries):
ret_code = 1
... | python | def validate_windows_cred(host,
username='Administrator',
password=None,
retries=10,
retry_delay=1):
'''
Check if the windows credentials are valid
'''
for i in range(retries):
ret_code = 1
... | [
"def",
"validate_windows_cred",
"(",
"host",
",",
"username",
"=",
"'Administrator'",
",",
"password",
"=",
"None",
",",
"retries",
"=",
"10",
",",
"retry_delay",
"=",
"1",
")",
":",
"for",
"i",
"in",
"range",
"(",
"retries",
")",
":",
"ret_code",
"=",
... | Check if the windows credentials are valid | [
"Check",
"if",
"the",
"windows",
"credentials",
"are",
"valid"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1124-L1143 | train |
saltstack/salt | salt/utils/cloud.py | wait_for_passwd | def wait_for_passwd(host, port=22, ssh_timeout=15, username='root',
password=None, key_filename=None, maxtries=15,
trysleep=1, display_ssh_output=True, gateway=None,
known_hosts_file='/dev/null', hard_timeout=None):
'''
Wait until ssh connection can be... | python | def wait_for_passwd(host, port=22, ssh_timeout=15, username='root',
password=None, key_filename=None, maxtries=15,
trysleep=1, display_ssh_output=True, gateway=None,
known_hosts_file='/dev/null', hard_timeout=None):
'''
Wait until ssh connection can be... | [
"def",
"wait_for_passwd",
"(",
"host",
",",
"port",
"=",
"22",
",",
"ssh_timeout",
"=",
"15",
",",
"username",
"=",
"'root'",
",",
"password",
"=",
"None",
",",
"key_filename",
"=",
"None",
",",
"maxtries",
"=",
"15",
",",
"trysleep",
"=",
"1",
",",
... | Wait until ssh connection can be accessed via password or ssh key | [
"Wait",
"until",
"ssh",
"connection",
"can",
"be",
"accessed",
"via",
"password",
"or",
"ssh",
"key"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1146-L1204 | train |
saltstack/salt | salt/utils/cloud.py | deploy_windows | def deploy_windows(host,
port=445,
timeout=900,
username='Administrator',
password=None,
name=None,
sock_dir=None,
conf_file=None,
start_action=None,
... | python | def deploy_windows(host,
port=445,
timeout=900,
username='Administrator',
password=None,
name=None,
sock_dir=None,
conf_file=None,
start_action=None,
... | [
"def",
"deploy_windows",
"(",
"host",
",",
"port",
"=",
"445",
",",
"timeout",
"=",
"900",
",",
"username",
"=",
"'Administrator'",
",",
"password",
"=",
"None",
",",
"name",
"=",
"None",
",",
"sock_dir",
"=",
"None",
",",
"conf_file",
"=",
"None",
","... | Copy the install files to a remote Windows box, and execute them | [
"Copy",
"the",
"install",
"files",
"to",
"a",
"remote",
"Windows",
"box",
"and",
"execute",
"them"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1207-L1408 | train |
saltstack/salt | salt/utils/cloud.py | deploy_script | def deploy_script(host,
port=22,
timeout=900,
username='root',
password=None,
key_filename=None,
script=None,
name=None,
sock_dir=None,
provider=None,
... | python | def deploy_script(host,
port=22,
timeout=900,
username='root',
password=None,
key_filename=None,
script=None,
name=None,
sock_dir=None,
provider=None,
... | [
"def",
"deploy_script",
"(",
"host",
",",
"port",
"=",
"22",
",",
"timeout",
"=",
"900",
",",
"username",
"=",
"'root'",
",",
"password",
"=",
"None",
",",
"key_filename",
"=",
"None",
",",
"script",
"=",
"None",
",",
"name",
"=",
"None",
",",
"sock_... | Copy a deploy script to a remote server, execute it, and remove it | [
"Copy",
"a",
"deploy",
"script",
"to",
"a",
"remote",
"server",
"execute",
"it",
"and",
"remove",
"it"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1411-L1887 | train |
saltstack/salt | salt/utils/cloud.py | run_inline_script | def run_inline_script(host,
name=None,
port=22,
timeout=900,
username='root',
key_filename=None,
inline_script=None,
ssh_timeout=15,
display_ssh... | python | def run_inline_script(host,
name=None,
port=22,
timeout=900,
username='root',
key_filename=None,
inline_script=None,
ssh_timeout=15,
display_ssh... | [
"def",
"run_inline_script",
"(",
"host",
",",
"name",
"=",
"None",
",",
"port",
"=",
"22",
",",
"timeout",
"=",
"900",
",",
"username",
"=",
"'root'",
",",
"key_filename",
"=",
"None",
",",
"inline_script",
"=",
"None",
",",
"ssh_timeout",
"=",
"15",
"... | Run the inline script commands, one by one
:**kwargs: catch all other things we may get but don't actually need/use | [
"Run",
"the",
"inline",
"script",
"commands",
"one",
"by",
"one",
":",
"**",
"kwargs",
":",
"catch",
"all",
"other",
"things",
"we",
"may",
"get",
"but",
"don",
"t",
"actually",
"need",
"/",
"use"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1890-L1961 | train |
saltstack/salt | salt/utils/cloud.py | filter_event | def filter_event(tag, data, defaults):
'''
Accept a tag, a dict and a list of default keys to return from the dict, and
check them against the cloud configuration for that tag
'''
ret = {}
keys = []
use_defaults = True
for ktag in __opts__.get('filter_events', {}):
if tag != kta... | python | def filter_event(tag, data, defaults):
'''
Accept a tag, a dict and a list of default keys to return from the dict, and
check them against the cloud configuration for that tag
'''
ret = {}
keys = []
use_defaults = True
for ktag in __opts__.get('filter_events', {}):
if tag != kta... | [
"def",
"filter_event",
"(",
"tag",
",",
"data",
",",
"defaults",
")",
":",
"ret",
"=",
"{",
"}",
"keys",
"=",
"[",
"]",
"use_defaults",
"=",
"True",
"for",
"ktag",
"in",
"__opts__",
".",
"get",
"(",
"'filter_events'",
",",
"{",
"}",
")",
":",
"if",... | Accept a tag, a dict and a list of default keys to return from the dict, and
check them against the cloud configuration for that tag | [
"Accept",
"a",
"tag",
"a",
"dict",
"and",
"a",
"list",
"of",
"default",
"keys",
"to",
"return",
"from",
"the",
"dict",
"and",
"check",
"them",
"against",
"the",
"cloud",
"configuration",
"for",
"that",
"tag"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1964-L1994 | train |
saltstack/salt | salt/utils/cloud.py | fire_event | def fire_event(key, msg, tag, sock_dir, args=None, transport='zeromq'):
'''
Fire deploy action
'''
event = salt.utils.event.get_event(
'master',
sock_dir,
transport,
listen=False)
try:
event.fire_event(msg, tag)
except ValueError:
# We're using at... | python | def fire_event(key, msg, tag, sock_dir, args=None, transport='zeromq'):
'''
Fire deploy action
'''
event = salt.utils.event.get_event(
'master',
sock_dir,
transport,
listen=False)
try:
event.fire_event(msg, tag)
except ValueError:
# We're using at... | [
"def",
"fire_event",
"(",
"key",
",",
"msg",
",",
"tag",
",",
"sock_dir",
",",
"args",
"=",
"None",
",",
"transport",
"=",
"'zeromq'",
")",
":",
"event",
"=",
"salt",
".",
"utils",
".",
"event",
".",
"get_event",
"(",
"'master'",
",",
"sock_dir",
","... | Fire deploy action | [
"Fire",
"deploy",
"action"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L1997-L2019 | train |
saltstack/salt | salt/utils/cloud.py | scp_file | def scp_file(dest_path, contents=None, kwargs=None, local_file=None):
'''
Use scp or sftp to copy a file to a server
'''
file_to_upload = None
try:
if contents is not None:
try:
tmpfd, file_to_upload = tempfile.mkstemp()
os.write(tmpfd, contents)
... | python | def scp_file(dest_path, contents=None, kwargs=None, local_file=None):
'''
Use scp or sftp to copy a file to a server
'''
file_to_upload = None
try:
if contents is not None:
try:
tmpfd, file_to_upload = tempfile.mkstemp()
os.write(tmpfd, contents)
... | [
"def",
"scp_file",
"(",
"dest_path",
",",
"contents",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"local_file",
"=",
"None",
")",
":",
"file_to_upload",
"=",
"None",
"try",
":",
"if",
"contents",
"is",
"not",
"None",
":",
"try",
":",
"tmpfd",
",",
... | Use scp or sftp to copy a file to a server | [
"Use",
"scp",
"or",
"sftp",
"to",
"copy",
"a",
"file",
"to",
"a",
"server"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2077-L2164 | train |
saltstack/salt | salt/utils/cloud.py | ssh_file | def ssh_file(opts, dest_path, contents=None, kwargs=None, local_file=None):
'''
Copies a file to the remote SSH target using either sftp or scp, as
configured.
'''
if opts.get('file_transport', 'sftp') == 'sftp':
return sftp_file(dest_path, contents, kwargs, local_file)
return scp_file(d... | python | def ssh_file(opts, dest_path, contents=None, kwargs=None, local_file=None):
'''
Copies a file to the remote SSH target using either sftp or scp, as
configured.
'''
if opts.get('file_transport', 'sftp') == 'sftp':
return sftp_file(dest_path, contents, kwargs, local_file)
return scp_file(d... | [
"def",
"ssh_file",
"(",
"opts",
",",
"dest_path",
",",
"contents",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"local_file",
"=",
"None",
")",
":",
"if",
"opts",
".",
"get",
"(",
"'file_transport'",
",",
"'sftp'",
")",
"==",
"'sftp'",
":",
"return",
... | Copies a file to the remote SSH target using either sftp or scp, as
configured. | [
"Copies",
"a",
"file",
"to",
"the",
"remote",
"SSH",
"target",
"using",
"either",
"sftp",
"or",
"scp",
"as",
"configured",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2167-L2174 | train |
saltstack/salt | salt/utils/cloud.py | win_cmd | def win_cmd(command, **kwargs):
'''
Wrapper for commands to be run against Windows boxes
'''
logging_command = kwargs.get('logging_command', None)
try:
proc = NonBlockingPopen(
command,
shell=True,
stderr=subprocess.PIPE,
stdout=subprocess.PIP... | python | def win_cmd(command, **kwargs):
'''
Wrapper for commands to be run against Windows boxes
'''
logging_command = kwargs.get('logging_command', None)
try:
proc = NonBlockingPopen(
command,
shell=True,
stderr=subprocess.PIPE,
stdout=subprocess.PIP... | [
"def",
"win_cmd",
"(",
"command",
",",
"*",
"*",
"kwargs",
")",
":",
"logging_command",
"=",
"kwargs",
".",
"get",
"(",
"'logging_command'",
",",
"None",
")",
"try",
":",
"proc",
"=",
"NonBlockingPopen",
"(",
"command",
",",
"shell",
"=",
"True",
",",
... | Wrapper for commands to be run against Windows boxes | [
"Wrapper",
"for",
"commands",
"to",
"be",
"run",
"against",
"Windows",
"boxes"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2269-L2302 | train |
saltstack/salt | salt/utils/cloud.py | winrm_cmd | def winrm_cmd(session, command, flags, **kwargs):
'''
Wrapper for commands to be run against Windows boxes using WinRM.
'''
log.debug('Executing WinRM command: %s %s', command, flags)
# rebuild the session to ensure we haven't timed out
session.protocol.transport.build_session()
r = session.... | python | def winrm_cmd(session, command, flags, **kwargs):
'''
Wrapper for commands to be run against Windows boxes using WinRM.
'''
log.debug('Executing WinRM command: %s %s', command, flags)
# rebuild the session to ensure we haven't timed out
session.protocol.transport.build_session()
r = session.... | [
"def",
"winrm_cmd",
"(",
"session",
",",
"command",
",",
"flags",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"'Executing WinRM command: %s %s'",
",",
"command",
",",
"flags",
")",
"# rebuild the session to ensure we haven't timed out",
"session",
... | Wrapper for commands to be run against Windows boxes using WinRM. | [
"Wrapper",
"for",
"commands",
"to",
"be",
"run",
"against",
"Windows",
"boxes",
"using",
"WinRM",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2305-L2313 | train |
saltstack/salt | salt/utils/cloud.py | root_cmd | def root_cmd(command, tty, sudo, allow_failure=False, **kwargs):
'''
Wrapper for commands to be run as root
'''
logging_command = command
sudo_password = kwargs.get('sudo_password', None)
if sudo:
if sudo_password is None:
command = 'sudo {0}'.format(command)
log... | python | def root_cmd(command, tty, sudo, allow_failure=False, **kwargs):
'''
Wrapper for commands to be run as root
'''
logging_command = command
sudo_password = kwargs.get('sudo_password', None)
if sudo:
if sudo_password is None:
command = 'sudo {0}'.format(command)
log... | [
"def",
"root_cmd",
"(",
"command",
",",
"tty",
",",
"sudo",
",",
"allow_failure",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"logging_command",
"=",
"command",
"sudo_password",
"=",
"kwargs",
".",
"get",
"(",
"'sudo_password'",
",",
"None",
")",
"i... | Wrapper for commands to be run as root | [
"Wrapper",
"for",
"commands",
"to",
"be",
"run",
"as",
"root"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2316-L2392 | train |
saltstack/salt | salt/utils/cloud.py | check_auth | def check_auth(name, sock_dir=None, queue=None, timeout=300):
'''
This function is called from a multiprocess instance, to wait for a minion
to become available to receive salt commands
'''
event = salt.utils.event.SaltEvent('master', sock_dir, listen=True)
starttime = time.mktime(time.localtime... | python | def check_auth(name, sock_dir=None, queue=None, timeout=300):
'''
This function is called from a multiprocess instance, to wait for a minion
to become available to receive salt commands
'''
event = salt.utils.event.SaltEvent('master', sock_dir, listen=True)
starttime = time.mktime(time.localtime... | [
"def",
"check_auth",
"(",
"name",
",",
"sock_dir",
"=",
"None",
",",
"queue",
"=",
"None",
",",
"timeout",
"=",
"300",
")",
":",
"event",
"=",
"salt",
".",
"utils",
".",
"event",
".",
"SaltEvent",
"(",
"'master'",
",",
"sock_dir",
",",
"listen",
"=",... | This function is called from a multiprocess instance, to wait for a minion
to become available to receive salt commands | [
"This",
"function",
"is",
"called",
"from",
"a",
"multiprocess",
"instance",
"to",
"wait",
"for",
"a",
"minion",
"to",
"become",
"available",
"to",
"receive",
"salt",
"commands"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2395-L2412 | train |
saltstack/salt | salt/utils/cloud.py | ip_to_int | def ip_to_int(ip):
'''
Converts an IP address to an integer
'''
ret = 0
for octet in ip.split('.'):
ret = ret * 256 + int(octet)
return ret | python | def ip_to_int(ip):
'''
Converts an IP address to an integer
'''
ret = 0
for octet in ip.split('.'):
ret = ret * 256 + int(octet)
return ret | [
"def",
"ip_to_int",
"(",
"ip",
")",
":",
"ret",
"=",
"0",
"for",
"octet",
"in",
"ip",
".",
"split",
"(",
"'.'",
")",
":",
"ret",
"=",
"ret",
"*",
"256",
"+",
"int",
"(",
"octet",
")",
"return",
"ret"
] | Converts an IP address to an integer | [
"Converts",
"an",
"IP",
"address",
"to",
"an",
"integer"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2415-L2422 | train |
saltstack/salt | salt/utils/cloud.py | is_public_ip | def is_public_ip(ip):
'''
Determines whether an IP address falls within one of the private IP ranges
'''
if ':' in ip:
# ipv6
if ip.startswith('fe80:'):
# ipv6 link local
return False
return True
addr = ip_to_int(ip)
if 167772160 < addr < 184549375... | python | def is_public_ip(ip):
'''
Determines whether an IP address falls within one of the private IP ranges
'''
if ':' in ip:
# ipv6
if ip.startswith('fe80:'):
# ipv6 link local
return False
return True
addr = ip_to_int(ip)
if 167772160 < addr < 184549375... | [
"def",
"is_public_ip",
"(",
"ip",
")",
":",
"if",
"':'",
"in",
"ip",
":",
"# ipv6",
"if",
"ip",
".",
"startswith",
"(",
"'fe80:'",
")",
":",
"# ipv6 link local",
"return",
"False",
"return",
"True",
"addr",
"=",
"ip_to_int",
"(",
"ip",
")",
"if",
"1677... | Determines whether an IP address falls within one of the private IP ranges | [
"Determines",
"whether",
"an",
"IP",
"address",
"falls",
"within",
"one",
"of",
"the",
"private",
"IP",
"ranges"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2425-L2448 | train |
saltstack/salt | salt/utils/cloud.py | check_name | def check_name(name, safe_chars):
'''
Check whether the specified name contains invalid characters
'''
regexp = re.compile('[^{0}]'.format(safe_chars))
if regexp.search(name):
raise SaltCloudException(
'{0} contains characters not supported by this cloud provider. '
'... | python | def check_name(name, safe_chars):
'''
Check whether the specified name contains invalid characters
'''
regexp = re.compile('[^{0}]'.format(safe_chars))
if regexp.search(name):
raise SaltCloudException(
'{0} contains characters not supported by this cloud provider. '
'... | [
"def",
"check_name",
"(",
"name",
",",
"safe_chars",
")",
":",
"regexp",
"=",
"re",
".",
"compile",
"(",
"'[^{0}]'",
".",
"format",
"(",
"safe_chars",
")",
")",
"if",
"regexp",
".",
"search",
"(",
"name",
")",
":",
"raise",
"SaltCloudException",
"(",
"... | Check whether the specified name contains invalid characters | [
"Check",
"whether",
"the",
"specified",
"name",
"contains",
"invalid",
"characters"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2451-L2462 | train |
saltstack/salt | salt/utils/cloud.py | remove_sshkey | def remove_sshkey(host, known_hosts=None):
'''
Remove a host from the known_hosts file
'''
if known_hosts is None:
if 'HOME' in os.environ:
known_hosts = '{0}/.ssh/known_hosts'.format(os.environ['HOME'])
else:
try:
known_hosts = '{0}/.ssh/known_hos... | python | def remove_sshkey(host, known_hosts=None):
'''
Remove a host from the known_hosts file
'''
if known_hosts is None:
if 'HOME' in os.environ:
known_hosts = '{0}/.ssh/known_hosts'.format(os.environ['HOME'])
else:
try:
known_hosts = '{0}/.ssh/known_hos... | [
"def",
"remove_sshkey",
"(",
"host",
",",
"known_hosts",
"=",
"None",
")",
":",
"if",
"known_hosts",
"is",
"None",
":",
"if",
"'HOME'",
"in",
"os",
".",
"environ",
":",
"known_hosts",
"=",
"'{0}/.ssh/known_hosts'",
".",
"format",
"(",
"os",
".",
"environ",... | Remove a host from the known_hosts file | [
"Remove",
"a",
"host",
"from",
"the",
"known_hosts",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2465-L2489 | train |
saltstack/salt | salt/utils/cloud.py | list_nodes_select | def list_nodes_select(nodes, selection, call=None):
'''
Return a list of the VMs that are on the provider, with select fields
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_select function must be called '
'with -f or --function.'
)
if 'e... | python | def list_nodes_select(nodes, selection, call=None):
'''
Return a list of the VMs that are on the provider, with select fields
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_select function must be called '
'with -f or --function.'
)
if 'e... | [
"def",
"list_nodes_select",
"(",
"nodes",
",",
"selection",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_nodes_select function must be called '",
"'with -f or --function.'",
")",
"if",
"'error... | Return a list of the VMs that are on the provider, with select fields | [
"Return",
"a",
"list",
"of",
"the",
"VMs",
"that",
"are",
"on",
"the",
"provider",
"with",
"select",
"fields"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2565-L2592 | train |
saltstack/salt | salt/utils/cloud.py | lock_file | def lock_file(filename, interval=.5, timeout=15):
'''
Lock a file; if it is already locked, then wait for it to become available
before locking it.
Note that these locks are only recognized by Salt Cloud, and not other
programs or platforms.
'''
log.trace('Attempting to obtain lock for %s',... | python | def lock_file(filename, interval=.5, timeout=15):
'''
Lock a file; if it is already locked, then wait for it to become available
before locking it.
Note that these locks are only recognized by Salt Cloud, and not other
programs or platforms.
'''
log.trace('Attempting to obtain lock for %s',... | [
"def",
"lock_file",
"(",
"filename",
",",
"interval",
"=",
".5",
",",
"timeout",
"=",
"15",
")",
":",
"log",
".",
"trace",
"(",
"'Attempting to obtain lock for %s'",
",",
"filename",
")",
"lock",
"=",
"filename",
"+",
"'.lock'",
"start",
"=",
"time",
".",
... | Lock a file; if it is already locked, then wait for it to become available
before locking it.
Note that these locks are only recognized by Salt Cloud, and not other
programs or platforms. | [
"Lock",
"a",
"file",
";",
"if",
"it",
"is",
"already",
"locked",
"then",
"wait",
"for",
"it",
"to",
"become",
"available",
"before",
"locking",
"it",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2595-L2616 | train |
saltstack/salt | salt/utils/cloud.py | unlock_file | def unlock_file(filename):
'''
Unlock a locked file
Note that these locks are only recognized by Salt Cloud, and not other
programs or platforms.
'''
log.trace('Removing lock for %s', filename)
lock = filename + '.lock'
try:
os.remove(lock)
except OSError as exc:
log... | python | def unlock_file(filename):
'''
Unlock a locked file
Note that these locks are only recognized by Salt Cloud, and not other
programs or platforms.
'''
log.trace('Removing lock for %s', filename)
lock = filename + '.lock'
try:
os.remove(lock)
except OSError as exc:
log... | [
"def",
"unlock_file",
"(",
"filename",
")",
":",
"log",
".",
"trace",
"(",
"'Removing lock for %s'",
",",
"filename",
")",
"lock",
"=",
"filename",
"+",
"'.lock'",
"try",
":",
"os",
".",
"remove",
"(",
"lock",
")",
"except",
"OSError",
"as",
"exc",
":",
... | Unlock a locked file
Note that these locks are only recognized by Salt Cloud, and not other
programs or platforms. | [
"Unlock",
"a",
"locked",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2619-L2631 | train |
saltstack/salt | salt/utils/cloud.py | cachedir_index_add | def cachedir_index_add(minion_id, profile, driver, provider, base=None):
'''
Add an entry to the cachedir index. This generally only needs to happen when
a new instance is created. This entry should contain:
.. code-block:: yaml
- minion_id
- profile used to create the instance
... | python | def cachedir_index_add(minion_id, profile, driver, provider, base=None):
'''
Add an entry to the cachedir index. This generally only needs to happen when
a new instance is created. This entry should contain:
.. code-block:: yaml
- minion_id
- profile used to create the instance
... | [
"def",
"cachedir_index_add",
"(",
"minion_id",
",",
"profile",
",",
"driver",
",",
"provider",
",",
"base",
"=",
"None",
")",
":",
"base",
"=",
"init_cachedir",
"(",
"base",
")",
"index_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base",
",",
"'in... | Add an entry to the cachedir index. This generally only needs to happen when
a new instance is created. This entry should contain:
.. code-block:: yaml
- minion_id
- profile used to create the instance
- provider and driver name
The intent of this function is to speed up lookups f... | [
"Add",
"an",
"entry",
"to",
"the",
"cachedir",
"index",
".",
"This",
"generally",
"only",
"needs",
"to",
"happen",
"when",
"a",
"new",
"instance",
"is",
"created",
".",
"This",
"entry",
"should",
"contain",
":"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2634-L2677 | train |
saltstack/salt | salt/utils/cloud.py | cachedir_index_del | def cachedir_index_del(minion_id, base=None):
'''
Delete an entry from the cachedir index. This generally only needs to happen
when an instance is deleted.
'''
base = init_cachedir(base)
index_file = os.path.join(base, 'index.p')
lock_file(index_file)
if os.path.exists(index_file):
... | python | def cachedir_index_del(minion_id, base=None):
'''
Delete an entry from the cachedir index. This generally only needs to happen
when an instance is deleted.
'''
base = init_cachedir(base)
index_file = os.path.join(base, 'index.p')
lock_file(index_file)
if os.path.exists(index_file):
... | [
"def",
"cachedir_index_del",
"(",
"minion_id",
",",
"base",
"=",
"None",
")",
":",
"base",
"=",
"init_cachedir",
"(",
"base",
")",
"index_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base",
",",
"'index.p'",
")",
"lock_file",
"(",
"index_file",
")",... | Delete an entry from the cachedir index. This generally only needs to happen
when an instance is deleted. | [
"Delete",
"an",
"entry",
"from",
"the",
"cachedir",
"index",
".",
"This",
"generally",
"only",
"needs",
"to",
"happen",
"when",
"an",
"instance",
"is",
"deleted",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2680-L2704 | train |
saltstack/salt | salt/utils/cloud.py | init_cachedir | def init_cachedir(base=None):
'''
Initialize the cachedir needed for Salt Cloud to keep track of minions
'''
if base is None:
base = __opts__['cachedir']
needed_dirs = (base,
os.path.join(base, 'requested'),
os.path.join(base, 'active'))
for dir_ in ... | python | def init_cachedir(base=None):
'''
Initialize the cachedir needed for Salt Cloud to keep track of minions
'''
if base is None:
base = __opts__['cachedir']
needed_dirs = (base,
os.path.join(base, 'requested'),
os.path.join(base, 'active'))
for dir_ in ... | [
"def",
"init_cachedir",
"(",
"base",
"=",
"None",
")",
":",
"if",
"base",
"is",
"None",
":",
"base",
"=",
"__opts__",
"[",
"'cachedir'",
"]",
"needed_dirs",
"=",
"(",
"base",
",",
"os",
".",
"path",
".",
"join",
"(",
"base",
",",
"'requested'",
")",
... | Initialize the cachedir needed for Salt Cloud to keep track of minions | [
"Initialize",
"the",
"cachedir",
"needed",
"for",
"Salt",
"Cloud",
"to",
"keep",
"track",
"of",
"minions"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2707-L2721 | train |
saltstack/salt | salt/utils/cloud.py | request_minion_cachedir | def request_minion_cachedir(
minion_id,
opts=None,
fingerprint='',
pubkey=None,
provider=None,
base=None,
):
'''
Creates an entry in the requested/ cachedir. This means that Salt Cloud has
made a request to a cloud provider to create an instance, but it has no... | python | def request_minion_cachedir(
minion_id,
opts=None,
fingerprint='',
pubkey=None,
provider=None,
base=None,
):
'''
Creates an entry in the requested/ cachedir. This means that Salt Cloud has
made a request to a cloud provider to create an instance, but it has no... | [
"def",
"request_minion_cachedir",
"(",
"minion_id",
",",
"opts",
"=",
"None",
",",
"fingerprint",
"=",
"''",
",",
"pubkey",
"=",
"None",
",",
"provider",
"=",
"None",
",",
"base",
"=",
"None",
",",
")",
":",
"if",
"base",
"is",
"None",
":",
"base",
"... | Creates an entry in the requested/ cachedir. This means that Salt Cloud has
made a request to a cloud provider to create an instance, but it has not
yet verified that the instance properly exists.
If the fingerprint is unknown, a raw pubkey can be passed in, and a
fingerprint will be calculated. If bot... | [
"Creates",
"an",
"entry",
"in",
"the",
"requested",
"/",
"cachedir",
".",
"This",
"means",
"that",
"Salt",
"Cloud",
"has",
"made",
"a",
"request",
"to",
"a",
"cloud",
"provider",
"to",
"create",
"an",
"instance",
"but",
"it",
"has",
"not",
"yet",
"verifi... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2725-L2760 | train |
saltstack/salt | salt/utils/cloud.py | change_minion_cachedir | def change_minion_cachedir(
minion_id,
cachedir,
data=None,
base=None,
):
'''
Changes the info inside a minion's cachedir entry. The type of cachedir
must be specified (i.e., 'requested' or 'active'). A dict is also passed in
which contains the data to be changed.
Ex... | python | def change_minion_cachedir(
minion_id,
cachedir,
data=None,
base=None,
):
'''
Changes the info inside a minion's cachedir entry. The type of cachedir
must be specified (i.e., 'requested' or 'active'). A dict is also passed in
which contains the data to be changed.
Ex... | [
"def",
"change_minion_cachedir",
"(",
"minion_id",
",",
"cachedir",
",",
"data",
"=",
"None",
",",
"base",
"=",
"None",
",",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"return",
"False",
"if",
"base",
"is",
"None",
":",
... | Changes the info inside a minion's cachedir entry. The type of cachedir
must be specified (i.e., 'requested' or 'active'). A dict is also passed in
which contains the data to be changed.
Example:
change_minion_cachedir(
'myminion',
'requested',
{'fingerprint': '... | [
"Changes",
"the",
"info",
"inside",
"a",
"minion",
"s",
"cachedir",
"entry",
".",
"The",
"type",
"of",
"cachedir",
"must",
"be",
"specified",
"(",
"i",
".",
"e",
".",
"requested",
"or",
"active",
")",
".",
"A",
"dict",
"is",
"also",
"passed",
"in",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2763-L2798 | train |
saltstack/salt | salt/utils/cloud.py | activate_minion_cachedir | def activate_minion_cachedir(minion_id, base=None):
'''
Moves a minion from the requested/ cachedir into the active/ cachedir. This
means that Salt Cloud has verified that a requested instance properly
exists, and should be expected to exist from here on out.
'''
if base is None:
base = ... | python | def activate_minion_cachedir(minion_id, base=None):
'''
Moves a minion from the requested/ cachedir into the active/ cachedir. This
means that Salt Cloud has verified that a requested instance properly
exists, and should be expected to exist from here on out.
'''
if base is None:
base = ... | [
"def",
"activate_minion_cachedir",
"(",
"minion_id",
",",
"base",
"=",
"None",
")",
":",
"if",
"base",
"is",
"None",
":",
"base",
"=",
"__opts__",
"[",
"'cachedir'",
"]",
"fname",
"=",
"'{0}.p'",
".",
"format",
"(",
"minion_id",
")",
"src",
"=",
"os",
... | Moves a minion from the requested/ cachedir into the active/ cachedir. This
means that Salt Cloud has verified that a requested instance properly
exists, and should be expected to exist from here on out. | [
"Moves",
"a",
"minion",
"from",
"the",
"requested",
"/",
"cachedir",
"into",
"the",
"active",
"/",
"cachedir",
".",
"This",
"means",
"that",
"Salt",
"Cloud",
"has",
"verified",
"that",
"a",
"requested",
"instance",
"properly",
"exists",
"and",
"should",
"be"... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2801-L2813 | train |
saltstack/salt | salt/utils/cloud.py | delete_minion_cachedir | def delete_minion_cachedir(minion_id, provider, opts, base=None):
'''
Deletes a minion's entry from the cloud cachedir. It will search through
all cachedirs to find the minion's cache file.
Needs `update_cachedir` set to True.
'''
if isinstance(opts, dict):
__opts__.update(opts)
if ... | python | def delete_minion_cachedir(minion_id, provider, opts, base=None):
'''
Deletes a minion's entry from the cloud cachedir. It will search through
all cachedirs to find the minion's cache file.
Needs `update_cachedir` set to True.
'''
if isinstance(opts, dict):
__opts__.update(opts)
if ... | [
"def",
"delete_minion_cachedir",
"(",
"minion_id",
",",
"provider",
",",
"opts",
",",
"base",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"opts",
",",
"dict",
")",
":",
"__opts__",
".",
"update",
"(",
"opts",
")",
"if",
"__opts__",
".",
"get",
"(",... | Deletes a minion's entry from the cloud cachedir. It will search through
all cachedirs to find the minion's cache file.
Needs `update_cachedir` set to True. | [
"Deletes",
"a",
"minion",
"s",
"entry",
"from",
"the",
"cloud",
"cachedir",
".",
"It",
"will",
"search",
"through",
"all",
"cachedirs",
"to",
"find",
"the",
"minion",
"s",
"cache",
"file",
".",
"Needs",
"update_cachedir",
"set",
"to",
"True",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2816-L2837 | train |
saltstack/salt | salt/utils/cloud.py | list_cache_nodes_full | def list_cache_nodes_full(opts=None, provider=None, base=None):
'''
Return a list of minion data from the cloud cache, rather from the cloud
providers themselves. This is the cloud cache version of list_nodes_full().
'''
if opts is None:
opts = __opts__
if opts.get('update_cachedir', Fal... | python | def list_cache_nodes_full(opts=None, provider=None, base=None):
'''
Return a list of minion data from the cloud cache, rather from the cloud
providers themselves. This is the cloud cache version of list_nodes_full().
'''
if opts is None:
opts = __opts__
if opts.get('update_cachedir', Fal... | [
"def",
"list_cache_nodes_full",
"(",
"opts",
"=",
"None",
",",
"provider",
"=",
"None",
",",
"base",
"=",
"None",
")",
":",
"if",
"opts",
"is",
"None",
":",
"opts",
"=",
"__opts__",
"if",
"opts",
".",
"get",
"(",
"'update_cachedir'",
",",
"False",
")",... | Return a list of minion data from the cloud cache, rather from the cloud
providers themselves. This is the cloud cache version of list_nodes_full(). | [
"Return",
"a",
"list",
"of",
"minion",
"data",
"from",
"the",
"cloud",
"cache",
"rather",
"from",
"the",
"cloud",
"providers",
"themselves",
".",
"This",
"is",
"the",
"cloud",
"cache",
"version",
"of",
"list_nodes_full",
"()",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2840-L2875 | train |
saltstack/salt | salt/utils/cloud.py | update_bootstrap | def update_bootstrap(config, url=None):
'''
Update the salt-bootstrap script
url can be one of:
- The URL to fetch the bootstrap script from
- The absolute path to the bootstrap
- The content of the bootstrap script
'''
default_url = config.get('bootstrap_script_url',
... | python | def update_bootstrap(config, url=None):
'''
Update the salt-bootstrap script
url can be one of:
- The URL to fetch the bootstrap script from
- The absolute path to the bootstrap
- The content of the bootstrap script
'''
default_url = config.get('bootstrap_script_url',
... | [
"def",
"update_bootstrap",
"(",
"config",
",",
"url",
"=",
"None",
")",
":",
"default_url",
"=",
"config",
".",
"get",
"(",
"'bootstrap_script_url'",
",",
"'https://bootstrap.saltstack.com'",
")",
"if",
"not",
"url",
":",
"url",
"=",
"default_url",
"if",
"not"... | Update the salt-bootstrap script
url can be one of:
- The URL to fetch the bootstrap script from
- The absolute path to the bootstrap
- The content of the bootstrap script | [
"Update",
"the",
"salt",
"-",
"bootstrap",
"script"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L2878-L3007 | train |
saltstack/salt | salt/utils/cloud.py | cache_node_list | def cache_node_list(nodes, provider, opts):
'''
If configured to do so, update the cloud cachedir with the current list of
nodes. Also fires configured events pertaining to the node list.
.. versionadded:: 2014.7.0
'''
if 'update_cachedir' not in opts or not opts['update_cachedir']:
ret... | python | def cache_node_list(nodes, provider, opts):
'''
If configured to do so, update the cloud cachedir with the current list of
nodes. Also fires configured events pertaining to the node list.
.. versionadded:: 2014.7.0
'''
if 'update_cachedir' not in opts or not opts['update_cachedir']:
ret... | [
"def",
"cache_node_list",
"(",
"nodes",
",",
"provider",
",",
"opts",
")",
":",
"if",
"'update_cachedir'",
"not",
"in",
"opts",
"or",
"not",
"opts",
"[",
"'update_cachedir'",
"]",
":",
"return",
"base",
"=",
"os",
".",
"path",
".",
"join",
"(",
"init_cac... | If configured to do so, update the cloud cachedir with the current list of
nodes. Also fires configured events pertaining to the node list.
.. versionadded:: 2014.7.0 | [
"If",
"configured",
"to",
"do",
"so",
"update",
"the",
"cloud",
"cachedir",
"with",
"the",
"current",
"list",
"of",
"nodes",
".",
"Also",
"fires",
"configured",
"events",
"pertaining",
"to",
"the",
"node",
"list",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3010-L3034 | train |
saltstack/salt | salt/utils/cloud.py | cache_node | def cache_node(node, provider, opts):
'''
Cache node individually
.. versionadded:: 2014.7.0
'''
if isinstance(opts, dict):
__opts__.update(opts)
if 'update_cachedir' not in __opts__ or not __opts__['update_cachedir']:
return
if not os.path.exists(os.path.join(__opts__['ca... | python | def cache_node(node, provider, opts):
'''
Cache node individually
.. versionadded:: 2014.7.0
'''
if isinstance(opts, dict):
__opts__.update(opts)
if 'update_cachedir' not in __opts__ or not __opts__['update_cachedir']:
return
if not os.path.exists(os.path.join(__opts__['ca... | [
"def",
"cache_node",
"(",
"node",
",",
"provider",
",",
"opts",
")",
":",
"if",
"isinstance",
"(",
"opts",
",",
"dict",
")",
":",
"__opts__",
".",
"update",
"(",
"opts",
")",
"if",
"'update_cachedir'",
"not",
"in",
"__opts__",
"or",
"not",
"__opts__",
... | Cache node individually
.. versionadded:: 2014.7.0 | [
"Cache",
"node",
"individually"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3037-L3060 | train |
saltstack/salt | salt/utils/cloud.py | missing_node_cache | def missing_node_cache(prov_dir, node_list, provider, opts):
'''
Check list of nodes to see if any nodes which were previously known about
in the cache have been removed from the node list.
This function will only run if configured to do so in the main Salt Cloud
configuration file (normally /etc/s... | python | def missing_node_cache(prov_dir, node_list, provider, opts):
'''
Check list of nodes to see if any nodes which were previously known about
in the cache have been removed from the node list.
This function will only run if configured to do so in the main Salt Cloud
configuration file (normally /etc/s... | [
"def",
"missing_node_cache",
"(",
"prov_dir",
",",
"node_list",
",",
"provider",
",",
"opts",
")",
":",
"cached_nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"os",
".",
"listdir",
"(",
"prov_dir",
")",
":",
"cached_nodes",
".",
"append",
"(",
"os",
".",
... | Check list of nodes to see if any nodes which were previously known about
in the cache have been removed from the node list.
This function will only run if configured to do so in the main Salt Cloud
configuration file (normally /etc/salt/cloud).
.. code-block:: yaml
diff_cache_events: True
... | [
"Check",
"list",
"of",
"nodes",
"to",
"see",
"if",
"any",
"nodes",
"which",
"were",
"previously",
"known",
"about",
"in",
"the",
"cache",
"have",
"been",
"removed",
"from",
"the",
"node",
"list",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3063-L3094 | train |
saltstack/salt | salt/utils/cloud.py | diff_node_cache | def diff_node_cache(prov_dir, node, new_data, opts):
'''
Check new node data against current cache. If data differ, fire an event
which consists of the new node data.
This function will only run if configured to do so in the main Salt Cloud
configuration file (normally /etc/salt/cloud).
.. cod... | python | def diff_node_cache(prov_dir, node, new_data, opts):
'''
Check new node data against current cache. If data differ, fire an event
which consists of the new node data.
This function will only run if configured to do so in the main Salt Cloud
configuration file (normally /etc/salt/cloud).
.. cod... | [
"def",
"diff_node_cache",
"(",
"prov_dir",
",",
"node",
",",
"new_data",
",",
"opts",
")",
":",
"if",
"'diff_cache_events'",
"not",
"in",
"opts",
"or",
"not",
"opts",
"[",
"'diff_cache_events'",
"]",
":",
"return",
"if",
"node",
"is",
"None",
":",
"return"... | Check new node data against current cache. If data differ, fire an event
which consists of the new node data.
This function will only run if configured to do so in the main Salt Cloud
configuration file (normally /etc/salt/cloud).
.. code-block:: yaml
diff_cache_events: True
.. versionad... | [
"Check",
"new",
"node",
"data",
"against",
"current",
"cache",
".",
"If",
"data",
"differ",
"fire",
"an",
"event",
"which",
"consists",
"of",
"the",
"new",
"node",
"data",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3097-L3158 | train |
saltstack/salt | salt/utils/cloud.py | _strip_cache_events | def _strip_cache_events(data, opts):
'''
Strip out user-configured sensitive event data. The fields to be stripped
are configured in the main Salt Cloud configuration file, usually
``/etc/salt/cloud``.
.. code-block: yaml
cache_event_strip_fields:
- password
- priv_key
... | python | def _strip_cache_events(data, opts):
'''
Strip out user-configured sensitive event data. The fields to be stripped
are configured in the main Salt Cloud configuration file, usually
``/etc/salt/cloud``.
.. code-block: yaml
cache_event_strip_fields:
- password
- priv_key
... | [
"def",
"_strip_cache_events",
"(",
"data",
",",
"opts",
")",
":",
"event_data",
"=",
"copy",
".",
"deepcopy",
"(",
"data",
")",
"strip_fields",
"=",
"opts",
".",
"get",
"(",
"'cache_event_strip_fields'",
",",
"[",
"]",
")",
"for",
"field",
"in",
"strip_fie... | Strip out user-configured sensitive event data. The fields to be stripped
are configured in the main Salt Cloud configuration file, usually
``/etc/salt/cloud``.
.. code-block: yaml
cache_event_strip_fields:
- password
- priv_key
.. versionadded:: 2014.7.0 | [
"Strip",
"out",
"user",
"-",
"configured",
"sensitive",
"event",
"data",
".",
"The",
"fields",
"to",
"be",
"stripped",
"are",
"configured",
"in",
"the",
"main",
"Salt",
"Cloud",
"configuration",
"file",
"usually",
"/",
"etc",
"/",
"salt",
"/",
"cloud",
"."... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3161-L3181 | train |
saltstack/salt | salt/utils/cloud.py | _salt_cloud_force_ascii | def _salt_cloud_force_ascii(exc):
'''
Helper method to try its best to convert any Unicode text into ASCII
without stack tracing since salt internally does not handle Unicode strings
This method is not supposed to be used directly. Once
`py:module: salt.utils.cloud` is imported this method register... | python | def _salt_cloud_force_ascii(exc):
'''
Helper method to try its best to convert any Unicode text into ASCII
without stack tracing since salt internally does not handle Unicode strings
This method is not supposed to be used directly. Once
`py:module: salt.utils.cloud` is imported this method register... | [
"def",
"_salt_cloud_force_ascii",
"(",
"exc",
")",
":",
"if",
"not",
"isinstance",
"(",
"exc",
",",
"(",
"UnicodeEncodeError",
",",
"UnicodeTranslateError",
")",
")",
":",
"raise",
"TypeError",
"(",
"'Can\\'t handle {0}'",
".",
"format",
"(",
"exc",
")",
")",
... | Helper method to try its best to convert any Unicode text into ASCII
without stack tracing since salt internally does not handle Unicode strings
This method is not supposed to be used directly. Once
`py:module: salt.utils.cloud` is imported this method register's with
python's codecs module for proper ... | [
"Helper",
"method",
"to",
"try",
"its",
"best",
"to",
"convert",
"any",
"Unicode",
"text",
"into",
"ASCII",
"without",
"stack",
"tracing",
"since",
"salt",
"internally",
"does",
"not",
"handle",
"Unicode",
"strings"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3184-L3208 | train |
saltstack/salt | salt/utils/cloud.py | retrieve_password_from_keyring | def retrieve_password_from_keyring(credential_id, username):
'''
Retrieve particular user's password for a specified credential set from system keyring.
'''
try:
import keyring # pylint: disable=import-error
return keyring.get_password(credential_id, username)
except ImportError:
... | python | def retrieve_password_from_keyring(credential_id, username):
'''
Retrieve particular user's password for a specified credential set from system keyring.
'''
try:
import keyring # pylint: disable=import-error
return keyring.get_password(credential_id, username)
except ImportError:
... | [
"def",
"retrieve_password_from_keyring",
"(",
"credential_id",
",",
"username",
")",
":",
"try",
":",
"import",
"keyring",
"# pylint: disable=import-error",
"return",
"keyring",
".",
"get_password",
"(",
"credential_id",
",",
"username",
")",
"except",
"ImportError",
... | Retrieve particular user's password for a specified credential set from system keyring. | [
"Retrieve",
"particular",
"user",
"s",
"password",
"for",
"a",
"specified",
"credential",
"set",
"from",
"system",
"keyring",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3214-L3223 | train |
saltstack/salt | salt/utils/cloud.py | _save_password_in_keyring | def _save_password_in_keyring(credential_id, username, password):
'''
Saves provider password in system keyring
'''
try:
import keyring # pylint: disable=import-error
return keyring.set_password(credential_id, username, password)
except ImportError:
log.error('Tried to store... | python | def _save_password_in_keyring(credential_id, username, password):
'''
Saves provider password in system keyring
'''
try:
import keyring # pylint: disable=import-error
return keyring.set_password(credential_id, username, password)
except ImportError:
log.error('Tried to store... | [
"def",
"_save_password_in_keyring",
"(",
"credential_id",
",",
"username",
",",
"password",
")",
":",
"try",
":",
"import",
"keyring",
"# pylint: disable=import-error",
"return",
"keyring",
".",
"set_password",
"(",
"credential_id",
",",
"username",
",",
"password",
... | Saves provider password in system keyring | [
"Saves",
"provider",
"password",
"in",
"system",
"keyring"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3226-L3235 | train |
saltstack/salt | salt/utils/cloud.py | store_password_in_keyring | def store_password_in_keyring(credential_id, username, password=None):
'''
Interactively prompts user for a password and stores it in system keyring
'''
try:
# pylint: disable=import-error
import keyring
import keyring.errors
# pylint: enable=import-error
if passw... | python | def store_password_in_keyring(credential_id, username, password=None):
'''
Interactively prompts user for a password and stores it in system keyring
'''
try:
# pylint: disable=import-error
import keyring
import keyring.errors
# pylint: enable=import-error
if passw... | [
"def",
"store_password_in_keyring",
"(",
"credential_id",
",",
"username",
",",
"password",
"=",
"None",
")",
":",
"try",
":",
"# pylint: disable=import-error",
"import",
"keyring",
"import",
"keyring",
".",
"errors",
"# pylint: enable=import-error",
"if",
"password",
... | Interactively prompts user for a password and stores it in system keyring | [
"Interactively",
"prompts",
"user",
"for",
"a",
"password",
"and",
"stores",
"it",
"in",
"system",
"keyring"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3238-L3265 | train |
saltstack/salt | salt/utils/cloud.py | _unwrap_dict | def _unwrap_dict(dictionary, index_string):
'''
Accepts index in form of a string
Returns final value
Example: dictionary = {'a': {'b': {'c': 'foobar'}}}
index_string = 'a,b,c'
returns 'foobar'
'''
index = index_string.split(',')
for k in index:
dictionary =... | python | def _unwrap_dict(dictionary, index_string):
'''
Accepts index in form of a string
Returns final value
Example: dictionary = {'a': {'b': {'c': 'foobar'}}}
index_string = 'a,b,c'
returns 'foobar'
'''
index = index_string.split(',')
for k in index:
dictionary =... | [
"def",
"_unwrap_dict",
"(",
"dictionary",
",",
"index_string",
")",
":",
"index",
"=",
"index_string",
".",
"split",
"(",
"','",
")",
"for",
"k",
"in",
"index",
":",
"dictionary",
"=",
"dictionary",
"[",
"k",
"]",
"return",
"dictionary"
] | Accepts index in form of a string
Returns final value
Example: dictionary = {'a': {'b': {'c': 'foobar'}}}
index_string = 'a,b,c'
returns 'foobar' | [
"Accepts",
"index",
"in",
"form",
"of",
"a",
"string",
"Returns",
"final",
"value",
"Example",
":",
"dictionary",
"=",
"{",
"a",
":",
"{",
"b",
":",
"{",
"c",
":",
"foobar",
"}}}",
"index_string",
"=",
"a",
"b",
"c",
"returns",
"foobar"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3268-L3279 | train |
saltstack/salt | salt/utils/cloud.py | run_func_until_ret_arg | def run_func_until_ret_arg(fun, kwargs, fun_call=None,
argument_being_watched=None, required_argument_response=None):
'''
Waits until the function retrieves some required argument.
NOTE: Tested with ec2 describe_volumes and describe_snapshots only.
'''
status = None
wh... | python | def run_func_until_ret_arg(fun, kwargs, fun_call=None,
argument_being_watched=None, required_argument_response=None):
'''
Waits until the function retrieves some required argument.
NOTE: Tested with ec2 describe_volumes and describe_snapshots only.
'''
status = None
wh... | [
"def",
"run_func_until_ret_arg",
"(",
"fun",
",",
"kwargs",
",",
"fun_call",
"=",
"None",
",",
"argument_being_watched",
"=",
"None",
",",
"required_argument_response",
"=",
"None",
")",
":",
"status",
"=",
"None",
"while",
"status",
"!=",
"required_argument_respo... | Waits until the function retrieves some required argument.
NOTE: Tested with ec2 describe_volumes and describe_snapshots only. | [
"Waits",
"until",
"the",
"function",
"retrieves",
"some",
"required",
"argument",
".",
"NOTE",
":",
"Tested",
"with",
"ec2",
"describe_volumes",
"and",
"describe_snapshots",
"only",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3282-L3305 | train |
saltstack/salt | salt/utils/cloud.py | get_salt_interface | def get_salt_interface(vm_, opts):
'''
Return the salt_interface type to connect to. Either 'public_ips' (default)
or 'private_ips'.
'''
salt_host = salt.config.get_cloud_config_value(
'salt_interface', vm_, opts, default=False,
search_global=False
)
if salt_host is False:
... | python | def get_salt_interface(vm_, opts):
'''
Return the salt_interface type to connect to. Either 'public_ips' (default)
or 'private_ips'.
'''
salt_host = salt.config.get_cloud_config_value(
'salt_interface', vm_, opts, default=False,
search_global=False
)
if salt_host is False:
... | [
"def",
"get_salt_interface",
"(",
"vm_",
",",
"opts",
")",
":",
"salt_host",
"=",
"salt",
".",
"config",
".",
"get_cloud_config_value",
"(",
"'salt_interface'",
",",
"vm_",
",",
"opts",
",",
"default",
"=",
"False",
",",
"search_global",
"=",
"False",
")",
... | Return the salt_interface type to connect to. Either 'public_ips' (default)
or 'private_ips'. | [
"Return",
"the",
"salt_interface",
"type",
"to",
"connect",
"to",
".",
"Either",
"public_ips",
"(",
"default",
")",
"or",
"private_ips",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3308-L3324 | train |
saltstack/salt | salt/utils/cloud.py | check_key_path_and_mode | def check_key_path_and_mode(provider, key_path):
'''
Checks that the key_path exists and the key_mode is either 0400 or 0600.
Returns True or False.
.. versionadded:: 2016.3.0
provider
The provider name that the key_path to check belongs to.
key_path
The key_path to ensure th... | python | def check_key_path_and_mode(provider, key_path):
'''
Checks that the key_path exists and the key_mode is either 0400 or 0600.
Returns True or False.
.. versionadded:: 2016.3.0
provider
The provider name that the key_path to check belongs to.
key_path
The key_path to ensure th... | [
"def",
"check_key_path_and_mode",
"(",
"provider",
",",
"key_path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"key_path",
")",
":",
"log",
".",
"error",
"(",
"'The key file \\'%s\\' used in the \\'%s\\' provider configuration '",
"'does not exist.\... | Checks that the key_path exists and the key_mode is either 0400 or 0600.
Returns True or False.
.. versionadded:: 2016.3.0
provider
The provider name that the key_path to check belongs to.
key_path
The key_path to ensure that it exists and to check adequate permissions
agains... | [
"Checks",
"that",
"the",
"key_path",
"exists",
"and",
"the",
"key_mode",
"is",
"either",
"0400",
"or",
"0600",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3327-L3357 | train |
saltstack/salt | salt/utils/cloud.py | userdata_template | def userdata_template(opts, vm_, userdata):
'''
Use the configured templating engine to template the userdata file
'''
# No userdata, no need to template anything
if userdata is None:
return userdata
userdata_template = salt.config.get_cloud_config_value(
'userdata_template', vm... | python | def userdata_template(opts, vm_, userdata):
'''
Use the configured templating engine to template the userdata file
'''
# No userdata, no need to template anything
if userdata is None:
return userdata
userdata_template = salt.config.get_cloud_config_value(
'userdata_template', vm... | [
"def",
"userdata_template",
"(",
"opts",
",",
"vm_",
",",
"userdata",
")",
":",
"# No userdata, no need to template anything",
"if",
"userdata",
"is",
"None",
":",
"return",
"userdata",
"userdata_template",
"=",
"salt",
".",
"config",
".",
"get_cloud_config_value",
... | Use the configured templating engine to template the userdata file | [
"Use",
"the",
"configured",
"templating",
"engine",
"to",
"template",
"the",
"userdata",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L3360-L3405 | train |
saltstack/salt | salt/utils/cloud.py | Client.remove_service | def remove_service(self, wait_timeout=10, sleep_wait=1):
'''
Removes the PAExec service and executable that was created as part of
the create_service function. This does not remove any older executables
or services from previous runs, use cleanup() instead for that purpose.
'''
... | python | def remove_service(self, wait_timeout=10, sleep_wait=1):
'''
Removes the PAExec service and executable that was created as part of
the create_service function. This does not remove any older executables
or services from previous runs, use cleanup() instead for that purpose.
'''
... | [
"def",
"remove_service",
"(",
"self",
",",
"wait_timeout",
"=",
"10",
",",
"sleep_wait",
"=",
"1",
")",
":",
"# Stops/remove the PAExec service and removes the executable",
"log",
".",
"debug",
"(",
"\"Deleting PAExec service at the end of the process\"",
")",
"wait_start",... | Removes the PAExec service and executable that was created as part of
the create_service function. This does not remove any older executables
or services from previous runs, use cleanup() instead for that purpose. | [
"Removes",
"the",
"PAExec",
"service",
"and",
"executable",
"that",
"was",
"created",
"as",
"part",
"of",
"the",
"create_service",
"function",
".",
"This",
"does",
"not",
"remove",
"any",
"older",
"executables",
"or",
"services",
"from",
"previous",
"runs",
"u... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/cloud.py#L893-L935 | train |
saltstack/salt | salt/crypt.py | dropfile | def dropfile(cachedir, user=None):
'''
Set an AES dropfile to request the master update the publish session key
'''
dfn = os.path.join(cachedir, '.dfn')
# set a mask (to avoid a race condition on file creation) and store original.
with salt.utils.files.set_umask(0o277):
log.info('Rotatin... | python | def dropfile(cachedir, user=None):
'''
Set an AES dropfile to request the master update the publish session key
'''
dfn = os.path.join(cachedir, '.dfn')
# set a mask (to avoid a race condition on file creation) and store original.
with salt.utils.files.set_umask(0o277):
log.info('Rotatin... | [
"def",
"dropfile",
"(",
"cachedir",
",",
"user",
"=",
"None",
")",
":",
"dfn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cachedir",
",",
"'.dfn'",
")",
"# set a mask (to avoid a race condition on file creation) and store original.",
"with",
"salt",
".",
"utils",
... | Set an AES dropfile to request the master update the publish session key | [
"Set",
"an",
"AES",
"dropfile",
"to",
"request",
"the",
"master",
"update",
"the",
"publish",
"session",
"key"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L82-L105 | train |
saltstack/salt | salt/crypt.py | gen_keys | def gen_keys(keydir, keyname, keysize, user=None, passphrase=None):
'''
Generate a RSA public keypair for use with salt
:param str keydir: The directory to write the keypair to
:param str keyname: The type of salt server for whom this key should be written. (i.e. 'master' or 'minion')
:param int ke... | python | def gen_keys(keydir, keyname, keysize, user=None, passphrase=None):
'''
Generate a RSA public keypair for use with salt
:param str keydir: The directory to write the keypair to
:param str keyname: The type of salt server for whom this key should be written. (i.e. 'master' or 'minion')
:param int ke... | [
"def",
"gen_keys",
"(",
"keydir",
",",
"keyname",
",",
"keysize",
",",
"user",
"=",
"None",
",",
"passphrase",
"=",
"None",
")",
":",
"base",
"=",
"os",
".",
"path",
".",
"join",
"(",
"keydir",
",",
"keyname",
")",
"priv",
"=",
"'{0}.pem'",
".",
"f... | Generate a RSA public keypair for use with salt
:param str keydir: The directory to write the keypair to
:param str keyname: The type of salt server for whom this key should be written. (i.e. 'master' or 'minion')
:param int keysize: The number of bits in the key
:param str user: The user on the system... | [
"Generate",
"a",
"RSA",
"public",
"keypair",
"for",
"use",
"with",
"salt"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L108-L168 | train |
saltstack/salt | salt/crypt.py | _get_key_with_evict | def _get_key_with_evict(path, timestamp, passphrase):
'''
Load a private key from disk. `timestamp` above is intended to be the
timestamp of the file's last modification. This fn is memoized so if it is
called with the same path and timestamp (the file's last modified time) the
second time the resu... | python | def _get_key_with_evict(path, timestamp, passphrase):
'''
Load a private key from disk. `timestamp` above is intended to be the
timestamp of the file's last modification. This fn is memoized so if it is
called with the same path and timestamp (the file's last modified time) the
second time the resu... | [
"def",
"_get_key_with_evict",
"(",
"path",
",",
"timestamp",
",",
"passphrase",
")",
":",
"log",
".",
"debug",
"(",
"'salt.crypt._get_key_with_evict: Loading private key'",
")",
"if",
"HAS_M2",
":",
"key",
"=",
"RSA",
".",
"load_key",
"(",
"path",
",",
"lambda",... | Load a private key from disk. `timestamp` above is intended to be the
timestamp of the file's last modification. This fn is memoized so if it is
called with the same path and timestamp (the file's last modified time) the
second time the result is returned from the memoiziation. If the file gets
modifi... | [
"Load",
"a",
"private",
"key",
"from",
"disk",
".",
"timestamp",
"above",
"is",
"intended",
"to",
"be",
"the",
"timestamp",
"of",
"the",
"file",
"s",
"last",
"modification",
".",
"This",
"fn",
"is",
"memoized",
"so",
"if",
"it",
"is",
"called",
"with",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L172-L186 | train |
saltstack/salt | salt/crypt.py | get_rsa_key | def get_rsa_key(path, passphrase):
'''
Read a private key off the disk. Poor man's simple cache in effect here,
we memoize the result of calling _get_rsa_with_evict. This means the first
time _get_key_with_evict is called with a path and a timestamp the result
is cached. If the file (the private ... | python | def get_rsa_key(path, passphrase):
'''
Read a private key off the disk. Poor man's simple cache in effect here,
we memoize the result of calling _get_rsa_with_evict. This means the first
time _get_key_with_evict is called with a path and a timestamp the result
is cached. If the file (the private ... | [
"def",
"get_rsa_key",
"(",
"path",
",",
"passphrase",
")",
":",
"log",
".",
"debug",
"(",
"'salt.crypt.get_rsa_key: Loading private key'",
")",
"return",
"_get_key_with_evict",
"(",
"path",
",",
"six",
".",
"text_type",
"(",
"os",
".",
"path",
".",
"getmtime",
... | Read a private key off the disk. Poor man's simple cache in effect here,
we memoize the result of calling _get_rsa_with_evict. This means the first
time _get_key_with_evict is called with a path and a timestamp the result
is cached. If the file (the private key) does not change then its
timestamp wil... | [
"Read",
"a",
"private",
"key",
"off",
"the",
"disk",
".",
"Poor",
"man",
"s",
"simple",
"cache",
"in",
"effect",
"here",
"we",
"memoize",
"the",
"result",
"of",
"calling",
"_get_rsa_with_evict",
".",
"This",
"means",
"the",
"first",
"time",
"_get_key_with_ev... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L189-L201 | train |
saltstack/salt | salt/crypt.py | get_rsa_pub_key | def get_rsa_pub_key(path):
'''
Read a public key off the disk.
'''
log.debug('salt.crypt.get_rsa_pub_key: Loading public key')
if HAS_M2:
with salt.utils.files.fopen(path, 'rb') as f:
data = f.read().replace(b'RSA ', b'')
bio = BIO.MemoryBuffer(data)
key = RSA.loa... | python | def get_rsa_pub_key(path):
'''
Read a public key off the disk.
'''
log.debug('salt.crypt.get_rsa_pub_key: Loading public key')
if HAS_M2:
with salt.utils.files.fopen(path, 'rb') as f:
data = f.read().replace(b'RSA ', b'')
bio = BIO.MemoryBuffer(data)
key = RSA.loa... | [
"def",
"get_rsa_pub_key",
"(",
"path",
")",
":",
"log",
".",
"debug",
"(",
"'salt.crypt.get_rsa_pub_key: Loading public key'",
")",
"if",
"HAS_M2",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"path",
",",
"'rb'",
")",
"as",
"f",
":"... | Read a public key off the disk. | [
"Read",
"a",
"public",
"key",
"off",
"the",
"disk",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L204-L217 | train |
saltstack/salt | salt/crypt.py | sign_message | def sign_message(privkey_path, message, passphrase=None):
'''
Use Crypto.Signature.PKCS1_v1_5 to sign a message. Returns the signature.
'''
key = get_rsa_key(privkey_path, passphrase)
log.debug('salt.crypt.sign_message: Signing message.')
if HAS_M2:
md = EVP.MessageDigest('sha1')
... | python | def sign_message(privkey_path, message, passphrase=None):
'''
Use Crypto.Signature.PKCS1_v1_5 to sign a message. Returns the signature.
'''
key = get_rsa_key(privkey_path, passphrase)
log.debug('salt.crypt.sign_message: Signing message.')
if HAS_M2:
md = EVP.MessageDigest('sha1')
... | [
"def",
"sign_message",
"(",
"privkey_path",
",",
"message",
",",
"passphrase",
"=",
"None",
")",
":",
"key",
"=",
"get_rsa_key",
"(",
"privkey_path",
",",
"passphrase",
")",
"log",
".",
"debug",
"(",
"'salt.crypt.sign_message: Signing message.'",
")",
"if",
"HAS... | Use Crypto.Signature.PKCS1_v1_5 to sign a message. Returns the signature. | [
"Use",
"Crypto",
".",
"Signature",
".",
"PKCS1_v1_5",
"to",
"sign",
"a",
"message",
".",
"Returns",
"the",
"signature",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L220-L233 | train |
saltstack/salt | salt/crypt.py | verify_signature | def verify_signature(pubkey_path, message, signature):
'''
Use Crypto.Signature.PKCS1_v1_5 to verify the signature on a message.
Returns True for valid signature.
'''
log.debug('salt.crypt.verify_signature: Loading public key')
pubkey = get_rsa_pub_key(pubkey_path)
log.debug('salt.crypt.veri... | python | def verify_signature(pubkey_path, message, signature):
'''
Use Crypto.Signature.PKCS1_v1_5 to verify the signature on a message.
Returns True for valid signature.
'''
log.debug('salt.crypt.verify_signature: Loading public key')
pubkey = get_rsa_pub_key(pubkey_path)
log.debug('salt.crypt.veri... | [
"def",
"verify_signature",
"(",
"pubkey_path",
",",
"message",
",",
"signature",
")",
":",
"log",
".",
"debug",
"(",
"'salt.crypt.verify_signature: Loading public key'",
")",
"pubkey",
"=",
"get_rsa_pub_key",
"(",
"pubkey_path",
")",
"log",
".",
"debug",
"(",
"'sa... | Use Crypto.Signature.PKCS1_v1_5 to verify the signature on a message.
Returns True for valid signature. | [
"Use",
"Crypto",
".",
"Signature",
".",
"PKCS1_v1_5",
"to",
"verify",
"the",
"signature",
"on",
"a",
"message",
".",
"Returns",
"True",
"for",
"valid",
"signature",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L236-L251 | train |
saltstack/salt | salt/crypt.py | gen_signature | def gen_signature(priv_path, pub_path, sign_path, passphrase=None):
'''
creates a signature for the given public-key with
the given private key and writes it to sign_path
'''
with salt.utils.files.fopen(pub_path) as fp_:
mpub_64 = fp_.read()
mpub_sig = sign_message(priv_path, mpub_64, ... | python | def gen_signature(priv_path, pub_path, sign_path, passphrase=None):
'''
creates a signature for the given public-key with
the given private key and writes it to sign_path
'''
with salt.utils.files.fopen(pub_path) as fp_:
mpub_64 = fp_.read()
mpub_sig = sign_message(priv_path, mpub_64, ... | [
"def",
"gen_signature",
"(",
"priv_path",
",",
"pub_path",
",",
"sign_path",
",",
"passphrase",
"=",
"None",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"pub_path",
")",
"as",
"fp_",
":",
"mpub_64",
"=",
"fp_",
".",
"read",... | creates a signature for the given public-key with
the given private key and writes it to sign_path | [
"creates",
"a",
"signature",
"for",
"the",
"given",
"public",
"-",
"key",
"with",
"the",
"given",
"private",
"key",
"and",
"writes",
"it",
"to",
"sign_path"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L254-L281 | train |
saltstack/salt | salt/crypt.py | private_encrypt | def private_encrypt(key, message):
'''
Generate an M2Crypto-compatible signature
:param Crypto.PublicKey.RSA._RSAobj key: The RSA key object
:param str message: The message to sign
:rtype: str
:return: The signature, or an empty string if the signature operation failed
'''
if HAS_M2:
... | python | def private_encrypt(key, message):
'''
Generate an M2Crypto-compatible signature
:param Crypto.PublicKey.RSA._RSAobj key: The RSA key object
:param str message: The message to sign
:rtype: str
:return: The signature, or an empty string if the signature operation failed
'''
if HAS_M2:
... | [
"def",
"private_encrypt",
"(",
"key",
",",
"message",
")",
":",
"if",
"HAS_M2",
":",
"return",
"key",
".",
"private_encrypt",
"(",
"message",
",",
"salt",
".",
"utils",
".",
"rsax931",
".",
"RSA_X931_PADDING",
")",
"else",
":",
"signer",
"=",
"salt",
"."... | Generate an M2Crypto-compatible signature
:param Crypto.PublicKey.RSA._RSAobj key: The RSA key object
:param str message: The message to sign
:rtype: str
:return: The signature, or an empty string if the signature operation failed | [
"Generate",
"an",
"M2Crypto",
"-",
"compatible",
"signature"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L284-L297 | train |
saltstack/salt | salt/crypt.py | public_decrypt | def public_decrypt(pub, message):
'''
Verify an M2Crypto-compatible signature
:param Crypto.PublicKey.RSA._RSAobj key: The RSA public key object
:param str message: The signed message to verify
:rtype: str
:return: The message (or digest) recovered from the signature, or an
empty string... | python | def public_decrypt(pub, message):
'''
Verify an M2Crypto-compatible signature
:param Crypto.PublicKey.RSA._RSAobj key: The RSA public key object
:param str message: The signed message to verify
:rtype: str
:return: The message (or digest) recovered from the signature, or an
empty string... | [
"def",
"public_decrypt",
"(",
"pub",
",",
"message",
")",
":",
"if",
"HAS_M2",
":",
"return",
"pub",
".",
"public_decrypt",
"(",
"message",
",",
"salt",
".",
"utils",
".",
"rsax931",
".",
"RSA_X931_PADDING",
")",
"else",
":",
"verifier",
"=",
"salt",
"."... | Verify an M2Crypto-compatible signature
:param Crypto.PublicKey.RSA._RSAobj key: The RSA public key object
:param str message: The signed message to verify
:rtype: str
:return: The message (or digest) recovered from the signature, or an
empty string if the verification failed | [
"Verify",
"an",
"M2Crypto",
"-",
"compatible",
"signature"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L300-L314 | train |
saltstack/salt | salt/crypt.py | MasterKeys.__get_keys | def __get_keys(self, name='master', passphrase=None):
'''
Returns a key object for a key in the pki-dir
'''
path = os.path.join(self.opts['pki_dir'],
name + '.pem')
if not os.path.exists(path):
log.info('Generating %s keys: %s', name, self.... | python | def __get_keys(self, name='master', passphrase=None):
'''
Returns a key object for a key in the pki-dir
'''
path = os.path.join(self.opts['pki_dir'],
name + '.pem')
if not os.path.exists(path):
log.info('Generating %s keys: %s', name, self.... | [
"def",
"__get_keys",
"(",
"self",
",",
"name",
"=",
"'master'",
",",
"passphrase",
"=",
"None",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opts",
"[",
"'pki_dir'",
"]",
",",
"name",
"+",
"'.pem'",
")",
"if",
"not",
... | Returns a key object for a key in the pki-dir | [
"Returns",
"a",
"key",
"object",
"for",
"a",
"key",
"in",
"the",
"pki",
"-",
"dir"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L383-L407 | train |
saltstack/salt | salt/crypt.py | MasterKeys.get_pub_str | def get_pub_str(self, name='master'):
'''
Return the string representation of a public key
in the pki-directory
'''
path = os.path.join(self.opts['pki_dir'],
name + '.pub')
if not os.path.isfile(path):
key = self.__get_keys()
... | python | def get_pub_str(self, name='master'):
'''
Return the string representation of a public key
in the pki-directory
'''
path = os.path.join(self.opts['pki_dir'],
name + '.pub')
if not os.path.isfile(path):
key = self.__get_keys()
... | [
"def",
"get_pub_str",
"(",
"self",
",",
"name",
"=",
"'master'",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opts",
"[",
"'pki_dir'",
"]",
",",
"name",
"+",
"'.pub'",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile... | Return the string representation of a public key
in the pki-directory | [
"Return",
"the",
"string",
"representation",
"of",
"a",
"public",
"key",
"in",
"the",
"pki",
"-",
"directory"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L409-L424 | train |
saltstack/salt | salt/crypt.py | AsyncAuth.authenticate | def authenticate(self, callback=None):
'''
Ask for this client to reconnect to the origin
This function will de-dupe all calls here and return a *single* future
for the sign-in-- whis way callers can all assume there aren't others
'''
# if an auth is in flight-- and not ... | python | def authenticate(self, callback=None):
'''
Ask for this client to reconnect to the origin
This function will de-dupe all calls here and return a *single* future
for the sign-in-- whis way callers can all assume there aren't others
'''
# if an auth is in flight-- and not ... | [
"def",
"authenticate",
"(",
"self",
",",
"callback",
"=",
"None",
")",
":",
"# if an auth is in flight-- and not done-- just pass that back as the future to wait on",
"if",
"hasattr",
"(",
"self",
",",
"'_authenticate_future'",
")",
"and",
"not",
"self",
".",
"_authentica... | Ask for this client to reconnect to the origin
This function will de-dupe all calls here and return a *single* future
for the sign-in-- whis way callers can all assume there aren't others | [
"Ask",
"for",
"this",
"client",
"to",
"reconnect",
"to",
"the",
"origin"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L558-L579 | train |
saltstack/salt | salt/crypt.py | AsyncAuth._authenticate | def _authenticate(self):
'''
Authenticate with the master, this method breaks the functional
paradigm, it will update the master information from a fresh sign
in, signing in can occur as often as needed to keep up with the
revolving master AES key.
:rtype: Crypticle
... | python | def _authenticate(self):
'''
Authenticate with the master, this method breaks the functional
paradigm, it will update the master information from a fresh sign
in, signing in can occur as often as needed to keep up with the
revolving master AES key.
:rtype: Crypticle
... | [
"def",
"_authenticate",
"(",
"self",
")",
":",
"acceptance_wait_time",
"=",
"self",
".",
"opts",
"[",
"'acceptance_wait_time'",
"]",
"acceptance_wait_time_max",
"=",
"self",
".",
"opts",
"[",
"'acceptance_wait_time_max'",
"]",
"if",
"not",
"acceptance_wait_time_max",
... | Authenticate with the master, this method breaks the functional
paradigm, it will update the master information from a fresh sign
in, signing in can occur as often as needed to keep up with the
revolving master AES key.
:rtype: Crypticle
:returns: A crypticle used for encryption... | [
"Authenticate",
"with",
"the",
"master",
"this",
"method",
"breaks",
"the",
"functional",
"paradigm",
"it",
"will",
"update",
"the",
"master",
"information",
"from",
"a",
"fresh",
"sign",
"in",
"signing",
"in",
"can",
"occur",
"as",
"often",
"as",
"needed",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L582-L661 | train |
saltstack/salt | salt/crypt.py | AsyncAuth.sign_in | def sign_in(self, timeout=60, safe=True, tries=1, channel=None):
'''
Send a sign in request to the master, sets the key information and
returns a dict containing the master publish interface to bind to
and the decrypted aes key for transport decryption.
:param int timeout: Numbe... | python | def sign_in(self, timeout=60, safe=True, tries=1, channel=None):
'''
Send a sign in request to the master, sets the key information and
returns a dict containing the master publish interface to bind to
and the decrypted aes key for transport decryption.
:param int timeout: Numbe... | [
"def",
"sign_in",
"(",
"self",
",",
"timeout",
"=",
"60",
",",
"safe",
"=",
"True",
",",
"tries",
"=",
"1",
",",
"channel",
"=",
"None",
")",
":",
"auth",
"=",
"{",
"}",
"auth_timeout",
"=",
"self",
".",
"opts",
".",
"get",
"(",
"'auth_timeout'",
... | Send a sign in request to the master, sets the key information and
returns a dict containing the master publish interface to bind to
and the decrypted aes key for transport decryption.
:param int timeout: Number of seconds to wait before timing out the sign-in request
:param bool safe: ... | [
"Send",
"a",
"sign",
"in",
"request",
"to",
"the",
"master",
"sets",
"the",
"key",
"information",
"and",
"returns",
"a",
"dict",
"containing",
"the",
"master",
"publish",
"interface",
"to",
"bind",
"to",
"and",
"the",
"decrypted",
"aes",
"key",
"for",
"tra... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L664-L782 | train |
saltstack/salt | salt/crypt.py | AsyncAuth.get_keys | def get_keys(self):
'''
Return keypair object for the minion.
:rtype: Crypto.PublicKey.RSA._RSAobj
:return: The RSA keypair
'''
# Make sure all key parent directories are accessible
user = self.opts.get('user', 'root')
salt.utils.verify.check_path_travers... | python | def get_keys(self):
'''
Return keypair object for the minion.
:rtype: Crypto.PublicKey.RSA._RSAobj
:return: The RSA keypair
'''
# Make sure all key parent directories are accessible
user = self.opts.get('user', 'root')
salt.utils.verify.check_path_travers... | [
"def",
"get_keys",
"(",
"self",
")",
":",
"# Make sure all key parent directories are accessible",
"user",
"=",
"self",
".",
"opts",
".",
"get",
"(",
"'user'",
",",
"'root'",
")",
"salt",
".",
"utils",
".",
"verify",
".",
"check_path_traversal",
"(",
"self",
"... | Return keypair object for the minion.
:rtype: Crypto.PublicKey.RSA._RSAobj
:return: The RSA keypair | [
"Return",
"keypair",
"object",
"for",
"the",
"minion",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L784-L803 | train |
saltstack/salt | salt/crypt.py | AsyncAuth.minion_sign_in_payload | def minion_sign_in_payload(self):
'''
Generates the payload used to authenticate with the master
server. This payload consists of the passed in id_ and the ssh
public key to encrypt the AES key sent back from the master.
:return: Payload dictionary
:rtype: dict
'... | python | def minion_sign_in_payload(self):
'''
Generates the payload used to authenticate with the master
server. This payload consists of the passed in id_ and the ssh
public key to encrypt the AES key sent back from the master.
:return: Payload dictionary
:rtype: dict
'... | [
"def",
"minion_sign_in_payload",
"(",
"self",
")",
":",
"payload",
"=",
"{",
"}",
"payload",
"[",
"'cmd'",
"]",
"=",
"'_auth'",
"payload",
"[",
"'id'",
"]",
"=",
"self",
".",
"opts",
"[",
"'id'",
"]",
"if",
"'autosign_grains'",
"in",
"self",
".",
"opts... | Generates the payload used to authenticate with the master
server. This payload consists of the passed in id_ and the ssh
public key to encrypt the AES key sent back from the master.
:return: Payload dictionary
:rtype: dict | [
"Generates",
"the",
"payload",
"used",
"to",
"authenticate",
"with",
"the",
"master",
"server",
".",
"This",
"payload",
"consists",
"of",
"the",
"passed",
"in",
"id_",
"and",
"the",
"ssh",
"public",
"key",
"to",
"encrypt",
"the",
"AES",
"key",
"sent",
"bac... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L816-L845 | train |
saltstack/salt | salt/crypt.py | AsyncAuth.decrypt_aes | def decrypt_aes(self, payload, master_pub=True):
'''
This function is used to decrypt the AES seed phrase returned from
the master server. The seed phrase is decrypted with the SSH RSA
host key.
Pass in the encrypted AES key.
Returns the decrypted AES seed key, a string
... | python | def decrypt_aes(self, payload, master_pub=True):
'''
This function is used to decrypt the AES seed phrase returned from
the master server. The seed phrase is decrypted with the SSH RSA
host key.
Pass in the encrypted AES key.
Returns the decrypted AES seed key, a string
... | [
"def",
"decrypt_aes",
"(",
"self",
",",
"payload",
",",
"master_pub",
"=",
"True",
")",
":",
"if",
"self",
".",
"opts",
".",
"get",
"(",
"'auth_trb'",
",",
"False",
")",
":",
"log",
".",
"warning",
"(",
"'Auth Called: %s'",
",",
"''",
".",
"join",
"(... | This function is used to decrypt the AES seed phrase returned from
the master server. The seed phrase is decrypted with the SSH RSA
host key.
Pass in the encrypted AES key.
Returns the decrypted AES seed key, a string
:param dict payload: The incoming payload. This is a diction... | [
"This",
"function",
"is",
"used",
"to",
"decrypt",
"the",
"AES",
"seed",
"phrase",
"returned",
"from",
"the",
"master",
"server",
".",
"The",
"seed",
"phrase",
"is",
"decrypted",
"with",
"the",
"SSH",
"RSA",
"host",
"key",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L847-L915 | train |
saltstack/salt | salt/crypt.py | AsyncAuth.verify_pubkey_sig | def verify_pubkey_sig(self, message, sig):
'''
Wraps the verify_signature method so we have
additional checks.
:rtype: bool
:return: Success or failure of public key verification
'''
if self.opts['master_sign_key_name']:
path = os.path.join(self.opts[... | python | def verify_pubkey_sig(self, message, sig):
'''
Wraps the verify_signature method so we have
additional checks.
:rtype: bool
:return: Success or failure of public key verification
'''
if self.opts['master_sign_key_name']:
path = os.path.join(self.opts[... | [
"def",
"verify_pubkey_sig",
"(",
"self",
",",
"message",
",",
"sig",
")",
":",
"if",
"self",
".",
"opts",
"[",
"'master_sign_key_name'",
"]",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opts",
"[",
"'pki_dir'",
"]",
",",
"sel... | Wraps the verify_signature method so we have
additional checks.
:rtype: bool
:return: Success or failure of public key verification | [
"Wraps",
"the",
"verify_signature",
"method",
"so",
"we",
"have",
"additional",
"checks",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L917-L956 | train |
saltstack/salt | salt/crypt.py | AsyncAuth.check_auth_deps | def check_auth_deps(self, payload):
'''
Checks if both master and minion either sign (master) and
verify (minion). If one side does not, it should fail.
:param dict payload: The incoming payload. This is a dictionary which may have the following keys:
'aes': The shared AES k... | python | def check_auth_deps(self, payload):
'''
Checks if both master and minion either sign (master) and
verify (minion). If one side does not, it should fail.
:param dict payload: The incoming payload. This is a dictionary which may have the following keys:
'aes': The shared AES k... | [
"def",
"check_auth_deps",
"(",
"self",
",",
"payload",
")",
":",
"# master and minion sign and verify",
"if",
"'pub_sig'",
"in",
"payload",
"and",
"self",
".",
"opts",
"[",
"'verify_master_pubkey_sign'",
"]",
":",
"return",
"True",
"# master and minion do NOT sign and d... | Checks if both master and minion either sign (master) and
verify (minion). If one side does not, it should fail.
:param dict payload: The incoming payload. This is a dictionary which may have the following keys:
'aes': The shared AES key
'enc': The format of the message. ('clear... | [
"Checks",
"if",
"both",
"master",
"and",
"minion",
"either",
"sign",
"(",
"master",
")",
"and",
"verify",
"(",
"minion",
")",
".",
"If",
"one",
"side",
"does",
"not",
"it",
"should",
"fail",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L984-L1016 | train |
saltstack/salt | salt/crypt.py | AsyncAuth.extract_aes | def extract_aes(self, payload, master_pub=True):
'''
Return the AES key received from the master after the minion has been
successfully authenticated.
:param dict payload: The incoming payload. This is a dictionary which may have the following keys:
'aes': The shared AES key... | python | def extract_aes(self, payload, master_pub=True):
'''
Return the AES key received from the master after the minion has been
successfully authenticated.
:param dict payload: The incoming payload. This is a dictionary which may have the following keys:
'aes': The shared AES key... | [
"def",
"extract_aes",
"(",
"self",
",",
"payload",
",",
"master_pub",
"=",
"True",
")",
":",
"if",
"master_pub",
":",
"try",
":",
"aes",
",",
"token",
"=",
"self",
".",
"decrypt_aes",
"(",
"payload",
",",
"master_pub",
")",
"if",
"token",
"!=",
"self",... | Return the AES key received from the master after the minion has been
successfully authenticated.
:param dict payload: The incoming payload. This is a dictionary which may have the following keys:
'aes': The shared AES key
'enc': The format of the message. ('clear', 'pub', etc)
... | [
"Return",
"the",
"AES",
"key",
"received",
"from",
"the",
"master",
"after",
"the",
"minion",
"has",
"been",
"successfully",
"authenticated",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1018-L1049 | train |
saltstack/salt | salt/crypt.py | AsyncAuth.verify_master | def verify_master(self, payload, master_pub=True):
'''
Verify that the master is the same one that was previously accepted.
:param dict payload: The incoming payload. This is a dictionary which may have the following keys:
'aes': The shared AES key
'enc': The format of t... | python | def verify_master(self, payload, master_pub=True):
'''
Verify that the master is the same one that was previously accepted.
:param dict payload: The incoming payload. This is a dictionary which may have the following keys:
'aes': The shared AES key
'enc': The format of t... | [
"def",
"verify_master",
"(",
"self",
",",
"payload",
",",
"master_pub",
"=",
"True",
")",
":",
"m_pub_fn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"opts",
"[",
"'pki_dir'",
"]",
",",
"self",
".",
"mpub",
")",
"m_pub_exists",
"=",
"os",... | Verify that the master is the same one that was previously accepted.
:param dict payload: The incoming payload. This is a dictionary which may have the following keys:
'aes': The shared AES key
'enc': The format of the message. ('clear', 'pub', etc)
'publish_port': The TCP p... | [
"Verify",
"that",
"the",
"master",
"is",
"the",
"same",
"one",
"that",
"was",
"previously",
"accepted",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1051-L1127 | train |
saltstack/salt | salt/crypt.py | SAuth.authenticate | def authenticate(self, _=None): # TODO: remove unused var
'''
Authenticate with the master, this method breaks the functional
paradigm, it will update the master information from a fresh sign
in, signing in can occur as often as needed to keep up with the
revolving master AES ke... | python | def authenticate(self, _=None): # TODO: remove unused var
'''
Authenticate with the master, this method breaks the functional
paradigm, it will update the master information from a fresh sign
in, signing in can occur as often as needed to keep up with the
revolving master AES ke... | [
"def",
"authenticate",
"(",
"self",
",",
"_",
"=",
"None",
")",
":",
"# TODO: remove unused var",
"acceptance_wait_time",
"=",
"self",
".",
"opts",
"[",
"'acceptance_wait_time'",
"]",
"acceptance_wait_time_max",
"=",
"self",
".",
"opts",
"[",
"'acceptance_wait_time_... | Authenticate with the master, this method breaks the functional
paradigm, it will update the master information from a fresh sign
in, signing in can occur as often as needed to keep up with the
revolving master AES key.
:rtype: Crypticle
:returns: A crypticle used for encryption... | [
"Authenticate",
"with",
"the",
"master",
"this",
"method",
"breaks",
"the",
"functional",
"paradigm",
"it",
"will",
"update",
"the",
"master",
"information",
"from",
"a",
"fresh",
"sign",
"in",
"signing",
"in",
"can",
"occur",
"as",
"often",
"as",
"needed",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1214-L1256 | train |
saltstack/salt | salt/crypt.py | Crypticle.encrypt | def encrypt(self, data):
'''
encrypt data with AES-CBC and sign it with HMAC-SHA256
'''
aes_key, hmac_key = self.keys
pad = self.AES_BLOCK_SIZE - len(data) % self.AES_BLOCK_SIZE
if six.PY2:
data = data + pad * chr(pad)
else:
data = data + s... | python | def encrypt(self, data):
'''
encrypt data with AES-CBC and sign it with HMAC-SHA256
'''
aes_key, hmac_key = self.keys
pad = self.AES_BLOCK_SIZE - len(data) % self.AES_BLOCK_SIZE
if six.PY2:
data = data + pad * chr(pad)
else:
data = data + s... | [
"def",
"encrypt",
"(",
"self",
",",
"data",
")",
":",
"aes_key",
",",
"hmac_key",
"=",
"self",
".",
"keys",
"pad",
"=",
"self",
".",
"AES_BLOCK_SIZE",
"-",
"len",
"(",
"data",
")",
"%",
"self",
".",
"AES_BLOCK_SIZE",
"if",
"six",
".",
"PY2",
":",
"... | encrypt data with AES-CBC and sign it with HMAC-SHA256 | [
"encrypt",
"data",
"with",
"AES",
"-",
"CBC",
"and",
"sign",
"it",
"with",
"HMAC",
"-",
"SHA256"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1406-L1426 | train |
saltstack/salt | salt/crypt.py | Crypticle.decrypt | def decrypt(self, data):
'''
verify HMAC-SHA256 signature and decrypt data with AES-CBC
'''
aes_key, hmac_key = self.keys
sig = data[-self.SIG_SIZE:]
data = data[:-self.SIG_SIZE]
if six.PY3 and not isinstance(data, bytes):
data = salt.utils.stringutils... | python | def decrypt(self, data):
'''
verify HMAC-SHA256 signature and decrypt data with AES-CBC
'''
aes_key, hmac_key = self.keys
sig = data[-self.SIG_SIZE:]
data = data[:-self.SIG_SIZE]
if six.PY3 and not isinstance(data, bytes):
data = salt.utils.stringutils... | [
"def",
"decrypt",
"(",
"self",
",",
"data",
")",
":",
"aes_key",
",",
"hmac_key",
"=",
"self",
".",
"keys",
"sig",
"=",
"data",
"[",
"-",
"self",
".",
"SIG_SIZE",
":",
"]",
"data",
"=",
"data",
"[",
":",
"-",
"self",
".",
"SIG_SIZE",
"]",
"if",
... | verify HMAC-SHA256 signature and decrypt data with AES-CBC | [
"verify",
"HMAC",
"-",
"SHA256",
"signature",
"and",
"decrypt",
"data",
"with",
"AES",
"-",
"CBC"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1428-L1464 | train |
saltstack/salt | salt/crypt.py | Crypticle.dumps | def dumps(self, obj):
'''
Serialize and encrypt a python object
'''
return self.encrypt(self.PICKLE_PAD + self.serial.dumps(obj)) | python | def dumps(self, obj):
'''
Serialize and encrypt a python object
'''
return self.encrypt(self.PICKLE_PAD + self.serial.dumps(obj)) | [
"def",
"dumps",
"(",
"self",
",",
"obj",
")",
":",
"return",
"self",
".",
"encrypt",
"(",
"self",
".",
"PICKLE_PAD",
"+",
"self",
".",
"serial",
".",
"dumps",
"(",
"obj",
")",
")"
] | Serialize and encrypt a python object | [
"Serialize",
"and",
"encrypt",
"a",
"python",
"object"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1466-L1470 | train |
saltstack/salt | salt/crypt.py | Crypticle.loads | def loads(self, data, raw=False):
'''
Decrypt and un-serialize a python object
'''
data = self.decrypt(data)
# simple integrity check to verify that we got meaningful data
if not data.startswith(self.PICKLE_PAD):
return {}
load = self.serial.loads(data... | python | def loads(self, data, raw=False):
'''
Decrypt and un-serialize a python object
'''
data = self.decrypt(data)
# simple integrity check to verify that we got meaningful data
if not data.startswith(self.PICKLE_PAD):
return {}
load = self.serial.loads(data... | [
"def",
"loads",
"(",
"self",
",",
"data",
",",
"raw",
"=",
"False",
")",
":",
"data",
"=",
"self",
".",
"decrypt",
"(",
"data",
")",
"# simple integrity check to verify that we got meaningful data",
"if",
"not",
"data",
".",
"startswith",
"(",
"self",
".",
"... | Decrypt and un-serialize a python object | [
"Decrypt",
"and",
"un",
"-",
"serialize",
"a",
"python",
"object"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/crypt.py#L1472-L1481 | train |
saltstack/salt | salt/pillar/hiera.py | ext_pillar | def ext_pillar(minion_id, # pylint: disable=W0613
pillar, # pylint: disable=W0613
conf):
'''
Execute hiera and return the data
'''
cmd = 'hiera -c {0}'.format(conf)
for key, val in six.iteritems(__grains__):
if isinstance(val, six.string_types):
cm... | python | def ext_pillar(minion_id, # pylint: disable=W0613
pillar, # pylint: disable=W0613
conf):
'''
Execute hiera and return the data
'''
cmd = 'hiera -c {0}'.format(conf)
for key, val in six.iteritems(__grains__):
if isinstance(val, six.string_types):
cm... | [
"def",
"ext_pillar",
"(",
"minion_id",
",",
"# pylint: disable=W0613",
"pillar",
",",
"# pylint: disable=W0613",
"conf",
")",
":",
"cmd",
"=",
"'hiera -c {0}'",
".",
"format",
"(",
"conf",
")",
"for",
"key",
",",
"val",
"in",
"six",
".",
"iteritems",
"(",
"_... | Execute hiera and return the data | [
"Execute",
"hiera",
"and",
"return",
"the",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/hiera.py#L29-L44 | train |
saltstack/salt | salt/modules/glusterfs.py | _gluster_output_cleanup | def _gluster_output_cleanup(result):
'''
Gluster versions prior to 6 have a bug that requires tricking
isatty. This adds "gluster> " to the output. Strip it off and
produce clean xml for ElementTree.
'''
ret = ''
for line in result.splitlines():
if line.startswith('gluster>'):
... | python | def _gluster_output_cleanup(result):
'''
Gluster versions prior to 6 have a bug that requires tricking
isatty. This adds "gluster> " to the output. Strip it off and
produce clean xml for ElementTree.
'''
ret = ''
for line in result.splitlines():
if line.startswith('gluster>'):
... | [
"def",
"_gluster_output_cleanup",
"(",
"result",
")",
":",
"ret",
"=",
"''",
"for",
"line",
"in",
"result",
".",
"splitlines",
"(",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"'gluster>'",
")",
":",
"ret",
"+=",
"line",
"[",
"9",
":",
"]",
".",
... | Gluster versions prior to 6 have a bug that requires tricking
isatty. This adds "gluster> " to the output. Strip it off and
produce clean xml for ElementTree. | [
"Gluster",
"versions",
"prior",
"to",
"6",
"have",
"a",
"bug",
"that",
"requires",
"tricking",
"isatty",
".",
"This",
"adds",
"gluster",
">",
"to",
"the",
"output",
".",
"Strip",
"it",
"off",
"and",
"produce",
"clean",
"xml",
"for",
"ElementTree",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L51-L66 | train |
saltstack/salt | salt/modules/glusterfs.py | _gluster_xml | def _gluster_xml(cmd):
'''
Perform a gluster --xml command and log result.
'''
# We will pass the command string as stdin to allow for much longer
# command strings. This is especially useful for creating large volumes
# where the list of bricks exceeds 128 characters.
if _get_version() < (3... | python | def _gluster_xml(cmd):
'''
Perform a gluster --xml command and log result.
'''
# We will pass the command string as stdin to allow for much longer
# command strings. This is especially useful for creating large volumes
# where the list of bricks exceeds 128 characters.
if _get_version() < (3... | [
"def",
"_gluster_xml",
"(",
"cmd",
")",
":",
"# We will pass the command string as stdin to allow for much longer",
"# command strings. This is especially useful for creating large volumes",
"# where the list of bricks exceeds 128 characters.",
"if",
"_get_version",
"(",
")",
"<",
"(",
... | Perform a gluster --xml command and log result. | [
"Perform",
"a",
"gluster",
"--",
"xml",
"command",
"and",
"log",
"result",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L69-L103 | train |
saltstack/salt | salt/modules/glusterfs.py | _iter | def _iter(root, term):
'''
Checks for python2.6 or python2.7
'''
if sys.version_info < (2, 7):
return root.getiterator(term)
else:
return root.iter(term) | python | def _iter(root, term):
'''
Checks for python2.6 or python2.7
'''
if sys.version_info < (2, 7):
return root.getiterator(term)
else:
return root.iter(term) | [
"def",
"_iter",
"(",
"root",
",",
"term",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"2",
",",
"7",
")",
":",
"return",
"root",
".",
"getiterator",
"(",
"term",
")",
"else",
":",
"return",
"root",
".",
"iter",
"(",
"term",
")"
] | Checks for python2.6 or python2.7 | [
"Checks",
"for",
"python2",
".",
"6",
"or",
"python2",
".",
"7"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L120-L127 | train |
saltstack/salt | salt/modules/glusterfs.py | peer_status | def peer_status():
'''
Return peer status information
The return value is a dictionary with peer UUIDs as keys and dicts of peer
information as values. Hostnames are listed in one list. GlusterFS separates
one of the hostnames but the only reason for this seems to be which hostname
happens to b... | python | def peer_status():
'''
Return peer status information
The return value is a dictionary with peer UUIDs as keys and dicts of peer
information as values. Hostnames are listed in one list. GlusterFS separates
one of the hostnames but the only reason for this seems to be which hostname
happens to b... | [
"def",
"peer_status",
"(",
")",
":",
"root",
"=",
"_gluster_xml",
"(",
"'peer status'",
")",
"if",
"not",
"_gluster_ok",
"(",
"root",
")",
":",
"return",
"None",
"result",
"=",
"{",
"}",
"for",
"peer",
"in",
"_iter",
"(",
"root",
",",
"'peer'",
")",
... | Return peer status information
The return value is a dictionary with peer UUIDs as keys and dicts of peer
information as values. Hostnames are listed in one list. GlusterFS separates
one of the hostnames but the only reason for this seems to be which hostname
happens to be used first in peering.
C... | [
"Return",
"peer",
"status",
"information"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L130-L181 | train |
saltstack/salt | salt/modules/glusterfs.py | peer | def peer(name):
'''
Add another node into the peer list.
name
The remote host to probe.
CLI Example:
.. code-block:: bash
salt 'one.gluster.*' glusterfs.peer two
GLUSTER direct CLI example (to show what salt is sending to gluster):
$ gluster peer probe ftp2
GLU... | python | def peer(name):
'''
Add another node into the peer list.
name
The remote host to probe.
CLI Example:
.. code-block:: bash
salt 'one.gluster.*' glusterfs.peer two
GLUSTER direct CLI example (to show what salt is sending to gluster):
$ gluster peer probe ftp2
GLU... | [
"def",
"peer",
"(",
"name",
")",
":",
"if",
"salt",
".",
"utils",
".",
"cloud",
".",
"check_name",
"(",
"name",
",",
"'a-zA-Z0-9._-'",
")",
":",
"raise",
"SaltInvocationError",
"(",
"'Invalid characters in peer name \"{0}\"'",
".",
"format",
"(",
"name",
")",
... | Add another node into the peer list.
name
The remote host to probe.
CLI Example:
.. code-block:: bash
salt 'one.gluster.*' glusterfs.peer two
GLUSTER direct CLI example (to show what salt is sending to gluster):
$ gluster peer probe ftp2
GLUSTER CLI 3.4.4 return exampl... | [
"Add",
"another",
"node",
"into",
"the",
"peer",
"list",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L184-L219 | train |
saltstack/salt | salt/modules/glusterfs.py | create_volume | def create_volume(name, bricks, stripe=False, replica=False, device_vg=False,
transport='tcp', start=False, force=False, arbiter=False):
'''
Create a glusterfs volume
name
Name of the gluster volume
bricks
Bricks to create volume from, in <peer>:<brick path> format. F... | python | def create_volume(name, bricks, stripe=False, replica=False, device_vg=False,
transport='tcp', start=False, force=False, arbiter=False):
'''
Create a glusterfs volume
name
Name of the gluster volume
bricks
Bricks to create volume from, in <peer>:<brick path> format. F... | [
"def",
"create_volume",
"(",
"name",
",",
"bricks",
",",
"stripe",
"=",
"False",
",",
"replica",
"=",
"False",
",",
"device_vg",
"=",
"False",
",",
"transport",
"=",
"'tcp'",
",",
"start",
"=",
"False",
",",
"force",
"=",
"False",
",",
"arbiter",
"=",
... | Create a glusterfs volume
name
Name of the gluster volume
bricks
Bricks to create volume from, in <peer>:<brick path> format. For \
multiple bricks use list format: '["<peer1>:<brick1>", \
"<peer2>:<brick2>"]'
stripe
Stripe count, the number of bricks should be a m... | [
"Create",
"a",
"glusterfs",
"volume"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L222-L320 | train |
saltstack/salt | salt/modules/glusterfs.py | list_volumes | def list_volumes():
'''
List configured volumes
CLI Example:
.. code-block:: bash
salt '*' glusterfs.list_volumes
'''
root = _gluster_xml('volume list')
if not _gluster_ok(root):
return None
results = [x.text for x in _iter(root, 'volume')]
return results | python | def list_volumes():
'''
List configured volumes
CLI Example:
.. code-block:: bash
salt '*' glusterfs.list_volumes
'''
root = _gluster_xml('volume list')
if not _gluster_ok(root):
return None
results = [x.text for x in _iter(root, 'volume')]
return results | [
"def",
"list_volumes",
"(",
")",
":",
"root",
"=",
"_gluster_xml",
"(",
"'volume list'",
")",
"if",
"not",
"_gluster_ok",
"(",
"root",
")",
":",
"return",
"None",
"results",
"=",
"[",
"x",
".",
"text",
"for",
"x",
"in",
"_iter",
"(",
"root",
",",
"'v... | List configured volumes
CLI Example:
.. code-block:: bash
salt '*' glusterfs.list_volumes | [
"List",
"configured",
"volumes"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L323-L338 | train |
saltstack/salt | salt/modules/glusterfs.py | status | def status(name):
'''
Check the status of a gluster volume.
name
Volume name
CLI Example:
.. code-block:: bash
salt '*' glusterfs.status myvolume
'''
# Get volume status
root = _gluster_xml('volume status {0}'.format(name))
if not _gluster_ok(root):
# Most... | python | def status(name):
'''
Check the status of a gluster volume.
name
Volume name
CLI Example:
.. code-block:: bash
salt '*' glusterfs.status myvolume
'''
# Get volume status
root = _gluster_xml('volume status {0}'.format(name))
if not _gluster_ok(root):
# Most... | [
"def",
"status",
"(",
"name",
")",
":",
"# Get volume status",
"root",
"=",
"_gluster_xml",
"(",
"'volume status {0}'",
".",
"format",
"(",
"name",
")",
")",
"if",
"not",
"_gluster_ok",
"(",
"root",
")",
":",
"# Most probably non-existing volume, the error output is... | Check the status of a gluster volume.
name
Volume name
CLI Example:
.. code-block:: bash
salt '*' glusterfs.status myvolume | [
"Check",
"the",
"status",
"of",
"a",
"gluster",
"volume",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L341-L392 | train |
saltstack/salt | salt/modules/glusterfs.py | info | def info(name=None):
'''
.. versionadded:: 2015.8.4
Return gluster volume info.
name
Optional name to retrieve only information of one volume
CLI Example:
.. code-block:: bash
salt '*' glusterfs.info
'''
cmd = 'volume info'
if name is not None:
cmd += ' '... | python | def info(name=None):
'''
.. versionadded:: 2015.8.4
Return gluster volume info.
name
Optional name to retrieve only information of one volume
CLI Example:
.. code-block:: bash
salt '*' glusterfs.info
'''
cmd = 'volume info'
if name is not None:
cmd += ' '... | [
"def",
"info",
"(",
"name",
"=",
"None",
")",
":",
"cmd",
"=",
"'volume info'",
"if",
"name",
"is",
"not",
"None",
":",
"cmd",
"+=",
"' '",
"+",
"name",
"root",
"=",
"_gluster_xml",
"(",
"cmd",
")",
"if",
"not",
"_gluster_ok",
"(",
"root",
")",
":"... | .. versionadded:: 2015.8.4
Return gluster volume info.
name
Optional name to retrieve only information of one volume
CLI Example:
.. code-block:: bash
salt '*' glusterfs.info | [
"..",
"versionadded",
"::",
"2015",
".",
"8",
".",
"4"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L395-L439 | train |
saltstack/salt | salt/modules/glusterfs.py | start_volume | def start_volume(name, force=False):
'''
Start a gluster volume
name
Volume name
force
Force the volume start even if the volume is started
.. versionadded:: 2015.8.4
CLI Example:
.. code-block:: bash
salt '*' glusterfs.start mycluster
'''
cmd = 'volu... | python | def start_volume(name, force=False):
'''
Start a gluster volume
name
Volume name
force
Force the volume start even if the volume is started
.. versionadded:: 2015.8.4
CLI Example:
.. code-block:: bash
salt '*' glusterfs.start mycluster
'''
cmd = 'volu... | [
"def",
"start_volume",
"(",
"name",
",",
"force",
"=",
"False",
")",
":",
"cmd",
"=",
"'volume start {0}'",
".",
"format",
"(",
"name",
")",
"if",
"force",
":",
"cmd",
"=",
"'{0} force'",
".",
"format",
"(",
"cmd",
")",
"volinfo",
"=",
"info",
"(",
"... | Start a gluster volume
name
Volume name
force
Force the volume start even if the volume is started
.. versionadded:: 2015.8.4
CLI Example:
.. code-block:: bash
salt '*' glusterfs.start mycluster | [
"Start",
"a",
"gluster",
"volume"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L442-L472 | train |
saltstack/salt | salt/modules/glusterfs.py | stop_volume | def stop_volume(name, force=False):
'''
Stop a gluster volume
name
Volume name
force
Force stop the volume
.. versionadded:: 2015.8.4
CLI Example:
.. code-block:: bash
salt '*' glusterfs.stop_volume mycluster
'''
volinfo = info()
if name not in v... | python | def stop_volume(name, force=False):
'''
Stop a gluster volume
name
Volume name
force
Force stop the volume
.. versionadded:: 2015.8.4
CLI Example:
.. code-block:: bash
salt '*' glusterfs.stop_volume mycluster
'''
volinfo = info()
if name not in v... | [
"def",
"stop_volume",
"(",
"name",
",",
"force",
"=",
"False",
")",
":",
"volinfo",
"=",
"info",
"(",
")",
"if",
"name",
"not",
"in",
"volinfo",
":",
"log",
".",
"error",
"(",
"'Cannot stop non-existing volume %s'",
",",
"name",
")",
"return",
"False",
"... | Stop a gluster volume
name
Volume name
force
Force stop the volume
.. versionadded:: 2015.8.4
CLI Example:
.. code-block:: bash
salt '*' glusterfs.stop_volume mycluster | [
"Stop",
"a",
"gluster",
"volume"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L475-L505 | train |
saltstack/salt | salt/modules/glusterfs.py | delete_volume | def delete_volume(target, stop=True):
'''
Deletes a gluster volume
target
Volume to delete
stop : True
If ``True``, stop volume before delete
CLI Example:
.. code-block:: bash
salt '*' glusterfs.delete_volume <volume>
'''
volinfo = info()
if target not in... | python | def delete_volume(target, stop=True):
'''
Deletes a gluster volume
target
Volume to delete
stop : True
If ``True``, stop volume before delete
CLI Example:
.. code-block:: bash
salt '*' glusterfs.delete_volume <volume>
'''
volinfo = info()
if target not in... | [
"def",
"delete_volume",
"(",
"target",
",",
"stop",
"=",
"True",
")",
":",
"volinfo",
"=",
"info",
"(",
")",
"if",
"target",
"not",
"in",
"volinfo",
":",
"log",
".",
"error",
"(",
"'Cannot delete non-existing volume %s'",
",",
"target",
")",
"return",
"Fal... | Deletes a gluster volume
target
Volume to delete
stop : True
If ``True``, stop volume before delete
CLI Example:
.. code-block:: bash
salt '*' glusterfs.delete_volume <volume> | [
"Deletes",
"a",
"gluster",
"volume"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L508-L542 | train |
saltstack/salt | salt/modules/glusterfs.py | add_volume_bricks | def add_volume_bricks(name, bricks):
'''
Add brick(s) to an existing volume
name
Volume name
bricks
List of bricks to add to the volume
CLI Example:
.. code-block:: bash
salt '*' glusterfs.add_volume_bricks <volume> <bricks>
'''
volinfo = info()
if name ... | python | def add_volume_bricks(name, bricks):
'''
Add brick(s) to an existing volume
name
Volume name
bricks
List of bricks to add to the volume
CLI Example:
.. code-block:: bash
salt '*' glusterfs.add_volume_bricks <volume> <bricks>
'''
volinfo = info()
if name ... | [
"def",
"add_volume_bricks",
"(",
"name",
",",
"bricks",
")",
":",
"volinfo",
"=",
"info",
"(",
")",
"if",
"name",
"not",
"in",
"volinfo",
":",
"log",
".",
"error",
"(",
"'Volume %s does not exist, cannot add bricks'",
",",
"name",
")",
"return",
"False",
"ne... | Add brick(s) to an existing volume
name
Volume name
bricks
List of bricks to add to the volume
CLI Example:
.. code-block:: bash
salt '*' glusterfs.add_volume_bricks <volume> <bricks> | [
"Add",
"brick",
"(",
"s",
")",
"to",
"an",
"existing",
"volume"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L545-L589 | train |
saltstack/salt | salt/modules/glusterfs.py | set_quota_volume | def set_quota_volume(name, path, size, enable_quota=False):
'''
Set quota to glusterfs volume.
name
Name of the gluster volume
path
Folder path for restriction in volume ("/")
size
Hard-limit size of the volume (MB/GB)
enable_quota
Enable quota before set up r... | python | def set_quota_volume(name, path, size, enable_quota=False):
'''
Set quota to glusterfs volume.
name
Name of the gluster volume
path
Folder path for restriction in volume ("/")
size
Hard-limit size of the volume (MB/GB)
enable_quota
Enable quota before set up r... | [
"def",
"set_quota_volume",
"(",
"name",
",",
"path",
",",
"size",
",",
"enable_quota",
"=",
"False",
")",
":",
"cmd",
"=",
"'volume quota {0}'",
".",
"format",
"(",
"name",
")",
"if",
"path",
":",
"cmd",
"+=",
"' limit-usage {0}'",
".",
"format",
"(",
"p... | Set quota to glusterfs volume.
name
Name of the gluster volume
path
Folder path for restriction in volume ("/")
size
Hard-limit size of the volume (MB/GB)
enable_quota
Enable quota before set up restriction
CLI Example:
.. code-block:: bash
salt '*'... | [
"Set",
"quota",
"to",
"glusterfs",
"volume",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/glusterfs.py#L632-L665 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.