partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | delete_subnet | Delete a subnet.
: param context: neutron api request context
: param id: UUID representing the subnet to delete. | quark/plugin_modules/subnets.py | def delete_subnet(context, id):
"""Delete a subnet.
: param context: neutron api request context
: param id: UUID representing the subnet to delete.
"""
LOG.info("delete_subnet %s for tenant %s" % (id, context.tenant_id))
with context.session.begin():
subnet = db_api.subnet_find(context... | def delete_subnet(context, id):
"""Delete a subnet.
: param context: neutron api request context
: param id: UUID representing the subnet to delete.
"""
LOG.info("delete_subnet %s for tenant %s" % (id, context.tenant_id))
with context.session.begin():
subnet = db_api.subnet_find(context... | [
"Delete",
"a",
"subnet",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/subnets.py#L454-L477 | [
"def",
"delete_subnet",
"(",
"context",
",",
"id",
")",
":",
"LOG",
".",
"info",
"(",
"\"delete_subnet %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"with",
"context",
".",
"session",
".",
"begin",
"(",
")",
":",
"subne... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Mac_address_ranges.get_resources | Returns Ext Resources. | quark/api/extensions/mac_address_ranges.py | def get_resources(cls):
"""Returns Ext Resources."""
plugin = directory.get_plugin()
controller = MacAddressRangesController(plugin)
return [extensions.ResourceExtension(Mac_address_ranges.get_alias(),
controller)] | def get_resources(cls):
"""Returns Ext Resources."""
plugin = directory.get_plugin()
controller = MacAddressRangesController(plugin)
return [extensions.ResourceExtension(Mac_address_ranges.get_alias(),
controller)] | [
"Returns",
"Ext",
"Resources",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/api/extensions/mac_address_ranges.py#L103-L108 | [
"def",
"get_resources",
"(",
"cls",
")",
":",
"plugin",
"=",
"directory",
".",
"get_plugin",
"(",
")",
"controller",
"=",
"MacAddressRangesController",
"(",
"plugin",
")",
"return",
"[",
"extensions",
".",
"ResourceExtension",
"(",
"Mac_address_ranges",
".",
"ge... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | _filter_update_security_group_rule | Only two fields are allowed for modification:
external_service and external_service_id | quark/plugin_modules/security_groups.py | def _filter_update_security_group_rule(rule):
'''Only two fields are allowed for modification:
external_service and external_service_id
'''
allowed = ['external_service', 'external_service_id']
filtered = {}
for k, val in rule.iteritems():
if k in allowed:
if isinstance(... | def _filter_update_security_group_rule(rule):
'''Only two fields are allowed for modification:
external_service and external_service_id
'''
allowed = ['external_service', 'external_service_id']
filtered = {}
for k, val in rule.iteritems():
if k in allowed:
if isinstance(... | [
"Only",
"two",
"fields",
"are",
"allowed",
"for",
"modification",
":"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/security_groups.py#L80-L92 | [
"def",
"_filter_update_security_group_rule",
"(",
"rule",
")",
":",
"allowed",
"=",
"[",
"'external_service'",
",",
"'external_service_id'",
"]",
"filtered",
"=",
"{",
"}",
"for",
"k",
",",
"val",
"in",
"rule",
".",
"iteritems",
"(",
")",
":",
"if",
"k",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | _perform_async_update_rule | Updates a SG rule async and return the job information.
Only happens if the security group has associated ports. If the async
connection fails the update continues (legacy mode). | quark/plugin_modules/security_groups.py | def _perform_async_update_rule(context, id, db_sg_group, rule_id, action):
"""Updates a SG rule async and return the job information.
Only happens if the security group has associated ports. If the async
connection fails the update continues (legacy mode).
"""
rpc_reply = None
sg_rpc = sg_rpc_a... | def _perform_async_update_rule(context, id, db_sg_group, rule_id, action):
"""Updates a SG rule async and return the job information.
Only happens if the security group has associated ports. If the async
connection fails the update continues (legacy mode).
"""
rpc_reply = None
sg_rpc = sg_rpc_a... | [
"Updates",
"a",
"SG",
"rule",
"async",
"and",
"return",
"the",
"job",
"information",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/security_groups.py#L176-L191 | [
"def",
"_perform_async_update_rule",
"(",
"context",
",",
"id",
",",
"db_sg_group",
",",
"rule_id",
",",
"action",
")",
":",
"rpc_reply",
"=",
"None",
"sg_rpc",
"=",
"sg_rpc_api",
".",
"QuarkSGAsyncProcessClient",
"(",
")",
"ports",
"=",
"db_api",
".",
"sg_gat... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | create_security_group_rule | Creates a rule and updates the ports (async) if enabled. | quark/plugin_modules/security_groups.py | def create_security_group_rule(context, security_group_rule):
"""Creates a rule and updates the ports (async) if enabled."""
LOG.info("create_security_group for tenant %s" %
(context.tenant_id))
with context.session.begin():
rule = _validate_security_group_rule(
context, sec... | def create_security_group_rule(context, security_group_rule):
"""Creates a rule and updates the ports (async) if enabled."""
LOG.info("create_security_group for tenant %s" %
(context.tenant_id))
with context.session.begin():
rule = _validate_security_group_rule(
context, sec... | [
"Creates",
"a",
"rule",
"and",
"updates",
"the",
"ports",
"(",
"async",
")",
"if",
"enabled",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/security_groups.py#L194-L217 | [
"def",
"create_security_group_rule",
"(",
"context",
",",
"security_group_rule",
")",
":",
"LOG",
".",
"info",
"(",
"\"create_security_group for tenant %s\"",
"%",
"(",
"context",
".",
"tenant_id",
")",
")",
"with",
"context",
".",
"session",
".",
"begin",
"(",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | update_security_group_rule | Updates a rule and updates the ports | quark/plugin_modules/security_groups.py | def update_security_group_rule(context, id, security_group_rule):
'''Updates a rule and updates the ports'''
LOG.info("update_security_group_rule for tenant %s" %
(context.tenant_id))
new_rule = security_group_rule["security_group_rule"]
# Only allow updatable fields
new_rule = _filter_... | def update_security_group_rule(context, id, security_group_rule):
'''Updates a rule and updates the ports'''
LOG.info("update_security_group_rule for tenant %s" %
(context.tenant_id))
new_rule = security_group_rule["security_group_rule"]
# Only allow updatable fields
new_rule = _filter_... | [
"Updates",
"a",
"rule",
"and",
"updates",
"the",
"ports"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/security_groups.py#L220-L246 | [
"def",
"update_security_group_rule",
"(",
"context",
",",
"id",
",",
"security_group_rule",
")",
":",
"LOG",
".",
"info",
"(",
"\"update_security_group_rule for tenant %s\"",
"%",
"(",
"context",
".",
"tenant_id",
")",
")",
"new_rule",
"=",
"security_group_rule",
"[... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | delete_security_group_rule | Deletes a rule and updates the ports (async) if enabled. | quark/plugin_modules/security_groups.py | def delete_security_group_rule(context, id):
"""Deletes a rule and updates the ports (async) if enabled."""
LOG.info("delete_security_group %s for tenant %s" %
(id, context.tenant_id))
with context.session.begin():
rule = db_api.security_group_rule_find(context, id=id,
... | def delete_security_group_rule(context, id):
"""Deletes a rule and updates the ports (async) if enabled."""
LOG.info("delete_security_group %s for tenant %s" %
(id, context.tenant_id))
with context.session.begin():
rule = db_api.security_group_rule_find(context, id=id,
... | [
"Deletes",
"a",
"rule",
"and",
"updates",
"the",
"ports",
"(",
"async",
")",
"if",
"enabled",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/security_groups.py#L259-L277 | [
"def",
"delete_security_group_rule",
"(",
"context",
",",
"id",
")",
":",
"LOG",
".",
"info",
"(",
"\"delete_security_group %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"with",
"context",
".",
"session",
".",
"begin",
"(",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_data | Returns combined list of tuples: [(table, column)].
List is built, based on retrieved tables, where column with name
``tenant_id`` exists. | quark/db/migration/alembic/versions/79b768afed65_rename_tenant_id_indexes.py | def get_data():
"""Returns combined list of tuples: [(table, column)].
List is built, based on retrieved tables, where column with name
``tenant_id`` exists.
"""
output = []
tables = get_tables()
for table in tables:
try:
columns = get_columns(table)
except sa.e... | def get_data():
"""Returns combined list of tuples: [(table, column)].
List is built, based on retrieved tables, where column with name
``tenant_id`` exists.
"""
output = []
tables = get_tables()
for table in tables:
try:
columns = get_columns(table)
except sa.e... | [
"Returns",
"combined",
"list",
"of",
"tuples",
":",
"[",
"(",
"table",
"column",
")",
"]",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/db/migration/alembic/versions/79b768afed65_rename_tenant_id_indexes.py#L93-L112 | [
"def",
"get_data",
"(",
")",
":",
"output",
"=",
"[",
"]",
"tables",
"=",
"get_tables",
"(",
")",
"for",
"table",
"in",
"tables",
":",
"try",
":",
"columns",
"=",
"get_columns",
"(",
"table",
")",
"except",
"sa",
".",
"exc",
".",
"NoSuchTableError",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | JSONStrategy.get_public_net_id | Returns the public net id | quark/network_strategy.py | def get_public_net_id(self):
"""Returns the public net id"""
for id, net_params in self.strategy.iteritems():
if id == CONF.QUARK.public_net_id:
return id
return None | def get_public_net_id(self):
"""Returns the public net id"""
for id, net_params in self.strategy.iteritems():
if id == CONF.QUARK.public_net_id:
return id
return None | [
"Returns",
"the",
"public",
"net",
"id"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/network_strategy.py#L104-L109 | [
"def",
"get_public_net_id",
"(",
"self",
")",
":",
"for",
"id",
",",
"net_params",
"in",
"self",
".",
"strategy",
".",
"iteritems",
"(",
")",
":",
"if",
"id",
"==",
"CONF",
".",
"QUARK",
".",
"public_net_id",
":",
"return",
"id",
"return",
"None"
] | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | opt_args_decorator | A decorator to be used on another decorator
This is done to allow separate handling on the basis of argument values | quark/utils.py | def opt_args_decorator(func):
"""A decorator to be used on another decorator
This is done to allow separate handling on the basis of argument values
"""
@wraps(func)
def wrapped_dec(*args, **kwargs):
if len(args) == 1 and len(kwargs) == 0 and callable(args[0]):
# actual decorate... | def opt_args_decorator(func):
"""A decorator to be used on another decorator
This is done to allow separate handling on the basis of argument values
"""
@wraps(func)
def wrapped_dec(*args, **kwargs):
if len(args) == 1 and len(kwargs) == 0 and callable(args[0]):
# actual decorate... | [
"A",
"decorator",
"to",
"be",
"used",
"on",
"another",
"decorator"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/utils.py#L82-L96 | [
"def",
"opt_args_decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped_dec",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"len",
"(",
"kwargs",
")",
"==",
"0",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Plugin._fix_missing_tenant_id | Will add the tenant_id to the context from body.
It is assumed that the body must have a tenant_id because neutron
core could never have gotten here otherwise. | quark/plugin.py | def _fix_missing_tenant_id(self, context, body, key):
"""Will add the tenant_id to the context from body.
It is assumed that the body must have a tenant_id because neutron
core could never have gotten here otherwise.
"""
if not body:
raise n_exc.BadRequest(resource=k... | def _fix_missing_tenant_id(self, context, body, key):
"""Will add the tenant_id to the context from body.
It is assumed that the body must have a tenant_id because neutron
core could never have gotten here otherwise.
"""
if not body:
raise n_exc.BadRequest(resource=k... | [
"Will",
"add",
"the",
"tenant_id",
"to",
"the",
"context",
"from",
"body",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin.py#L143-L161 | [
"def",
"_fix_missing_tenant_id",
"(",
"self",
",",
"context",
",",
"body",
",",
"key",
")",
":",
"if",
"not",
"body",
":",
"raise",
"n_exc",
".",
"BadRequest",
"(",
"resource",
"=",
"key",
",",
"msg",
"=",
"\"Body malformed\"",
")",
"resource",
"=",
"bod... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | AllocationPools._validate_allocation_pools | Validate IP allocation pools.
Verify start and end address for each allocation pool are valid,
ie: constituted by valid and appropriately ordered IP addresses.
Also, verify pools do not overlap among themselves.
Finally, verify that each range fall within the subnet's CIDR. | quark/allocation_pool.py | def _validate_allocation_pools(self):
"""Validate IP allocation pools.
Verify start and end address for each allocation pool are valid,
ie: constituted by valid and appropriately ordered IP addresses.
Also, verify pools do not overlap among themselves.
Finally, verify that each ... | def _validate_allocation_pools(self):
"""Validate IP allocation pools.
Verify start and end address for each allocation pool are valid,
ie: constituted by valid and appropriately ordered IP addresses.
Also, verify pools do not overlap among themselves.
Finally, verify that each ... | [
"Validate",
"IP",
"allocation",
"pools",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/allocation_pool.py#L47-L112 | [
"def",
"_validate_allocation_pools",
"(",
"self",
")",
":",
"ip_pools",
"=",
"self",
".",
"_alloc_pools",
"subnet_cidr",
"=",
"self",
".",
"_subnet_cidr",
"LOG",
".",
"debug",
"(",
"_",
"(",
"\"Performing IP validity checks on allocation pools\"",
")",
")",
"ip_sets... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | add_job_to_context | Adds job to neutron context for use later. | quark/plugin_modules/jobs.py | def add_job_to_context(context, job_id):
"""Adds job to neutron context for use later."""
db_job = db_api.async_transaction_find(
context, id=job_id, scope=db_api.ONE)
if not db_job:
return
context.async_job = {"job": v._make_job_dict(db_job)} | def add_job_to_context(context, job_id):
"""Adds job to neutron context for use later."""
db_job = db_api.async_transaction_find(
context, id=job_id, scope=db_api.ONE)
if not db_job:
return
context.async_job = {"job": v._make_job_dict(db_job)} | [
"Adds",
"job",
"to",
"neutron",
"context",
"for",
"use",
"later",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/jobs.py#L28-L34 | [
"def",
"add_job_to_context",
"(",
"context",
",",
"job_id",
")",
":",
"db_job",
"=",
"db_api",
".",
"async_transaction_find",
"(",
"context",
",",
"id",
"=",
"job_id",
",",
"scope",
"=",
"db_api",
".",
"ONE",
")",
"if",
"not",
"db_job",
":",
"return",
"c... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | create_job | Creates a job with support for subjobs.
If parent_id is not in the body:
* the job is considered a parent job
* it will have a NULL transaction id
* its transaction id == its id
* all subjobs will use its transaction id as theirs
Else:
* the job is a sub job
* the parent id is the id p... | quark/plugin_modules/jobs.py | def create_job(context, body):
"""Creates a job with support for subjobs.
If parent_id is not in the body:
* the job is considered a parent job
* it will have a NULL transaction id
* its transaction id == its id
* all subjobs will use its transaction id as theirs
Else:
* the job is a s... | def create_job(context, body):
"""Creates a job with support for subjobs.
If parent_id is not in the body:
* the job is considered a parent job
* it will have a NULL transaction id
* its transaction id == its id
* all subjobs will use its transaction id as theirs
Else:
* the job is a s... | [
"Creates",
"a",
"job",
"with",
"support",
"for",
"subjobs",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/jobs.py#L55-L91 | [
"def",
"create_job",
"(",
"context",
",",
"body",
")",
":",
"LOG",
".",
"info",
"(",
"\"create_job for tenant %s\"",
"%",
"context",
".",
"tenant_id",
")",
"if",
"not",
"context",
".",
"is_admin",
":",
"raise",
"n_exc",
".",
"NotAuthorized",
"(",
")",
"job... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | delete_job | Delete an ip address.
: param context: neutron api request context
: param id: UUID representing the ip address to delete. | quark/plugin_modules/jobs.py | def delete_job(context, id, **filters):
"""Delete an ip address.
: param context: neutron api request context
: param id: UUID representing the ip address to delete.
"""
LOG.info("delete_ip_address %s for tenant %s" % (id, context.tenant_id))
if not context.is_admin:
raise n_exc.NotAut... | def delete_job(context, id, **filters):
"""Delete an ip address.
: param context: neutron api request context
: param id: UUID representing the ip address to delete.
"""
LOG.info("delete_ip_address %s for tenant %s" % (id, context.tenant_id))
if not context.is_admin:
raise n_exc.NotAut... | [
"Delete",
"an",
"ip",
"address",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/jobs.py#L109-L124 | [
"def",
"delete_job",
"(",
"context",
",",
"id",
",",
"*",
"*",
"filters",
")",
":",
"LOG",
".",
"info",
"(",
"\"delete_ip_address %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"if",
"not",
"context",
".",
"is_admin",
":... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Ip_policies.get_resources | Returns Ext Resources. | quark/api/extensions/ip_policies.py | def get_resources(cls):
"""Returns Ext Resources."""
plugin = directory.get_plugin()
controller = IPPoliciesController(plugin)
return [extensions.ResourceExtension(Ip_policies.get_alias(),
controller)] | def get_resources(cls):
"""Returns Ext Resources."""
plugin = directory.get_plugin()
controller = IPPoliciesController(plugin)
return [extensions.ResourceExtension(Ip_policies.get_alias(),
controller)] | [
"Returns",
"Ext",
"Resources",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/api/extensions/ip_policies.py#L102-L107 | [
"def",
"get_resources",
"(",
"cls",
")",
":",
"plugin",
"=",
"directory",
".",
"get_plugin",
"(",
")",
"controller",
"=",
"IPPoliciesController",
"(",
"plugin",
")",
"return",
"[",
"extensions",
".",
"ResourceExtension",
"(",
"Ip_policies",
".",
"get_alias",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | NVPDriver._lswitch_select_open | Selects an open lswitch for a network.
Note that it does not select the most full switch, but merely one with
ports available. | quark/drivers/nvp_driver.py | def _lswitch_select_open(self, context, switches=None, **kwargs):
"""Selects an open lswitch for a network.
Note that it does not select the most full switch, but merely one with
ports available.
"""
if switches is not None:
for res in switches["results"]:
... | def _lswitch_select_open(self, context, switches=None, **kwargs):
"""Selects an open lswitch for a network.
Note that it does not select the most full switch, but merely one with
ports available.
"""
if switches is not None:
for res in switches["results"]:
... | [
"Selects",
"an",
"open",
"lswitch",
"for",
"a",
"network",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/nvp_driver.py#L587-L600 | [
"def",
"_lswitch_select_open",
"(",
"self",
",",
"context",
",",
"switches",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"switches",
"is",
"not",
"None",
":",
"for",
"res",
"in",
"switches",
"[",
"\"results\"",
"]",
":",
"count",
"=",
"res",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | NVPDriver._add_default_tz_bindings | Configure any additional default transport zone bindings. | quark/drivers/nvp_driver.py | def _add_default_tz_bindings(self, context, switch, network_id):
"""Configure any additional default transport zone bindings."""
default_tz = CONF.NVP.default_tz
# If there is no default tz specified it's pointless to try
# and add any additional default tz bindings.
if not defa... | def _add_default_tz_bindings(self, context, switch, network_id):
"""Configure any additional default transport zone bindings."""
default_tz = CONF.NVP.default_tz
# If there is no default tz specified it's pointless to try
# and add any additional default tz bindings.
if not defa... | [
"Configure",
"any",
"additional",
"default",
"transport",
"zone",
"bindings",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/nvp_driver.py#L636-L660 | [
"def",
"_add_default_tz_bindings",
"(",
"self",
",",
"context",
",",
"switch",
",",
"network_id",
")",
":",
"default_tz",
"=",
"CONF",
".",
"NVP",
".",
"default_tz",
"# If there is no default tz specified it's pointless to try",
"# and add any additional default tz bindings."... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | NVPDriver._remove_default_tz_bindings | Deconfigure any additional default transport zone bindings. | quark/drivers/nvp_driver.py | def _remove_default_tz_bindings(self, context, network_id):
"""Deconfigure any additional default transport zone bindings."""
default_tz = CONF.NVP.default_tz
if not default_tz:
LOG.warn("additional_default_tz_types specified, "
"but no default_tz. Skipping "
... | def _remove_default_tz_bindings(self, context, network_id):
"""Deconfigure any additional default transport zone bindings."""
default_tz = CONF.NVP.default_tz
if not default_tz:
LOG.warn("additional_default_tz_types specified, "
"but no default_tz. Skipping "
... | [
"Deconfigure",
"any",
"additional",
"default",
"transport",
"zone",
"bindings",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/nvp_driver.py#L662-L682 | [
"def",
"_remove_default_tz_bindings",
"(",
"self",
",",
"context",
",",
"network_id",
")",
":",
"default_tz",
"=",
"CONF",
".",
"NVP",
".",
"default_tz",
"if",
"not",
"default_tz",
":",
"LOG",
".",
"warn",
"(",
"\"additional_default_tz_types specified, \"",
"\"but... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | NVPDriver.get_lswitch_ids_for_network | Public interface for fetching lswitch ids for a given network.
NOTE(morgabra) This is here because calling private methods
from outside the class feels wrong, and we need to be able to
fetch lswitch ids for use in other drivers. | quark/drivers/nvp_driver.py | def get_lswitch_ids_for_network(self, context, network_id):
"""Public interface for fetching lswitch ids for a given network.
NOTE(morgabra) This is here because calling private methods
from outside the class feels wrong, and we need to be able to
fetch lswitch ids for use in other driv... | def get_lswitch_ids_for_network(self, context, network_id):
"""Public interface for fetching lswitch ids for a given network.
NOTE(morgabra) This is here because calling private methods
from outside the class feels wrong, and we need to be able to
fetch lswitch ids for use in other driv... | [
"Public",
"interface",
"for",
"fetching",
"lswitch",
"ids",
"for",
"a",
"given",
"network",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/nvp_driver.py#L740-L748 | [
"def",
"get_lswitch_ids_for_network",
"(",
"self",
",",
"context",
",",
"network_id",
")",
":",
"lswitches",
"=",
"self",
".",
"_lswitches_for_network",
"(",
"context",
",",
"network_id",
")",
".",
"results",
"(",
")",
"return",
"[",
"s",
"[",
"'uuid'",
"]",... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | UnicornDriver.register_floating_ip | Register a floating ip with Unicorn
:param floating_ip: The quark.db.models.IPAddress to register
:param port_fixed_ips: A dictionary containing the port and fixed ips
to associate the floating IP with. Has the structure of:
{"<id of port>": {"port": <quark.db.models.Port>,
"f... | quark/drivers/unicorn_driver.py | def register_floating_ip(self, floating_ip, port_fixed_ips):
"""Register a floating ip with Unicorn
:param floating_ip: The quark.db.models.IPAddress to register
:param port_fixed_ips: A dictionary containing the port and fixed ips
to associate the floating IP with. Has the structure o... | def register_floating_ip(self, floating_ip, port_fixed_ips):
"""Register a floating ip with Unicorn
:param floating_ip: The quark.db.models.IPAddress to register
:param port_fixed_ips: A dictionary containing the port and fixed ips
to associate the floating IP with. Has the structure o... | [
"Register",
"a",
"floating",
"ip",
"with",
"Unicorn"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/unicorn_driver.py#L54-L82 | [
"def",
"register_floating_ip",
"(",
"self",
",",
"floating_ip",
",",
"port_fixed_ips",
")",
":",
"url",
"=",
"CONF",
".",
"QUARK",
".",
"floating_ip_base_url",
"timeout",
"=",
"CONF",
".",
"QUARK",
".",
"unicorn_api_timeout_seconds",
"req",
"=",
"self",
".",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | UnicornDriver.remove_floating_ip | Register a floating ip with Unicorn
:param floating_ip: The quark.db.models.IPAddress to remove
:return: None | quark/drivers/unicorn_driver.py | def remove_floating_ip(self, floating_ip):
"""Register a floating ip with Unicorn
:param floating_ip: The quark.db.models.IPAddress to remove
:return: None
"""
url = "%s/%s" % (CONF.QUARK.floating_ip_base_url,
floating_ip.address_readable)
timeou... | def remove_floating_ip(self, floating_ip):
"""Register a floating ip with Unicorn
:param floating_ip: The quark.db.models.IPAddress to remove
:return: None
"""
url = "%s/%s" % (CONF.QUARK.floating_ip_base_url,
floating_ip.address_readable)
timeou... | [
"Register",
"a",
"floating",
"ip",
"with",
"Unicorn"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/unicorn_driver.py#L115-L141 | [
"def",
"remove_floating_ip",
"(",
"self",
",",
"floating_ip",
")",
":",
"url",
"=",
"\"%s/%s\"",
"%",
"(",
"CONF",
".",
"QUARK",
".",
"floating_ip_base_url",
",",
"floating_ip",
".",
"address_readable",
")",
"timeout",
"=",
"CONF",
".",
"QUARK",
".",
"unicor... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkAsyncServer._load_worker_plugin_with_module | Instantiates worker plugins that have requsite properties.
The required properties are:
* must have PLUGIN_EP entrypoint registered (or it wouldn't be in the
list)
* must have class attribute versions (list) of supported RPC versions
* must subclass QuarkAsyncPluginBase | quark/tools/async_worker.py | def _load_worker_plugin_with_module(self, module, version):
"""Instantiates worker plugins that have requsite properties.
The required properties are:
* must have PLUGIN_EP entrypoint registered (or it wouldn't be in the
list)
* must have class attribute versions (list) of sup... | def _load_worker_plugin_with_module(self, module, version):
"""Instantiates worker plugins that have requsite properties.
The required properties are:
* must have PLUGIN_EP entrypoint registered (or it wouldn't be in the
list)
* must have class attribute versions (list) of sup... | [
"Instantiates",
"worker",
"plugins",
"that",
"have",
"requsite",
"properties",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tools/async_worker.py#L64-L87 | [
"def",
"_load_worker_plugin_with_module",
"(",
"self",
",",
"module",
",",
"version",
")",
":",
"classes",
"=",
"inspect",
".",
"getmembers",
"(",
"module",
",",
"inspect",
".",
"isclass",
")",
"loaded",
"=",
"0",
"for",
"cls_name",
",",
"cls",
"in",
"clas... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkAsyncServer._discover_via_entrypoints | Looks for modules with amtching entry points. | quark/tools/async_worker.py | def _discover_via_entrypoints(self):
"""Looks for modules with amtching entry points."""
emgr = extension.ExtensionManager(PLUGIN_EP, invoke_on_load=False)
return ((ext.name, ext.plugin) for ext in emgr) | def _discover_via_entrypoints(self):
"""Looks for modules with amtching entry points."""
emgr = extension.ExtensionManager(PLUGIN_EP, invoke_on_load=False)
return ((ext.name, ext.plugin) for ext in emgr) | [
"Looks",
"for",
"modules",
"with",
"amtching",
"entry",
"points",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tools/async_worker.py#L89-L92 | [
"def",
"_discover_via_entrypoints",
"(",
"self",
")",
":",
"emgr",
"=",
"extension",
".",
"ExtensionManager",
"(",
"PLUGIN_EP",
",",
"invoke_on_load",
"=",
"False",
")",
"return",
"(",
"(",
"ext",
".",
"name",
",",
"ext",
".",
"plugin",
")",
"for",
"ext",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkAsyncServer.serve_rpc | Launches configured # of workers per loaded plugin. | quark/tools/async_worker.py | def serve_rpc(self):
"""Launches configured # of workers per loaded plugin."""
if cfg.CONF.QUARK_ASYNC.rpc_workers < 1:
cfg.CONF.set_override('rpc_workers', 1, "QUARK_ASYNC")
try:
rpc = service.RpcWorker(self.plugins)
launcher = common_service.ProcessLauncher... | def serve_rpc(self):
"""Launches configured # of workers per loaded plugin."""
if cfg.CONF.QUARK_ASYNC.rpc_workers < 1:
cfg.CONF.set_override('rpc_workers', 1, "QUARK_ASYNC")
try:
rpc = service.RpcWorker(self.plugins)
launcher = common_service.ProcessLauncher... | [
"Launches",
"configured",
"#",
"of",
"workers",
"per",
"loaded",
"plugin",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tools/async_worker.py#L99-L113 | [
"def",
"serve_rpc",
"(",
"self",
")",
":",
"if",
"cfg",
".",
"CONF",
".",
"QUARK_ASYNC",
".",
"rpc_workers",
"<",
"1",
":",
"cfg",
".",
"CONF",
".",
"set_override",
"(",
"'rpc_workers'",
",",
"1",
",",
"\"QUARK_ASYNC\"",
")",
"try",
":",
"rpc",
"=",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkAsyncServer.start_api_and_rpc_workers | Initializes eventlet and starts wait for workers to exit.
Spawns the workers returned from serve_rpc | quark/tools/async_worker.py | def start_api_and_rpc_workers(self):
"""Initializes eventlet and starts wait for workers to exit.
Spawns the workers returned from serve_rpc
"""
pool = eventlet.GreenPool()
quark_rpc = self.serve_rpc()
pool.spawn(quark_rpc.wait)
pool.waitall() | def start_api_and_rpc_workers(self):
"""Initializes eventlet and starts wait for workers to exit.
Spawns the workers returned from serve_rpc
"""
pool = eventlet.GreenPool()
quark_rpc = self.serve_rpc()
pool.spawn(quark_rpc.wait)
pool.waitall() | [
"Initializes",
"eventlet",
"and",
"starts",
"wait",
"for",
"workers",
"to",
"exit",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tools/async_worker.py#L115-L125 | [
"def",
"start_api_and_rpc_workers",
"(",
"self",
")",
":",
"pool",
"=",
"eventlet",
".",
"GreenPool",
"(",
")",
"quark_rpc",
"=",
"self",
".",
"serve_rpc",
"(",
")",
"pool",
".",
"spawn",
"(",
"quark_rpc",
".",
"wait",
")",
"pool",
".",
"waitall",
"(",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Scalingip.get_resources | Returns Ext Resources. | quark/api/extensions/scalingip.py | def get_resources(cls):
"""Returns Ext Resources."""
plural_mappings = resource_helper.build_plural_mappings(
{}, RESOURCE_ATTRIBUTE_MAP)
# attr.PLURALS.update(plural_mappings)
return resource_helper.build_resource_info(plural_mappings,
... | def get_resources(cls):
"""Returns Ext Resources."""
plural_mappings = resource_helper.build_plural_mappings(
{}, RESOURCE_ATTRIBUTE_MAP)
# attr.PLURALS.update(plural_mappings)
return resource_helper.build_resource_info(plural_mappings,
... | [
"Returns",
"Ext",
"Resources",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/api/extensions/scalingip.py#L127-L135 | [
"def",
"get_resources",
"(",
"cls",
")",
":",
"plural_mappings",
"=",
"resource_helper",
".",
"build_plural_mappings",
"(",
"{",
"}",
",",
"RESOURCE_ATTRIBUTE_MAP",
")",
"# attr.PLURALS.update(plural_mappings)",
"return",
"resource_helper",
".",
"build_resource_info",
"("... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | BaseSegmentAllocation._chunks | Chunks data into chunk with size<=chunk_size. | quark/segment_allocations.py | def _chunks(self, iterable, chunk_size):
"""Chunks data into chunk with size<=chunk_size."""
iterator = iter(iterable)
chunk = list(itertools.islice(iterator, 0, chunk_size))
while chunk:
yield chunk
chunk = list(itertools.islice(iterator, 0, chunk_size)) | def _chunks(self, iterable, chunk_size):
"""Chunks data into chunk with size<=chunk_size."""
iterator = iter(iterable)
chunk = list(itertools.islice(iterator, 0, chunk_size))
while chunk:
yield chunk
chunk = list(itertools.islice(iterator, 0, chunk_size)) | [
"Chunks",
"data",
"into",
"chunk",
"with",
"size<",
"=",
"chunk_size",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/segment_allocations.py#L38-L44 | [
"def",
"_chunks",
"(",
"self",
",",
"iterable",
",",
"chunk_size",
")",
":",
"iterator",
"=",
"iter",
"(",
"iterable",
")",
"chunk",
"=",
"list",
"(",
"itertools",
".",
"islice",
"(",
"iterator",
",",
"0",
",",
"chunk_size",
")",
")",
"while",
"chunk",... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | BaseSegmentAllocation._check_collisions | Check for overlapping ranges. | quark/segment_allocations.py | def _check_collisions(self, new_range, existing_ranges):
"""Check for overlapping ranges."""
def _contains(num, r1):
return (num >= r1[0] and
num <= r1[1])
def _is_overlap(r1, r2):
return (_contains(r1[0], r2) or
_contains(r1[1], r... | def _check_collisions(self, new_range, existing_ranges):
"""Check for overlapping ranges."""
def _contains(num, r1):
return (num >= r1[0] and
num <= r1[1])
def _is_overlap(r1, r2):
return (_contains(r1[0], r2) or
_contains(r1[1], r... | [
"Check",
"for",
"overlapping",
"ranges",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/segment_allocations.py#L46-L61 | [
"def",
"_check_collisions",
"(",
"self",
",",
"new_range",
",",
"existing_ranges",
")",
":",
"def",
"_contains",
"(",
"num",
",",
"r1",
")",
":",
"return",
"(",
"num",
">=",
"r1",
"[",
"0",
"]",
"and",
"num",
"<=",
"r1",
"[",
"1",
"]",
")",
"def",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | BaseSegmentAllocation._try_allocate | Find a deallocated network segment id and reallocate it.
NOTE(morgabra) This locks the segment table, but only the rows
in use by the segment, which is pretty handy if we ever have
more than 1 segment or segment type. | quark/segment_allocations.py | def _try_allocate(self, context, segment_id, network_id):
"""Find a deallocated network segment id and reallocate it.
NOTE(morgabra) This locks the segment table, but only the rows
in use by the segment, which is pretty handy if we ever have
more than 1 segment or segment type.
... | def _try_allocate(self, context, segment_id, network_id):
"""Find a deallocated network segment id and reallocate it.
NOTE(morgabra) This locks the segment table, but only the rows
in use by the segment, which is pretty handy if we ever have
more than 1 segment or segment type.
... | [
"Find",
"a",
"deallocated",
"network",
"segment",
"id",
"and",
"reallocate",
"it",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/segment_allocations.py#L131-L196 | [
"def",
"_try_allocate",
"(",
"self",
",",
"context",
",",
"segment_id",
",",
"network_id",
")",
":",
"LOG",
".",
"info",
"(",
"\"Attempting to allocate segment for network %s \"",
"\"segment_id %s segment_type %s\"",
"%",
"(",
"network_id",
",",
"segment_id",
",",
"se... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | delete_locks | Deletes locks for each IP address that is no longer null-routed. | quark/tools/null_routes.py | def delete_locks(context, network_ids, addresses):
"""Deletes locks for each IP address that is no longer null-routed."""
addresses_no_longer_null_routed = _find_addresses_to_be_unlocked(
context, network_ids, addresses)
LOG.info("Deleting %s lock holders on IPAddress with ids: %s",
len... | def delete_locks(context, network_ids, addresses):
"""Deletes locks for each IP address that is no longer null-routed."""
addresses_no_longer_null_routed = _find_addresses_to_be_unlocked(
context, network_ids, addresses)
LOG.info("Deleting %s lock holders on IPAddress with ids: %s",
len... | [
"Deletes",
"locks",
"for",
"each",
"IP",
"address",
"that",
"is",
"no",
"longer",
"null",
"-",
"routed",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tools/null_routes.py#L117-L136 | [
"def",
"delete_locks",
"(",
"context",
",",
"network_ids",
",",
"addresses",
")",
":",
"addresses_no_longer_null_routed",
"=",
"_find_addresses_to_be_unlocked",
"(",
"context",
",",
"network_ids",
",",
"addresses",
")",
"LOG",
".",
"info",
"(",
"\"Deleting %s lock hol... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | create_locks | Creates locks for each IP address that is null-routed.
The function creates the IP address if it is not present in the database. | quark/tools/null_routes.py | def create_locks(context, network_ids, addresses):
"""Creates locks for each IP address that is null-routed.
The function creates the IP address if it is not present in the database.
"""
for address in addresses:
address_model = None
try:
address_model = _find_or_create_ad... | def create_locks(context, network_ids, addresses):
"""Creates locks for each IP address that is null-routed.
The function creates the IP address if it is not present in the database.
"""
for address in addresses:
address_model = None
try:
address_model = _find_or_create_ad... | [
"Creates",
"locks",
"for",
"each",
"IP",
"address",
"that",
"is",
"null",
"-",
"routed",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tools/null_routes.py#L162-L191 | [
"def",
"create_locks",
"(",
"context",
",",
"network_ids",
",",
"addresses",
")",
":",
"for",
"address",
"in",
"addresses",
":",
"address_model",
"=",
"None",
"try",
":",
"address_model",
"=",
"_find_or_create_address",
"(",
"context",
",",
"network_ids",
",",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | IronicDriver.select_ipam_strategy | Return relevant IPAM strategy name.
:param network_id: neutron network id.
:param network_strategy: default strategy for the network.
NOTE(morgabra) This feels like a hack but I can't think of a better
idea. The root problem is we can now attach ports to networks with
a differe... | quark/drivers/ironic_driver.py | def select_ipam_strategy(self, network_id, network_strategy, **kwargs):
"""Return relevant IPAM strategy name.
:param network_id: neutron network id.
:param network_strategy: default strategy for the network.
NOTE(morgabra) This feels like a hack but I can't think of a better
i... | def select_ipam_strategy(self, network_id, network_strategy, **kwargs):
"""Return relevant IPAM strategy name.
:param network_id: neutron network id.
:param network_strategy: default strategy for the network.
NOTE(morgabra) This feels like a hack but I can't think of a better
i... | [
"Return",
"relevant",
"IPAM",
"strategy",
"name",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/ironic_driver.py#L165-L211 | [
"def",
"select_ipam_strategy",
"(",
"self",
",",
"network_id",
",",
"network_strategy",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"info",
"(",
"\"Selecting IPAM strategy for network_id:%s \"",
"\"network_strategy:%s\"",
"%",
"(",
"network_id",
",",
"network_strat... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | IronicDriver._get_base_network_info | Return a dict of extra network information.
:param context: neutron request context.
:param network_id: neturon network id.
:param net_driver: network driver associated with network_id.
:raises IronicException: Any unexpected data fetching failures will
be logged and IronicE... | quark/drivers/ironic_driver.py | def _get_base_network_info(self, context, network_id, base_net_driver):
"""Return a dict of extra network information.
:param context: neutron request context.
:param network_id: neturon network id.
:param net_driver: network driver associated with network_id.
:raises IronicExce... | def _get_base_network_info(self, context, network_id, base_net_driver):
"""Return a dict of extra network information.
:param context: neutron request context.
:param network_id: neturon network id.
:param net_driver: network driver associated with network_id.
:raises IronicExce... | [
"Return",
"a",
"dict",
"of",
"extra",
"network",
"information",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/ironic_driver.py#L248-L288 | [
"def",
"_get_base_network_info",
"(",
"self",
",",
"context",
",",
"network_id",
",",
"base_net_driver",
")",
":",
"driver_name",
"=",
"base_net_driver",
".",
"get_name",
"(",
")",
"net_info",
"=",
"{",
"\"network_type\"",
":",
"driver_name",
"}",
"LOG",
".",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | IronicDriver.create_port | Create a port.
:param context: neutron api request context.
:param network_id: neutron network id.
:param port_id: neutron port id.
:param kwargs:
required keys - device_id: neutron port device_id (instance_id)
instance_node_id: nova hypervisor ho... | quark/drivers/ironic_driver.py | def create_port(self, context, network_id, port_id, **kwargs):
"""Create a port.
:param context: neutron api request context.
:param network_id: neutron network id.
:param port_id: neutron port id.
:param kwargs:
required keys - device_id: neutron port device_id (ins... | def create_port(self, context, network_id, port_id, **kwargs):
"""Create a port.
:param context: neutron api request context.
:param network_id: neutron network id.
:param port_id: neutron port id.
:param kwargs:
required keys - device_id: neutron port device_id (ins... | [
"Create",
"a",
"port",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/ironic_driver.py#L290-L367 | [
"def",
"create_port",
"(",
"self",
",",
"context",
",",
"network_id",
",",
"port_id",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"info",
"(",
"\"create_port %s %s %s\"",
"%",
"(",
"context",
".",
"tenant_id",
",",
"network_id",
",",
"port_id",
")",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | IronicDriver.update_port | Update a port.
:param context: neutron api request context.
:param port_id: neutron port id.
:param kwargs: optional kwargs.
:raises IronicException: If the client is unable to update the
downstream port for any reason, the exception will be logged
and IronicExce... | quark/drivers/ironic_driver.py | def update_port(self, context, port_id, **kwargs):
"""Update a port.
:param context: neutron api request context.
:param port_id: neutron port id.
:param kwargs: optional kwargs.
:raises IronicException: If the client is unable to update the
downstream port for any r... | def update_port(self, context, port_id, **kwargs):
"""Update a port.
:param context: neutron api request context.
:param port_id: neutron port id.
:param kwargs: optional kwargs.
:raises IronicException: If the client is unable to update the
downstream port for any r... | [
"Update",
"a",
"port",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/ironic_driver.py#L369-L393 | [
"def",
"update_port",
"(",
"self",
",",
"context",
",",
"port_id",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"info",
"(",
"\"update_port %s %s\"",
"%",
"(",
"context",
".",
"tenant_id",
",",
"port_id",
")",
")",
"# TODO(morgabra): Change this when we enab... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | IronicDriver.delete_port | Delete a port.
:param context: neutron api request context.
:param port_id: neutron port id.
:param kwargs: optional kwargs.
:raises IronicException: If the client is unable to delete the
downstream port for any reason, the exception will be logged
and IronicExce... | quark/drivers/ironic_driver.py | def delete_port(self, context, port_id, **kwargs):
"""Delete a port.
:param context: neutron api request context.
:param port_id: neutron port id.
:param kwargs: optional kwargs.
:raises IronicException: If the client is unable to delete the
downstream port for any r... | def delete_port(self, context, port_id, **kwargs):
"""Delete a port.
:param context: neutron api request context.
:param port_id: neutron port id.
:param kwargs: optional kwargs.
:raises IronicException: If the client is unable to delete the
downstream port for any r... | [
"Delete",
"a",
"port",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/ironic_driver.py#L413-L429 | [
"def",
"delete_port",
"(",
"self",
",",
"context",
",",
"port_id",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"info",
"(",
"\"delete_port %s %s\"",
"%",
"(",
"context",
".",
"tenant_id",
",",
"port_id",
")",
")",
"try",
":",
"self",
".",
"_delete_p... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | IronicDriver.diag_port | Diagnose a port.
:param context: neutron api request context.
:param port_id: neutron port id.
:param kwargs: optional kwargs.
:raises IronicException: If the client is unable to fetch the
downstream port for any reason, the exception will be
logged and IronicExc... | quark/drivers/ironic_driver.py | def diag_port(self, context, port_id, **kwargs):
"""Diagnose a port.
:param context: neutron api request context.
:param port_id: neutron port id.
:param kwargs: optional kwargs.
:raises IronicException: If the client is unable to fetch the
downstream port for any re... | def diag_port(self, context, port_id, **kwargs):
"""Diagnose a port.
:param context: neutron api request context.
:param port_id: neutron port id.
:param kwargs: optional kwargs.
:raises IronicException: If the client is unable to fetch the
downstream port for any re... | [
"Diagnose",
"a",
"port",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/ironic_driver.py#L431-L448 | [
"def",
"diag_port",
"(",
"self",
",",
"context",
",",
"port_id",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"info",
"(",
"\"diag_port %s\"",
"%",
"port_id",
")",
"try",
":",
"port",
"=",
"self",
".",
"_client",
".",
"show_port",
"(",
"port_id",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Tag.set | Set tag on model object. | quark/tags.py | def set(self, model, value):
"""Set tag on model object."""
self.validate(value)
self._pop(model)
value = self.serialize(value)
model.tags.append(value) | def set(self, model, value):
"""Set tag on model object."""
self.validate(value)
self._pop(model)
value = self.serialize(value)
model.tags.append(value) | [
"Set",
"tag",
"on",
"model",
"object",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tags.py#L53-L58 | [
"def",
"set",
"(",
"self",
",",
"model",
",",
"value",
")",
":",
"self",
".",
"validate",
"(",
"value",
")",
"self",
".",
"_pop",
"(",
"model",
")",
"value",
"=",
"self",
".",
"serialize",
"(",
"value",
")",
"model",
".",
"tags",
".",
"append",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Tag.get | Get a matching valid tag off the model. | quark/tags.py | def get(self, model):
"""Get a matching valid tag off the model."""
for tag in model.tags:
if self.is_tag(tag):
value = self.deserialize(tag)
try:
self.validate(value)
return value
except TagValidationErr... | def get(self, model):
"""Get a matching valid tag off the model."""
for tag in model.tags:
if self.is_tag(tag):
value = self.deserialize(tag)
try:
self.validate(value)
return value
except TagValidationErr... | [
"Get",
"a",
"matching",
"valid",
"tag",
"off",
"the",
"model",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tags.py#L60-L70 | [
"def",
"get",
"(",
"self",
",",
"model",
")",
":",
"for",
"tag",
"in",
"model",
".",
"tags",
":",
"if",
"self",
".",
"is_tag",
"(",
"tag",
")",
":",
"value",
"=",
"self",
".",
"deserialize",
"(",
"tag",
")",
"try",
":",
"self",
".",
"validate",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Tag._pop | Pop all matching tags off the model and return them. | quark/tags.py | def _pop(self, model):
"""Pop all matching tags off the model and return them."""
tags = []
# collect any exsiting tags with matching prefix
for tag in model.tags:
if self.is_tag(tag):
tags.append(tag)
# remove collected tags from model
if ta... | def _pop(self, model):
"""Pop all matching tags off the model and return them."""
tags = []
# collect any exsiting tags with matching prefix
for tag in model.tags:
if self.is_tag(tag):
tags.append(tag)
# remove collected tags from model
if ta... | [
"Pop",
"all",
"matching",
"tags",
"off",
"the",
"model",
"and",
"return",
"them",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tags.py#L72-L86 | [
"def",
"_pop",
"(",
"self",
",",
"model",
")",
":",
"tags",
"=",
"[",
"]",
"# collect any exsiting tags with matching prefix",
"for",
"tag",
"in",
"model",
".",
"tags",
":",
"if",
"self",
".",
"is_tag",
"(",
"tag",
")",
":",
"tags",
".",
"append",
"(",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Tag.pop | Pop all matching tags off the port, return a valid one. | quark/tags.py | def pop(self, model):
"""Pop all matching tags off the port, return a valid one."""
tags = self._pop(model)
if tags:
for tag in tags:
value = self.deserialize(tag)
try:
self.validate(value)
return value
... | def pop(self, model):
"""Pop all matching tags off the port, return a valid one."""
tags = self._pop(model)
if tags:
for tag in tags:
value = self.deserialize(tag)
try:
self.validate(value)
return value
... | [
"Pop",
"all",
"matching",
"tags",
"off",
"the",
"port",
"return",
"a",
"valid",
"one",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tags.py#L88-L98 | [
"def",
"pop",
"(",
"self",
",",
"model",
")",
":",
"tags",
"=",
"self",
".",
"_pop",
"(",
"model",
")",
"if",
"tags",
":",
"for",
"tag",
"in",
"tags",
":",
"value",
"=",
"self",
".",
"deserialize",
"(",
"tag",
")",
"try",
":",
"self",
".",
"val... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Tag.has_tag | Does the given port have this tag? | quark/tags.py | def has_tag(self, model):
"""Does the given port have this tag?"""
for tag in model.tags:
if self.is_tag(tag):
return True
return False | def has_tag(self, model):
"""Does the given port have this tag?"""
for tag in model.tags:
if self.is_tag(tag):
return True
return False | [
"Does",
"the",
"given",
"port",
"have",
"this",
"tag?"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tags.py#L104-L109 | [
"def",
"has_tag",
"(",
"self",
",",
"model",
")",
":",
"for",
"tag",
"in",
"model",
".",
"tags",
":",
"if",
"self",
".",
"is_tag",
"(",
"tag",
")",
":",
"return",
"True",
"return",
"False"
] | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | VlanTag.validate | Validates a VLAN ID.
:param value: The VLAN ID to validate against.
:raises TagValidationError: Raised if the VLAN ID is invalid. | quark/tags.py | def validate(self, value):
"""Validates a VLAN ID.
:param value: The VLAN ID to validate against.
:raises TagValidationError: Raised if the VLAN ID is invalid.
"""
try:
vlan_id_int = int(value)
assert vlan_id_int >= self.MIN_VLAN_ID
assert vla... | def validate(self, value):
"""Validates a VLAN ID.
:param value: The VLAN ID to validate against.
:raises TagValidationError: Raised if the VLAN ID is invalid.
"""
try:
vlan_id_int = int(value)
assert vlan_id_int >= self.MIN_VLAN_ID
assert vla... | [
"Validates",
"a",
"VLAN",
"ID",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tags.py#L118-L135 | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"vlan_id_int",
"=",
"int",
"(",
"value",
")",
"assert",
"vlan_id_int",
">=",
"self",
".",
"MIN_VLAN_ID",
"assert",
"vlan_id_int",
"<=",
"self",
".",
"MAX_VLAN_ID",
"except",
"Exception",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | TagRegistry.get_all | Get all known tags from a model.
Returns a dict of {<tag_name>:<tag_value>}. | quark/tags.py | def get_all(self, model):
"""Get all known tags from a model.
Returns a dict of {<tag_name>:<tag_value>}.
"""
tags = {}
for name, tag in self.tags.items():
for mtag in model.tags:
if tag.is_tag(mtag):
tags[name] = tag.get(model)
... | def get_all(self, model):
"""Get all known tags from a model.
Returns a dict of {<tag_name>:<tag_value>}.
"""
tags = {}
for name, tag in self.tags.items():
for mtag in model.tags:
if tag.is_tag(mtag):
tags[name] = tag.get(model)
... | [
"Get",
"all",
"known",
"tags",
"from",
"a",
"model",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tags.py#L142-L152 | [
"def",
"get_all",
"(",
"self",
",",
"model",
")",
":",
"tags",
"=",
"{",
"}",
"for",
"name",
",",
"tag",
"in",
"self",
".",
"tags",
".",
"items",
"(",
")",
":",
"for",
"mtag",
"in",
"model",
".",
"tags",
":",
"if",
"tag",
".",
"is_tag",
"(",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | TagRegistry.set_all | Validate and set all known tags on a port. | quark/tags.py | def set_all(self, model, **tags):
"""Validate and set all known tags on a port."""
for name, tag in self.tags.items():
if name in tags:
value = tags.pop(name)
if value:
try:
tag.set(model, value)
... | def set_all(self, model, **tags):
"""Validate and set all known tags on a port."""
for name, tag in self.tags.items():
if name in tags:
value = tags.pop(name)
if value:
try:
tag.set(model, value)
... | [
"Validate",
"and",
"set",
"all",
"known",
"tags",
"on",
"a",
"port",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tags.py#L154-L165 | [
"def",
"set_all",
"(",
"self",
",",
"model",
",",
"*",
"*",
"tags",
")",
":",
"for",
"name",
",",
"tag",
"in",
"self",
".",
"tags",
".",
"items",
"(",
")",
":",
"if",
"name",
"in",
"tags",
":",
"value",
"=",
"tags",
".",
"pop",
"(",
"name",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | SecurityGroupsClient.serialize_rules | Creates a payload for the redis server. | quark/cache/security_groups_client.py | def serialize_rules(self, rules):
"""Creates a payload for the redis server."""
# TODO(mdietz): If/when we support other rule types, this comment
# will have to be revised.
# Action and direction are static, for now. The implementation may
# support 'deny' and 'egre... | def serialize_rules(self, rules):
"""Creates a payload for the redis server."""
# TODO(mdietz): If/when we support other rule types, this comment
# will have to be revised.
# Action and direction are static, for now. The implementation may
# support 'deny' and 'egre... | [
"Creates",
"a",
"payload",
"for",
"the",
"redis",
"server",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/cache/security_groups_client.py#L49-L93 | [
"def",
"serialize_rules",
"(",
"self",
",",
"rules",
")",
":",
"# TODO(mdietz): If/when we support other rule types, this comment",
"# will have to be revised.",
"# Action and direction are static, for now. The implementation may",
"# support 'deny' and 'egress' respectively in t... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | SecurityGroupsClient.serialize_groups | Creates a payload for the redis server
The rule schema is the following:
REDIS KEY - port_device_id.port_mac_address/sg
REDIS VALUE - A JSON dump of the following:
port_mac_address must be lower-cased and stripped of non-alphanumeric
characters
{"id": "<arbitrary uuid... | quark/cache/security_groups_client.py | def serialize_groups(self, groups):
"""Creates a payload for the redis server
The rule schema is the following:
REDIS KEY - port_device_id.port_mac_address/sg
REDIS VALUE - A JSON dump of the following:
port_mac_address must be lower-cased and stripped of non-alphanumeric
... | def serialize_groups(self, groups):
"""Creates a payload for the redis server
The rule schema is the following:
REDIS KEY - port_device_id.port_mac_address/sg
REDIS VALUE - A JSON dump of the following:
port_mac_address must be lower-cased and stripped of non-alphanumeric
... | [
"Creates",
"a",
"payload",
"for",
"the",
"redis",
"server"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/cache/security_groups_client.py#L95-L142 | [
"def",
"serialize_groups",
"(",
"self",
",",
"groups",
")",
":",
"rules",
"=",
"[",
"]",
"for",
"group",
"in",
"groups",
":",
"rules",
".",
"extend",
"(",
"self",
".",
"serialize_rules",
"(",
"group",
".",
"rules",
")",
")",
"return",
"rules"
] | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | SecurityGroupsClient.apply_rules | Writes a series of security group rules to a redis server. | quark/cache/security_groups_client.py | def apply_rules(self, device_id, mac_address, rules):
"""Writes a series of security group rules to a redis server."""
LOG.info("Applying security group rules for device %s with MAC %s" %
(device_id, mac_address))
rule_dict = {SECURITY_GROUP_RULE_KEY: rules}
redis_key =... | def apply_rules(self, device_id, mac_address, rules):
"""Writes a series of security group rules to a redis server."""
LOG.info("Applying security group rules for device %s with MAC %s" %
(device_id, mac_address))
rule_dict = {SECURITY_GROUP_RULE_KEY: rules}
redis_key =... | [
"Writes",
"a",
"series",
"of",
"security",
"group",
"rules",
"to",
"a",
"redis",
"server",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/cache/security_groups_client.py#L150-L159 | [
"def",
"apply_rules",
"(",
"self",
",",
"device_id",
",",
"mac_address",
",",
"rules",
")",
":",
"LOG",
".",
"info",
"(",
"\"Applying security group rules for device %s with MAC %s\"",
"%",
"(",
"device_id",
",",
"mac_address",
")",
")",
"rule_dict",
"=",
"{",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | SecurityGroupsClient.get_security_group_states | Gets security groups for interfaces from Redis
Returns a dictionary of xapi.VIFs with values of the current
acknowledged status in Redis.
States not explicitly handled:
* ack key, no rules - This is the same as just tagging the VIF,
the instance will be inaccessible
*... | quark/cache/security_groups_client.py | def get_security_group_states(self, interfaces):
"""Gets security groups for interfaces from Redis
Returns a dictionary of xapi.VIFs with values of the current
acknowledged status in Redis.
States not explicitly handled:
* ack key, no rules - This is the same as just tagging th... | def get_security_group_states(self, interfaces):
"""Gets security groups for interfaces from Redis
Returns a dictionary of xapi.VIFs with values of the current
acknowledged status in Redis.
States not explicitly handled:
* ack key, no rules - This is the same as just tagging th... | [
"Gets",
"security",
"groups",
"for",
"interfaces",
"from",
"Redis"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/cache/security_groups_client.py#L173-L214 | [
"def",
"get_security_group_states",
"(",
"self",
",",
"interfaces",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Getting security groups from Redis for {0}\"",
".",
"format",
"(",
"interfaces",
")",
")",
"interfaces",
"=",
"tuple",
"(",
"interfaces",
")",
"vif_keys",
"=... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | SecurityGroupsClient.update_group_states_for_vifs | Updates security groups by setting the ack field | quark/cache/security_groups_client.py | def update_group_states_for_vifs(self, vifs, ack):
"""Updates security groups by setting the ack field"""
vif_keys = [self.vif_key(vif.device_id, vif.mac_address)
for vif in vifs]
self.set_fields(vif_keys, SECURITY_GROUP_ACK, ack) | def update_group_states_for_vifs(self, vifs, ack):
"""Updates security groups by setting the ack field"""
vif_keys = [self.vif_key(vif.device_id, vif.mac_address)
for vif in vifs]
self.set_fields(vif_keys, SECURITY_GROUP_ACK, ack) | [
"Updates",
"security",
"groups",
"by",
"setting",
"the",
"ack",
"field"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/cache/security_groups_client.py#L217-L221 | [
"def",
"update_group_states_for_vifs",
"(",
"self",
",",
"vifs",
",",
"ack",
")",
":",
"vif_keys",
"=",
"[",
"self",
".",
"vif_key",
"(",
"vif",
".",
"device_id",
",",
"vif",
".",
"mac_address",
")",
"for",
"vif",
"in",
"vifs",
"]",
"self",
".",
"set_f... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | run_migrations_offline | Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output. | quark/db/migration/alembic/env.py | def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the g... | def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the g... | [
"Run",
"migrations",
"in",
"offline",
"mode",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/db/migration/alembic/env.py#L24-L39 | [
"def",
"run_migrations_offline",
"(",
")",
":",
"context",
".",
"configure",
"(",
"url",
"=",
"neutron_config",
".",
"database",
".",
"connection",
")",
"with",
"context",
".",
"begin_transaction",
"(",
")",
":",
"context",
".",
"run_migrations",
"(",
")"
] | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | run_migrations_online | Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context. | quark/db/migration/alembic/env.py | def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = create_engine(
neutron_config.database.connection,
poolclass=pool.NullPool)
connection = engine.connect()
... | def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = create_engine(
neutron_config.database.connection,
poolclass=pool.NullPool)
connection = engine.connect()
... | [
"Run",
"migrations",
"in",
"online",
"mode",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/db/migration/alembic/env.py#L42-L62 | [
"def",
"run_migrations_online",
"(",
")",
":",
"engine",
"=",
"create_engine",
"(",
"neutron_config",
".",
"database",
".",
"connection",
",",
"poolclass",
"=",
"pool",
".",
"NullPool",
")",
"connection",
"=",
"engine",
".",
"connect",
"(",
")",
"context",
"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | do_notify | Generic Notifier.
Parameters:
- `context`: session context
- `event_type`: the event type to report, i.e. ip.usage
- `payload`: dict containing the payload to send | quark/billing.py | def do_notify(context, event_type, payload):
"""Generic Notifier.
Parameters:
- `context`: session context
- `event_type`: the event type to report, i.e. ip.usage
- `payload`: dict containing the payload to send
"""
LOG.debug('IP_BILL: notifying {}'.format(payload))
notifie... | def do_notify(context, event_type, payload):
"""Generic Notifier.
Parameters:
- `context`: session context
- `event_type`: the event type to report, i.e. ip.usage
- `payload`: dict containing the payload to send
"""
LOG.debug('IP_BILL: notifying {}'.format(payload))
notifie... | [
"Generic",
"Notifier",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/billing.py#L82-L93 | [
"def",
"do_notify",
"(",
"context",
",",
"event_type",
",",
"payload",
")",
":",
"LOG",
".",
"debug",
"(",
"'IP_BILL: notifying {}'",
".",
"format",
"(",
"payload",
")",
")",
"notifier",
"=",
"n_rpc",
".",
"get_notifier",
"(",
"'network'",
")",
"notifier",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | notify | Method to send notifications.
We must send USAGE when a public IPv4 address is deallocated or a FLIP is
associated.
Parameters:
- `context`: the context for notifier
- `event_type`: the event type for IP allocate, deallocate, associate,
disassociate
- `ipaddress`: the ipaddr... | quark/billing.py | def notify(context, event_type, ipaddress, send_usage=False, *args, **kwargs):
"""Method to send notifications.
We must send USAGE when a public IPv4 address is deallocated or a FLIP is
associated.
Parameters:
- `context`: the context for notifier
- `event_type`: the event type for IP a... | def notify(context, event_type, ipaddress, send_usage=False, *args, **kwargs):
"""Method to send notifications.
We must send USAGE when a public IPv4 address is deallocated or a FLIP is
associated.
Parameters:
- `context`: the context for notifier
- `event_type`: the event type for IP a... | [
"Method",
"to",
"send",
"notifications",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/billing.py#L97-L151 | [
"def",
"notify",
"(",
"context",
",",
"event_type",
",",
"ipaddress",
",",
"send_usage",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"(",
"event_type",
"==",
"IP_ADD",
"and",
"not",
"CONF",
".",
"QUARK",
".",
"notify_ip_add... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | build_payload | Method builds a payload out of the passed arguments.
Parameters:
`ipaddress`: the models.IPAddress object
`event_type`: USAGE,CREATE,DELETE,SUSPEND,or UNSUSPEND
`start_time`: startTime for cloudfeeds
`end_time`: endTime for cloudfeeds
Returns a dictionary suitable to notify bill... | quark/billing.py | def build_payload(ipaddress,
event_type,
event_time=None,
start_time=None,
end_time=None):
"""Method builds a payload out of the passed arguments.
Parameters:
`ipaddress`: the models.IPAddress object
`event_type`: USAGE,CRE... | def build_payload(ipaddress,
event_type,
event_time=None,
start_time=None,
end_time=None):
"""Method builds a payload out of the passed arguments.
Parameters:
`ipaddress`: the models.IPAddress object
`event_type`: USAGE,CRE... | [
"Method",
"builds",
"a",
"payload",
"out",
"of",
"the",
"passed",
"arguments",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/billing.py#L154-L208 | [
"def",
"build_payload",
"(",
"ipaddress",
",",
"event_type",
",",
"event_time",
"=",
"None",
",",
"start_time",
"=",
"None",
",",
"end_time",
"=",
"None",
")",
":",
"# This is the common part of all message types",
"payload",
"=",
"{",
"'event_type'",
":",
"unicod... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | build_full_day_ips | Method to build an IP list for the case 1
when the IP was allocated before the period start
and is still allocated after the period end.
This method only looks at public IPv4 addresses. | quark/billing.py | def build_full_day_ips(query, period_start, period_end):
"""Method to build an IP list for the case 1
when the IP was allocated before the period start
and is still allocated after the period end.
This method only looks at public IPv4 addresses.
"""
# Filter out only IPv4 that have not been dea... | def build_full_day_ips(query, period_start, period_end):
"""Method to build an IP list for the case 1
when the IP was allocated before the period start
and is still allocated after the period end.
This method only looks at public IPv4 addresses.
"""
# Filter out only IPv4 that have not been dea... | [
"Method",
"to",
"build",
"an",
"IP",
"list",
"for",
"the",
"case",
"1"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/billing.py#L211-L229 | [
"def",
"build_full_day_ips",
"(",
"query",
",",
"period_start",
",",
"period_end",
")",
":",
"# Filter out only IPv4 that have not been deallocated",
"ip_list",
"=",
"query",
".",
"filter",
"(",
"models",
".",
"IPAddress",
".",
"version",
"==",
"4L",
")",
".",
"fi... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | calc_periods | Returns a tuple of start_period and end_period.
Assumes that the period is 24-hrs.
Parameters:
- `hour`: the hour from 0 to 23 when the period ends
- `minute`: the minute from 0 to 59 when the period ends
This method will calculate the end of the period as the closest hour/minute
going ... | quark/billing.py | def calc_periods(hour=0, minute=0):
"""Returns a tuple of start_period and end_period.
Assumes that the period is 24-hrs.
Parameters:
- `hour`: the hour from 0 to 23 when the period ends
- `minute`: the minute from 0 to 59 when the period ends
This method will calculate the end of the p... | def calc_periods(hour=0, minute=0):
"""Returns a tuple of start_period and end_period.
Assumes that the period is 24-hrs.
Parameters:
- `hour`: the hour from 0 to 23 when the period ends
- `minute`: the minute from 0 to 59 when the period ends
This method will calculate the end of the p... | [
"Returns",
"a",
"tuple",
"of",
"start_period",
"and",
"end_period",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/billing.py#L256-L288 | [
"def",
"calc_periods",
"(",
"hour",
"=",
"0",
",",
"minute",
"=",
"0",
")",
":",
"# Calculate the time intervals in a usable form",
"period_end",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"hour",
"=",
"hour",
",",
"minut... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | _make_job_dict | Creates the view for a job while calculating progress.
Since a root job does not have a transaction id (TID) it will return its
id as the TID. | quark/plugin_views.py | def _make_job_dict(job):
"""Creates the view for a job while calculating progress.
Since a root job does not have a transaction id (TID) it will return its
id as the TID.
"""
body = {"id": job.get('id'),
"action": job.get('action'),
"completed": job.get('completed'),
... | def _make_job_dict(job):
"""Creates the view for a job while calculating progress.
Since a root job does not have a transaction id (TID) it will return its
id as the TID.
"""
body = {"id": job.get('id'),
"action": job.get('action'),
"completed": job.get('completed'),
... | [
"Creates",
"the",
"view",
"for",
"a",
"job",
"while",
"calculating",
"progress",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_views.py#L369-L394 | [
"def",
"_make_job_dict",
"(",
"job",
")",
":",
"body",
"=",
"{",
"\"id\"",
":",
"job",
".",
"get",
"(",
"'id'",
")",
",",
"\"action\"",
":",
"job",
".",
"get",
"(",
"'action'",
")",
",",
"\"completed\"",
":",
"job",
".",
"get",
"(",
"'completed'",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_mac_address_range | Retrieve a mac_address_range.
: param context: neutron api request context
: param id: UUID representing the network to fetch.
: param fields: a list of strings that are valid keys in a
network dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in neutron/api/v2/attributes.py. Only t... | quark/plugin_modules/mac_address_ranges.py | def get_mac_address_range(context, id, fields=None):
"""Retrieve a mac_address_range.
: param context: neutron api request context
: param id: UUID representing the network to fetch.
: param fields: a list of strings that are valid keys in a
network dictionary as listed in the RESOURCE_ATTRIBUT... | def get_mac_address_range(context, id, fields=None):
"""Retrieve a mac_address_range.
: param context: neutron api request context
: param id: UUID representing the network to fetch.
: param fields: a list of strings that are valid keys in a
network dictionary as listed in the RESOURCE_ATTRIBUT... | [
"Retrieve",
"a",
"mac_address_range",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/mac_address_ranges.py#L54-L76 | [
"def",
"get_mac_address_range",
"(",
"context",
",",
"id",
",",
"fields",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"get_mac_address_range %s for tenant %s fields %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
",",
"fields",
")",
")",
"if",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | delete_mac_address_range | Delete a mac_address_range.
: param context: neutron api request context
: param id: UUID representing the mac_address_range to delete. | quark/plugin_modules/mac_address_ranges.py | def delete_mac_address_range(context, id):
"""Delete a mac_address_range.
: param context: neutron api request context
: param id: UUID representing the mac_address_range to delete.
"""
LOG.info("delete_mac_address_range %s for tenant %s" %
(id, context.tenant_id))
if not context.i... | def delete_mac_address_range(context, id):
"""Delete a mac_address_range.
: param context: neutron api request context
: param id: UUID representing the mac_address_range to delete.
"""
LOG.info("delete_mac_address_range %s for tenant %s" %
(id, context.tenant_id))
if not context.i... | [
"Delete",
"a",
"mac_address_range",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/mac_address_ranges.py#L120-L136 | [
"def",
"delete_mac_address_range",
"(",
"context",
",",
"id",
")",
":",
"LOG",
".",
"info",
"(",
"\"delete_mac_address_range %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"if",
"not",
"context",
".",
"is_admin",
":",
"raise",... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Jobs.get_resources | Returns Ext Resources. | quark/api/extensions/jobs.py | def get_resources(cls):
"""Returns Ext Resources."""
job_controller = JobsController(
directory.get_plugin())
resources = []
resources.append(extensions.ResourceExtension(
Jobs.get_alias(),
job_controller))
return reso... | def get_resources(cls):
"""Returns Ext Resources."""
job_controller = JobsController(
directory.get_plugin())
resources = []
resources.append(extensions.ResourceExtension(
Jobs.get_alias(),
job_controller))
return reso... | [
"Returns",
"Ext",
"Resources",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/api/extensions/jobs.py#L103-L111 | [
"def",
"get_resources",
"(",
"cls",
")",
":",
"job_controller",
"=",
"JobsController",
"(",
"directory",
".",
"get_plugin",
"(",
")",
")",
"resources",
"=",
"[",
"]",
"resources",
".",
"append",
"(",
"extensions",
".",
"ResourceExtension",
"(",
"Jobs",
".",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | downgrade | alexm: i believe this method is never called | quark/db/migration/alembic/versions/5927940a466e_create_shared_ips_columns.py | def downgrade():
"""alexm: i believe this method is never called"""
with op.batch_alter_table(t2_name) as batch_op:
batch_op.drop_column('do_not_use')
with op.batch_alter_table(t1_name) as batch_op:
batch_op.drop_column('enabled') | def downgrade():
"""alexm: i believe this method is never called"""
with op.batch_alter_table(t2_name) as batch_op:
batch_op.drop_column('do_not_use')
with op.batch_alter_table(t1_name) as batch_op:
batch_op.drop_column('enabled') | [
"alexm",
":",
"i",
"believe",
"this",
"method",
"is",
"never",
"called"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/db/migration/alembic/versions/5927940a466e_create_shared_ips_columns.py#L45-L51 | [
"def",
"downgrade",
"(",
")",
":",
"with",
"op",
".",
"batch_alter_table",
"(",
"t2_name",
")",
"as",
"batch_op",
":",
"batch_op",
".",
"drop_column",
"(",
"'do_not_use'",
")",
"with",
"op",
".",
"batch_alter_table",
"(",
"t1_name",
")",
"as",
"batch_op",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | delete_segment_allocation_range | Delete a segment_allocation_range.
: param context: neutron api request context
: param id: UUID representing the segment_allocation_range to delete. | quark/plugin_modules/segment_allocation_ranges.py | def delete_segment_allocation_range(context, sa_id):
"""Delete a segment_allocation_range.
: param context: neutron api request context
: param id: UUID representing the segment_allocation_range to delete.
"""
LOG.info("delete_segment_allocation_range %s for tenant %s" %
(sa_id, contex... | def delete_segment_allocation_range(context, sa_id):
"""Delete a segment_allocation_range.
: param context: neutron api request context
: param id: UUID representing the segment_allocation_range to delete.
"""
LOG.info("delete_segment_allocation_range %s for tenant %s" %
(sa_id, contex... | [
"Delete",
"a",
"segment_allocation_range",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/segment_allocation_ranges.py#L127-L144 | [
"def",
"delete_segment_allocation_range",
"(",
"context",
",",
"sa_id",
")",
":",
"LOG",
".",
"info",
"(",
"\"delete_segment_allocation_range %s for tenant %s\"",
"%",
"(",
"sa_id",
",",
"context",
".",
"tenant_id",
")",
")",
"if",
"not",
"context",
".",
"is_admin... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | filter_factory | Returns a WSGI filter app for use with paste.deploy. | quark/tools/middleware/resp_async_id.py | def filter_factory(global_conf, **local_conf):
"""Returns a WSGI filter app for use with paste.deploy."""
conf = global_conf.copy()
conf.update(local_conf)
def wrapper(app):
return ResponseAsyncIdAdder(app, conf)
return wrapper | def filter_factory(global_conf, **local_conf):
"""Returns a WSGI filter app for use with paste.deploy."""
conf = global_conf.copy()
conf.update(local_conf)
def wrapper(app):
return ResponseAsyncIdAdder(app, conf)
return wrapper | [
"Returns",
"a",
"WSGI",
"filter",
"app",
"for",
"use",
"with",
"paste",
".",
"deploy",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tools/middleware/resp_async_id.py#L56-L64 | [
"def",
"filter_factory",
"(",
"global_conf",
",",
"*",
"*",
"local_conf",
")",
":",
"conf",
"=",
"global_conf",
".",
"copy",
"(",
")",
"conf",
".",
"update",
"(",
"local_conf",
")",
"def",
"wrapper",
"(",
"app",
")",
":",
"return",
"ResponseAsyncIdAdder",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_used_ips | Returns dictionary with keys segment_id and value used IPs count.
Used IP address count is determined by:
- allocated IPs
- deallocated IPs whose `deallocated_at` is within the `reuse_after`
window compared to the present time, excluding IPs that are accounted for
in the current IP policy (because ... | quark/ip_availability.py | def get_used_ips(session, **kwargs):
"""Returns dictionary with keys segment_id and value used IPs count.
Used IP address count is determined by:
- allocated IPs
- deallocated IPs whose `deallocated_at` is within the `reuse_after`
window compared to the present time, excluding IPs that are accounte... | def get_used_ips(session, **kwargs):
"""Returns dictionary with keys segment_id and value used IPs count.
Used IP address count is determined by:
- allocated IPs
- deallocated IPs whose `deallocated_at` is within the `reuse_after`
window compared to the present time, excluding IPs that are accounte... | [
"Returns",
"dictionary",
"with",
"keys",
"segment_id",
"and",
"value",
"used",
"IPs",
"count",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/ip_availability.py#L85-L131 | [
"def",
"get_used_ips",
"(",
"session",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Getting used IPs...\"",
")",
"with",
"session",
".",
"begin",
"(",
")",
":",
"query",
"=",
"session",
".",
"query",
"(",
"models",
".",
"Subnet",
"."... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_unused_ips | Returns dictionary with key segment_id, and value unused IPs count.
Unused IP address count is determined by:
- adding subnet's cidr's size
- subtracting IP policy exclusions on subnet
- subtracting used ips per segment | quark/ip_availability.py | def get_unused_ips(session, used_ips_counts, **kwargs):
"""Returns dictionary with key segment_id, and value unused IPs count.
Unused IP address count is determined by:
- adding subnet's cidr's size
- subtracting IP policy exclusions on subnet
- subtracting used ips per segment
"""
LOG.debu... | def get_unused_ips(session, used_ips_counts, **kwargs):
"""Returns dictionary with key segment_id, and value unused IPs count.
Unused IP address count is determined by:
- adding subnet's cidr's size
- subtracting IP policy exclusions on subnet
- subtracting used ips per segment
"""
LOG.debu... | [
"Returns",
"dictionary",
"with",
"key",
"segment_id",
"and",
"value",
"unused",
"IPs",
"count",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/ip_availability.py#L134-L159 | [
"def",
"get_unused_ips",
"(",
"session",
",",
"used_ips_counts",
",",
"*",
"*",
"kwargs",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Getting unused IPs...\"",
")",
"with",
"session",
".",
"begin",
"(",
")",
":",
"query",
"=",
"session",
".",
"query",
"(",
"m... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | XapiClient.get_instances | Returns a dict of `VM OpaqueRef` (str) -> `xapi.VM`. | quark/agent/xapi.py | def get_instances(self, session):
"""Returns a dict of `VM OpaqueRef` (str) -> `xapi.VM`."""
LOG.debug("Getting instances from Xapi")
recs = session.xenapi.VM.get_all_records()
# NOTE(asadoughi): Copied from xen-networking-scripts/utils.py
is_inst = lambda r: (r['power_state'].... | def get_instances(self, session):
"""Returns a dict of `VM OpaqueRef` (str) -> `xapi.VM`."""
LOG.debug("Getting instances from Xapi")
recs = session.xenapi.VM.get_all_records()
# NOTE(asadoughi): Copied from xen-networking-scripts/utils.py
is_inst = lambda r: (r['power_state'].... | [
"Returns",
"a",
"dict",
"of",
"VM",
"OpaqueRef",
"(",
"str",
")",
"-",
">",
"xapi",
".",
"VM",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/agent/xapi.py#L122-L142 | [
"def",
"get_instances",
"(",
"self",
",",
"session",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Getting instances from Xapi\"",
")",
"recs",
"=",
"session",
".",
"xenapi",
".",
"VM",
".",
"get_all_records",
"(",
")",
"# NOTE(asadoughi): Copied from xen-networking-script... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | XapiClient.get_interfaces | Returns a set of VIFs from `get_instances` return value. | quark/agent/xapi.py | def get_interfaces(self):
"""Returns a set of VIFs from `get_instances` return value."""
LOG.debug("Getting interfaces from Xapi")
with self.sessioned() as session:
instances = self.get_instances(session)
recs = session.xenapi.VIF.get_all_records()
interfaces = ... | def get_interfaces(self):
"""Returns a set of VIFs from `get_instances` return value."""
LOG.debug("Getting interfaces from Xapi")
with self.sessioned() as session:
instances = self.get_instances(session)
recs = session.xenapi.VIF.get_all_records()
interfaces = ... | [
"Returns",
"a",
"set",
"of",
"VIFs",
"from",
"get_instances",
"return",
"value",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/agent/xapi.py#L144-L159 | [
"def",
"get_interfaces",
"(",
"self",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Getting interfaces from Xapi\"",
")",
"with",
"self",
".",
"sessioned",
"(",
")",
"as",
"session",
":",
"instances",
"=",
"self",
".",
"get_instances",
"(",
"session",
")",
"recs",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | XapiClient.update_interfaces | Handles changes to interfaces' security groups
Calls refresh_interfaces on argument VIFs. Set security groups on
added_sg's VIFs. Unsets security groups on removed_sg's VIFs. | quark/agent/xapi.py | def update_interfaces(self, added_sg, updated_sg, removed_sg):
"""Handles changes to interfaces' security groups
Calls refresh_interfaces on argument VIFs. Set security groups on
added_sg's VIFs. Unsets security groups on removed_sg's VIFs.
"""
if not (added_sg or updated_sg or ... | def update_interfaces(self, added_sg, updated_sg, removed_sg):
"""Handles changes to interfaces' security groups
Calls refresh_interfaces on argument VIFs. Set security groups on
added_sg's VIFs. Unsets security groups on removed_sg's VIFs.
"""
if not (added_sg or updated_sg or ... | [
"Handles",
"changes",
"to",
"interfaces",
"security",
"groups"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/agent/xapi.py#L215-L228 | [
"def",
"update_interfaces",
"(",
"self",
",",
"added_sg",
",",
"updated_sg",
",",
"removed_sg",
")",
":",
"if",
"not",
"(",
"added_sg",
"or",
"updated_sg",
"or",
"removed_sg",
")",
":",
"return",
"with",
"self",
".",
"sessioned",
"(",
")",
"as",
"session",... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | create_network | Create a network.
Create a network which represents an L2 network segment which
can have a set of subnets and ports associated with it.
: param context: neutron api request context
: param network: dictionary describing the network, with keys
as listed in the RESOURCE_ATTRIBUTE_MAP object in
... | quark/plugin_modules/networks.py | def create_network(context, network):
"""Create a network.
Create a network which represents an L2 network segment which
can have a set of subnets and ports associated with it.
: param context: neutron api request context
: param network: dictionary describing the network, with keys
as list... | def create_network(context, network):
"""Create a network.
Create a network which represents an L2 network segment which
can have a set of subnets and ports associated with it.
: param context: neutron api request context
: param network: dictionary describing the network, with keys
as list... | [
"Create",
"a",
"network",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/networks.py#L53-L151 | [
"def",
"create_network",
"(",
"context",
",",
"network",
")",
":",
"LOG",
".",
"info",
"(",
"\"create_network for tenant %s\"",
"%",
"context",
".",
"tenant_id",
")",
"with",
"context",
".",
"session",
".",
"begin",
"(",
")",
":",
"net_attrs",
"=",
"network"... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | update_network | Update values of a network.
: param context: neutron api request context
: param id: UUID representing the network to update.
: param network: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow_put'
as listed in the RESOURCE_ATTRIBUTE... | quark/plugin_modules/networks.py | def update_network(context, id, network):
"""Update values of a network.
: param context: neutron api request context
: param id: UUID representing the network to update.
: param network: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow... | def update_network(context, id, network):
"""Update values of a network.
: param context: neutron api request context
: param id: UUID representing the network to update.
: param network: dictionary with keys indicating fields to update.
valid keys are those that have a value of True for 'allow... | [
"Update",
"values",
"of",
"a",
"network",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/networks.py#L154-L176 | [
"def",
"update_network",
"(",
"context",
",",
"id",
",",
"network",
")",
":",
"LOG",
".",
"info",
"(",
"\"update_network %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"with",
"context",
".",
"session",
".",
"begin",
"(",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_network | Retrieve a network.
: param context: neutron api request context
: param id: UUID representing the network to fetch.
: param fields: a list of strings that are valid keys in a
network dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object in neutron/api/v2/attributes.py. Only these field... | quark/plugin_modules/networks.py | def get_network(context, id, fields=None):
"""Retrieve a network.
: param context: neutron api request context
: param id: UUID representing the network to fetch.
: param fields: a list of strings that are valid keys in a
network dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object... | def get_network(context, id, fields=None):
"""Retrieve a network.
: param context: neutron api request context
: param id: UUID representing the network to fetch.
: param fields: a list of strings that are valid keys in a
network dictionary as listed in the RESOURCE_ATTRIBUTE_MAP
object... | [
"Retrieve",
"a",
"network",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/networks.py#L179-L197 | [
"def",
"get_network",
"(",
"context",
",",
"id",
",",
"fields",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"get_network %s for tenant %s fields %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
",",
"fields",
")",
")",
"network",
"=",
"db_api... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_networks | Retrieve a list of networks.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid keys for
a network as listed... | quark/plugin_modules/networks.py | def get_networks(context, limit=None, sorts=['id'], marker=None,
page_reverse=False, filters=None, fields=None):
"""Retrieve a list of networks.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: p... | def get_networks(context, limit=None, sorts=['id'], marker=None,
page_reverse=False, filters=None, fields=None):
"""Retrieve a list of networks.
The contents of the list depends on the identity of the user
making the request (as indicated by the context) as well as any
filters.
: p... | [
"Retrieve",
"a",
"list",
"of",
"networks",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/networks.py#L200-L226 | [
"def",
"get_networks",
"(",
"context",
",",
"limit",
"=",
"None",
",",
"sorts",
"=",
"[",
"'id'",
"]",
",",
"marker",
"=",
"None",
",",
"page_reverse",
"=",
"False",
",",
"filters",
"=",
"None",
",",
"fields",
"=",
"None",
")",
":",
"LOG",
".",
"in... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | get_networks_count | Return the number of networks.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are valid keys for
a network as listed in the RESOURCE... | quark/plugin_modules/networks.py | def get_networks_count(context, filters=None):
"""Return the number of networks.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are vali... | def get_networks_count(context, filters=None):
"""Return the number of networks.
The result depends on the identity of the user making the request
(as indicated by the context) as well as any filters.
: param context: neutron api request context
: param filters: a dictionary with keys that are vali... | [
"Return",
"the",
"number",
"of",
"networks",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/networks.py#L229-L248 | [
"def",
"get_networks_count",
"(",
"context",
",",
"filters",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"get_networks_count for tenant %s filters %s\"",
"%",
"(",
"context",
".",
"tenant_id",
",",
"filters",
")",
")",
"return",
"db_api",
".",
"network_cou... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | delete_network | Delete a network.
: param context: neutron api request context
: param id: UUID representing the network to delete. | quark/plugin_modules/networks.py | def delete_network(context, id):
"""Delete a network.
: param context: neutron api request context
: param id: UUID representing the network to delete.
"""
LOG.info("delete_network %s for tenant %s" % (id, context.tenant_id))
with context.session.begin():
net = db_api.network_find(conte... | def delete_network(context, id):
"""Delete a network.
: param context: neutron api request context
: param id: UUID representing the network to delete.
"""
LOG.info("delete_network %s for tenant %s" % (id, context.tenant_id))
with context.session.begin():
net = db_api.network_find(conte... | [
"Delete",
"a",
"network",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/networks.py#L251-L273 | [
"def",
"delete_network",
"(",
"context",
",",
"id",
")",
":",
"LOG",
".",
"info",
"(",
"\"delete_network %s for tenant %s\"",
"%",
"(",
"id",
",",
"context",
".",
"tenant_id",
")",
")",
"with",
"context",
".",
"session",
".",
"begin",
"(",
")",
":",
"net... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | make_case2 | This is a helper method for testing.
When run with the current context, it will create a case 2 entries
in the database. See top of file for what case 2 is. | quark/tools/billing.py | def make_case2(context):
"""This is a helper method for testing.
When run with the current context, it will create a case 2 entries
in the database. See top of file for what case 2 is.
"""
query = context.session.query(models.IPAddress)
period_start, period_end = billing.calc_periods()
ip_l... | def make_case2(context):
"""This is a helper method for testing.
When run with the current context, it will create a case 2 entries
in the database. See top of file for what case 2 is.
"""
query = context.session.query(models.IPAddress)
period_start, period_end = billing.calc_periods()
ip_l... | [
"This",
"is",
"a",
"helper",
"method",
"for",
"testing",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tools/billing.py#L32-L47 | [
"def",
"make_case2",
"(",
"context",
")",
":",
"query",
"=",
"context",
".",
"session",
".",
"query",
"(",
"models",
".",
"IPAddress",
")",
"period_start",
",",
"period_end",
"=",
"billing",
".",
"calc_periods",
"(",
")",
"ip_list",
"=",
"billing",
".",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | main | Runs billing report. Optionally sends notifications to billing | quark/tools/billing.py | def main(notify, hour, minute):
"""Runs billing report. Optionally sends notifications to billing"""
# Read the config file and get the admin context
config_opts = ['--config-file', '/etc/neutron/neutron.conf']
config.init(config_opts)
# Have to load the billing module _after_ config is parsed so
... | def main(notify, hour, minute):
"""Runs billing report. Optionally sends notifications to billing"""
# Read the config file and get the admin context
config_opts = ['--config-file', '/etc/neutron/neutron.conf']
config.init(config_opts)
# Have to load the billing module _after_ config is parsed so
... | [
"Runs",
"billing",
"report",
".",
"Optionally",
"sends",
"notifications",
"to",
"billing"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/tools/billing.py#L57-L118 | [
"def",
"main",
"(",
"notify",
",",
"hour",
",",
"minute",
")",
":",
"# Read the config file and get the admin context",
"config_opts",
"=",
"[",
"'--config-file'",
",",
"'/etc/neutron/neutron.conf'",
"]",
"config",
".",
"init",
"(",
"config_opts",
")",
"# Have to load... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkAsyncPluginBase.start_rpc_listeners | Configure all listeners here | quark/worker_plugins/base_worker.py | def start_rpc_listeners(self):
"""Configure all listeners here"""
self._setup_rpc()
if not self.endpoints:
return []
self.conn = n_rpc.create_connection()
self.conn.create_consumer(self.topic, self.endpoints,
fanout=False)
ret... | def start_rpc_listeners(self):
"""Configure all listeners here"""
self._setup_rpc()
if not self.endpoints:
return []
self.conn = n_rpc.create_connection()
self.conn.create_consumer(self.topic, self.endpoints,
fanout=False)
ret... | [
"Configure",
"all",
"listeners",
"here"
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/worker_plugins/base_worker.py#L42-L50 | [
"def",
"start_rpc_listeners",
"(",
"self",
")",
":",
"self",
".",
"_setup_rpc",
"(",
")",
"if",
"not",
"self",
".",
"endpoints",
":",
"return",
"[",
"]",
"self",
".",
"conn",
"=",
"n_rpc",
".",
"create_connection",
"(",
")",
"self",
".",
"conn",
".",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkAsyncPluginBase.context | Provides an admin context for workers. | quark/worker_plugins/base_worker.py | def context(self):
"""Provides an admin context for workers."""
if not self._context:
self._context = context.get_admin_context()
return self._context | def context(self):
"""Provides an admin context for workers."""
if not self._context:
self._context = context.get_admin_context()
return self._context | [
"Provides",
"an",
"admin",
"context",
"for",
"workers",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/worker_plugins/base_worker.py#L53-L57 | [
"def",
"context",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_context",
":",
"self",
".",
"_context",
"=",
"context",
".",
"get_admin_context",
"(",
")",
"return",
"self",
".",
"_context"
] | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkSGAsyncProcessCallback.update_sg | Begins the async update process. | quark/worker_plugins/sg_update_worker.py | def update_sg(self, context, sg, rule_id, action):
"""Begins the async update process."""
db_sg = db_api.security_group_find(context, id=sg, scope=db_api.ONE)
if not db_sg:
return None
with context.session.begin():
job_body = dict(action="%s sg rule %s" % (action,... | def update_sg(self, context, sg, rule_id, action):
"""Begins the async update process."""
db_sg = db_api.security_group_find(context, id=sg, scope=db_api.ONE)
if not db_sg:
return None
with context.session.begin():
job_body = dict(action="%s sg rule %s" % (action,... | [
"Begins",
"the",
"async",
"update",
"process",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/worker_plugins/sg_update_worker.py#L71-L88 | [
"def",
"update_sg",
"(",
"self",
",",
"context",
",",
"sg",
",",
"rule_id",
",",
"action",
")",
":",
"db_sg",
"=",
"db_api",
".",
"security_group_find",
"(",
"context",
",",
"id",
"=",
"sg",
",",
"scope",
"=",
"db_api",
".",
"ONE",
")",
"if",
"not",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkSGProducerCallback.populate_subtasks | Produces a list of ports to be updated async. | quark/worker_plugins/sg_update_worker.py | def populate_subtasks(self, context, sg, parent_job_id):
"""Produces a list of ports to be updated async."""
db_sg = db_api.security_group_find(context, id=sg, scope=db_api.ONE)
if not db_sg:
return None
ports = db_api.sg_gather_associated_ports(context, db_sg)
if len... | def populate_subtasks(self, context, sg, parent_job_id):
"""Produces a list of ports to be updated async."""
db_sg = db_api.security_group_find(context, id=sg, scope=db_api.ONE)
if not db_sg:
return None
ports = db_api.sg_gather_associated_ports(context, db_sg)
if len... | [
"Produces",
"a",
"list",
"of",
"ports",
"to",
"be",
"updated",
"async",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/worker_plugins/sg_update_worker.py#L124-L146 | [
"def",
"populate_subtasks",
"(",
"self",
",",
"context",
",",
"sg",
",",
"parent_job_id",
")",
":",
"db_sg",
"=",
"db_api",
".",
"security_group_find",
"(",
"context",
",",
"id",
"=",
"sg",
",",
"scope",
"=",
"db_api",
".",
"ONE",
")",
"if",
"not",
"db... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | QuarkSGConsumerCallback.update_ports_for_sg | Updates the ports through redis. | quark/worker_plugins/sg_update_worker.py | def update_ports_for_sg(self, context, portid, jobid):
"""Updates the ports through redis."""
port = db_api.port_find(context, id=portid, scope=db_api.ONE)
if not port:
LOG.warning("Port not found")
return
net_driver = port_api._get_net_driver(port.network, port=p... | def update_ports_for_sg(self, context, portid, jobid):
"""Updates the ports through redis."""
port = db_api.port_find(context, id=portid, scope=db_api.ONE)
if not port:
LOG.warning("Port not found")
return
net_driver = port_api._get_net_driver(port.network, port=p... | [
"Updates",
"the",
"ports",
"through",
"redis",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/worker_plugins/sg_update_worker.py#L179-L212 | [
"def",
"update_ports_for_sg",
"(",
"self",
",",
"context",
",",
"portid",
",",
"jobid",
")",
":",
"port",
"=",
"db_api",
".",
"port_find",
"(",
"context",
",",
"id",
"=",
"portid",
",",
"scope",
"=",
"db_api",
".",
"ONE",
")",
"if",
"not",
"port",
":... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | sg_gather_associated_ports | Gather all ports associated to security group.
Returns:
* list, or None | quark/db/api.py | def sg_gather_associated_ports(context, group):
"""Gather all ports associated to security group.
Returns:
* list, or None
"""
if not group:
return None
if not hasattr(group, "ports") or len(group.ports) <= 0:
return []
return group.ports | def sg_gather_associated_ports(context, group):
"""Gather all ports associated to security group.
Returns:
* list, or None
"""
if not group:
return None
if not hasattr(group, "ports") or len(group.ports) <= 0:
return []
return group.ports | [
"Gather",
"all",
"ports",
"associated",
"to",
"security",
"group",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/db/api.py#L892-L902 | [
"def",
"sg_gather_associated_ports",
"(",
"context",
",",
"group",
")",
":",
"if",
"not",
"group",
":",
"return",
"None",
"if",
"not",
"hasattr",
"(",
"group",
",",
"\"ports\"",
")",
"or",
"len",
"(",
"group",
".",
"ports",
")",
"<=",
"0",
":",
"return... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | security_group_rule_update | Updates a security group rule.
NOTE(alexm) this is non-standard functionality. | quark/db/api.py | def security_group_rule_update(context, rule, **kwargs):
'''Updates a security group rule.
NOTE(alexm) this is non-standard functionality.
'''
rule.update(kwargs)
context.session.add(rule)
return rule | def security_group_rule_update(context, rule, **kwargs):
'''Updates a security group rule.
NOTE(alexm) this is non-standard functionality.
'''
rule.update(kwargs)
context.session.add(rule)
return rule | [
"Updates",
"a",
"security",
"group",
"rule",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/db/api.py#L969-L976 | [
"def",
"security_group_rule_update",
"(",
"context",
",",
"rule",
",",
"*",
"*",
"kwargs",
")",
":",
"rule",
".",
"update",
"(",
"kwargs",
")",
"context",
".",
"session",
".",
"add",
"(",
"rule",
")",
"return",
"rule"
] | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | segment_allocation_find | Query for segment allocations. | quark/db/api.py | def segment_allocation_find(context, lock_mode=False, **filters):
"""Query for segment allocations."""
range_ids = filters.pop("segment_allocation_range_ids", None)
query = context.session.query(models.SegmentAllocation)
if lock_mode:
query = query.with_lockmode("update")
query = query.fil... | def segment_allocation_find(context, lock_mode=False, **filters):
"""Query for segment allocations."""
range_ids = filters.pop("segment_allocation_range_ids", None)
query = context.session.query(models.SegmentAllocation)
if lock_mode:
query = query.with_lockmode("update")
query = query.fil... | [
"Query",
"for",
"segment",
"allocations",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/db/api.py#L1148-L1163 | [
"def",
"segment_allocation_find",
"(",
"context",
",",
"lock_mode",
"=",
"False",
",",
"*",
"*",
"filters",
")",
":",
"range_ids",
"=",
"filters",
".",
"pop",
"(",
"\"segment_allocation_range_ids\"",
",",
"None",
")",
"query",
"=",
"context",
".",
"session",
... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | Routes.get_resources | Returns Ext Resources. | quark/api/extensions/routes.py | def get_resources(cls):
"""Returns Ext Resources."""
controller = RoutesController(directory.get_plugin())
return [extensions.ResourceExtension(
Routes.get_alias(),
controller)] | def get_resources(cls):
"""Returns Ext Resources."""
controller = RoutesController(directory.get_plugin())
return [extensions.ResourceExtension(
Routes.get_alias(),
controller)] | [
"Returns",
"Ext",
"Resources",
"."
] | openstack/quark | python | https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/api/extensions/routes.py#L100-L105 | [
"def",
"get_resources",
"(",
"cls",
")",
":",
"controller",
"=",
"RoutesController",
"(",
"directory",
".",
"get_plugin",
"(",
")",
")",
"return",
"[",
"extensions",
".",
"ResourceExtension",
"(",
"Routes",
".",
"get_alias",
"(",
")",
",",
"controller",
")",... | 1112e6a66917d3e98e44cb7b33b107fd5a74bb2e |
valid | NikoHomeControlConnection.send | Sends the given command to Niko Home Control and returns the output of
the system.
Aliases: write, put, sendall, send_all | nikohomecontrol/nhcconnection.py | def send(self, s):
"""
Sends the given command to Niko Home Control and returns the output of
the system.
Aliases: write, put, sendall, send_all
"""
self._socket.send(s.encode())
return self.read() | def send(self, s):
"""
Sends the given command to Niko Home Control and returns the output of
the system.
Aliases: write, put, sendall, send_all
"""
self._socket.send(s.encode())
return self.read() | [
"Sends",
"the",
"given",
"command",
"to",
"Niko",
"Home",
"Control",
"and",
"returns",
"the",
"output",
"of",
"the",
"system",
"."
] | NoUseFreak/niko-home-control | python | https://github.com/NoUseFreak/niko-home-control/blob/4b9ff57c0f3fdadea7ac450d548292ca7b3033ad/nikohomecontrol/nhcconnection.py#L55-L63 | [
"def",
"send",
"(",
"self",
",",
"s",
")",
":",
"self",
".",
"_socket",
".",
"send",
"(",
"s",
".",
"encode",
"(",
")",
")",
"return",
"self",
".",
"read",
"(",
")"
] | 4b9ff57c0f3fdadea7ac450d548292ca7b3033ad |
valid | if_ | Implements the 'if' operator with support for multiple elseif-s. | json_logic/__init__.py | def if_(*args):
"""Implements the 'if' operator with support for multiple elseif-s."""
for i in range(0, len(args) - 1, 2):
if args[i]:
return args[i + 1]
if len(args) % 2:
return args[-1]
else:
return None | def if_(*args):
"""Implements the 'if' operator with support for multiple elseif-s."""
for i in range(0, len(args) - 1, 2):
if args[i]:
return args[i + 1]
if len(args) % 2:
return args[-1]
else:
return None | [
"Implements",
"the",
"if",
"operator",
"with",
"support",
"for",
"multiple",
"elseif",
"-",
"s",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L20-L28 | [
"def",
"if_",
"(",
"*",
"args",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"args",
")",
"-",
"1",
",",
"2",
")",
":",
"if",
"args",
"[",
"i",
"]",
":",
"return",
"args",
"[",
"i",
"+",
"1",
"]",
"if",
"len",
"(",
"a... | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | soft_equals | Implements the '==' operator, which does type JS-style coertion. | json_logic/__init__.py | def soft_equals(a, b):
"""Implements the '==' operator, which does type JS-style coertion."""
if isinstance(a, str) or isinstance(b, str):
return str(a) == str(b)
if isinstance(a, bool) or isinstance(b, bool):
return bool(a) is bool(b)
return a == b | def soft_equals(a, b):
"""Implements the '==' operator, which does type JS-style coertion."""
if isinstance(a, str) or isinstance(b, str):
return str(a) == str(b)
if isinstance(a, bool) or isinstance(b, bool):
return bool(a) is bool(b)
return a == b | [
"Implements",
"the",
"==",
"operator",
"which",
"does",
"type",
"JS",
"-",
"style",
"coertion",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L31-L37 | [
"def",
"soft_equals",
"(",
"a",
",",
"b",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"str",
")",
"or",
"isinstance",
"(",
"b",
",",
"str",
")",
":",
"return",
"str",
"(",
"a",
")",
"==",
"str",
"(",
"b",
")",
"if",
"isinstance",
"(",
"a",
"... | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | hard_equals | Implements the '===' operator. | json_logic/__init__.py | def hard_equals(a, b):
"""Implements the '===' operator."""
if type(a) != type(b):
return False
return a == b | def hard_equals(a, b):
"""Implements the '===' operator."""
if type(a) != type(b):
return False
return a == b | [
"Implements",
"the",
"===",
"operator",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L40-L44 | [
"def",
"hard_equals",
"(",
"a",
",",
"b",
")",
":",
"if",
"type",
"(",
"a",
")",
"!=",
"type",
"(",
"b",
")",
":",
"return",
"False",
"return",
"a",
"==",
"b"
] | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | less | Implements the '<' operator with JS-style type coertion. | json_logic/__init__.py | def less(a, b, *args):
"""Implements the '<' operator with JS-style type coertion."""
types = set([type(a), type(b)])
if float in types or int in types:
try:
a, b = float(a), float(b)
except TypeError:
# NaN
return False
return a < b and (not args or l... | def less(a, b, *args):
"""Implements the '<' operator with JS-style type coertion."""
types = set([type(a), type(b)])
if float in types or int in types:
try:
a, b = float(a), float(b)
except TypeError:
# NaN
return False
return a < b and (not args or l... | [
"Implements",
"the",
"<",
"operator",
"with",
"JS",
"-",
"style",
"type",
"coertion",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L47-L56 | [
"def",
"less",
"(",
"a",
",",
"b",
",",
"*",
"args",
")",
":",
"types",
"=",
"set",
"(",
"[",
"type",
"(",
"a",
")",
",",
"type",
"(",
"b",
")",
"]",
")",
"if",
"float",
"in",
"types",
"or",
"int",
"in",
"types",
":",
"try",
":",
"a",
","... | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | less_or_equal | Implements the '<=' operator with JS-style type coertion. | json_logic/__init__.py | def less_or_equal(a, b, *args):
"""Implements the '<=' operator with JS-style type coertion."""
return (
less(a, b) or soft_equals(a, b)
) and (not args or less_or_equal(b, *args)) | def less_or_equal(a, b, *args):
"""Implements the '<=' operator with JS-style type coertion."""
return (
less(a, b) or soft_equals(a, b)
) and (not args or less_or_equal(b, *args)) | [
"Implements",
"the",
"<",
"=",
"operator",
"with",
"JS",
"-",
"style",
"type",
"coertion",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L59-L63 | [
"def",
"less_or_equal",
"(",
"a",
",",
"b",
",",
"*",
"args",
")",
":",
"return",
"(",
"less",
"(",
"a",
",",
"b",
")",
"or",
"soft_equals",
"(",
"a",
",",
"b",
")",
")",
"and",
"(",
"not",
"args",
"or",
"less_or_equal",
"(",
"b",
",",
"*",
"... | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | to_numeric | Converts a string either to int or to float.
This is important, because e.g. {"!==": [{"+": "0"}, 0.0]} | json_logic/__init__.py | def to_numeric(arg):
"""
Converts a string either to int or to float.
This is important, because e.g. {"!==": [{"+": "0"}, 0.0]}
"""
if isinstance(arg, str):
if '.' in arg:
return float(arg)
else:
return int(arg)
return arg | def to_numeric(arg):
"""
Converts a string either to int or to float.
This is important, because e.g. {"!==": [{"+": "0"}, 0.0]}
"""
if isinstance(arg, str):
if '.' in arg:
return float(arg)
else:
return int(arg)
return arg | [
"Converts",
"a",
"string",
"either",
"to",
"int",
"or",
"to",
"float",
".",
"This",
"is",
"important",
"because",
"e",
".",
"g",
".",
"{",
"!",
"==",
":",
"[",
"{",
"+",
":",
"0",
"}",
"0",
".",
"0",
"]",
"}"
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L66-L76 | [
"def",
"to_numeric",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"str",
")",
":",
"if",
"'.'",
"in",
"arg",
":",
"return",
"float",
"(",
"arg",
")",
"else",
":",
"return",
"int",
"(",
"arg",
")",
"return",
"arg"
] | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | minus | Also, converts either to ints or to floats. | json_logic/__init__.py | def minus(*args):
"""Also, converts either to ints or to floats."""
if len(args) == 1:
return -to_numeric(args[0])
return to_numeric(args[0]) - to_numeric(args[1]) | def minus(*args):
"""Also, converts either to ints or to floats."""
if len(args) == 1:
return -to_numeric(args[0])
return to_numeric(args[0]) - to_numeric(args[1]) | [
"Also",
"converts",
"either",
"to",
"ints",
"or",
"to",
"floats",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L83-L87 | [
"def",
"minus",
"(",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"return",
"-",
"to_numeric",
"(",
"args",
"[",
"0",
"]",
")",
"return",
"to_numeric",
"(",
"args",
"[",
"0",
"]",
")",
"-",
"to_numeric",
"(",
"args",
"[... | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | merge | Implements the 'merge' operator for merging lists. | json_logic/__init__.py | def merge(*args):
"""Implements the 'merge' operator for merging lists."""
ret = []
for arg in args:
if isinstance(arg, list) or isinstance(arg, tuple):
ret += list(arg)
else:
ret.append(arg)
return ret | def merge(*args):
"""Implements the 'merge' operator for merging lists."""
ret = []
for arg in args:
if isinstance(arg, list) or isinstance(arg, tuple):
ret += list(arg)
else:
ret.append(arg)
return ret | [
"Implements",
"the",
"merge",
"operator",
"for",
"merging",
"lists",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L90-L98 | [
"def",
"merge",
"(",
"*",
"args",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",
"if",
"isinstance",
"(",
"arg",
",",
"list",
")",
"or",
"isinstance",
"(",
"arg",
",",
"tuple",
")",
":",
"ret",
"+=",
"list",
"(",
"arg",
")",
... | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | get_var | Gets variable value from data dictionary. | json_logic/__init__.py | def get_var(data, var_name, not_found=None):
"""Gets variable value from data dictionary."""
try:
for key in str(var_name).split('.'):
try:
data = data[key]
except TypeError:
data = data[int(key)]
except (KeyError, TypeError, ValueError):
... | def get_var(data, var_name, not_found=None):
"""Gets variable value from data dictionary."""
try:
for key in str(var_name).split('.'):
try:
data = data[key]
except TypeError:
data = data[int(key)]
except (KeyError, TypeError, ValueError):
... | [
"Gets",
"variable",
"value",
"from",
"data",
"dictionary",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L101-L112 | [
"def",
"get_var",
"(",
"data",
",",
"var_name",
",",
"not_found",
"=",
"None",
")",
":",
"try",
":",
"for",
"key",
"in",
"str",
"(",
"var_name",
")",
".",
"split",
"(",
"'.'",
")",
":",
"try",
":",
"data",
"=",
"data",
"[",
"key",
"]",
"except",
... | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | missing | Implements the missing operator for finding missing variables. | json_logic/__init__.py | def missing(data, *args):
"""Implements the missing operator for finding missing variables."""
not_found = object()
if args and isinstance(args[0], list):
args = args[0]
ret = []
for arg in args:
if get_var(data, arg, not_found) is not_found:
ret.append(arg)
return re... | def missing(data, *args):
"""Implements the missing operator for finding missing variables."""
not_found = object()
if args and isinstance(args[0], list):
args = args[0]
ret = []
for arg in args:
if get_var(data, arg, not_found) is not_found:
ret.append(arg)
return re... | [
"Implements",
"the",
"missing",
"operator",
"for",
"finding",
"missing",
"variables",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L115-L124 | [
"def",
"missing",
"(",
"data",
",",
"*",
"args",
")",
":",
"not_found",
"=",
"object",
"(",
")",
"if",
"args",
"and",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"list",
")",
":",
"args",
"=",
"args",
"[",
"0",
"]",
"ret",
"=",
"[",
"]",
"... | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | missing_some | Implements the missing_some operator for finding missing variables. | json_logic/__init__.py | def missing_some(data, min_required, args):
"""Implements the missing_some operator for finding missing variables."""
if min_required < 1:
return []
found = 0
not_found = object()
ret = []
for arg in args:
if get_var(data, arg, not_found) is not_found:
ret.append(arg)... | def missing_some(data, min_required, args):
"""Implements the missing_some operator for finding missing variables."""
if min_required < 1:
return []
found = 0
not_found = object()
ret = []
for arg in args:
if get_var(data, arg, not_found) is not_found:
ret.append(arg)... | [
"Implements",
"the",
"missing_some",
"operator",
"for",
"finding",
"missing",
"variables",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L127-L141 | [
"def",
"missing_some",
"(",
"data",
",",
"min_required",
",",
"args",
")",
":",
"if",
"min_required",
"<",
"1",
":",
"return",
"[",
"]",
"found",
"=",
"0",
"not_found",
"=",
"object",
"(",
")",
"ret",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",
":",... | 5fda9125eab4178f8f81c7779291940e31e87bab |
valid | jsonLogic | Executes the json-logic with given data. | json_logic/__init__.py | def jsonLogic(tests, data=None):
"""Executes the json-logic with given data."""
# You've recursed to a primitive, stop!
if tests is None or not isinstance(tests, dict):
return tests
data = data or {}
operator = list(tests.keys())[0]
values = tests[operator]
# Easy syntax for unary... | def jsonLogic(tests, data=None):
"""Executes the json-logic with given data."""
# You've recursed to a primitive, stop!
if tests is None or not isinstance(tests, dict):
return tests
data = data or {}
operator = list(tests.keys())[0]
values = tests[operator]
# Easy syntax for unary... | [
"Executes",
"the",
"json",
"-",
"logic",
"with",
"given",
"data",
"."
] | nadirizr/json-logic-py | python | https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L174-L203 | [
"def",
"jsonLogic",
"(",
"tests",
",",
"data",
"=",
"None",
")",
":",
"# You've recursed to a primitive, stop!",
"if",
"tests",
"is",
"None",
"or",
"not",
"isinstance",
"(",
"tests",
",",
"dict",
")",
":",
"return",
"tests",
"data",
"=",
"data",
"or",
"{",... | 5fda9125eab4178f8f81c7779291940e31e87bab |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.