Add E128 to pep8 check list

Unlike E126, which is controversial, E128 is a check should be applied
to code.

E128 continuation line under-indented for visual indent

Change-Id: Idc67968dcc424e8eef252fff1704c96d32fe452a
Partial-Bug: #1663864
This commit is contained in:
Hong Hui Xiao 2017-02-13 15:14:44 +08:00
parent e6db08a184
commit 95de68ea33
35 changed files with 203 additions and 193 deletions

View File

@ -40,7 +40,7 @@ def environment_setup():
environment_destroy()
cmd = ["ovs-vsctl", "add-port", bridge, interface,
"--", "set", "Interface", interface, "type=internal"]
"--", "set", "Interface", interface, "type=internal"]
utils.execute(cmd, run_as_root=True)
ip = cfg.CONF.df_metadata.ip

View File

@ -130,8 +130,8 @@ df_opts = [
)
),
cfg.FloatOpt('monitor_table_poll_time',
default=30,
help=_('Poll monitored tables every this number of seconds')),
default=30,
help=_('Poll monitored tables every this number of seconds')),
cfg.BoolOpt('enable_selective_topology_distribution',
default=False,
help=_('When enabled, each controller will get only the part '

View File

@ -19,17 +19,18 @@ from dragonflow._i18n import _
df_dhcp_opts = [
cfg.ListOpt('df_dns_servers',
default=['8.8.8.8', '8.8.4.4'],
help=_('Comma-separated list of the DNS servers which will be used.')),
default=['8.8.8.8', '8.8.4.4'],
help=_('Comma-separated list of the DNS servers which will '
'be used.')),
cfg.IntOpt('df_default_network_device_mtu', default=1460,
help=_('default MTU setting for interface.')),
help=_('default MTU setting for interface.')),
cfg.IntOpt('df_dhcp_max_rate_per_sec', default=3,
help=_('Port Max rate of DHCP messages per second')),
help=_('Port Max rate of DHCP messages per second')),
cfg.IntOpt('df_dhcp_block_time_in_sec', default=100,
help=_('Time to block port that passes the max rate')),
help=_('Time to block port that passes the max rate')),
cfg.BoolOpt('df_add_link_local_route', default=True,
help=_("Set True to add route for link local address, which will be "
"useful for metadata service.")),
help=_("Set True to add route for link local address, which "
"will be useful for metadata service.")),
]

View File

@ -52,7 +52,7 @@ def _import_modules():
if not hasattr(mod, LIST_OPTS_FUNC_NAME):
msg = _i18("The module '%s' should have a '%s' function which "
"returns the config options." % (mod.__name__,
LIST_OPTS_FUNC_NAME))
LIST_OPTS_FUNC_NAME))
raise Exception(msg)
else:
imported_modules.append(mod)

View File

@ -39,7 +39,7 @@ class ClassifierApp(df_base_app.DFlowApp):
LOG.debug("match reg7=%(reg7)s for ingress dispatch of %(lport)s",
{'reg7': port_key, 'lport': lport})
actions = [self.parser.OFPActionOutput(ofport,
self.ofproto.OFPCML_NO_BUFFER)]
self.ofproto.OFPCML_NO_BUFFER)]
action_inst = self.parser.OFPInstructionActions(
self.ofproto.OFPIT_APPLY_ACTIONS, actions)
inst = [action_inst]

View File

@ -126,6 +126,6 @@ def get_cookie(name, value, old_cookie=0, old_mask=0,
result_unmasked = (value << pair.offset)
result = (result_unmasked & pair.mask)
if result != result_unmasked:
raise exceptions.CookieOverflowExcpetion(cookie=value,
offset=pair.offset, mask=pair.mask)
raise exceptions.CookieOverflowExcpetion(
cookie=value, offset=pair.offset, mask=pair.mask)
return result | (old_cookie & ~pair.mask), pair.mask | old_mask

View File

@ -87,10 +87,10 @@ class DfLocalController(object):
self.vswitch_api.initialize(self.nb_api)
if cfg.CONF.df.enable_port_status_notifier:
self.port_status_notifier.initialize(mech_driver=None,
nb_api=self.nb_api,
pub=self.nb_api.publisher,
sub=None,
is_neutron_server=False)
nb_api=self.nb_api,
pub=self.nb_api.publisher,
sub=None,
is_neutron_server=False)
self.topology = topology.Topology(self,
self.enable_selective_topo_dist)
if self.enable_db_consistency:
@ -104,7 +104,7 @@ class DfLocalController(object):
# if yes, don't set controller and don't delete controller.
# if no, set controller
targets = ('tcp:' + cfg.CONF.df_ryu.of_listen_address + ':' +
str(cfg.CONF.df_ryu.of_listen_port))
str(cfg.CONF.df_ryu.of_listen_port))
is_controller_set = self.vswitch_api.check_controller(targets)
if not is_controller_set:
self.vswitch_api.set_controller(self.integration_bridge, [targets])

View File

