Create BayModel with provided(VM/BM) server type
In its current state of art, the Baymodel is created with only "VM" server type. This value is hardcoded in the code and a tech debt bug was filed to clean it off. Also this feature can be useful to allow bay model creation with various server type like virtual machines, baremetal etc. Client side changes will be provided as part of seperate patch. Partial-Bug: #1491003 Change-Id: I8981031d097fc41c94ad509c7b090f0a57a90525
This commit is contained in:
parent
7f68503b79
commit
798fc51c47
|
@ -151,6 +151,11 @@ class BayModel(base.APIBase):
|
|||
public = wsme.wsattr(types.boolean, default=False)
|
||||
"""Indicates whether the baymodel is public or not."""
|
||||
|
||||
server_type = wsme.wsattr(wtypes.StringType(min_length=1,
|
||||
max_length=255),
|
||||
default='vm')
|
||||
"""Server type for this bay model """
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.fields = []
|
||||
for field in objects.BayModel.fields:
|
||||
|
@ -201,6 +206,7 @@ class BayModel(base.APIBase):
|
|||
https_proxy='https://proxy.com:123',
|
||||
no_proxy='192.168.0.1,192.168.0.2,192.168.0.3',
|
||||
labels={'key1': 'val1', 'key2': 'val2'},
|
||||
server_type='vm',
|
||||
created_at=timeutils.utcnow(),
|
||||
updated_at=timeutils.utcnow(),
|
||||
public=False),
|
||||
|
|
|
@ -61,7 +61,9 @@ def _extract_template_definition(context, bay, scale_manager=None):
|
|||
baymodel = conductor_utils.retrieve_baymodel(context, bay)
|
||||
cluster_distro = baymodel.cluster_distro
|
||||
cluster_coe = baymodel.coe
|
||||
definition = TDef.get_template_definition('vm', cluster_distro,
|
||||
cluster_server_type = baymodel.server_type
|
||||
definition = TDef.get_template_definition(cluster_server_type,
|
||||
cluster_distro,
|
||||
cluster_coe)
|
||||
return definition.extract_definition(context, baymodel, bay,
|
||||
scale_manager=scale_manager)
|
||||
|
@ -216,7 +218,8 @@ class HeatPoller(object):
|
|||
self.attempts = 0
|
||||
self.baymodel = conductor_utils.retrieve_baymodel(self.context, bay)
|
||||
self.template_def = TDef.get_template_definition(
|
||||
'vm', self.baymodel.cluster_distro, self.baymodel.coe)
|
||||
self.baymodel.server_type,
|
||||
self.baymodel.cluster_distro, self.baymodel.coe)
|
||||
|
||||
def poll_and_check(self):
|
||||
# TODO(yuanying): temporary implementation to update api_address,
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
# 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 server_type column to baymodel
|
||||
|
||||
Revision ID: 417917e778f5
|
||||
Revises: 33ef79969018
|
||||
Create Date: 2015-10-14 16:21:57.229436
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '417917e778f5'
|
||||
down_revision = '33ef79969018'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('baymodel', sa.Column('server_type',
|
||||
sa.String(length=255), nullable=True,
|
||||
server_default='vm'))
|
|
@ -175,6 +175,7 @@ class BayModel(Base):
|
|||
labels = Column(JSONEncodedDict)
|
||||
tls_disabled = Column(Boolean, default=False)
|
||||
public = Column(Boolean, default=False)
|
||||
server_type = Column(String(255))
|
||||
|
||||
|
||||
class Container(Base):
|
||||
|
|
|
@ -30,7 +30,8 @@ class BayModel(base.MagnumPersistentObject, base.MagnumObject,
|
|||
# Version 1.5: Changed type of 'coe' from StringField to BayTypeField
|
||||
# Version 1.6: Change 'insecure' to 'tls_disabled'
|
||||
# Version 1.7: Added 'public' field
|
||||
VERSION = '1.7'
|
||||
# Version 1.8: Added 'server_type' field
|
||||
VERSION = '1.8'
|
||||
|
||||
dbapi = dbapi.get_instance()
|
||||
|
||||
|
@ -60,6 +61,7 @@ class BayModel(base.MagnumPersistentObject, base.MagnumObject,
|
|||
'labels': fields.DictOfStringsField(nullable=True),
|
||||
'tls_disabled': fields.BooleanField(default=False),
|
||||
'public': fields.BooleanField(default=False),
|
||||
'server_type': fields.StringField(nullable=True),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -44,6 +44,7 @@ class TestBayConductorWithK8s(base.TestCase):
|
|||
'flannel_network_subnetlen': '26',
|
||||
'flannel_use_vxlan': 'yes'},
|
||||
'tls_disabled': False,
|
||||
'server_type': 'vm'
|
||||
}
|
||||
self.bay_dict = {
|
||||
'uuid': 'bay-xx-xx-xx-xx',
|
||||
|
|
|
@ -37,7 +37,8 @@ class TestBayConductorWithMesos(base.TestCase):
|
|||
'coe': 'mesos',
|
||||
'http_proxy': 'http_proxy',
|
||||
'https_proxy': 'https_proxy',
|
||||
'no_proxy': 'no_proxy'
|
||||
'no_proxy': 'no_proxy',
|
||||
'server_type': 'vm'
|
||||
}
|
||||
self.bay_dict = {
|
||||
'id': 1,
|
||||
|
|
|
@ -38,7 +38,8 @@ class TestBayConductorWithSwarm(base.TestCase):
|
|||
'http_proxy': 'http_proxy',
|
||||
'https_proxy': 'https_proxy',
|
||||
'no_proxy': 'no_proxy',
|
||||
'tls_disabled': False
|
||||
'tls_disabled': False,
|
||||
'server_type': 'vm'
|
||||
}
|
||||
self.bay_dict = {
|
||||
'id': 1,
|
||||
|
|
|
@ -54,7 +54,8 @@ def get_test_baymodel(**kw):
|
|||
'no_proxy': kw.get('no_proxy', 'fake_no_proxy'),
|
||||
'registry_enabled': kw.get('registry_enabled', False),
|
||||
'tls_disabled': kw.get('tls_disabled', False),
|
||||
'public': kw.get('public', False)
|
||||
'public': kw.get('public', False),
|
||||
'server_type': kw.get('server_type', 'vm')
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -426,7 +426,7 @@ class _TestObject(object):
|
|||
object_data = {
|
||||
'Bay': '1.0-35edde13ad178e9419e7ea8b6d580bcd',
|
||||
'BayLock': '1.0-7d1eb08cf2070523bd210369c7a2e076',
|
||||
'BayModel': '1.7-3ceb83f91310437d21f465ce522fc4e7',
|
||||
'BayModel': '1.8-a4bb0976be245f06edbd1db087a18071',
|
||||
'Certificate': '1.0-2aff667971b85c1edf8d15684fd7d5e2',
|
||||
'Container': '1.1-968c62bc65ee08027a2cdbba95f5819c',
|
||||
'MyObj': '1.0-b43567e512438205e32f4e95ca616697',
|
||||
|
|
Loading…
Reference in New Issue