Replace network_uuid with network_info
Change-Id: I9714741e7f6446668c94c3b4f1de5a40c3a8248e
This commit is contained in:
@@ -63,8 +63,8 @@ class Instance(base.APIBase):
|
||||
image_uuid = types.uuid
|
||||
"""The image UUID of the instance"""
|
||||
|
||||
network_uuid = types.uuid
|
||||
"""The network UUID of the instance"""
|
||||
network_info = {wtypes.text: types.jsontype}
|
||||
"""The network information of the instance"""
|
||||
|
||||
links = wsme.wsattr([link.Link], readonly=True)
|
||||
"""A list containing a self link"""
|
||||
|
||||
@@ -15,11 +15,15 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from wsme import types as wtypes
|
||||
|
||||
from nimble.common import exception
|
||||
from nimble.common.i18n import _
|
||||
|
||||
|
||||
class UuidType(wtypes.UserType):
|
||||
@@ -62,5 +66,32 @@ class BooleanType(wtypes.UserType):
|
||||
return BooleanType.validate(value)
|
||||
|
||||
|
||||
class JsonType(wtypes.UserType):
|
||||
"""A simple JSON type."""
|
||||
|
||||
basetype = wtypes.text
|
||||
name = 'json'
|
||||
|
||||
def __str__(self):
|
||||
# These are the json serializable native types
|
||||
return ' | '.join(map(str, (wtypes.text, six.integer_types, float,
|
||||
BooleanType, list, dict, None)))
|
||||
|
||||
@staticmethod
|
||||
def validate(value):
|
||||
try:
|
||||
json.dumps(value)
|
||||
except TypeError:
|
||||
raise exception.Invalid(_('%s is not JSON serializable') % value)
|
||||
else:
|
||||
return value
|
||||
|
||||
@staticmethod
|
||||
def frombasetype(value):
|
||||
return JsonType.validate(value)
|
||||
|
||||
|
||||
boolean = BooleanType()
|
||||
uuid = UuidType()
|
||||
# Can't call it 'json' because that's the name of the stdlib module
|
||||
jsontype = JsonType()
|
||||
|
||||
@@ -69,7 +69,7 @@ def upgrade():
|
||||
sa.Column('task_state', sa.String(length=255), nullable=True),
|
||||
sa.Column('instance_type_id', sa.Integer(), nullable=True),
|
||||
sa.Column('image_uuid', sa.String(length=36), nullable=True),
|
||||
sa.Column('network_uuid', sa.String(length=36), nullable=True),
|
||||
sa.Column('network_info', sa.Text(), nullable=True),
|
||||
sa.Column('launched_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('terminated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('availability_zone', sa.String(length=255), nullable=True),
|
||||
|
||||
@@ -19,6 +19,7 @@ SQLAlchemy models for baremetal compute service.
|
||||
|
||||
from oslo_db import options as db_options
|
||||
from oslo_db.sqlalchemy import models
|
||||
from oslo_db.sqlalchemy import types as db_types
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from sqlalchemy import Boolean, Column
|
||||
from sqlalchemy import schema, String, Integer, Text
|
||||
@@ -105,6 +106,6 @@ class Instance(Base):
|
||||
instance_type_id = Column(Integer, nullable=True)
|
||||
availability_zone = Column(String(255), nullable=True)
|
||||
image_uuid = Column(String(36), nullable=True)
|
||||
network_uuid = Column(String(36), nullable=True)
|
||||
network_info = Column(db_types.JsonEncodedDict)
|
||||
node_uuid = Column(String(36), nullable=True)
|
||||
extra = Column(Text, nullable=True)
|
||||
|
||||
@@ -58,7 +58,7 @@ class EngineManager(base_manager.BaseEngineManager):
|
||||
|
||||
def _build_networks(self, context, instance):
|
||||
macs = ironic.get_macs_from_node(instance.node_uuid)
|
||||
port = neutron.create_ports(context, instance.network_uuid, macs[0])
|
||||
port = neutron.create_ports(context, instance.network_info, macs[0])
|
||||
ironic.plug_vifs(instance.node_uuid, port['port']['id'])
|
||||
|
||||
def _wait_for_active(self, instance):
|
||||
|
||||
@@ -39,7 +39,7 @@ class Instance(base.NimbleObject, object_base.VersionedObjectDictCompat):
|
||||
'instance_type_id': object_fields.IntegerField(nullable=True),
|
||||
'availability_zone': object_fields.StringField(nullable=True),
|
||||
'image_uuid': object_fields.UUIDField(nullable=True),
|
||||
'network_uuid': object_fields.UUIDField(nullable=True),
|
||||
'network_info': object_fields.FlexibleDictField(nullable=True),
|
||||
'node_uuid': object_fields.UUIDField(nullable=True),
|
||||
'extra': object_fields.FlexibleDictField(nullable=True),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user