Added in the new port ip address association table but didn't remove the port_id association yet from the IP address. Deallocation needs to be reworked

This commit is contained in:
Matt Dietz 2013-03-01 23:34:14 +00:00
parent fa50eedc38
commit 7c50a8e357
3 changed files with 25 additions and 4 deletions

3
TODO
View File

@ -9,6 +9,9 @@ CRUD IP Allocations
* CRUD MacAddressRanges * 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 * 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: Later:
Maybe implement a straight passthrough driver for testing and debugging purposes Maybe implement a straight passthrough driver for testing and debugging purposes

View File

@ -210,6 +210,18 @@ class Port(BASEV2, HasId, HasTenant):
ip_addresses = orm.relationship(IPAddress, backref=orm.backref("ports")) 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): class MacAddress(BASEV2, 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)
@ -218,7 +230,6 @@ class MacAddress(BASEV2, HasTenant):
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())
orm.relationship(Port, backref="mac_address")
class MacAddressRange(BASEV2, HasId): class MacAddressRange(BASEV2, HasId):
@ -226,6 +237,7 @@ class MacAddressRange(BASEV2, HasId):
cidr = sa.Column(sa.String(255), nullable=False) cidr = sa.Column(sa.String(255), nullable=False)
first_address = sa.Column(sa.BigInteger(), nullable=False) first_address = sa.Column(sa.BigInteger(), nullable=False)
last_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): class Network(BASEV2, HasTenant, HasId):

View File

@ -489,6 +489,7 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
if k in port["port"]: if k in port["port"]:
port["port"].pop(k) port["port"].pop(k)
addresses = []
with session.begin(): with session.begin():
port_id = uuidutils.generate_uuid() port_id = uuidutils.generate_uuid()
net_id = port["port"]["network_id"] net_id = port["port"]["network_id"]
@ -520,10 +521,15 @@ class Plugin(quantum_plugin_base_v2.QuantumPluginBaseV2):
new_port["addresses"] = addresses new_port["addresses"] = addresses
new_port["mac_address"] = mac["address"] new_port["mac_address"] = mac["address"]
for a in addresses:
session.add(a)
session.add(mac)
session.add(new_port) session.add(new_port)
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)
new_port["mac_address"] = str(netaddr.EUI(new_port["mac_address"], new_port["mac_address"] = str(netaddr.EUI(new_port["mac_address"],
dialect=netaddr.mac_unix)) dialect=netaddr.mac_unix))