Support getting and updating network_info of environment.

Change-Id: I6f0f5fe75cecba1ba78aeebc6e974b314ce5485e
Closes-bug: #1257629
This commit is contained in:
Timur Sufiev 2013-12-04 18:18:43 +04:00
parent 07bf9ab166
commit 672bd325d3
3 changed files with 35 additions and 0 deletions

View File

@ -102,6 +102,7 @@ def handle_result(message):
return
environment.description = environment_result
environment.networking = environment_result.get('networking', {})
environment.version += 1
environment.save(session)

View File

@ -0,0 +1,33 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# 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.
from migrate.changeset.constraint import ForeignKeyConstraint
from sqlalchemy.schema import MetaData, Table, Column
from sqlalchemy.types import String, Text, DateTime, BigInteger
meta = MetaData()
def upgrade(migrate_engine):
meta.bind = migrate_engine
environment = Table('environment', meta, autoload=True)
networking = Column('networking', Text(), nullable=True, default='{}')
networking.create(environment)
def downgrade(migrate_engine):
meta.bind = migrate_engine
environment = Table('environment', meta, autoload=True)
environment.c.networking.drop()

View File

@ -104,6 +104,7 @@ class Environment(BASE, ModelBase):
tenant_id = Column(String(32), nullable=False)
version = Column(BigInteger, nullable=False, default=0)
description = Column(JsonBlob(), nullable=False, default={})
networking = Column(JsonBlob(), nullable=True, default={})
sessions = relationship("Session", backref='environment',
cascade='save-update, merge, delete')