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/gitfs.py | GitProvider.get_url | def get_url(self):
'''
Examine self.id and assign self.url (and self.branch, for git_pillar)
'''
if self.role in ('git_pillar', 'winrepo'):
# With winrepo and git_pillar, the remote is specified in the
# format '<branch> <url>', so that we can get a unique identif... | python | def get_url(self):
'''
Examine self.id and assign self.url (and self.branch, for git_pillar)
'''
if self.role in ('git_pillar', 'winrepo'):
# With winrepo and git_pillar, the remote is specified in the
# format '<branch> <url>', so that we can get a unique identif... | [
"def",
"get_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"role",
"in",
"(",
"'git_pillar'",
",",
"'winrepo'",
")",
":",
"# With winrepo and git_pillar, the remote is specified in the",
"# format '<branch> <url>', so that we can get a unique identifier",
"# to hash for each r... | Examine self.id and assign self.url (and self.branch, for git_pillar) | [
"Examine",
"self",
".",
"id",
"and",
"assign",
"self",
".",
"url",
"(",
"and",
"self",
".",
"branch",
"for",
"git_pillar",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1047-L1061 | train |
saltstack/salt | salt/utils/gitfs.py | GitProvider.linkdir_walk | def linkdir_walk(self):
'''
Return the expected result of an os.walk on the linkdir, based on the
mountpoint value.
'''
try:
# Use cached linkdir_walk if we've already run this
return self._linkdir_walk
except AttributeError:
self._link... | python | def linkdir_walk(self):
'''
Return the expected result of an os.walk on the linkdir, based on the
mountpoint value.
'''
try:
# Use cached linkdir_walk if we've already run this
return self._linkdir_walk
except AttributeError:
self._link... | [
"def",
"linkdir_walk",
"(",
"self",
")",
":",
"try",
":",
"# Use cached linkdir_walk if we've already run this",
"return",
"self",
".",
"_linkdir_walk",
"except",
"AttributeError",
":",
"self",
".",
"_linkdir_walk",
"=",
"[",
"]",
"try",
":",
"parts",
"=",
"self",... | Return the expected result of an os.walk on the linkdir, based on the
mountpoint value. | [
"Return",
"the",
"expected",
"result",
"of",
"an",
"os",
".",
"walk",
"on",
"the",
"linkdir",
"based",
"on",
"the",
"mountpoint",
"value",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1064-L1097 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython.checkout | def checkout(self):
'''
Checkout the configured branch/tag. We catch an "Exception" class here
instead of a specific exception class because the exceptions raised by
GitPython when running these functions vary in different versions of
GitPython.
'''
tgt_ref = self... | python | def checkout(self):
'''
Checkout the configured branch/tag. We catch an "Exception" class here
instead of a specific exception class because the exceptions raised by
GitPython when running these functions vary in different versions of
GitPython.
'''
tgt_ref = self... | [
"def",
"checkout",
"(",
"self",
")",
":",
"tgt_ref",
"=",
"self",
".",
"get_checkout_target",
"(",
")",
"try",
":",
"head_sha",
"=",
"self",
".",
"repo",
".",
"rev_parse",
"(",
"'HEAD'",
")",
".",
"hexsha",
"except",
"Exception",
":",
"# Should only happen... | Checkout the configured branch/tag. We catch an "Exception" class here
instead of a specific exception class because the exceptions raised by
GitPython when running these functions vary in different versions of
GitPython. | [
"Checkout",
"the",
"configured",
"branch",
"/",
"tag",
".",
"We",
"catch",
"an",
"Exception",
"class",
"here",
"instead",
"of",
"a",
"specific",
"exception",
"class",
"because",
"the",
"exceptions",
"raised",
"by",
"GitPython",
"when",
"running",
"these",
"fun... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1131-L1196 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython.init_remote | def init_remote(self):
'''
Initialize/attach to a remote using GitPython. Return a boolean
which will let the calling function know whether or not a new repo was
initialized by this function.
'''
new = False
if not os.listdir(self.cachedir):
# Repo cac... | python | def init_remote(self):
'''
Initialize/attach to a remote using GitPython. Return a boolean
which will let the calling function know whether or not a new repo was
initialized by this function.
'''
new = False
if not os.listdir(self.cachedir):
# Repo cac... | [
"def",
"init_remote",
"(",
"self",
")",
":",
"new",
"=",
"False",
"if",
"not",
"os",
".",
"listdir",
"(",
"self",
".",
"cachedir",
")",
":",
"# Repo cachedir is empty, initialize a new repo there",
"self",
".",
"repo",
"=",
"git",
".",
"Repo",
".",
"init",
... | Initialize/attach to a remote using GitPython. Return a boolean
which will let the calling function know whether or not a new repo was
initialized by this function. | [
"Initialize",
"/",
"attach",
"to",
"a",
"remote",
"using",
"GitPython",
".",
"Return",
"a",
"boolean",
"which",
"will",
"let",
"the",
"calling",
"function",
"know",
"whether",
"or",
"not",
"a",
"new",
"repo",
"was",
"initialized",
"by",
"this",
"function",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1198-L1220 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython.dir_list | def dir_list(self, tgt_env):
'''
Get list of directories for the target environment using GitPython
'''
ret = set()
tree = self.get_tree(tgt_env)
if not tree:
return ret
if self.root(tgt_env):
try:
tree = tree / self.root(tg... | python | def dir_list(self, tgt_env):
'''
Get list of directories for the target environment using GitPython
'''
ret = set()
tree = self.get_tree(tgt_env)
if not tree:
return ret
if self.root(tgt_env):
try:
tree = tree / self.root(tg... | [
"def",
"dir_list",
"(",
"self",
",",
"tgt_env",
")",
":",
"ret",
"=",
"set",
"(",
")",
"tree",
"=",
"self",
".",
"get_tree",
"(",
"tgt_env",
")",
"if",
"not",
"tree",
":",
"return",
"ret",
"if",
"self",
".",
"root",
"(",
"tgt_env",
")",
":",
"try... | Get list of directories for the target environment using GitPython | [
"Get",
"list",
"of",
"directories",
"for",
"the",
"target",
"environment",
"using",
"GitPython"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1222-L1245 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython.envs | def envs(self):
'''
Check the refs and return a list of the ones which can be used as salt
environments.
'''
ref_paths = [x.path for x in self.repo.refs]
return self._get_envs_from_ref_paths(ref_paths) | python | def envs(self):
'''
Check the refs and return a list of the ones which can be used as salt
environments.
'''
ref_paths = [x.path for x in self.repo.refs]
return self._get_envs_from_ref_paths(ref_paths) | [
"def",
"envs",
"(",
"self",
")",
":",
"ref_paths",
"=",
"[",
"x",
".",
"path",
"for",
"x",
"in",
"self",
".",
"repo",
".",
"refs",
"]",
"return",
"self",
".",
"_get_envs_from_ref_paths",
"(",
"ref_paths",
")"
] | Check the refs and return a list of the ones which can be used as salt
environments. | [
"Check",
"the",
"refs",
"and",
"return",
"a",
"list",
"of",
"the",
"ones",
"which",
"can",
"be",
"used",
"as",
"salt",
"environments",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1247-L1253 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython._fetch | def _fetch(self):
'''
Fetch the repo. If the local copy was updated, return True. If the
local copy was already up-to-date, return False.
'''
origin = self.repo.remotes[0]
try:
fetch_results = origin.fetch()
except AssertionError:
fetch_res... | python | def _fetch(self):
'''
Fetch the repo. If the local copy was updated, return True. If the
local copy was already up-to-date, return False.
'''
origin = self.repo.remotes[0]
try:
fetch_results = origin.fetch()
except AssertionError:
fetch_res... | [
"def",
"_fetch",
"(",
"self",
")",
":",
"origin",
"=",
"self",
".",
"repo",
".",
"remotes",
"[",
"0",
"]",
"try",
":",
"fetch_results",
"=",
"origin",
".",
"fetch",
"(",
")",
"except",
"AssertionError",
":",
"fetch_results",
"=",
"origin",
".",
"fetch"... | Fetch the repo. If the local copy was updated, return True. If the
local copy was already up-to-date, return False. | [
"Fetch",
"the",
"repo",
".",
"If",
"the",
"local",
"copy",
"was",
"updated",
"return",
"True",
".",
"If",
"the",
"local",
"copy",
"was",
"already",
"up",
"-",
"to",
"-",
"date",
"return",
"False",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1255-L1291 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython.file_list | def file_list(self, tgt_env):
'''
Get file list for the target environment using GitPython
'''
files = set()
symlinks = {}
tree = self.get_tree(tgt_env)
if not tree:
# Not found, return empty objects
return files, symlinks
if self.r... | python | def file_list(self, tgt_env):
'''
Get file list for the target environment using GitPython
'''
files = set()
symlinks = {}
tree = self.get_tree(tgt_env)
if not tree:
# Not found, return empty objects
return files, symlinks
if self.r... | [
"def",
"file_list",
"(",
"self",
",",
"tgt_env",
")",
":",
"files",
"=",
"set",
"(",
")",
"symlinks",
"=",
"{",
"}",
"tree",
"=",
"self",
".",
"get_tree",
"(",
"tgt_env",
")",
"if",
"not",
"tree",
":",
"# Not found, return empty objects",
"return",
"file... | Get file list for the target environment using GitPython | [
"Get",
"file",
"list",
"for",
"the",
"target",
"environment",
"using",
"GitPython"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1293-L1325 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython.find_file | def find_file(self, path, tgt_env):
'''
Find the specified file in the specified environment
'''
tree = self.get_tree(tgt_env)
if not tree:
# Branch/tag/SHA not found in repo
return None, None, None
blob = None
depth = 0
while True:... | python | def find_file(self, path, tgt_env):
'''
Find the specified file in the specified environment
'''
tree = self.get_tree(tgt_env)
if not tree:
# Branch/tag/SHA not found in repo
return None, None, None
blob = None
depth = 0
while True:... | [
"def",
"find_file",
"(",
"self",
",",
"path",
",",
"tgt_env",
")",
":",
"tree",
"=",
"self",
".",
"get_tree",
"(",
"tgt_env",
")",
"if",
"not",
"tree",
":",
"# Branch/tag/SHA not found in repo",
"return",
"None",
",",
"None",
",",
"None",
"blob",
"=",
"N... | Find the specified file in the specified environment | [
"Find",
"the",
"specified",
"file",
"in",
"the",
"specified",
"environment"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1327-L1368 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython.get_tree_from_branch | def get_tree_from_branch(self, ref):
'''
Return a git.Tree object matching a head ref fetched into
refs/remotes/origin/
'''
try:
return git.RemoteReference(
self.repo,
'refs/remotes/origin/{0}'.format(ref)).commit.tree
except Va... | python | def get_tree_from_branch(self, ref):
'''
Return a git.Tree object matching a head ref fetched into
refs/remotes/origin/
'''
try:
return git.RemoteReference(
self.repo,
'refs/remotes/origin/{0}'.format(ref)).commit.tree
except Va... | [
"def",
"get_tree_from_branch",
"(",
"self",
",",
"ref",
")",
":",
"try",
":",
"return",
"git",
".",
"RemoteReference",
"(",
"self",
".",
"repo",
",",
"'refs/remotes/origin/{0}'",
".",
"format",
"(",
"ref",
")",
")",
".",
"commit",
".",
"tree",
"except",
... | Return a git.Tree object matching a head ref fetched into
refs/remotes/origin/ | [
"Return",
"a",
"git",
".",
"Tree",
"object",
"matching",
"a",
"head",
"ref",
"fetched",
"into",
"refs",
"/",
"remotes",
"/",
"origin",
"/"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1370-L1380 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython.get_tree_from_tag | def get_tree_from_tag(self, ref):
'''
Return a git.Tree object matching a tag ref fetched into refs/tags/
'''
try:
return git.TagReference(
self.repo,
'refs/tags/{0}'.format(ref)).commit.tree
except ValueError:
return None | python | def get_tree_from_tag(self, ref):
'''
Return a git.Tree object matching a tag ref fetched into refs/tags/
'''
try:
return git.TagReference(
self.repo,
'refs/tags/{0}'.format(ref)).commit.tree
except ValueError:
return None | [
"def",
"get_tree_from_tag",
"(",
"self",
",",
"ref",
")",
":",
"try",
":",
"return",
"git",
".",
"TagReference",
"(",
"self",
".",
"repo",
",",
"'refs/tags/{0}'",
".",
"format",
"(",
"ref",
")",
")",
".",
"commit",
".",
"tree",
"except",
"ValueError",
... | Return a git.Tree object matching a tag ref fetched into refs/tags/ | [
"Return",
"a",
"git",
".",
"Tree",
"object",
"matching",
"a",
"tag",
"ref",
"fetched",
"into",
"refs",
"/",
"tags",
"/"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1382-L1391 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython.get_tree_from_sha | def get_tree_from_sha(self, ref):
'''
Return a git.Tree object matching a SHA
'''
try:
return self.repo.rev_parse(ref).tree
except (gitdb.exc.ODBError, AttributeError):
return None | python | def get_tree_from_sha(self, ref):
'''
Return a git.Tree object matching a SHA
'''
try:
return self.repo.rev_parse(ref).tree
except (gitdb.exc.ODBError, AttributeError):
return None | [
"def",
"get_tree_from_sha",
"(",
"self",
",",
"ref",
")",
":",
"try",
":",
"return",
"self",
".",
"repo",
".",
"rev_parse",
"(",
"ref",
")",
".",
"tree",
"except",
"(",
"gitdb",
".",
"exc",
".",
"ODBError",
",",
"AttributeError",
")",
":",
"return",
... | Return a git.Tree object matching a SHA | [
"Return",
"a",
"git",
".",
"Tree",
"object",
"matching",
"a",
"SHA"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1393-L1400 | train |
saltstack/salt | salt/utils/gitfs.py | GitPython.write_file | def write_file(self, blob, dest):
'''
Using the blob object, write the file to the destination path
'''
with salt.utils.files.fopen(dest, 'wb+') as fp_:
blob.stream_data(fp_) | python | def write_file(self, blob, dest):
'''
Using the blob object, write the file to the destination path
'''
with salt.utils.files.fopen(dest, 'wb+') as fp_:
blob.stream_data(fp_) | [
"def",
"write_file",
"(",
"self",
",",
"blob",
",",
"dest",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"dest",
",",
"'wb+'",
")",
"as",
"fp_",
":",
"blob",
".",
"stream_data",
"(",
"fp_",
")"
] | Using the blob object, write the file to the destination path | [
"Using",
"the",
"blob",
"object",
"write",
"the",
"file",
"to",
"the",
"destination",
"path"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1402-L1407 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.checkout | def checkout(self):
'''
Checkout the configured branch/tag
'''
tgt_ref = self.get_checkout_target()
local_ref = 'refs/heads/' + tgt_ref
remote_ref = 'refs/remotes/origin/' + tgt_ref
tag_ref = 'refs/tags/' + tgt_ref
try:
local_head = self.repo.... | python | def checkout(self):
'''
Checkout the configured branch/tag
'''
tgt_ref = self.get_checkout_target()
local_ref = 'refs/heads/' + tgt_ref
remote_ref = 'refs/remotes/origin/' + tgt_ref
tag_ref = 'refs/tags/' + tgt_ref
try:
local_head = self.repo.... | [
"def",
"checkout",
"(",
"self",
")",
":",
"tgt_ref",
"=",
"self",
".",
"get_checkout_target",
"(",
")",
"local_ref",
"=",
"'refs/heads/'",
"+",
"tgt_ref",
"remote_ref",
"=",
"'refs/remotes/origin/'",
"+",
"tgt_ref",
"tag_ref",
"=",
"'refs/tags/'",
"+",
"tgt_ref"... | Checkout the configured branch/tag | [
"Checkout",
"the",
"configured",
"branch",
"/",
"tag"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1435-L1617 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.clean_stale_refs | def clean_stale_refs(self, local_refs=None): # pylint: disable=arguments-differ
'''
Clean stale local refs so they don't appear as fileserver environments
'''
try:
if pygit2.GIT_FETCH_PRUNE:
# Don't need to clean anything, pygit2 can do it by itself
... | python | def clean_stale_refs(self, local_refs=None): # pylint: disable=arguments-differ
'''
Clean stale local refs so they don't appear as fileserver environments
'''
try:
if pygit2.GIT_FETCH_PRUNE:
# Don't need to clean anything, pygit2 can do it by itself
... | [
"def",
"clean_stale_refs",
"(",
"self",
",",
"local_refs",
"=",
"None",
")",
":",
"# pylint: disable=arguments-differ",
"try",
":",
"if",
"pygit2",
".",
"GIT_FETCH_PRUNE",
":",
"# Don't need to clean anything, pygit2 can do it by itself",
"return",
"[",
"]",
"except",
"... | Clean stale local refs so they don't appear as fileserver environments | [
"Clean",
"stale",
"local",
"refs",
"so",
"they",
"don",
"t",
"appear",
"as",
"fileserver",
"environments"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1619-L1638 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.init_remote | def init_remote(self):
'''
Initialize/attach to a remote using pygit2. Return a boolean which
will let the calling function know whether or not a new repo was
initialized by this function.
'''
# https://github.com/libgit2/pygit2/issues/339
# https://github.com/lib... | python | def init_remote(self):
'''
Initialize/attach to a remote using pygit2. Return a boolean which
will let the calling function know whether or not a new repo was
initialized by this function.
'''
# https://github.com/libgit2/pygit2/issues/339
# https://github.com/lib... | [
"def",
"init_remote",
"(",
"self",
")",
":",
"# https://github.com/libgit2/pygit2/issues/339",
"# https://github.com/libgit2/libgit2/issues/2122",
"home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"pygit2",
".",
"settings",
".",
"search_path",
"[",
"... | Initialize/attach to a remote using pygit2. Return a boolean which
will let the calling function know whether or not a new repo was
initialized by this function. | [
"Initialize",
"/",
"attach",
"to",
"a",
"remote",
"using",
"pygit2",
".",
"Return",
"a",
"boolean",
"which",
"will",
"let",
"the",
"calling",
"function",
"know",
"whether",
"or",
"not",
"a",
"new",
"repo",
"was",
"initialized",
"by",
"this",
"function",
".... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1640-L1666 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.dir_list | def dir_list(self, tgt_env):
'''
Get a list of directories for the target environment using pygit2
'''
def _traverse(tree, blobs, prefix):
'''
Traverse through a pygit2 Tree object recursively, accumulating all
the empty directories within it in the "b... | python | def dir_list(self, tgt_env):
'''
Get a list of directories for the target environment using pygit2
'''
def _traverse(tree, blobs, prefix):
'''
Traverse through a pygit2 Tree object recursively, accumulating all
the empty directories within it in the "b... | [
"def",
"dir_list",
"(",
"self",
",",
"tgt_env",
")",
":",
"def",
"_traverse",
"(",
"tree",
",",
"blobs",
",",
"prefix",
")",
":",
"'''\n Traverse through a pygit2 Tree object recursively, accumulating all\n the empty directories within it in the \"blobs\" li... | Get a list of directories for the target environment using pygit2 | [
"Get",
"a",
"list",
"of",
"directories",
"for",
"the",
"target",
"environment",
"using",
"pygit2"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1668-L1717 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2._fetch | def _fetch(self):
'''
Fetch the repo. If the local copy was updated, return True. If the
local copy was already up-to-date, return False.
'''
origin = self.repo.remotes[0]
refs_pre = self.repo.listall_references()
fetch_kwargs = {}
# pygit2 radically chang... | python | def _fetch(self):
'''
Fetch the repo. If the local copy was updated, return True. If the
local copy was already up-to-date, return False.
'''
origin = self.repo.remotes[0]
refs_pre = self.repo.listall_references()
fetch_kwargs = {}
# pygit2 radically chang... | [
"def",
"_fetch",
"(",
"self",
")",
":",
"origin",
"=",
"self",
".",
"repo",
".",
"remotes",
"[",
"0",
"]",
"refs_pre",
"=",
"self",
".",
"repo",
".",
"listall_references",
"(",
")",
"fetch_kwargs",
"=",
"{",
"}",
"# pygit2 radically changed fetchiing in 0.23... | Fetch the repo. If the local copy was updated, return True. If the
local copy was already up-to-date, return False. | [
"Fetch",
"the",
"repo",
".",
"If",
"the",
"local",
"copy",
"was",
"updated",
"return",
"True",
".",
"If",
"the",
"local",
"copy",
"was",
"already",
"up",
"-",
"to",
"-",
"date",
"return",
"False",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1727-L1790 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.file_list | def file_list(self, tgt_env):
'''
Get file list for the target environment using pygit2
'''
def _traverse(tree, blobs, prefix):
'''
Traverse through a pygit2 Tree object recursively, accumulating all
the file paths and symlink info in the "blobs" dict
... | python | def file_list(self, tgt_env):
'''
Get file list for the target environment using pygit2
'''
def _traverse(tree, blobs, prefix):
'''
Traverse through a pygit2 Tree object recursively, accumulating all
the file paths and symlink info in the "blobs" dict
... | [
"def",
"file_list",
"(",
"self",
",",
"tgt_env",
")",
":",
"def",
"_traverse",
"(",
"tree",
",",
"blobs",
",",
"prefix",
")",
":",
"'''\n Traverse through a pygit2 Tree object recursively, accumulating all\n the file paths and symlink info in the \"blobs\" d... | Get file list for the target environment using pygit2 | [
"Get",
"file",
"list",
"for",
"the",
"target",
"environment",
"using",
"pygit2"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1792-L1847 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.find_file | def find_file(self, path, tgt_env):
'''
Find the specified file in the specified environment
'''
tree = self.get_tree(tgt_env)
if not tree:
# Branch/tag/SHA not found in repo
return None, None, None
blob = None
mode = None
depth = 0... | python | def find_file(self, path, tgt_env):
'''
Find the specified file in the specified environment
'''
tree = self.get_tree(tgt_env)
if not tree:
# Branch/tag/SHA not found in repo
return None, None, None
blob = None
mode = None
depth = 0... | [
"def",
"find_file",
"(",
"self",
",",
"path",
",",
"tgt_env",
")",
":",
"tree",
"=",
"self",
".",
"get_tree",
"(",
"tgt_env",
")",
"if",
"not",
"tree",
":",
"# Branch/tag/SHA not found in repo",
"return",
"None",
",",
"None",
",",
"None",
"blob",
"=",
"N... | Find the specified file in the specified environment | [
"Find",
"the",
"specified",
"file",
"in",
"the",
"specified",
"environment"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1849-L1887 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.get_tree_from_branch | def get_tree_from_branch(self, ref):
'''
Return a pygit2.Tree object matching a head ref fetched into
refs/remotes/origin/
'''
try:
return self.peel(self.repo.lookup_reference(
'refs/remotes/origin/{0}'.format(ref))).tree
except KeyError:
... | python | def get_tree_from_branch(self, ref):
'''
Return a pygit2.Tree object matching a head ref fetched into
refs/remotes/origin/
'''
try:
return self.peel(self.repo.lookup_reference(
'refs/remotes/origin/{0}'.format(ref))).tree
except KeyError:
... | [
"def",
"get_tree_from_branch",
"(",
"self",
",",
"ref",
")",
":",
"try",
":",
"return",
"self",
".",
"peel",
"(",
"self",
".",
"repo",
".",
"lookup_reference",
"(",
"'refs/remotes/origin/{0}'",
".",
"format",
"(",
"ref",
")",
")",
")",
".",
"tree",
"exce... | Return a pygit2.Tree object matching a head ref fetched into
refs/remotes/origin/ | [
"Return",
"a",
"pygit2",
".",
"Tree",
"object",
"matching",
"a",
"head",
"ref",
"fetched",
"into",
"refs",
"/",
"remotes",
"/",
"origin",
"/"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1889-L1898 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.get_tree_from_sha | def get_tree_from_sha(self, ref):
'''
Return a pygit2.Tree object matching a SHA
'''
try:
return self.repo.revparse_single(ref).tree
except (KeyError, TypeError, ValueError, AttributeError):
return None | python | def get_tree_from_sha(self, ref):
'''
Return a pygit2.Tree object matching a SHA
'''
try:
return self.repo.revparse_single(ref).tree
except (KeyError, TypeError, ValueError, AttributeError):
return None | [
"def",
"get_tree_from_sha",
"(",
"self",
",",
"ref",
")",
":",
"try",
":",
"return",
"self",
".",
"repo",
".",
"revparse_single",
"(",
"ref",
")",
".",
"tree",
"except",
"(",
"KeyError",
",",
"TypeError",
",",
"ValueError",
",",
"AttributeError",
")",
":... | Return a pygit2.Tree object matching a SHA | [
"Return",
"a",
"pygit2",
".",
"Tree",
"object",
"matching",
"a",
"SHA"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1910-L1917 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.setup_callbacks | def setup_callbacks(self):
'''
Assign attributes for pygit2 callbacks
'''
if PYGIT2_VERSION >= _LooseVersion('0.23.2'):
self.remotecallbacks = pygit2.RemoteCallbacks(
credentials=self.credentials)
if not self.ssl_verify:
# Override ... | python | def setup_callbacks(self):
'''
Assign attributes for pygit2 callbacks
'''
if PYGIT2_VERSION >= _LooseVersion('0.23.2'):
self.remotecallbacks = pygit2.RemoteCallbacks(
credentials=self.credentials)
if not self.ssl_verify:
# Override ... | [
"def",
"setup_callbacks",
"(",
"self",
")",
":",
"if",
"PYGIT2_VERSION",
">=",
"_LooseVersion",
"(",
"'0.23.2'",
")",
":",
"self",
".",
"remotecallbacks",
"=",
"pygit2",
".",
"RemoteCallbacks",
"(",
"credentials",
"=",
"self",
".",
"credentials",
")",
"if",
... | Assign attributes for pygit2 callbacks | [
"Assign",
"attributes",
"for",
"pygit2",
"callbacks"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1919-L1940 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.verify_auth | def verify_auth(self):
'''
Check the username and password/keypair info for validity. If valid,
set a 'credentials' attribute consisting of the appropriate Pygit2
credentials object. Return False if a required auth param is not
present. Return True if the required auth parameters... | python | def verify_auth(self):
'''
Check the username and password/keypair info for validity. If valid,
set a 'credentials' attribute consisting of the appropriate Pygit2
credentials object. Return False if a required auth param is not
present. Return True if the required auth parameters... | [
"def",
"verify_auth",
"(",
"self",
")",
":",
"self",
".",
"credentials",
"=",
"None",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"self",
".",
"url",
")",
":",
"# If the URL is an absolute file path, there is no authentication.",
"return",
"True",
"elif",
"not",... | Check the username and password/keypair info for validity. If valid,
set a 'credentials' attribute consisting of the appropriate Pygit2
credentials object. Return False if a required auth param is not
present. Return True if the required auth parameters are present (or
auth is not config... | [
"Check",
"the",
"username",
"and",
"password",
"/",
"keypair",
"info",
"for",
"validity",
".",
"If",
"valid",
"set",
"a",
"credentials",
"attribute",
"consisting",
"of",
"the",
"appropriate",
"Pygit2",
"credentials",
"object",
".",
"Return",
"False",
"if",
"a"... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1942-L2063 | train |
saltstack/salt | salt/utils/gitfs.py | Pygit2.write_file | def write_file(self, blob, dest):
'''
Using the blob object, write the file to the destination path
'''
with salt.utils.files.fopen(dest, 'wb+') as fp_:
fp_.write(blob.data) | python | def write_file(self, blob, dest):
'''
Using the blob object, write the file to the destination path
'''
with salt.utils.files.fopen(dest, 'wb+') as fp_:
fp_.write(blob.data) | [
"def",
"write_file",
"(",
"self",
",",
"blob",
",",
"dest",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"dest",
",",
"'wb+'",
")",
"as",
"fp_",
":",
"fp_",
".",
"write",
"(",
"blob",
".",
"data",
")"
] | Using the blob object, write the file to the destination path | [
"Using",
"the",
"blob",
"object",
"write",
"the",
"file",
"to",
"the",
"destination",
"path"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2065-L2070 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.init_remotes | def init_remotes(self, remotes, per_remote_overrides=(),
per_remote_only=PER_REMOTE_ONLY,
global_only=GLOBAL_ONLY):
'''
Initialize remotes
'''
# The global versions of the auth params (gitfs_user,
# gitfs_password, etc.) default to empty ... | python | def init_remotes(self, remotes, per_remote_overrides=(),
per_remote_only=PER_REMOTE_ONLY,
global_only=GLOBAL_ONLY):
'''
Initialize remotes
'''
# The global versions of the auth params (gitfs_user,
# gitfs_password, etc.) default to empty ... | [
"def",
"init_remotes",
"(",
"self",
",",
"remotes",
",",
"per_remote_overrides",
"=",
"(",
")",
",",
"per_remote_only",
"=",
"PER_REMOTE_ONLY",
",",
"global_only",
"=",
"GLOBAL_ONLY",
")",
":",
"# The global versions of the auth params (gitfs_user,",
"# gitfs_password, et... | Initialize remotes | [
"Initialize",
"remotes"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2146-L2269 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.clear_old_remotes | def clear_old_remotes(self):
'''
Remove cache directories for remotes no longer configured
'''
try:
cachedir_ls = os.listdir(self.cache_root)
except OSError:
cachedir_ls = []
# Remove actively-used remotes from list
for repo in self.remotes... | python | def clear_old_remotes(self):
'''
Remove cache directories for remotes no longer configured
'''
try:
cachedir_ls = os.listdir(self.cache_root)
except OSError:
cachedir_ls = []
# Remove actively-used remotes from list
for repo in self.remotes... | [
"def",
"clear_old_remotes",
"(",
"self",
")",
":",
"try",
":",
"cachedir_ls",
"=",
"os",
".",
"listdir",
"(",
"self",
".",
"cache_root",
")",
"except",
"OSError",
":",
"cachedir_ls",
"=",
"[",
"]",
"# Remove actively-used remotes from list",
"for",
"repo",
"in... | Remove cache directories for remotes no longer configured | [
"Remove",
"cache",
"directories",
"for",
"remotes",
"no",
"longer",
"configured"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2271-L2310 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.clear_cache | def clear_cache(self):
'''
Completely clear cache
'''
errors = []
for rdir in (self.cache_root, self.file_list_cachedir):
if os.path.exists(rdir):
try:
shutil.rmtree(rdir)
except OSError as exc:
e... | python | def clear_cache(self):
'''
Completely clear cache
'''
errors = []
for rdir in (self.cache_root, self.file_list_cachedir):
if os.path.exists(rdir):
try:
shutil.rmtree(rdir)
except OSError as exc:
e... | [
"def",
"clear_cache",
"(",
"self",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"rdir",
"in",
"(",
"self",
".",
"cache_root",
",",
"self",
".",
"file_list_cachedir",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"rdir",
")",
":",
"try",
":",
... | Completely clear cache | [
"Completely",
"clear",
"cache"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2312-L2325 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.clear_lock | def clear_lock(self, remote=None, lock_type='update'):
'''
Clear update.lk for all remotes
'''
cleared = []
errors = []
for repo in self.remotes:
if remote:
# Specific remote URL/pattern was passed, ensure that the URL
# matches... | python | def clear_lock(self, remote=None, lock_type='update'):
'''
Clear update.lk for all remotes
'''
cleared = []
errors = []
for repo in self.remotes:
if remote:
# Specific remote URL/pattern was passed, ensure that the URL
# matches... | [
"def",
"clear_lock",
"(",
"self",
",",
"remote",
"=",
"None",
",",
"lock_type",
"=",
"'update'",
")",
":",
"cleared",
"=",
"[",
"]",
"errors",
"=",
"[",
"]",
"for",
"repo",
"in",
"self",
".",
"remotes",
":",
"if",
"remote",
":",
"# Specific remote URL/... | Clear update.lk for all remotes | [
"Clear",
"update",
".",
"lk",
"for",
"all",
"remotes"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2327-L2347 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.fetch_remotes | def fetch_remotes(self, remotes=None):
'''
Fetch all remotes and return a boolean to let the calling function know
whether or not any remotes were updated in the process of fetching
'''
if remotes is None:
remotes = []
elif not isinstance(remotes, list):
... | python | def fetch_remotes(self, remotes=None):
'''
Fetch all remotes and return a boolean to let the calling function know
whether or not any remotes were updated in the process of fetching
'''
if remotes is None:
remotes = []
elif not isinstance(remotes, list):
... | [
"def",
"fetch_remotes",
"(",
"self",
",",
"remotes",
"=",
"None",
")",
":",
"if",
"remotes",
"is",
"None",
":",
"remotes",
"=",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"remotes",
",",
"list",
")",
":",
"log",
".",
"error",
"(",
"'Invalid \\'remotes... | Fetch all remotes and return a boolean to let the calling function know
whether or not any remotes were updated in the process of fetching | [
"Fetch",
"all",
"remotes",
"and",
"return",
"a",
"boolean",
"to",
"let",
"the",
"calling",
"function",
"know",
"whether",
"or",
"not",
"any",
"remotes",
"were",
"updated",
"in",
"the",
"process",
"of",
"fetching"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2349-L2382 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.lock | def lock(self, remote=None):
'''
Place an update.lk
'''
locked = []
errors = []
for repo in self.remotes:
if remote:
# Specific remote URL/pattern was passed, ensure that the URL
# matches or else skip this one
t... | python | def lock(self, remote=None):
'''
Place an update.lk
'''
locked = []
errors = []
for repo in self.remotes:
if remote:
# Specific remote URL/pattern was passed, ensure that the URL
# matches or else skip this one
t... | [
"def",
"lock",
"(",
"self",
",",
"remote",
"=",
"None",
")",
":",
"locked",
"=",
"[",
"]",
"errors",
"=",
"[",
"]",
"for",
"repo",
"in",
"self",
".",
"remotes",
":",
"if",
"remote",
":",
"# Specific remote URL/pattern was passed, ensure that the URL",
"# mat... | Place an update.lk | [
"Place",
"an",
"update",
".",
"lk"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2384-L2404 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.update | def update(self, remotes=None):
'''
.. versionchanged:: 2018.3.0
The remotes argument was added. This being a list of remote URLs,
it will only update matching remotes. This actually matches on
repo.id
Execute a git fetch on all of the repos and perform maint... | python | def update(self, remotes=None):
'''
.. versionchanged:: 2018.3.0
The remotes argument was added. This being a list of remote URLs,
it will only update matching remotes. This actually matches on
repo.id
Execute a git fetch on all of the repos and perform maint... | [
"def",
"update",
"(",
"self",
",",
"remotes",
"=",
"None",
")",
":",
"# data for the fileserver event",
"data",
"=",
"{",
"'changed'",
":",
"False",
",",
"'backend'",
":",
"'gitfs'",
"}",
"data",
"[",
"'changed'",
"]",
"=",
"self",
".",
"clear_old_remotes",
... | .. versionchanged:: 2018.3.0
The remotes argument was added. This being a list of remote URLs,
it will only update matching remotes. This actually matches on
repo.id
Execute a git fetch on all of the repos and perform maintenance on the
fileserver cache. | [
"..",
"versionchanged",
"::",
"2018",
".",
"3",
".",
"0",
"The",
"remotes",
"argument",
"was",
"added",
".",
"This",
"being",
"a",
"list",
"of",
"remote",
"URLs",
"it",
"will",
"only",
"update",
"matching",
"remotes",
".",
"This",
"actually",
"matches",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2406-L2460 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.update_intervals | def update_intervals(self):
'''
Returns a dictionary mapping remote IDs to their intervals, designed to
be used for variable update intervals in salt.master.FileserverUpdate.
A remote's ID is defined here as a tuple of the GitPython/Pygit2
object's "id" and "name" attributes, wi... | python | def update_intervals(self):
'''
Returns a dictionary mapping remote IDs to their intervals, designed to
be used for variable update intervals in salt.master.FileserverUpdate.
A remote's ID is defined here as a tuple of the GitPython/Pygit2
object's "id" and "name" attributes, wi... | [
"def",
"update_intervals",
"(",
"self",
")",
":",
"return",
"{",
"(",
"repo",
".",
"id",
",",
"getattr",
"(",
"repo",
",",
"'name'",
",",
"None",
")",
")",
":",
"repo",
".",
"update_interval",
"for",
"repo",
"in",
"self",
".",
"remotes",
"}"
] | Returns a dictionary mapping remote IDs to their intervals, designed to
be used for variable update intervals in salt.master.FileserverUpdate.
A remote's ID is defined here as a tuple of the GitPython/Pygit2
object's "id" and "name" attributes, with None being assumed as the
"name" valu... | [
"Returns",
"a",
"dictionary",
"mapping",
"remote",
"IDs",
"to",
"their",
"intervals",
"designed",
"to",
"be",
"used",
"for",
"variable",
"update",
"intervals",
"in",
"salt",
".",
"master",
".",
"FileserverUpdate",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2462-L2472 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.verify_provider | def verify_provider(self):
'''
Determine which provider to use
'''
if 'verified_{0}_provider'.format(self.role) in self.opts:
self.provider = self.opts['verified_{0}_provider'.format(self.role)]
else:
desired_provider = self.opts.get('{0}_provider'.format(... | python | def verify_provider(self):
'''
Determine which provider to use
'''
if 'verified_{0}_provider'.format(self.role) in self.opts:
self.provider = self.opts['verified_{0}_provider'.format(self.role)]
else:
desired_provider = self.opts.get('{0}_provider'.format(... | [
"def",
"verify_provider",
"(",
"self",
")",
":",
"if",
"'verified_{0}_provider'",
".",
"format",
"(",
"self",
".",
"role",
")",
"in",
"self",
".",
"opts",
":",
"self",
".",
"provider",
"=",
"self",
".",
"opts",
"[",
"'verified_{0}_provider'",
".",
"format"... | Determine which provider to use | [
"Determine",
"which",
"provider",
"to",
"use"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2474-L2511 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.verify_gitpython | def verify_gitpython(self, quiet=False):
'''
Check if GitPython is available and at a compatible version (>= 0.3.0)
'''
def _recommend():
if PYGIT2_VERSION and 'pygit2' in self.git_providers:
log.error(_RECOMMEND_PYGIT2, self.role, self.role)
if not G... | python | def verify_gitpython(self, quiet=False):
'''
Check if GitPython is available and at a compatible version (>= 0.3.0)
'''
def _recommend():
if PYGIT2_VERSION and 'pygit2' in self.git_providers:
log.error(_RECOMMEND_PYGIT2, self.role, self.role)
if not G... | [
"def",
"verify_gitpython",
"(",
"self",
",",
"quiet",
"=",
"False",
")",
":",
"def",
"_recommend",
"(",
")",
":",
"if",
"PYGIT2_VERSION",
"and",
"'pygit2'",
"in",
"self",
".",
"git_providers",
":",
"log",
".",
"error",
"(",
"_RECOMMEND_PYGIT2",
",",
"self"... | Check if GitPython is available and at a compatible version (>= 0.3.0) | [
"Check",
"if",
"GitPython",
"is",
"available",
"and",
"at",
"a",
"compatible",
"version",
"(",
">",
"=",
"0",
".",
"3",
".",
"0",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2513-L2557 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.verify_pygit2 | def verify_pygit2(self, quiet=False):
'''
Check if pygit2/libgit2 are available and at a compatible version.
Pygit2 must be at least 0.20.3 and libgit2 must be at least 0.20.0.
'''
def _recommend():
if GITPYTHON_VERSION and 'gitpython' in self.git_providers:
... | python | def verify_pygit2(self, quiet=False):
'''
Check if pygit2/libgit2 are available and at a compatible version.
Pygit2 must be at least 0.20.3 and libgit2 must be at least 0.20.0.
'''
def _recommend():
if GITPYTHON_VERSION and 'gitpython' in self.git_providers:
... | [
"def",
"verify_pygit2",
"(",
"self",
",",
"quiet",
"=",
"False",
")",
":",
"def",
"_recommend",
"(",
")",
":",
"if",
"GITPYTHON_VERSION",
"and",
"'gitpython'",
"in",
"self",
".",
"git_providers",
":",
"log",
".",
"error",
"(",
"_RECOMMEND_GITPYTHON",
",",
... | Check if pygit2/libgit2 are available and at a compatible version.
Pygit2 must be at least 0.20.3 and libgit2 must be at least 0.20.0. | [
"Check",
"if",
"pygit2",
"/",
"libgit2",
"are",
"available",
"and",
"at",
"a",
"compatible",
"version",
".",
"Pygit2",
"must",
"be",
"at",
"least",
"0",
".",
"20",
".",
"3",
"and",
"libgit2",
"must",
"be",
"at",
"least",
"0",
".",
"20",
".",
"0",
"... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2559-L2614 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.write_remote_map | def write_remote_map(self):
'''
Write the remote_map.txt
'''
remote_map = salt.utils.path.join(self.cache_root, 'remote_map.txt')
try:
with salt.utils.files.fopen(remote_map, 'w+') as fp_:
timestamp = \
datetime.now().strftime('%d %... | python | def write_remote_map(self):
'''
Write the remote_map.txt
'''
remote_map = salt.utils.path.join(self.cache_root, 'remote_map.txt')
try:
with salt.utils.files.fopen(remote_map, 'w+') as fp_:
timestamp = \
datetime.now().strftime('%d %... | [
"def",
"write_remote_map",
"(",
"self",
")",
":",
"remote_map",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"join",
"(",
"self",
".",
"cache_root",
",",
"'remote_map.txt'",
")",
"try",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"("... | Write the remote_map.txt | [
"Write",
"the",
"remote_map",
".",
"txt"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2616-L2643 | train |
saltstack/salt | salt/utils/gitfs.py | GitBase.do_checkout | def do_checkout(self, repo):
'''
Common code for git_pillar/winrepo to handle locking and checking out
of a repo.
'''
time_start = time.time()
while time.time() - time_start <= 5:
try:
return repo.checkout()
except GitLockError as e... | python | def do_checkout(self, repo):
'''
Common code for git_pillar/winrepo to handle locking and checking out
of a repo.
'''
time_start = time.time()
while time.time() - time_start <= 5:
try:
return repo.checkout()
except GitLockError as e... | [
"def",
"do_checkout",
"(",
"self",
",",
"repo",
")",
":",
"time_start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"time",
".",
"time",
"(",
")",
"-",
"time_start",
"<=",
"5",
":",
"try",
":",
"return",
"repo",
".",
"checkout",
"(",
")",
"except"... | Common code for git_pillar/winrepo to handle locking and checking out
of a repo. | [
"Common",
"code",
"for",
"git_pillar",
"/",
"winrepo",
"to",
"handle",
"locking",
"and",
"checking",
"out",
"of",
"a",
"repo",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2645-L2676 | train |
saltstack/salt | salt/utils/gitfs.py | GitFS.envs | def envs(self, ignore_cache=False):
'''
Return a list of refs that can be used as environments
'''
if not ignore_cache:
cache_match = salt.fileserver.check_env_cache(
self.opts,
self.env_cache
)
if cache_match is not Non... | python | def envs(self, ignore_cache=False):
'''
Return a list of refs that can be used as environments
'''
if not ignore_cache:
cache_match = salt.fileserver.check_env_cache(
self.opts,
self.env_cache
)
if cache_match is not Non... | [
"def",
"envs",
"(",
"self",
",",
"ignore_cache",
"=",
"False",
")",
":",
"if",
"not",
"ignore_cache",
":",
"cache_match",
"=",
"salt",
".",
"fileserver",
".",
"check_env_cache",
"(",
"self",
".",
"opts",
",",
"self",
".",
"env_cache",
")",
"if",
"cache_m... | Return a list of refs that can be used as environments | [
"Return",
"a",
"list",
"of",
"refs",
"that",
"can",
"be",
"used",
"as",
"environments"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2735-L2752 | train |
saltstack/salt | salt/utils/gitfs.py | GitFS.find_file | def find_file(self, path, tgt_env='base', **kwargs): # pylint: disable=W0613
'''
Find the first file to match the path and ref, read the file out of git
and send the path to the newly cached file
'''
fnd = {'path': '',
'rel': ''}
if os.path.isabs(path) or ... | python | def find_file(self, path, tgt_env='base', **kwargs): # pylint: disable=W0613
'''
Find the first file to match the path and ref, read the file out of git
and send the path to the newly cached file
'''
fnd = {'path': '',
'rel': ''}
if os.path.isabs(path) or ... | [
"def",
"find_file",
"(",
"self",
",",
"path",
",",
"tgt_env",
"=",
"'base'",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=W0613",
"fnd",
"=",
"{",
"'path'",
":",
"''",
",",
"'rel'",
":",
"''",
"}",
"if",
"os",
".",
"path",
".",
"isabs",
"(... | Find the first file to match the path and ref, read the file out of git
and send the path to the newly cached file | [
"Find",
"the",
"first",
"file",
"to",
"match",
"the",
"path",
"and",
"ref",
"read",
"the",
"file",
"out",
"of",
"git",
"and",
"send",
"the",
"path",
"to",
"the",
"newly",
"cached",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2754-L2852 | train |
saltstack/salt | salt/utils/gitfs.py | GitFS.file_hash | def file_hash(self, load, fnd):
'''
Return a file hash, the hash type is set in the master config file
'''
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if not all(x in load for x in ('path', 'saltenv')):
return ''... | python | def file_hash(self, load, fnd):
'''
Return a file hash, the hash type is set in the master config file
'''
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if not all(x in load for x in ('path', 'saltenv')):
return ''... | [
"def",
"file_hash",
"(",
"self",
",",
"load",
",",
"fnd",
")",
":",
"if",
"'env'",
"in",
"load",
":",
"# \"env\" is not supported; Use \"saltenv\".",
"load",
".",
"pop",
"(",
"'env'",
")",
"if",
"not",
"all",
"(",
"x",
"in",
"load",
"for",
"x",
"in",
"... | Return a file hash, the hash type is set in the master config file | [
"Return",
"a",
"file",
"hash",
"the",
"hash",
"type",
"is",
"set",
"in",
"the",
"master",
"config",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2887-L2921 | train |
saltstack/salt | salt/utils/gitfs.py | GitFS._file_lists | def _file_lists(self, load, form):
'''
Return a dict containing the file lists for files and dirs
'''
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if not os.path.isdir(self.file_list_cachedir):
try:
... | python | def _file_lists(self, load, form):
'''
Return a dict containing the file lists for files and dirs
'''
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if not os.path.isdir(self.file_list_cachedir):
try:
... | [
"def",
"_file_lists",
"(",
"self",
",",
"load",
",",
"form",
")",
":",
"if",
"'env'",
"in",
"load",
":",
"# \"env\" is not supported; Use \"saltenv\".",
"load",
".",
"pop",
"(",
"'env'",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
"."... | Return a dict containing the file lists for files and dirs | [
"Return",
"a",
"dict",
"containing",
"the",
"file",
"lists",
"for",
"files",
"and",
"dirs"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2923-L2972 | train |
saltstack/salt | salt/utils/gitfs.py | GitFS.symlink_list | def symlink_list(self, load):
'''
Return a dict of all symlinks based on a given path in the repo
'''
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if not salt.utils.stringutils.is_hex(load['saltenv']) \
and lo... | python | def symlink_list(self, load):
'''
Return a dict of all symlinks based on a given path in the repo
'''
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if not salt.utils.stringutils.is_hex(load['saltenv']) \
and lo... | [
"def",
"symlink_list",
"(",
"self",
",",
"load",
")",
":",
"if",
"'env'",
"in",
"load",
":",
"# \"env\" is not supported; Use \"saltenv\".",
"load",
".",
"pop",
"(",
"'env'",
")",
"if",
"not",
"salt",
".",
"utils",
".",
"stringutils",
".",
"is_hex",
"(",
"... | Return a dict of all symlinks based on a given path in the repo | [
"Return",
"a",
"dict",
"of",
"all",
"symlinks",
"based",
"on",
"a",
"given",
"path",
"in",
"the",
"repo"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L2988-L3006 | train |
saltstack/salt | salt/utils/gitfs.py | GitPillar.checkout | def checkout(self):
'''
Checkout the targeted branches/tags from the git_pillar remotes
'''
self.pillar_dirs = OrderedDict()
self.pillar_linked_dirs = []
for repo in self.remotes:
cachedir = self.do_checkout(repo)
if cachedir is not None:
... | python | def checkout(self):
'''
Checkout the targeted branches/tags from the git_pillar remotes
'''
self.pillar_dirs = OrderedDict()
self.pillar_linked_dirs = []
for repo in self.remotes:
cachedir = self.do_checkout(repo)
if cachedir is not None:
... | [
"def",
"checkout",
"(",
"self",
")",
":",
"self",
".",
"pillar_dirs",
"=",
"OrderedDict",
"(",
")",
"self",
".",
"pillar_linked_dirs",
"=",
"[",
"]",
"for",
"repo",
"in",
"self",
".",
"remotes",
":",
"cachedir",
"=",
"self",
".",
"do_checkout",
"(",
"r... | Checkout the targeted branches/tags from the git_pillar remotes | [
"Checkout",
"the",
"targeted",
"branches",
"/",
"tags",
"from",
"the",
"git_pillar",
"remotes"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L3015-L3042 | train |
saltstack/salt | salt/utils/gitfs.py | GitPillar.link_mountpoint | def link_mountpoint(self, repo):
'''
Ensure that the mountpoint is present in the correct location and
points at the correct path
'''
lcachelink = salt.utils.path.join(repo.linkdir, repo._mountpoint)
lcachedest = salt.utils.path.join(repo.cachedir, repo.root()).rstrip(os.... | python | def link_mountpoint(self, repo):
'''
Ensure that the mountpoint is present in the correct location and
points at the correct path
'''
lcachelink = salt.utils.path.join(repo.linkdir, repo._mountpoint)
lcachedest = salt.utils.path.join(repo.cachedir, repo.root()).rstrip(os.... | [
"def",
"link_mountpoint",
"(",
"self",
",",
"repo",
")",
":",
"lcachelink",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"join",
"(",
"repo",
".",
"linkdir",
",",
"repo",
".",
"_mountpoint",
")",
"lcachedest",
"=",
"salt",
".",
"utils",
".",
"path",
... | Ensure that the mountpoint is present in the correct location and
points at the correct path | [
"Ensure",
"that",
"the",
"mountpoint",
"is",
"present",
"in",
"the",
"correct",
"location",
"and",
"points",
"at",
"the",
"correct",
"path"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L3044-L3156 | train |
saltstack/salt | salt/utils/gitfs.py | WinRepo.checkout | def checkout(self):
'''
Checkout the targeted branches/tags from the winrepo remotes
'''
self.winrepo_dirs = {}
for repo in self.remotes:
cachedir = self.do_checkout(repo)
if cachedir is not None:
self.winrepo_dirs[repo.id] = cachedir | python | def checkout(self):
'''
Checkout the targeted branches/tags from the winrepo remotes
'''
self.winrepo_dirs = {}
for repo in self.remotes:
cachedir = self.do_checkout(repo)
if cachedir is not None:
self.winrepo_dirs[repo.id] = cachedir | [
"def",
"checkout",
"(",
"self",
")",
":",
"self",
".",
"winrepo_dirs",
"=",
"{",
"}",
"for",
"repo",
"in",
"self",
".",
"remotes",
":",
"cachedir",
"=",
"self",
".",
"do_checkout",
"(",
"repo",
")",
"if",
"cachedir",
"is",
"not",
"None",
":",
"self",... | Checkout the targeted branches/tags from the winrepo remotes | [
"Checkout",
"the",
"targeted",
"branches",
"/",
"tags",
"from",
"the",
"winrepo",
"remotes"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L3168-L3176 | train |
saltstack/salt | salt/fileserver/minionfs.py | _is_exposed | def _is_exposed(minion):
'''
Check if the minion is exposed, based on the whitelist and blacklist
'''
return salt.utils.stringutils.check_whitelist_blacklist(
minion,
whitelist=__opts__['minionfs_whitelist'],
blacklist=__opts__['minionfs_blacklist']
) | python | def _is_exposed(minion):
'''
Check if the minion is exposed, based on the whitelist and blacklist
'''
return salt.utils.stringutils.check_whitelist_blacklist(
minion,
whitelist=__opts__['minionfs_whitelist'],
blacklist=__opts__['minionfs_blacklist']
) | [
"def",
"_is_exposed",
"(",
"minion",
")",
":",
"return",
"salt",
".",
"utils",
".",
"stringutils",
".",
"check_whitelist_blacklist",
"(",
"minion",
",",
"whitelist",
"=",
"__opts__",
"[",
"'minionfs_whitelist'",
"]",
",",
"blacklist",
"=",
"__opts__",
"[",
"'m... | Check if the minion is exposed, based on the whitelist and blacklist | [
"Check",
"if",
"the",
"minion",
"is",
"exposed",
"based",
"on",
"the",
"whitelist",
"and",
"blacklist"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/minionfs.py#L65-L73 | train |
saltstack/salt | salt/fileserver/minionfs.py | find_file | def find_file(path, tgt_env='base', **kwargs): # pylint: disable=W0613
'''
Search the environment for the relative path
'''
fnd = {'path': '', 'rel': ''}
if os.path.isabs(path):
return fnd
if tgt_env not in envs():
return fnd
if os.path.basename(path) == 'top.sls':
l... | python | def find_file(path, tgt_env='base', **kwargs): # pylint: disable=W0613
'''
Search the environment for the relative path
'''
fnd = {'path': '', 'rel': ''}
if os.path.isabs(path):
return fnd
if tgt_env not in envs():
return fnd
if os.path.basename(path) == 'top.sls':
l... | [
"def",
"find_file",
"(",
"path",
",",
"tgt_env",
"=",
"'base'",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=W0613",
"fnd",
"=",
"{",
"'path'",
":",
"''",
",",
"'rel'",
":",
"''",
"}",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"path",
")... | Search the environment for the relative path | [
"Search",
"the",
"environment",
"for",
"the",
"relative",
"path"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/minionfs.py#L76-L110 | train |
saltstack/salt | salt/fileserver/minionfs.py | update | def update():
'''
When we are asked to update (regular interval) lets reap the cache
'''
try:
salt.fileserver.reap_fileserver_cache_dir(
os.path.join(__opts__['cachedir'], 'minionfs/hash'),
find_file)
except os.error:
# Hash file won't exist if no files have y... | python | def update():
'''
When we are asked to update (regular interval) lets reap the cache
'''
try:
salt.fileserver.reap_fileserver_cache_dir(
os.path.join(__opts__['cachedir'], 'minionfs/hash'),
find_file)
except os.error:
# Hash file won't exist if no files have y... | [
"def",
"update",
"(",
")",
":",
"try",
":",
"salt",
".",
"fileserver",
".",
"reap_fileserver_cache_dir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"__opts__",
"[",
"'cachedir'",
"]",
",",
"'minionfs/hash'",
")",
",",
"find_file",
")",
"except",
"os",
"."... | When we are asked to update (regular interval) lets reap the cache | [
"When",
"we",
"are",
"asked",
"to",
"update",
"(",
"regular",
"interval",
")",
"lets",
"reap",
"the",
"cache"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/minionfs.py#L155-L165 | train |
saltstack/salt | salt/fileserver/minionfs.py | file_hash | def file_hash(load, fnd):
'''
Return a file hash, the hash type is set in the master config file
'''
path = fnd['path']
ret = {}
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if load['saltenv'] not in envs():
return {}
# if the file... | python | def file_hash(load, fnd):
'''
Return a file hash, the hash type is set in the master config file
'''
path = fnd['path']
ret = {}
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if load['saltenv'] not in envs():
return {}
# if the file... | [
"def",
"file_hash",
"(",
"load",
",",
"fnd",
")",
":",
"path",
"=",
"fnd",
"[",
"'path'",
"]",
"ret",
"=",
"{",
"}",
"if",
"'env'",
"in",
"load",
":",
"# \"env\" is not supported; Use \"saltenv\".",
"load",
".",
"pop",
"(",
"'env'",
")",
"if",
"load",
... | Return a file hash, the hash type is set in the master config file | [
"Return",
"a",
"file",
"hash",
"the",
"hash",
"type",
"is",
"set",
"in",
"the",
"master",
"config",
"file"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/minionfs.py#L168-L234 | train |
saltstack/salt | salt/fileserver/minionfs.py | file_list | def file_list(load):
'''
Return a list of all files on the file server in a specified environment
'''
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if load['saltenv'] not in envs():
return []
mountpoint = salt.utils.url.strip_proto(__opts__['... | python | def file_list(load):
'''
Return a list of all files on the file server in a specified environment
'''
if 'env' in load:
# "env" is not supported; Use "saltenv".
load.pop('env')
if load['saltenv'] not in envs():
return []
mountpoint = salt.utils.url.strip_proto(__opts__['... | [
"def",
"file_list",
"(",
"load",
")",
":",
"if",
"'env'",
"in",
"load",
":",
"# \"env\" is not supported; Use \"saltenv\".",
"load",
".",
"pop",
"(",
"'env'",
")",
"if",
"load",
"[",
"'saltenv'",
"]",
"not",
"in",
"envs",
"(",
")",
":",
"return",
"[",
"]... | Return a list of all files on the file server in a specified environment | [
"Return",
"a",
"list",
"of",
"all",
"files",
"on",
"the",
"file",
"server",
"in",
"a",
"specified",
"environment"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileserver/minionfs.py#L237-L299 | train |
saltstack/salt | salt/modules/trafficserver.py | _subprocess | def _subprocess(cmd):
'''
Function to standardize the subprocess call
'''
log.debug('Running: "%s"', ' '.join(cmd))
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
ret = salt.utils.stringutils.to_unicode(proc.communicate()[0]).strip()
retcode = proc.wait()
... | python | def _subprocess(cmd):
'''
Function to standardize the subprocess call
'''
log.debug('Running: "%s"', ' '.join(cmd))
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
ret = salt.utils.stringutils.to_unicode(proc.communicate()[0]).strip()
retcode = proc.wait()
... | [
"def",
"_subprocess",
"(",
"cmd",
")",
":",
"log",
".",
"debug",
"(",
"'Running: \"%s\"'",
",",
"' '",
".",
"join",
"(",
"cmd",
")",
")",
"try",
":",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
... | Function to standardize the subprocess call | [
"Function",
"to",
"standardize",
"the",
"subprocess",
"call"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/trafficserver.py#L53-L72 | train |
saltstack/salt | salt/modules/trafficserver.py | bounce_local | def bounce_local(drain=False):
'''
Bounce Traffic Server on the local node. Bouncing Traffic Server shuts down
and immediately restarts the Traffic Server node.
drain
This option modifies the restart behavior such that traffic_server
is not shut down until the number of active client co... | python | def bounce_local(drain=False):
'''
Bounce Traffic Server on the local node. Bouncing Traffic Server shuts down
and immediately restarts the Traffic Server node.
drain
This option modifies the restart behavior such that traffic_server
is not shut down until the number of active client co... | [
"def",
"bounce_local",
"(",
"drain",
"=",
"False",
")",
":",
"if",
"_TRAFFICCTL",
":",
"cmd",
"=",
"_traffic_ctl",
"(",
"'server'",
",",
"'restart'",
")",
"else",
":",
"cmd",
"=",
"_traffic_line",
"(",
"'-b'",
")",
"if",
"drain",
":",
"cmd",
"=",
"cmd"... | Bounce Traffic Server on the local node. Bouncing Traffic Server shuts down
and immediately restarts the Traffic Server node.
drain
This option modifies the restart behavior such that traffic_server
is not shut down until the number of active client connections
drops to the number given... | [
"Bounce",
"Traffic",
"Server",
"on",
"the",
"local",
"node",
".",
"Bouncing",
"Traffic",
"Server",
"shuts",
"down",
"and",
"immediately",
"restarts",
"the",
"Traffic",
"Server",
"node",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/trafficserver.py#L93-L118 | train |
saltstack/salt | salt/modules/trafficserver.py | restart_local | def restart_local(drain=False):
'''
Restart the traffic_manager and traffic_server processes on the local node.
drain
This option modifies the restart behavior such that
``traffic_server`` is not shut down until the number of
active client connections drops to the number given by th... | python | def restart_local(drain=False):
'''
Restart the traffic_manager and traffic_server processes on the local node.
drain
This option modifies the restart behavior such that
``traffic_server`` is not shut down until the number of
active client connections drops to the number given by th... | [
"def",
"restart_local",
"(",
"drain",
"=",
"False",
")",
":",
"if",
"_TRAFFICCTL",
":",
"cmd",
"=",
"_traffic_ctl",
"(",
"'server'",
",",
"'restart'",
",",
"'--manager'",
")",
"else",
":",
"cmd",
"=",
"_traffic_line",
"(",
"'-L'",
")",
"if",
"drain",
":"... | Restart the traffic_manager and traffic_server processes on the local node.
drain
This option modifies the restart behavior such that
``traffic_server`` is not shut down until the number of
active client connections drops to the number given by the
``proxy.config.restart.active_clie... | [
"Restart",
"the",
"traffic_manager",
"and",
"traffic_server",
"processes",
"on",
"the",
"local",
"node",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/trafficserver.py#L173-L197 | train |
saltstack/salt | salt/modules/trafficserver.py | match_metric | def match_metric(regex):
'''
Display the current values of all metrics whose names match the
given regular expression.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.match_metric regex
'''
if _TRAFFICCTL:
cmd = _traffic_ctl('metric', 'match', regex... | python | def match_metric(regex):
'''
Display the current values of all metrics whose names match the
given regular expression.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.match_metric regex
'''
if _TRAFFICCTL:
cmd = _traffic_ctl('metric', 'match', regex... | [
"def",
"match_metric",
"(",
"regex",
")",
":",
"if",
"_TRAFFICCTL",
":",
"cmd",
"=",
"_traffic_ctl",
"(",
"'metric'",
",",
"'match'",
",",
"regex",
")",
"else",
":",
"cmd",
"=",
"_traffic_ctl",
"(",
"'-m'",
",",
"regex",
")",
"return",
"_subprocess",
"("... | Display the current values of all metrics whose names match the
given regular expression.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.match_metric regex | [
"Display",
"the",
"current",
"values",
"of",
"all",
"metrics",
"whose",
"names",
"match",
"the",
"given",
"regular",
"expression",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/trafficserver.py#L200-L216 | train |
saltstack/salt | salt/modules/trafficserver.py | match_config | def match_config(regex):
'''
Display the current values of all configuration variables whose
names match the given regular expression.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.match_config regex
'''
if _TRAFFICCTL:
cmd = _traffic_ctl('config'... | python | def match_config(regex):
'''
Display the current values of all configuration variables whose
names match the given regular expression.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.match_config regex
'''
if _TRAFFICCTL:
cmd = _traffic_ctl('config'... | [
"def",
"match_config",
"(",
"regex",
")",
":",
"if",
"_TRAFFICCTL",
":",
"cmd",
"=",
"_traffic_ctl",
"(",
"'config'",
",",
"'match'",
",",
"regex",
")",
"else",
":",
"cmd",
"=",
"_traffic_line",
"(",
"'-m'",
",",
"regex",
")",
"return",
"_subprocess",
"(... | Display the current values of all configuration variables whose
names match the given regular expression.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.match_config regex | [
"Display",
"the",
"current",
"values",
"of",
"all",
"configuration",
"variables",
"whose",
"names",
"match",
"the",
"given",
"regular",
"expression",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/trafficserver.py#L219-L235 | train |
saltstack/salt | salt/modules/trafficserver.py | read_config | def read_config(*args):
'''
Read Traffic Server configuration variable definitions.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.read_config proxy.config.http.keep_alive_post_out
'''
ret = {}
if _TRAFFICCTL:
cmd = _traffic_ctl('config', 'get')
... | python | def read_config(*args):
'''
Read Traffic Server configuration variable definitions.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.read_config proxy.config.http.keep_alive_post_out
'''
ret = {}
if _TRAFFICCTL:
cmd = _traffic_ctl('config', 'get')
... | [
"def",
"read_config",
"(",
"*",
"args",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"_TRAFFICCTL",
":",
"cmd",
"=",
"_traffic_ctl",
"(",
"'config'",
",",
"'get'",
")",
"else",
":",
"cmd",
"=",
"_traffic_line",
"(",
"'-r'",
")",
"try",
":",
"for",
"arg",
... | Read Traffic Server configuration variable definitions.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.read_config proxy.config.http.keep_alive_post_out | [
"Read",
"Traffic",
"Server",
"configuration",
"variable",
"definitions",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/trafficserver.py#L238-L262 | train |
saltstack/salt | salt/modules/trafficserver.py | set_config | def set_config(variable, value):
'''
Set the value of a Traffic Server configuration variable.
variable
Name of a Traffic Server configuration variable.
value
The new value to set.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.set_config pro... | python | def set_config(variable, value):
'''
Set the value of a Traffic Server configuration variable.
variable
Name of a Traffic Server configuration variable.
value
The new value to set.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.set_config pro... | [
"def",
"set_config",
"(",
"variable",
",",
"value",
")",
":",
"if",
"_TRAFFICCTL",
":",
"cmd",
"=",
"_traffic_ctl",
"(",
"'config'",
",",
"'set'",
",",
"variable",
",",
"value",
")",
"else",
":",
"cmd",
"=",
"_traffic_line",
"(",
"'-s'",
",",
"variable",... | Set the value of a Traffic Server configuration variable.
variable
Name of a Traffic Server configuration variable.
value
The new value to set.
.. versionadded:: 2016.11.0
.. code-block:: bash
salt '*' trafficserver.set_config proxy.config.http.keep_alive_post_out 0 | [
"Set",
"the",
"value",
"of",
"a",
"Traffic",
"Server",
"configuration",
"variable",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/trafficserver.py#L292-L315 | train |
saltstack/salt | salt/modules/trafficserver.py | offline | def offline(path):
'''
Mark a cache storage device as offline. The storage is identified by a path
which must match exactly a path specified in storage.config. This removes
the storage from the cache and redirects requests that would have used this
storage to other storage. This has exactly the same... | python | def offline(path):
'''
Mark a cache storage device as offline. The storage is identified by a path
which must match exactly a path specified in storage.config. This removes
the storage from the cache and redirects requests that would have used this
storage to other storage. This has exactly the same... | [
"def",
"offline",
"(",
"path",
")",
":",
"if",
"_TRAFFICCTL",
":",
"cmd",
"=",
"_traffic_ctl",
"(",
"'storage'",
",",
"'offline'",
",",
"path",
")",
"else",
":",
"cmd",
"=",
"_traffic_line",
"(",
"'--offline'",
",",
"path",
")",
"return",
"_subprocess",
... | Mark a cache storage device as offline. The storage is identified by a path
which must match exactly a path specified in storage.config. This removes
the storage from the cache and redirects requests that would have used this
storage to other storage. This has exactly the same effect as a disk
failure f... | [
"Mark",
"a",
"cache",
"storage",
"device",
"as",
"offline",
".",
"The",
"storage",
"is",
"identified",
"by",
"a",
"path",
"which",
"must",
"match",
"exactly",
"a",
"path",
"specified",
"in",
"storage",
".",
"config",
".",
"This",
"removes",
"the",
"storage... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/trafficserver.py#L411-L430 | train |
saltstack/salt | salt/modules/trafficserver.py | clear_alarms | def clear_alarms(alarm):
'''
Clear (acknowledge) an alarm event. The arguments are “all” for all current
alarms, a specific alarm number (e.g. ‘‘1’‘), or an alarm string identifier
(e.g. ‘’MGMT_ALARM_PROXY_CONFIG_ERROR’‘).
.. code-block:: bash
salt '*' trafficserver.clear_alarms [all | #ev... | python | def clear_alarms(alarm):
'''
Clear (acknowledge) an alarm event. The arguments are “all” for all current
alarms, a specific alarm number (e.g. ‘‘1’‘), or an alarm string identifier
(e.g. ‘’MGMT_ALARM_PROXY_CONFIG_ERROR’‘).
.. code-block:: bash
salt '*' trafficserver.clear_alarms [all | #ev... | [
"def",
"clear_alarms",
"(",
"alarm",
")",
":",
"if",
"_TRAFFICCTL",
":",
"cmd",
"=",
"_traffic_ctl",
"(",
"'alarm'",
",",
"'clear'",
",",
"alarm",
")",
"else",
":",
"cmd",
"=",
"_traffic_line",
"(",
"'--clear_alarms'",
",",
"alarm",
")",
"return",
"_subpro... | Clear (acknowledge) an alarm event. The arguments are “all” for all current
alarms, a specific alarm number (e.g. ‘‘1’‘), or an alarm string identifier
(e.g. ‘’MGMT_ALARM_PROXY_CONFIG_ERROR’‘).
.. code-block:: bash
salt '*' trafficserver.clear_alarms [all | #event | name] | [
"Clear",
"(",
"acknowledge",
")",
"an",
"alarm",
"event",
".",
"The",
"arguments",
"are",
"“all”",
"for",
"all",
"current",
"alarms",
"a",
"specific",
"alarm",
"number",
"(",
"e",
".",
"g",
".",
"‘‘1’‘",
")",
"or",
"an",
"alarm",
"string",
"identifier",
... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/trafficserver.py#L450-L466 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | node_state | def node_state(id_):
'''
Libcloud supported node states
'''
states_int = {
0: 'RUNNING',
1: 'REBOOTING',
2: 'TERMINATED',
3: 'PENDING',
4: 'UNKNOWN',
5: 'STOPPED',
6: 'SUSPENDED',
7: 'ERROR',
8: 'PAUSED'}
states_str = {
... | python | def node_state(id_):
'''
Libcloud supported node states
'''
states_int = {
0: 'RUNNING',
1: 'REBOOTING',
2: 'TERMINATED',
3: 'PENDING',
4: 'UNKNOWN',
5: 'STOPPED',
6: 'SUSPENDED',
7: 'ERROR',
8: 'PAUSED'}
states_str = {
... | [
"def",
"node_state",
"(",
"id_",
")",
":",
"states_int",
"=",
"{",
"0",
":",
"'RUNNING'",
",",
"1",
":",
"'REBOOTING'",
",",
"2",
":",
"'TERMINATED'",
",",
"3",
":",
"'PENDING'",
",",
"4",
":",
"'UNKNOWN'",
",",
"5",
":",
"'STOPPED'",
",",
"6",
":"... | Libcloud supported node states | [
"Libcloud",
"supported",
"node",
"states"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L54-L82 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | check_libcloud_version | def check_libcloud_version(reqver=LIBCLOUD_MINIMAL_VERSION, why=None):
'''
Compare different libcloud versions
'''
if not HAS_LIBCLOUD:
return False
if not isinstance(reqver, (list, tuple)):
raise RuntimeError(
'\'reqver\' needs to passed as a tuple or list, i.e., (0, 14... | python | def check_libcloud_version(reqver=LIBCLOUD_MINIMAL_VERSION, why=None):
'''
Compare different libcloud versions
'''
if not HAS_LIBCLOUD:
return False
if not isinstance(reqver, (list, tuple)):
raise RuntimeError(
'\'reqver\' needs to passed as a tuple or list, i.e., (0, 14... | [
"def",
"check_libcloud_version",
"(",
"reqver",
"=",
"LIBCLOUD_MINIMAL_VERSION",
",",
"why",
"=",
"None",
")",
":",
"if",
"not",
"HAS_LIBCLOUD",
":",
"return",
"False",
"if",
"not",
"isinstance",
"(",
"reqver",
",",
"(",
"list",
",",
"tuple",
")",
")",
":"... | Compare different libcloud versions | [
"Compare",
"different",
"libcloud",
"versions"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L85-L115 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | get_node | def get_node(conn, name):
'''
Return a libcloud node for the named VM
'''
nodes = conn.list_nodes()
for node in nodes:
if node.name == name:
__utils__['cloud.cache_node'](salt.utils.data.simple_types_filter(node.__dict__), __active_provider_name__, __opts__)
return no... | python | def get_node(conn, name):
'''
Return a libcloud node for the named VM
'''
nodes = conn.list_nodes()
for node in nodes:
if node.name == name:
__utils__['cloud.cache_node'](salt.utils.data.simple_types_filter(node.__dict__), __active_provider_name__, __opts__)
return no... | [
"def",
"get_node",
"(",
"conn",
",",
"name",
")",
":",
"nodes",
"=",
"conn",
".",
"list_nodes",
"(",
")",
"for",
"node",
"in",
"nodes",
":",
"if",
"node",
".",
"name",
"==",
"name",
":",
"__utils__",
"[",
"'cloud.cache_node'",
"]",
"(",
"salt",
".",
... | Return a libcloud node for the named VM | [
"Return",
"a",
"libcloud",
"node",
"for",
"the",
"named",
"VM"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L118-L126 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | avail_locations | def avail_locations(conn=None, call=None):
'''
Return a dict of all available VM locations on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_locations function must be called with '
'-f or --function, or with the -... | python | def avail_locations(conn=None, call=None):
'''
Return a dict of all available VM locations on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_locations function must be called with '
'-f or --function, or with the -... | [
"def",
"avail_locations",
"(",
"conn",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The avail_locations function must be called with '",
"'-f or --function, or with the --list-locations option'"... | Return a dict of all available VM locations on the cloud provider with
relevant data | [
"Return",
"a",
"dict",
"of",
"all",
"available",
"VM",
"locations",
"on",
"the",
"cloud",
"provider",
"with",
"relevant",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L129-L163 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | avail_images | def avail_images(conn=None, call=None):
'''
Return a dict of all available VM images on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_images function must be called with '
'-f or --function, or with the --list-ima... | python | def avail_images(conn=None, call=None):
'''
Return a dict of all available VM images on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_images function must be called with '
'-f or --function, or with the --list-ima... | [
"def",
"avail_images",
"(",
"conn",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The avail_images function must be called with '",
"'-f or --function, or with the --list-images option'",
")",
... | Return a dict of all available VM images on the cloud provider with
relevant data | [
"Return",
"a",
"dict",
"of",
"all",
"available",
"VM",
"images",
"on",
"the",
"cloud",
"provider",
"with",
"relevant",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L166-L198 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | avail_sizes | def avail_sizes(conn=None, call=None):
'''
Return a dict of all available VM images on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_sizes function must be called with '
'-f or --function, or with the --list-sizes... | python | def avail_sizes(conn=None, call=None):
'''
Return a dict of all available VM images on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_sizes function must be called with '
'-f or --function, or with the --list-sizes... | [
"def",
"avail_sizes",
"(",
"conn",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The avail_sizes function must be called with '",
"'-f or --function, or with the --list-sizes option'",
")",
"... | Return a dict of all available VM images on the cloud provider with
relevant data | [
"Return",
"a",
"dict",
"of",
"all",
"available",
"VM",
"images",
"on",
"the",
"cloud",
"provider",
"with",
"relevant",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L201-L238 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | get_location | def get_location(conn, vm_):
'''
Return the location object to use
'''
locations = conn.list_locations()
vm_location = config.get_cloud_config_value('location', vm_, __opts__)
if not six.PY3:
vm_location = vm_location.encode(
'ascii', 'salt-cloud-force-ascii'
)
f... | python | def get_location(conn, vm_):
'''
Return the location object to use
'''
locations = conn.list_locations()
vm_location = config.get_cloud_config_value('location', vm_, __opts__)
if not six.PY3:
vm_location = vm_location.encode(
'ascii', 'salt-cloud-force-ascii'
)
f... | [
"def",
"get_location",
"(",
"conn",
",",
"vm_",
")",
":",
"locations",
"=",
"conn",
".",
"list_locations",
"(",
")",
"vm_location",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'location'",
",",
"vm_",
",",
"__opts__",
")",
"if",
"not",
"six",
".",
... | Return the location object to use | [
"Return",
"the",
"location",
"object",
"to",
"use"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L241-L270 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | get_image | def get_image(conn, vm_):
'''
Return the image object to use
'''
images = conn.list_images()
vm_image = config.get_cloud_config_value('image', vm_, __opts__)
if not six.PY3:
vm_image = vm_image.encode('ascii', 'salt-cloud-force-ascii')
for img in images:
if isinstance(img.i... | python | def get_image(conn, vm_):
'''
Return the image object to use
'''
images = conn.list_images()
vm_image = config.get_cloud_config_value('image', vm_, __opts__)
if not six.PY3:
vm_image = vm_image.encode('ascii', 'salt-cloud-force-ascii')
for img in images:
if isinstance(img.i... | [
"def",
"get_image",
"(",
"conn",
",",
"vm_",
")",
":",
"images",
"=",
"conn",
".",
"list_images",
"(",
")",
"vm_image",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'image'",
",",
"vm_",
",",
"__opts__",
")",
"if",
"not",
"six",
".",
"PY3",
":",... | Return the image object to use | [
"Return",
"the",
"image",
"object",
"to",
"use"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L273-L299 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | get_size | def get_size(conn, vm_):
'''
Return the VM's size object
'''
sizes = conn.list_sizes()
vm_size = config.get_cloud_config_value('size', vm_, __opts__)
if not vm_size:
return sizes[0]
for size in sizes:
if vm_size and str(vm_size) in (str(size.id), str(size.name)): # pylint: ... | python | def get_size(conn, vm_):
'''
Return the VM's size object
'''
sizes = conn.list_sizes()
vm_size = config.get_cloud_config_value('size', vm_, __opts__)
if not vm_size:
return sizes[0]
for size in sizes:
if vm_size and str(vm_size) in (str(size.id), str(size.name)): # pylint: ... | [
"def",
"get_size",
"(",
"conn",
",",
"vm_",
")",
":",
"sizes",
"=",
"conn",
".",
"list_sizes",
"(",
")",
"vm_size",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'size'",
",",
"vm_",
",",
"__opts__",
")",
"if",
"not",
"vm_size",
":",
"return",
"s... | Return the VM's size object | [
"Return",
"the",
"VM",
"s",
"size",
"object"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L302-L316 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | destroy | def destroy(name, conn=None, call=None):
'''
Delete a single VM
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -d, --destroy, '
'-a or --action.'
)
__utils__['cloud.fire_event'](
'event',
'destroy... | python | def destroy(name, conn=None, call=None):
'''
Delete a single VM
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -d, --destroy, '
'-a or --action.'
)
__utils__['cloud.fire_event'](
'event',
'destroy... | [
"def",
"destroy",
"(",
"name",
",",
"conn",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'function'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The destroy action must be called with -d, --destroy, '",
"'-a or --action.'",
")",
"__utils__"... | Delete a single VM | [
"Delete",
"a",
"single",
"VM"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L335-L409 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | reboot | def reboot(name, conn=None):
'''
Reboot a single VM
'''
if not conn:
conn = get_conn() # pylint: disable=E0602
node = get_node(conn, name)
if node is None:
log.error('Unable to find the VM %s', name)
log.info('Rebooting VM: %s', name)
ret = conn.reboot_node(node)
i... | python | def reboot(name, conn=None):
'''
Reboot a single VM
'''
if not conn:
conn = get_conn() # pylint: disable=E0602
node = get_node(conn, name)
if node is None:
log.error('Unable to find the VM %s', name)
log.info('Rebooting VM: %s', name)
ret = conn.reboot_node(node)
i... | [
"def",
"reboot",
"(",
"name",
",",
"conn",
"=",
"None",
")",
":",
"if",
"not",
"conn",
":",
"conn",
"=",
"get_conn",
"(",
")",
"# pylint: disable=E0602",
"node",
"=",
"get_node",
"(",
"conn",
",",
"name",
")",
"if",
"node",
"is",
"None",
":",
"log",
... | Reboot a single VM | [
"Reboot",
"a",
"single",
"VM"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L412-L438 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | list_nodes | def list_nodes(conn=None, call=None):
'''
Return a list of the VMs that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes function must be called with -f or --function.'
)
if not conn:
conn = get_conn() # pylint: disable=E0... | python | def list_nodes(conn=None, call=None):
'''
Return a list of the VMs that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes function must be called with -f or --function.'
)
if not conn:
conn = get_conn() # pylint: disable=E0... | [
"def",
"list_nodes",
"(",
"conn",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_nodes function must be called with -f or --function.'",
")",
"if",
"not",
"conn",
":",
"conn",
... | Return a list of the VMs that are on the provider | [
"Return",
"a",
"list",
"of",
"the",
"VMs",
"that",
"are",
"on",
"the",
"provider"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L441-L465 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | list_nodes_full | def list_nodes_full(conn=None, call=None):
'''
Return a list of the VMs that are on the provider, with all fields
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_full function must be called with -f or --function.'
)
if not conn:
conn = get_co... | python | def list_nodes_full(conn=None, call=None):
'''
Return a list of the VMs that are on the provider, with all fields
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_full function must be called with -f or --function.'
)
if not conn:
conn = get_co... | [
"def",
"list_nodes_full",
"(",
"conn",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_nodes_full function must be called with -f or --function.'",
")",
"if",
"not",
"conn",
":",
... | Return a list of the VMs that are on the provider, with all fields | [
"Return",
"a",
"list",
"of",
"the",
"VMs",
"that",
"are",
"on",
"the",
"provider",
"with",
"all",
"fields"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L468-L490 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | list_nodes_select | def list_nodes_select(conn=None, call=None):
'''
Return a list of the VMs that are on the provider, with select fields
'''
if not conn:
conn = get_conn() # pylint: disable=E0602
return salt.utils.cloud.list_nodes_select(
list_nodes_full(conn, 'function'), __opts__['query.selection... | python | def list_nodes_select(conn=None, call=None):
'''
Return a list of the VMs that are on the provider, with select fields
'''
if not conn:
conn = get_conn() # pylint: disable=E0602
return salt.utils.cloud.list_nodes_select(
list_nodes_full(conn, 'function'), __opts__['query.selection... | [
"def",
"list_nodes_select",
"(",
"conn",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"not",
"conn",
":",
"conn",
"=",
"get_conn",
"(",
")",
"# pylint: disable=E0602",
"return",
"salt",
".",
"utils",
".",
"cloud",
".",
"list_nodes_select",
"(",
... | 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/cloud/libcloudfuncs.py#L493-L502 | train |
saltstack/salt | salt/cloud/libcloudfuncs.py | conn_has_method | def conn_has_method(conn, method_name):
'''
Find if the provided connection object has a specific method
'''
if method_name in dir(conn):
return True
log.error('Method \'%s\' not yet supported!', method_name)
return False | python | def conn_has_method(conn, method_name):
'''
Find if the provided connection object has a specific method
'''
if method_name in dir(conn):
return True
log.error('Method \'%s\' not yet supported!', method_name)
return False | [
"def",
"conn_has_method",
"(",
"conn",
",",
"method_name",
")",
":",
"if",
"method_name",
"in",
"dir",
"(",
"conn",
")",
":",
"return",
"True",
"log",
".",
"error",
"(",
"'Method \\'%s\\' not yet supported!'",
",",
"method_name",
")",
"return",
"False"
] | Find if the provided connection object has a specific method | [
"Find",
"if",
"the",
"provided",
"connection",
"object",
"has",
"a",
"specific",
"method"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/libcloudfuncs.py#L519-L527 | train |
saltstack/salt | salt/modules/influxdbmod.py | db_exists | def db_exists(name, **client_args):
'''
Checks if a database exists in InfluxDB.
name
Name of the database to check.
CLI Example:
.. code-block:: bash
salt '*' influxdb.db_exists <name>
'''
if name in [db['name'] for db in list_dbs(**client_args)]:
return True
... | python | def db_exists(name, **client_args):
'''
Checks if a database exists in InfluxDB.
name
Name of the database to check.
CLI Example:
.. code-block:: bash
salt '*' influxdb.db_exists <name>
'''
if name in [db['name'] for db in list_dbs(**client_args)]:
return True
... | [
"def",
"db_exists",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"if",
"name",
"in",
"[",
"db",
"[",
"'name'",
"]",
"for",
"db",
"in",
"list_dbs",
"(",
"*",
"*",
"client_args",
")",
"]",
":",
"return",
"True",
"return",
"False"
] | Checks if a database exists in InfluxDB.
name
Name of the database to check.
CLI Example:
.. code-block:: bash
salt '*' influxdb.db_exists <name> | [
"Checks",
"if",
"a",
"database",
"exists",
"in",
"InfluxDB",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L95-L111 | train |
saltstack/salt | salt/modules/influxdbmod.py | create_db | def create_db(name, **client_args):
'''
Create a database.
name
Name of the database to create.
CLI Example:
.. code-block:: bash
salt '*' influxdb.create_db <name>
'''
if db_exists(name, **client_args):
log.info('DB \'%s\' already exists', name)
return Fa... | python | def create_db(name, **client_args):
'''
Create a database.
name
Name of the database to create.
CLI Example:
.. code-block:: bash
salt '*' influxdb.create_db <name>
'''
if db_exists(name, **client_args):
log.info('DB \'%s\' already exists', name)
return Fa... | [
"def",
"create_db",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"if",
"db_exists",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"log",
".",
"info",
"(",
"'DB \\'%s\\' already exists'",
",",
"name",
")",
"return",
"False",
"client",
"=",
... | Create a database.
name
Name of the database to create.
CLI Example:
.. code-block:: bash
salt '*' influxdb.create_db <name> | [
"Create",
"a",
"database",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L114-L134 | train |
saltstack/salt | salt/modules/influxdbmod.py | drop_db | def drop_db(name, **client_args):
'''
Drop a database.
name
Name of the database to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_db <name>
'''
if not db_exists(name, **client_args):
log.info('DB \'%s\' does not exist', name)
return False
... | python | def drop_db(name, **client_args):
'''
Drop a database.
name
Name of the database to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_db <name>
'''
if not db_exists(name, **client_args):
log.info('DB \'%s\' does not exist', name)
return False
... | [
"def",
"drop_db",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"if",
"not",
"db_exists",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"log",
".",
"info",
"(",
"'DB \\'%s\\' does not exist'",
",",
"name",
")",
"return",
"False",
"client",
... | Drop a database.
name
Name of the database to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_db <name> | [
"Drop",
"a",
"database",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L137-L157 | train |
saltstack/salt | salt/modules/influxdbmod.py | user_info | def user_info(name, **client_args):
'''
Get information about given user.
name
Name of the user for which to get information.
CLI Example:
.. code-block:: bash
salt '*' influxdb.user_info <name>
'''
matching_users = (user for user in list_users(**client_args)
... | python | def user_info(name, **client_args):
'''
Get information about given user.
name
Name of the user for which to get information.
CLI Example:
.. code-block:: bash
salt '*' influxdb.user_info <name>
'''
matching_users = (user for user in list_users(**client_args)
... | [
"def",
"user_info",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"matching_users",
"=",
"(",
"user",
"for",
"user",
"in",
"list_users",
"(",
"*",
"*",
"client_args",
")",
"if",
"user",
".",
"get",
"(",
"'user'",
")",
"==",
"name",
")",
"try",... | Get information about given user.
name
Name of the user for which to get information.
CLI Example:
.. code-block:: bash
salt '*' influxdb.user_info <name> | [
"Get",
"information",
"about",
"given",
"user",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L194-L213 | train |
saltstack/salt | salt/modules/influxdbmod.py | create_user | def create_user(name, passwd, admin=False, **client_args):
'''
Create a user.
name
Name of the user to create.
passwd
Password of the new user.
admin : False
Whether the user should have cluster administration
privileges or not.
CLI Example:
.. code-block... | python | def create_user(name, passwd, admin=False, **client_args):
'''
Create a user.
name
Name of the user to create.
passwd
Password of the new user.
admin : False
Whether the user should have cluster administration
privileges or not.
CLI Example:
.. code-block... | [
"def",
"create_user",
"(",
"name",
",",
"passwd",
",",
"admin",
"=",
"False",
",",
"*",
"*",
"client_args",
")",
":",
"if",
"user_exists",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"log",
".",
"info",
"(",
"\"User '%s' already exists\"",
",",
... | Create a user.
name
Name of the user to create.
passwd
Password of the new user.
admin : False
Whether the user should have cluster administration
privileges or not.
CLI Example:
.. code-block:: bash
salt '*' influxdb.create_user <name> <password>
... | [
"Create",
"a",
"user",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L216-L244 | train |
saltstack/salt | salt/modules/influxdbmod.py | set_user_password | def set_user_password(name, passwd, **client_args):
'''
Change password of a user.
name
Name of the user for whom to set the password.
passwd
New password of the user.
CLI Example:
.. code-block:: bash
salt '*' influxdb.set_user_password <name> <password>
'''
... | python | def set_user_password(name, passwd, **client_args):
'''
Change password of a user.
name
Name of the user for whom to set the password.
passwd
New password of the user.
CLI Example:
.. code-block:: bash
salt '*' influxdb.set_user_password <name> <password>
'''
... | [
"def",
"set_user_password",
"(",
"name",
",",
"passwd",
",",
"*",
"*",
"client_args",
")",
":",
"if",
"not",
"user_exists",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"log",
".",
"info",
"(",
"'User \\'%s\\' does not exist'",
",",
"name",
")",
... | Change password of a user.
name
Name of the user for whom to set the password.
passwd
New password of the user.
CLI Example:
.. code-block:: bash
salt '*' influxdb.set_user_password <name> <password> | [
"Change",
"password",
"of",
"a",
"user",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L247-L270 | train |
saltstack/salt | salt/modules/influxdbmod.py | grant_admin_privileges | def grant_admin_privileges(name, **client_args):
'''
Grant cluster administration privileges to a user.
name
Name of the user to whom admin privileges will be granted.
CLI Example:
.. code-block:: bash
salt '*' influxdb.grant_admin_privileges <name>
'''
client = _client(*... | python | def grant_admin_privileges(name, **client_args):
'''
Grant cluster administration privileges to a user.
name
Name of the user to whom admin privileges will be granted.
CLI Example:
.. code-block:: bash
salt '*' influxdb.grant_admin_privileges <name>
'''
client = _client(*... | [
"def",
"grant_admin_privileges",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"client",
".",
"grant_admin_privileges",
"(",
"name",
")",
"return",
"True"
] | Grant cluster administration privileges to a user.
name
Name of the user to whom admin privileges will be granted.
CLI Example:
.. code-block:: bash
salt '*' influxdb.grant_admin_privileges <name> | [
"Grant",
"cluster",
"administration",
"privileges",
"to",
"a",
"user",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L273-L289 | train |
saltstack/salt | salt/modules/influxdbmod.py | revoke_admin_privileges | def revoke_admin_privileges(name, **client_args):
'''
Revoke cluster administration privileges from a user.
name
Name of the user from whom admin privileges will be revoked.
CLI Example:
.. code-block:: bash
salt '*' influxdb.revoke_admin_privileges <name>
'''
client = _c... | python | def revoke_admin_privileges(name, **client_args):
'''
Revoke cluster administration privileges from a user.
name
Name of the user from whom admin privileges will be revoked.
CLI Example:
.. code-block:: bash
salt '*' influxdb.revoke_admin_privileges <name>
'''
client = _c... | [
"def",
"revoke_admin_privileges",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"client",
".",
"revoke_admin_privileges",
"(",
"name",
")",
"return",
"True"
] | Revoke cluster administration privileges from a user.
name
Name of the user from whom admin privileges will be revoked.
CLI Example:
.. code-block:: bash
salt '*' influxdb.revoke_admin_privileges <name> | [
"Revoke",
"cluster",
"administration",
"privileges",
"from",
"a",
"user",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L292-L308 | train |
saltstack/salt | salt/modules/influxdbmod.py | remove_user | def remove_user(name, **client_args):
'''
Remove a user.
name
Name of the user to remove
CLI Example:
.. code-block:: bash
salt '*' influxdb.remove_user <name>
'''
if not user_exists(name, **client_args):
log.info('User \'%s\' does not exist', name)
return... | python | def remove_user(name, **client_args):
'''
Remove a user.
name
Name of the user to remove
CLI Example:
.. code-block:: bash
salt '*' influxdb.remove_user <name>
'''
if not user_exists(name, **client_args):
log.info('User \'%s\' does not exist', name)
return... | [
"def",
"remove_user",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"if",
"not",
"user_exists",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"log",
".",
"info",
"(",
"'User \\'%s\\' does not exist'",
",",
"name",
")",
"return",
"False",
"c... | Remove a user.
name
Name of the user to remove
CLI Example:
.. code-block:: bash
salt '*' influxdb.remove_user <name> | [
"Remove",
"a",
"user",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L311-L331 | train |
saltstack/salt | salt/modules/influxdbmod.py | get_retention_policy | def get_retention_policy(database, name, **client_args):
'''
Get an existing retention policy.
database
Name of the database for which the retention policy was
defined.
name
Name of the retention policy.
CLI Example:
.. code-block:: bash
salt '*' influxdb.get... | python | def get_retention_policy(database, name, **client_args):
'''
Get an existing retention policy.
database
Name of the database for which the retention policy was
defined.
name
Name of the retention policy.
CLI Example:
.. code-block:: bash
salt '*' influxdb.get... | [
"def",
"get_retention_policy",
"(",
"database",
",",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"try",
":",
"return",
"next",
"(",
"(",
"p",
"for",
"p",
"in",
"client",
".",
"get_list_re... | Get an existing retention policy.
database
Name of the database for which the retention policy was
defined.
name
Name of the retention policy.
CLI Example:
.. code-block:: bash
salt '*' influxdb.get_retention_policy metrics default | [
"Get",
"an",
"existing",
"retention",
"policy",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L334-L357 | train |
saltstack/salt | salt/modules/influxdbmod.py | retention_policy_exists | def retention_policy_exists(database, name, **client_args):
'''
Check if retention policy with given name exists.
database
Name of the database for which the retention policy was
defined.
name
Name of the retention policy to check.
CLI Example:
.. code-block:: bash
... | python | def retention_policy_exists(database, name, **client_args):
'''
Check if retention policy with given name exists.
database
Name of the database for which the retention policy was
defined.
name
Name of the retention policy to check.
CLI Example:
.. code-block:: bash
... | [
"def",
"retention_policy_exists",
"(",
"database",
",",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"if",
"get_retention_policy",
"(",
"database",
",",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"return",
"True",
"return",
"False"
] | Check if retention policy with given name exists.
database
Name of the database for which the retention policy was
defined.
name
Name of the retention policy to check.
CLI Example:
.. code-block:: bash
salt '*' influxdb.retention_policy_exists metrics default | [
"Check",
"if",
"retention",
"policy",
"with",
"given",
"name",
"exists",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L360-L380 | train |
saltstack/salt | salt/modules/influxdbmod.py | drop_retention_policy | def drop_retention_policy(database, name, **client_args):
'''
Drop a retention policy.
database
Name of the database for which the retention policy will be dropped.
name
Name of the retention policy to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_re... | python | def drop_retention_policy(database, name, **client_args):
'''
Drop a retention policy.
database
Name of the database for which the retention policy will be dropped.
name
Name of the retention policy to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_re... | [
"def",
"drop_retention_policy",
"(",
"database",
",",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"client",
".",
"drop_retention_policy",
"(",
"name",
",",
"database",
")",
"return",
"True"
] | Drop a retention policy.
database
Name of the database for which the retention policy will be dropped.
name
Name of the retention policy to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_retention_policy mydb mypr | [
"Drop",
"a",
"retention",
"policy",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L383-L402 | train |
saltstack/salt | salt/modules/influxdbmod.py | create_retention_policy | def create_retention_policy(database,
name,
duration,
replication,
default=False,
**client_args):
'''
Create a retention policy.
database
Name of the database ... | python | def create_retention_policy(database,
name,
duration,
replication,
default=False,
**client_args):
'''
Create a retention policy.
database
Name of the database ... | [
"def",
"create_retention_policy",
"(",
"database",
",",
"name",
",",
"duration",
",",
"replication",
",",
"default",
"=",
"False",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"client",
".",
"create_r... | Create a retention policy.
database
Name of the database for which the retention policy will be created.
name
Name of the new retention policy.
duration
Duration of the new retention policy.
Durations such as 1h, 90m, 12h, 7d, and 4w, are all supported and mean
1 ... | [
"Create",
"a",
"retention",
"policy",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L405-L447 | train |
saltstack/salt | salt/modules/influxdbmod.py | list_privileges | def list_privileges(name, **client_args):
'''
List privileges from a user.
name
Name of the user from whom privileges will be listed.
CLI Example:
.. code-block:: bash
salt '*' influxdb.list_privileges <name>
'''
client = _client(**client_args)
res = {}
for item ... | python | def list_privileges(name, **client_args):
'''
List privileges from a user.
name
Name of the user from whom privileges will be listed.
CLI Example:
.. code-block:: bash
salt '*' influxdb.list_privileges <name>
'''
client = _client(**client_args)
res = {}
for item ... | [
"def",
"list_privileges",
"(",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"res",
"=",
"{",
"}",
"for",
"item",
"in",
"client",
".",
"get_list_privileges",
"(",
"name",
")",
":",
"res",
... | List privileges from a user.
name
Name of the user from whom privileges will be listed.
CLI Example:
.. code-block:: bash
salt '*' influxdb.list_privileges <name> | [
"List",
"privileges",
"from",
"a",
"user",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L495-L513 | train |
saltstack/salt | salt/modules/influxdbmod.py | grant_privilege | def grant_privilege(database, privilege, username, **client_args):
'''
Grant a privilege on a database to a user.
database
Name of the database to grant the privilege on.
privilege
Privilege to grant. Can be one of 'read', 'write' or 'all'.
username
Name of the user to gra... | python | def grant_privilege(database, privilege, username, **client_args):
'''
Grant a privilege on a database to a user.
database
Name of the database to grant the privilege on.
privilege
Privilege to grant. Can be one of 'read', 'write' or 'all'.
username
Name of the user to gra... | [
"def",
"grant_privilege",
"(",
"database",
",",
"privilege",
",",
"username",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"client",
".",
"grant_privilege",
"(",
"privilege",
",",
"database",
",",
"us... | Grant a privilege on a database to a user.
database
Name of the database to grant the privilege on.
privilege
Privilege to grant. Can be one of 'read', 'write' or 'all'.
username
Name of the user to grant the privilege to. | [
"Grant",
"a",
"privilege",
"on",
"a",
"database",
"to",
"a",
"user",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L516-L532 | train |
saltstack/salt | salt/modules/influxdbmod.py | revoke_privilege | def revoke_privilege(database, privilege, username, **client_args):
'''
Revoke a privilege on a database from a user.
database
Name of the database to grant the privilege on.
privilege
Privilege to grant. Can be one of 'read', 'write' or 'all'.
username
Name of the user to... | python | def revoke_privilege(database, privilege, username, **client_args):
'''
Revoke a privilege on a database from a user.
database
Name of the database to grant the privilege on.
privilege
Privilege to grant. Can be one of 'read', 'write' or 'all'.
username
Name of the user to... | [
"def",
"revoke_privilege",
"(",
"database",
",",
"privilege",
",",
"username",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"client",
".",
"revoke_privilege",
"(",
"privilege",
",",
"database",
",",
"... | Revoke a privilege on a database from a user.
database
Name of the database to grant the privilege on.
privilege
Privilege to grant. Can be one of 'read', 'write' or 'all'.
username
Name of the user to grant the privilege to. | [
"Revoke",
"a",
"privilege",
"on",
"a",
"database",
"from",
"a",
"user",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L535-L551 | train |
saltstack/salt | salt/modules/influxdbmod.py | continuous_query_exists | def continuous_query_exists(database, name, **client_args):
'''
Check if continuous query with given name exists on the database.
database
Name of the database for which the continuous query was
defined.
name
Name of the continuous query to check.
CLI Example:
.. code... | python | def continuous_query_exists(database, name, **client_args):
'''
Check if continuous query with given name exists on the database.
database
Name of the database for which the continuous query was
defined.
name
Name of the continuous query to check.
CLI Example:
.. code... | [
"def",
"continuous_query_exists",
"(",
"database",
",",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"if",
"get_continuous_query",
"(",
"database",
",",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"return",
"True",
"return",
"False"
] | Check if continuous query with given name exists on the database.
database
Name of the database for which the continuous query was
defined.
name
Name of the continuous query to check.
CLI Example:
.. code-block:: bash
salt '*' influxdb.continuous_query_exists metrics... | [
"Check",
"if",
"continuous",
"query",
"with",
"given",
"name",
"exists",
"on",
"the",
"database",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L554-L574 | train |
saltstack/salt | salt/modules/influxdbmod.py | get_continuous_query | def get_continuous_query(database, name, **client_args):
'''
Get an existing continuous query.
database
Name of the database for which the continuous query was
defined.
name
Name of the continuous query to get.
CLI Example:
.. code-block:: bash
salt '*' influ... | python | def get_continuous_query(database, name, **client_args):
'''
Get an existing continuous query.
database
Name of the database for which the continuous query was
defined.
name
Name of the continuous query to get.
CLI Example:
.. code-block:: bash
salt '*' influ... | [
"def",
"get_continuous_query",
"(",
"database",
",",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"try",
":",
"for",
"db",
",",
"cqs",
"in",
"client",
".",
"query",
"(",
"'SHOW CONTINUOUS QU... | Get an existing continuous query.
database
Name of the database for which the continuous query was
defined.
name
Name of the continuous query to get.
CLI Example:
.. code-block:: bash
salt '*' influxdb.get_continuous_query mydb cq_month | [
"Get",
"an",
"existing",
"continuous",
"query",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L577-L602 | train |
saltstack/salt | salt/modules/influxdbmod.py | create_continuous_query | def create_continuous_query(database, name, query, resample_time=None, coverage_period=None, **client_args):
'''
Create a continuous query.
database
Name of the database for which the continuous query will be
created on.
name
Name of the continuous query to create.
query
... | python | def create_continuous_query(database, name, query, resample_time=None, coverage_period=None, **client_args):
'''
Create a continuous query.
database
Name of the database for which the continuous query will be
created on.
name
Name of the continuous query to create.
query
... | [
"def",
"create_continuous_query",
"(",
"database",
",",
"name",
",",
"query",
",",
"resample_time",
"=",
"None",
",",
"coverage_period",
"=",
"None",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"full... | Create a continuous query.
database
Name of the database for which the continuous query will be
created on.
name
Name of the continuous query to create.
query
The continuous query string.
resample_time : None
Duration between continuous query resampling.
... | [
"Create",
"a",
"continuous",
"query",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L605-L645 | train |
saltstack/salt | salt/modules/influxdbmod.py | drop_continuous_query | def drop_continuous_query(database, name, **client_args):
'''
Drop a continuous query.
database
Name of the database for which the continuous query will
be drop from.
name
Name of the continuous query to drop.
CLI Example:
.. code-block:: bash
salt '*' influx... | python | def drop_continuous_query(database, name, **client_args):
'''
Drop a continuous query.
database
Name of the database for which the continuous query will
be drop from.
name
Name of the continuous query to drop.
CLI Example:
.. code-block:: bash
salt '*' influx... | [
"def",
"drop_continuous_query",
"(",
"database",
",",
"name",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"query",
"=",
"'DROP CONTINUOUS QUERY {0} ON {1}'",
".",
"format",
"(",
"name",
",",
"database",
... | Drop a continuous query.
database
Name of the database for which the continuous query will
be drop from.
name
Name of the continuous query to drop.
CLI Example:
.. code-block:: bash
salt '*' influxdb.drop_continuous_query mydb my_cq | [
"Drop",
"a",
"continuous",
"query",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L648-L669 | train |
saltstack/salt | salt/modules/influxdbmod.py | _pull_query_results | def _pull_query_results(resultset):
'''
Parses a ResultSet returned from InfluxDB into a dictionary of results,
grouped by series names and optional JSON-encoded grouping tags.
'''
_results = collections.defaultdict(lambda: {})
for _header, _values in resultset.items():
_header, _group_t... | python | def _pull_query_results(resultset):
'''
Parses a ResultSet returned from InfluxDB into a dictionary of results,
grouped by series names and optional JSON-encoded grouping tags.
'''
_results = collections.defaultdict(lambda: {})
for _header, _values in resultset.items():
_header, _group_t... | [
"def",
"_pull_query_results",
"(",
"resultset",
")",
":",
"_results",
"=",
"collections",
".",
"defaultdict",
"(",
"lambda",
":",
"{",
"}",
")",
"for",
"_header",
",",
"_values",
"in",
"resultset",
".",
"items",
"(",
")",
":",
"_header",
",",
"_group_tags"... | Parses a ResultSet returned from InfluxDB into a dictionary of results,
grouped by series names and optional JSON-encoded grouping tags. | [
"Parses",
"a",
"ResultSet",
"returned",
"from",
"InfluxDB",
"into",
"a",
"dictionary",
"of",
"results",
"grouped",
"by",
"series",
"names",
"and",
"optional",
"JSON",
"-",
"encoded",
"grouping",
"tags",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L672-L684 | train |
saltstack/salt | salt/modules/influxdbmod.py | query | def query(database, query, **client_args):
'''
Execute a query.
database
Name of the database to query on.
query
InfluxQL query string.
'''
client = _client(**client_args)
_result = client.query(query, database=database)
if isinstance(_result, collections.Sequence):
... | python | def query(database, query, **client_args):
'''
Execute a query.
database
Name of the database to query on.
query
InfluxQL query string.
'''
client = _client(**client_args)
_result = client.query(query, database=database)
if isinstance(_result, collections.Sequence):
... | [
"def",
"query",
"(",
"database",
",",
"query",
",",
"*",
"*",
"client_args",
")",
":",
"client",
"=",
"_client",
"(",
"*",
"*",
"client_args",
")",
"_result",
"=",
"client",
".",
"query",
"(",
"query",
",",
"database",
"=",
"database",
")",
"if",
"is... | Execute a query.
database
Name of the database to query on.
query
InfluxQL query string. | [
"Execute",
"a",
"query",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L687-L702 | train |
saltstack/salt | salt/utils/listdiffer.py | ListDictDiffer._get_recursive_difference | def _get_recursive_difference(self, type):
'''Returns the recursive diff between dict values'''
if type == 'intersect':
return [recursive_diff(item['old'], item['new']) for item in self._intersect]
elif type == 'added':
return [recursive_diff({}, item) for item in self._a... | python | def _get_recursive_difference(self, type):
'''Returns the recursive diff between dict values'''
if type == 'intersect':
return [recursive_diff(item['old'], item['new']) for item in self._intersect]
elif type == 'added':
return [recursive_diff({}, item) for item in self._a... | [
"def",
"_get_recursive_difference",
"(",
"self",
",",
"type",
")",
":",
"if",
"type",
"==",
"'intersect'",
":",
"return",
"[",
"recursive_diff",
"(",
"item",
"[",
"'old'",
"]",
",",
"item",
"[",
"'new'",
"]",
")",
"for",
"item",
"in",
"self",
".",
"_in... | Returns the recursive diff between dict values | [
"Returns",
"the",
"recursive",
"diff",
"between",
"dict",
"values"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/listdiffer.py#L69-L88 | train |
saltstack/salt | salt/utils/listdiffer.py | ListDictDiffer.remove_diff | def remove_diff(self, diff_key=None, diff_list='intersect'):
'''Deletes an attribute from all of the intersect objects'''
if diff_list == 'intersect':
for item in self._intersect:
item['old'].pop(diff_key, None)
item['new'].pop(diff_key, None)
if diff_... | python | def remove_diff(self, diff_key=None, diff_list='intersect'):
'''Deletes an attribute from all of the intersect objects'''
if diff_list == 'intersect':
for item in self._intersect:
item['old'].pop(diff_key, None)
item['new'].pop(diff_key, None)
if diff_... | [
"def",
"remove_diff",
"(",
"self",
",",
"diff_key",
"=",
"None",
",",
"diff_list",
"=",
"'intersect'",
")",
":",
"if",
"diff_list",
"==",
"'intersect'",
":",
"for",
"item",
"in",
"self",
".",
"_intersect",
":",
"item",
"[",
"'old'",
"]",
".",
"pop",
"(... | Deletes an attribute from all of the intersect objects | [
"Deletes",
"an",
"attribute",
"from",
"all",
"of",
"the",
"intersect",
"objects"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/listdiffer.py#L105-L113 | train |
saltstack/salt | salt/utils/listdiffer.py | ListDictDiffer.diffs | def diffs(self):
'''
Returns a list of dictionaries with key value pairs.
The values are the differences between the items identified by the key.
'''
differences = []
for item in self._get_recursive_difference(type='all'):
if item.diffs:
if ite... | python | def diffs(self):
'''
Returns a list of dictionaries with key value pairs.
The values are the differences between the items identified by the key.
'''
differences = []
for item in self._get_recursive_difference(type='all'):
if item.diffs:
if ite... | [
"def",
"diffs",
"(",
"self",
")",
":",
"differences",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
".",
"_get_recursive_difference",
"(",
"type",
"=",
"'all'",
")",
":",
"if",
"item",
".",
"diffs",
":",
"if",
"item",
".",
"past_dict",
":",
"differences"... | Returns a list of dictionaries with key value pairs.
The values are the differences between the items identified by the key. | [
"Returns",
"a",
"list",
"of",
"dictionaries",
"with",
"key",
"value",
"pairs",
".",
"The",
"values",
"are",
"the",
"differences",
"between",
"the",
"items",
"identified",
"by",
"the",
"key",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/listdiffer.py#L116-L128 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.