diff --git a/zun/db/sqlalchemy/alembic/versions/5359d23b2322_add_websocket_url_and_websocket_token.py b/zun/db/sqlalchemy/alembic/versions/5359d23b2322_add_websocket_url_and_websocket_token.py new file mode 100644 index 000000000..c2a432be7 --- /dev/null +++ b/zun/db/sqlalchemy/alembic/versions/5359d23b2322_add_websocket_url_and_websocket_token.py @@ -0,0 +1,37 @@ +# 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 websocket_url and websocket_token + +Revision ID: 5359d23b2322 +Revises: 17ab8b533cc8 +Create Date: 2017-05-03 15:54:26.194603 + +""" + +# revision identifiers, used by Alembic. +revision = '5359d23b2322' +down_revision = '17ab8b533cc8' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('container', + sa.Column('websocket_url', sa.String(length=255), + nullable=True)) + op.add_column('container', + sa.Column('websocket_token', sa.String(length=255), + nullable=True)) diff --git a/zun/db/sqlalchemy/models.py b/zun/db/sqlalchemy/models.py index a2ee96f7d..04914ac10 100644 --- a/zun/db/sqlalchemy/models.py +++ b/zun/db/sqlalchemy/models.py @@ -152,6 +152,8 @@ class Container(Base): status_detail = Column(String(50)) interactive = Column(Boolean, default=False) image_driver = Column(String(255)) + websocket_url = Column(String(255)) + websocket_token = Column(String(255)) class Image(Base): diff --git a/zun/objects/container.py b/zun/objects/container.py index d5fe93834..8ff0b8f72 100644 --- a/zun/objects/container.py +++ b/zun/objects/container.py @@ -35,7 +35,8 @@ class Container(base.ZunPersistentObject, base.ZunObject): # Version 1.13: Add more task states for container # Version 1.14: Add method 'list_by_host' # Version 1.15: Combine tty and stdin_open - VERSION = '1.15' + # Version 1.16: Add websocket_url and token + VERSION = '1.16' fields = { 'id': fields.IntegerField(), @@ -63,7 +64,9 @@ class Container(base.ZunPersistentObject, base.ZunObject): 'restart_policy': fields.DictOfStringsField(nullable=True), 'status_detail': fields.StringField(nullable=True), 'interactive': fields.BooleanField(nullable=True), - 'image_driver': fields.StringField(nullable=True) + 'image_driver': fields.StringField(nullable=True), + 'websocket_url': fields.StringField(nullable=True), + 'websocket_token': fields.StringField(nullable=True) } @staticmethod diff --git a/zun/tests/unit/db/utils.py b/zun/tests/unit/db/utils.py index 5f089d6fd..1597852f8 100644 --- a/zun/tests/unit/db/utils.py +++ b/zun/tests/unit/db/utils.py @@ -61,7 +61,10 @@ def get_test_container(**kw): {'Name': 'no', 'MaximumRetryCount': '0'}), 'status_detail': kw.get('status_detail', 'up from 5 hours'), 'interactive': kw.get('interactive', True), - 'image_driver': 'glance' + 'image_driver': 'glance', + 'websocket_url': 'ws://127.0.0.1:6784/4c03164962fa/attach/' + 'ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1', + 'websocket_token': '7878038e-957c-4d52-ae19-1e9561784e7b', } diff --git a/zun/tests/unit/objects/test_objects.py b/zun/tests/unit/objects/test_objects.py index 41c0f68d7..28a92d191 100644 --- a/zun/tests/unit/objects/test_objects.py +++ b/zun/tests/unit/objects/test_objects.py @@ -354,7 +354,7 @@ class TestObject(test_base.TestCase, _TestObject): # For more information on object version testing, read # http://docs.openstack.org/developer/zun/objects.html object_data = { - 'Container': '1.15-b2f1403b9bfcd97b52f46d2c53f003a5', + 'Container': '1.16-ed5876b31900577fc7f236098b16d2b4', 'Image': '1.0-0b976be24f4f6ee0d526e5c981ce0633', 'MyObj': '1.0-34c4b1aadefd177b13f9a2f894cc23cd', 'NUMANode': '1.0-cba878b70b2f8b52f1e031b41ac13b4e',