Merge "Adding name to health monitor and member"

This commit is contained in:
Jenkins 2016-12-20 19:06:11 +00:00 committed by Gerrit Code Review
commit d7cb74092c
4 changed files with 58 additions and 12 deletions

View File

@ -195,7 +195,7 @@ class HealthMonitor(BaseDataModel):
delay=None, timeout=None, fall_threshold=None, delay=None, timeout=None, fall_threshold=None,
rise_threshold=None, http_method=None, url_path=None, rise_threshold=None, http_method=None, url_path=None,
expected_codes=None, enabled=None, pool=None, expected_codes=None, enabled=None, pool=None,
provisioning_status=None): provisioning_status=None, name=None):
self.id = id self.id = id
self.project_id = project_id self.project_id = project_id
self.pool_id = pool_id self.pool_id = pool_id
@ -210,6 +210,7 @@ class HealthMonitor(BaseDataModel):
self.enabled = enabled self.enabled = enabled
self.pool = pool self.pool = pool
self.provisioning_status = provisioning_status self.provisioning_status = provisioning_status
self.name = name
def delete(self): def delete(self):
self.pool.health_monitor = None 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, def __init__(self, id=None, project_id=None, pool_id=None, ip_address=None,
protocol_port=None, weight=None, enabled=None, protocol_port=None, weight=None, enabled=None,
subnet_id=None, operating_status=None, pool=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.id = id
self.project_id = project_id self.project_id = project_id
self.pool_id = pool_id self.pool_id = pool_id
@ -298,6 +300,7 @@ class Member(BaseDataModel):
self.created_at = created_at self.created_at = created_at
self.updated_at = updated_at self.updated_at = updated_at
self.provisioning_status = provisioning_status self.provisioning_status = provisioning_status
self.name = name
def delete(self): def delete(self):
for mem in self.pool.members: for mem in self.pool.members:

View File

@ -118,4 +118,9 @@ class ProjectMixin(object):
project_id = sa.Column(sa.String(36)) 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) BASE = declarative.declarative_base(cls=OctaviaBase)

View File

@ -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)
)

View File

@ -141,7 +141,7 @@ class ListenerStatistics(base_models.BASE):
class Member(base_models.BASE, base_models.IdMixin, base_models.ProjectMixin, class Member(base_models.BASE, base_models.IdMixin, base_models.ProjectMixin,
models.TimestampMixin): models.TimestampMixin, base_models.NameMixin):
__data_model__ = data_models.Member __data_model__ = data_models.Member
@ -175,7 +175,8 @@ class Member(base_models.BASE, base_models.IdMixin, base_models.ProjectMixin,
nullable=True) 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 __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, class Pool(base_models.BASE, base_models.IdMixin, base_models.ProjectMixin,
models.TimestampMixin): models.TimestampMixin, base_models.NameMixin):
__data_model__ = data_models.Pool __data_model__ = data_models.Pool
__tablename__ = "pool" __tablename__ = "pool"
name = sa.Column(sa.String(255), nullable=True)
description = sa.Column(sa.String(255), nullable=True) description = sa.Column(sa.String(255), nullable=True)
protocol = sa.Column( protocol = sa.Column(
sa.String(16), 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, 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 __data_model__ = data_models.LoadBalancer
__tablename__ = "load_balancer" __tablename__ = "load_balancer"
name = sa.Column(sa.String(255), nullable=True)
description = sa.Column(sa.String(255), nullable=True) description = sa.Column(sa.String(255), nullable=True)
provisioning_status = sa.Column( provisioning_status = sa.Column(
sa.String(16), sa.String(16),
@ -338,7 +338,8 @@ class Vip(base_models.BASE):
class Listener(base_models.BASE, base_models.IdMixin, 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 __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='uq_listener_load_balancer_id_protocol_port'),
) )
name = sa.Column(sa.String(255), nullable=True)
description = sa.Column(sa.String(255), nullable=True) description = sa.Column(sa.String(255), nullable=True)
protocol = sa.Column( protocol = sa.Column(
sa.String(16), sa.String(16),
@ -510,13 +510,12 @@ class L7Rule(base_models.BASE, base_models.IdMixin):
nullable=True) 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 __data_model__ = data_models.L7Policy
__tablename__ = "l7policy" __tablename__ = "l7policy"
name = sa.Column(sa.String(255), nullable=True)
description = sa.Column(sa.String(255), nullable=True) description = sa.Column(sa.String(255), nullable=True)
listener_id = sa.Column( listener_id = sa.Column(
sa.String(36), sa.String(36),