Add disk info to compute node

Part of blueprint limit-container-diskspace

Change-Id: Ifd7d1588b40b92eda92b488c7ff97259f0524cf1
This commit is contained in:
Feng Shengqin 2018-03-05 16:21:30 +08:00 committed by feng.shengqin
parent de0cd125b4
commit 592b7dd920
5 changed files with 45 additions and 2 deletions

View File

@ -0,0 +1,36 @@
# 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 disk total and used to compute node
Revision ID: d0c606fdec3c
Revises: 3f49fa520409
Create Date: 2018-03-06 18:44:27.630273
"""
# revision identifiers, used by Alembic.
revision = 'd0c606fdec3c'
down_revision = '3f49fa520409'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade():
with op.batch_alter_table('compute_node', schema=None) as batch_op:
batch_op.add_column(sa.Column('disk_total',
sa.Integer(), nullable=False))
batch_op.add_column(sa.Column('disk_used',
sa.Integer(), nullable=False))

View File

@ -326,6 +326,8 @@ class ComputeNode(Base):
# Json string PCI Stats
# '[{"vendor_id":"8086", "product_id":"1234", "count":3 }, ...]'
pci_stats = Column(Text)
disk_total = Column(Integer, nullable=False, default=0)
disk_used = Column(Integer, nullable=False, default=0)
class Capsule(Base):

View File

@ -31,7 +31,8 @@ class ComputeNode(base.ZunPersistentObject, base.ZunObject):
# Version 1.7: Change get_by_hostname to get_by_name
# Version 1.8: Add pci_device_pools to compute node
# Version 1.9: Change PciDevicePoolList to ObjectField
VERSION = '1.9'
# Version 1.10: Add disk_total, disk_used columns
VERSION = '1.10'
fields = {
'uuid': fields.UUIDField(read_only=True, nullable=False),
@ -56,6 +57,8 @@ class ComputeNode(base.ZunPersistentObject, base.ZunObject):
# pci_stats field in the database
'pci_device_pools': fields.ObjectField('PciDevicePoolList',
nullable=True),
'disk_total': fields.IntegerField(nullable=False),
'disk_used': fields.IntegerField(nullable=False),
}
@staticmethod

View File

@ -346,6 +346,8 @@ def get_test_compute_node(**kwargs):
'labels': kwargs.get('labels', {"dev.type": "product"}),
'created_at': kwargs.get('created_at'),
'updated_at': kwargs.get('updated_at'),
'disk_total': kwargs.get('disk_total', 80),
'disk_used': kwargs.get('disk_used', 20),
}

View File

@ -355,7 +355,7 @@ object_data = {
'ZunService': '1.2-deff2a74a9ce23baa231ae12f39a6189',
'Capsule': '1.6-7238a80b4ef34e219c135fa72d0adc06',
'PciDevice': '1.1-6e3f0851ad1cf12583e6af4df1883979',
'ComputeNode': '1.9-e8536102d3b28cb3378e9e26f508cd72',
'ComputeNode': '1.10-707fc7af76adf27f967eebeb6e4dd3ba',
'PciDevicePool': '1.0-3f5ddc3ff7bfa14da7f6c7e9904cc000',
'PciDevicePoolList': '1.0-15ecf022a68ddbb8c2a6739cfc9f8f5e',
'ContainerPCIRequest': '1.0-b060f9f9f734bedde79a71a4d3112ee0',