Big pep8 cleanup

This commit is contained in:
Matt Dietz
2013-02-28 18:30:55 +00:00
parent 0c30c8cc57
commit ada0452654
7 changed files with 119 additions and 121 deletions

View File

@@ -69,7 +69,8 @@ class TagAssociation(BASEV2, HasId):
class Tag(BASEV2, HasId, HasTenant): class Tag(BASEV2, HasId, HasTenant):
__tablename__ = "quark_tags" __tablename__ = "quark_tags"
association_uuid = sa.Column(sa.String(36), association_uuid = sa.Column(sa.String(36),
sa.ForeignKey(TagAssociation.id), nullable=False) sa.ForeignKey(TagAssociation.id),
nullable=False)
tag = sa.Column(sa.String(255), nullable=False) tag = sa.Column(sa.String(255), nullable=False)
parent = associationproxy.association_proxy("association", "parent") parent = associationproxy.association_proxy("association", "parent")
@@ -208,8 +209,8 @@ class Port(BASEV2, CreatedAt, HasId, HasTenant):
class MacAddress(BASEV2, CreatedAt, HasTenant): class MacAddress(BASEV2, CreatedAt, HasTenant):
__tablename__ = "quark_mac_addresses" __tablename__ = "quark_mac_addresses"
address = sa.Column(sa.BigInteger(), primary_key=True) address = sa.Column(sa.BigInteger(), primary_key=True)
mac_address_range_id = sa.Column(sa.String(36), mac_address_range_id = sa.Column(
sa.ForeignKey("quark_mac_address_ranges.id"), sa.String(36), sa.ForeignKey("quark_mac_address_ranges.id"),
nullable=False) nullable=False)
deallocated = sa.Column(sa.Boolean()) deallocated = sa.Column(sa.Boolean())
deallocated_at = sa.Column(sa.DateTime()) deallocated_at = sa.Column(sa.DateTime())

View File

@@ -224,8 +224,7 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
LOG.info("get_subnet %s for tenant %s with fields %s" % LOG.info("get_subnet %s for tenant %s with fields %s" %
(id, context.tenant_id, fields)) (id, context.tenant_id, fields))
subnet = context.session.query(models.Subnet).\ subnet = context.session.query(models.Subnet).\
filter(models.Subnet.id == id).\ filter(models.Subnet.id == id).first()
first()
if not subnet: if not subnet:
raise exceptions.SubnetNotFound(subnet_id=id) raise exceptions.SubnetNotFound(subnet_id=id)
@@ -484,10 +483,8 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
if not net: if not net:
raise exceptions.NetworkNotFound(net_id=net_id) raise exceptions.NetworkNotFound(net_id=net_id)
addresses = self.ipam_driver.allocate_ip_address(session, addresses = self.ipam_driver.allocate_ip_address(
net_id, session, net_id, port_id, self.ipam_reuse_after)
port_id,
self.ipam_reuse_after)
mac = self.ipam_driver.allocate_mac_address(session, mac = self.ipam_driver.allocate_mac_address(session,
net_id, net_id,
port_id, port_id,
@@ -642,9 +639,9 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
backend_key = port["backend_key"] backend_key = port["backend_key"]
self.ipam_driver.deallocate_mac_address(session, self.ipam_driver.deallocate_mac_address(session,
port["mac_address"],) port["mac_address"])
self.ipam_driver.deallocate_ip_address(session, id, self.ipam_driver.deallocate_ip_address(
ipam_reuse_after=self.ipam_reuse_after) session, id, ipam_reuse_after=self.ipam_reuse_after)
session.delete(port) session.delete(port)
self.net_driver.delete_port(context, backend_key) self.net_driver.delete_port(context, backend_key)
@@ -657,7 +654,7 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
LOG.info("create_mac_address_range for tenant %s" % context.tenant_id) LOG.info("create_mac_address_range for tenant %s" % context.tenant_id)
new_range = models.MacAddressRange() new_range = models.MacAddressRange()
cidr = mac_range["mac_address_range"]["cidr"] cidr = mac_range["mac_address_range"]["cidr"]
cidr, first_address, last_address = self._to_mac(cidr) cidr, first_address, last_address = self.bto_mac_range(cidr)
new_range["cidr"] = cidr new_range["cidr"] = cidr
new_range["first_address"] = first_address new_range["first_address"] = first_address
new_range["last_address"] = last_address new_range["last_address"] = last_address
@@ -666,7 +663,7 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
context.session.flush() context.session.flush()
return self._make_mac_range_dict(new_range) return self._make_mac_range_dict(new_range)
def _to_mac(self, val): def _to_mac_range(self, val):
cidr_parts = val.split("/") cidr_parts = val.split("/")
prefix = cidr_parts[0] prefix = cidr_parts[0]
prefix = prefix.replace(':', '') prefix = prefix.replace(':', '')