NSXv - add timestamps to NSXv driver tables

Patch adds create and update to NSXv plugin's database tables.
This should help with error tracking, debugging etc.

Change-Id: Ibe158555bcfe16b3c764e5cfaf1066697dd8a6a0
This commit is contained in:
Kobi Samoray 2016-07-06 13:57:22 +03:00
parent 6a0228be11
commit 4ed02f2d6c
5 changed files with 140 additions and 44 deletions

View File

@ -1 +1 @@
5e564e781d77
aede17d51d0f

View File

@ -0,0 +1,86 @@
# Copyright 2016 VMware, Inc.
# All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""add timestamp
Revision ID: aede17d51d0f
Revises: 5e564e781d77
Create Date: 2016-04-21 10:45:32.278433
"""
# revision identifiers, used by Alembic.
revision = 'aede17d51d0f'
down_revision = '5e564e781d77'
from alembic import op
import sqlalchemy as sa
tables = [
'nsxv_router_bindings',
'nsxv_edge_vnic_bindings',
'nsxv_edge_dhcp_static_bindings',
'nsxv_internal_networks',
'nsxv_internal_edges',
'nsxv_security_group_section_mappings',
'nsxv_rule_mappings',
'nsxv_port_vnic_mappings',
'nsxv_router_ext_attributes',
'nsxv_tz_network_bindings',
'nsxv_port_index_mappings',
'nsxv_firewall_rule_bindings',
'nsxv_spoofguard_policy_network_mappings',
'nsxv_vdr_dhcp_bindings',
'nsxv_lbaas_loadbalancer_bindings',
'nsxv_lbaas_listener_bindings',
'nsxv_lbaas_pool_bindings',
'nsxv_lbaas_monitor_bindings',
'nsxv_lbaas_certificate_bindings',
'nsxv_subnet_ext_attributes',
'tz_network_bindings',
'neutron_nsx_network_mappings',
'neutron_nsx_security_group_mappings',
'neutron_nsx_firewall_section_mappings',
'neutron_nsx_rule_mappings',
'neutron_nsx_port_mappings',
'neutron_nsx_router_mappings',
'neutron_nsx_service_bindings',
'neutron_nsx_dhcp_bindings',
'multi_provider_networks',
'networkconnections',
'networkgatewaydevicereferences',
'networkgatewaydevices',
'networkgateways',
'maclearningstates',
'lsn_port',
'lsn',
'qosqueues',
'portqueuemappings',
'networkqueuemappings',
'nsx_l2gw_connection_mappings',
'neutron_nsx_qos_policy_mappings',
'vcns_router_bindings']
def upgrade():
for table in tables:
op.add_column(
table,
sa.Column(u'created_at', sa.DateTime(), nullable=True)
)
op.add_column(
table,
sa.Column(u'updated_at', sa.DateTime(), nullable=True)
)

View File

@ -25,11 +25,12 @@ from sqlalchemy import sql
from neutron.db import model_base
from neutron.db import models_v2
from oslo_db.sqlalchemy import models
from vmware_nsx.common import nsx_constants
class TzNetworkBinding(model_base.BASEV2):
class TzNetworkBinding(model_base.BASEV2, models.TimestampMixin):
"""Represents a binding of a virtual network with a transport zone.
This model class associates a Neutron network with a transport zone;
@ -64,7 +65,7 @@ class TzNetworkBinding(model_base.BASEV2):
self.vlan_id)
class NeutronNsxNetworkMapping(model_base.BASEV2):
class NeutronNsxNetworkMapping(model_base.BASEV2, models.TimestampMixin):
"""Maps neutron network identifiers to NSX identifiers.
Because of chained logical switches more than one mapping might exist
@ -83,7 +84,7 @@ class NeutronNsxNetworkMapping(model_base.BASEV2):
dvs_id = sa.Column(sa.String(36), nullable=True)
class NeutronNsxSecurityGroupMapping(model_base.BASEV2):
class NeutronNsxSecurityGroupMapping(model_base.BASEV2, models.TimestampMixin):
"""Backend mappings for Neutron Security Group identifiers.
This class maps a neutron security group identifier to the corresponding
@ -98,7 +99,8 @@ class NeutronNsxSecurityGroupMapping(model_base.BASEV2):
nsx_id = sa.Column(sa.String(36), primary_key=True)
class NeutronNsxFirewallSectionMapping(model_base.BASEV2):
class NeutronNsxFirewallSectionMapping(model_base.BASEV2,
models.TimestampMixin):
"""Backend mappings for Neutron Security-group associated fw sections."""
__tablename__ = 'neutron_nsx_firewall_section_mappings'
@ -110,7 +112,7 @@ class NeutronNsxFirewallSectionMapping(model_base.BASEV2):
nsx_id = sa.Column(sa.String(36), nullable=False)
class NeutronNsxRuleMapping(model_base.BASEV2):
class NeutronNsxRuleMapping(model_base.BASEV2, models.TimestampMixin):
"""Backend mappings for firewall rules.
This class maps a neutron security group rule with NSX firewall rule.
@ -126,7 +128,7 @@ class NeutronNsxRuleMapping(model_base.BASEV2):
nsx_id = sa.Column(sa.String(36), nullable=False)
class NeutronNsxPortMapping(model_base.BASEV2):
class NeutronNsxPortMapping(model_base.BASEV2, models.TimestampMixin):
"""Represents the mapping between neutron and nsx port uuids."""
__tablename__ = 'neutron_nsx_port_mappings'
@ -142,7 +144,7 @@ class NeutronNsxPortMapping(model_base.BASEV2):
self.nsx_port_id = nsx_port_id
class NeutronNsxRouterMapping(model_base.BASEV2):
class NeutronNsxRouterMapping(model_base.BASEV2, models.TimestampMixin):
"""Maps neutron router identifiers to NSX identifiers."""
__tablename__ = 'neutron_nsx_router_mappings'
neutron_id = sa.Column(sa.String(36),
@ -151,7 +153,7 @@ class NeutronNsxRouterMapping(model_base.BASEV2):
nsx_id = sa.Column(sa.String(36))
class NeutronNsxServiceBinding(model_base.BASEV2):
class NeutronNsxServiceBinding(model_base.BASEV2, models.TimestampMixin):
"""Represents a binding of a Neutron network with enabled NSX services."""
__tablename__ = 'neutron_nsx_service_bindings'
network_id = sa.Column(sa.String(36),
@ -165,7 +167,7 @@ class NeutronNsxServiceBinding(model_base.BASEV2):
nsx_service_id = sa.Column(sa.String(36), nullable=False)
class NeutronNsxDhcpBinding(model_base.BASEV2):
class NeutronNsxDhcpBinding(model_base.BASEV2, models.TimestampMixin):
"""Represents a binding of a Neutron port with DHCP address binding."""
__tablename__ = 'neutron_nsx_dhcp_bindings'
port_id = sa.Column(sa.String(36),
@ -177,7 +179,7 @@ class NeutronNsxDhcpBinding(model_base.BASEV2):
nsx_binding_id = sa.Column(sa.String(36), nullable=False, primary_key=True)
class MultiProviderNetworks(model_base.BASEV2):
class MultiProviderNetworks(model_base.BASEV2, models.TimestampMixin):
"""Networks provisioned through multiprovider extension."""
__tablename__ = 'multi_provider_networks'
@ -189,7 +191,8 @@ class MultiProviderNetworks(model_base.BASEV2):
self.network_id = network_id
class NetworkConnection(model_base.BASEV2, models_v2.HasTenant):
class NetworkConnection(model_base.BASEV2, models_v2.HasTenant,
models.TimestampMixin):
"""Defines a connection between a network gateway and a network."""
# We use port_id as the primary key as one can connect a gateway
# to a network in multiple ways (and we cannot use the same port form
@ -214,7 +217,7 @@ class NetworkConnection(model_base.BASEV2, models_v2.HasTenant):
primary_key=True)
class NetworkGatewayDeviceReference(model_base.BASEV2):
class NetworkGatewayDeviceReference(model_base.BASEV2, models.TimestampMixin):
id = sa.Column(sa.String(36), primary_key=True)
network_gateway_id = sa.Column(sa.String(36),
sa.ForeignKey('networkgateways.id',
@ -224,7 +227,7 @@ class NetworkGatewayDeviceReference(model_base.BASEV2):
class NetworkGatewayDevice(model_base.BASEV2, models_v2.HasId,
models_v2.HasTenant):
models_v2.HasTenant, models.TimestampMixin):
nsx_id = sa.Column(sa.String(36))
# Optional name for the gateway device
name = sa.Column(sa.String(255))
@ -238,7 +241,7 @@ class NetworkGatewayDevice(model_base.BASEV2, models_v2.HasId,
class NetworkGateway(model_base.BASEV2, models_v2.HasId,
models_v2.HasTenant):
models_v2.HasTenant, models.TimestampMixin):
"""Defines the data model for a network gateway."""
name = sa.Column(sa.String(255))
default = sa.Column(sa.Boolean())
@ -248,7 +251,7 @@ class NetworkGateway(model_base.BASEV2, models_v2.HasId,
network_connections = orm.relationship(NetworkConnection, lazy='joined')
class MacLearningState(model_base.BASEV2):
class MacLearningState(model_base.BASEV2, models.TimestampMixin):
port_id = sa.Column(sa.String(36),
sa.ForeignKey('ports.id', ondelete="CASCADE"),
@ -263,7 +266,7 @@ class MacLearningState(model_base.BASEV2):
uselist=False, cascade='delete'))
class LsnPort(models_v2.model_base.BASEV2):
class LsnPort(models_v2.model_base.BASEV2, models.TimestampMixin):
__tablename__ = 'lsn_port'
@ -282,7 +285,7 @@ class LsnPort(models_v2.model_base.BASEV2):
self.mac_addr = mac_address
class Lsn(models_v2.model_base.BASEV2):
class Lsn(models_v2.model_base.BASEV2, models.TimestampMixin):
__tablename__ = 'lsn'
lsn_id = sa.Column(sa.String(36), primary_key=True)
@ -293,7 +296,8 @@ class Lsn(models_v2.model_base.BASEV2):
self.lsn_id = lsn_id
class QoSQueue(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
class QoSQueue(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant,
models.TimestampMixin):
name = sa.Column(sa.String(255))
default = sa.Column(sa.Boolean, default=False, server_default=sql.false())
min = sa.Column(sa.Integer, nullable=False)
@ -303,7 +307,7 @@ class QoSQueue(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
dscp = sa.Column(sa.Integer)
class PortQueueMapping(model_base.BASEV2):
class PortQueueMapping(model_base.BASEV2, models.TimestampMixin):
port_id = sa.Column(sa.String(36),
sa.ForeignKey("ports.id", ondelete="CASCADE"),
primary_key=True)
@ -319,7 +323,7 @@ class PortQueueMapping(model_base.BASEV2):
cascade='delete', lazy='joined'))
class NetworkQueueMapping(model_base.BASEV2):
class NetworkQueueMapping(model_base.BASEV2, models.TimestampMixin):
network_id = sa.Column(sa.String(36),
sa.ForeignKey("networks.id", ondelete="CASCADE"),
primary_key=True)
@ -335,7 +339,7 @@ class NetworkQueueMapping(model_base.BASEV2):
cascade='delete', lazy='joined'))
class NsxL2GWConnectionMapping(model_base.BASEV2):
class NsxL2GWConnectionMapping(model_base.BASEV2, models.TimestampMixin):
"""Define a mapping between L2 gateway connection and bridge endpoint."""
__tablename__ = 'nsx_l2gw_connection_mappings'
connection_id = sa.Column(sa.String(36),
@ -347,7 +351,7 @@ class NsxL2GWConnectionMapping(model_base.BASEV2):
bridge_endpoint_id = sa.Column(sa.String(36), nullable=False)
class QosPolicySwitchProfile(model_base.BASEV2):
class QosPolicySwitchProfile(model_base.BASEV2, models.TimestampMixin):
# Maps neutron qos policy identifiers to NSX-V3 switch profile identifiers
__tablename__ = 'neutron_nsx_qos_policy_mappings'
qos_policy_id = sa.Column(sa.String(36),

View File

@ -21,11 +21,13 @@ from sqlalchemy import orm
from neutron.db import l3_db
from neutron.db import model_base
from neutron.db import models_v2
from oslo_db.sqlalchemy import models
from vmware_nsx.common import nsxv_constants
class NsxvRouterBinding(model_base.BASEV2, models_v2.HasStatusDescription):
class NsxvRouterBinding(model_base.BASEV2, models_v2.HasStatusDescription,
models.TimestampMixin):
"""Represents the mapping between neutron router and vShield Edge."""
__tablename__ = 'nsxv_router_bindings'
@ -52,7 +54,7 @@ class NsxvRouterBinding(model_base.BASEV2, models_v2.HasStatusDescription):
nullable=True)
class NsxvEdgeVnicBinding(model_base.BASEV2):
class NsxvEdgeVnicBinding(model_base.BASEV2, models.TimestampMixin):
"""Represents mapping between vShield Edge vnic and neutron netowrk."""
__tablename__ = 'nsxv_edge_vnic_bindings'
@ -66,7 +68,7 @@ class NsxvEdgeVnicBinding(model_base.BASEV2):
network_id = sa.Column(sa.String(36), nullable=True)
class NsxvEdgeDhcpStaticBinding(model_base.BASEV2):
class NsxvEdgeDhcpStaticBinding(model_base.BASEV2, models.TimestampMixin):
"""Represents mapping between mac addr and bindingId."""
__tablename__ = 'nsxv_edge_dhcp_static_bindings'
@ -76,7 +78,7 @@ class NsxvEdgeDhcpStaticBinding(model_base.BASEV2):
binding_id = sa.Column(sa.String(36), nullable=False)
class NsxvInternalNetworks(model_base.BASEV2):
class NsxvInternalNetworks(model_base.BASEV2, models.TimestampMixin):
"""Represents internal networks between NSXV plugin elements."""
__tablename__ = 'nsxv_internal_networks'
@ -90,7 +92,7 @@ class NsxvInternalNetworks(model_base.BASEV2):
nullable=True)
class NsxvInternalEdges(model_base.BASEV2):
class NsxvInternalEdges(model_base.BASEV2, models.TimestampMixin):
"""Represents internal Edge appliances for NSXV plugin operations."""
__tablename__ = 'nsxv_internal_edges'
@ -102,7 +104,8 @@ class NsxvInternalEdges(model_base.BASEV2):
name='nsxv_internal_edges_purpose'))
class NsxvSecurityGroupSectionMapping(model_base.BASEV2):
class NsxvSecurityGroupSectionMapping(model_base.BASEV2,
models.TimestampMixin):
"""Backend mappings for Neutron Rule Sections.
This class maps a neutron security group identifier to the corresponding
@ -117,7 +120,7 @@ class NsxvSecurityGroupSectionMapping(model_base.BASEV2):
ip_section_id = sa.Column(sa.String(100))
class NsxvRuleMapping(model_base.BASEV2):
class NsxvRuleMapping(model_base.BASEV2, models.TimestampMixin):
"""Backend mappings for Neutron Rule Sections.
This class maps a neutron security group identifier to the corresponding
@ -133,7 +136,7 @@ class NsxvRuleMapping(model_base.BASEV2):
nsx_rule_id = sa.Column(sa.String(36), primary_key=True)
class NsxvPortVnicMapping(model_base.BASEV2):
class NsxvPortVnicMapping(model_base.BASEV2, models.TimestampMixin):
"""Maps neutron port to NSXv VM Vnic Id."""
__tablename__ = 'nsxv_port_vnic_mappings'
@ -144,7 +147,7 @@ class NsxvPortVnicMapping(model_base.BASEV2):
nsx_id = sa.Column(sa.String(42), primary_key=True)
class NsxvRouterExtAttributes(model_base.BASEV2):
class NsxvRouterExtAttributes(model_base.BASEV2, models.TimestampMixin):
"""Router attributes managed by NSX plugin extensions."""
__tablename__ = 'nsxv_router_ext_attributes'
@ -166,7 +169,7 @@ class NsxvRouterExtAttributes(model_base.BASEV2):
uselist=False, cascade='delete'))
class NsxvTzNetworkBinding(model_base.BASEV2):
class NsxvTzNetworkBinding(model_base.BASEV2, models.TimestampMixin):
"""Represents a binding of a virtual network with a transport zone.
This model class associates a Neutron network with a transport zone;
@ -199,7 +202,7 @@ class NsxvTzNetworkBinding(model_base.BASEV2):
self.vlan_id)
class NsxvPortIndexMapping(model_base.BASEV2):
class NsxvPortIndexMapping(model_base.BASEV2, models.TimestampMixin):
"""Associates attached Neutron ports with the instance VNic index."""
__tablename__ = 'nsxv_port_index_mappings'
@ -220,7 +223,7 @@ class NsxvPortIndexMapping(model_base.BASEV2):
uselist=False, cascade='delete'))
class NsxvEdgeFirewallRuleBinding(model_base.BASEV2):
class NsxvEdgeFirewallRuleBinding(model_base.BASEV2, models.TimestampMixin):
"""Mapping between firewall rule and edge firewall rule_id."""
__tablename__ = 'nsxv_firewall_rule_bindings'
@ -231,7 +234,8 @@ class NsxvEdgeFirewallRuleBinding(model_base.BASEV2):
rule_vse_id = sa.Column(sa.String(36))
class NsxvSpoofGuardPolicyNetworkMapping(model_base.BASEV2):
class NsxvSpoofGuardPolicyNetworkMapping(model_base.BASEV2,
models.TimestampMixin):
"""Mapping between SpoofGuard and neutron networks"""
__tablename__ = 'nsxv_spoofguard_policy_network_mappings'
@ -243,7 +247,7 @@ class NsxvSpoofGuardPolicyNetworkMapping(model_base.BASEV2):
policy_id = sa.Column(sa.String(36), nullable=False)
class NsxvVdrDhcpBinding(model_base.BASEV2):
class NsxvVdrDhcpBinding(model_base.BASEV2, models.TimestampMixin):
"""1:1 mapping between VDR and a DHCP Edge."""
__tablename__ = 'nsxv_vdr_dhcp_bindings'
@ -258,7 +262,7 @@ class NsxvVdrDhcpBinding(model_base.BASEV2):
model_base.BASEV2.__table_args__)
class NsxvLbaasLoadbalancerBinding(model_base.BASEV2):
class NsxvLbaasLoadbalancerBinding(model_base.BASEV2, models.TimestampMixin):
"""Mapping between Edge LB and LBaaSv2"""
__tablename__ = 'nsxv_lbaas_loadbalancer_bindings'
@ -269,7 +273,7 @@ class NsxvLbaasLoadbalancerBinding(model_base.BASEV2):
vip_address = sa.Column(sa.String(36), nullable=False)
class NsxvLbaasListenerBinding(model_base.BASEV2):
class NsxvLbaasListenerBinding(model_base.BASEV2, models.TimestampMixin):
"""Mapping between Edge VSE and LBaaSv2"""
__tablename__ = 'nsxv_lbaas_listener_bindings'
@ -280,7 +284,7 @@ class NsxvLbaasListenerBinding(model_base.BASEV2):
vse_id = sa.Column(sa.String(36), nullable=False)
class NsxvLbaasPoolBinding(model_base.BASEV2):
class NsxvLbaasPoolBinding(model_base.BASEV2, models.TimestampMixin):
"""Mapping between Edge Pool and LBaaSv2"""
__tablename__ = 'nsxv_lbaas_pool_bindings'
@ -291,7 +295,7 @@ class NsxvLbaasPoolBinding(model_base.BASEV2):
edge_pool_id = sa.Column(sa.String(36), nullable=False)
class NsxvLbaasMonitorBinding(model_base.BASEV2):
class NsxvLbaasMonitorBinding(model_base.BASEV2, models.TimestampMixin):
"""Mapping between Edge Monitor and LBaaSv2"""
__tablename__ = 'nsxv_lbaas_monitor_bindings'
@ -304,7 +308,7 @@ class NsxvLbaasMonitorBinding(model_base.BASEV2):
edge_mon_id = sa.Column(sa.String(36), nullable=False)
class NsxvLbaasCertificateBinding(model_base.BASEV2):
class NsxvLbaasCertificateBinding(model_base.BASEV2, models.TimestampMixin):
"""Mapping between Edge certificate and LBaaSv2 object"""
__tablename__ = 'nsxv_lbaas_certificate_bindings'
@ -314,7 +318,7 @@ class NsxvLbaasCertificateBinding(model_base.BASEV2):
edge_cert_id = sa.Column(sa.String(36), nullable=False)
class NsxvSubnetExtAttributes(model_base.BASEV2):
class NsxvSubnetExtAttributes(model_base.BASEV2, models.TimestampMixin):
"""Subnet attributes managed by NSX plugin extensions."""
__tablename__ = 'nsxv_subnet_ext_attributes'

View File

@ -19,9 +19,11 @@ import sqlalchemy as sa
from neutron.db import model_base
from neutron.db import models_v2
from oslo_db.sqlalchemy import models
class VcnsRouterBinding(model_base.BASEV2, models_v2.HasStatusDescription):
class VcnsRouterBinding(model_base.BASEV2, models_v2.HasStatusDescription,
models.TimestampMixin):
"""Represents the mapping between neutron router and vShield Edge."""
__tablename__ = 'vcns_router_bindings'