Adding name to health monitor and member
1) Refactor to have a new name mixin to unify names in Octavia 2) Add name to the two tables and have migration scripts Change-Id: Ic60b9c8c28f7a99de2d36c98a28afac830b24947 Closes-Bug:#1635731 Closes-Bug:#1635740
This commit is contained in:
parent
3ffcbeab64
commit
2766174c2b
@ -195,7 +195,7 @@ class HealthMonitor(BaseDataModel):
|
||||
delay=None, timeout=None, fall_threshold=None,
|
||||
rise_threshold=None, http_method=None, url_path=None,
|
||||
expected_codes=None, enabled=None, pool=None,
|
||||
provisioning_status=None):
|
||||
provisioning_status=None, name=None):
|
||||
self.id = id
|
||||
self.project_id = project_id
|
||||
self.pool_id = pool_id
|
||||
@ -210,6 +210,7 @@ class HealthMonitor(BaseDataModel):
|
||||
self.enabled = enabled
|
||||
self.pool = pool
|
||||
self.provisioning_status = provisioning_status
|
||||
self.name = name
|
||||
|
||||
def delete(self):
|
||||
self.pool.health_monitor = None
|
||||
@ -284,7 +285,8 @@ class Member(BaseDataModel):
|
||||
def __init__(self, id=None, project_id=None, pool_id=None, ip_address=None,
|
||||
protocol_port=None, weight=None, enabled=None,
|
||||
subnet_id=None, operating_status=None, pool=None,
|
||||
created_at=None, updated_at=None, provisioning_status=None):
|
||||
created_at=None, updated_at=None, provisioning_status=None,
|
||||
name=None):
|
||||
self.id = id
|
||||
self.project_id = project_id
|
||||
self.pool_id = pool_id
|
||||
@ -298,6 +300,7 @@ class Member(BaseDataModel):
|
||||
self.created_at = created_at
|
||||
self.updated_at = updated_at
|
||||
self.provisioning_status = provisioning_status
|
||||
self.name = name
|
||||
|
||||
def delete(self):
|
||||
for mem in self.pool.members:
|
||||
|
@ -118,4 +118,9 @@ class ProjectMixin(object):
|
||||
project_id = sa.Column(sa.String(36))
|
||||
|
||||
|
||||
class NameMixin(object):
|
||||
"""Name mixin to add to classes which need a name."""
|
||||
name = sa.Column(sa.String(255), nullable=True)
|
||||
|
||||
|
||||
BASE = declarative.declarative_base(cls=OctaviaBase)
|
||||
|
@ -0,0 +1,39 @@
|
||||
# Copyright 2016 Rackspace
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""adding name column to member and health monitor
|
||||
|
||||
Revision ID: 44a2414dd683
|
||||
Revises: c11292016060
|
||||
Create Date: 2016-12-19 13:14:58.879793
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '44a2414dd683'
|
||||
down_revision = 'c11292016060'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
tables = ['member', 'health_monitor']
|
||||
|
||||
|
||||
def upgrade():
|
||||
for table in tables:
|
||||
op.add_column(
|
||||
table,
|
||||
sa.Column(u'name', sa.String(255), nullable=True)
|
||||
)
|
@ -141,7 +141,7 @@ class ListenerStatistics(base_models.BASE):
|
||||
|
||||
|
||||
class Member(base_models.BASE, base_models.IdMixin, base_models.ProjectMixin,
|
||||
models.TimestampMixin):
|
||||
models.TimestampMixin, base_models.NameMixin):
|
||||
|
||||
__data_model__ = data_models.Member
|
||||
|
||||
@ -175,7 +175,8 @@ class Member(base_models.BASE, base_models.IdMixin, base_models.ProjectMixin,
|
||||
nullable=True)
|
||||
|
||||
|
||||
class HealthMonitor(base_models.BASE, base_models.ProjectMixin):
|
||||
class HealthMonitor(base_models.BASE, base_models.ProjectMixin,
|
||||
base_models.NameMixin):
|
||||
|
||||
__data_model__ = data_models.HealthMonitor
|
||||
|
||||
@ -210,13 +211,12 @@ class HealthMonitor(base_models.BASE, base_models.ProjectMixin):
|
||||
|
||||
|
||||
class Pool(base_models.BASE, base_models.IdMixin, base_models.ProjectMixin,
|
||||
models.TimestampMixin):
|
||||
models.TimestampMixin, base_models.NameMixin):
|
||||
|
||||
__data_model__ = data_models.Pool
|
||||
|
||||
__tablename__ = "pool"
|
||||
|
||||
name = sa.Column(sa.String(255), nullable=True)
|
||||
description = sa.Column(sa.String(255), nullable=True)
|
||||
protocol = sa.Column(
|
||||
sa.String(16),
|
||||
@ -265,13 +265,13 @@ class Pool(base_models.BASE, base_models.IdMixin, base_models.ProjectMixin,
|
||||
|
||||
|
||||
class LoadBalancer(base_models.BASE, base_models.IdMixin,
|
||||
base_models.ProjectMixin, models.TimestampMixin):
|
||||
base_models.ProjectMixin, models.TimestampMixin,
|
||||
base_models.NameMixin):
|
||||
|
||||
__data_model__ = data_models.LoadBalancer
|
||||
|
||||
__tablename__ = "load_balancer"
|
||||
|
||||
name = sa.Column(sa.String(255), nullable=True)
|
||||
description = sa.Column(sa.String(255), nullable=True)
|
||||
provisioning_status = sa.Column(
|
||||
sa.String(16),
|
||||
@ -338,7 +338,8 @@ class Vip(base_models.BASE):
|
||||
|
||||
|
||||
class Listener(base_models.BASE, base_models.IdMixin,
|
||||
base_models.ProjectMixin, models.TimestampMixin):
|
||||
base_models.ProjectMixin, models.TimestampMixin,
|
||||
base_models.NameMixin):
|
||||
|
||||
__data_model__ = data_models.Listener
|
||||
|
||||
@ -348,7 +349,6 @@ class Listener(base_models.BASE, base_models.IdMixin,
|
||||
name='uq_listener_load_balancer_id_protocol_port'),
|
||||
)
|
||||
|
||||
name = sa.Column(sa.String(255), nullable=True)
|
||||
description = sa.Column(sa.String(255), nullable=True)
|
||||
protocol = sa.Column(
|
||||
sa.String(16),
|
||||
@ -510,13 +510,12 @@ class L7Rule(base_models.BASE, base_models.IdMixin):
|
||||
nullable=True)
|
||||
|
||||
|
||||
class L7Policy(base_models.BASE, base_models.IdMixin):
|
||||
class L7Policy(base_models.BASE, base_models.IdMixin, base_models.NameMixin):
|
||||
|
||||
__data_model__ = data_models.L7Policy
|
||||
|
||||
__tablename__ = "l7policy"
|
||||
|
||||
name = sa.Column(sa.String(255), nullable=True)
|
||||
description = sa.Column(sa.String(255), nullable=True)
|
||||
listener_id = sa.Column(
|
||||
sa.String(36),
|
||||
|
Loading…
Reference in New Issue
Block a user