Add insecure_registry column to baymoddel

Adding new column of `insecure_registry`, it indicates using insecure
registry when deploying a bay, it should be a validate url with port.

Partially-Implements: blueprint support-insecure-registry
Change-Id: Iaa28d6409264d1d2acd992a7fa14630bb6394852
This commit is contained in:
Eli Qiao 2016-03-28 09:14:54 +08:00
parent c7b0a8ce3d
commit 7b1e0ecb2e
7 changed files with 42 additions and 4 deletions

View File

@ -131,6 +131,9 @@ class BayModel(base.APIBase):
default='vm')
"""Server type for this bay model """
insecure_registry = wtypes.StringType(min_length=1, max_length=255)
"""insecure registry url when create baymodel """
def __init__(self, **kwargs):
self.fields = []
for field in objects.BayModel.fields:
@ -177,6 +180,7 @@ class BayModel(base.APIBase):
no_proxy='192.168.0.1,192.168.0.2,192.168.0.3',
labels={'key1': 'val1', 'key2': 'val2'},
server_type='vm',
insecure_registry='10.238.100.100:5000',
created_at=timeutils.utcnow(),
updated_at=timeutils.utcnow(),
public=False),

View File

@ -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 insecure_registry to baymodel
Revision ID: e647f5931da8
Revises: 049f81f6f584
Create Date: 2016-03-28 09:08:07.467102
"""
# revision identifiers, used by Alembic.
revision = 'e647f5931da8'
down_revision = '049f81f6f584'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('baymodel', sa.Column('insecure_registry',
sa.String(length=255), nullable=True))

View File

@ -170,6 +170,7 @@ class BayModel(Base):
tls_disabled = Column(Boolean, default=False)
public = Column(Boolean, default=False)
server_type = Column(String(255))
insecure_registry = Column(String(255))
class Container(Base):

View File

@ -33,7 +33,8 @@ class BayModel(base.MagnumPersistentObject, base.MagnumObject,
# Version 1.8: Added 'server_type' field
# Version 1.9: Added 'volume_driver' field
# Version 1.10: Removed 'ssh_authorized_key' field
VERSION = '1.10'
# Version 1.11: Added 'insecure_registry' field
VERSION = '1.11'
dbapi = dbapi.get_instance()
@ -64,6 +65,7 @@ class BayModel(base.MagnumPersistentObject, base.MagnumObject,
'tls_disabled': fields.BooleanField(default=False),
'public': fields.BooleanField(default=False),
'server_type': fields.StringField(nullable=True),
'insecure_registry': fields.StringField(nullable=True),
}
@staticmethod

View File

@ -49,7 +49,7 @@ class TestListBayModel(api_base.FunctionalTest):
'image_id', 'registry_enabled', 'no_proxy',
'keypair_id', 'https_proxy', 'tls_disabled',
'public', 'labels', 'master_flavor_id',
'volume_driver')
'volume_driver', 'insecure_registry')
def test_empty(self):
response = self.get_json('/baymodels')

View File

@ -48,7 +48,8 @@ def get_test_baymodel(**kw):
'registry_enabled': kw.get('registry_enabled', False),
'tls_disabled': kw.get('tls_disabled', False),
'public': kw.get('public', False),
'server_type': kw.get('server_type', 'vm')
'server_type': kw.get('server_type', 'vm'),
'insecure_registry': kw.get('insecure_registry', '10.0.0.1:5000'),
}

View File

@ -424,7 +424,7 @@ class _TestObject(object):
# http://docs.openstack.org/developer/magnum/objects.html
object_data = {
'Bay': '1.5-a3b9292ef5d35175b93ca46ba3baec2d',
'BayModel': '1.10-759aea0021329a0c413e1d9d5179dda2',
'BayModel': '1.11-ca90ce57d0c7e6ac4716dc2b7ed28e42',
'Certificate': '1.0-2aff667971b85c1edf8d15684fd7d5e2',
'Container': '1.3-e2d9d2e8a8844d421148cd9fde6c6bd6',
'MyObj': '1.0-b43567e512438205e32f4e95ca616697',