diff --git a/TODO b/TODO index 1a1da56..2601449 100644 --- a/TODO +++ b/TODO @@ -9,9 +9,6 @@ CRUD IP Allocations * CRUD MacAddressRanges * AIC doesn't support creating multiple switches on the same network. i.e. if we expand past the port count per switch, undefined -We may want to override the existing sessionmaker. Things it chooses to do, like disabling expiration and autocommiting, are discouraged by the docs -Implementation of Zope Interfaces to abstract base class all the things, as well as represent pluggable all the things - Later: Maybe implement a straight passthrough driver for testing and debugging purposes diff --git a/quark/db/models.py b/quark/db/models.py index 62bf05d..e7c5175 100644 --- a/quark/db/models.py +++ b/quark/db/models.py @@ -216,18 +216,6 @@ class Port(BASEV2, HasId, HasTenant): ip_addresses = orm.relationship(IPAddress, backref=orm.backref("ports")) -class PortIPAddressAssociation(BASEV2, HasId): - __tablename__ = "quark_port_ip_address_associations" - port_id = sa.Column(sa.String(36), sa.ForeignKey("quark_ports.id"), - nullable=False) - ip_address_id = sa.Column(sa.String(36), - sa.ForeignKey("quark_ip_addresses.id"), - nullable=False) - port = orm.relationship(Port, uselist=False, backref="association") - ip_address = orm.relationship(IPAddress, uselist=False, - backref="association") - - class MacAddress(BASEV2, HasTenant): __tablename__ = "quark_mac_addresses" address = sa.Column(sa.BigInteger(), primary_key=True) @@ -236,6 +224,7 @@ class MacAddress(BASEV2, HasTenant): nullable=False) deallocated = sa.Column(sa.Boolean()) deallocated_at = sa.Column(sa.DateTime()) + orm.relationship(Port, backref="mac_address") class MacAddressRange(BASEV2, HasId): @@ -243,7 +232,6 @@ class MacAddressRange(BASEV2, HasId): cidr = sa.Column(sa.String(255), nullable=False) first_address = sa.Column(sa.BigInteger(), nullable=False) last_address = sa.Column(sa.BigInteger(), nullable=False) - mac_addresses = orm.relationship(MacAddress, backref="mac_address_range") class Network(BASEV2, HasTenant, HasId): diff --git a/quark/plugin.py b/quark/plugin.py index 48c9ae6..c4de3c7 100644 --- a/quark/plugin.py +++ b/quark/plugin.py @@ -490,7 +490,6 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2): if k in port["port"]: port["port"].pop(k) - addresses = [] with session.begin(): port_id = uuidutils.generate_uuid() net_id = port["port"]["network_id"] @@ -523,15 +522,10 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2): new_port["mac_address"] = mac["address"] new_port["tenant_id"] = context.tenant_id - session.add(new_port) + for a in addresses: + session.add(a) session.add(mac) - for addr in addresses: - addr["port"] = new_port - assoc = models.PortIPAddressAssociation() - assoc["port"] = new_port - assoc["ip_address"] = addr - session.add(addr) - session.add(assoc) + session.add(new_port) new_port["mac_address"] = str(netaddr.EUI(new_port["mac_address"], dialect=netaddr.mac_unix))