diff --git a/magnum/api/controllers/v1/baymodel.py b/magnum/api/controllers/v1/baymodel.py index 4fc86d2f30..711ae4743a 100644 --- a/magnum/api/controllers/v1/baymodel.py +++ b/magnum/api/controllers/v1/baymodel.py @@ -138,6 +138,11 @@ class BayModel(base.APIBase): docker_storage_driver = wtypes.Enum(str, *fields.DockerStorageDriver.ALL) """Docker storage driver""" + master_lb_enabled = wsme.wsattr(types.boolean, default=False) + """Indicates whether created bays should have a load balancer for master + nodes or not. + """ + def __init__(self, **kwargs): self.fields = [] for field in objects.BayModel.fields: @@ -188,7 +193,8 @@ class BayModel(base.APIBase): insecure_registry='10.238.100.100:5000', created_at=timeutils.utcnow(), updated_at=timeutils.utcnow(), - public=False), + public=False, + master_lb_enabled=False) return cls._convert_with_links(sample, 'http://localhost:9511') diff --git a/magnum/db/sqlalchemy/alembic/versions/68ce16dfd341_add_master_lb_enabled_column_to_baymodel_table.py b/magnum/db/sqlalchemy/alembic/versions/68ce16dfd341_add_master_lb_enabled_column_to_baymodel_table.py new file mode 100644 index 0000000000..c9447d34ff --- /dev/null +++ b/magnum/db/sqlalchemy/alembic/versions/68ce16dfd341_add_master_lb_enabled_column_to_baymodel_table.py @@ -0,0 +1,30 @@ +# 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 master_lb_enabled column to baymodel table + +Revision ID: 68ce16dfd341 +Revises: 085e601a39f6 +Create Date: 2016-06-23 18:44:55.312413 + +""" + +# revision identifiers, used by Alembic. +revision = '68ce16dfd341' +down_revision = '085e601a39f6' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('baymodel', + sa.Column('master_lb_enabled', sa.Boolean(), default=False)) diff --git a/magnum/db/sqlalchemy/models.py b/magnum/db/sqlalchemy/models.py index 6eaa0ddd33..5b1f26e7d3 100644 --- a/magnum/db/sqlalchemy/models.py +++ b/magnum/db/sqlalchemy/models.py @@ -172,6 +172,7 @@ class BayModel(Base): public = Column(Boolean, default=False) server_type = Column(String(255)) insecure_registry = Column(String(255)) + master_lb_enabled = Column(Boolean, default=False) class Container(Base): diff --git a/magnum/objects/baymodel.py b/magnum/objects/baymodel.py index 1202679716..012b527546 100644 --- a/magnum/objects/baymodel.py +++ b/magnum/objects/baymodel.py @@ -36,7 +36,8 @@ class BayModel(base.MagnumPersistentObject, base.MagnumObject, # Version 1.10: Removed 'ssh_authorized_key' field # Version 1.11: Added 'insecure_registry' field # Version 1.12: Added 'docker_storage_driver' field - VERSION = '1.12' + # Version 1.13: Added 'master_lb_enabled' field + VERSION = '1.13' dbapi = dbapi.get_instance() @@ -70,6 +71,7 @@ class BayModel(base.MagnumPersistentObject, base.MagnumObject, 'public': fields.BooleanField(default=False), 'server_type': fields.StringField(nullable=True), 'insecure_registry': fields.StringField(nullable=True), + 'master_lb_enabled': fields.BooleanField(default=False), } @staticmethod diff --git a/magnum/tests/unit/db/utils.py b/magnum/tests/unit/db/utils.py index 6b40ef09da..12d2f9ae40 100644 --- a/magnum/tests/unit/db/utils.py +++ b/magnum/tests/unit/db/utils.py @@ -52,6 +52,7 @@ def get_test_baymodel(**kw): 'public': kw.get('public', False), 'server_type': kw.get('server_type', 'vm'), 'insecure_registry': kw.get('insecure_registry', '10.0.0.1:5000'), + 'master_lb_enabled': kw.get('master_lb_enabled', False), } diff --git a/magnum/tests/unit/objects/test_objects.py b/magnum/tests/unit/objects/test_objects.py index 9140753234..a80aa24259 100644 --- a/magnum/tests/unit/objects/test_objects.py +++ b/magnum/tests/unit/objects/test_objects.py @@ -363,7 +363,7 @@ class TestObject(test_base.TestCase, _TestObject): # http://docs.openstack.org/developer/magnum/objects.html object_data = { 'Bay': '1.5-a3b9292ef5d35175b93ca46ba3baec2d', - 'BayModel': '1.12-ab6910eba29f1af6e6660020228d31d0', + 'BayModel': '1.13-dd8deda88d7ee7e8911fb900e0f75a1e', 'Certificate': '1.0-2aff667971b85c1edf8d15684fd7d5e2', 'Container': '1.3-e2d9d2e8a8844d421148cd9fde6c6bd6', 'MyObj': '1.0-b43567e512438205e32f4e95ca616697',