@ -60,7 +60,7 @@ class DHCPApp(df_base_app.DFlowApp):
self.ofport_to_dhcp_app_port_data = {}
self.api.register_table_handler(const.DHCP_TABLE,
self.packet_in_handler)
self.packet_in_handler)
self.switch_dhcp_ip_map = collections.defaultdict(dict)
self.subnet_vm_port_map = collections.defaultdict(set)
@ -134,7 +134,7 @@ class DHCPApp(df_base_app.DFlowApp):
'tunnel_id': lport.get_id()})
else:
LOG.error(_LE("DHCP message type %d not handled"),
dhcp_message_type)
dhcp_message_type)
if send_packet:
self.send_packet(ofport, send_packet)
@ -181,8 +181,8 @@ class DHCPApp(df_base_app.DFlowApp):
dst=pkt_ethernet.src,
src=pkt_ethernet.dst))
dhcp_pkt.add_protocol(ipv4.ipv4(dst=pkt_ipv4.src,
src=dhcp_server_address,
proto=pkt_ipv4.proto))
src=dhcp_server_address,
proto=pkt_ipv4.proto))
dhcp_pkt.add_protocol(udp.udp(src_port=const.DHCP_SERVER_PORT,
dst_port=const.DHCP_CLIENT_PORT))
dhcp_pkt.add_protocol(dhcp.dhcp(op=dhcp.DHCP_BOOT_REPLY,
@ -426,11 +426,11 @@ class DHCPApp(df_base_app.DFlowApp):
ofproto = self.ofproto
if ip_addr:
match = parser.OFPMatch(eth_type=ether.ETH_TYPE_IP,
ipv4_dst=ip_addr,
ip_proto=n_const.PROTO_NUM_UDP,
udp_src=const.DHCP_CLIENT_PORT,
udp_dst=const.DHCP_SERVER_PORT,
metadata=network_id)
ipv4_dst=ip_addr,
ip_proto=n_const.PROTO_NUM_UDP,
udp_src=const.DHCP_CLIENT_PORT,
udp_dst=const.DHCP_SERVER_PORT,
metadata=network_id)
else:
match = parser.OFPMatch(metadata=network_id)
self.mod_flow(
@ -443,10 +443,10 @@ class DHCPApp(df_base_app.DFlowApp):
parser = self.parser
match = parser.OFPMatch(eth_type=ether.ETH_TYPE_IP,
eth_dst=const.BROADCAST_MAC,
ip_proto=n_const.PROTO_NUM_UDP,
udp_src=const.DHCP_CLIENT_PORT,
udp_dst=const.DHCP_SERVER_PORT)
eth_dst=const.BROADCAST_MAC,
ip_proto=n_const.PROTO_NUM_UDP,
udp_src=const.DHCP_CLIENT_PORT,
udp_dst=const.DHCP_SERVER_PORT)
self.add_flow_go_to_table(const.SERVICES_CLASSIFICATION_TABLE,
const.PRIORITY_MEDIUM,
@ -455,11 +455,11 @@ class DHCPApp(df_base_app.DFlowApp):
def _install_dhcp_unicast_match_flow(self, ip_addr, network_id):
parser = self.parser
match = parser.OFPMatch(eth_type=ether.ETH_TYPE_IP,
ipv4_dst=ip_addr,
ip_proto=n_const.PROTO_NUM_UDP,
udp_src=const.DHCP_CLIENT_PORT,
udp_dst=const.DHCP_SERVER_PORT,
metadata=network_id)
ipv4_dst=ip_addr,
ip_proto=n_const.PROTO_NUM_UDP,
udp_src=const.DHCP_CLIENT_PORT,
udp_dst=const.DHCP_SERVER_PORT,
metadata=network_id)
self.add_flow_go_to_table(const.SERVICES_CLASSIFICATION_TABLE,
const.PRIORITY_MEDIUM,

View File

@ -72,9 +72,9 @@ class DNATApp(df_base_app.DFlowApp):
max_rate=self.conf.dnat_icmp_error_max_rate,
time_unit=1)
self.api.register_table_handler(const.INGRESS_NAT_TABLE,
self.ingress_packet_in_handler)
self.ingress_packet_in_handler)
self.api.register_table_handler(const.EGRESS_NAT_TABLE,
self.egress_packet_in_handler)
self.egress_packet_in_handler)
def switch_features_handler(self, ev):
self._init_external_bridge()
@ -235,20 +235,20 @@ class DNATApp(df_base_app.DFlowApp):
if netaddr.IPAddress(floatingip.get_ip_address()).version != 4:
return
arp_responder.ArpResponder(self,
None,
floatingip.get_ip_address(),
floatingip.get_mac_address(),
const.INGRESS_NAT_TABLE).add()
None,
floatingip.get_ip_address(),
floatingip.get_mac_address(),
const.INGRESS_NAT_TABLE).add()
def _remove_floatingip_arp_responder(self, floatingip):
# install floatingip arp responder flow rules
if netaddr.IPAddress(floatingip.get_ip_address()).version != 4:
return
arp_responder.ArpResponder(self,
None,
floatingip.get_ip_address(),
floatingip.get_mac_address(),
const.INGRESS_NAT_TABLE).remove()
None,
floatingip.get_ip_address(),
floatingip.get_mac_address(),
const.INGRESS_NAT_TABLE).remove()
def _get_vm_port_info(self, floatingip):
lport = self.db_store.get_local_port(floatingip.get_lport_id())

