repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
tarbell-project/tarbell | tarbell/cli.py | tarbell_spreadsheet | def tarbell_spreadsheet(command, args):
"""
Open context spreadsheet
"""
with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
try:
# First, try to get the Google Spreadsheet URL
spreadsheet_url = _google_spreadsheet_url(site.project.SPRE... | python | def tarbell_spreadsheet(command, args):
"""
Open context spreadsheet
"""
with ensure_settings(command, args) as settings, ensure_project(command, args) as site:
try:
# First, try to get the Google Spreadsheet URL
spreadsheet_url = _google_spreadsheet_url(site.project.SPRE... | [
"def",
"tarbell_spreadsheet",
"(",
"command",
",",
"args",
")",
":",
"with",
"ensure_settings",
"(",
"command",
",",
"args",
")",
"as",
"settings",
",",
"ensure_project",
"(",
"command",
",",
"args",
")",
"as",
"site",
":",
"try",
":",
"# First, try to get t... | Open context spreadsheet | [
"Open",
"context",
"spreadsheet"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L507-L535 |
tarbell-project/tarbell | tarbell/cli.py | _context_source_file_url | def _context_source_file_url(path_or_url):
"""
Returns a URL for a remote or local context CSV file
"""
if path_or_url.startswith('http'):
# Remote CSV. Just return the URL
return path_or_url
if path_or_url.startswith('/'):
# Absolute path
return "file://" + path_or_... | python | def _context_source_file_url(path_or_url):
"""
Returns a URL for a remote or local context CSV file
"""
if path_or_url.startswith('http'):
# Remote CSV. Just return the URL
return path_or_url
if path_or_url.startswith('/'):
# Absolute path
return "file://" + path_or_... | [
"def",
"_context_source_file_url",
"(",
"path_or_url",
")",
":",
"if",
"path_or_url",
".",
"startswith",
"(",
"'http'",
")",
":",
"# Remote CSV. Just return the URL",
"return",
"path_or_url",
"if",
"path_or_url",
".",
"startswith",
"(",
"'/'",
")",
":",
"# Absolute ... | Returns a URL for a remote or local context CSV file | [
"Returns",
"a",
"URL",
"for",
"a",
"remote",
"or",
"local",
"context",
"CSV",
"file"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L547-L559 |
tarbell-project/tarbell | tarbell/cli.py | _newproject | def _newproject(command, path, name, settings):
"""
Helper to create new project.
"""
key = None
title = _get_project_title()
template = _get_template(settings)
# Init repo
git = sh.git.bake(_cwd=path)
puts(git.init())
if template.get("url"):
# Create submodule
... | python | def _newproject(command, path, name, settings):
"""
Helper to create new project.
"""
key = None
title = _get_project_title()
template = _get_template(settings)
# Init repo
git = sh.git.bake(_cwd=path)
puts(git.init())
if template.get("url"):
# Create submodule
... | [
"def",
"_newproject",
"(",
"command",
",",
"path",
",",
"name",
",",
"settings",
")",
":",
"key",
"=",
"None",
"title",
"=",
"_get_project_title",
"(",
")",
"template",
"=",
"_get_template",
"(",
"settings",
")",
"# Init repo",
"git",
"=",
"sh",
".",
"gi... | Helper to create new project. | [
"Helper",
"to",
"create",
"new",
"project",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L563-L620 |
tarbell-project/tarbell | tarbell/cli.py | _install_requirements | def _install_requirements(path):
"""
Install a blueprint's requirements.txt
"""
locations = [os.path.join(path, "_blueprint"), os.path.join(path, "_base"), path]
success = True
for location in locations:
try:
with open(os.path.join(location, "requirements.txt")):
... | python | def _install_requirements(path):
"""
Install a blueprint's requirements.txt
"""
locations = [os.path.join(path, "_blueprint"), os.path.join(path, "_base"), path]
success = True
for location in locations:
try:
with open(os.path.join(location, "requirements.txt")):
... | [
"def",
"_install_requirements",
"(",
"path",
")",
":",
"locations",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"\"_blueprint\"",
")",
",",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"\"_base\"",
")",
",",
"path",
"]",
"success... | Install a blueprint's requirements.txt | [
"Install",
"a",
"blueprint",
"s",
"requirements",
".",
"txt"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L623-L645 |
tarbell-project/tarbell | tarbell/cli.py | _get_project_name | def _get_project_name(args):
"""
Get project name.
"""
name = args.get(0)
puts("")
while not name:
name = raw_input("What is the project's short directory name? (e.g. my_project) ")
return name | python | def _get_project_name(args):
"""
Get project name.
"""
name = args.get(0)
puts("")
while not name:
name = raw_input("What is the project's short directory name? (e.g. my_project) ")
return name | [
"def",
"_get_project_name",
"(",
"args",
")",
":",
"name",
"=",
"args",
".",
"get",
"(",
"0",
")",
"puts",
"(",
"\"\"",
")",
"while",
"not",
"name",
":",
"name",
"=",
"raw_input",
"(",
"\"What is the project's short directory name? (e.g. my_project) \"",
")",
... | Get project name. | [
"Get",
"project",
"name",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L648-L656 |
tarbell-project/tarbell | tarbell/cli.py | _clean_suffix | def _clean_suffix(string, suffix):
"""
If string endswith the suffix, remove it. Else leave it alone.
"""
suffix_len = len(suffix)
if len(string) < suffix_len:
# the string param was shorter than the suffix
raise ValueError("A suffix can not be bigger than string argument.")
if ... | python | def _clean_suffix(string, suffix):
"""
If string endswith the suffix, remove it. Else leave it alone.
"""
suffix_len = len(suffix)
if len(string) < suffix_len:
# the string param was shorter than the suffix
raise ValueError("A suffix can not be bigger than string argument.")
if ... | [
"def",
"_clean_suffix",
"(",
"string",
",",
"suffix",
")",
":",
"suffix_len",
"=",
"len",
"(",
"suffix",
")",
"if",
"len",
"(",
"string",
")",
"<",
"suffix_len",
":",
"# the string param was shorter than the suffix",
"raise",
"ValueError",
"(",
"\"A suffix can not... | If string endswith the suffix, remove it. Else leave it alone. | [
"If",
"string",
"endswith",
"the",
"suffix",
"remove",
"it",
".",
"Else",
"leave",
"it",
"alone",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L671-L687 |
tarbell-project/tarbell | tarbell/cli.py | _get_path | def _get_path(name, settings, mkdir=True):
"""
Generate a project path.
"""
default_projects_path = settings.config.get("projects_path")
path = None
if default_projects_path:
path = raw_input("\nWhere would you like to create this project? [{0}/{1}] ".format(default_projects_path, name)... | python | def _get_path(name, settings, mkdir=True):
"""
Generate a project path.
"""
default_projects_path = settings.config.get("projects_path")
path = None
if default_projects_path:
path = raw_input("\nWhere would you like to create this project? [{0}/{1}] ".format(default_projects_path, name)... | [
"def",
"_get_path",
"(",
"name",
",",
"settings",
",",
"mkdir",
"=",
"True",
")",
":",
"default_projects_path",
"=",
"settings",
".",
"config",
".",
"get",
"(",
"\"projects_path\"",
")",
"path",
"=",
"None",
"if",
"default_projects_path",
":",
"path",
"=",
... | Generate a project path. | [
"Generate",
"a",
"project",
"path",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L690-L705 |
tarbell-project/tarbell | tarbell/cli.py | _mkdir | def _mkdir(path):
"""
Make a directory or bail.
"""
try:
os.mkdir(path)
except OSError as e:
if e.errno == 17:
show_error("ABORTING: Directory {0} already exists.".format(path))
else:
show_error("ABORTING: OSError {0}".format(e))
sys.exit() | python | def _mkdir(path):
"""
Make a directory or bail.
"""
try:
os.mkdir(path)
except OSError as e:
if e.errno == 17:
show_error("ABORTING: Directory {0} already exists.".format(path))
else:
show_error("ABORTING: OSError {0}".format(e))
sys.exit() | [
"def",
"_mkdir",
"(",
"path",
")",
":",
"try",
":",
"os",
".",
"mkdir",
"(",
"path",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"==",
"17",
":",
"show_error",
"(",
"\"ABORTING: Directory {0} already exists.\"",
".",
"format",
"(",... | Make a directory or bail. | [
"Make",
"a",
"directory",
"or",
"bail",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L708-L719 |
tarbell-project/tarbell | tarbell/cli.py | _get_template | def _get_template(settings):
"""
Prompt user to pick template from a list.
"""
puts("\nPick a template\n")
template = None
while not template:
_list_templates(settings)
index = raw_input("\nWhich template would you like to use? [1] ")
if not index:
index = "1"... | python | def _get_template(settings):
"""
Prompt user to pick template from a list.
"""
puts("\nPick a template\n")
template = None
while not template:
_list_templates(settings)
index = raw_input("\nWhich template would you like to use? [1] ")
if not index:
index = "1"... | [
"def",
"_get_template",
"(",
"settings",
")",
":",
"puts",
"(",
"\"\\nPick a template\\n\"",
")",
"template",
"=",
"None",
"while",
"not",
"template",
":",
"_list_templates",
"(",
"settings",
")",
"index",
"=",
"raw_input",
"(",
"\"\\nWhich template would you like t... | Prompt user to pick template from a list. | [
"Prompt",
"user",
"to",
"pick",
"template",
"from",
"a",
"list",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L722-L738 |
tarbell-project/tarbell | tarbell/cli.py | _list_templates | def _list_templates(settings):
"""
List templates from settings.
"""
for idx, option in enumerate(settings.config.get("project_templates"), start=1):
puts(" {0!s:5} {1!s:36}".format(
colored.yellow("[{0}]".format(idx)),
colored.cyan(option.get("name"))
))
... | python | def _list_templates(settings):
"""
List templates from settings.
"""
for idx, option in enumerate(settings.config.get("project_templates"), start=1):
puts(" {0!s:5} {1!s:36}".format(
colored.yellow("[{0}]".format(idx)),
colored.cyan(option.get("name"))
))
... | [
"def",
"_list_templates",
"(",
"settings",
")",
":",
"for",
"idx",
",",
"option",
"in",
"enumerate",
"(",
"settings",
".",
"config",
".",
"get",
"(",
"\"project_templates\"",
")",
",",
"start",
"=",
"1",
")",
":",
"puts",
"(",
"\" {0!s:5} {1!s:36}\"",
"."... | List templates from settings. | [
"List",
"templates",
"from",
"settings",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L741-L751 |
tarbell-project/tarbell | tarbell/cli.py | _create_spreadsheet | def _create_spreadsheet(name, title, path, settings):
"""
Create Google spreadsheet.
"""
if not settings.client_secrets:
return None
create = raw_input("Would you like to create a Google spreadsheet? [Y/n] ")
if create and not create.lower() == "y":
return puts("Not creating sp... | python | def _create_spreadsheet(name, title, path, settings):
"""
Create Google spreadsheet.
"""
if not settings.client_secrets:
return None
create = raw_input("Would you like to create a Google spreadsheet? [Y/n] ")
if create and not create.lower() == "y":
return puts("Not creating sp... | [
"def",
"_create_spreadsheet",
"(",
"name",
",",
"title",
",",
"path",
",",
"settings",
")",
":",
"if",
"not",
"settings",
".",
"client_secrets",
":",
"return",
"None",
"create",
"=",
"raw_input",
"(",
"\"Would you like to create a Google spreadsheet? [Y/n] \"",
")",... | Create Google spreadsheet. | [
"Create",
"Google",
"spreadsheet",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L754-L808 |
tarbell-project/tarbell | tarbell/cli.py | _add_user_to_file | def _add_user_to_file(file_id, service, user_email,
perm_type='user', role='writer'):
"""
Grants the given set of permissions for a given file_id. service is an
already-credentialed Google Drive service instance.
"""
new_permission = {
'value': user_email,
'type... | python | def _add_user_to_file(file_id, service, user_email,
perm_type='user', role='writer'):
"""
Grants the given set of permissions for a given file_id. service is an
already-credentialed Google Drive service instance.
"""
new_permission = {
'value': user_email,
'type... | [
"def",
"_add_user_to_file",
"(",
"file_id",
",",
"service",
",",
"user_email",
",",
"perm_type",
"=",
"'user'",
",",
"role",
"=",
"'writer'",
")",
":",
"new_permission",
"=",
"{",
"'value'",
":",
"user_email",
",",
"'type'",
":",
"perm_type",
",",
"'role'",
... | Grants the given set of permissions for a given file_id. service is an
already-credentialed Google Drive service instance. | [
"Grants",
"the",
"given",
"set",
"of",
"permissions",
"for",
"a",
"given",
"file_id",
".",
"service",
"is",
"an",
"already",
"-",
"credentialed",
"Google",
"Drive",
"service",
"instance",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L811-L827 |
tarbell-project/tarbell | tarbell/cli.py | _copy_config_template | def _copy_config_template(name, title, template, path, key, settings):
"""
Get and render tarbell_config.py.template from Tarbell default.
"""
puts("\nCopying configuration file")
context = settings.config
context.update({
"default_context": {
... | python | def _copy_config_template(name, title, template, path, key, settings):
"""
Get and render tarbell_config.py.template from Tarbell default.
"""
puts("\nCopying configuration file")
context = settings.config
context.update({
"default_context": {
... | [
"def",
"_copy_config_template",
"(",
"name",
",",
"title",
",",
"template",
",",
"path",
",",
"key",
",",
"settings",
")",
":",
"puts",
"(",
"\"\\nCopying configuration file\"",
")",
"context",
"=",
"settings",
".",
"config",
"context",
".",
"update",
"(",
"... | Get and render tarbell_config.py.template from Tarbell default. | [
"Get",
"and",
"render",
"tarbell_config",
".",
"py",
".",
"template",
"from",
"Tarbell",
"default",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L830-L878 |
tarbell-project/tarbell | tarbell/cli.py | _delete_dir | def _delete_dir(dir):
"""
Delete a directory.
"""
try:
shutil.rmtree(dir) # delete directory
except OSError as exc:
if exc.errno != 2: # code 2 - no such file or directory
raise # re-raise exception
except UnboundLocalError:
pass | python | def _delete_dir(dir):
"""
Delete a directory.
"""
try:
shutil.rmtree(dir) # delete directory
except OSError as exc:
if exc.errno != 2: # code 2 - no such file or directory
raise # re-raise exception
except UnboundLocalError:
pass | [
"def",
"_delete_dir",
"(",
"dir",
")",
":",
"try",
":",
"shutil",
".",
"rmtree",
"(",
"dir",
")",
"# delete directory",
"except",
"OSError",
"as",
"exc",
":",
"if",
"exc",
".",
"errno",
"!=",
"2",
":",
"# code 2 - no such file or directory",
"raise",
"# re-r... | Delete a directory. | [
"Delete",
"a",
"directory",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L881-L891 |
tarbell-project/tarbell | tarbell/cli.py | def_cmd | def def_cmd(name=None, short=None, fn=None, usage=None, help=None):
"""
Define a command.
"""
command = Command(name=name, short=short, fn=fn, usage=usage, help=help)
Command.register(command) | python | def def_cmd(name=None, short=None, fn=None, usage=None, help=None):
"""
Define a command.
"""
command = Command(name=name, short=short, fn=fn, usage=usage, help=help)
Command.register(command) | [
"def",
"def_cmd",
"(",
"name",
"=",
"None",
",",
"short",
"=",
"None",
",",
"fn",
"=",
"None",
",",
"usage",
"=",
"None",
",",
"help",
"=",
"None",
")",
":",
"command",
"=",
"Command",
"(",
"name",
"=",
"name",
",",
"short",
"=",
"short",
",",
... | Define a command. | [
"Define",
"a",
"command",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/cli.py#L933-L938 |
tarbell-project/tarbell | tarbell/settings.py | Settings.save | def save(self):
"""
Save settings.
"""
with open(self.path, "w") as f:
self.config["project_templates"] = list(filter(lambda template: template.get("url"), self.config["project_templates"]))
yaml.dump(self.config, f, default_flow_style=False) | python | def save(self):
"""
Save settings.
"""
with open(self.path, "w") as f:
self.config["project_templates"] = list(filter(lambda template: template.get("url"), self.config["project_templates"]))
yaml.dump(self.config, f, default_flow_style=False) | [
"def",
"save",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"path",
",",
"\"w\"",
")",
"as",
"f",
":",
"self",
".",
"config",
"[",
"\"project_templates\"",
"]",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"template",
":",
"template",
".",
... | Save settings. | [
"Save",
"settings",
"."
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/settings.py#L49-L55 |
tarbell-project/tarbell | tarbell/template.py | read_file | def read_file(path, absolute=False, encoding='utf-8'):
"""
Read the file at `path`. If `absolute` is True, use absolute path,
otherwise path is assumed to be relative to Tarbell template root dir.
For example:
.. code-block:: html+jinja
<div class="chapter">
{{ read_fi... | python | def read_file(path, absolute=False, encoding='utf-8'):
"""
Read the file at `path`. If `absolute` is True, use absolute path,
otherwise path is assumed to be relative to Tarbell template root dir.
For example:
.. code-block:: html+jinja
<div class="chapter">
{{ read_fi... | [
"def",
"read_file",
"(",
"path",
",",
"absolute",
"=",
"False",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"site",
"=",
"g",
".",
"current_site",
"if",
"not",
"absolute",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"site",
".",
"path",
"... | Read the file at `path`. If `absolute` is True, use absolute path,
otherwise path is assumed to be relative to Tarbell template root dir.
For example:
.. code-block:: html+jinja
<div class="chapter">
{{ read_file('_chapters/one.txt')|linebreaks }}
</div> | [
"Read",
"the",
"file",
"at",
"path",
".",
"If",
"absolute",
"is",
"True",
"use",
"absolute",
"path",
"otherwise",
"path",
"is",
"assumed",
"to",
"be",
"relative",
"to",
"Tarbell",
"template",
"root",
"dir",
".",
"For",
"example",
":"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/template.py#L89-L109 |
tarbell-project/tarbell | tarbell/template.py | render_file | def render_file(context, path, absolute=False):
"""
Like :py:func:`read_file`, except that the file is rendered as a Jinja template
using the current context. If `absolute` is True, use absolute path, otherwise
path is assumed to be relative to Tarbell template root dir.
For example:
... | python | def render_file(context, path, absolute=False):
"""
Like :py:func:`read_file`, except that the file is rendered as a Jinja template
using the current context. If `absolute` is True, use absolute path, otherwise
path is assumed to be relative to Tarbell template root dir.
For example:
... | [
"def",
"render_file",
"(",
"context",
",",
"path",
",",
"absolute",
"=",
"False",
")",
":",
"site",
"=",
"g",
".",
"current_site",
"if",
"not",
"absolute",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"site",
".",
"path",
",",
"path",
")"... | Like :py:func:`read_file`, except that the file is rendered as a Jinja template
using the current context. If `absolute` is True, use absolute path, otherwise
path is assumed to be relative to Tarbell template root dir.
For example:
.. code-block:: html+jinja
<div class="chapter... | [
"Like",
":",
"py",
":",
"func",
":",
"read_file",
"except",
"that",
"the",
"file",
"is",
"rendered",
"as",
"a",
"Jinja",
"template",
"using",
"the",
"current",
"context",
".",
"If",
"absolute",
"is",
"True",
"use",
"absolute",
"path",
"otherwise",
"path",
... | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/template.py#L114-L132 |
tarbell-project/tarbell | tarbell/template.py | format_date | def format_date(value, format='%b %d, %Y', convert_tz=None):
"""
Format an Excel date or date string, returning a formatted date.
To return a Python :py:class:`datetime.datetime` object, pass ``None``
as a ``format`` argument.
>>> format_date(42419.82163)
'Feb. 19, 2016'
.. code-block:: ht... | python | def format_date(value, format='%b %d, %Y', convert_tz=None):
"""
Format an Excel date or date string, returning a formatted date.
To return a Python :py:class:`datetime.datetime` object, pass ``None``
as a ``format`` argument.
>>> format_date(42419.82163)
'Feb. 19, 2016'
.. code-block:: ht... | [
"def",
"format_date",
"(",
"value",
",",
"format",
"=",
"'%b %d, %Y'",
",",
"convert_tz",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"float",
")",
"or",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"seconds",
"=",
"(",
"value",
... | Format an Excel date or date string, returning a formatted date.
To return a Python :py:class:`datetime.datetime` object, pass ``None``
as a ``format`` argument.
>>> format_date(42419.82163)
'Feb. 19, 2016'
.. code-block:: html+jinja
{{ row.date|format_date('%Y-%m-%d') }} | [
"Format",
"an",
"Excel",
"date",
"or",
"date",
"string",
"returning",
"a",
"formatted",
"date",
".",
"To",
"return",
"a",
"Python",
":",
"py",
":",
"class",
":",
"datetime",
".",
"datetime",
"object",
"pass",
"None",
"as",
"a",
"format",
"argument",
"."
... | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/template.py#L147-L172 |
tarbell-project/tarbell | tarbell/template.py | pprint_lines | def pprint_lines(value):
"""
Pretty print lines
"""
pformatted = pformat(value, width=1, indent=4)
formatted = "{0}\n {1}\n{2}".format(
pformatted[0],
pformatted[1:-1],
pformatted[-1]
)
return Markup(formatted) | python | def pprint_lines(value):
"""
Pretty print lines
"""
pformatted = pformat(value, width=1, indent=4)
formatted = "{0}\n {1}\n{2}".format(
pformatted[0],
pformatted[1:-1],
pformatted[-1]
)
return Markup(formatted) | [
"def",
"pprint_lines",
"(",
"value",
")",
":",
"pformatted",
"=",
"pformat",
"(",
"value",
",",
"width",
"=",
"1",
",",
"indent",
"=",
"4",
")",
"formatted",
"=",
"\"{0}\\n {1}\\n{2}\"",
".",
"format",
"(",
"pformatted",
"[",
"0",
"]",
",",
"pformatted",... | Pretty print lines | [
"Pretty",
"print",
"lines"
] | train | https://github.com/tarbell-project/tarbell/blob/818b3d3623dcda5a08a5bf45550219719b0f0365/tarbell/template.py#L176-L186 |
matthewgilbert/mapping | mapping/plot.py | plot_composition | def plot_composition(df, intervals, axes=None):
"""
Plot time series of generics and label underlying instruments which
these series are composed of.
Parameters:
-----------
df: pd.DataFrame
DataFrame of time series to be plotted. Each column is a generic time
series.
interv... | python | def plot_composition(df, intervals, axes=None):
"""
Plot time series of generics and label underlying instruments which
these series are composed of.
Parameters:
-----------
df: pd.DataFrame
DataFrame of time series to be plotted. Each column is a generic time
series.
interv... | [
"def",
"plot_composition",
"(",
"df",
",",
"intervals",
",",
"axes",
"=",
"None",
")",
":",
"generics",
"=",
"df",
".",
"columns",
"if",
"(",
"axes",
"is",
"not",
"None",
")",
"and",
"(",
"len",
"(",
"axes",
")",
"!=",
"len",
"(",
"generics",
")",
... | Plot time series of generics and label underlying instruments which
these series are composed of.
Parameters:
-----------
df: pd.DataFrame
DataFrame of time series to be plotted. Each column is a generic time
series.
intervals: pd.DataFrame
A DataFrame including information ... | [
"Plot",
"time",
"series",
"of",
"generics",
"and",
"label",
"underlying",
"instruments",
"which",
"these",
"series",
"are",
"composed",
"of",
"."
] | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/plot.py#L5-L76 |
matthewgilbert/mapping | mapping/plot.py | intervals | def intervals(weights):
"""
Extract intervals where generics are composed of different tradeable
instruments.
Parameters
----------
weights: DataFrame or dict
A DataFrame or dictionary of DataFrames with columns representing
generics and a MultiIndex of date and contract. Values... | python | def intervals(weights):
"""
Extract intervals where generics are composed of different tradeable
instruments.
Parameters
----------
weights: DataFrame or dict
A DataFrame or dictionary of DataFrames with columns representing
generics and a MultiIndex of date and contract. Values... | [
"def",
"intervals",
"(",
"weights",
")",
":",
"intrvls",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"weights",
",",
"dict",
")",
":",
"for",
"root",
"in",
"weights",
":",
"wts",
"=",
"weights",
"[",
"root",
"]",
"intrvls",
".",
"append",
"(",
"_interval... | Extract intervals where generics are composed of different tradeable
instruments.
Parameters
----------
weights: DataFrame or dict
A DataFrame or dictionary of DataFrames with columns representing
generics and a MultiIndex of date and contract. Values represent
weights on tradea... | [
"Extract",
"intervals",
"where",
"generics",
"are",
"composed",
"of",
"different",
"tradeable",
"instruments",
"."
] | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/plot.py#L79-L106 |
openstack/networking-arista | networking_arista/l3Plugin/l3_arista.py | AristaL3SyncWorker.synchronize | def synchronize(self):
"""Synchronizes Router DB from Neturon DB with EOS.
Walks through the Neturon Db and ensures that all the routers
created in Netuton DB match with EOS. After creating appropriate
routers, it ensures to add interfaces as well.
Uses idempotent properties of ... | python | def synchronize(self):
"""Synchronizes Router DB from Neturon DB with EOS.
Walks through the Neturon Db and ensures that all the routers
created in Netuton DB match with EOS. After creating appropriate
routers, it ensures to add interfaces as well.
Uses idempotent properties of ... | [
"def",
"synchronize",
"(",
"self",
")",
":",
"LOG",
".",
"info",
"(",
"_LI",
"(",
"'Syncing Neutron Router DB <-> EOS'",
")",
")",
"routers",
",",
"router_interfaces",
"=",
"self",
".",
"get_routers_and_interfaces",
"(",
")",
"expected_vrfs",
"=",
"set",
"(",
... | Synchronizes Router DB from Neturon DB with EOS.
Walks through the Neturon Db and ensures that all the routers
created in Netuton DB match with EOS. After creating appropriate
routers, it ensures to add interfaces as well.
Uses idempotent properties of EOS configuration, which means
... | [
"Synchronizes",
"Router",
"DB",
"from",
"Neturon",
"DB",
"with",
"EOS",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/l3_arista.py#L106-L125 |
openstack/networking-arista | networking_arista/l3Plugin/l3_arista.py | AristaL3ServicePlugin.create_router | def create_router(self, context, router):
"""Create a new router entry in DB, and create it Arista HW."""
# Add router to the DB
new_router = super(AristaL3ServicePlugin, self).create_router(
context,
router)
# create router on the Arista Hw
try:
... | python | def create_router(self, context, router):
"""Create a new router entry in DB, and create it Arista HW."""
# Add router to the DB
new_router = super(AristaL3ServicePlugin, self).create_router(
context,
router)
# create router on the Arista Hw
try:
... | [
"def",
"create_router",
"(",
"self",
",",
"context",
",",
"router",
")",
":",
"# Add router to the DB",
"new_router",
"=",
"super",
"(",
"AristaL3ServicePlugin",
",",
"self",
")",
".",
"create_router",
"(",
"context",
",",
"router",
")",
"# create router on the Ar... | Create a new router entry in DB, and create it Arista HW. | [
"Create",
"a",
"new",
"router",
"entry",
"in",
"DB",
"and",
"create",
"it",
"Arista",
"HW",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/l3_arista.py#L231-L249 |
openstack/networking-arista | networking_arista/l3Plugin/l3_arista.py | AristaL3ServicePlugin.update_router | def update_router(self, context, router_id, router):
"""Update an existing router in DB, and update it in Arista HW."""
# Read existing router record from DB
original_router = self.get_router(context, router_id)
# Update router DB
new_router = super(AristaL3ServicePlugin, self).... | python | def update_router(self, context, router_id, router):
"""Update an existing router in DB, and update it in Arista HW."""
# Read existing router record from DB
original_router = self.get_router(context, router_id)
# Update router DB
new_router = super(AristaL3ServicePlugin, self).... | [
"def",
"update_router",
"(",
"self",
",",
"context",
",",
"router_id",
",",
"router",
")",
":",
"# Read existing router record from DB",
"original_router",
"=",
"self",
".",
"get_router",
"(",
"context",
",",
"router_id",
")",
"# Update router DB",
"new_router",
"="... | Update an existing router in DB, and update it in Arista HW. | [
"Update",
"an",
"existing",
"router",
"in",
"DB",
"and",
"update",
"it",
"in",
"Arista",
"HW",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/l3_arista.py#L252-L268 |
openstack/networking-arista | networking_arista/l3Plugin/l3_arista.py | AristaL3ServicePlugin.delete_router | def delete_router(self, context, router_id):
"""Delete an existing router from Arista HW as well as from the DB."""
router = self.get_router(context, router_id)
# Delete router on the Arista Hw
try:
self.driver.delete_router(context, router_id, router)
except Except... | python | def delete_router(self, context, router_id):
"""Delete an existing router from Arista HW as well as from the DB."""
router = self.get_router(context, router_id)
# Delete router on the Arista Hw
try:
self.driver.delete_router(context, router_id, router)
except Except... | [
"def",
"delete_router",
"(",
"self",
",",
"context",
",",
"router_id",
")",
":",
"router",
"=",
"self",
".",
"get_router",
"(",
"context",
",",
"router_id",
")",
"# Delete router on the Arista Hw",
"try",
":",
"self",
".",
"driver",
".",
"delete_router",
"(",
... | Delete an existing router from Arista HW as well as from the DB. | [
"Delete",
"an",
"existing",
"router",
"from",
"Arista",
"HW",
"as",
"well",
"as",
"from",
"the",
"DB",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/l3_arista.py#L271-L284 |
openstack/networking-arista | networking_arista/l3Plugin/l3_arista.py | AristaL3ServicePlugin.add_router_interface | def add_router_interface(self, context, router_id, interface_info):
"""Add a subnet of a network to an existing router."""
new_router = super(AristaL3ServicePlugin, self).add_router_interface(
context, router_id, interface_info)
core = directory.get_plugin()
# Get network ... | python | def add_router_interface(self, context, router_id, interface_info):
"""Add a subnet of a network to an existing router."""
new_router = super(AristaL3ServicePlugin, self).add_router_interface(
context, router_id, interface_info)
core = directory.get_plugin()
# Get network ... | [
"def",
"add_router_interface",
"(",
"self",
",",
"context",
",",
"router_id",
",",
"interface_info",
")",
":",
"new_router",
"=",
"super",
"(",
"AristaL3ServicePlugin",
",",
"self",
")",
".",
"add_router_interface",
"(",
"context",
",",
"router_id",
",",
"interf... | Add a subnet of a network to an existing router. | [
"Add",
"a",
"subnet",
"of",
"a",
"network",
"to",
"an",
"existing",
"router",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/l3_arista.py#L287-L331 |
openstack/networking-arista | networking_arista/l3Plugin/l3_arista.py | AristaL3ServicePlugin.remove_router_interface | def remove_router_interface(self, context, router_id, interface_info):
"""Remove a subnet of a network from an existing router."""
router_to_del = (
super(AristaL3ServicePlugin, self).remove_router_interface(
context,
router_id,
interface_info... | python | def remove_router_interface(self, context, router_id, interface_info):
"""Remove a subnet of a network from an existing router."""
router_to_del = (
super(AristaL3ServicePlugin, self).remove_router_interface(
context,
router_id,
interface_info... | [
"def",
"remove_router_interface",
"(",
"self",
",",
"context",
",",
"router_id",
",",
"interface_info",
")",
":",
"router_to_del",
"=",
"(",
"super",
"(",
"AristaL3ServicePlugin",
",",
"self",
")",
".",
"remove_router_interface",
"(",
"context",
",",
"router_id",
... | Remove a subnet of a network from an existing router. | [
"Remove",
"a",
"subnet",
"of",
"a",
"network",
"from",
"an",
"existing",
"router",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/l3_arista.py#L334-L366 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper.initialize_switch_endpoints | def initialize_switch_endpoints(self):
"""Initialize endpoints for switch communication"""
self._switches = {}
self._port_group_info = {}
self._validate_config()
for s in cfg.CONF.ml2_arista.switch_info:
switch_ip, switch_user, switch_pass = s.split(":")
i... | python | def initialize_switch_endpoints(self):
"""Initialize endpoints for switch communication"""
self._switches = {}
self._port_group_info = {}
self._validate_config()
for s in cfg.CONF.ml2_arista.switch_info:
switch_ip, switch_user, switch_pass = s.split(":")
i... | [
"def",
"initialize_switch_endpoints",
"(",
"self",
")",
":",
"self",
".",
"_switches",
"=",
"{",
"}",
"self",
".",
"_port_group_info",
"=",
"{",
"}",
"self",
".",
"_validate_config",
"(",
")",
"for",
"s",
"in",
"cfg",
".",
"CONF",
".",
"ml2_arista",
".",... | Initialize endpoints for switch communication | [
"Initialize",
"endpoints",
"for",
"switch",
"communication"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L42-L57 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper._check_dynamic_acl_support | def _check_dynamic_acl_support(self):
"""Log an error if any switches don't support dynamic ACLs"""
cmds = ['ip access-list openstack-test dynamic',
'no ip access-list openstack-test']
for switch_ip, switch_client in self._switches.items():
try:
self.r... | python | def _check_dynamic_acl_support(self):
"""Log an error if any switches don't support dynamic ACLs"""
cmds = ['ip access-list openstack-test dynamic',
'no ip access-list openstack-test']
for switch_ip, switch_client in self._switches.items():
try:
self.r... | [
"def",
"_check_dynamic_acl_support",
"(",
"self",
")",
":",
"cmds",
"=",
"[",
"'ip access-list openstack-test dynamic'",
",",
"'no ip access-list openstack-test'",
"]",
"for",
"switch_ip",
",",
"switch_client",
"in",
"self",
".",
"_switches",
".",
"items",
"(",
")",
... | Log an error if any switches don't support dynamic ACLs | [
"Log",
"an",
"error",
"if",
"any",
"switches",
"don",
"t",
"support",
"dynamic",
"ACLs"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L59-L69 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper._validate_config | def _validate_config(self):
"""Ensure at least one switch is configured"""
if len(cfg.CONF.ml2_arista.get('switch_info')) < 1:
msg = _('Required option - when "sec_group_support" is enabled, '
'at least one switch must be specified ')
LOG.exception(msg)
... | python | def _validate_config(self):
"""Ensure at least one switch is configured"""
if len(cfg.CONF.ml2_arista.get('switch_info')) < 1:
msg = _('Required option - when "sec_group_support" is enabled, '
'at least one switch must be specified ')
LOG.exception(msg)
... | [
"def",
"_validate_config",
"(",
"self",
")",
":",
"if",
"len",
"(",
"cfg",
".",
"CONF",
".",
"ml2_arista",
".",
"get",
"(",
"'switch_info'",
")",
")",
"<",
"1",
":",
"msg",
"=",
"_",
"(",
"'Required option - when \"sec_group_support\" is enabled, '",
"'at leas... | Ensure at least one switch is configured | [
"Ensure",
"at",
"least",
"one",
"switch",
"is",
"configured"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L71-L77 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper.run_openstack_sg_cmds | def run_openstack_sg_cmds(self, commands, switch):
"""Execute/sends a CAPI (Command API) command to EOS.
In this method, list of commands is appended with prefix and
postfix commands - to make is understandble by EOS.
:param commands : List of command to be executed on EOS.
:pa... | python | def run_openstack_sg_cmds(self, commands, switch):
"""Execute/sends a CAPI (Command API) command to EOS.
In this method, list of commands is appended with prefix and
postfix commands - to make is understandble by EOS.
:param commands : List of command to be executed on EOS.
:pa... | [
"def",
"run_openstack_sg_cmds",
"(",
"self",
",",
"commands",
",",
"switch",
")",
":",
"if",
"not",
"switch",
":",
"LOG",
".",
"exception",
"(",
"\"No client found for switch\"",
")",
"return",
"[",
"]",
"if",
"len",
"(",
"commands",
")",
"==",
"0",
":",
... | Execute/sends a CAPI (Command API) command to EOS.
In this method, list of commands is appended with prefix and
postfix commands - to make is understandble by EOS.
:param commands : List of command to be executed on EOS.
:param switch: Endpoint on the Arista switch to be configured | [
"Execute",
"/",
"sends",
"a",
"CAPI",
"(",
"Command",
"API",
")",
"command",
"to",
"EOS",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L79-L96 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper._run_eos_cmds | def _run_eos_cmds(self, commands, switch):
"""Execute/sends a CAPI (Command API) command to EOS.
This method is useful for running show commands that require no
prefix or postfix commands.
:param commands : List of commands to be executed on EOS.
:param switch: Endpoint on the ... | python | def _run_eos_cmds(self, commands, switch):
"""Execute/sends a CAPI (Command API) command to EOS.
This method is useful for running show commands that require no
prefix or postfix commands.
:param commands : List of commands to be executed on EOS.
:param switch: Endpoint on the ... | [
"def",
"_run_eos_cmds",
"(",
"self",
",",
"commands",
",",
"switch",
")",
":",
"LOG",
".",
"info",
"(",
"_LI",
"(",
"'Executing command on Arista EOS: %s'",
")",
",",
"commands",
")",
"try",
":",
"# this returns array of return values for every command in",
"# command... | Execute/sends a CAPI (Command API) command to EOS.
This method is useful for running show commands that require no
prefix or postfix commands.
:param commands : List of commands to be executed on EOS.
:param switch: Endpoint on the Arista switch to be configured | [
"Execute",
"/",
"sends",
"a",
"CAPI",
"(",
"Command",
"API",
")",
"command",
"to",
"EOS",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L98-L119 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper._get_switchports | def _get_switchports(profile):
"""Return list of (switch_ip, interface) tuples from local_link_info"""
switchports = []
if profile.get('local_link_information'):
for link in profile['local_link_information']:
if 'switch_info' in link and 'port_id' in link:
... | python | def _get_switchports(profile):
"""Return list of (switch_ip, interface) tuples from local_link_info"""
switchports = []
if profile.get('local_link_information'):
for link in profile['local_link_information']:
if 'switch_info' in link and 'port_id' in link:
... | [
"def",
"_get_switchports",
"(",
"profile",
")",
":",
"switchports",
"=",
"[",
"]",
"if",
"profile",
".",
"get",
"(",
"'local_link_information'",
")",
":",
"for",
"link",
"in",
"profile",
"[",
"'local_link_information'",
"]",
":",
"if",
"'switch_info'",
"in",
... | Return list of (switch_ip, interface) tuples from local_link_info | [
"Return",
"list",
"of",
"(",
"switch_ip",
"interface",
")",
"tuples",
"from",
"local_link_info"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L133-L144 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper._update_port_group_info | def _update_port_group_info(self, switches=None):
"""Refresh data on switch interfaces' port group membership"""
if switches is None:
switches = self._switches.keys()
for switch_ip in switches:
client = self._switches.get(switch_ip)
ret = self._run_eos_cmds(['... | python | def _update_port_group_info(self, switches=None):
"""Refresh data on switch interfaces' port group membership"""
if switches is None:
switches = self._switches.keys()
for switch_ip in switches:
client = self._switches.get(switch_ip)
ret = self._run_eos_cmds(['... | [
"def",
"_update_port_group_info",
"(",
"self",
",",
"switches",
"=",
"None",
")",
":",
"if",
"switches",
"is",
"None",
":",
"switches",
"=",
"self",
".",
"_switches",
".",
"keys",
"(",
")",
"for",
"switch_ip",
"in",
"switches",
":",
"client",
"=",
"self"... | Refresh data on switch interfaces' port group membership | [
"Refresh",
"data",
"on",
"switch",
"interfaces",
"port",
"group",
"membership"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L146-L158 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper._get_port_for_acl | def _get_port_for_acl(self, port_id, switch):
"""Gets interface name for ACLs
Finds the Port-Channel name if port_id is in a Port-Channel, otherwise
ACLs are applied to Ethernet interface.
:param port_id: Name of port from ironic db
:param server: Server endpoint on the Arista ... | python | def _get_port_for_acl(self, port_id, switch):
"""Gets interface name for ACLs
Finds the Port-Channel name if port_id is in a Port-Channel, otherwise
ACLs are applied to Ethernet interface.
:param port_id: Name of port from ironic db
:param server: Server endpoint on the Arista ... | [
"def",
"_get_port_for_acl",
"(",
"self",
",",
"port_id",
",",
"switch",
")",
":",
"all_intf_info",
"=",
"self",
".",
"_port_group_info",
".",
"get",
"(",
"switch",
",",
"{",
"}",
")",
"intf_info",
"=",
"all_intf_info",
".",
"get",
"(",
"port_id",
",",
"{... | Gets interface name for ACLs
Finds the Port-Channel name if port_id is in a Port-Channel, otherwise
ACLs are applied to Ethernet interface.
:param port_id: Name of port from ironic db
:param server: Server endpoint on the Arista switch to be configured | [
"Gets",
"interface",
"name",
"for",
"ACLs"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L160-L176 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper._supported_rule | def _supported_rule(protocol, ethertype):
"""Checks that the rule is an IPv4 rule of a supported protocol"""
if not protocol or protocol not in utils.SUPPORTED_SG_PROTOCOLS:
return False
if ethertype != n_const.IPv4:
return False
return True | python | def _supported_rule(protocol, ethertype):
"""Checks that the rule is an IPv4 rule of a supported protocol"""
if not protocol or protocol not in utils.SUPPORTED_SG_PROTOCOLS:
return False
if ethertype != n_const.IPv4:
return False
return True | [
"def",
"_supported_rule",
"(",
"protocol",
",",
"ethertype",
")",
":",
"if",
"not",
"protocol",
"or",
"protocol",
"not",
"in",
"utils",
".",
"SUPPORTED_SG_PROTOCOLS",
":",
"return",
"False",
"if",
"ethertype",
"!=",
"n_const",
".",
"IPv4",
":",
"return",
"Fa... | Checks that the rule is an IPv4 rule of a supported protocol | [
"Checks",
"that",
"the",
"rule",
"is",
"an",
"IPv4",
"rule",
"of",
"a",
"supported",
"protocol"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L179-L187 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper._format_rule | def _format_rule(self, protocol, cidr, min_port, max_port, direction):
"""Get EOS formatted rule"""
if cidr is None:
cidr = 'any'
if direction == n_const.INGRESS_DIRECTION:
dst_ip = 'any'
src_ip = cidr
elif direction == n_const.EGRESS_DIRECTION:
... | python | def _format_rule(self, protocol, cidr, min_port, max_port, direction):
"""Get EOS formatted rule"""
if cidr is None:
cidr = 'any'
if direction == n_const.INGRESS_DIRECTION:
dst_ip = 'any'
src_ip = cidr
elif direction == n_const.EGRESS_DIRECTION:
... | [
"def",
"_format_rule",
"(",
"self",
",",
"protocol",
",",
"cidr",
",",
"min_port",
",",
"max_port",
",",
"direction",
")",
":",
"if",
"cidr",
"is",
"None",
":",
"cidr",
"=",
"'any'",
"if",
"direction",
"==",
"n_const",
".",
"INGRESS_DIRECTION",
":",
"dst... | Get EOS formatted rule | [
"Get",
"EOS",
"formatted",
"rule"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L189-L213 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSwitchHelper._format_rules_for_eos | def _format_rules_for_eos(self, rules):
"""Format list of rules for EOS and sort into ingress/egress rules"""
in_rules = []
eg_rules = []
for rule in rules:
protocol = rule.get('protocol')
cidr = rule.get('remote_ip_prefix', 'any')
min_port = rule.get(... | python | def _format_rules_for_eos(self, rules):
"""Format list of rules for EOS and sort into ingress/egress rules"""
in_rules = []
eg_rules = []
for rule in rules:
protocol = rule.get('protocol')
cidr = rule.get('remote_ip_prefix', 'any')
min_port = rule.get(... | [
"def",
"_format_rules_for_eos",
"(",
"self",
",",
"rules",
")",
":",
"in_rules",
"=",
"[",
"]",
"eg_rules",
"=",
"[",
"]",
"for",
"rule",
"in",
"rules",
":",
"protocol",
"=",
"rule",
".",
"get",
"(",
"'protocol'",
")",
"cidr",
"=",
"rule",
".",
"get"... | Format list of rules for EOS and sort into ingress/egress rules | [
"Format",
"list",
"of",
"rules",
"for",
"EOS",
"and",
"sort",
"into",
"ingress",
"/",
"egress",
"rules"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L215-L234 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupCallbackHelper.run_cmds_on_all_switches | def run_cmds_on_all_switches(self, cmds):
"""Runs all cmds on all configured switches
This helper is used for ACL and rule creation/deletion as ACLs
and rules must exist on all switches.
"""
for switch in self._switches.values():
self.run_openstack_sg_cmds(cmds, swit... | python | def run_cmds_on_all_switches(self, cmds):
"""Runs all cmds on all configured switches
This helper is used for ACL and rule creation/deletion as ACLs
and rules must exist on all switches.
"""
for switch in self._switches.values():
self.run_openstack_sg_cmds(cmds, swit... | [
"def",
"run_cmds_on_all_switches",
"(",
"self",
",",
"cmds",
")",
":",
"for",
"switch",
"in",
"self",
".",
"_switches",
".",
"values",
"(",
")",
":",
"self",
".",
"run_openstack_sg_cmds",
"(",
"cmds",
",",
"switch",
")"
] | Runs all cmds on all configured switches
This helper is used for ACL and rule creation/deletion as ACLs
and rules must exist on all switches. | [
"Runs",
"all",
"cmds",
"on",
"all",
"configured",
"switches"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L239-L246 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupCallbackHelper.run_per_switch_cmds | def run_per_switch_cmds(self, switch_cmds):
"""Applies cmds to appropriate switches
This takes in a switch->cmds mapping and runs only the set of cmds
specified for a switch on that switch. This helper is used for
applying/removing ACLs to/from interfaces as this config will vary
... | python | def run_per_switch_cmds(self, switch_cmds):
"""Applies cmds to appropriate switches
This takes in a switch->cmds mapping and runs only the set of cmds
specified for a switch on that switch. This helper is used for
applying/removing ACLs to/from interfaces as this config will vary
... | [
"def",
"run_per_switch_cmds",
"(",
"self",
",",
"switch_cmds",
")",
":",
"for",
"switch_ip",
",",
"cmds",
"in",
"switch_cmds",
".",
"items",
"(",
")",
":",
"switch",
"=",
"self",
".",
"_switches",
".",
"get",
"(",
"switch_ip",
")",
"self",
".",
"run_open... | Applies cmds to appropriate switches
This takes in a switch->cmds mapping and runs only the set of cmds
specified for a switch on that switch. This helper is used for
applying/removing ACLs to/from interfaces as this config will vary
from switch to switch. | [
"Applies",
"cmds",
"to",
"appropriate",
"switches"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L248-L258 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupCallbackHelper._get_switches | def _get_switches(self, profile):
"""Get set of switches referenced in a port binding profile"""
switchports = self._get_switchports(profile)
switches = set([switchport[0] for switchport in switchports])
return switches | python | def _get_switches(self, profile):
"""Get set of switches referenced in a port binding profile"""
switchports = self._get_switchports(profile)
switches = set([switchport[0] for switchport in switchports])
return switches | [
"def",
"_get_switches",
"(",
"self",
",",
"profile",
")",
":",
"switchports",
"=",
"self",
".",
"_get_switchports",
"(",
"profile",
")",
"switches",
"=",
"set",
"(",
"[",
"switchport",
"[",
"0",
"]",
"for",
"switchport",
"in",
"switchports",
"]",
")",
"r... | Get set of switches referenced in a port binding profile | [
"Get",
"set",
"of",
"switches",
"referenced",
"in",
"a",
"port",
"binding",
"profile"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L260-L264 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupCallbackHelper.get_create_security_group_commands | def get_create_security_group_commands(self, sg_id, sg_rules):
"""Commands for creating ACL"""
cmds = []
in_rules, eg_rules = self._format_rules_for_eos(sg_rules)
cmds.append("ip access-list %s dynamic" %
self._acl_name(sg_id, n_const.INGRESS_DIRECTION))
for i... | python | def get_create_security_group_commands(self, sg_id, sg_rules):
"""Commands for creating ACL"""
cmds = []
in_rules, eg_rules = self._format_rules_for_eos(sg_rules)
cmds.append("ip access-list %s dynamic" %
self._acl_name(sg_id, n_const.INGRESS_DIRECTION))
for i... | [
"def",
"get_create_security_group_commands",
"(",
"self",
",",
"sg_id",
",",
"sg_rules",
")",
":",
"cmds",
"=",
"[",
"]",
"in_rules",
",",
"eg_rules",
"=",
"self",
".",
"_format_rules_for_eos",
"(",
"sg_rules",
")",
"cmds",
".",
"append",
"(",
"\"ip access-lis... | Commands for creating ACL | [
"Commands",
"for",
"creating",
"ACL"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L266-L280 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupCallbackHelper.get_delete_security_group_commands | def get_delete_security_group_commands(self, sg_id):
"""Commands for deleting ACL"""
cmds = []
cmds.append("no ip access-list %s" %
self._acl_name(sg_id, n_const.INGRESS_DIRECTION))
cmds.append("no ip access-list %s" %
self._acl_name(sg_id, n_const... | python | def get_delete_security_group_commands(self, sg_id):
"""Commands for deleting ACL"""
cmds = []
cmds.append("no ip access-list %s" %
self._acl_name(sg_id, n_const.INGRESS_DIRECTION))
cmds.append("no ip access-list %s" %
self._acl_name(sg_id, n_const... | [
"def",
"get_delete_security_group_commands",
"(",
"self",
",",
"sg_id",
")",
":",
"cmds",
"=",
"[",
"]",
"cmds",
".",
"append",
"(",
"\"no ip access-list %s\"",
"%",
"self",
".",
"_acl_name",
"(",
"sg_id",
",",
"n_const",
".",
"INGRESS_DIRECTION",
")",
")",
... | Commands for deleting ACL | [
"Commands",
"for",
"deleting",
"ACL"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L282-L289 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupCallbackHelper._get_rule_cmds | def _get_rule_cmds(self, sg_id, sg_rule, delete=False):
"""Helper for getting add/delete ACL rule commands"""
rule_prefix = ""
if delete:
rule_prefix = "no "
in_rules, eg_rules = self._format_rules_for_eos([sg_rule])
cmds = []
if in_rules:
cmds.app... | python | def _get_rule_cmds(self, sg_id, sg_rule, delete=False):
"""Helper for getting add/delete ACL rule commands"""
rule_prefix = ""
if delete:
rule_prefix = "no "
in_rules, eg_rules = self._format_rules_for_eos([sg_rule])
cmds = []
if in_rules:
cmds.app... | [
"def",
"_get_rule_cmds",
"(",
"self",
",",
"sg_id",
",",
"sg_rule",
",",
"delete",
"=",
"False",
")",
":",
"rule_prefix",
"=",
"\"\"",
"if",
"delete",
":",
"rule_prefix",
"=",
"\"no \"",
"in_rules",
",",
"eg_rules",
"=",
"self",
".",
"_format_rules_for_eos",... | Helper for getting add/delete ACL rule commands | [
"Helper",
"for",
"getting",
"add",
"/",
"delete",
"ACL",
"rule",
"commands"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L291-L310 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupCallbackHelper.get_delete_security_group_rule_commands | def get_delete_security_group_rule_commands(self, sg_id, sg_rule):
"""Commands for removing rule from ACLS"""
return self._get_rule_cmds(sg_id, sg_rule, delete=True) | python | def get_delete_security_group_rule_commands(self, sg_id, sg_rule):
"""Commands for removing rule from ACLS"""
return self._get_rule_cmds(sg_id, sg_rule, delete=True) | [
"def",
"get_delete_security_group_rule_commands",
"(",
"self",
",",
"sg_id",
",",
"sg_rule",
")",
":",
"return",
"self",
".",
"_get_rule_cmds",
"(",
"sg_id",
",",
"sg_rule",
",",
"delete",
"=",
"True",
")"
] | Commands for removing rule from ACLS | [
"Commands",
"for",
"removing",
"rule",
"from",
"ACLS"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L316-L318 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupCallbackHelper._get_interface_commands | def _get_interface_commands(self, sg_id, profile, delete=False):
"""Helper for getting interface ACL apply/remove commands"""
rule_prefix = ""
if delete:
rule_prefix = "no "
switch_cmds = {}
switchports = self._get_switchports(profile)
for switch_ip, intf in s... | python | def _get_interface_commands(self, sg_id, profile, delete=False):
"""Helper for getting interface ACL apply/remove commands"""
rule_prefix = ""
if delete:
rule_prefix = "no "
switch_cmds = {}
switchports = self._get_switchports(profile)
for switch_ip, intf in s... | [
"def",
"_get_interface_commands",
"(",
"self",
",",
"sg_id",
",",
"profile",
",",
"delete",
"=",
"False",
")",
":",
"rule_prefix",
"=",
"\"\"",
"if",
"delete",
":",
"rule_prefix",
"=",
"\"no \"",
"switch_cmds",
"=",
"{",
"}",
"switchports",
"=",
"self",
".... | Helper for getting interface ACL apply/remove commands | [
"Helper",
"for",
"getting",
"interface",
"ACL",
"apply",
"/",
"remove",
"commands"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L320-L341 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupCallbackHelper.get_remove_security_group_commands | def get_remove_security_group_commands(self, sg_id, profile):
"""Commands for removing ACL from interface"""
return self._get_interface_commands(sg_id, profile, delete=True) | python | def get_remove_security_group_commands(self, sg_id, profile):
"""Commands for removing ACL from interface"""
return self._get_interface_commands(sg_id, profile, delete=True) | [
"def",
"get_remove_security_group_commands",
"(",
"self",
",",
"sg_id",
",",
"profile",
")",
":",
"return",
"self",
".",
"_get_interface_commands",
"(",
"sg_id",
",",
"profile",
",",
"delete",
"=",
"True",
")"
] | Commands for removing ACL from interface | [
"Commands",
"for",
"removing",
"ACL",
"from",
"interface"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L347-L349 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSyncHelper._parse_acl_config | def _parse_acl_config(self, acl_config):
"""Parse configured ACLs and rules
ACLs are returned as a dict of rule sets:
{<eos_acl1_name>: set([<eos_acl1_rules>]),
<eos_acl2_name>: set([<eos_acl2_rules>]),
...,
}
"""
parsed_acls = dict()
for acl in... | python | def _parse_acl_config(self, acl_config):
"""Parse configured ACLs and rules
ACLs are returned as a dict of rule sets:
{<eos_acl1_name>: set([<eos_acl1_rules>]),
<eos_acl2_name>: set([<eos_acl2_rules>]),
...,
}
"""
parsed_acls = dict()
for acl in... | [
"def",
"_parse_acl_config",
"(",
"self",
",",
"acl_config",
")",
":",
"parsed_acls",
"=",
"dict",
"(",
")",
"for",
"acl",
"in",
"acl_config",
"[",
"'aclList'",
"]",
":",
"parsed_acls",
"[",
"acl",
"[",
"'name'",
"]",
"]",
"=",
"set",
"(",
")",
"for",
... | Parse configured ACLs and rules
ACLs are returned as a dict of rule sets:
{<eos_acl1_name>: set([<eos_acl1_rules>]),
<eos_acl2_name>: set([<eos_acl2_rules>]),
...,
} | [
"Parse",
"configured",
"ACLs",
"and",
"rules"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L354-L368 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSyncHelper._parse_binding_config | def _parse_binding_config(self, binding_config):
"""Parse configured interface -> ACL bindings
Bindings are returned as a set of (intf, name, direction) tuples:
set([(intf1, acl_name, direction),
(intf2, acl_name, direction),
...,
])
"""
parsed_... | python | def _parse_binding_config(self, binding_config):
"""Parse configured interface -> ACL bindings
Bindings are returned as a set of (intf, name, direction) tuples:
set([(intf1, acl_name, direction),
(intf2, acl_name, direction),
...,
])
"""
parsed_... | [
"def",
"_parse_binding_config",
"(",
"self",
",",
"binding_config",
")",
":",
"parsed_bindings",
"=",
"set",
"(",
")",
"for",
"acl",
"in",
"binding_config",
"[",
"'aclList'",
"]",
":",
"for",
"intf",
"in",
"acl",
"[",
"'configuredIngressIntfs'",
"]",
":",
"p... | Parse configured interface -> ACL bindings
Bindings are returned as a set of (intf, name, direction) tuples:
set([(intf1, acl_name, direction),
(intf2, acl_name, direction),
...,
]) | [
"Parse",
"configured",
"interface",
"-",
">",
"ACL",
"bindings"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L370-L387 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSyncHelper._get_dynamic_acl_info | def _get_dynamic_acl_info(self, switch_ip):
"""Retrieve ACLs, ACLs rules and interface bindings from switch"""
cmds = ["enable",
"show ip access-lists dynamic",
"show ip access-lists summary dynamic"]
switch = self._switches.get(switch_ip)
_, acls, bindin... | python | def _get_dynamic_acl_info(self, switch_ip):
"""Retrieve ACLs, ACLs rules and interface bindings from switch"""
cmds = ["enable",
"show ip access-lists dynamic",
"show ip access-lists summary dynamic"]
switch = self._switches.get(switch_ip)
_, acls, bindin... | [
"def",
"_get_dynamic_acl_info",
"(",
"self",
",",
"switch_ip",
")",
":",
"cmds",
"=",
"[",
"\"enable\"",
",",
"\"show ip access-lists dynamic\"",
",",
"\"show ip access-lists summary dynamic\"",
"]",
"switch",
"=",
"self",
".",
"_switches",
".",
"get",
"(",
"switch_... | Retrieve ACLs, ACLs rules and interface bindings from switch | [
"Retrieve",
"ACLs",
"ACLs",
"rules",
"and",
"interface",
"bindings",
"from",
"switch"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L389-L401 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSyncHelper.get_expected_acls | def get_expected_acls(self):
"""Query the neutron DB for Security Groups and Rules
Groups and rules are returned as a dict of rule sets:
{<eos_acl1_name>: set([<eos_acl1_rules>]),
<eos_acl2_name>: set([<eos_acl2_rules>]),
...,
}
"""
security_groups = db... | python | def get_expected_acls(self):
"""Query the neutron DB for Security Groups and Rules
Groups and rules are returned as a dict of rule sets:
{<eos_acl1_name>: set([<eos_acl1_rules>]),
<eos_acl2_name>: set([<eos_acl2_rules>]),
...,
}
"""
security_groups = db... | [
"def",
"get_expected_acls",
"(",
"self",
")",
":",
"security_groups",
"=",
"db_lib",
".",
"get_security_groups",
"(",
")",
"expected_acls",
"=",
"collections",
".",
"defaultdict",
"(",
"set",
")",
"for",
"sg",
"in",
"security_groups",
":",
"in_rules",
",",
"ou... | Query the neutron DB for Security Groups and Rules
Groups and rules are returned as a dict of rule sets:
{<eos_acl1_name>: set([<eos_acl1_rules>]),
<eos_acl2_name>: set([<eos_acl2_rules>]),
...,
} | [
"Query",
"the",
"neutron",
"DB",
"for",
"Security",
"Groups",
"and",
"Rules"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L403-L423 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSyncHelper.get_expected_bindings | def get_expected_bindings(self):
"""Query the neutron DB for SG->switch interface bindings
Bindings are returned as a dict of bindings for each switch:
{<switch1>: set([(intf1, acl_name, direction),
(intf2, acl_name, direction)]),
<switch2>: set([(intf1, acl_na... | python | def get_expected_bindings(self):
"""Query the neutron DB for SG->switch interface bindings
Bindings are returned as a dict of bindings for each switch:
{<switch1>: set([(intf1, acl_name, direction),
(intf2, acl_name, direction)]),
<switch2>: set([(intf1, acl_na... | [
"def",
"get_expected_bindings",
"(",
"self",
")",
":",
"sg_bindings",
"=",
"db_lib",
".",
"get_baremetal_sg_bindings",
"(",
")",
"all_expected_bindings",
"=",
"collections",
".",
"defaultdict",
"(",
"set",
")",
"for",
"sg_binding",
",",
"port_binding",
"in",
"sg_b... | Query the neutron DB for SG->switch interface bindings
Bindings are returned as a dict of bindings for each switch:
{<switch1>: set([(intf1, acl_name, direction),
(intf2, acl_name, direction)]),
<switch2>: set([(intf1, acl_name, direction)]),
...,
} | [
"Query",
"the",
"neutron",
"DB",
"for",
"SG",
"-",
">",
"switch",
"interface",
"bindings"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L425-L452 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSyncHelper.adjust_bindings_for_lag | def adjust_bindings_for_lag(self, switch_ip, bindings):
"""Adjusting interface names for expected bindings where LAGs exist"""
# Get latest LAG info for switch
self._update_port_group_info([switch_ip])
# Update bindings to account for LAG info
adjusted_bindings = set()
... | python | def adjust_bindings_for_lag(self, switch_ip, bindings):
"""Adjusting interface names for expected bindings where LAGs exist"""
# Get latest LAG info for switch
self._update_port_group_info([switch_ip])
# Update bindings to account for LAG info
adjusted_bindings = set()
... | [
"def",
"adjust_bindings_for_lag",
"(",
"self",
",",
"switch_ip",
",",
"bindings",
")",
":",
"# Get latest LAG info for switch",
"self",
".",
"_update_port_group_info",
"(",
"[",
"switch_ip",
"]",
")",
"# Update bindings to account for LAG info",
"adjusted_bindings",
"=",
... | Adjusting interface names for expected bindings where LAGs exist | [
"Adjusting",
"interface",
"names",
"for",
"expected",
"bindings",
"where",
"LAGs",
"exist"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L454-L465 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSyncHelper.get_sync_acl_cmds | def get_sync_acl_cmds(self, switch_acls, expected_acls):
"""Returns the list of commands required synchronize switch ACLs
1. Identify unexpected ACLs and delete them
2. Iterate over expected ACLs
a. Add missing ACLs + all rules
b. Delete unexpected rules
c. Add ... | python | def get_sync_acl_cmds(self, switch_acls, expected_acls):
"""Returns the list of commands required synchronize switch ACLs
1. Identify unexpected ACLs and delete them
2. Iterate over expected ACLs
a. Add missing ACLs + all rules
b. Delete unexpected rules
c. Add ... | [
"def",
"get_sync_acl_cmds",
"(",
"self",
",",
"switch_acls",
",",
"expected_acls",
")",
":",
"switch_cmds",
"=",
"list",
"(",
")",
"# Delete any stale ACLs",
"acls_to_delete",
"=",
"(",
"set",
"(",
"switch_acls",
".",
"keys",
"(",
")",
")",
"-",
"set",
"(",
... | Returns the list of commands required synchronize switch ACLs
1. Identify unexpected ACLs and delete them
2. Iterate over expected ACLs
a. Add missing ACLs + all rules
b. Delete unexpected rules
c. Add missing rules | [
"Returns",
"the",
"list",
"of",
"commands",
"required",
"synchronize",
"switch",
"ACLs"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L467-L500 |
openstack/networking-arista | networking_arista/ml2/security_groups/switch_helper.py | AristaSecurityGroupSyncHelper.get_sync_binding_cmds | def get_sync_binding_cmds(self, switch_bindings, expected_bindings):
"""Returns the list of commands required to synchronize ACL bindings
1. Delete any unexpected bindings
2. Add any missing bindings
"""
switch_cmds = list()
# Update any necessary switch interface ACLs
... | python | def get_sync_binding_cmds(self, switch_bindings, expected_bindings):
"""Returns the list of commands required to synchronize ACL bindings
1. Delete any unexpected bindings
2. Add any missing bindings
"""
switch_cmds = list()
# Update any necessary switch interface ACLs
... | [
"def",
"get_sync_binding_cmds",
"(",
"self",
",",
"switch_bindings",
",",
"expected_bindings",
")",
":",
"switch_cmds",
"=",
"list",
"(",
")",
"# Update any necessary switch interface ACLs",
"bindings_to_delete",
"=",
"switch_bindings",
"-",
"expected_bindings",
"bindings_t... | Returns the list of commands required to synchronize ACL bindings
1. Delete any unexpected bindings
2. Add any missing bindings | [
"Returns",
"the",
"list",
"of",
"commands",
"required",
"to",
"synchronize",
"ACL",
"bindings"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/switch_helper.py#L502-L522 |
matthewgilbert/mapping | mapping/util.py | read_price_data | def read_price_data(files, name_func=None):
"""
Convenience function for reading in pricing data from csv files
Parameters
----------
files: list
List of strings refering to csv files to read data in from, first
column should be dates
name_func: func
A function to apply ... | python | def read_price_data(files, name_func=None):
"""
Convenience function for reading in pricing data from csv files
Parameters
----------
files: list
List of strings refering to csv files to read data in from, first
column should be dates
name_func: func
A function to apply ... | [
"def",
"read_price_data",
"(",
"files",
",",
"name_func",
"=",
"None",
")",
":",
"if",
"name_func",
"is",
"None",
":",
"def",
"name_func",
"(",
"x",
")",
":",
"return",
"os",
".",
"path",
".",
"split",
"(",
"x",
")",
"[",
"1",
"]",
".",
"split",
... | Convenience function for reading in pricing data from csv files
Parameters
----------
files: list
List of strings refering to csv files to read data in from, first
column should be dates
name_func: func
A function to apply to the file strings to infer the instrument name,
... | [
"Convenience",
"function",
"for",
"reading",
"in",
"pricing",
"data",
"from",
"csv",
"files"
] | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/util.py#L6-L40 |
matthewgilbert/mapping | mapping/util.py | flatten | def flatten(weights):
"""
Flatten weights into a long DataFrame.
Parameters
----------
weights: pandas.DataFrame or dict
A DataFrame of instrument weights with a MultiIndex where the top level
contains pandas. Timestamps and the second level is instrument names.
The columns ... | python | def flatten(weights):
"""
Flatten weights into a long DataFrame.
Parameters
----------
weights: pandas.DataFrame or dict
A DataFrame of instrument weights with a MultiIndex where the top level
contains pandas. Timestamps and the second level is instrument names.
The columns ... | [
"def",
"flatten",
"(",
"weights",
")",
":",
"# NOQA",
"if",
"isinstance",
"(",
"weights",
",",
"pd",
".",
"DataFrame",
")",
":",
"wts",
"=",
"weights",
".",
"stack",
"(",
")",
".",
"reset_index",
"(",
")",
"wts",
".",
"columns",
"=",
"[",
"\"date\"",... | Flatten weights into a long DataFrame.
Parameters
----------
weights: pandas.DataFrame or dict
A DataFrame of instrument weights with a MultiIndex where the top level
contains pandas. Timestamps and the second level is instrument names.
The columns consist of generic names. If dict ... | [
"Flatten",
"weights",
"into",
"a",
"long",
"DataFrame",
"."
] | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/util.py#L43-L89 |
matthewgilbert/mapping | mapping/util.py | unflatten | def unflatten(flat_weights):
"""
Pivot weights from long DataFrame into weighting matrix.
Parameters
----------
flat_weights: pandas.DataFrame
A long DataFrame of weights, where columns are "date", "contract",
"generic", "weight" and optionally "key". If "key" column is
pres... | python | def unflatten(flat_weights):
"""
Pivot weights from long DataFrame into weighting matrix.
Parameters
----------
flat_weights: pandas.DataFrame
A long DataFrame of weights, where columns are "date", "contract",
"generic", "weight" and optionally "key". If "key" column is
pres... | [
"def",
"unflatten",
"(",
"flat_weights",
")",
":",
"# NOQA",
"if",
"flat_weights",
".",
"columns",
".",
"contains",
"(",
"\"key\"",
")",
":",
"weights",
"=",
"{",
"}",
"for",
"key",
"in",
"flat_weights",
".",
"loc",
"[",
":",
",",
"\"key\"",
"]",
".",
... | Pivot weights from long DataFrame into weighting matrix.
Parameters
----------
flat_weights: pandas.DataFrame
A long DataFrame of weights, where columns are "date", "contract",
"generic", "weight" and optionally "key". If "key" column is
present a dictionary of unflattened DataFrame... | [
"Pivot",
"weights",
"from",
"long",
"DataFrame",
"into",
"weighting",
"matrix",
"."
] | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/util.py#L92-L143 |
matthewgilbert/mapping | mapping/util.py | calc_rets | def calc_rets(returns, weights):
"""
Calculate continuous return series for futures instruments. These consist
of weighted underlying instrument returns, who's weights can vary over
time.
Parameters
----------
returns: pandas.Series or dict
A Series of instrument returns with a Mult... | python | def calc_rets(returns, weights):
"""
Calculate continuous return series for futures instruments. These consist
of weighted underlying instrument returns, who's weights can vary over
time.
Parameters
----------
returns: pandas.Series or dict
A Series of instrument returns with a Mult... | [
"def",
"calc_rets",
"(",
"returns",
",",
"weights",
")",
":",
"# NOQA",
"if",
"not",
"isinstance",
"(",
"returns",
",",
"dict",
")",
":",
"returns",
"=",
"{",
"\"\"",
":",
"returns",
"}",
"if",
"not",
"isinstance",
"(",
"weights",
",",
"dict",
")",
"... | Calculate continuous return series for futures instruments. These consist
of weighted underlying instrument returns, who's weights can vary over
time.
Parameters
----------
returns: pandas.Series or dict
A Series of instrument returns with a MultiIndex where the top level is
pandas.... | [
"Calculate",
"continuous",
"return",
"series",
"for",
"futures",
"instruments",
".",
"These",
"consist",
"of",
"weighted",
"underlying",
"instrument",
"returns",
"who",
"s",
"weights",
"can",
"vary",
"over",
"time",
"."
] | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/util.py#L146-L225 |
matthewgilbert/mapping | mapping/util.py | reindex | def reindex(prices, index, limit):
"""
Reindex a pd.Series of prices such that when instrument level returns are
calculated they are compatible with a pd.MultiIndex of instrument weights
in calc_rets(). This amount to reindexing the series by an augmented
version of index which includes the precedin... | python | def reindex(prices, index, limit):
"""
Reindex a pd.Series of prices such that when instrument level returns are
calculated they are compatible with a pd.MultiIndex of instrument weights
in calc_rets(). This amount to reindexing the series by an augmented
version of index which includes the precedin... | [
"def",
"reindex",
"(",
"prices",
",",
"index",
",",
"limit",
")",
":",
"if",
"not",
"index",
".",
"is_unique",
":",
"raise",
"ValueError",
"(",
"\"'index' must be unique\"",
")",
"index",
"=",
"index",
".",
"sort_values",
"(",
")",
"index",
".",
"names",
... | Reindex a pd.Series of prices such that when instrument level returns are
calculated they are compatible with a pd.MultiIndex of instrument weights
in calc_rets(). This amount to reindexing the series by an augmented
version of index which includes the preceding date for the first appearance
of each ins... | [
"Reindex",
"a",
"pd",
".",
"Series",
"of",
"prices",
"such",
"that",
"when",
"instrument",
"level",
"returns",
"are",
"calculated",
"they",
"are",
"compatible",
"with",
"a",
"pd",
".",
"MultiIndex",
"of",
"instrument",
"weights",
"in",
"calc_rets",
"()",
"."... | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/util.py#L282-L362 |
matthewgilbert/mapping | mapping/util.py | calc_trades | def calc_trades(current_contracts, desired_holdings, trade_weights, prices,
multipliers, **kwargs):
"""
Calculate the number of tradeable contracts for rebalancing from a set
of current contract holdings to a set of desired generic notional holdings
based on prevailing prices and mapping... | python | def calc_trades(current_contracts, desired_holdings, trade_weights, prices,
multipliers, **kwargs):
"""
Calculate the number of tradeable contracts for rebalancing from a set
of current contract holdings to a set of desired generic notional holdings
based on prevailing prices and mapping... | [
"def",
"calc_trades",
"(",
"current_contracts",
",",
"desired_holdings",
",",
"trade_weights",
",",
"prices",
",",
"multipliers",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"trade_weights",
",",
"dict",
")",
":",
"trade_weights",
"=",
... | Calculate the number of tradeable contracts for rebalancing from a set
of current contract holdings to a set of desired generic notional holdings
based on prevailing prices and mapping from generics to tradeable
instruments. Differences between current holdings and desired holdings
are treated as 0. Zer... | [
"Calculate",
"the",
"number",
"of",
"tradeable",
"contracts",
"for",
"rebalancing",
"from",
"a",
"set",
"of",
"current",
"contract",
"holdings",
"to",
"a",
"set",
"of",
"desired",
"generic",
"notional",
"holdings",
"based",
"on",
"prevailing",
"prices",
"and",
... | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/util.py#L365-L458 |
matthewgilbert/mapping | mapping/util.py | to_notional | def to_notional(instruments, prices, multipliers, desired_ccy=None,
instr_fx=None, fx_rates=None):
"""
Convert number of contracts of tradeable instruments to notional value of
tradeable instruments in a desired currency.
Parameters
----------
instruments: pandas.Series
... | python | def to_notional(instruments, prices, multipliers, desired_ccy=None,
instr_fx=None, fx_rates=None):
"""
Convert number of contracts of tradeable instruments to notional value of
tradeable instruments in a desired currency.
Parameters
----------
instruments: pandas.Series
... | [
"def",
"to_notional",
"(",
"instruments",
",",
"prices",
",",
"multipliers",
",",
"desired_ccy",
"=",
"None",
",",
"instr_fx",
"=",
"None",
",",
"fx_rates",
"=",
"None",
")",
":",
"notionals",
"=",
"_instr_conv",
"(",
"instruments",
",",
"prices",
",",
"mu... | Convert number of contracts of tradeable instruments to notional value of
tradeable instruments in a desired currency.
Parameters
----------
instruments: pandas.Series
Series of instrument holdings. Index is instrument name and values are
number of contracts.
prices: pandas.Series
... | [
"Convert",
"number",
"of",
"contracts",
"of",
"tradeable",
"instruments",
"to",
"notional",
"value",
"of",
"tradeable",
"instruments",
"in",
"a",
"desired",
"currency",
"."
] | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/util.py#L461-L508 |
matthewgilbert/mapping | mapping/util.py | to_contracts | def to_contracts(instruments, prices, multipliers, desired_ccy=None,
instr_fx=None, fx_rates=None, rounder=None):
"""
Convert notional amount of tradeable instruments to number of instrument
contracts, rounding to nearest integer number of contracts.
Parameters
----------
instr... | python | def to_contracts(instruments, prices, multipliers, desired_ccy=None,
instr_fx=None, fx_rates=None, rounder=None):
"""
Convert notional amount of tradeable instruments to number of instrument
contracts, rounding to nearest integer number of contracts.
Parameters
----------
instr... | [
"def",
"to_contracts",
"(",
"instruments",
",",
"prices",
",",
"multipliers",
",",
"desired_ccy",
"=",
"None",
",",
"instr_fx",
"=",
"None",
",",
"fx_rates",
"=",
"None",
",",
"rounder",
"=",
"None",
")",
":",
"contracts",
"=",
"_instr_conv",
"(",
"instrum... | Convert notional amount of tradeable instruments to number of instrument
contracts, rounding to nearest integer number of contracts.
Parameters
----------
instruments: pandas.Series
Series of instrument holdings. Index is instrument name and values are
notional amount on instrument.
... | [
"Convert",
"notional",
"amount",
"of",
"tradeable",
"instruments",
"to",
"number",
"of",
"instrument",
"contracts",
"rounding",
"to",
"nearest",
"integer",
"number",
"of",
"contracts",
"."
] | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/util.py#L511-L557 |
matthewgilbert/mapping | mapping/util.py | get_multiplier | def get_multiplier(weights, root_generic_multiplier):
"""
Determine tradeable instrument multiplier based on generic asset
multipliers and weights mapping from generics to tradeables.
Parameters
----------
weights: pandas.DataFrame or dict
A pandas.DataFrame of loadings of generic contr... | python | def get_multiplier(weights, root_generic_multiplier):
"""
Determine tradeable instrument multiplier based on generic asset
multipliers and weights mapping from generics to tradeables.
Parameters
----------
weights: pandas.DataFrame or dict
A pandas.DataFrame of loadings of generic contr... | [
"def",
"get_multiplier",
"(",
"weights",
",",
"root_generic_multiplier",
")",
":",
"if",
"len",
"(",
"root_generic_multiplier",
")",
">",
"1",
"and",
"not",
"isinstance",
"(",
"weights",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"\"For multiple generic ... | Determine tradeable instrument multiplier based on generic asset
multipliers and weights mapping from generics to tradeables.
Parameters
----------
weights: pandas.DataFrame or dict
A pandas.DataFrame of loadings of generic contracts on tradeable
instruments **for a given date**. The co... | [
"Determine",
"tradeable",
"instrument",
"multiplier",
"based",
"on",
"generic",
"asset",
"multipliers",
"and",
"weights",
"mapping",
"from",
"generics",
"to",
"tradeables",
"."
] | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/util.py#L593-L643 |
matthewgilbert/mapping | mapping/util.py | weighted_expiration | def weighted_expiration(weights, contract_dates):
"""
Calculate the days to expiration for generic futures, weighted by the
composition of the underlying tradeable instruments.
Parameters:
-----------
weights: pandas.DataFrame
A DataFrame of instrument weights with a MultiIndex where th... | python | def weighted_expiration(weights, contract_dates):
"""
Calculate the days to expiration for generic futures, weighted by the
composition of the underlying tradeable instruments.
Parameters:
-----------
weights: pandas.DataFrame
A DataFrame of instrument weights with a MultiIndex where th... | [
"def",
"weighted_expiration",
"(",
"weights",
",",
"contract_dates",
")",
":",
"# NOQA",
"cols",
"=",
"weights",
".",
"columns",
"weights",
"=",
"weights",
".",
"reset_index",
"(",
"level",
"=",
"-",
"1",
")",
"expiries",
"=",
"contract_dates",
".",
"to_dict... | Calculate the days to expiration for generic futures, weighted by the
composition of the underlying tradeable instruments.
Parameters:
-----------
weights: pandas.DataFrame
A DataFrame of instrument weights with a MultiIndex where the top level
contains pandas.Timestamps and the second ... | [
"Calculate",
"the",
"days",
"to",
"expiration",
"for",
"generic",
"futures",
"weighted",
"by",
"the",
"composition",
"of",
"the",
"underlying",
"tradeable",
"instruments",
"."
] | train | https://github.com/matthewgilbert/mapping/blob/24ea21acfe37a0ee273f63a273b5d24ea405e70d/mapping/util.py#L646-L694 |
openstack/networking-arista | networking_arista/ml2/security_groups/arista_security_groups.py | AristaSecurityGroupHandler._valid_baremetal_port | def _valid_baremetal_port(port):
"""Check if port is a baremetal port with exactly one security group"""
if port.get(portbindings.VNIC_TYPE) != portbindings.VNIC_BAREMETAL:
return False
sgs = port.get('security_groups', [])
if len(sgs) == 0:
# Nothing to do
... | python | def _valid_baremetal_port(port):
"""Check if port is a baremetal port with exactly one security group"""
if port.get(portbindings.VNIC_TYPE) != portbindings.VNIC_BAREMETAL:
return False
sgs = port.get('security_groups', [])
if len(sgs) == 0:
# Nothing to do
... | [
"def",
"_valid_baremetal_port",
"(",
"port",
")",
":",
"if",
"port",
".",
"get",
"(",
"portbindings",
".",
"VNIC_TYPE",
")",
"!=",
"portbindings",
".",
"VNIC_BAREMETAL",
":",
"return",
"False",
"sgs",
"=",
"port",
".",
"get",
"(",
"'security_groups'",
",",
... | Check if port is a baremetal port with exactly one security group | [
"Check",
"if",
"port",
"is",
"a",
"baremetal",
"port",
"with",
"exactly",
"one",
"security",
"group"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/arista_security_groups.py#L87-L100 |
openstack/networking-arista | networking_arista/ml2/arista_sync.py | AristaSyncWorker.synchronize_resources | def synchronize_resources(self):
"""Synchronize worker with CVX
All database queries must occur while the sync lock is held. This
tightly couples reads with writes and ensures that an older read
does not result in the last write. Eg:
Worker 1 reads (P1 created)
Worder 2... | python | def synchronize_resources(self):
"""Synchronize worker with CVX
All database queries must occur while the sync lock is held. This
tightly couples reads with writes and ensures that an older read
does not result in the last write. Eg:
Worker 1 reads (P1 created)
Worder 2... | [
"def",
"synchronize_resources",
"(",
"self",
")",
":",
"# Grab the sync lock",
"if",
"not",
"self",
".",
"_rpc",
".",
"sync_start",
"(",
")",
":",
"LOG",
".",
"info",
"(",
"\"%(pid)s Failed to grab the sync lock\"",
",",
"{",
"'pid'",
":",
"os",
".",
"getpid",... | Synchronize worker with CVX
All database queries must occur while the sync lock is held. This
tightly couples reads with writes and ensures that an older read
does not result in the last write. Eg:
Worker 1 reads (P1 created)
Worder 2 reads (P1 deleted)
Worker 2 writes ... | [
"Synchronize",
"worker",
"with",
"CVX"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/arista_sync.py#L176-L241 |
openstack/networking-arista | networking_arista/ml2/arista_trunk.py | AristaTrunkDriver.register | def register(self, resource, event, trigger, **kwargs):
"""Called in trunk plugin's AFTER_INIT"""
super(AristaTrunkDriver, self).register(resource, event,
trigger, kwargs)
registry.subscribe(self.subport_create,
resources... | python | def register(self, resource, event, trigger, **kwargs):
"""Called in trunk plugin's AFTER_INIT"""
super(AristaTrunkDriver, self).register(resource, event,
trigger, kwargs)
registry.subscribe(self.subport_create,
resources... | [
"def",
"register",
"(",
"self",
",",
"resource",
",",
"event",
",",
"trigger",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"AristaTrunkDriver",
",",
"self",
")",
".",
"register",
"(",
"resource",
",",
"event",
",",
"trigger",
",",
"kwargs",
")",
... | Called in trunk plugin's AFTER_INIT | [
"Called",
"in",
"trunk",
"plugin",
"s",
"AFTER_INIT"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/arista_trunk.py#L54-L69 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver.create_router_on_eos | def create_router_on_eos(self, router_name, rdm, server):
"""Creates a router on Arista HW Device.
:param router_name: globally unique identifier for router/VRF
:param rdm: A value generated by hashing router name
:param server: Server endpoint on the Arista switch to be configured
... | python | def create_router_on_eos(self, router_name, rdm, server):
"""Creates a router on Arista HW Device.
:param router_name: globally unique identifier for router/VRF
:param rdm: A value generated by hashing router name
:param server: Server endpoint on the Arista switch to be configured
... | [
"def",
"create_router_on_eos",
"(",
"self",
",",
"router_name",
",",
"rdm",
",",
"server",
")",
":",
"cmds",
"=",
"[",
"]",
"rd",
"=",
"\"%s:%s\"",
"%",
"(",
"rdm",
",",
"rdm",
")",
"for",
"c",
"in",
"self",
".",
"routerDict",
"[",
"'create'",
"]",
... | Creates a router on Arista HW Device.
:param router_name: globally unique identifier for router/VRF
:param rdm: A value generated by hashing router name
:param server: Server endpoint on the Arista switch to be configured | [
"Creates",
"a",
"router",
"on",
"Arista",
"HW",
"Device",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L181-L199 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver.delete_router_from_eos | def delete_router_from_eos(self, router_name, server):
"""Deletes a router from Arista HW Device.
:param router_name: globally unique identifier for router/VRF
:param server: Server endpoint on the Arista switch to be configured
"""
cmds = []
for c in self.routerDict['de... | python | def delete_router_from_eos(self, router_name, server):
"""Deletes a router from Arista HW Device.
:param router_name: globally unique identifier for router/VRF
:param server: Server endpoint on the Arista switch to be configured
"""
cmds = []
for c in self.routerDict['de... | [
"def",
"delete_router_from_eos",
"(",
"self",
",",
"router_name",
",",
"server",
")",
":",
"cmds",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"routerDict",
"[",
"'delete'",
"]",
":",
"cmds",
".",
"append",
"(",
"c",
".",
"format",
"(",
"router_name"... | Deletes a router from Arista HW Device.
:param router_name: globally unique identifier for router/VRF
:param server: Server endpoint on the Arista switch to be configured | [
"Deletes",
"a",
"router",
"from",
"Arista",
"HW",
"Device",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L201-L214 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver.add_interface_to_router | def add_interface_to_router(self, segment_id,
router_name, gip, router_ip, mask, server):
"""Adds an interface to existing HW router on Arista HW device.
:param segment_id: VLAN Id associated with interface that is added
:param router_name: globally unique identi... | python | def add_interface_to_router(self, segment_id,
router_name, gip, router_ip, mask, server):
"""Adds an interface to existing HW router on Arista HW device.
:param segment_id: VLAN Id associated with interface that is added
:param router_name: globally unique identi... | [
"def",
"add_interface_to_router",
"(",
"self",
",",
"segment_id",
",",
"router_name",
",",
"gip",
",",
"router_ip",
",",
"mask",
",",
"server",
")",
":",
"if",
"not",
"segment_id",
":",
"segment_id",
"=",
"DEFAULT_VLAN",
"cmds",
"=",
"[",
"]",
"for",
"c",
... | Adds an interface to existing HW router on Arista HW device.
:param segment_id: VLAN Id associated with interface that is added
:param router_name: globally unique identifier for router/VRF
:param gip: Gateway IP associated with the subnet
:param router_ip: IP address of the router
... | [
"Adds",
"an",
"interface",
"to",
"existing",
"HW",
"router",
"on",
"Arista",
"HW",
"device",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L234-L260 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver.delete_interface_from_router | def delete_interface_from_router(self, segment_id, router_name, server):
"""Deletes an interface from existing HW router on Arista HW device.
:param segment_id: VLAN Id associated with interface that is added
:param router_name: globally unique identifier for router/VRF
:param server: S... | python | def delete_interface_from_router(self, segment_id, router_name, server):
"""Deletes an interface from existing HW router on Arista HW device.
:param segment_id: VLAN Id associated with interface that is added
:param router_name: globally unique identifier for router/VRF
:param server: S... | [
"def",
"delete_interface_from_router",
"(",
"self",
",",
"segment_id",
",",
"router_name",
",",
"server",
")",
":",
"if",
"not",
"segment_id",
":",
"segment_id",
"=",
"DEFAULT_VLAN",
"cmds",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"_interfaceDict",
"["... | Deletes an interface from existing HW router on Arista HW device.
:param segment_id: VLAN Id associated with interface that is added
:param router_name: globally unique identifier for router/VRF
:param server: Server endpoint on the Arista switch to be configured | [
"Deletes",
"an",
"interface",
"from",
"existing",
"HW",
"router",
"on",
"Arista",
"HW",
"device",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L262-L276 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver.create_router | def create_router(self, context, router):
"""Creates a router on Arista Switch.
Deals with multiple configurations - such as Router per VRF,
a router in default VRF, Virtual Router in MLAG configurations
"""
if router:
router_name = self._arista_router_name(router['i... | python | def create_router(self, context, router):
"""Creates a router on Arista Switch.
Deals with multiple configurations - such as Router per VRF,
a router in default VRF, Virtual Router in MLAG configurations
"""
if router:
router_name = self._arista_router_name(router['i... | [
"def",
"create_router",
"(",
"self",
",",
"context",
",",
"router",
")",
":",
"if",
"router",
":",
"router_name",
"=",
"self",
".",
"_arista_router_name",
"(",
"router",
"[",
"'id'",
"]",
",",
"router",
"[",
"'name'",
"]",
")",
"hashed",
"=",
"hashlib",
... | Creates a router on Arista Switch.
Deals with multiple configurations - such as Router per VRF,
a router in default VRF, Virtual Router in MLAG configurations | [
"Creates",
"a",
"router",
"on",
"Arista",
"Switch",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L278-L304 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver.delete_router | def delete_router(self, context, router_id, router):
"""Deletes a router from Arista Switch."""
if router:
router_name = self._arista_router_name(router_id, router['name'])
mlag_peer_failed = False
for s in self._servers:
try:
self... | python | def delete_router(self, context, router_id, router):
"""Deletes a router from Arista Switch."""
if router:
router_name = self._arista_router_name(router_id, router['name'])
mlag_peer_failed = False
for s in self._servers:
try:
self... | [
"def",
"delete_router",
"(",
"self",
",",
"context",
",",
"router_id",
",",
"router",
")",
":",
"if",
"router",
":",
"router_name",
"=",
"self",
".",
"_arista_router_name",
"(",
"router_id",
",",
"router",
"[",
"'name'",
"]",
")",
"mlag_peer_failed",
"=",
... | Deletes a router from Arista Switch. | [
"Deletes",
"a",
"router",
"from",
"Arista",
"Switch",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L306-L324 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver.add_router_interface | def add_router_interface(self, context, router_info):
"""Adds an interface to a router created on Arista HW router.
This deals with both IPv6 and IPv4 configurations.
"""
if router_info:
self._select_dicts(router_info['ip_version'])
cidr = router_info['cidr']
... | python | def add_router_interface(self, context, router_info):
"""Adds an interface to a router created on Arista HW router.
This deals with both IPv6 and IPv4 configurations.
"""
if router_info:
self._select_dicts(router_info['ip_version'])
cidr = router_info['cidr']
... | [
"def",
"add_router_interface",
"(",
"self",
",",
"context",
",",
"router_info",
")",
":",
"if",
"router_info",
":",
"self",
".",
"_select_dicts",
"(",
"router_info",
"[",
"'ip_version'",
"]",
")",
"cidr",
"=",
"router_info",
"[",
"'cidr'",
"]",
"subnet_mask",
... | Adds an interface to a router created on Arista HW router.
This deals with both IPv6 and IPv4 configurations. | [
"Adds",
"an",
"interface",
"to",
"a",
"router",
"created",
"on",
"Arista",
"HW",
"router",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L333-L374 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver.remove_router_interface | def remove_router_interface(self, context, router_info):
"""Removes previously configured interface from router on Arista HW.
This deals with both IPv6 and IPv4 configurations.
"""
if router_info:
router_name = self._arista_router_name(router_info['id'],
... | python | def remove_router_interface(self, context, router_info):
"""Removes previously configured interface from router on Arista HW.
This deals with both IPv6 and IPv4 configurations.
"""
if router_info:
router_name = self._arista_router_name(router_info['id'],
... | [
"def",
"remove_router_interface",
"(",
"self",
",",
"context",
",",
"router_info",
")",
":",
"if",
"router_info",
":",
"router_name",
"=",
"self",
".",
"_arista_router_name",
"(",
"router_info",
"[",
"'id'",
"]",
",",
"router_info",
"[",
"'name'",
"]",
")",
... | Removes previously configured interface from router on Arista HW.
This deals with both IPv6 and IPv4 configurations. | [
"Removes",
"previously",
"configured",
"interface",
"from",
"router",
"on",
"Arista",
"HW",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L376-L398 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver._run_config_cmds | def _run_config_cmds(self, commands, server):
"""Execute/sends a CAPI (Command API) command to EOS.
In this method, list of commands is appended with prefix and
postfix commands - to make is understandble by EOS.
:param commands : List of command to be executed on EOS.
:param s... | python | def _run_config_cmds(self, commands, server):
"""Execute/sends a CAPI (Command API) command to EOS.
In this method, list of commands is appended with prefix and
postfix commands - to make is understandble by EOS.
:param commands : List of command to be executed on EOS.
:param s... | [
"def",
"_run_config_cmds",
"(",
"self",
",",
"commands",
",",
"server",
")",
":",
"command_start",
"=",
"[",
"'enable'",
",",
"'configure'",
"]",
"command_end",
"=",
"[",
"'exit'",
"]",
"full_command",
"=",
"command_start",
"+",
"commands",
"+",
"command_end",... | Execute/sends a CAPI (Command API) command to EOS.
In this method, list of commands is appended with prefix and
postfix commands - to make is understandble by EOS.
:param commands : List of command to be executed on EOS.
:param server: Server endpoint on the Arista switch to be configu... | [
"Execute",
"/",
"sends",
"a",
"CAPI",
"(",
"Command",
"API",
")",
"command",
"to",
"EOS",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L400-L412 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver._get_binary_from_ipv4 | def _get_binary_from_ipv4(self, ip_addr):
"""Converts IPv4 address to binary form."""
return struct.unpack("!L", socket.inet_pton(socket.AF_INET,
ip_addr))[0] | python | def _get_binary_from_ipv4(self, ip_addr):
"""Converts IPv4 address to binary form."""
return struct.unpack("!L", socket.inet_pton(socket.AF_INET,
ip_addr))[0] | [
"def",
"_get_binary_from_ipv4",
"(",
"self",
",",
"ip_addr",
")",
":",
"return",
"struct",
".",
"unpack",
"(",
"\"!L\"",
",",
"socket",
".",
"inet_pton",
"(",
"socket",
".",
"AF_INET",
",",
"ip_addr",
")",
")",
"[",
"0",
"]"
] | Converts IPv4 address to binary form. | [
"Converts",
"IPv4",
"address",
"to",
"binary",
"form",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L439-L443 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver._get_binary_from_ipv6 | def _get_binary_from_ipv6(self, ip_addr):
"""Converts IPv6 address to binary form."""
hi, lo = struct.unpack("!QQ", socket.inet_pton(socket.AF_INET6,
ip_addr))
return (hi << 64) | lo | python | def _get_binary_from_ipv6(self, ip_addr):
"""Converts IPv6 address to binary form."""
hi, lo = struct.unpack("!QQ", socket.inet_pton(socket.AF_INET6,
ip_addr))
return (hi << 64) | lo | [
"def",
"_get_binary_from_ipv6",
"(",
"self",
",",
"ip_addr",
")",
":",
"hi",
",",
"lo",
"=",
"struct",
".",
"unpack",
"(",
"\"!QQ\"",
",",
"socket",
".",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"ip_addr",
")",
")",
"return",
"(",
"hi",
"<<",
... | Converts IPv6 address to binary form. | [
"Converts",
"IPv6",
"address",
"to",
"binary",
"form",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L445-L450 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver._get_ipv4_from_binary | def _get_ipv4_from_binary(self, bin_addr):
"""Converts binary address to Ipv4 format."""
return socket.inet_ntop(socket.AF_INET, struct.pack("!L", bin_addr)) | python | def _get_ipv4_from_binary(self, bin_addr):
"""Converts binary address to Ipv4 format."""
return socket.inet_ntop(socket.AF_INET, struct.pack("!L", bin_addr)) | [
"def",
"_get_ipv4_from_binary",
"(",
"self",
",",
"bin_addr",
")",
":",
"return",
"socket",
".",
"inet_ntop",
"(",
"socket",
".",
"AF_INET",
",",
"struct",
".",
"pack",
"(",
"\"!L\"",
",",
"bin_addr",
")",
")"
] | Converts binary address to Ipv4 format. | [
"Converts",
"binary",
"address",
"to",
"Ipv4",
"format",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L452-L455 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver._get_ipv6_from_binary | def _get_ipv6_from_binary(self, bin_addr):
"""Converts binary address to Ipv6 format."""
hi = bin_addr >> 64
lo = bin_addr & 0xFFFFFFFF
return socket.inet_ntop(socket.AF_INET6, struct.pack("!QQ", hi, lo)) | python | def _get_ipv6_from_binary(self, bin_addr):
"""Converts binary address to Ipv6 format."""
hi = bin_addr >> 64
lo = bin_addr & 0xFFFFFFFF
return socket.inet_ntop(socket.AF_INET6, struct.pack("!QQ", hi, lo)) | [
"def",
"_get_ipv6_from_binary",
"(",
"self",
",",
"bin_addr",
")",
":",
"hi",
"=",
"bin_addr",
">>",
"64",
"lo",
"=",
"bin_addr",
"&",
"0xFFFFFFFF",
"return",
"socket",
".",
"inet_ntop",
"(",
"socket",
".",
"AF_INET6",
",",
"struct",
".",
"pack",
"(",
"\... | Converts binary address to Ipv6 format. | [
"Converts",
"binary",
"address",
"to",
"Ipv6",
"format",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L457-L462 |
openstack/networking-arista | networking_arista/l3Plugin/arista_l3_driver.py | AristaL3Driver._get_router_ip | def _get_router_ip(self, cidr, ip_count, ip_ver):
"""For a given IP subnet and IP version type, generate IP for router.
This method takes the network address (cidr) and selects an
IP address that should be assigned to virtual router running
on multiple switches. It uses upper addresses ... | python | def _get_router_ip(self, cidr, ip_count, ip_ver):
"""For a given IP subnet and IP version type, generate IP for router.
This method takes the network address (cidr) and selects an
IP address that should be assigned to virtual router running
on multiple switches. It uses upper addresses ... | [
"def",
"_get_router_ip",
"(",
"self",
",",
"cidr",
",",
"ip_count",
",",
"ip_ver",
")",
":",
"start_ip",
"=",
"MLAG_SWITCHES",
"+",
"ip_count",
"network_addr",
",",
"prefix",
"=",
"cidr",
".",
"split",
"(",
"'/'",
")",
"if",
"ip_ver",
"==",
"4",
":",
"... | For a given IP subnet and IP version type, generate IP for router.
This method takes the network address (cidr) and selects an
IP address that should be assigned to virtual router running
on multiple switches. It uses upper addresses in a subnet address
as IP for the router. Each instac... | [
"For",
"a",
"given",
"IP",
"subnet",
"and",
"IP",
"version",
"type",
"generate",
"IP",
"for",
"router",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/l3Plugin/arista_l3_driver.py#L464-L494 |
openstack/networking-arista | networking_arista/db/migration/alembic_migrations/env.py | run_migrations_offline | def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL or an Engine.
Calls to context.execute() here emit the given string to the
script output.
"""
set_mysql_engine()
kwargs = dict()
if neutron_config.database.connection:
... | python | def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL or an Engine.
Calls to context.execute() here emit the given string to the
script output.
"""
set_mysql_engine()
kwargs = dict()
if neutron_config.database.connection:
... | [
"def",
"run_migrations_offline",
"(",
")",
":",
"set_mysql_engine",
"(",
")",
"kwargs",
"=",
"dict",
"(",
")",
"if",
"neutron_config",
".",
"database",
".",
"connection",
":",
"kwargs",
"[",
"'url'",
"]",
"=",
"neutron_config",
".",
"database",
".",
"connect... | Run migrations in 'offline' mode.
This configures the context with just a URL or an Engine.
Calls to context.execute() here emit the given string to the
script output. | [
"Run",
"migrations",
"in",
"offline",
"mode",
"."
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/db/migration/alembic_migrations/env.py#L64-L85 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.create_tenant | def create_tenant(self, tenant_id):
"""Enqueue tenant create"""
t_res = MechResource(tenant_id, a_const.TENANT_RESOURCE,
a_const.CREATE)
self.provision_queue.put(t_res) | python | def create_tenant(self, tenant_id):
"""Enqueue tenant create"""
t_res = MechResource(tenant_id, a_const.TENANT_RESOURCE,
a_const.CREATE)
self.provision_queue.put(t_res) | [
"def",
"create_tenant",
"(",
"self",
",",
"tenant_id",
")",
":",
"t_res",
"=",
"MechResource",
"(",
"tenant_id",
",",
"a_const",
".",
"TENANT_RESOURCE",
",",
"a_const",
".",
"CREATE",
")",
"self",
".",
"provision_queue",
".",
"put",
"(",
"t_res",
")"
] | Enqueue tenant create | [
"Enqueue",
"tenant",
"create"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L78-L82 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.delete_tenant_if_removed | def delete_tenant_if_removed(self, tenant_id):
"""Enqueue tenant delete if it's no longer in the db"""
if not db_lib.tenant_provisioned(tenant_id):
t_res = MechResource(tenant_id, a_const.TENANT_RESOURCE,
a_const.DELETE)
self.provision_queue.put(t... | python | def delete_tenant_if_removed(self, tenant_id):
"""Enqueue tenant delete if it's no longer in the db"""
if not db_lib.tenant_provisioned(tenant_id):
t_res = MechResource(tenant_id, a_const.TENANT_RESOURCE,
a_const.DELETE)
self.provision_queue.put(t... | [
"def",
"delete_tenant_if_removed",
"(",
"self",
",",
"tenant_id",
")",
":",
"if",
"not",
"db_lib",
".",
"tenant_provisioned",
"(",
"tenant_id",
")",
":",
"t_res",
"=",
"MechResource",
"(",
"tenant_id",
",",
"a_const",
".",
"TENANT_RESOURCE",
",",
"a_const",
".... | Enqueue tenant delete if it's no longer in the db | [
"Enqueue",
"tenant",
"delete",
"if",
"it",
"s",
"no",
"longer",
"in",
"the",
"db"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L84-L89 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.create_network | def create_network(self, network):
"""Enqueue network create"""
n_res = MechResource(network['id'], a_const.NETWORK_RESOURCE,
a_const.CREATE)
self.provision_queue.put(n_res) | python | def create_network(self, network):
"""Enqueue network create"""
n_res = MechResource(network['id'], a_const.NETWORK_RESOURCE,
a_const.CREATE)
self.provision_queue.put(n_res) | [
"def",
"create_network",
"(",
"self",
",",
"network",
")",
":",
"n_res",
"=",
"MechResource",
"(",
"network",
"[",
"'id'",
"]",
",",
"a_const",
".",
"NETWORK_RESOURCE",
",",
"a_const",
".",
"CREATE",
")",
"self",
".",
"provision_queue",
".",
"put",
"(",
... | Enqueue network create | [
"Enqueue",
"network",
"create"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L91-L95 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.delete_network | def delete_network(self, network):
"""Enqueue network delete"""
n_res = MechResource(network['id'], a_const.NETWORK_RESOURCE,
a_const.DELETE)
self.provision_queue.put(n_res) | python | def delete_network(self, network):
"""Enqueue network delete"""
n_res = MechResource(network['id'], a_const.NETWORK_RESOURCE,
a_const.DELETE)
self.provision_queue.put(n_res) | [
"def",
"delete_network",
"(",
"self",
",",
"network",
")",
":",
"n_res",
"=",
"MechResource",
"(",
"network",
"[",
"'id'",
"]",
",",
"a_const",
".",
"NETWORK_RESOURCE",
",",
"a_const",
".",
"DELETE",
")",
"self",
".",
"provision_queue",
".",
"put",
"(",
... | Enqueue network delete | [
"Enqueue",
"network",
"delete"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L97-L101 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.create_segments | def create_segments(self, segments):
"""Enqueue segment creates"""
for segment in segments:
s_res = MechResource(segment['id'], a_const.SEGMENT_RESOURCE,
a_const.CREATE)
self.provision_queue.put(s_res) | python | def create_segments(self, segments):
"""Enqueue segment creates"""
for segment in segments:
s_res = MechResource(segment['id'], a_const.SEGMENT_RESOURCE,
a_const.CREATE)
self.provision_queue.put(s_res) | [
"def",
"create_segments",
"(",
"self",
",",
"segments",
")",
":",
"for",
"segment",
"in",
"segments",
":",
"s_res",
"=",
"MechResource",
"(",
"segment",
"[",
"'id'",
"]",
",",
"a_const",
".",
"SEGMENT_RESOURCE",
",",
"a_const",
".",
"CREATE",
")",
"self",
... | Enqueue segment creates | [
"Enqueue",
"segment",
"creates"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L103-L108 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.delete_segments | def delete_segments(self, segments):
"""Enqueue segment deletes"""
for segment in segments:
s_res = MechResource(segment['id'], a_const.SEGMENT_RESOURCE,
a_const.DELETE)
self.provision_queue.put(s_res) | python | def delete_segments(self, segments):
"""Enqueue segment deletes"""
for segment in segments:
s_res = MechResource(segment['id'], a_const.SEGMENT_RESOURCE,
a_const.DELETE)
self.provision_queue.put(s_res) | [
"def",
"delete_segments",
"(",
"self",
",",
"segments",
")",
":",
"for",
"segment",
"in",
"segments",
":",
"s_res",
"=",
"MechResource",
"(",
"segment",
"[",
"'id'",
"]",
",",
"a_const",
".",
"SEGMENT_RESOURCE",
",",
"a_const",
".",
"DELETE",
")",
"self",
... | Enqueue segment deletes | [
"Enqueue",
"segment",
"deletes"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L110-L115 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.get_instance_type | def get_instance_type(self, port):
"""Determine the port type based on device owner and vnic type"""
if port[portbindings.VNIC_TYPE] == portbindings.VNIC_BAREMETAL:
return a_const.BAREMETAL_RESOURCE
owner_to_type = {
n_const.DEVICE_OWNER_DHCP: a_const.DHCP_RESOURCE,
... | python | def get_instance_type(self, port):
"""Determine the port type based on device owner and vnic type"""
if port[portbindings.VNIC_TYPE] == portbindings.VNIC_BAREMETAL:
return a_const.BAREMETAL_RESOURCE
owner_to_type = {
n_const.DEVICE_OWNER_DHCP: a_const.DHCP_RESOURCE,
... | [
"def",
"get_instance_type",
"(",
"self",
",",
"port",
")",
":",
"if",
"port",
"[",
"portbindings",
".",
"VNIC_TYPE",
"]",
"==",
"portbindings",
".",
"VNIC_BAREMETAL",
":",
"return",
"a_const",
".",
"BAREMETAL_RESOURCE",
"owner_to_type",
"=",
"{",
"n_const",
".... | Determine the port type based on device owner and vnic type | [
"Determine",
"the",
"port",
"type",
"based",
"on",
"device",
"owner",
"and",
"vnic",
"type"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L117-L130 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.create_instance | def create_instance(self, port):
"""Enqueue instance create"""
instance_type = self.get_instance_type(port)
if not instance_type:
return
i_res = MechResource(port['device_id'], instance_type, a_const.CREATE)
self.provision_queue.put(i_res) | python | def create_instance(self, port):
"""Enqueue instance create"""
instance_type = self.get_instance_type(port)
if not instance_type:
return
i_res = MechResource(port['device_id'], instance_type, a_const.CREATE)
self.provision_queue.put(i_res) | [
"def",
"create_instance",
"(",
"self",
",",
"port",
")",
":",
"instance_type",
"=",
"self",
".",
"get_instance_type",
"(",
"port",
")",
"if",
"not",
"instance_type",
":",
"return",
"i_res",
"=",
"MechResource",
"(",
"port",
"[",
"'device_id'",
"]",
",",
"i... | Enqueue instance create | [
"Enqueue",
"instance",
"create"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L132-L138 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.delete_instance_if_removed | def delete_instance_if_removed(self, port):
"""Enqueue instance delete if it's no longer in the db"""
instance_type = self.get_instance_type(port)
if not instance_type:
return
if not db_lib.instance_provisioned(port['device_id']):
i_res = MechResource(port['device... | python | def delete_instance_if_removed(self, port):
"""Enqueue instance delete if it's no longer in the db"""
instance_type = self.get_instance_type(port)
if not instance_type:
return
if not db_lib.instance_provisioned(port['device_id']):
i_res = MechResource(port['device... | [
"def",
"delete_instance_if_removed",
"(",
"self",
",",
"port",
")",
":",
"instance_type",
"=",
"self",
".",
"get_instance_type",
"(",
"port",
")",
"if",
"not",
"instance_type",
":",
"return",
"if",
"not",
"db_lib",
".",
"instance_provisioned",
"(",
"port",
"["... | Enqueue instance delete if it's no longer in the db | [
"Enqueue",
"instance",
"delete",
"if",
"it",
"s",
"no",
"longer",
"in",
"the",
"db"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L140-L148 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.create_port | def create_port(self, port):
"""Enqueue port create"""
instance_type = self.get_instance_type(port)
if not instance_type:
return
port_type = instance_type + a_const.PORT_SUFFIX
p_res = MechResource(port['id'], port_type, a_const.CREATE)
self.provision_queue.pu... | python | def create_port(self, port):
"""Enqueue port create"""
instance_type = self.get_instance_type(port)
if not instance_type:
return
port_type = instance_type + a_const.PORT_SUFFIX
p_res = MechResource(port['id'], port_type, a_const.CREATE)
self.provision_queue.pu... | [
"def",
"create_port",
"(",
"self",
",",
"port",
")",
":",
"instance_type",
"=",
"self",
".",
"get_instance_type",
"(",
"port",
")",
"if",
"not",
"instance_type",
":",
"return",
"port_type",
"=",
"instance_type",
"+",
"a_const",
".",
"PORT_SUFFIX",
"p_res",
"... | Enqueue port create | [
"Enqueue",
"port",
"create"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L150-L157 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.delete_port_if_removed | def delete_port_if_removed(self, port):
"""Enqueue port delete"""
instance_type = self.get_instance_type(port)
if not instance_type:
return
port_type = instance_type + a_const.PORT_SUFFIX
if not db_lib.port_provisioned(port['id']):
p_res = MechResource(por... | python | def delete_port_if_removed(self, port):
"""Enqueue port delete"""
instance_type = self.get_instance_type(port)
if not instance_type:
return
port_type = instance_type + a_const.PORT_SUFFIX
if not db_lib.port_provisioned(port['id']):
p_res = MechResource(por... | [
"def",
"delete_port_if_removed",
"(",
"self",
",",
"port",
")",
":",
"instance_type",
"=",
"self",
".",
"get_instance_type",
"(",
"port",
")",
"if",
"not",
"instance_type",
":",
"return",
"port_type",
"=",
"instance_type",
"+",
"a_const",
".",
"PORT_SUFFIX",
"... | Enqueue port delete | [
"Enqueue",
"port",
"delete"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L159-L167 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver._get_binding_keys | def _get_binding_keys(self, port, host):
"""Get binding keys from the port binding"""
binding_keys = list()
switch_binding = port[portbindings.PROFILE].get(
'local_link_information', None)
if switch_binding:
for binding in switch_binding:
switch_id... | python | def _get_binding_keys(self, port, host):
"""Get binding keys from the port binding"""
binding_keys = list()
switch_binding = port[portbindings.PROFILE].get(
'local_link_information', None)
if switch_binding:
for binding in switch_binding:
switch_id... | [
"def",
"_get_binding_keys",
"(",
"self",
",",
"port",
",",
"host",
")",
":",
"binding_keys",
"=",
"list",
"(",
")",
"switch_binding",
"=",
"port",
"[",
"portbindings",
".",
"PROFILE",
"]",
".",
"get",
"(",
"'local_link_information'",
",",
"None",
")",
"if"... | Get binding keys from the port binding | [
"Get",
"binding",
"keys",
"from",
"the",
"port",
"binding"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L169-L181 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.create_port_binding | def create_port_binding(self, port, host):
"""Enqueue port binding create"""
if not self.get_instance_type(port):
return
for pb_key in self._get_binding_keys(port, host):
pb_res = MechResource(pb_key, a_const.PORT_BINDING_RESOURCE,
a_cons... | python | def create_port_binding(self, port, host):
"""Enqueue port binding create"""
if not self.get_instance_type(port):
return
for pb_key in self._get_binding_keys(port, host):
pb_res = MechResource(pb_key, a_const.PORT_BINDING_RESOURCE,
a_cons... | [
"def",
"create_port_binding",
"(",
"self",
",",
"port",
",",
"host",
")",
":",
"if",
"not",
"self",
".",
"get_instance_type",
"(",
"port",
")",
":",
"return",
"for",
"pb_key",
"in",
"self",
".",
"_get_binding_keys",
"(",
"port",
",",
"host",
")",
":",
... | Enqueue port binding create | [
"Enqueue",
"port",
"binding",
"create"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L183-L190 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.delete_port_binding | def delete_port_binding(self, port, host):
"""Enqueue port binding delete"""
if not self.get_instance_type(port):
return
for pb_key in self._get_binding_keys(port, host):
pb_res = MechResource(pb_key, a_const.PORT_BINDING_RESOURCE,
a_cons... | python | def delete_port_binding(self, port, host):
"""Enqueue port binding delete"""
if not self.get_instance_type(port):
return
for pb_key in self._get_binding_keys(port, host):
pb_res = MechResource(pb_key, a_const.PORT_BINDING_RESOURCE,
a_cons... | [
"def",
"delete_port_binding",
"(",
"self",
",",
"port",
",",
"host",
")",
":",
"if",
"not",
"self",
".",
"get_instance_type",
"(",
"port",
")",
":",
"return",
"for",
"pb_key",
"in",
"self",
".",
"_get_binding_keys",
"(",
"port",
",",
"host",
")",
":",
... | Enqueue port binding delete | [
"Enqueue",
"port",
"binding",
"delete"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L192-L199 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.create_network_postcommit | def create_network_postcommit(self, context):
"""Provision the network on CVX"""
network = context.current
log_context("create_network_postcommit: network", network)
segments = context.network_segments
tenant_id = network['project_id']
self.create_tenant(tenant_id)
... | python | def create_network_postcommit(self, context):
"""Provision the network on CVX"""
network = context.current
log_context("create_network_postcommit: network", network)
segments = context.network_segments
tenant_id = network['project_id']
self.create_tenant(tenant_id)
... | [
"def",
"create_network_postcommit",
"(",
"self",
",",
"context",
")",
":",
"network",
"=",
"context",
".",
"current",
"log_context",
"(",
"\"create_network_postcommit: network\"",
",",
"network",
")",
"segments",
"=",
"context",
".",
"network_segments",
"tenant_id",
... | Provision the network on CVX | [
"Provision",
"the",
"network",
"on",
"CVX"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L201-L211 |
openstack/networking-arista | networking_arista/ml2/mechanism_arista.py | AristaDriver.update_network_postcommit | def update_network_postcommit(self, context):
"""Send network updates to CVX:
- Update the network name
- Add new segments
- Delete stale segments
"""
network = context.current
orig_network = context.original
log_context("update_network_postcommit: netwo... | python | def update_network_postcommit(self, context):
"""Send network updates to CVX:
- Update the network name
- Add new segments
- Delete stale segments
"""
network = context.current
orig_network = context.original
log_context("update_network_postcommit: netwo... | [
"def",
"update_network_postcommit",
"(",
"self",
",",
"context",
")",
":",
"network",
"=",
"context",
".",
"current",
"orig_network",
"=",
"context",
".",
"original",
"log_context",
"(",
"\"update_network_postcommit: network\"",
",",
"network",
")",
"log_context",
"... | Send network updates to CVX:
- Update the network name
- Add new segments
- Delete stale segments | [
"Send",
"network",
"updates",
"to",
"CVX",
":"
] | train | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/mechanism_arista.py#L213-L231 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.