repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
openstack/horizon | openstack_dashboard/dashboards/admin/flavors/tables.py | FlavorFilterAction.filter | def filter(self, table, flavors, filter_string):
"""Really naive case-insensitive search."""
q = filter_string.lower()
def comp(flavor):
return q in flavor.name.lower()
return filter(comp, flavors) | python | def filter(self, table, flavors, filter_string):
"""Really naive case-insensitive search."""
q = filter_string.lower()
def comp(flavor):
return q in flavor.name.lower()
return filter(comp, flavors) | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"flavors",
",",
"filter_string",
")",
":",
"q",
"=",
"filter_string",
".",
"lower",
"(",
")",
"def",
"comp",
"(",
"flavor",
")",
":",
"return",
"q",
"in",
"flavor",
".",
"name",
".",
"lower",
"(",
")... | Really naive case-insensitive search. | [
"Really",
"naive",
"case",
"-",
"insensitive",
"search",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/admin/flavors/tables.py#L104-L111 | train |
openstack/horizon | horizon/middleware/operation_log.py | OperationLogMiddleware._process_response | def _process_response(self, request, response):
"""Log user operation."""
log_format = self._get_log_format(request)
if not log_format:
return response
params = self._get_parameters_from_request(request)
# log a message displayed to user
messages = django_mes... | python | def _process_response(self, request, response):
"""Log user operation."""
log_format = self._get_log_format(request)
if not log_format:
return response
params = self._get_parameters_from_request(request)
# log a message displayed to user
messages = django_mes... | [
"def",
"_process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"log_format",
"=",
"self",
".",
"_get_log_format",
"(",
"request",
")",
"if",
"not",
"log_format",
":",
"return",
"response",
"params",
"=",
"self",
".",
"_get_parameters_from_... | Log user operation. | [
"Log",
"user",
"operation",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/middleware/operation_log.py#L87-L107 | train |
openstack/horizon | horizon/middleware/operation_log.py | OperationLogMiddleware.process_exception | def process_exception(self, request, exception):
"""Log error info when exception occurred."""
log_format = self._get_log_format(request)
if log_format is None:
return
params = self._get_parameters_from_request(request, True)
params['message'] = exception
par... | python | def process_exception(self, request, exception):
"""Log error info when exception occurred."""
log_format = self._get_log_format(request)
if log_format is None:
return
params = self._get_parameters_from_request(request, True)
params['message'] = exception
par... | [
"def",
"process_exception",
"(",
"self",
",",
"request",
",",
"exception",
")",
":",
"log_format",
"=",
"self",
".",
"_get_log_format",
"(",
"request",
")",
"if",
"log_format",
"is",
"None",
":",
"return",
"params",
"=",
"self",
".",
"_get_parameters_from_requ... | Log error info when exception occurred. | [
"Log",
"error",
"info",
"when",
"exception",
"occurred",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/middleware/operation_log.py#L109-L119 | train |
openstack/horizon | horizon/middleware/operation_log.py | OperationLogMiddleware._get_log_format | def _get_log_format(self, request):
"""Return operation log format."""
user = getattr(request, 'user', None)
if not user:
return
if not request.user.is_authenticated:
return
method = request.method.upper()
if not (method in self.target_methods):
... | python | def _get_log_format(self, request):
"""Return operation log format."""
user = getattr(request, 'user', None)
if not user:
return
if not request.user.is_authenticated:
return
method = request.method.upper()
if not (method in self.target_methods):
... | [
"def",
"_get_log_format",
"(",
"self",
",",
"request",
")",
":",
"user",
"=",
"getattr",
"(",
"request",
",",
"'user'",
",",
"None",
")",
"if",
"not",
"user",
":",
"return",
"if",
"not",
"request",
".",
"user",
".",
"is_authenticated",
":",
"return",
"... | Return operation log format. | [
"Return",
"operation",
"log",
"format",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/middleware/operation_log.py#L121-L135 | train |
openstack/horizon | horizon/middleware/operation_log.py | OperationLogMiddleware._get_parameters_from_request | def _get_parameters_from_request(self, request, exception=False):
"""Get parameters to log in OPERATION_LOG."""
user = request.user
referer_url = None
try:
referer_dic = urlparse.urlsplit(
urlparse.unquote(request.META.get('HTTP_REFERER')))
referer... | python | def _get_parameters_from_request(self, request, exception=False):
"""Get parameters to log in OPERATION_LOG."""
user = request.user
referer_url = None
try:
referer_dic = urlparse.urlsplit(
urlparse.unquote(request.META.get('HTTP_REFERER')))
referer... | [
"def",
"_get_parameters_from_request",
"(",
"self",
",",
"request",
",",
"exception",
"=",
"False",
")",
":",
"user",
"=",
"request",
".",
"user",
"referer_url",
"=",
"None",
"try",
":",
"referer_dic",
"=",
"urlparse",
".",
"urlsplit",
"(",
"urlparse",
".",
... | Get parameters to log in OPERATION_LOG. | [
"Get",
"parameters",
"to",
"log",
"in",
"OPERATION_LOG",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/middleware/operation_log.py#L137-L167 | train |
openstack/horizon | horizon/middleware/operation_log.py | OperationLogMiddleware._get_request_param | def _get_request_param(self, request):
"""Change POST data to JSON string and mask data."""
params = {}
try:
params = request.POST.copy()
if not params:
params = json.loads(request.body)
except Exception:
pass
for key in params:... | python | def _get_request_param(self, request):
"""Change POST data to JSON string and mask data."""
params = {}
try:
params = request.POST.copy()
if not params:
params = json.loads(request.body)
except Exception:
pass
for key in params:... | [
"def",
"_get_request_param",
"(",
"self",
",",
"request",
")",
":",
"params",
"=",
"{",
"}",
"try",
":",
"params",
"=",
"request",
".",
"POST",
".",
"copy",
"(",
")",
"if",
"not",
"params",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"request",
... | Change POST data to JSON string and mask data. | [
"Change",
"POST",
"data",
"to",
"JSON",
"string",
"and",
"mask",
"data",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/middleware/operation_log.py#L169-L193 | train |
openstack/horizon | openstack_dashboard/dashboards/identity/projects/workflows.py | UpdateProject._update_project | def _update_project(self, request, data):
"""Update project info"""
domain_id = identity.get_domain_id_for_operation(request)
try:
project_id = data['project_id']
# add extra information
if keystone.VERSIONS.active >= 3:
EXTRA_INFO = getattr(s... | python | def _update_project(self, request, data):
"""Update project info"""
domain_id = identity.get_domain_id_for_operation(request)
try:
project_id = data['project_id']
# add extra information
if keystone.VERSIONS.active >= 3:
EXTRA_INFO = getattr(s... | [
"def",
"_update_project",
"(",
"self",
",",
"request",
",",
"data",
")",
":",
"domain_id",
"=",
"identity",
".",
"get_domain_id_for_operation",
"(",
"request",
")",
"try",
":",
"project_id",
"=",
"data",
"[",
"'project_id'",
"]",
"# add extra information",
"if",... | Update project info | [
"Update",
"project",
"info"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/identity/projects/workflows.py#L683-L711 | train |
openstack/horizon | horizon/tables/formset.py | FormsetDataTableMixin.get_required_columns | def get_required_columns(self):
"""Lists names of columns that have required fields."""
required_columns = []
if self.formset_class:
empty_form = self.get_formset().empty_form
for column in self.columns.values():
field = empty_form.fields.get(column.name)
... | python | def get_required_columns(self):
"""Lists names of columns that have required fields."""
required_columns = []
if self.formset_class:
empty_form = self.get_formset().empty_form
for column in self.columns.values():
field = empty_form.fields.get(column.name)
... | [
"def",
"get_required_columns",
"(",
"self",
")",
":",
"required_columns",
"=",
"[",
"]",
"if",
"self",
".",
"formset_class",
":",
"empty_form",
"=",
"self",
".",
"get_formset",
"(",
")",
".",
"empty_form",
"for",
"column",
"in",
"self",
".",
"columns",
"."... | Lists names of columns that have required fields. | [
"Lists",
"names",
"of",
"columns",
"that",
"have",
"required",
"fields",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/formset.py#L87-L96 | train |
openstack/horizon | horizon/tables/formset.py | FormsetDataTableMixin._get_formset_data | def _get_formset_data(self):
"""Formats the self.filtered_data in a way suitable for a formset."""
data = []
for datum in self.filtered_data:
form_data = {}
for column in self.columns.values():
value = column.get_data(datum)
form_data[colum... | python | def _get_formset_data(self):
"""Formats the self.filtered_data in a way suitable for a formset."""
data = []
for datum in self.filtered_data:
form_data = {}
for column in self.columns.values():
value = column.get_data(datum)
form_data[colum... | [
"def",
"_get_formset_data",
"(",
"self",
")",
":",
"data",
"=",
"[",
"]",
"for",
"datum",
"in",
"self",
".",
"filtered_data",
":",
"form_data",
"=",
"{",
"}",
"for",
"column",
"in",
"self",
".",
"columns",
".",
"values",
"(",
")",
":",
"value",
"=",
... | Formats the self.filtered_data in a way suitable for a formset. | [
"Formats",
"the",
"self",
".",
"filtered_data",
"in",
"a",
"way",
"suitable",
"for",
"a",
"formset",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/formset.py#L98-L108 | train |
openstack/horizon | horizon/tables/formset.py | FormsetDataTableMixin.get_rows | def get_rows(self):
"""Return the row data for this table broken out by columns.
The row objects get an additional ``form`` parameter, with the
formset form corresponding to that row.
"""
try:
rows = []
if self.formset_class is None:
forms... | python | def get_rows(self):
"""Return the row data for this table broken out by columns.
The row objects get an additional ``form`` parameter, with the
formset form corresponding to that row.
"""
try:
rows = []
if self.formset_class is None:
forms... | [
"def",
"get_rows",
"(",
"self",
")",
":",
"try",
":",
"rows",
"=",
"[",
"]",
"if",
"self",
".",
"formset_class",
"is",
"None",
":",
"formset",
"=",
"[",
"]",
"else",
":",
"formset",
"=",
"self",
".",
"get_formset",
"(",
")",
"formset",
".",
"is_val... | Return the row data for this table broken out by columns.
The row objects get an additional ``form`` parameter, with the
formset form corresponding to that row. | [
"Return",
"the",
"row",
"data",
"for",
"this",
"table",
"broken",
"out",
"by",
"columns",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/formset.py#L126-L153 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | keystoneclient | def keystoneclient(request, admin=False):
"""Returns a client connected to the Keystone backend.
Several forms of authentication are supported:
* Username + password -> Unscoped authentication
* Username + password + tenant id -> Scoped authentication
* Unscoped token -> Unscoped authe... | python | def keystoneclient(request, admin=False):
"""Returns a client connected to the Keystone backend.
Several forms of authentication are supported:
* Username + password -> Unscoped authentication
* Username + password + tenant id -> Scoped authentication
* Unscoped token -> Unscoped authe... | [
"def",
"keystoneclient",
"(",
"request",
",",
"admin",
"=",
"False",
")",
":",
"client_version",
"=",
"VERSIONS",
".",
"get_active_version",
"(",
")",
"user",
"=",
"request",
".",
"user",
"token_id",
"=",
"user",
".",
"token",
".",
"id",
"if",
"is_multi_do... | Returns a client connected to the Keystone backend.
Several forms of authentication are supported:
* Username + password -> Unscoped authentication
* Username + password + tenant id -> Scoped authentication
* Unscoped token -> Unscoped authentication
* Unscoped token + tenant id ->... | [
"Returns",
"a",
"client",
"connected",
"to",
"the",
"Keystone",
"backend",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L141-L206 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | get_default_domain | def get_default_domain(request, get_name=True):
"""Gets the default domain object to use when creating Identity object.
Returns the domain context if is set, otherwise return the domain
of the logon user.
:param get_name: Whether to get the domain name from Keystone if the
context isn't set. ... | python | def get_default_domain(request, get_name=True):
"""Gets the default domain object to use when creating Identity object.
Returns the domain context if is set, otherwise return the domain
of the logon user.
:param get_name: Whether to get the domain name from Keystone if the
context isn't set. ... | [
"def",
"get_default_domain",
"(",
"request",
",",
"get_name",
"=",
"True",
")",
":",
"domain_id",
"=",
"request",
".",
"session",
".",
"get",
"(",
"\"domain_context\"",
",",
"None",
")",
"domain_name",
"=",
"request",
".",
"session",
".",
"get",
"(",
"\"do... | Gets the default domain object to use when creating Identity object.
Returns the domain context if is set, otherwise return the domain
of the logon user.
:param get_name: Whether to get the domain name from Keystone if the
context isn't set. Setting this to False prevents an unnecessary call
... | [
"Gets",
"the",
"default",
"domain",
"object",
"to",
"use",
"when",
"creating",
"Identity",
"object",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L284-L324 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | get_effective_domain_id | def get_effective_domain_id(request):
"""Gets the id of the default domain.
If the requests default domain is the same as DEFAULT_DOMAIN,
return None.
"""
default_domain = get_default_domain(request)
domain_id = default_domain.get('id')
domain_name = default_domain.get('name')
return No... | python | def get_effective_domain_id(request):
"""Gets the id of the default domain.
If the requests default domain is the same as DEFAULT_DOMAIN,
return None.
"""
default_domain = get_default_domain(request)
domain_id = default_domain.get('id')
domain_name = default_domain.get('name')
return No... | [
"def",
"get_effective_domain_id",
"(",
"request",
")",
":",
"default_domain",
"=",
"get_default_domain",
"(",
"request",
")",
"domain_id",
"=",
"default_domain",
".",
"get",
"(",
"'id'",
")",
"domain_name",
"=",
"default_domain",
".",
"get",
"(",
"'name'",
")",
... | Gets the id of the default domain.
If the requests default domain is the same as DEFAULT_DOMAIN,
return None. | [
"Gets",
"the",
"id",
"of",
"the",
"default",
"domain",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L327-L336 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | get_project_groups_roles | def get_project_groups_roles(request, project):
"""Gets the groups roles in a given project.
:param request: the request entity containing the login user information
:param project: the project to filter the groups roles. It accepts both
project object resource or project ID
:retur... | python | def get_project_groups_roles(request, project):
"""Gets the groups roles in a given project.
:param request: the request entity containing the login user information
:param project: the project to filter the groups roles. It accepts both
project object resource or project ID
:retur... | [
"def",
"get_project_groups_roles",
"(",
"request",
",",
"project",
")",
":",
"groups_roles",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"project_role_assignments",
"=",
"role_assignments_list",
"(",
"request",
",",
"project",
"=",
"project",
")",
"f... | Gets the groups roles in a given project.
:param request: the request entity containing the login user information
:param project: the project to filter the groups roles. It accepts both
project object resource or project ID
:returns group_roles: a dictionary mapping the groups and the... | [
"Gets",
"the",
"groups",
"roles",
"in",
"a",
"given",
"project",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L671-L696 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | role_list | def role_list(request, filters=None):
"""Returns a global list of available roles."""
manager = keystoneclient(request, admin=True).roles
roles = []
kwargs = {}
if filters is not None:
kwargs.update(filters)
if 'id' in kwargs:
try:
roles = [manager.get(kwargs['id'])]
... | python | def role_list(request, filters=None):
"""Returns a global list of available roles."""
manager = keystoneclient(request, admin=True).roles
roles = []
kwargs = {}
if filters is not None:
kwargs.update(filters)
if 'id' in kwargs:
try:
roles = [manager.get(kwargs['id'])]
... | [
"def",
"role_list",
"(",
"request",
",",
"filters",
"=",
"None",
")",
":",
"manager",
"=",
"keystoneclient",
"(",
"request",
",",
"admin",
"=",
"True",
")",
".",
"roles",
"roles",
"=",
"[",
"]",
"kwargs",
"=",
"{",
"}",
"if",
"filters",
"is",
"not",
... | Returns a global list of available roles. | [
"Returns",
"a",
"global",
"list",
"of",
"available",
"roles",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L742-L758 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | roles_for_user | def roles_for_user(request, user, project=None, domain=None):
"""Returns a list of user roles scoped to a project or domain."""
manager = keystoneclient(request, admin=True).roles
if VERSIONS.active < 3:
return manager.roles_for_user(user, project)
else:
return manager.list(user=user, do... | python | def roles_for_user(request, user, project=None, domain=None):
"""Returns a list of user roles scoped to a project or domain."""
manager = keystoneclient(request, admin=True).roles
if VERSIONS.active < 3:
return manager.roles_for_user(user, project)
else:
return manager.list(user=user, do... | [
"def",
"roles_for_user",
"(",
"request",
",",
"user",
",",
"project",
"=",
"None",
",",
"domain",
"=",
"None",
")",
":",
"manager",
"=",
"keystoneclient",
"(",
"request",
",",
"admin",
"=",
"True",
")",
".",
"roles",
"if",
"VERSIONS",
".",
"active",
"<... | Returns a list of user roles scoped to a project or domain. | [
"Returns",
"a",
"list",
"of",
"user",
"roles",
"scoped",
"to",
"a",
"project",
"or",
"domain",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L762-L768 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | add_domain_user_role | def add_domain_user_role(request, user, role, domain):
"""Adds a role for a user on a domain."""
manager = keystoneclient(request, admin=True).roles
return manager.grant(role, user=user, domain=domain) | python | def add_domain_user_role(request, user, role, domain):
"""Adds a role for a user on a domain."""
manager = keystoneclient(request, admin=True).roles
return manager.grant(role, user=user, domain=domain) | [
"def",
"add_domain_user_role",
"(",
"request",
",",
"user",
",",
"role",
",",
"domain",
")",
":",
"manager",
"=",
"keystoneclient",
"(",
"request",
",",
"admin",
"=",
"True",
")",
".",
"roles",
"return",
"manager",
".",
"grant",
"(",
"role",
",",
"user",... | Adds a role for a user on a domain. | [
"Adds",
"a",
"role",
"for",
"a",
"user",
"on",
"a",
"domain",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L791-L794 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | remove_domain_user_role | def remove_domain_user_role(request, user, role, domain=None):
"""Removes a given single role for a user from a domain."""
manager = keystoneclient(request, admin=True).roles
return manager.revoke(role, user=user, domain=domain) | python | def remove_domain_user_role(request, user, role, domain=None):
"""Removes a given single role for a user from a domain."""
manager = keystoneclient(request, admin=True).roles
return manager.revoke(role, user=user, domain=domain) | [
"def",
"remove_domain_user_role",
"(",
"request",
",",
"user",
",",
"role",
",",
"domain",
"=",
"None",
")",
":",
"manager",
"=",
"keystoneclient",
"(",
"request",
",",
"admin",
"=",
"True",
")",
".",
"roles",
"return",
"manager",
".",
"revoke",
"(",
"ro... | Removes a given single role for a user from a domain. | [
"Removes",
"a",
"given",
"single",
"role",
"for",
"a",
"user",
"from",
"a",
"domain",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L798-L801 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | add_tenant_user_role | def add_tenant_user_role(request, project=None, user=None, role=None,
group=None, domain=None):
"""Adds a role for a user on a tenant."""
manager = keystoneclient(request, admin=True).roles
if VERSIONS.active < 3:
manager.add_user_role(user, role, project)
else:
... | python | def add_tenant_user_role(request, project=None, user=None, role=None,
group=None, domain=None):
"""Adds a role for a user on a tenant."""
manager = keystoneclient(request, admin=True).roles
if VERSIONS.active < 3:
manager.add_user_role(user, role, project)
else:
... | [
"def",
"add_tenant_user_role",
"(",
"request",
",",
"project",
"=",
"None",
",",
"user",
"=",
"None",
",",
"role",
"=",
"None",
",",
"group",
"=",
"None",
",",
"domain",
"=",
"None",
")",
":",
"manager",
"=",
"keystoneclient",
"(",
"request",
",",
"adm... | Adds a role for a user on a tenant. | [
"Adds",
"a",
"role",
"for",
"a",
"user",
"on",
"a",
"tenant",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L831-L839 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | remove_tenant_user_role | def remove_tenant_user_role(request, project=None, user=None, role=None,
group=None, domain=None):
"""Removes a given single role for a user from a tenant."""
manager = keystoneclient(request, admin=True).roles
if VERSIONS.active < 3:
return manager.remove_user_role(user,... | python | def remove_tenant_user_role(request, project=None, user=None, role=None,
group=None, domain=None):
"""Removes a given single role for a user from a tenant."""
manager = keystoneclient(request, admin=True).roles
if VERSIONS.active < 3:
return manager.remove_user_role(user,... | [
"def",
"remove_tenant_user_role",
"(",
"request",
",",
"project",
"=",
"None",
",",
"user",
"=",
"None",
",",
"role",
"=",
"None",
",",
"group",
"=",
"None",
",",
"domain",
"=",
"None",
")",
":",
"manager",
"=",
"keystoneclient",
"(",
"request",
",",
"... | Removes a given single role for a user from a tenant. | [
"Removes",
"a",
"given",
"single",
"role",
"for",
"a",
"user",
"from",
"a",
"tenant",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L843-L851 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | remove_tenant_user | def remove_tenant_user(request, project=None, user=None, domain=None):
"""Removes all roles from a user on a tenant, removing them from it."""
client = keystoneclient(request, admin=True)
roles = client.roles.roles_for_user(user, project)
for role in roles:
remove_tenant_user_role(request, user=... | python | def remove_tenant_user(request, project=None, user=None, domain=None):
"""Removes all roles from a user on a tenant, removing them from it."""
client = keystoneclient(request, admin=True)
roles = client.roles.roles_for_user(user, project)
for role in roles:
remove_tenant_user_role(request, user=... | [
"def",
"remove_tenant_user",
"(",
"request",
",",
"project",
"=",
"None",
",",
"user",
"=",
"None",
",",
"domain",
"=",
"None",
")",
":",
"client",
"=",
"keystoneclient",
"(",
"request",
",",
"admin",
"=",
"True",
")",
"roles",
"=",
"client",
".",
"rol... | Removes all roles from a user on a tenant, removing them from it. | [
"Removes",
"all",
"roles",
"from",
"a",
"user",
"on",
"a",
"tenant",
"removing",
"them",
"from",
"it",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L854-L860 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | add_group_role | def add_group_role(request, role, group, domain=None, project=None):
"""Adds a role for a group on a domain or project."""
manager = keystoneclient(request, admin=True).roles
return manager.grant(role=role, group=group, domain=domain,
project=project) | python | def add_group_role(request, role, group, domain=None, project=None):
"""Adds a role for a group on a domain or project."""
manager = keystoneclient(request, admin=True).roles
return manager.grant(role=role, group=group, domain=domain,
project=project) | [
"def",
"add_group_role",
"(",
"request",
",",
"role",
",",
"group",
",",
"domain",
"=",
"None",
",",
"project",
"=",
"None",
")",
":",
"manager",
"=",
"keystoneclient",
"(",
"request",
",",
"admin",
"=",
"True",
")",
".",
"roles",
"return",
"manager",
... | Adds a role for a group on a domain or project. | [
"Adds",
"a",
"role",
"for",
"a",
"group",
"on",
"a",
"domain",
"or",
"project",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L870-L874 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | remove_group_role | def remove_group_role(request, role, group, domain=None, project=None):
"""Removes a given single role for a group from a domain or project."""
manager = keystoneclient(request, admin=True).roles
return manager.revoke(role=role, group=group, project=project,
domain=domain) | python | def remove_group_role(request, role, group, domain=None, project=None):
"""Removes a given single role for a group from a domain or project."""
manager = keystoneclient(request, admin=True).roles
return manager.revoke(role=role, group=group, project=project,
domain=domain) | [
"def",
"remove_group_role",
"(",
"request",
",",
"role",
",",
"group",
",",
"domain",
"=",
"None",
",",
"project",
"=",
"None",
")",
":",
"manager",
"=",
"keystoneclient",
"(",
"request",
",",
"admin",
"=",
"True",
")",
".",
"roles",
"return",
"manager",... | Removes a given single role for a group from a domain or project. | [
"Removes",
"a",
"given",
"single",
"role",
"for",
"a",
"group",
"from",
"a",
"domain",
"or",
"project",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L878-L882 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | remove_group_roles | def remove_group_roles(request, group, domain=None, project=None):
"""Removes all roles from a group on a domain or project."""
client = keystoneclient(request, admin=True)
roles = client.roles.list(group=group, domain=domain, project=project)
for role in roles:
remove_group_role(request, role=r... | python | def remove_group_roles(request, group, domain=None, project=None):
"""Removes all roles from a group on a domain or project."""
client = keystoneclient(request, admin=True)
roles = client.roles.list(group=group, domain=domain, project=project)
for role in roles:
remove_group_role(request, role=r... | [
"def",
"remove_group_roles",
"(",
"request",
",",
"group",
",",
"domain",
"=",
"None",
",",
"project",
"=",
"None",
")",
":",
"client",
"=",
"keystoneclient",
"(",
"request",
",",
"admin",
"=",
"True",
")",
"roles",
"=",
"client",
".",
"roles",
".",
"l... | Removes all roles from a group on a domain or project. | [
"Removes",
"all",
"roles",
"from",
"a",
"group",
"on",
"a",
"domain",
"or",
"project",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L886-L892 | train |
openstack/horizon | openstack_dashboard/api/keystone.py | get_default_role | def get_default_role(request):
"""Gets the default role object from Keystone and saves it as a global.
Since this is configured in settings and should not change from request
to request. Supports lookup by name or id.
"""
global DEFAULT_ROLE
default = getattr(settings, "OPENSTACK_KEYSTONE_DEFAU... | python | def get_default_role(request):
"""Gets the default role object from Keystone and saves it as a global.
Since this is configured in settings and should not change from request
to request. Supports lookup by name or id.
"""
global DEFAULT_ROLE
default = getattr(settings, "OPENSTACK_KEYSTONE_DEFAU... | [
"def",
"get_default_role",
"(",
"request",
")",
":",
"global",
"DEFAULT_ROLE",
"default",
"=",
"getattr",
"(",
"settings",
",",
"\"OPENSTACK_KEYSTONE_DEFAULT_ROLE\"",
",",
"None",
")",
"if",
"default",
"and",
"DEFAULT_ROLE",
"is",
"None",
":",
"try",
":",
"roles... | Gets the default role object from Keystone and saves it as a global.
Since this is configured in settings and should not change from request
to request. Supports lookup by name or id. | [
"Gets",
"the",
"default",
"role",
"object",
"from",
"Keystone",
"and",
"saves",
"it",
"as",
"a",
"global",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/keystone.py#L895-L913 | train |
openstack/horizon | horizon/browsers/breadcrumb.py | Breadcrumb.render | def render(self):
"""Renders the table using the template from the table options."""
breadcrumb_template = template.loader.get_template(self.template)
extra_context = {"breadcrumb": self}
return breadcrumb_template.render(extra_context, self.request) | python | def render(self):
"""Renders the table using the template from the table options."""
breadcrumb_template = template.loader.get_template(self.template)
extra_context = {"breadcrumb": self}
return breadcrumb_template.render(extra_context, self.request) | [
"def",
"render",
"(",
"self",
")",
":",
"breadcrumb_template",
"=",
"template",
".",
"loader",
".",
"get_template",
"(",
"self",
".",
"template",
")",
"extra_context",
"=",
"{",
"\"breadcrumb\"",
":",
"self",
"}",
"return",
"breadcrumb_template",
".",
"render"... | Renders the table using the template from the table options. | [
"Renders",
"the",
"table",
"using",
"the",
"template",
"from",
"the",
"table",
"options",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/browsers/breadcrumb.py#L41-L45 | train |
openstack/horizon | horizon/tabs/base.py | TabGroup.load_tab_data | def load_tab_data(self):
"""Preload all data that for the tabs that will be displayed."""
for tab in self._tabs.values():
if tab.load and not tab.data_loaded:
try:
tab._data = tab.get_context_data(self.request)
except Exception:
... | python | def load_tab_data(self):
"""Preload all data that for the tabs that will be displayed."""
for tab in self._tabs.values():
if tab.load and not tab.data_loaded:
try:
tab._data = tab.get_context_data(self.request)
except Exception:
... | [
"def",
"load_tab_data",
"(",
"self",
")",
":",
"for",
"tab",
"in",
"self",
".",
"_tabs",
".",
"values",
"(",
")",
":",
"if",
"tab",
".",
"load",
"and",
"not",
"tab",
".",
"data_loaded",
":",
"try",
":",
"tab",
".",
"_data",
"=",
"tab",
".",
"get_... | Preload all data that for the tabs that will be displayed. | [
"Preload",
"all",
"data",
"that",
"for",
"the",
"tabs",
"that",
"will",
"be",
"displayed",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/base.py#L170-L178 | train |
openstack/horizon | horizon/tabs/base.py | TabGroup.get_default_classes | def get_default_classes(self):
"""Returns a list of the default classes for the tab group.
Defaults to ``["nav", "nav-tabs", "ajax-tabs"]``.
"""
default_classes = super(TabGroup, self).get_default_classes()
default_classes.extend(CSS_TAB_GROUP_CLASSES)
return default_cla... | python | def get_default_classes(self):
"""Returns a list of the default classes for the tab group.
Defaults to ``["nav", "nav-tabs", "ajax-tabs"]``.
"""
default_classes = super(TabGroup, self).get_default_classes()
default_classes.extend(CSS_TAB_GROUP_CLASSES)
return default_cla... | [
"def",
"get_default_classes",
"(",
"self",
")",
":",
"default_classes",
"=",
"super",
"(",
"TabGroup",
",",
"self",
")",
".",
"get_default_classes",
"(",
")",
"default_classes",
".",
"extend",
"(",
"CSS_TAB_GROUP_CLASSES",
")",
"return",
"default_classes"
] | Returns a list of the default classes for the tab group.
Defaults to ``["nav", "nav-tabs", "ajax-tabs"]``. | [
"Returns",
"a",
"list",
"of",
"the",
"default",
"classes",
"for",
"the",
"tab",
"group",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/base.py#L188-L195 | train |
openstack/horizon | horizon/tabs/base.py | TabGroup.get_tab | def get_tab(self, tab_name, allow_disabled=False):
"""Returns a specific tab from this tab group.
If the tab is not allowed or not enabled this method returns ``None``.
If the tab is disabled but you wish to return it anyway, you can pass
``True`` to the allow_disabled argument.
... | python | def get_tab(self, tab_name, allow_disabled=False):
"""Returns a specific tab from this tab group.
If the tab is not allowed or not enabled this method returns ``None``.
If the tab is disabled but you wish to return it anyway, you can pass
``True`` to the allow_disabled argument.
... | [
"def",
"get_tab",
"(",
"self",
",",
"tab_name",
",",
"allow_disabled",
"=",
"False",
")",
":",
"tab",
"=",
"self",
".",
"_tabs",
".",
"get",
"(",
"tab_name",
",",
"None",
")",
"if",
"tab",
"and",
"tab",
".",
"_allowed",
"and",
"(",
"tab",
".",
"_en... | Returns a specific tab from this tab group.
If the tab is not allowed or not enabled this method returns ``None``.
If the tab is disabled but you wish to return it anyway, you can pass
``True`` to the allow_disabled argument. | [
"Returns",
"a",
"specific",
"tab",
"from",
"this",
"tab",
"group",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/base.py#L236-L247 | train |
openstack/horizon | horizon/tabs/base.py | TabGroup.get_selected_tab | def get_selected_tab(self):
"""Returns the tab specific by the GET request parameter.
In the event that there is no GET request parameter, the value
of the query parameter is invalid, or the tab is not allowed/enabled,
the return value of this function is None.
"""
selec... | python | def get_selected_tab(self):
"""Returns the tab specific by the GET request parameter.
In the event that there is no GET request parameter, the value
of the query parameter is invalid, or the tab is not allowed/enabled,
the return value of this function is None.
"""
selec... | [
"def",
"get_selected_tab",
"(",
"self",
")",
":",
"selected",
"=",
"self",
".",
"request",
".",
"GET",
".",
"get",
"(",
"self",
".",
"param_name",
",",
"None",
")",
"if",
"selected",
":",
"try",
":",
"tab_group",
",",
"tab_name",
"=",
"selected",
".",
... | Returns the tab specific by the GET request parameter.
In the event that there is no GET request parameter, the value
of the query parameter is invalid, or the tab is not allowed/enabled,
the return value of this function is None. | [
"Returns",
"the",
"tab",
"specific",
"by",
"the",
"GET",
"request",
"parameter",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/base.py#L252-L267 | train |
openstack/horizon | horizon/tabs/base.py | Tab.render | def render(self):
"""Renders the tab to HTML.
:meth:`~horizon.tabs.Tab.get_context_data` method and
the :meth:`~horizon.tabs.Tab.get_template_name` method are called.
If :attr:`~horizon.tabs.Tab.preload` is ``False`` and ``force_load``
is not ``True``, or
either :meth:`... | python | def render(self):
"""Renders the tab to HTML.
:meth:`~horizon.tabs.Tab.get_context_data` method and
the :meth:`~horizon.tabs.Tab.get_template_name` method are called.
If :attr:`~horizon.tabs.Tab.preload` is ``False`` and ``force_load``
is not ``True``, or
either :meth:`... | [
"def",
"render",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"load",
":",
"return",
"''",
"try",
":",
"context",
"=",
"self",
".",
"data",
"except",
"exceptions",
".",
"Http302",
":",
"raise",
"except",
"Exception",
":",
"exc_type",
",",
"exc_valu... | Renders the tab to HTML.
:meth:`~horizon.tabs.Tab.get_context_data` method and
the :meth:`~horizon.tabs.Tab.get_template_name` method are called.
If :attr:`~horizon.tabs.Tab.preload` is ``False`` and ``force_load``
is not ``True``, or
either :meth:`~horizon.tabs.Tab.allowed` or... | [
"Renders",
"the",
"tab",
"to",
"HTML",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/base.py#L356-L377 | train |
openstack/horizon | horizon/tabs/base.py | Tab.get_default_classes | def get_default_classes(self):
"""Returns a list of the default classes for the tab.
Defaults to and empty list (``[]``), however additional classes may
be added depending on the state of the tab as follows:
If the tab is the active tab for the tab group, in which
the class ``"... | python | def get_default_classes(self):
"""Returns a list of the default classes for the tab.
Defaults to and empty list (``[]``), however additional classes may
be added depending on the state of the tab as follows:
If the tab is the active tab for the tab group, in which
the class ``"... | [
"def",
"get_default_classes",
"(",
"self",
")",
":",
"default_classes",
"=",
"super",
"(",
"Tab",
",",
"self",
")",
".",
"get_default_classes",
"(",
")",
"if",
"self",
".",
"is_active",
"(",
")",
":",
"default_classes",
".",
"extend",
"(",
"CSS_ACTIVE_TAB_CL... | Returns a list of the default classes for the tab.
Defaults to and empty list (``[]``), however additional classes may
be added depending on the state of the tab as follows:
If the tab is the active tab for the tab group, in which
the class ``"active"`` will be added.
If the t... | [
"Returns",
"a",
"list",
"of",
"the",
"default",
"classes",
"for",
"the",
"tab",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/base.py#L389-L406 | train |
openstack/horizon | horizon/tabs/base.py | Tab.get_template_name | def get_template_name(self, request):
"""Returns the name of the template to be used for rendering this tab.
By default it returns the value of the ``template_name`` attribute
on the ``Tab`` class.
"""
if not hasattr(self, "template_name"):
raise AttributeError("%s m... | python | def get_template_name(self, request):
"""Returns the name of the template to be used for rendering this tab.
By default it returns the value of the ``template_name`` attribute
on the ``Tab`` class.
"""
if not hasattr(self, "template_name"):
raise AttributeError("%s m... | [
"def",
"get_template_name",
"(",
"self",
",",
"request",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"template_name\"",
")",
":",
"raise",
"AttributeError",
"(",
"\"%s must have a template_name attribute or \"",
"\"override the get_template_name method.\"",
"%",... | Returns the name of the template to be used for rendering this tab.
By default it returns the value of the ``template_name`` attribute
on the ``Tab`` class. | [
"Returns",
"the",
"name",
"of",
"the",
"template",
"to",
"be",
"used",
"for",
"rendering",
"this",
"tab",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/base.py#L408-L418 | train |
openstack/horizon | horizon/templatetags/breadcrumb_nav.py | breadcrumb_nav | def breadcrumb_nav(context):
"""A logic heavy function for automagically creating a breadcrumb.
It uses the dashboard, panel group(if it exists), then current panel.
Can also use a "custom_breadcrumb" context item to add extra items.
"""
breadcrumb = []
dashboard = context.request.horizon['dash... | python | def breadcrumb_nav(context):
"""A logic heavy function for automagically creating a breadcrumb.
It uses the dashboard, panel group(if it exists), then current panel.
Can also use a "custom_breadcrumb" context item to add extra items.
"""
breadcrumb = []
dashboard = context.request.horizon['dash... | [
"def",
"breadcrumb_nav",
"(",
"context",
")",
":",
"breadcrumb",
"=",
"[",
"]",
"dashboard",
"=",
"context",
".",
"request",
".",
"horizon",
"[",
"'dashboard'",
"]",
"try",
":",
"panel_groups",
"=",
"dashboard",
".",
"get_panel_groups",
"(",
")",
"except",
... | A logic heavy function for automagically creating a breadcrumb.
It uses the dashboard, panel group(if it exists), then current panel.
Can also use a "custom_breadcrumb" context item to add extra items. | [
"A",
"logic",
"heavy",
"function",
"for",
"automagically",
"creating",
"a",
"breadcrumb",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/breadcrumb_nav.py#L22-L61 | train |
openstack/horizon | horizon/utils/html.py | HTMLElement.get_final_attrs | def get_final_attrs(self, classes=True):
"""Returns a dict containing the final attributes to be rendered."""
final_attrs = copy.copy(self.get_default_attrs())
final_attrs.update(self.attrs)
if classes:
final_attrs['class'] = self.get_final_css()
else:
fin... | python | def get_final_attrs(self, classes=True):
"""Returns a dict containing the final attributes to be rendered."""
final_attrs = copy.copy(self.get_default_attrs())
final_attrs.update(self.attrs)
if classes:
final_attrs['class'] = self.get_final_css()
else:
fin... | [
"def",
"get_final_attrs",
"(",
"self",
",",
"classes",
"=",
"True",
")",
":",
"final_attrs",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"get_default_attrs",
"(",
")",
")",
"final_attrs",
".",
"update",
"(",
"self",
".",
"attrs",
")",
"if",
"classes",
... | Returns a dict containing the final attributes to be rendered. | [
"Returns",
"a",
"dict",
"containing",
"the",
"final",
"attributes",
"to",
"be",
"rendered",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/html.py#L38-L47 | train |
openstack/horizon | horizon/utils/html.py | HTMLElement.get_final_css | def get_final_css(self):
"""Returns a final css class concatenated string."""
default = " ".join(self.get_default_classes())
defined = self.attrs.get('class', '')
additional = " ".join(getattr(self, "classes", []))
non_empty = [test for test in (defined, default, additional) if t... | python | def get_final_css(self):
"""Returns a final css class concatenated string."""
default = " ".join(self.get_default_classes())
defined = self.attrs.get('class', '')
additional = " ".join(getattr(self, "classes", []))
non_empty = [test for test in (defined, default, additional) if t... | [
"def",
"get_final_css",
"(",
"self",
")",
":",
"default",
"=",
"\" \"",
".",
"join",
"(",
"self",
".",
"get_default_classes",
"(",
")",
")",
"defined",
"=",
"self",
".",
"attrs",
".",
"get",
"(",
"'class'",
",",
"''",
")",
"additional",
"=",
"\" \"",
... | Returns a final css class concatenated string. | [
"Returns",
"a",
"final",
"css",
"class",
"concatenated",
"string",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/html.py#L49-L56 | train |
openstack/horizon | openstack_dashboard/dashboards/project/instances/utils.py | flavor_list | def flavor_list(request):
"""Utility method to retrieve a list of flavors."""
try:
return api.nova.flavor_list(request)
except Exception:
exceptions.handle(request,
_('Unable to retrieve instance flavors.'))
return [] | python | def flavor_list(request):
"""Utility method to retrieve a list of flavors."""
try:
return api.nova.flavor_list(request)
except Exception:
exceptions.handle(request,
_('Unable to retrieve instance flavors.'))
return [] | [
"def",
"flavor_list",
"(",
"request",
")",
":",
"try",
":",
"return",
"api",
".",
"nova",
".",
"flavor_list",
"(",
"request",
")",
"except",
"Exception",
":",
"exceptions",
".",
"handle",
"(",
"request",
",",
"_",
"(",
"'Unable to retrieve instance flavors.'",... | Utility method to retrieve a list of flavors. | [
"Utility",
"method",
"to",
"retrieve",
"a",
"list",
"of",
"flavors",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/utils.py#L27-L34 | train |
openstack/horizon | openstack_dashboard/dashboards/project/instances/utils.py | sort_flavor_list | def sort_flavor_list(request, flavors, with_menu_label=True):
"""Utility method to sort a list of flavors.
By default, returns the available flavors, sorted by RAM usage (ascending).
Override these behaviours with a ``CREATE_INSTANCE_FLAVOR_SORT`` dict
in ``local_settings.py``.
"""
def get_key(... | python | def sort_flavor_list(request, flavors, with_menu_label=True):
"""Utility method to sort a list of flavors.
By default, returns the available flavors, sorted by RAM usage (ascending).
Override these behaviours with a ``CREATE_INSTANCE_FLAVOR_SORT`` dict
in ``local_settings.py``.
"""
def get_key(... | [
"def",
"sort_flavor_list",
"(",
"request",
",",
"flavors",
",",
"with_menu_label",
"=",
"True",
")",
":",
"def",
"get_key",
"(",
"flavor",
",",
"sort_key",
")",
":",
"try",
":",
"return",
"getattr",
"(",
"flavor",
",",
"sort_key",
")",
"except",
"Attribute... | Utility method to sort a list of flavors.
By default, returns the available flavors, sorted by RAM usage (ascending).
Override these behaviours with a ``CREATE_INSTANCE_FLAVOR_SORT`` dict
in ``local_settings.py``. | [
"Utility",
"method",
"to",
"sort",
"a",
"list",
"of",
"flavors",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/utils.py#L37-L70 | train |
openstack/horizon | openstack_dashboard/dashboards/project/instances/utils.py | server_group_list | def server_group_list(request):
"""Utility method to retrieve a list of server groups."""
try:
return api.nova.server_group_list(request)
except Exception:
exceptions.handle(request,
_('Unable to retrieve Nova server groups.'))
return [] | python | def server_group_list(request):
"""Utility method to retrieve a list of server groups."""
try:
return api.nova.server_group_list(request)
except Exception:
exceptions.handle(request,
_('Unable to retrieve Nova server groups.'))
return [] | [
"def",
"server_group_list",
"(",
"request",
")",
":",
"try",
":",
"return",
"api",
".",
"nova",
".",
"server_group_list",
"(",
"request",
")",
"except",
"Exception",
":",
"exceptions",
".",
"handle",
"(",
"request",
",",
"_",
"(",
"'Unable to retrieve Nova ser... | Utility method to retrieve a list of server groups. | [
"Utility",
"method",
"to",
"retrieve",
"a",
"list",
"of",
"server",
"groups",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/utils.py#L83-L90 | train |
openstack/horizon | openstack_dashboard/dashboards/project/instances/utils.py | network_field_data | def network_field_data(request, include_empty_option=False, with_cidr=False,
for_launch=False):
"""Returns a list of tuples of all networks.
Generates a list of networks available to the user (request). And returns
a list of (id, name) tuples.
:param request: django http request... | python | def network_field_data(request, include_empty_option=False, with_cidr=False,
for_launch=False):
"""Returns a list of tuples of all networks.
Generates a list of networks available to the user (request). And returns
a list of (id, name) tuples.
:param request: django http request... | [
"def",
"network_field_data",
"(",
"request",
",",
"include_empty_option",
"=",
"False",
",",
"with_cidr",
"=",
"False",
",",
"for_launch",
"=",
"False",
")",
":",
"tenant_id",
"=",
"request",
".",
"user",
".",
"tenant_id",
"networks",
"=",
"[",
"]",
"if",
... | Returns a list of tuples of all networks.
Generates a list of networks available to the user (request). And returns
a list of (id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a empty tuple in the front of
the list
:param with_cidr:... | [
"Returns",
"a",
"list",
"of",
"tuples",
"of",
"all",
"networks",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/utils.py#L93-L140 | train |
openstack/horizon | openstack_dashboard/dashboards/project/instances/utils.py | keypair_field_data | def keypair_field_data(request, include_empty_option=False):
"""Returns a list of tuples of all keypairs.
Generates a list of keypairs available to the user (request). And returns
a list of (id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a... | python | def keypair_field_data(request, include_empty_option=False):
"""Returns a list of tuples of all keypairs.
Generates a list of keypairs available to the user (request). And returns
a list of (id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a... | [
"def",
"keypair_field_data",
"(",
"request",
",",
"include_empty_option",
"=",
"False",
")",
":",
"keypair_list",
"=",
"[",
"]",
"try",
":",
"keypairs",
"=",
"api",
".",
"nova",
".",
"keypair_list",
"(",
"request",
")",
"keypair_list",
"=",
"[",
"(",
"kp",... | Returns a list of tuples of all keypairs.
Generates a list of keypairs available to the user (request). And returns
a list of (id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a empty tuple in the front of
the list
:return: list of (... | [
"Returns",
"a",
"list",
"of",
"tuples",
"of",
"all",
"keypairs",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/utils.py#L143-L168 | train |
openstack/horizon | openstack_dashboard/dashboards/project/instances/utils.py | flavor_field_data | def flavor_field_data(request, include_empty_option=False):
"""Returns a list of tuples of all image flavors.
Generates a list of image flavors available. And returns a list of
(id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a empty tuple ... | python | def flavor_field_data(request, include_empty_option=False):
"""Returns a list of tuples of all image flavors.
Generates a list of image flavors available. And returns a list of
(id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a empty tuple ... | [
"def",
"flavor_field_data",
"(",
"request",
",",
"include_empty_option",
"=",
"False",
")",
":",
"flavors",
"=",
"flavor_list",
"(",
"request",
")",
"if",
"flavors",
":",
"flavors_list",
"=",
"sort_flavor_list",
"(",
"request",
",",
"flavors",
")",
"if",
"incl... | Returns a list of tuples of all image flavors.
Generates a list of image flavors available. And returns a list of
(id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a empty tuple in the front of
the list
:return: list of (id, name) tu... | [
"Returns",
"a",
"list",
"of",
"tuples",
"of",
"all",
"image",
"flavors",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/utils.py#L171-L191 | train |
openstack/horizon | openstack_dashboard/dashboards/project/instances/utils.py | port_field_data | def port_field_data(request, with_network=False):
"""Returns a list of tuples of all ports available for the tenant.
Generates a list of ports that have no device_owner based on the networks
available to the tenant doing the request.
:param request: django http request object
:param with_network: ... | python | def port_field_data(request, with_network=False):
"""Returns a list of tuples of all ports available for the tenant.
Generates a list of ports that have no device_owner based on the networks
available to the tenant doing the request.
:param request: django http request object
:param with_network: ... | [
"def",
"port_field_data",
"(",
"request",
",",
"with_network",
"=",
"False",
")",
":",
"def",
"add_more_info_port_name",
"(",
"port",
",",
"network",
")",
":",
"# add more info to the port for the display",
"port_name",
"=",
"\"{} ({})\"",
".",
"format",
"(",
"port"... | Returns a list of tuples of all ports available for the tenant.
Generates a list of ports that have no device_owner based on the networks
available to the tenant doing the request.
:param request: django http request object
:param with_network: include network name in field name
:return: list of (... | [
"Returns",
"a",
"list",
"of",
"tuples",
"of",
"all",
"ports",
"available",
"for",
"the",
"tenant",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/utils.py#L194-L227 | train |
openstack/horizon | openstack_dashboard/dashboards/project/instances/utils.py | server_group_field_data | def server_group_field_data(request):
"""Returns a list of tuples of all server groups.
Generates a list of server groups available. And returns a list of
(id, name) tuples.
:param request: django http request object
:return: list of (id, name) tuples
"""
server_groups = server_group_list(... | python | def server_group_field_data(request):
"""Returns a list of tuples of all server groups.
Generates a list of server groups available. And returns a list of
(id, name) tuples.
:param request: django http request object
:return: list of (id, name) tuples
"""
server_groups = server_group_list(... | [
"def",
"server_group_field_data",
"(",
"request",
")",
":",
"server_groups",
"=",
"server_group_list",
"(",
"request",
")",
"if",
"server_groups",
":",
"server_groups_list",
"=",
"[",
"(",
"sg",
".",
"id",
",",
"sg",
".",
"name",
")",
"for",
"sg",
"in",
"s... | Returns a list of tuples of all server groups.
Generates a list of server groups available. And returns a list of
(id, name) tuples.
:param request: django http request object
:return: list of (id, name) tuples | [
"Returns",
"a",
"list",
"of",
"tuples",
"of",
"all",
"server",
"groups",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/utils.py#L230-L245 | train |
openstack/horizon | openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tables.py | ExtraRoutesTable.get_object_display | def get_object_display(self, datum):
"""Display ExtraRoutes when deleted."""
return (super(ExtraRoutesTable, self).get_object_display(datum) or
datum.destination + " -> " + datum.nexthop) | python | def get_object_display(self, datum):
"""Display ExtraRoutes when deleted."""
return (super(ExtraRoutesTable, self).get_object_display(datum) or
datum.destination + " -> " + datum.nexthop) | [
"def",
"get_object_display",
"(",
"self",
",",
"datum",
")",
":",
"return",
"(",
"super",
"(",
"ExtraRoutesTable",
",",
"self",
")",
".",
"get_object_display",
"(",
"datum",
")",
"or",
"datum",
".",
"destination",
"+",
"\" -> \"",
"+",
"datum",
".",
"nexth... | Display ExtraRoutes when deleted. | [
"Display",
"ExtraRoutes",
"when",
"deleted",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/routers/extensions/extraroutes/tables.py#L68-L71 | train |
openstack/horizon | openstack_dashboard/api/rest/json_encoder.py | NaNJSONEncoder.iterencode | def iterencode(self, o, _one_shot=False):
"""JSON encoder with NaN and float inf support.
The sole purpose of defining a custom JSONEncoder class is to
override floatstr() inner function, or more specifically the
representation of NaN and +/-float('inf') values in a JSON. Although
... | python | def iterencode(self, o, _one_shot=False):
"""JSON encoder with NaN and float inf support.
The sole purpose of defining a custom JSONEncoder class is to
override floatstr() inner function, or more specifically the
representation of NaN and +/-float('inf') values in a JSON. Although
... | [
"def",
"iterencode",
"(",
"self",
",",
"o",
",",
"_one_shot",
"=",
"False",
")",
":",
"if",
"self",
".",
"check_circular",
":",
"markers",
"=",
"{",
"}",
"else",
":",
"markers",
"=",
"None",
"if",
"self",
".",
"ensure_ascii",
":",
"_encoder",
"=",
"e... | JSON encoder with NaN and float inf support.
The sole purpose of defining a custom JSONEncoder class is to
override floatstr() inner function, or more specifically the
representation of NaN and +/-float('inf') values in a JSON. Although
Infinity values are not supported by JSON standard... | [
"JSON",
"encoder",
"with",
"NaN",
"and",
"float",
"inf",
"support",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/rest/json_encoder.py#L27-L84 | train |
openstack/horizon | openstack_dashboard/templatetags/context_selection.py | get_project_name | def get_project_name(project_id, projects):
"""Retrieves project name for given project id
Args:
projects: List of projects
project_id: project id
Returns: Project name or None if there is no match
"""
for project in projects:
if project_id == project.id:
return... | python | def get_project_name(project_id, projects):
"""Retrieves project name for given project id
Args:
projects: List of projects
project_id: project id
Returns: Project name or None if there is no match
"""
for project in projects:
if project_id == project.id:
return... | [
"def",
"get_project_name",
"(",
"project_id",
",",
"projects",
")",
":",
"for",
"project",
"in",
"projects",
":",
"if",
"project_id",
"==",
"project",
".",
"id",
":",
"return",
"project",
".",
"name"
] | Retrieves project name for given project id
Args:
projects: List of projects
project_id: project id
Returns: Project name or None if there is no match | [
"Retrieves",
"project",
"name",
"for",
"given",
"project",
"id"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/templatetags/context_selection.py#L120-L131 | train |
openstack/horizon | horizon/templatetags/parse_date.py | ParseDateNode.render | def render(self, datestring):
"""Parses a date-like string into a timezone aware Python datetime."""
formats = ["%Y-%m-%dT%H:%M:%S.%f", "%Y-%m-%d %H:%M:%S.%f",
"%Y-%m-%dT%H:%M:%S", "%Y-%m-%d %H:%M:%S"]
if datestring:
for format in formats:
try:
... | python | def render(self, datestring):
"""Parses a date-like string into a timezone aware Python datetime."""
formats = ["%Y-%m-%dT%H:%M:%S.%f", "%Y-%m-%d %H:%M:%S.%f",
"%Y-%m-%dT%H:%M:%S", "%Y-%m-%d %H:%M:%S"]
if datestring:
for format in formats:
try:
... | [
"def",
"render",
"(",
"self",
",",
"datestring",
")",
":",
"formats",
"=",
"[",
"\"%Y-%m-%dT%H:%M:%S.%f\"",
",",
"\"%Y-%m-%d %H:%M:%S.%f\"",
",",
"\"%Y-%m-%dT%H:%M:%S\"",
",",
"\"%Y-%m-%d %H:%M:%S\"",
"]",
"if",
"datestring",
":",
"for",
"format",
"in",
"formats",
... | Parses a date-like string into a timezone aware Python datetime. | [
"Parses",
"a",
"date",
"-",
"like",
"string",
"into",
"a",
"timezone",
"aware",
"Python",
"datetime",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/parse_date.py#L33-L46 | train |
openstack/horizon | horizon/utils/memoized.py | _try_weakref | def _try_weakref(arg, remove_callback):
"""Return a weak reference to arg if possible, or arg itself if not."""
try:
arg = weakref.ref(arg, remove_callback)
except TypeError:
# Not all types can have a weakref. That includes strings
# and floats and such, so just pass them through di... | python | def _try_weakref(arg, remove_callback):
"""Return a weak reference to arg if possible, or arg itself if not."""
try:
arg = weakref.ref(arg, remove_callback)
except TypeError:
# Not all types can have a weakref. That includes strings
# and floats and such, so just pass them through di... | [
"def",
"_try_weakref",
"(",
"arg",
",",
"remove_callback",
")",
":",
"try",
":",
"arg",
"=",
"weakref",
".",
"ref",
"(",
"arg",
",",
"remove_callback",
")",
"except",
"TypeError",
":",
"# Not all types can have a weakref. That includes strings",
"# and floats and such... | Return a weak reference to arg if possible, or arg itself if not. | [
"Return",
"a",
"weak",
"reference",
"to",
"arg",
"if",
"possible",
"or",
"arg",
"itself",
"if",
"not",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/memoized.py#L28-L36 | train |
openstack/horizon | horizon/utils/memoized.py | _get_key | def _get_key(args, kwargs, remove_callback):
"""Calculate the cache key, using weak references where possible."""
# Use tuples, because lists are not hashable.
weak_args = tuple(_try_weakref(arg, remove_callback) for arg in args)
# Use a tuple of (key, values) pairs, because dict is not hashable.
# ... | python | def _get_key(args, kwargs, remove_callback):
"""Calculate the cache key, using weak references where possible."""
# Use tuples, because lists are not hashable.
weak_args = tuple(_try_weakref(arg, remove_callback) for arg in args)
# Use a tuple of (key, values) pairs, because dict is not hashable.
# ... | [
"def",
"_get_key",
"(",
"args",
",",
"kwargs",
",",
"remove_callback",
")",
":",
"# Use tuples, because lists are not hashable.",
"weak_args",
"=",
"tuple",
"(",
"_try_weakref",
"(",
"arg",
",",
"remove_callback",
")",
"for",
"arg",
"in",
"args",
")",
"# Use a tup... | Calculate the cache key, using weak references where possible. | [
"Calculate",
"the",
"cache",
"key",
"using",
"weak",
"references",
"where",
"possible",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/memoized.py#L39-L48 | train |
openstack/horizon | horizon/utils/memoized.py | memoized | def memoized(func=None, max_size=None):
"""Decorator that caches function calls.
Caches the decorated function's return value the first time it is called
with the given arguments. If called later with the same arguments, the
cached value is returned instead of calling the decorated function again.
... | python | def memoized(func=None, max_size=None):
"""Decorator that caches function calls.
Caches the decorated function's return value the first time it is called
with the given arguments. If called later with the same arguments, the
cached value is returned instead of calling the decorated function again.
... | [
"def",
"memoized",
"(",
"func",
"=",
"None",
",",
"max_size",
"=",
"None",
")",
":",
"def",
"decorate",
"(",
"func",
")",
":",
"# The dictionary in which all the data will be cached. This is a",
"# separate instance for every decorated function, and it's stored in a",
"# clos... | Decorator that caches function calls.
Caches the decorated function's return value the first time it is called
with the given arguments. If called later with the same arguments, the
cached value is returned instead of calling the decorated function again.
It operates as a LRU cache and keeps up to th... | [
"Decorator",
"that",
"caches",
"function",
"calls",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/memoized.py#L51-L132 | train |
openstack/horizon | openstack_dashboard/management/commands/make_web_conf.py | _getattr | def _getattr(obj, name, default):
"""Like getattr but return `default` if None or False.
By default, getattr(obj, name, default) returns default only if
attr does not exist, here, we return `default` even if attr evaluates to
None or False.
"""
value = getattr(obj, name, default)
if value:
... | python | def _getattr(obj, name, default):
"""Like getattr but return `default` if None or False.
By default, getattr(obj, name, default) returns default only if
attr does not exist, here, we return `default` even if attr evaluates to
None or False.
"""
value = getattr(obj, name, default)
if value:
... | [
"def",
"_getattr",
"(",
"obj",
",",
"name",
",",
"default",
")",
":",
"value",
"=",
"getattr",
"(",
"obj",
",",
"name",
",",
"default",
")",
"if",
"value",
":",
"return",
"value",
"else",
":",
"return",
"default"
] | Like getattr but return `default` if None or False.
By default, getattr(obj, name, default) returns default only if
attr does not exist, here, we return `default` even if attr evaluates to
None or False. | [
"Like",
"getattr",
"but",
"return",
"default",
"if",
"None",
"or",
"False",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/management/commands/make_web_conf.py#L56-L67 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | list_resources_with_long_filters | def list_resources_with_long_filters(list_method,
filter_attr, filter_values, **params):
"""List neutron resources with handling RequestURITooLong exception.
If filter parameters are long, list resources API request leads to
414 error (URL is too long). For such case, t... | python | def list_resources_with_long_filters(list_method,
filter_attr, filter_values, **params):
"""List neutron resources with handling RequestURITooLong exception.
If filter parameters are long, list resources API request leads to
414 error (URL is too long). For such case, t... | [
"def",
"list_resources_with_long_filters",
"(",
"list_method",
",",
"filter_attr",
",",
"filter_values",
",",
"*",
"*",
"params",
")",
":",
"try",
":",
"params",
"[",
"filter_attr",
"]",
"=",
"filter_values",
"return",
"list_method",
"(",
"*",
"*",
"params",
"... | List neutron resources with handling RequestURITooLong exception.
If filter parameters are long, list resources API request leads to
414 error (URL is too long). For such case, this method split
list parameters specified by a list_field argument into chunks
and call the specified list_method repeatedly... | [
"List",
"neutron",
"resources",
"with",
"handling",
"RequestURITooLong",
"exception",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L821-L872 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | network_list_for_tenant | def network_list_for_tenant(request, tenant_id, include_external=False,
include_pre_auto_allocate=False,
**params):
"""Return a network list available for the tenant.
The list contains networks owned by the tenant and public networks.
If requested_net... | python | def network_list_for_tenant(request, tenant_id, include_external=False,
include_pre_auto_allocate=False,
**params):
"""Return a network list available for the tenant.
The list contains networks owned by the tenant and public networks.
If requested_net... | [
"def",
"network_list_for_tenant",
"(",
"request",
",",
"tenant_id",
",",
"include_external",
"=",
"False",
",",
"include_pre_auto_allocate",
"=",
"False",
",",
"*",
"*",
"params",
")",
":",
"LOG",
".",
"debug",
"(",
"\"network_list_for_tenant(): tenant_id=%(tenant_id)... | Return a network list available for the tenant.
The list contains networks owned by the tenant and public networks.
If requested_networks specified, it searches requested_networks only. | [
"Return",
"a",
"network",
"list",
"available",
"for",
"the",
"tenant",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1052-L1098 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | network_create | def network_create(request, **kwargs):
"""Create a network object.
:param request: request context
:param tenant_id: (optional) tenant id of the network created
:param name: (optional) name of the network created
:returns: Network object
"""
LOG.debug("network_create(): kwargs = %s", kwarg... | python | def network_create(request, **kwargs):
"""Create a network object.
:param request: request context
:param tenant_id: (optional) tenant id of the network created
:param name: (optional) name of the network created
:returns: Network object
"""
LOG.debug("network_create(): kwargs = %s", kwarg... | [
"def",
"network_create",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"\"network_create(): kwargs = %s\"",
",",
"kwargs",
")",
"if",
"'tenant_id'",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"'tenant_id'",
"]",
"=",
"request",... | Create a network object.
:param request: request context
:param tenant_id: (optional) tenant id of the network created
:param name: (optional) name of the network created
:returns: Network object | [
"Create",
"a",
"network",
"object",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1129-L1142 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | subnet_create | def subnet_create(request, network_id, **kwargs):
"""Create a subnet on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param cidr: (optional) subnet IP address range
:param ip_version: (optional) IP version (4 or 6)
:param gateway_ip: ... | python | def subnet_create(request, network_id, **kwargs):
"""Create a subnet on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param cidr: (optional) subnet IP address range
:param ip_version: (optional) IP version (4 or 6)
:param gateway_ip: ... | [
"def",
"subnet_create",
"(",
"request",
",",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"\"subnet_create(): netid=%(network_id)s, kwargs=%(kwargs)s\"",
",",
"{",
"'network_id'",
":",
"network_id",
",",
"'kwargs'",
":",
"kwargs",
"}"... | Create a subnet on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param cidr: (optional) subnet IP address range
:param ip_version: (optional) IP version (4 or 6)
:param gateway_ip: (optional) IP address of gateway
:param tenant_id: (o... | [
"Create",
"a",
"subnet",
"on",
"a",
"specified",
"network",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1179-L1204 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | subnetpool_create | def subnetpool_create(request, name, prefixes, **kwargs):
"""Create a subnetpool.
ip_version is auto-detected in back-end.
Parameters:
request -- Request context
name -- Name for subnetpool
prefixes -- List of prefixes for pool
Keyword Arguments (optional):... | python | def subnetpool_create(request, name, prefixes, **kwargs):
"""Create a subnetpool.
ip_version is auto-detected in back-end.
Parameters:
request -- Request context
name -- Name for subnetpool
prefixes -- List of prefixes for pool
Keyword Arguments (optional):... | [
"def",
"subnetpool_create",
"(",
"request",
",",
"name",
",",
"prefixes",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"\"subnetpool_create(): name=%(name)s, prefixes=%(prefixes)s, \"",
"\"kwargs=%(kwargs)s\"",
",",
"{",
"'name'",
":",
"name",
",",
... | Create a subnetpool.
ip_version is auto-detected in back-end.
Parameters:
request -- Request context
name -- Name for subnetpool
prefixes -- List of prefixes for pool
Keyword Arguments (optional):
min_prefixlen -- Minimum prefix length for allocations f... | [
"Create",
"a",
"subnetpool",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1243-L1277 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | port_list_with_trunk_types | def port_list_with_trunk_types(request, **params):
"""List neutron Ports for this tenant with possible TrunkPort indicated
:param request: request context
NOTE Performing two API calls is not atomic, but this is not worse
than the original idea when we call port_list repeatedly for
each ... | python | def port_list_with_trunk_types(request, **params):
"""List neutron Ports for this tenant with possible TrunkPort indicated
:param request: request context
NOTE Performing two API calls is not atomic, but this is not worse
than the original idea when we call port_list repeatedly for
each ... | [
"def",
"port_list_with_trunk_types",
"(",
"request",
",",
"*",
"*",
"params",
")",
":",
"LOG",
".",
"debug",
"(",
"\"port_list_with_trunk_types(): params=%s\"",
",",
"params",
")",
"# When trunk feature is disabled in neutron, we have no need to fetch",
"# trunk information and... | List neutron Ports for this tenant with possible TrunkPort indicated
:param request: request context
NOTE Performing two API calls is not atomic, but this is not worse
than the original idea when we call port_list repeatedly for
each network to perform identification run-time. We should
... | [
"List",
"neutron",
"Ports",
"for",
"this",
"tenant",
"with",
"possible",
"TrunkPort",
"indicated"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1308-L1348 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | port_create | def port_create(request, network_id, **kwargs):
"""Create a port on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param device_id: (optional) device id attached to the port
:param tenant_id: (optional) tenant id of the port created
:p... | python | def port_create(request, network_id, **kwargs):
"""Create a port on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param device_id: (optional) device id attached to the port
:param tenant_id: (optional) tenant id of the port created
:p... | [
"def",
"port_create",
"(",
"request",
",",
"network_id",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"\"port_create(): netid=%(network_id)s, kwargs=%(kwargs)s\"",
",",
"{",
"'network_id'",
":",
"network_id",
",",
"'kwargs'",
":",
"kwargs",
"}",
... | Create a port on a specified network.
:param request: request context
:param network_id: network id a subnet is created on
:param device_id: (optional) device id attached to the port
:param tenant_id: (optional) tenant id of the port created
:param name: (optional) name of the port created
:ret... | [
"Create",
"a",
"port",
"on",
"a",
"specified",
"network",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1367-L1385 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | list_extensions | def list_extensions(request):
"""List neutron extensions.
:param request: django request object
"""
neutron_api = neutronclient(request)
try:
extensions_list = neutron_api.list_extensions()
except exceptions.ServiceCatalogException:
return {}
if 'extensions' in extensions_li... | python | def list_extensions(request):
"""List neutron extensions.
:param request: django request object
"""
neutron_api = neutronclient(request)
try:
extensions_list = neutron_api.list_extensions()
except exceptions.ServiceCatalogException:
return {}
if 'extensions' in extensions_li... | [
"def",
"list_extensions",
"(",
"request",
")",
":",
"neutron_api",
"=",
"neutronclient",
"(",
"request",
")",
"try",
":",
"extensions_list",
"=",
"neutron_api",
".",
"list_extensions",
"(",
")",
"except",
"exceptions",
".",
"ServiceCatalogException",
":",
"return"... | List neutron extensions.
:param request: django request object | [
"List",
"neutron",
"extensions",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1795-L1808 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | is_extension_supported | def is_extension_supported(request, extension_alias):
"""Check if a specified extension is supported.
:param request: django request object
:param extension_alias: neutron extension alias
"""
extensions = list_extensions(request)
for extension in extensions:
if extension['alias'] == ext... | python | def is_extension_supported(request, extension_alias):
"""Check if a specified extension is supported.
:param request: django request object
:param extension_alias: neutron extension alias
"""
extensions = list_extensions(request)
for extension in extensions:
if extension['alias'] == ext... | [
"def",
"is_extension_supported",
"(",
"request",
",",
"extension_alias",
")",
":",
"extensions",
"=",
"list_extensions",
"(",
"request",
")",
"for",
"extension",
"in",
"extensions",
":",
"if",
"extension",
"[",
"'alias'",
"]",
"==",
"extension_alias",
":",
"retu... | Check if a specified extension is supported.
:param request: django request object
:param extension_alias: neutron extension alias | [
"Check",
"if",
"a",
"specified",
"extension",
"is",
"supported",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1812-L1823 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | get_feature_permission | def get_feature_permission(request, feature, operation=None):
"""Check if a feature-specific field can be displayed.
This method check a permission for a feature-specific field.
Such field is usually provided through Neutron extension.
:param request: Request Object
:param feature: feature name de... | python | def get_feature_permission(request, feature, operation=None):
"""Check if a feature-specific field can be displayed.
This method check a permission for a feature-specific field.
Such field is usually provided through Neutron extension.
:param request: Request Object
:param feature: feature name de... | [
"def",
"get_feature_permission",
"(",
"request",
",",
"feature",
",",
"operation",
"=",
"None",
")",
":",
"network_config",
"=",
"getattr",
"(",
"settings",
",",
"'OPENSTACK_NEUTRON_NETWORK'",
",",
"{",
"}",
")",
"feature_info",
"=",
"FEATURE_MAP",
".",
"get",
... | Check if a feature-specific field can be displayed.
This method check a permission for a feature-specific field.
Such field is usually provided through Neutron extension.
:param request: Request Object
:param feature: feature name defined in FEATURE_MAP
:param operation (optional): Operation type.... | [
"Check",
"if",
"a",
"feature",
"-",
"specific",
"field",
"can",
"be",
"displayed",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1889-L1940 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | policy_create | def policy_create(request, **kwargs):
"""Create a QoS Policy.
:param request: request context
:param name: name of the policy
:param description: description of policy
:param shared: boolean (true or false)
:return: QoSPolicy object
"""
body = {'policy': kwargs}
policy = neutronclie... | python | def policy_create(request, **kwargs):
"""Create a QoS Policy.
:param request: request context
:param name: name of the policy
:param description: description of policy
:param shared: boolean (true or false)
:return: QoSPolicy object
"""
body = {'policy': kwargs}
policy = neutronclie... | [
"def",
"policy_create",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"body",
"=",
"{",
"'policy'",
":",
"kwargs",
"}",
"policy",
"=",
"neutronclient",
"(",
"request",
")",
".",
"create_qos_policy",
"(",
"body",
"=",
"body",
")",
".",
"get",
"(",
... | Create a QoS Policy.
:param request: request context
:param name: name of the policy
:param description: description of policy
:param shared: boolean (true or false)
:return: QoSPolicy object | [
"Create",
"a",
"QoS",
"Policy",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1950-L1961 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | policy_list | def policy_list(request, **kwargs):
"""List of QoS Policies."""
policies = neutronclient(request).list_qos_policies(
**kwargs).get('policies')
return [QoSPolicy(p) for p in policies] | python | def policy_list(request, **kwargs):
"""List of QoS Policies."""
policies = neutronclient(request).list_qos_policies(
**kwargs).get('policies')
return [QoSPolicy(p) for p in policies] | [
"def",
"policy_list",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"policies",
"=",
"neutronclient",
"(",
"request",
")",
".",
"list_qos_policies",
"(",
"*",
"*",
"kwargs",
")",
".",
"get",
"(",
"'policies'",
")",
"return",
"[",
"QoSPolicy",
"(",
... | List of QoS Policies. | [
"List",
"of",
"QoS",
"Policies",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1964-L1968 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | policy_get | def policy_get(request, policy_id, **kwargs):
"""Get QoS policy for a given policy id."""
policy = neutronclient(request).show_qos_policy(
policy_id, **kwargs).get('policy')
return QoSPolicy(policy) | python | def policy_get(request, policy_id, **kwargs):
"""Get QoS policy for a given policy id."""
policy = neutronclient(request).show_qos_policy(
policy_id, **kwargs).get('policy')
return QoSPolicy(policy) | [
"def",
"policy_get",
"(",
"request",
",",
"policy_id",
",",
"*",
"*",
"kwargs",
")",
":",
"policy",
"=",
"neutronclient",
"(",
"request",
")",
".",
"show_qos_policy",
"(",
"policy_id",
",",
"*",
"*",
"kwargs",
")",
".",
"get",
"(",
"'policy'",
")",
"re... | Get QoS policy for a given policy id. | [
"Get",
"QoS",
"policy",
"for",
"a",
"given",
"policy",
"id",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L1972-L1976 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | rbac_policy_create | def rbac_policy_create(request, **kwargs):
"""Create a RBAC Policy.
:param request: request context
:param target_tenant: target tenant of the policy
:param tenant_id: owner tenant of the policy(Not recommended)
:param object_type: network or qos_policy
:param object_id: object id of policy
... | python | def rbac_policy_create(request, **kwargs):
"""Create a RBAC Policy.
:param request: request context
:param target_tenant: target tenant of the policy
:param tenant_id: owner tenant of the policy(Not recommended)
:param object_type: network or qos_policy
:param object_id: object id of policy
... | [
"def",
"rbac_policy_create",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"body",
"=",
"{",
"'rbac_policy'",
":",
"kwargs",
"}",
"rbac_policy",
"=",
"neutronclient",
"(",
"request",
")",
".",
"create_rbac_policy",
"(",
"body",
"=",
"body",
")",
".",
... | Create a RBAC Policy.
:param request: request context
:param target_tenant: target tenant of the policy
:param tenant_id: owner tenant of the policy(Not recommended)
:param object_type: network or qos_policy
:param object_id: object id of policy
:param action: access_as_shared or access_as_exte... | [
"Create",
"a",
"RBAC",
"Policy",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L2001-L2015 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | rbac_policy_list | def rbac_policy_list(request, **kwargs):
"""List of RBAC Policies."""
policies = neutronclient(request).list_rbac_policies(
**kwargs).get('rbac_policies')
return [RBACPolicy(p) for p in policies] | python | def rbac_policy_list(request, **kwargs):
"""List of RBAC Policies."""
policies = neutronclient(request).list_rbac_policies(
**kwargs).get('rbac_policies')
return [RBACPolicy(p) for p in policies] | [
"def",
"rbac_policy_list",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"policies",
"=",
"neutronclient",
"(",
"request",
")",
".",
"list_rbac_policies",
"(",
"*",
"*",
"kwargs",
")",
".",
"get",
"(",
"'rbac_policies'",
")",
"return",
"[",
"RBACPolic... | List of RBAC Policies. | [
"List",
"of",
"RBAC",
"Policies",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L2018-L2022 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | rbac_policy_update | def rbac_policy_update(request, policy_id, **kwargs):
"""Update a RBAC Policy.
:param request: request context
:param policy_id: target policy id
:param target_tenant: target tenant of the policy
:return: RBACPolicy object
"""
body = {'rbac_policy': kwargs}
rbac_policy = neutronclient(r... | python | def rbac_policy_update(request, policy_id, **kwargs):
"""Update a RBAC Policy.
:param request: request context
:param policy_id: target policy id
:param target_tenant: target tenant of the policy
:return: RBACPolicy object
"""
body = {'rbac_policy': kwargs}
rbac_policy = neutronclient(r... | [
"def",
"rbac_policy_update",
"(",
"request",
",",
"policy_id",
",",
"*",
"*",
"kwargs",
")",
":",
"body",
"=",
"{",
"'rbac_policy'",
":",
"kwargs",
"}",
"rbac_policy",
"=",
"neutronclient",
"(",
"request",
")",
".",
"update_rbac_policy",
"(",
"policy_id",
",... | Update a RBAC Policy.
:param request: request context
:param policy_id: target policy id
:param target_tenant: target tenant of the policy
:return: RBACPolicy object | [
"Update",
"a",
"RBAC",
"Policy",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L2025-L2036 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | rbac_policy_get | def rbac_policy_get(request, policy_id, **kwargs):
"""Get RBAC policy for a given policy id."""
policy = neutronclient(request).show_rbac_policy(
policy_id, **kwargs).get('rbac_policy')
return RBACPolicy(policy) | python | def rbac_policy_get(request, policy_id, **kwargs):
"""Get RBAC policy for a given policy id."""
policy = neutronclient(request).show_rbac_policy(
policy_id, **kwargs).get('rbac_policy')
return RBACPolicy(policy) | [
"def",
"rbac_policy_get",
"(",
"request",
",",
"policy_id",
",",
"*",
"*",
"kwargs",
")",
":",
"policy",
"=",
"neutronclient",
"(",
"request",
")",
".",
"show_rbac_policy",
"(",
"policy_id",
",",
"*",
"*",
"kwargs",
")",
".",
"get",
"(",
"'rbac_policy'",
... | Get RBAC policy for a given policy id. | [
"Get",
"RBAC",
"policy",
"for",
"a",
"given",
"policy",
"id",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L2040-L2044 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager.list | def list(self, **params):
"""Fetches a list all security groups.
:returns: List of SecurityGroup objects
"""
# This is to ensure tenant_id key is not populated
# if tenant_id=None is specified.
tenant_id = params.pop('tenant_id', self.request.user.tenant_id)
if t... | python | def list(self, **params):
"""Fetches a list all security groups.
:returns: List of SecurityGroup objects
"""
# This is to ensure tenant_id key is not populated
# if tenant_id=None is specified.
tenant_id = params.pop('tenant_id', self.request.user.tenant_id)
if t... | [
"def",
"list",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"# This is to ensure tenant_id key is not populated",
"# if tenant_id=None is specified.",
"tenant_id",
"=",
"params",
".",
"pop",
"(",
"'tenant_id'",
",",
"self",
".",
"request",
".",
"user",
".",
"te... | Fetches a list all security groups.
:returns: List of SecurityGroup objects | [
"Fetches",
"a",
"list",
"all",
"security",
"groups",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L361-L371 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager._sg_name_dict | def _sg_name_dict(self, sg_id, rules):
"""Create a mapping dict from secgroup id to its name."""
related_ids = set([sg_id])
related_ids |= set(filter(None, [r['remote_group_id'] for r in rules]))
related_sgs = self.client.list_security_groups(id=related_ids,
... | python | def _sg_name_dict(self, sg_id, rules):
"""Create a mapping dict from secgroup id to its name."""
related_ids = set([sg_id])
related_ids |= set(filter(None, [r['remote_group_id'] for r in rules]))
related_sgs = self.client.list_security_groups(id=related_ids,
... | [
"def",
"_sg_name_dict",
"(",
"self",
",",
"sg_id",
",",
"rules",
")",
":",
"related_ids",
"=",
"set",
"(",
"[",
"sg_id",
"]",
")",
"related_ids",
"|=",
"set",
"(",
"filter",
"(",
"None",
",",
"[",
"r",
"[",
"'remote_group_id'",
"]",
"for",
"r",
"in",... | Create a mapping dict from secgroup id to its name. | [
"Create",
"a",
"mapping",
"dict",
"from",
"secgroup",
"id",
"to",
"its",
"name",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L373-L380 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager.get | def get(self, sg_id):
"""Fetches the security group.
:returns: SecurityGroup object corresponding to sg_id
"""
secgroup = self.client.show_security_group(sg_id).get('security_group')
sg_dict = self._sg_name_dict(sg_id, secgroup['security_group_rules'])
return SecurityGro... | python | def get(self, sg_id):
"""Fetches the security group.
:returns: SecurityGroup object corresponding to sg_id
"""
secgroup = self.client.show_security_group(sg_id).get('security_group')
sg_dict = self._sg_name_dict(sg_id, secgroup['security_group_rules'])
return SecurityGro... | [
"def",
"get",
"(",
"self",
",",
"sg_id",
")",
":",
"secgroup",
"=",
"self",
".",
"client",
".",
"show_security_group",
"(",
"sg_id",
")",
".",
"get",
"(",
"'security_group'",
")",
"sg_dict",
"=",
"self",
".",
"_sg_name_dict",
"(",
"sg_id",
",",
"secgroup... | Fetches the security group.
:returns: SecurityGroup object corresponding to sg_id | [
"Fetches",
"the",
"security",
"group",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L383-L390 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager.rule_create | def rule_create(self, parent_group_id,
direction=None, ethertype=None,
ip_protocol=None, from_port=None, to_port=None,
cidr=None, group_id=None, description=None):
"""Create a new security group rule.
:param parent_group_id: security group id ... | python | def rule_create(self, parent_group_id,
direction=None, ethertype=None,
ip_protocol=None, from_port=None, to_port=None,
cidr=None, group_id=None, description=None):
"""Create a new security group rule.
:param parent_group_id: security group id ... | [
"def",
"rule_create",
"(",
"self",
",",
"parent_group_id",
",",
"direction",
"=",
"None",
",",
"ethertype",
"=",
"None",
",",
"ip_protocol",
"=",
"None",
",",
"from_port",
"=",
"None",
",",
"to_port",
"=",
"None",
",",
"cidr",
"=",
"None",
",",
"group_id... | Create a new security group rule.
:param parent_group_id: security group id a rule is created to
:param direction: ``ingress`` or ``egress``
:param ethertype: ``IPv4`` or ``IPv6``
:param ip_protocol: tcp, udp, icmp
:param from_port: L4 port range min
:param to_port: L4 p... | [
"Create",
"a",
"new",
"security",
"group",
"rule",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L417-L463 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager.list_by_instance | def list_by_instance(self, instance_id):
"""Gets security groups of an instance.
:returns: List of SecurityGroup objects associated with the instance
"""
ports = port_list(self.request, device_id=instance_id)
sg_ids = []
for p in ports:
sg_ids += p.security_g... | python | def list_by_instance(self, instance_id):
"""Gets security groups of an instance.
:returns: List of SecurityGroup objects associated with the instance
"""
ports = port_list(self.request, device_id=instance_id)
sg_ids = []
for p in ports:
sg_ids += p.security_g... | [
"def",
"list_by_instance",
"(",
"self",
",",
"instance_id",
")",
":",
"ports",
"=",
"port_list",
"(",
"self",
".",
"request",
",",
"device_id",
"=",
"instance_id",
")",
"sg_ids",
"=",
"[",
"]",
"for",
"p",
"in",
"ports",
":",
"sg_ids",
"+=",
"p",
".",
... | Gets security groups of an instance.
:returns: List of SecurityGroup objects associated with the instance | [
"Gets",
"security",
"groups",
"of",
"an",
"instance",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L471-L480 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | SecurityGroupManager.update_instance_security_group | def update_instance_security_group(self, instance_id,
new_security_group_ids):
"""Update security groups of a specified instance."""
ports = port_list(self.request, device_id=instance_id)
for p in ports:
params = {'security_groups': new_security... | python | def update_instance_security_group(self, instance_id,
new_security_group_ids):
"""Update security groups of a specified instance."""
ports = port_list(self.request, device_id=instance_id)
for p in ports:
params = {'security_groups': new_security... | [
"def",
"update_instance_security_group",
"(",
"self",
",",
"instance_id",
",",
"new_security_group_ids",
")",
":",
"ports",
"=",
"port_list",
"(",
"self",
".",
"request",
",",
"device_id",
"=",
"instance_id",
")",
"for",
"p",
"in",
"ports",
":",
"params",
"=",... | Update security groups of a specified instance. | [
"Update",
"security",
"groups",
"of",
"a",
"specified",
"instance",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L483-L489 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.list_pools | def list_pools(self):
"""Fetches a list of all floating IP pools.
:returns: List of FloatingIpPool objects
"""
search_opts = {'router:external': True}
return [FloatingIpPool(pool) for pool
in self.client.list_networks(**search_opts).get('networks')] | python | def list_pools(self):
"""Fetches a list of all floating IP pools.
:returns: List of FloatingIpPool objects
"""
search_opts = {'router:external': True}
return [FloatingIpPool(pool) for pool
in self.client.list_networks(**search_opts).get('networks')] | [
"def",
"list_pools",
"(",
"self",
")",
":",
"search_opts",
"=",
"{",
"'router:external'",
":",
"True",
"}",
"return",
"[",
"FloatingIpPool",
"(",
"pool",
")",
"for",
"pool",
"in",
"self",
".",
"client",
".",
"list_networks",
"(",
"*",
"*",
"search_opts",
... | Fetches a list of all floating IP pools.
:returns: List of FloatingIpPool objects | [
"Fetches",
"a",
"list",
"of",
"all",
"floating",
"IP",
"pools",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L553-L560 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.list | def list(self, all_tenants=False, **search_opts):
"""Fetches a list of all floating IPs.
:returns: List of FloatingIp object
"""
if not all_tenants:
tenant_id = self.request.user.tenant_id
# In Neutron, list_floatingips returns Floating IPs from
# all... | python | def list(self, all_tenants=False, **search_opts):
"""Fetches a list of all floating IPs.
:returns: List of FloatingIp object
"""
if not all_tenants:
tenant_id = self.request.user.tenant_id
# In Neutron, list_floatingips returns Floating IPs from
# all... | [
"def",
"list",
"(",
"self",
",",
"all_tenants",
"=",
"False",
",",
"*",
"*",
"search_opts",
")",
":",
"if",
"not",
"all_tenants",
":",
"tenant_id",
"=",
"self",
".",
"request",
".",
"user",
".",
"tenant_id",
"# In Neutron, list_floatingips returns Floating IPs f... | Fetches a list of all floating IPs.
:returns: List of FloatingIp object | [
"Fetches",
"a",
"list",
"of",
"all",
"floating",
"IPs",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L580-L602 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.get | def get(self, floating_ip_id):
"""Fetches the floating IP.
:returns: FloatingIp object corresponding to floating_ip_id
"""
fip = self.client.show_floatingip(floating_ip_id).get('floatingip')
self._set_instance_info(fip)
return FloatingIp(fip) | python | def get(self, floating_ip_id):
"""Fetches the floating IP.
:returns: FloatingIp object corresponding to floating_ip_id
"""
fip = self.client.show_floatingip(floating_ip_id).get('floatingip')
self._set_instance_info(fip)
return FloatingIp(fip) | [
"def",
"get",
"(",
"self",
",",
"floating_ip_id",
")",
":",
"fip",
"=",
"self",
".",
"client",
".",
"show_floatingip",
"(",
"floating_ip_id",
")",
".",
"get",
"(",
"'floatingip'",
")",
"self",
".",
"_set_instance_info",
"(",
"fip",
")",
"return",
"Floating... | Fetches the floating IP.
:returns: FloatingIp object corresponding to floating_ip_id | [
"Fetches",
"the",
"floating",
"IP",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L605-L612 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.allocate | def allocate(self, pool, tenant_id=None, **params):
"""Allocates a floating IP to the tenant.
You must provide a pool name or id for which you would like to
allocate a floating IP.
:returns: FloatingIp object corresponding to an allocated floating IP
"""
if not tenant_i... | python | def allocate(self, pool, tenant_id=None, **params):
"""Allocates a floating IP to the tenant.
You must provide a pool name or id for which you would like to
allocate a floating IP.
:returns: FloatingIp object corresponding to an allocated floating IP
"""
if not tenant_i... | [
"def",
"allocate",
"(",
"self",
",",
"pool",
",",
"tenant_id",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"if",
"not",
"tenant_id",
":",
"tenant_id",
"=",
"self",
".",
"request",
".",
"user",
".",
"project_id",
"create_dict",
"=",
"{",
"'floating_... | Allocates a floating IP to the tenant.
You must provide a pool name or id for which you would like to
allocate a floating IP.
:returns: FloatingIp object corresponding to an allocated floating IP | [
"Allocates",
"a",
"floating",
"IP",
"to",
"the",
"tenant",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L615-L640 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.associate | def associate(self, floating_ip_id, port_id):
"""Associates the floating IP to the port.
``port_id`` represents a VNIC of an instance.
``port_id`` argument is different from a normal neutron port ID.
A value passed as ``port_id`` must be one of target_id returned by
``list_targe... | python | def associate(self, floating_ip_id, port_id):
"""Associates the floating IP to the port.
``port_id`` represents a VNIC of an instance.
``port_id`` argument is different from a normal neutron port ID.
A value passed as ``port_id`` must be one of target_id returned by
``list_targe... | [
"def",
"associate",
"(",
"self",
",",
"floating_ip_id",
",",
"port_id",
")",
":",
"# NOTE: In Neutron Horizon floating IP support, port_id is",
"# \"<port_id>_<ip_address>\" format to identify multiple ports.",
"pid",
",",
"ip_address",
"=",
"port_id",
".",
"split",
"(",
"'_'... | Associates the floating IP to the port.
``port_id`` represents a VNIC of an instance.
``port_id`` argument is different from a normal neutron port ID.
A value passed as ``port_id`` must be one of target_id returned by
``list_targets``, ``get_target_by_instance`` or
``list_target... | [
"Associates",
"the",
"floating",
"IP",
"to",
"the",
"port",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L648-L663 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.list_targets | def list_targets(self):
"""Returns a list of association targets of instance VIFs.
Each association target is represented as FloatingIpTarget object.
FloatingIpTarget is a APIResourceWrapper/APIDictWrapper and
'id' and 'name' attributes must be defined in each object.
FloatingIp... | python | def list_targets(self):
"""Returns a list of association targets of instance VIFs.
Each association target is represented as FloatingIpTarget object.
FloatingIpTarget is a APIResourceWrapper/APIDictWrapper and
'id' and 'name' attributes must be defined in each object.
FloatingIp... | [
"def",
"list_targets",
"(",
"self",
")",
":",
"tenant_id",
"=",
"self",
".",
"request",
".",
"user",
".",
"tenant_id",
"ports",
"=",
"port_list",
"(",
"self",
".",
"request",
",",
"tenant_id",
"=",
"tenant_id",
")",
"servers",
",",
"has_more",
"=",
"nova... | Returns a list of association targets of instance VIFs.
Each association target is represented as FloatingIpTarget object.
FloatingIpTarget is a APIResourceWrapper/APIDictWrapper and
'id' and 'name' attributes must be defined in each object.
FloatingIpTarget.id can be passed as port_id ... | [
"Returns",
"a",
"list",
"of",
"association",
"targets",
"of",
"instance",
"VIFs",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L700-L731 | train |
openstack/horizon | openstack_dashboard/api/neutron.py | FloatingIpManager.list_targets_by_instance | def list_targets_by_instance(self, instance_id, target_list=None):
"""Returns a list of FloatingIpTarget objects of FIP association.
:param instance_id: ID of target VM instance
:param target_list: (optional) a list returned by list_targets().
If specified, looking up is done agains... | python | def list_targets_by_instance(self, instance_id, target_list=None):
"""Returns a list of FloatingIpTarget objects of FIP association.
:param instance_id: ID of target VM instance
:param target_list: (optional) a list returned by list_targets().
If specified, looking up is done agains... | [
"def",
"list_targets_by_instance",
"(",
"self",
",",
"instance_id",
",",
"target_list",
"=",
"None",
")",
":",
"if",
"target_list",
"is",
"not",
"None",
":",
"# We assume that target_list was returned by list_targets()",
"# so we can assume checks for subnet reachability and IP... | Returns a list of FloatingIpTarget objects of FIP association.
:param instance_id: ID of target VM instance
:param target_list: (optional) a list returned by list_targets().
If specified, looking up is done against the specified list
to save extra API calls to a back-end. Otherw... | [
"Returns",
"a",
"list",
"of",
"FloatingIpTarget",
"objects",
"of",
"FIP",
"association",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/neutron.py#L740-L769 | train |
openstack/horizon | horizon/decorators.py | require_perms | def require_perms(view_func, required):
"""Enforces permission-based access controls.
:param list required: A tuple of permission names, all of which the request
user must possess in order access the decorated view.
Example usage::
from horizon.decorators import require_... | python | def require_perms(view_func, required):
"""Enforces permission-based access controls.
:param list required: A tuple of permission names, all of which the request
user must possess in order access the decorated view.
Example usage::
from horizon.decorators import require_... | [
"def",
"require_perms",
"(",
"view_func",
",",
"required",
")",
":",
"from",
"horizon",
".",
"exceptions",
"import",
"NotAuthorized",
"# We only need to check each permission once for a view, so we'll use a set",
"current_perms",
"=",
"getattr",
"(",
"view_func",
",",
"'_re... | Enforces permission-based access controls.
:param list required: A tuple of permission names, all of which the request
user must possess in order access the decorated view.
Example usage::
from horizon.decorators import require_perms
@require_perms(['foo.admin', 'f... | [
"Enforces",
"permission",
"-",
"based",
"access",
"controls",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/decorators.py#L57-L92 | train |
openstack/horizon | horizon/decorators.py | require_component_access | def require_component_access(view_func, component):
"""Perform component can_access check to access the view.
:param component containing the view (panel or dashboard).
Raises a :exc:`~horizon.exceptions.NotAuthorized` exception if the
user cannot access the component containing the view.
By examp... | python | def require_component_access(view_func, component):
"""Perform component can_access check to access the view.
:param component containing the view (panel or dashboard).
Raises a :exc:`~horizon.exceptions.NotAuthorized` exception if the
user cannot access the component containing the view.
By examp... | [
"def",
"require_component_access",
"(",
"view_func",
",",
"component",
")",
":",
"from",
"horizon",
".",
"exceptions",
"import",
"NotAuthorized",
"@",
"functools",
".",
"wraps",
"(",
"view_func",
",",
"assigned",
"=",
"available_attrs",
"(",
"view_func",
")",
")... | Perform component can_access check to access the view.
:param component containing the view (panel or dashboard).
Raises a :exc:`~horizon.exceptions.NotAuthorized` exception if the
user cannot access the component containing the view.
By example the check of component policy rules will be applied to i... | [
"Perform",
"component",
"can_access",
"check",
"to",
"access",
"the",
"view",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/decorators.py#L95-L115 | train |
openstack/horizon | openstack_dashboard/api/glance.py | image_get | def image_get(request, image_id):
"""Returns an Image object populated with metadata for a given image."""
image = glanceclient(request).images.get(image_id)
return Image(image) | python | def image_get(request, image_id):
"""Returns an Image object populated with metadata for a given image."""
image = glanceclient(request).images.get(image_id)
return Image(image) | [
"def",
"image_get",
"(",
"request",
",",
"image_id",
")",
":",
"image",
"=",
"glanceclient",
"(",
"request",
")",
".",
"images",
".",
"get",
"(",
"image_id",
")",
"return",
"Image",
"(",
"image",
")"
] | Returns an Image object populated with metadata for a given image. | [
"Returns",
"an",
"Image",
"object",
"populated",
"with",
"metadata",
"for",
"a",
"given",
"image",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L263-L266 | train |
openstack/horizon | openstack_dashboard/api/glance.py | image_list_detailed | def image_list_detailed(request, marker=None, sort_dir='desc',
sort_key='created_at', filters=None, paginate=False,
reversed_order=False, **kwargs):
"""Thin layer above glanceclient, for handling pagination issues.
It provides iterating both forward and backward ... | python | def image_list_detailed(request, marker=None, sort_dir='desc',
sort_key='created_at', filters=None, paginate=False,
reversed_order=False, **kwargs):
"""Thin layer above glanceclient, for handling pagination issues.
It provides iterating both forward and backward ... | [
"def",
"image_list_detailed",
"(",
"request",
",",
"marker",
"=",
"None",
",",
"sort_dir",
"=",
"'desc'",
",",
"sort_key",
"=",
"'created_at'",
",",
"filters",
"=",
"None",
",",
"paginate",
"=",
"False",
",",
"reversed_order",
"=",
"False",
",",
"*",
"*",
... | Thin layer above glanceclient, for handling pagination issues.
It provides iterating both forward and backward on top of ascetic
OpenStack pagination API - which natively supports only iterating forward
through the entries. Thus in order to retrieve list of objects at previous
page, a request with the ... | [
"Thin",
"layer",
"above",
"glanceclient",
"for",
"handling",
"pagination",
"issues",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L283-L386 | train |
openstack/horizon | openstack_dashboard/api/glance.py | create_image_metadata | def create_image_metadata(data):
"""Generate metadata dict for a new image from a given form data."""
# Default metadata
meta = {'protected': data.get('protected', False),
'disk_format': data.get('disk_format', 'raw'),
'container_format': data.get('container_format', 'bare'),
... | python | def create_image_metadata(data):
"""Generate metadata dict for a new image from a given form data."""
# Default metadata
meta = {'protected': data.get('protected', False),
'disk_format': data.get('disk_format', 'raw'),
'container_format': data.get('container_format', 'bare'),
... | [
"def",
"create_image_metadata",
"(",
"data",
")",
":",
"# Default metadata",
"meta",
"=",
"{",
"'protected'",
":",
"data",
".",
"get",
"(",
"'protected'",
",",
"False",
")",
",",
"'disk_format'",
":",
"data",
".",
"get",
"(",
"'disk_format'",
",",
"'raw'",
... | Generate metadata dict for a new image from a given form data. | [
"Generate",
"metadata",
"dict",
"for",
"a",
"new",
"image",
"from",
"a",
"given",
"form",
"data",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L451-L506 | train |
openstack/horizon | openstack_dashboard/api/glance.py | image_create | def image_create(request, **kwargs):
"""Create image.
:param kwargs:
* copy_from: URL from which Glance server should immediately copy
the data and store it in its configured image store.
* data: Form data posted from client.
* location: URL where the data for this image alr... | python | def image_create(request, **kwargs):
"""Create image.
:param kwargs:
* copy_from: URL from which Glance server should immediately copy
the data and store it in its configured image store.
* data: Form data posted from client.
* location: URL where the data for this image alr... | [
"def",
"image_create",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"kwargs",
".",
"pop",
"(",
"'data'",
",",
"None",
")",
"location",
"=",
"None",
"if",
"VERSIONS",
".",
"active",
">=",
"2",
":",
"location",
"=",
"kwargs",
".",
... | Create image.
:param kwargs:
* copy_from: URL from which Glance server should immediately copy
the data and store it in its configured image store.
* data: Form data posted from client.
* location: URL where the data for this image already resides.
In the case of 'copy_from... | [
"Create",
"image",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L521-L581 | train |
openstack/horizon | openstack_dashboard/api/glance.py | image_update_properties | def image_update_properties(request, image_id, remove_props=None, **kwargs):
"""Add or update a custom property of an image."""
return glanceclient(request, '2').images.update(image_id,
remove_props,
**kwargs... | python | def image_update_properties(request, image_id, remove_props=None, **kwargs):
"""Add or update a custom property of an image."""
return glanceclient(request, '2').images.update(image_id,
remove_props,
**kwargs... | [
"def",
"image_update_properties",
"(",
"request",
",",
"image_id",
",",
"remove_props",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"glanceclient",
"(",
"request",
",",
"'2'",
")",
".",
"images",
".",
"update",
"(",
"image_id",
",",
"remove_p... | Add or update a custom property of an image. | [
"Add",
"or",
"update",
"a",
"custom",
"property",
"of",
"an",
"image",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L585-L589 | train |
openstack/horizon | openstack_dashboard/api/glance.py | image_delete_properties | def image_delete_properties(request, image_id, keys):
"""Delete custom properties for an image."""
return glanceclient(request, '2').images.update(image_id, keys) | python | def image_delete_properties(request, image_id, keys):
"""Delete custom properties for an image."""
return glanceclient(request, '2').images.update(image_id, keys) | [
"def",
"image_delete_properties",
"(",
"request",
",",
"image_id",
",",
"keys",
")",
":",
"return",
"glanceclient",
"(",
"request",
",",
"'2'",
")",
".",
"images",
".",
"update",
"(",
"image_id",
",",
"keys",
")"
] | Delete custom properties for an image. | [
"Delete",
"custom",
"properties",
"for",
"an",
"image",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L593-L595 | train |
openstack/horizon | openstack_dashboard/api/glance.py | filter_properties_target | def filter_properties_target(namespaces_iter,
resource_types,
properties_target):
"""Filter metadata namespaces.
Filtering is done based ongiven resource types and a properties target.
:param namespaces_iter: Metadata namespaces iterable.
:para... | python | def filter_properties_target(namespaces_iter,
resource_types,
properties_target):
"""Filter metadata namespaces.
Filtering is done based ongiven resource types and a properties target.
:param namespaces_iter: Metadata namespaces iterable.
:para... | [
"def",
"filter_properties_target",
"(",
"namespaces_iter",
",",
"resource_types",
",",
"properties_target",
")",
":",
"def",
"filter_namespace",
"(",
"namespace",
")",
":",
"for",
"asn",
"in",
"namespace",
".",
"get",
"(",
"'resource_type_associations'",
")",
":",
... | Filter metadata namespaces.
Filtering is done based ongiven resource types and a properties target.
:param namespaces_iter: Metadata namespaces iterable.
:param resource_types: List of resource type names.
:param properties_target: Name of the properties target. | [
"Filter",
"metadata",
"namespaces",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L634-L651 | train |
openstack/horizon | openstack_dashboard/api/glance.py | metadefs_namespace_list | def metadefs_namespace_list(request,
filters=None,
sort_dir='asc',
sort_key='namespace',
marker=None,
paginate=False):
"""Retrieve a listing of Namespaces
:param paginate:... | python | def metadefs_namespace_list(request,
filters=None,
sort_dir='asc',
sort_key='namespace',
marker=None,
paginate=False):
"""Retrieve a listing of Namespaces
:param paginate:... | [
"def",
"metadefs_namespace_list",
"(",
"request",
",",
"filters",
"=",
"None",
",",
"sort_dir",
"=",
"'asc'",
",",
"sort_key",
"=",
"'namespace'",
",",
"marker",
"=",
"None",
",",
"paginate",
"=",
"False",
")",
":",
"# Listing namespaces requires the v2 API. If no... | Retrieve a listing of Namespaces
:param paginate: If true will perform pagination based on settings.
:param marker: Specifies the namespace of the last-seen namespace.
The typical pattern of limit and marker is to make an
initial limited request and then to use the last
n... | [
"Retrieve",
"a",
"listing",
"of",
"Namespaces"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/glance.py#L668-L751 | train |
openstack/horizon | horizon/utils/file_discovery.py | discover_files | def discover_files(base_path, sub_path='', ext='', trim_base_path=False):
"""Discovers all files with certain extension in given paths."""
file_list = []
for root, dirs, files in walk(path.join(base_path, sub_path)):
if trim_base_path:
root = path.relpath(root, base_path)
file_li... | python | def discover_files(base_path, sub_path='', ext='', trim_base_path=False):
"""Discovers all files with certain extension in given paths."""
file_list = []
for root, dirs, files in walk(path.join(base_path, sub_path)):
if trim_base_path:
root = path.relpath(root, base_path)
file_li... | [
"def",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"''",
",",
"ext",
"=",
"''",
",",
"trim_base_path",
"=",
"False",
")",
":",
"file_list",
"=",
"[",
"]",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"walk",
"(",
"path",
".",
"join",... | Discovers all files with certain extension in given paths. | [
"Discovers",
"all",
"files",
"with",
"certain",
"extension",
"in",
"given",
"paths",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/file_discovery.py#L25-L34 | train |
openstack/horizon | horizon/utils/file_discovery.py | sort_js_files | def sort_js_files(js_files):
"""Sorts JavaScript files in `js_files`.
It sorts JavaScript files in a given `js_files`
into source files, mock files and spec files based on file extension.
Output:
* sources: source files for production. The order of source files
is significant and should be... | python | def sort_js_files(js_files):
"""Sorts JavaScript files in `js_files`.
It sorts JavaScript files in a given `js_files`
into source files, mock files and spec files based on file extension.
Output:
* sources: source files for production. The order of source files
is significant and should be... | [
"def",
"sort_js_files",
"(",
"js_files",
")",
":",
"modules",
"=",
"[",
"f",
"for",
"f",
"in",
"js_files",
"if",
"f",
".",
"endswith",
"(",
"MODULE_EXT",
")",
"]",
"mocks",
"=",
"[",
"f",
"for",
"f",
"in",
"js_files",
"if",
"f",
".",
"endswith",
"(... | Sorts JavaScript files in `js_files`.
It sorts JavaScript files in a given `js_files`
into source files, mock files and spec files based on file extension.
Output:
* sources: source files for production. The order of source files
is significant and should be listed in the below order:
-... | [
"Sorts",
"JavaScript",
"files",
"in",
"js_files",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/file_discovery.py#L37-L72 | train |
openstack/horizon | horizon/utils/file_discovery.py | discover_static_files | def discover_static_files(base_path, sub_path=''):
"""Discovers static files in given paths.
It returns JavaScript sources, mocks, specs and HTML templates,
all grouped in lists.
"""
js_files = discover_files(base_path, sub_path=sub_path,
ext='.js', trim_base_path=True... | python | def discover_static_files(base_path, sub_path=''):
"""Discovers static files in given paths.
It returns JavaScript sources, mocks, specs and HTML templates,
all grouped in lists.
"""
js_files = discover_files(base_path, sub_path=sub_path,
ext='.js', trim_base_path=True... | [
"def",
"discover_static_files",
"(",
"base_path",
",",
"sub_path",
"=",
"''",
")",
":",
"js_files",
"=",
"discover_files",
"(",
"base_path",
",",
"sub_path",
"=",
"sub_path",
",",
"ext",
"=",
"'.js'",
",",
"trim_base_path",
"=",
"True",
")",
"sources",
",",
... | Discovers static files in given paths.
It returns JavaScript sources, mocks, specs and HTML templates,
all grouped in lists. | [
"Discovers",
"static",
"files",
"in",
"given",
"paths",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/file_discovery.py#L75-L93 | train |
openstack/horizon | horizon/utils/file_discovery.py | _log | def _log(file_list, list_name, in_path):
"""Logs result at debug level"""
file_names = '\n'.join(file_list)
LOG.debug("\nDiscovered %(size)d %(name)s file(s) in %(path)s:\n"
"%(files)s\n",
{'size': len(file_list), 'name': list_name, 'path': in_path,
'files': file_n... | python | def _log(file_list, list_name, in_path):
"""Logs result at debug level"""
file_names = '\n'.join(file_list)
LOG.debug("\nDiscovered %(size)d %(name)s file(s) in %(path)s:\n"
"%(files)s\n",
{'size': len(file_list), 'name': list_name, 'path': in_path,
'files': file_n... | [
"def",
"_log",
"(",
"file_list",
",",
"list_name",
",",
"in_path",
")",
":",
"file_names",
"=",
"'\\n'",
".",
"join",
"(",
"file_list",
")",
"LOG",
".",
"debug",
"(",
"\"\\nDiscovered %(size)d %(name)s file(s) in %(path)s:\\n\"",
"\"%(files)s\\n\"",
",",
"{",
"'si... | Logs result at debug level | [
"Logs",
"result",
"at",
"debug",
"level"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/file_discovery.py#L110-L116 | train |
openstack/horizon | horizon/browsers/base.py | ResourceBrowser.set_tables | def set_tables(self, tables):
"""Sets the table instances on the browser.
``tables`` argument specifies tables to be set.
It is a dictionary mapping table names to table instances
(as constructed by MultiTableView).
"""
self.navigation_table = tables[self.navigation_tabl... | python | def set_tables(self, tables):
"""Sets the table instances on the browser.
``tables`` argument specifies tables to be set.
It is a dictionary mapping table names to table instances
(as constructed by MultiTableView).
"""
self.navigation_table = tables[self.navigation_tabl... | [
"def",
"set_tables",
"(",
"self",
",",
"tables",
")",
":",
"self",
".",
"navigation_table",
"=",
"tables",
"[",
"self",
".",
"navigation_table_class",
".",
"_meta",
".",
"name",
"]",
"self",
".",
"content_table",
"=",
"tables",
"[",
"self",
".",
"content_t... | Sets the table instances on the browser.
``tables`` argument specifies tables to be set.
It is a dictionary mapping table names to table instances
(as constructed by MultiTableView). | [
"Sets",
"the",
"table",
"instances",
"on",
"the",
"browser",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/browsers/base.py#L121-L133 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.get_account_history | def get_account_history(self, account_id, **kwargs):
""" List account activity. Account activity either increases or
decreases your account balance.
Entry type indicates the reason for the account change.
* transfer: Funds moved to/from Coinbase to cbpro
* match: Funds moved as ... | python | def get_account_history(self, account_id, **kwargs):
""" List account activity. Account activity either increases or
decreases your account balance.
Entry type indicates the reason for the account change.
* transfer: Funds moved to/from Coinbase to cbpro
* match: Funds moved as ... | [
"def",
"get_account_history",
"(",
"self",
",",
"account_id",
",",
"*",
"*",
"kwargs",
")",
":",
"endpoint",
"=",
"'/accounts/{}/ledger'",
".",
"format",
"(",
"account_id",
")",
"return",
"self",
".",
"_send_paginated_message",
"(",
"endpoint",
",",
"params",
... | List account activity. Account activity either increases or
decreases your account balance.
Entry type indicates the reason for the account change.
* transfer: Funds moved to/from Coinbase to cbpro
* match: Funds moved as a result of a trade
* fee: Fee as a result of a trade... | [
"List",
"account",
"activity",
".",
"Account",
"activity",
"either",
"increases",
"or",
"decreases",
"your",
"account",
"balance",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L91-L129 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.get_account_holds | def get_account_holds(self, account_id, **kwargs):
""" Get holds on an account.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Holds are placed on an account for active orders or
pending withdraw requests.
As an order ... | python | def get_account_holds(self, account_id, **kwargs):
""" Get holds on an account.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Holds are placed on an account for active orders or
pending withdraw requests.
As an order ... | [
"def",
"get_account_holds",
"(",
"self",
",",
"account_id",
",",
"*",
"*",
"kwargs",
")",
":",
"endpoint",
"=",
"'/accounts/{}/holds'",
".",
"format",
"(",
"account_id",
")",
"return",
"self",
".",
"_send_paginated_message",
"(",
"endpoint",
",",
"params",
"="... | Get holds on an account.
This method returns a generator which may make multiple HTTP requests
while iterating through it.
Holds are placed on an account for active orders or
pending withdraw requests.
As an order is filled, the hold amount is updated. If an order
is c... | [
"Get",
"holds",
"on",
"an",
"account",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L131-L174 | train |
danpaquin/coinbasepro-python | cbpro/authenticated_client.py | AuthenticatedClient.buy | def buy(self, product_id, order_type, **kwargs):
"""Place a buy order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
p... | python | def buy(self, product_id, order_type, **kwargs):
"""Place a buy order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
p... | [
"def",
"buy",
"(",
"self",
",",
"product_id",
",",
"order_type",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"place_order",
"(",
"product_id",
",",
"'buy'",
",",
"order_type",
",",
"*",
"*",
"kwargs",
")"
] | Place a buy order.
This is included to maintain backwards compatibility with older versions
of cbpro-Python. For maximum support from docstrings and function
signatures see the order type-specific functions place_limit_order,
place_market_order, and place_stop_order.
Args:
... | [
"Place",
"a",
"buy",
"order",
"."
] | 0a9dbd86a25ae266d0e0eefeb112368c284b7dcc | https://github.com/danpaquin/coinbasepro-python/blob/0a9dbd86a25ae266d0e0eefeb112368c284b7dcc/cbpro/authenticated_client.py#L258-L276 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.