View File

@ -54,7 +54,7 @@ class L3App(df_base_app.DFlowApp):
max_rate=self.conf.router_ttl_invalid_max_rate,
time_unit=1)
self.api.register_table_handler(const.L3_LOOKUP_TABLE,
self.packet_in_handler)
self.packet_in_handler)
def switch_features_handler(self, ev):
self.router_port_rarp_cache.clear()
@ -111,7 +111,7 @@ class L3App(df_base_app.DFlowApp):
self.send_packet(in_port, icmp_ttl_pkt)
else:
LOG.warning(_LW("The invalid TTL packet's destination mac %s "
"can't be recognized."), e_pkt.dst)
"can't be recognized."), e_pkt.dst)
return
pkt = packet.Packet(msg.data)

View File

@ -42,7 +42,7 @@ class L3ProactiveApp(df_base_app.DFlowApp):
self.route_cache = {}
self.router_port_rarp_cache = {}
self.api.register_table_handler(const.L3_LOOKUP_TABLE,
self.packet_in_handler)
self.packet_in_handler)
self.register_local_cookie_bits(COOKIE_NAME, 24)
def switch_features_handler(self, ev):
@ -418,7 +418,7 @@ class L3ProactiveApp(df_base_app.DFlowApp):
def _delete_router_route(self, router, route):
LOG.debug('Delete extra route %(route)s from router %(router)s',
{'route': route, 'router': router})
{'route': route, 'router': router})
self._delete_route_process(router, route)
self._del_from_route_cache(ROUTE_ADDED, router.get_id(), route)

View File

@ -59,12 +59,12 @@ class ZookeeperDbDriver(db_api.DbApi):
hosts = _parse_hosts(self.config.remote_db_hosts)
_handler = eventlet.SequentialEventletHandler()
_retry = retry.KazooRetry(max_tries=CLIENT_CONNECTION_RETRIES,
delay=0.5,
backoff=2,
sleep_func=_handler.sleep_func)
delay=0.5,
backoff=2,
sleep_func=_handler.sleep_func)
self.client = client.KazooClient(hosts=hosts,
handler=_handler,
connection_retry=_retry)
handler=_handler,
connection_retry=_retry)
self.client.start()
self.client.ensure_path(ROOT_NS)

View File

@ -177,8 +177,8 @@ def _test_and_create_object(id):
row = session.query(models.DFLockedObjects).filter_by(
object_uuid=id).one()
# test ttl
if row.lock and timeutils.is_older_than(row.created_at,
cfg.CONF.df.distributed_lock_ttl):
if row.lock and timeutils.is_older_than(
row.created_at, cfg.CONF.df.distributed_lock_ttl):
# reset the lock if it is timeout
LOG.warning(_LW('The lock for object %(id)s is reset '
'due to timeout.'), {'id': id})

View File

@ -33,7 +33,7 @@ class ZMQPubSub(pub_sub_api.PubSubApi):
transport = cfg.CONF.df.publisher_transport
if transport not in SUPPORTED_TRANSPORTS:
message = _LE("zmq_pub_sub: Unsupported publisher_transport value "
"%(transport)s, expected %(expected)s")
"%(transport)s, expected %(expected)s")
LOG.error(message, {
'transport': transport,
'expected': SUPPORTED_TRANSPORTS
@ -161,7 +161,7 @@ class ZMQSubscriberAgentBase(pub_sub_api.SubscriberAgentBase):
def run(self):
self.sub_socket = self.connect()
LOG.info(_LI("Starting Subscriber on ports %(endpoints)s"),
{'endpoints': self.uri_list})
{'endpoints': self.uri_list})
while True:
try:
eventlet.sleep(0)

View File

@ -17,5 +17,5 @@ from neutron.agent import l3_agent
def main(manager='dragonflow.neutron.agent.l3.df_router.'
'DfL3NATAgentWithStateReport'):
'DfL3NATAgentWithStateReport'):
l3_agent.main(manager)

View File

@ -75,9 +75,9 @@ class DFMechDriver(driver_api.MechanismDriver):
df_utils.DF_PORT_STATUS_DRIVER_NAMESPACE)
self.port_status_notifier = port_status_notifier
self.port_status_notifier.initialize(self, self.nb_api,
pub=None,
sub=self.nb_api.subscriber,
is_neutron_server=True)
pub=None,
sub=self.nb_api.subscriber,
is_neutron_server=True)
self.port_status = None
def subscribe_registries(self):
@ -604,7 +604,7 @@ class DFMechDriver(driver_api.MechanismDriver):
in updated_port['device_owner'] and
context.status != context.original_status and
(context.status == n_const.PORT_STATUS_DOWN or
context.status == n_const.PORT_STATUS_ACTIVE)):
context.status == n_const.PORT_STATUS_ACTIVE)):
return None
# If a subnet enabled dhcp, the DFMechDriver will create a dhcp server

