diff --git a/octavia/common/data_models.py b/octavia/common/data_models.py index ad49d641a9..a9449e4d9f 100644 --- a/octavia/common/data_models.py +++ b/octavia/common/data_models.py @@ -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: diff --git a/octavia/db/base_models.py b/octavia/db/base_models.py index 219a34c6a8..55b68e5ea0 100644 --- a/octavia/db/base_models.py +++ b/octavia/db/base_models.py @@ -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) diff --git a/octavia/db/migration/alembic_migrations/versions/44a2414dd683_adding_name_column_to_member_and_health_.py b/octavia/db/migration/alembic_migrations/versions/44a2414dd683_adding_name_column_to_member_and_health_.py new file mode 100644 index 0000000000..dfd45eb285 --- /dev/null +++ b/octavia/db/migration/alembic_migrations/versions/44a2414dd683_adding_name_column_to_member_and_health_.py @@ -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) + ) \ No newline at end of file diff --git a/octavia/db/models.py b/octavia/db/models.py index 1c03ab25aa..4b37ca7c83 100644 --- a/octavia/db/models.py +++ b/octavia/db/models.py @@ -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),