Merge "Add host to image table"
This commit is contained in:
commit
1efb2b9645
@ -144,6 +144,7 @@ class ImagesController(base.Controller):
|
|||||||
image_dict['project_id'] = context.project_id
|
image_dict['project_id'] = context.project_id
|
||||||
image_dict['user_id'] = context.user_id
|
image_dict['user_id'] = context.user_id
|
||||||
repo_tag = image_dict.get('repo')
|
repo_tag = image_dict.get('repo')
|
||||||
|
image_dict['host'] = host.hostname
|
||||||
image_dict['repo'], image_dict['tag'] = utils.parse_image_name(
|
image_dict['repo'], image_dict['tag'] = utils.parse_image_name(
|
||||||
repo_tag)
|
repo_tag)
|
||||||
new_image = objects.Image(context, **image_dict)
|
new_image = objects.Image(context, **image_dict)
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
# 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 host to image
|
||||||
|
|
||||||
|
Revision ID: a019998b09b5
|
||||||
|
Revises: a9c9fb54274a
|
||||||
|
Create Date: 2018-08-17 13:49:11.470002
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'a019998b09b5'
|
||||||
|
down_revision = 'a9c9fb54274a'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.add_column('image',
|
||||||
|
sa.Column('host', sa.String(length=255), nullable=True))
|
||||||
|
op.drop_constraint(constraint_name='uniq_image0repotag',
|
||||||
|
table_name='image', type_='unique')
|
||||||
|
op.create_unique_constraint(constraint_name='uniq_image0repotaghost',
|
||||||
|
table_name='image',
|
||||||
|
columns=['repo', 'tag', 'host'])
|
@ -241,6 +241,7 @@ class Image(Base):
|
|||||||
repo = Column(String(255))
|
repo = Column(String(255))
|
||||||
tag = Column(String(255))
|
tag = Column(String(255))
|
||||||
size = Column(String(255))
|
size = Column(String(255))
|
||||||
|
host = Column(String(255))
|
||||||
|
|
||||||
|
|
||||||
class ResourceProvider(Base):
|
class ResourceProvider(Base):
|
||||||
|
@ -19,8 +19,9 @@ from zun.objects import base
|
|||||||
@base.ZunObjectRegistry.register
|
@base.ZunObjectRegistry.register
|
||||||
class Image(base.ZunPersistentObject, base.ZunObject):
|
class Image(base.ZunPersistentObject, base.ZunObject):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
# Version = '1.1': Add delete image
|
# Version 1.1: Add delete image
|
||||||
VERSION = '1.1'
|
# Version 1.2: Add host to image
|
||||||
|
VERSION = '1.2'
|
||||||
|
|
||||||
fields = {
|
fields = {
|
||||||
'id': fields.IntegerField(),
|
'id': fields.IntegerField(),
|
||||||
@ -31,6 +32,7 @@ class Image(base.ZunPersistentObject, base.ZunObject):
|
|||||||
'repo': fields.StringField(nullable=True),
|
'repo': fields.StringField(nullable=True),
|
||||||
'tag': fields.StringField(nullable=True),
|
'tag': fields.StringField(nullable=True),
|
||||||
'size': fields.StringField(nullable=True),
|
'size': fields.StringField(nullable=True),
|
||||||
|
'host': fields.StringField(nullable=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -177,6 +177,7 @@ def get_test_image(**kwargs):
|
|||||||
'user_id': kwargs.get('user_id', 'fake_user'),
|
'user_id': kwargs.get('user_id', 'fake_user'),
|
||||||
'created_at': kwargs.get('created_at'),
|
'created_at': kwargs.get('created_at'),
|
||||||
'updated_at': kwargs.get('updated_at'),
|
'updated_at': kwargs.get('updated_at'),
|
||||||
|
'host': kwargs.get('host', 'host1'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ class TestObject(test_base.TestCase, _TestObject):
|
|||||||
object_data = {
|
object_data = {
|
||||||
'Container': '1.36-ad2bacdaa51afd0047e96003f93ff181',
|
'Container': '1.36-ad2bacdaa51afd0047e96003f93ff181',
|
||||||
'VolumeMapping': '1.3-14e3f9fc64e7afd751727c6ad3f32a94',
|
'VolumeMapping': '1.3-14e3f9fc64e7afd751727c6ad3f32a94',
|
||||||
'Image': '1.1-330e6205c80b99b59717e1cfc6a79935',
|
'Image': '1.2-80504fdd797e9dd86128a91680e876ad',
|
||||||
'MyObj': '1.0-34c4b1aadefd177b13f9a2f894cc23cd',
|
'MyObj': '1.0-34c4b1aadefd177b13f9a2f894cc23cd',
|
||||||
'NUMANode': '1.0-cba878b70b2f8b52f1e031b41ac13b4e',
|
'NUMANode': '1.0-cba878b70b2f8b52f1e031b41ac13b4e',
|
||||||
'NUMATopology': '1.0-b54086eda7e4b2e6145ecb6ee2c925ab',
|
'NUMATopology': '1.0-b54086eda7e4b2e6145ecb6ee2c925ab',
|
||||||
|
Loading…
Reference in New Issue
Block a user