View File

@ -107,15 +107,15 @@ class LocalInterface(object):
"iface_id:%s, peer:%s, "
"attached_mac:%s, mac_in_use:%s, "
"tunnel_type:%s" % (self.uuid,
self.ofport,
self.name,
self.admin_state,
self.type,
self.iface_id,
self.peer,
self.attached_mac,
self.mac_in_use,
self.tunnel_type))
self.ofport,
self.name,
self.admin_state,
self.type,
self.iface_id,
self.peer,
self.attached_mac,
self.mac_in_use,
self.tunnel_type))
class OvsdbPort(object):

View File

@ -158,7 +158,7 @@ def main():
is_server = True
elif sys.argv[1] != 'client':
raise Exception('Bad parameter #1: Expected \'server\' or \'client\','
' found: %s' % sys.argv[1])
' found: %s' % sys.argv[1])
nb_api = api_nb.NbApi(
nb_driver_class(),
use_pubsub=cfg.CONF.df.enable_df_pub_sub,

View File

@ -47,7 +47,7 @@ class Test_API_NB(test_base.DFTestBase):
self.addCleanup(self.nb_api.delete_lswitch,
fake_lswitch1['id'], fake_lswitch1['topic'])
lswitch1 = self.nb_api.get_lswitch(fake_lswitch1['id'],
fake_lswitch1['topic'])
fake_lswitch1['topic'])
self.assertIsNotNone(lswitch1.get_unique_key())
self.assertNotEqual(lswitch.get_unique_key(),

View File

@ -177,15 +177,16 @@ class TestNeighborAdvertiser(test_base.DFTestBase):
try:
# Disable Duplicate Address Detection requests from the interface
self.dad_conf = utils.execute(['sysctl', '-n',
'net.ipv6.conf.default.accept_dad'])
'net.ipv6.conf.default.accept_dad'])
utils.execute(['sysctl', '-w',
'net.ipv6.conf.default.accept_dad=0'], run_as_root=True)
'net.ipv6.conf.default.accept_dad=0'],
run_as_root=True)
# Disable Router Solicitation requests from the interface
self.router_solicit_conf = utils.execute(['sysctl', '-n',
'net.ipv6.conf.default.router_solicitations'])
self.router_solicit_conf = utils.execute(
['sysctl', '-n', 'net.ipv6.conf.default.router_solicitations'])
utils.execute(['sysctl', '-w',
'net.ipv6.conf.default.router_solicitations=0'],
run_as_root=True)
'net.ipv6.conf.default.router_solicitations=0'],
run_as_root=True)
self.topology = app_testing_objects.Topology(
self.neutron,
self.nb_api)
@ -270,10 +271,10 @@ class TestNeighborAdvertiser(test_base.DFTestBase):
self.topology.close()
self.policy.close()
utils.execute(['sysctl', '-w', 'net.ipv6.conf.default.accept_dad={}'.
format(self.dad_conf)], run_as_root=True)
format(self.dad_conf)], run_as_root=True)
utils.execute(['sysctl', '-w',
'net.ipv6.conf.default.router_solicitations={}'.
format(self.router_solicit_conf)], run_as_root=True)
'net.ipv6.conf.default.router_solicitations={}'.
format(self.router_solicit_conf)], run_as_root=True)
def test_simple_response(self):
"""
@ -312,9 +313,9 @@ class TestDHCPApp(test_base.DFTestBase):
raise
def _create_udp_packet_for_dhcp(self,
dst_mac=constants.BROADCAST_MAC,
src_ip='0.0.0.0',
dst_ip=constants.BROADCAST_IP):
dst_mac=constants.BROADCAST_MAC,
src_ip='0.0.0.0',
dst_ip=constants.BROADCAST_IP):
ethernet = ryu.lib.packet.ethernet.ethernet(
src=self.port1.port.get_logical_port().get_mac(),
dst=dst_mac,
@ -520,9 +521,9 @@ class TestDHCPApp(test_base.DFTestBase):
policy = self.store(
app_testing_objects.Policy(
initial_actions=[send_dhcp_offer,
send_dhcp_offer,
send_dhcp_offer,
send_dhcp_offer],
send_dhcp_offer,
send_dhcp_offer,
send_dhcp_offer],
port_policies=port_policies,
unknown_port_action=app_testing_objects.IgnoreAction()
)

View File

@ -39,7 +39,7 @@ class DFTestBase(base.BaseTestCase):
self.neutron = clients.get_neutron_client_from_env()
except KeyError as e:
message = _LE('Cannot find environment variable %s. '
'Have you sourced openrc?')
'Have you sourced openrc?')
LOG.error(message, e.args[0])
self.fail(message % e.args[0])
else:

View File

@ -49,11 +49,11 @@ class TestDbConsistent(test_base.DFTestBase):
subnet = self.store(objects.SubnetTestObj(self.neutron, self.nb_api,
network_id))
subnet_body = {'network_id': network_id,
'cidr': '10.50.0.0/24',
'gateway_ip': '10.50.0.1',
'ip_version': 4,
'name': 'private',
'enable_dhcp': True}
'cidr': '10.50.0.0/24',
'gateway_ip': '10.50.0.1',
'ip_version': 4,
'name': 'private',
'enable_dhcp': True}
subnet.create(subnet=subnet_body)
time.sleep(constants.DEFAULT_RESOURCE_READY_TIMEOUT)
self.assertTrue(network.exists())

View File

@ -57,11 +57,11 @@ class TestOVSFlowsForDHCP(test_base.DFTestBase):
network = self.store(objects.NetworkTestObj(self.neutron, self.nb_api))
network_id = network.create()
subnet = {'network_id': network_id,
'cidr': '10.10.254.0/24',
'gateway_ip': '10.10.254.1',
'ip_version': 4,
'name': 'subnet-test',
'enable_dhcp': True}
'cidr': '10.10.254.0/24',
'gateway_ip': '10.10.254.1',
'ip_version': 4,
'name': 'subnet-test',
'enable_dhcp': True}
subnet = self.neutron.create_subnet({'subnet': subnet})
subnet_id = subnet['subnet']['id']
dhcp_ip = utils.wait_until_is_and_return(
@ -72,7 +72,7 @@ class TestOVSFlowsForDHCP(test_base.DFTestBase):
flows_before_change, dhcp_ip))
utils.wait_until_true(
lambda: utils.check_dhcp_ip_rule(ovs.dump(self.integration_bridge),
dhcp_ip),
dhcp_ip),
exception=Exception('DHCP ip was not found in OpenFlow rules'),
timeout=5
)
@ -90,11 +90,11 @@ class TestOVSFlowsForDHCP(test_base.DFTestBase):
network = self.store(objects.NetworkTestObj(self.neutron, self.nb_api))
network_id = network.create()
subnet = {'network_id': network_id,
'cidr': '10.20.0.0/24',
'gateway_ip': '10.20.0.1',
'ip_version': 4,
'name': 'subnet-test',
'enable_dhcp': False}
'cidr': '10.20.0.0/24',
'gateway_ip': '10.20.0.1',
'ip_version': 4,
'name': 'subnet-test',
'enable_dhcp': False}
subnet = self.neutron.create_subnet({'subnet': subnet})
subnet_id = subnet['subnet']['id']
time.sleep(const.DEFAULT_CMD_TIMEOUT)
@ -111,14 +111,14 @@ class TestOVSFlowsForDHCP(test_base.DFTestBase):
self.assertFalse(utils.check_dhcp_ip_rule(flows_after_change, dhcp_ip))
utils.wait_until_true(
lambda: utils.check_dhcp_ip_rule(ovs.dump(self.integration_bridge),
dhcp_ip),
dhcp_ip),
exception=Exception('DHCP ip was not found in OpenFlow rules'),
timeout=5
)
network.close()
utils.wait_until_none(
lambda: utils.check_dhcp_ip_rule(ovs.dump(self.integration_bridge),
dhcp_ip),
dhcp_ip),
exception=Exception('DHCP IP was not removed from OpenFlow rules'),
timeout=30
)
@ -130,11 +130,11 @@ class TestOVSFlowsForDHCP(test_base.DFTestBase):
network = self.store(objects.NetworkTestObj(self.neutron, self.nb_api))
network_id = network.create()
subnet = {'network_id': network_id,
'cidr': '10.30.0.0/24',
'gateway_ip': '10.30.0.1',
'ip_version': 4,
'name': 'subnet-test',
'enable_dhcp': True}
'cidr': '10.30.0.0/24',
'gateway_ip': '10.30.0.1',
'ip_version': 4,
'name': 'subnet-test',
'enable_dhcp': True}
subnet = self.neutron.create_subnet({'subnet': subnet})
subnet_id = subnet['subnet']['id']
router_id = router.create()
@ -155,7 +155,7 @@ class TestOVSFlowsForDHCP(test_base.DFTestBase):
network.close()
utils.wait_until_none(
lambda: utils.check_dhcp_ip_rule(ovs.dump(self.integration_bridge),
dhcp_ip),
dhcp_ip),
exception=Exception('DHCP IP was not removed from OpenFlow rules'),
timeout=30
)

View File

@ -52,11 +52,11 @@ class TestL2FLows(test_base.DFTestBase):
network_params = network.get_network()
segmentation_id = network_params['network']['provider:segmentation_id']
subnet = {'network_id': network_id,
'cidr': '10.200.0.0/24',
'gateway_ip': '10.200.0.1',
'ip_version': 4,
'name': 'private',
'enable_dhcp': True}
'cidr': '10.200.0.0/24',
'gateway_ip': '10.200.0.1',
'ip_version': 4,
'name': 'private',
'enable_dhcp': True}
subnet = self.neutron.create_subnet({'subnet': subnet})
self.assertIsNotNone(subnet)

View File

@ -49,11 +49,11 @@ class TestNeutronAPIandDB(test_base.DFTestBase):
network_id = network.create()
self.assertTrue(network.exists())
subnet = {'network_id': network_id,
'cidr': '10.1.0.0/24',
'gateway_ip': '10.1.0.1',
'ip_version': 4,
'name': 'subnet-test',
'enable_dhcp': True}
'cidr': '10.1.0.0/24',
'gateway_ip': '10.1.0.1',
'ip_version': 4,
'name': 'subnet-test',
'enable_dhcp': True}
self.neutron.create_subnet({'subnet': subnet})
ports = utils.wait_until_is_and_return(
lambda: self.nb_api.get_all_logical_ports(),
@ -165,7 +165,7 @@ class TestNeutronAPIandDB(test_base.DFTestBase):
network_id = network.create()
self.assertTrue(network.exists())
port = self.store(objects.PortTestObj(self.neutron,
self.nb_api, network_id))
self.nb_api, network_id))
port.create()
self.assertTrue(port.exists())
self.assertEqual(network_id, port.get_logical_port().get_lswitch_id())
@ -331,7 +331,8 @@ class TestNeutronAPIandDB(test_base.DFTestBase):
external_network_id,
))
external_subnet_para = {'cidr': '192.168.199.0/24',
'ip_version': 4, 'network_id': external_network_id}
'ip_version': 4,
'network_id': external_network_id}
ext_subnet.create(external_subnet_para)
self.assertTrue(ext_subnet.exists())
else:
@ -355,8 +356,9 @@ class TestNeutronAPIandDB(test_base.DFTestBase):
fip = self.store(
objects.FloatingipTestObj(self.neutron, self.nb_api))
router_para = {'name': 'myrouter1', 'admin_state_up': True,
'external_gateway_info': {"network_id": external_network_id}}
router_para = {
'name': 'myrouter1', 'admin_state_up': True,
'external_gateway_info': {"network_id": external_network_id}}
router.create(router=router_para)
self.assertTrue(router.exists())
@ -374,7 +376,8 @@ class TestNeutronAPIandDB(test_base.DFTestBase):
private_network_id,
))
private_subnet_para = {'cidr': '10.0.0.0/24',
'ip_version': 4, 'network_id': private_network_id}
'ip_version': 4,
'network_id': private_network_id}
priv_subnet_id = priv_subnet.create(private_subnet_para)
self.assertTrue(priv_subnet.exists())
router_interface = router.add_interface(subnet_id=priv_subnet_id)
@ -384,7 +387,7 @@ class TestNeutronAPIandDB(test_base.DFTestBase):
port = self.store(
objects.PortTestObj(self.neutron,
self.nb_api, private_network_id))
self.nb_api, private_network_id))
port_id = port.create()
self.assertIsNotNone(port.get_logical_port())
@ -415,8 +418,9 @@ class TestNeutronAPIandDB(test_base.DFTestBase):
fip = self.store(
objects.FloatingipTestObj(self.neutron, self.nb_api))
router_para = {'name': 'myrouter1', 'admin_state_up': True,
'external_gateway_info': {"network_id": external_network_id}}
router_para = {
'name': 'myrouter1', 'admin_state_up': True,
'external_gateway_info': {"network_id": external_network_id}}
router.create(router=router_para)
self.assertTrue(router.exists())
@ -433,7 +437,8 @@ class TestNeutronAPIandDB(test_base.DFTestBase):
private_network_id,
))
private_subnet_para = {'cidr': '10.0.0.0/24',
'ip_version': 4, 'network_id': private_network_id}
'ip_version': 4,
'network_id': private_network_id}
priv_subnet_id = priv_subnet.create(private_subnet_para)
self.assertTrue(priv_subnet.exists())
router_interface = router.add_interface(subnet_id=priv_subnet_id)
@ -443,12 +448,12 @@ class TestNeutronAPIandDB(test_base.DFTestBase):
port = self.store(
objects.PortTestObj(self.neutron,
self.nb_api, private_network_id))
self.nb_api, private_network_id))
port_id = port.create()
self.assertIsNotNone(port.get_logical_port())
fip_para = {'floating_network_id': external_network_id,
'port_id': port_id}
'port_id': port_id}
# create
fip.create(fip_para)
self.assertTrue(fip.exists())

View File

@ -159,7 +159,8 @@ class TestObjectVersion(test_base.DFTestBase):
external_network_id,
))
external_subnet_para = {'cidr': '192.168.199.0/24',
'ip_version': 4, 'network_id': external_network_id}
'ip_version': 4,
'network_id': external_network_id}
ext_subnet.create(external_subnet_para)
self.assertTrue(ext_subnet.exists())
else:
@ -192,17 +193,19 @@ class TestObjectVersion(test_base.DFTestBase):
objects.RouterTestObj(self.neutron, self.nb_api))
port = self.store(
objects.PortTestObj(self.neutron,
self.nb_api, private_network_id))
self.nb_api, private_network_id))
fip = self.store(
objects.FloatingipTestObj(self.neutron, self.nb_api))
router_para = {'name': 'myrouter1', 'admin_state_up': True,
'external_gateway_info': {"network_id": external_network_id}}
router_para = {
'name': 'myrouter1', 'admin_state_up': True,
'external_gateway_info': {"network_id": external_network_id}}
router.create(router=router_para)
self.assertTrue(router.exists())
private_subnet_para = {'cidr': '10.0.0.0/24',
'ip_version': 4, 'network_id': private_network_id}
'ip_version': 4,
'network_id': private_network_id}
priv_subnet_id = priv_subnet.create(private_subnet_para)
self.assertTrue(priv_subnet.exists())
router_interface = router.add_interface(subnet_id=priv_subnet_id)

View File

@ -33,7 +33,7 @@ def find_first_network(nclient, params):
return None
if networks_count > 1:
message = _LW("More than one network (%(count)d) found matching: "
"%(args)s")
"%(args)s")
LOG.warning(message, {'args': params, 'count': networks_count})
return networks[0]

View File

@ -105,11 +105,11 @@ class TestOvsdbMonitor(test_base.DFTestBase):
subnet = self.store(objects.SubnetTestObj(self.neutron, self.nb_api,
network_id))
subnet_body = {'network_id': network_id,
'cidr': '10.10.0.0/24',
'gateway_ip': '10.10.0.1',
'ip_version': 4,
'name': 'private',
'enable_dhcp': True}
'cidr': '10.10.0.0/24',
'gateway_ip': '10.10.0.1',
'ip_version': 4,
'name': 'private',
'enable_dhcp': True}
subnet.create(subnet=subnet_body)
self.assertTrue(network.exists())
self.assertTrue(subnet.exists())
@ -145,11 +145,11 @@ class TestOvsdbMonitor(test_base.DFTestBase):
subnet = self.store(objects.SubnetTestObj(self.neutron, self.nb_api,
network_id))
subnet_body = {'network_id': network_id,
'cidr': '10.20.0.0/24',
'gateway_ip': '10.20.0.1',
'ip_version': 4,
'name': 'private',
'enable_dhcp': True}
'cidr': '10.20.0.0/24',
'gateway_ip': '10.20.0.1',
'ip_version': 4,
'name': 'private',
'enable_dhcp': True}
subnet.create(subnet=subnet_body)
self.assertTrue(network.exists())
self.assertTrue(subnet.exists())

View File

@ -40,7 +40,7 @@ class ArpResponderTest(test_base.DFTestBase):
ovs_flows_parser = test_utils.OvsFlowsParser()
flows = ovs_flows_parser.dump(self.integration_bridge)
flows = [flow for flow in flows
if flow['table'] == str(const.ARP_TABLE)]
if flow['table'] == str(const.ARP_TABLE)]
return flows
def _check_arp_flow_removal(self, ip):
@ -63,11 +63,11 @@ class ArpResponderTest(test_base.DFTestBase):
))
subnet = {'network_id': network_id,
'cidr': '10.10.10.0/24',
'gateway_ip': '10.10.10.1',
'ip_version': 4,
'name': 'arp_responder_test',
'enable_dhcp': True}
'cidr': '10.10.10.0/24',
'gateway_ip': '10.10.10.1',
'ip_version': 4,
'name': 'arp_responder_test',
'enable_dhcp': True}
subnet = subnet_obj.create(subnet)
flows_before = self._get_arp_table_flows()
@ -81,7 +81,7 @@ class ArpResponderTest(test_base.DFTestBase):
vm.close()
time.sleep(test_const.DEFAULT_RESOURCE_READY_TIMEOUT)
flows_delta = [flow for flow in flows_middle
if flow not in flows_before]
if flow not in flows_before]
self.assertIsNotNone(
self._find_arp_responder_flow_by_ip(flows_delta, ip)
)
@ -120,7 +120,7 @@ class ICMPResponderTest(test_base.DFTestBase):
ovs_flows_parser = test_utils.OvsFlowsParser()
flows = ovs_flows_parser.dump(self.integration_bridge)
flows = [flow for flow in flows
if flow['table'] == str(const.L2_LOOKUP_TABLE)]
if flow['table'] == str(const.L2_LOOKUP_TABLE)]
return flows
def _check_icmp_flow_removal(self, ip):
@ -143,11 +143,11 @@ class ICMPResponderTest(test_base.DFTestBase):
))
subnet = {'network_id': network_id,
'cidr': '10.10.10.0/24',
'gateway_ip': '10.10.10.1',
'ip_version': 4,
'name': 'arp_responder_test',
'enable_dhcp': True}
'cidr': '10.10.10.0/24',
'gateway_ip': '10.10.10.1',
'ip_version': 4,
'name': 'arp_responder_test',
'enable_dhcp': True}
subnet_id = subnet_obj.create(subnet)
flows_before = self._get_l2_lookup_table_flows()
@ -177,7 +177,7 @@ class ICMPResponderTest(test_base.DFTestBase):
time.sleep(test_const.DEFAULT_RESOURCE_READY_TIMEOUT)
flows_delta = [flow for flow in flows_middle
if flow not in flows_before]
if flow not in flows_before]
self.assertIsNotNone(
self._find_icmp_responder_flow_by_ip(flows_delta, router_ip)

View File

@ -37,7 +37,7 @@ class TestRyuBaseApp(test_base.DFTestBase):
self.addCleanup(app_mgr.uninstantiate, self.open_flow_app.name)
test_controller = ('tcp:' + cfg.CONF.df_ryu.of_listen_address + ':' +
str(cfg.CONF.df_ryu.of_listen_port + 1))
str(cfg.CONF.df_ryu.of_listen_port + 1))
self.vswitch_api = vswitch_impl.OvsApi(self.mgt_ip)
self.vswitch_api.initialize(self.nb_api)
cur_controllers = self.vswitch_api.ovsdb.get_controller(

View File

@ -85,15 +85,15 @@ fake_logic_router1.inner_obj = {
"id": "fake_router_port1"}]}
fake_lswitch_default_subnets = [{"dhcp_ip": "10.0.0.2",
"name": "private-subnet",
"enable_dhcp": True,
"lswitch": "fake_switch1",
"dns_nameservers": [],
"topic": "fake_tenant1",
"gateway_ip": "10.0.0.1",
"host_routes": [],
"cidr": "10.0.0.0/24",
"id": "fake_subnet1"}]
"name": "private-subnet",
"enable_dhcp": True,
"lswitch": "fake_switch1",
"dns_nameservers": [],
"topic": "fake_tenant1",
"gateway_ip": "10.0.0.1",
"host_routes": [],
"cidr": "10.0.0.0/24",
"id": "fake_subnet1"}]
def make_fake_logic_switch(
@ -134,14 +134,14 @@ fake_logic_switch1 = make_fake_logic_switch(
id='fake_switch1')
external_switch1_subnets = [{"name": "public-subnet",
"enable_dhcp": False,
"lswitch": "fake_external_switch1",
"dns_nameservers": [],
"topic": "fake_tenant1",
"gateway_ip": "172.24.4.1",
"host_routes": [],
"cidr": "172.24.4.0/24",
"id": "fake_external_subnet1"}]
"enable_dhcp": False,
"lswitch": "fake_external_switch1",
"dns_nameservers": [],
"topic": "fake_tenant1",
"gateway_ip": "172.24.4.1",
"host_routes": [],
"cidr": "172.24.4.0/24",
"id": "fake_external_subnet1"}]
fake_external_switch1 = make_fake_logic_switch(

View File

@ -36,8 +36,9 @@ class TestClassifierApp(test_app_base.DFAppTestBase):
self.app = self.open_flow_app.dispatcher.apps[0]
def test_classifier_for_vlan_port(self):
fake_local_vlan_port = make_fake_local_port(network_type='vlan',
lswitch='fake_vlan_switch1')
fake_local_vlan_port = make_fake_local_port(
network_type='vlan',
lswitch='fake_vlan_switch1')
port_key = fake_local_vlan_port.get_unique_key()
match = self.app.parser.OFPMatch(reg7=port_key)
self.controller.update_lport(fake_local_vlan_port)

View File

@ -71,7 +71,7 @@ class TestRetryFunc(tests_base.BaseTestCase):
# wrapped function), then that exception is reraised but not logged.
@utils.wrap_func_retry(max_retries=5,
_errors=[ValueError])
_errors=[ValueError])
def some_method():
raise AttributeError('test')

View File

@ -94,13 +94,13 @@ class TestDHCPApp(test_app_base.DFAppTestBase):
fake_dhcp_packet = mock.Mock()
fake_dhcp_packet.options.option_list = (
[Option(dhcp.DHCP_MESSAGE_TYPE_OPT, 'a'),
Option(dhcp.DHCP_HOST_NAME_OPT, 'b')])
Option(dhcp.DHCP_HOST_NAME_OPT, 'b')])
a_unicode = ord('a')
opt_value = self.app._get_dhcp_message_type_opt(fake_dhcp_packet)
self.assertEqual(a_unicode, opt_value)
fake_dhcp_packet.options.option_list = (
[Option(dhcp.DHCP_END_OPT, 'a'),
Option(dhcp.DHCP_HOST_NAME_OPT, 'b')])
Option(dhcp.DHCP_HOST_NAME_OPT, 'b')])
opt_value2 = self.app._get_dhcp_message_type_opt(fake_dhcp_packet)
self.assertIsNone(opt_value2)
@ -132,7 +132,7 @@ class TestDHCPApp(test_app_base.DFAppTestBase):
# test case: lport has valid ip
self.app.remove_local_port(fake_lport)
self.assertNotIn(fake_lport.get_id(),
self.app.subnet_vm_port_map[subnet])
self.app.subnet_vm_port_map[subnet])
self.app._uninstall_dhcp_flow_for_vm_port.assert_called_once()
def test_remove_logical_switch(self):

View File

@ -48,12 +48,11 @@ commands = sphinx-build -W -b html doc/source doc/build/html
[flake8]
# E126 continuation line over-indented for hanging indent
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
# H404 multi line docstring should start with a summary
# H405 multi line docstring summary not separated with an empty line
# N530 Direct neutron imports not allowed
ignore = E126,E128,E129,H404,H405,N530
ignore = E126,E129,H404,H405,N530
# H904: Delay string interpolations at logging calls
enable-extensions=H904
show-source = true