MANY flake8 error fixes, all cosmetic
This commit is contained in:
@@ -259,7 +259,7 @@ def ip_address_find(context, lock_mode=False, **filters):
|
||||
|
||||
query = query.outerjoin(stmt, stmt.c.id == models.IPAddress.id)
|
||||
|
||||
#!@# HACK(amir): replace once attributes are configured in ip address
|
||||
# !@# HACK(amir): replace once attributes are configured in ip address
|
||||
# extension correctly
|
||||
if "True" in ip_shared:
|
||||
query = query.filter(stmt.c.ports_count > 1)
|
||||
|
||||
@@ -17,7 +17,7 @@ from quark.db.custom_types import INET
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
# commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'quark_mac_address_ranges',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
@@ -260,11 +260,11 @@ def upgrade():
|
||||
sa.ForeignKeyConstraint(['port_id'], ['quark_ports.id'], ),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
### end Alembic commands ###
|
||||
# end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
# commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('quark_port_ip_address_associations')
|
||||
op.drop_table('quark_dns_nameservers')
|
||||
op.drop_index('ix_quark_ip_addresses_version',
|
||||
@@ -299,4 +299,4 @@ def downgrade():
|
||||
op.drop_table('quark_ip_policy')
|
||||
op.drop_table('quark_tag_associations')
|
||||
op.drop_table('quark_mac_address_ranges')
|
||||
### end Alembic commands ###
|
||||
# end Alembic commands ###
|
||||
|
||||
@@ -14,7 +14,7 @@ from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
# commands auto generated by Alembic - please adjust! ###
|
||||
op.create_index(op.f('ix_quark_mac_addresses_deallocated'),
|
||||
'quark_mac_addresses',
|
||||
['deallocated'],
|
||||
@@ -22,12 +22,12 @@ def upgrade():
|
||||
op.create_unique_constraint('mac_address_range_id_address',
|
||||
'quark_mac_addresses',
|
||||
['mac_address_range_id', 'address'])
|
||||
### end Alembic commands ###
|
||||
# end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
# commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('mac_address_range_id_address', 'quark_mac_addresses')
|
||||
op.drop_index(op.f('ix_quark_mac_addresses_deallocated'),
|
||||
table_name='quark_mac_addresses')
|
||||
### end Alembic commands ###
|
||||
# end Alembic commands ###
|
||||
|
||||
@@ -14,15 +14,15 @@ from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
# commands auto generated by Alembic - please adjust! ###
|
||||
op.create_unique_constraint(
|
||||
'subnet_id_address',
|
||||
'quark_ip_addresses',
|
||||
['subnet_id', 'address'])
|
||||
### end Alembic commands ###
|
||||
# end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
# commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('subnet_id_address', 'quark_ip_addresses')
|
||||
### end Alembic commands ###
|
||||
# end Alembic commands ###
|
||||
|
||||
@@ -28,5 +28,5 @@ def main():
|
||||
config.neutron_config = cli.CONF
|
||||
|
||||
cli.CONF()
|
||||
#TODO(gongysh) enable logging
|
||||
# TODO(gongysh) enable logging
|
||||
cli.CONF.command.func(config, cli.CONF.command.name)
|
||||
|
||||
@@ -28,9 +28,9 @@ from neutron.openstack.common import log as logging
|
||||
from neutron.openstack.common import timeutils
|
||||
|
||||
from quark.db import custom_types
|
||||
#NOTE(mdietz): This is the only way to actually create the quotas table,
|
||||
# NOTE(mdietz): This is the only way to actually create the quotas table,
|
||||
# regardless if we need it. This is how it's done upstream.
|
||||
#NOTE(jhammond): If it isn't obvious quota_driver is unused and that's ok.
|
||||
# NOTE(jhammond): If it isn't obvious quota_driver is unused and that's ok.
|
||||
# DO NOT DELETE IT!!!
|
||||
from quark import quota_driver # noqa
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ class NVPDriver(base.BaseDriver):
|
||||
return "NVP"
|
||||
|
||||
def load_config(self):
|
||||
#NOTE(mdietz): What does default_tz actually mean?
|
||||
# NOTE(mdietz): What does default_tz actually mean?
|
||||
# We don't have one default.
|
||||
# NOTE(jkoelker): Transport Zone
|
||||
default_tz = CONF.NVP.default_tz
|
||||
@@ -433,7 +433,7 @@ class NVPDriver(base.BaseDriver):
|
||||
if phys_net and not net_type:
|
||||
raise exceptions.ProvidernetParamError(
|
||||
msg="provider:network_type parameter required")
|
||||
if not net_type in ("bridge", "vlan") and segment_id:
|
||||
if net_type not in ("bridge", "vlan") and segment_id:
|
||||
raise exceptions.SegmentIdUnsupported(net_type=net_type)
|
||||
if net_type == "vlan" and not segment_id:
|
||||
raise exceptions.SegmentIdRequired(net_type=net_type)
|
||||
|
||||
@@ -4,7 +4,6 @@ import sys
|
||||
from gunicorn.app import base
|
||||
from gunicorn import config as gconfig
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.common import config
|
||||
from neutron.common import legacy
|
||||
from neutron.common import utils
|
||||
|
||||
@@ -19,15 +19,12 @@ Quark Pluggable IPAM
|
||||
|
||||
import random
|
||||
import uuid
|
||||
|
||||
import netaddr
|
||||
from neutron.common import exceptions
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.openstack.common.notifier import api as notifier_api
|
||||
from neutron.openstack.common import timeutils
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from quark.db import api as db_api
|
||||
from quark.db import models
|
||||
from quark import exceptions as q_exc
|
||||
@@ -61,7 +58,7 @@ MAGIC_INT = 144115188075855872
|
||||
|
||||
|
||||
def rfc2462_ip(mac, cidr):
|
||||
#NOTE(mdietz): see RFC2462
|
||||
# NOTE(mdietz): see RFC2462
|
||||
int_val = netaddr.IPNetwork(cidr).value
|
||||
mac = netaddr.EUI(mac)
|
||||
int_val += mac.eui64().value
|
||||
@@ -213,7 +210,7 @@ class QuarkIpam(object):
|
||||
address = db_api.ip_address_find(elevated, **ip_kwargs)
|
||||
|
||||
if address:
|
||||
#NOTE(mdietz): We should always be in the CIDR but we
|
||||
# NOTE(mdietz): We should always be in the CIDR but we
|
||||
# also said that before :-/
|
||||
subnet = address.get('subnet')
|
||||
if subnet:
|
||||
@@ -295,8 +292,7 @@ class QuarkIpam(object):
|
||||
|
||||
This should provide a performance boost over attempting to check
|
||||
each and every subnet in the existing reallocate logic, as we'd
|
||||
have to iterate over each and every subnet returned
|
||||
"""
|
||||
have to iterate over each and every subnet returned """
|
||||
if not (ip_address is None and "mac_address" in kwargs and
|
||||
kwargs["mac_address"]):
|
||||
return self._allocate_from_subnet(context, net_id, subnet,
|
||||
@@ -312,7 +308,7 @@ class QuarkIpam(object):
|
||||
|
||||
ip_address = netaddr.IPAddress(ip_address)
|
||||
|
||||
#NOTE(mdietz): treating the IPSet as a boolean caused netaddr
|
||||
# NOTE(mdietz): treating the IPSet as a boolean caused netaddr
|
||||
# to attempt to enumerate the entire set!
|
||||
if (ip_policy_cidrs is not None and
|
||||
ip_address in ip_policy_cidrs):
|
||||
|
||||
@@ -17,13 +17,11 @@
|
||||
v2 Neutron Plug-in API Quark Implementation
|
||||
"""
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.db import api as neutron_db_api
|
||||
from neutron.extensions import securitygroup as sg_ext
|
||||
from neutron import neutron_plugin_base_v2
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron import quota
|
||||
|
||||
from quark.api import extensions
|
||||
from quark.db import models
|
||||
from quark.plugin_modules import ip_addresses
|
||||
@@ -75,7 +73,7 @@ def sessioned(func):
|
||||
res = func(self, context, *args, **kwargs)
|
||||
context.session.close()
|
||||
|
||||
#NOTE(mdietz): Forces neutron to get a fresh session
|
||||
# NOTE(mdietz): Forces neutron to get a fresh session
|
||||
# if it needs it after our call
|
||||
context._session = None
|
||||
return res
|
||||
@@ -122,16 +120,16 @@ class Plugin(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
||||
def delete_mac_address_range(self, context, id):
|
||||
mac_address_ranges.delete_mac_address_range(context, id)
|
||||
|
||||
#TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
#XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
# TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
# XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
@sessioned
|
||||
def create_security_group(self, context, security_group, net_driver):
|
||||
self._fix_missing_tenant_id(context, security_group["security_group"])
|
||||
return security_groups.create_security_group(context, security_group,
|
||||
net_driver)
|
||||
|
||||
#TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
#XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
# TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
# XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
@sessioned
|
||||
def create_security_group_rule(self, context, security_group,
|
||||
security_group_rule, net_driver):
|
||||
@@ -140,14 +138,14 @@ class Plugin(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
||||
security_group_rule,
|
||||
net_driver)
|
||||
|
||||
#TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
#XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
# TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
# XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
@sessioned
|
||||
def delete_security_group(self, context, id, net_driver):
|
||||
security_groups.delete_security_group(context, id, net_driver)
|
||||
|
||||
#TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
#XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
# TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
# XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
@sessioned
|
||||
def delete_security_group_rule(self, context, id, net_driver):
|
||||
security_groups.delete_security_group_rule(context, id, net_driver)
|
||||
@@ -176,8 +174,8 @@ class Plugin(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
||||
fields, sorts, limit,
|
||||
marker, page_reverse)
|
||||
|
||||
#TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
#XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
# TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
# XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
@sessioned
|
||||
def update_security_group(self, context, id, security_group, net_driver):
|
||||
return security_groups.update_security_group(context, id,
|
||||
|
||||
@@ -14,12 +14,10 @@
|
||||
# under the License.
|
||||
|
||||
import webob
|
||||
|
||||
from neutron.common import exceptions
|
||||
from neutron.openstack.common import importutils
|
||||
from neutron.openstack.common import log as logging
|
||||
from oslo.config import cfg
|
||||
|
||||
from quark.db import api as db_api
|
||||
from quark import exceptions as quark_exceptions
|
||||
from quark import plugin_views as v
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
import netaddr
|
||||
from neutron.openstack.common import log as logging
|
||||
|
||||
from quark.db import api as db_api
|
||||
from quark import exceptions as quark_exceptions
|
||||
from quark import plugin_views as v
|
||||
@@ -27,7 +26,7 @@ def _to_mac_range(val):
|
||||
cidr_parts = val.split("/")
|
||||
prefix = cidr_parts[0]
|
||||
|
||||
#FIXME(anyone): replace is slow, but this doesn't really
|
||||
# FIXME(anyone): replace is slow, but this doesn't really
|
||||
# get called ever. Fix maybe?
|
||||
prefix = prefix.replace(':', '')
|
||||
prefix = prefix.replace('-', '')
|
||||
|
||||
@@ -38,7 +38,7 @@ ipam_driver = (importutils.import_class(CONF.QUARK.ipam_driver))()
|
||||
|
||||
|
||||
def _adapt_provider_nets(context, network):
|
||||
#TODO(mdietz) going to ignore all the boundary and network
|
||||
# TODO(mdietz) going to ignore all the boundary and network
|
||||
# type checking for now.
|
||||
attrs = network["network"]
|
||||
net_type = utils.pop_param(attrs, pnet.NETWORK_TYPE)
|
||||
@@ -72,7 +72,7 @@ def create_network(context, network):
|
||||
else:
|
||||
net_uuid = uuidutils.generate_uuid()
|
||||
|
||||
#TODO(mdietz) this will be the first component registry hook, but
|
||||
# TODO(mdietz) this will be the first component registry hook, but
|
||||
# lets make it work first
|
||||
pnet_type, phys_net, seg_id = _adapt_provider_nets(context, network)
|
||||
|
||||
@@ -111,7 +111,7 @@ def create_network(context, network):
|
||||
new_subnets.append(s)
|
||||
new_net["subnets"] = new_subnets
|
||||
|
||||
#if not security_groups.get_security_groups(
|
||||
# if not security_groups.get_security_groups(
|
||||
# context,
|
||||
# filters={"id": security_groups.DEFAULT_SG_UUID}):
|
||||
# security_groups._create_default_security_group(context)
|
||||
|
||||
@@ -203,7 +203,7 @@ def update_port(context, id, port):
|
||||
fixed_ips = port["port"].pop("fixed_ips", None)
|
||||
if fixed_ips is not None:
|
||||
|
||||
#NOTE(mdietz): we want full control over IPAM since
|
||||
# NOTE(mdietz): we want full control over IPAM since
|
||||
# we're allocating by subnet instead of
|
||||
# network.
|
||||
ipam_driver = ipam.IPAM_REGISTRY.get_strategy(
|
||||
@@ -272,7 +272,7 @@ def update_port(context, id, port):
|
||||
with context.session.begin():
|
||||
port = db_api.port_update(context, port_db, **port["port"])
|
||||
|
||||
#NOTE(mdietz): fix for issue 112, we wanted the IPs to be in
|
||||
# NOTE(mdietz): fix for issue 112, we wanted the IPs to be in
|
||||
# allocated_at order, so get a fresh object every time
|
||||
if port_db in context.session:
|
||||
context.session.expunge(port_db)
|
||||
|
||||
@@ -71,7 +71,7 @@ def create_route(context, route):
|
||||
|
||||
|
||||
def delete_route(context, id):
|
||||
#TODO(mdietz): This is probably where we check to see that someone is
|
||||
# TODO(mdietz): This is probably where we check to see that someone is
|
||||
# admin and only filter on tenant if they aren't. Correct
|
||||
# for all the above later
|
||||
LOG.info("delete_route %s for tenant %s" % (id, context.tenant_id))
|
||||
|
||||
@@ -67,7 +67,7 @@ def _validate_security_group_rule(context, rule):
|
||||
|
||||
def create_security_group(context, security_group, net_driver):
|
||||
# TODO(dietz/perkins): passing in net_driver as a stopgap,
|
||||
# XXX DO NOT DEPLOY!! XXX see redmine #2487
|
||||
# XXX DO NOT DEPLOY!! XXX see redmine # 2487
|
||||
LOG.info("create_security_group for tenant %s" %
|
||||
(context.tenant_id))
|
||||
group = security_group["security_group"]
|
||||
@@ -151,7 +151,7 @@ def delete_security_group(context, id, net_driver):
|
||||
with context.session.begin():
|
||||
group = db_api.security_group_find(context, id=id, scope=db_api.ONE)
|
||||
|
||||
#TODO(anyone): name and ports are lazy-loaded. Could be good op later
|
||||
# TODO(anyone): name and ports are lazy-loaded. Could be good op later
|
||||
if not group:
|
||||
raise sg_ext.SecurityGroupNotFound(group_id=id)
|
||||
if id == DEFAULT_SG_UUID or group.name == "default":
|
||||
|
||||
@@ -18,11 +18,9 @@ View Helpers for Quark Plugin
|
||||
"""
|
||||
|
||||
import netaddr
|
||||
|
||||
from neutron.extensions import securitygroup as sg_ext
|
||||
from neutron.openstack.common import log as logging
|
||||
from oslo.config import cfg
|
||||
|
||||
from quark.db import api as db_api
|
||||
from quark.db import models
|
||||
from quark import network_strategy
|
||||
@@ -115,18 +113,18 @@ def _make_subnet_dict(subnet, fields=None):
|
||||
return {"destination": route["cidr"],
|
||||
"nexthop": route["gateway"]}
|
||||
|
||||
#TODO(mdietz): really inefficient, should go away
|
||||
# TODO(mdietz): really inefficient, should go away
|
||||
res["gateway_ip"] = None
|
||||
res["host_routes"] = []
|
||||
default_found = False
|
||||
for route in subnet["routes"]:
|
||||
netroute = netaddr.IPNetwork(route["cidr"])
|
||||
if _is_default_route(netroute):
|
||||
#NOTE(mdietz): This has the potential to find more than one default
|
||||
# route. Quark normally won't allow you to create
|
||||
# more than one, but it's plausible one exists
|
||||
# regardless. As such, we're going to pretend
|
||||
# it isn't possible, but log it anyway.
|
||||
# NOTE(mdietz): This has the potential to find more than one
|
||||
# default route. Quark normally won't allow you to create
|
||||
# more than one, but it's plausible one exists regardless.
|
||||
# As such, we're going to pretend it isn't possible, but
|
||||
# log it anyway.
|
||||
if default_found:
|
||||
LOG.info(_("Default route %(gateway_ip)s already found for "
|
||||
"subnet %(id)s") % res)
|
||||
@@ -178,7 +176,7 @@ def _port_dict(port, fields=None):
|
||||
mac = str(netaddr.EUI(res["mac_address"])).replace('-', ':')
|
||||
res["mac_address"] = mac
|
||||
|
||||
#NOTE(mdietz): more pythonic key in dict check fails here. Leave as get
|
||||
# NOTE(mdietz): more pythonic key in dict check fails here. Leave as get
|
||||
if port.get("bridge"):
|
||||
res["bridge"] = port["bridge"]
|
||||
return res
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
import contextlib
|
||||
import cProfile as profiler
|
||||
import gc
|
||||
try:
|
||||
@@ -23,9 +24,6 @@ except Exception:
|
||||
pass
|
||||
import sys
|
||||
import time
|
||||
|
||||
import contextlib
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.openstack.common import log as logging
|
||||
|
||||
|
||||
Reference in New Issue
Block a user