From baa9c21862e359bcfb0d24664adf185955a9872a Mon Sep 17 00:00:00 2001 From: "OTSUKA, Yuanying" Date: Wed, 19 Aug 2015 14:13:08 +0900 Subject: [PATCH] Add cert_uuid attributes to Bay in db This patch adds two attributes. 1. ca_cert_uuid 2. magnum_cert_uuid ca_cert_uuid is used for storing CA cert reference, and magnum_cert_uuid is used for storing client cert reference which is used by magnum-conductor as a Kubernetes client. These attributes are not exposed to user. Change-Id: I510d096abffa238c3a6cb20975f1693f0284747d Partial-Implements: blueprint magnum-as-a-ca --- magnum/api/controllers/v1/bay.py | 3 +- .../6f21dc920bb_add_cert_uuid_to_bay.py | 34 +++++++++++++++++++ magnum/db/sqlalchemy/models.py | 2 ++ magnum/objects/bay.py | 2 ++ .../conductor/handlers/test_bay_conductor.py | 2 ++ magnum/tests/unit/db/utils.py | 2 ++ 6 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 magnum/db/sqlalchemy/alembic/versions/6f21dc920bb_add_cert_uuid_to_bay.py diff --git a/magnum/api/controllers/v1/bay.py b/magnum/api/controllers/v1/bay.py index 1f06801421..326199becc 100644 --- a/magnum/api/controllers/v1/bay.py +++ b/magnum/api/controllers/v1/bay.py @@ -40,7 +40,8 @@ class BayPatchType(types.JsonPatchType): @staticmethod def internal_attrs(): internal_attrs = ['/api_address', '/node_addresses', - '/master_addresses', '/stack_id'] + '/master_addresses', '/stack_id', + '/ca_cert_uuid', '/magnum_cert_uuid'] return types.JsonPatchType.internal_attrs() + internal_attrs diff --git a/magnum/db/sqlalchemy/alembic/versions/6f21dc920bb_add_cert_uuid_to_bay.py b/magnum/db/sqlalchemy/alembic/versions/6f21dc920bb_add_cert_uuid_to_bay.py new file mode 100644 index 0000000000..02354a974f --- /dev/null +++ b/magnum/db/sqlalchemy/alembic/versions/6f21dc920bb_add_cert_uuid_to_bay.py @@ -0,0 +1,34 @@ +# 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 cert_uuuid to bay + +Revision ID: 6f21dc920bb +Revises: 966a99e70ff +Create Date: 2015-08-19 13:57:14.863292 + +""" + +# revision identifiers, used by Alembic. +revision = '6f21dc920bb' +down_revision = '966a99e70ff' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column( + 'bay', + sa.Column('ca_cert_uuid', sa.String(length=36), nullable=True)) + op.add_column( + 'bay', + sa.Column('magnum_cert_uuid', sa.String(length=36), nullable=True)) diff --git a/magnum/db/sqlalchemy/models.py b/magnum/db/sqlalchemy/models.py index 8d1e441c2f..6b987a8d4d 100644 --- a/magnum/db/sqlalchemy/models.py +++ b/magnum/db/sqlalchemy/models.py @@ -133,6 +133,8 @@ class Bay(Base): status_reason = Column(Text) discovery_url = Column(String(255)) master_addresses = Column(JSONEncodedList) + ca_cert_uuid = Column(String(36)) + magnum_cert_uuid = Column(String(36)) class BayLock(Base): diff --git a/magnum/objects/bay.py b/magnum/objects/bay.py index 9ffd8a77cc..94709416ae 100644 --- a/magnum/objects/bay.py +++ b/magnum/objects/bay.py @@ -60,6 +60,8 @@ class Bay(base.MagnumPersistentObject, base.MagnumObject, 'master_count': fields.IntegerField(nullable=True), 'discovery_url': fields.StringField(nullable=True), 'master_addresses': fields.ListOfStringsField(nullable=True), + 'ca_cert_uuid': fields.StringField(nullable=True), + 'magnum_cert_uuid': fields.StringField(nullable=True), } @staticmethod diff --git a/magnum/tests/unit/conductor/handlers/test_bay_conductor.py b/magnum/tests/unit/conductor/handlers/test_bay_conductor.py index a0c857b660..3d7de7687f 100644 --- a/magnum/tests/unit/conductor/handlers/test_bay_conductor.py +++ b/magnum/tests/unit/conductor/handlers/test_bay_conductor.py @@ -58,6 +58,8 @@ class TestBayConductorWithK8s(base.TestCase): 'master_count': 1, 'discovery_url': 'https://discovery.etcd.io/test', 'master_addresses': ['172.17.2.18'], + 'ca_cert_uuid': 'xx-xx-xx-xx', + 'magnum_cert_uuid': 'xx-xx-xx-xx', } @patch('magnum.objects.BayModel.get_by_uuid') diff --git a/magnum/tests/unit/db/utils.py b/magnum/tests/unit/db/utils.py index 42961bbd49..c05923a960 100644 --- a/magnum/tests/unit/db/utils.py +++ b/magnum/tests/unit/db/utils.py @@ -73,6 +73,8 @@ def get_test_bay(**kw): 'uuid': kw.get('uuid', '5d12f6fd-a196-4bf0-ae4c-1f639a523a52'), 'name': kw.get('name', 'bay1'), 'discovery_url': kw.get('discovery_url', None), + 'ca_cert_uuid': kw.get('ca_cert_uuid', None), + 'magnum_cert_uuid': kw.get('magnum_cert_uuid', None), 'project_id': kw.get('project_id', 'fake_project'), 'user_id': kw.get('user_id', 'fake_user'), 'baymodel_id': kw.get('baymodel_id',