1c5bf09a03
Remove The following _MAX_LEN constants from neutron/api/v2/attributes.py and use the corresponding DB field size constants from neutron_lib.db.constants instead. NAME_MAX_LEN --> NAME_FIELD_SIZE TENANT_ID_MAX_LEN --> PROJECT_ID_FIELD_SIZE DESCRIPTION_MAX_LEN --> DESCRIPTION_FIELD_SIZE LONG_DESCRIPTION_MAX_LEN --> LONG_DESCRIPTION_FIELD_SIZE DEVICE_ID_MAX_LEN --> DEVICE_ID_FIELD_SIZE DEVICE_OWNER_MAX_LEN --> DEVICE_NAME_FIELD_SIZE In alembic migration scripts, the raw numerical value is used. For more information, see: http://lists.openstack.org/pipermail/openstack-dev/2016-October/105789.html NeutronLibImpact Change-Id: I734890372584fe27e5d6ec38c0cad2de882ff11c
60 lines
2.6 KiB
Python
60 lines
2.6 KiB
Python
# 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 neutron_lib.db import constants as db_const
|
|
from neutron_lib.db import model_base
|
|
import sqlalchemy as sa
|
|
from sqlalchemy import sql
|
|
|
|
from neutron.agent.common import utils
|
|
|
|
|
|
class Agent(model_base.BASEV2, model_base.HasId):
|
|
"""Represents agents running in neutron deployments."""
|
|
|
|
__table_args__ = (
|
|
sa.UniqueConstraint('agent_type', 'host',
|
|
name='uniq_agents0agent_type0host'),
|
|
model_base.BASEV2.__table_args__
|
|
)
|
|
|
|
# L3 agent, DHCP agent, OVS agent, LinuxBridge
|
|
agent_type = sa.Column(sa.String(255), nullable=False)
|
|
binary = sa.Column(sa.String(255), nullable=False)
|
|
# TOPIC is a fanout exchange topic
|
|
topic = sa.Column(sa.String(255), nullable=False)
|
|
# TOPIC.host is a target topic
|
|
host = sa.Column(sa.String(255), nullable=False)
|
|
availability_zone = sa.Column(sa.String(255))
|
|
admin_state_up = sa.Column(sa.Boolean, default=True,
|
|
server_default=sql.true(), nullable=False)
|
|
# the time when first report came from agents
|
|
created_at = sa.Column(sa.DateTime, nullable=False)
|
|
# the time when first report came after agents start
|
|
started_at = sa.Column(sa.DateTime, nullable=False)
|
|
# updated when agents report
|
|
heartbeat_timestamp = sa.Column(sa.DateTime, nullable=False)
|
|
# description is note for admin user
|
|
description = sa.Column(sa.String(db_const.DESCRIPTION_FIELD_SIZE))
|
|
# configurations: a json dict string, I think 4095 is enough
|
|
configurations = sa.Column(sa.String(4095), nullable=False)
|
|
# resource_versions: json dict, 8191 allows for ~256 resource versions
|
|
# assuming ~32byte length "'name': 'ver',"
|
|
# the whole row limit is 65535 bytes in mysql
|
|
resource_versions = sa.Column(sa.String(8191))
|
|
# load - number of resources hosted by the agent
|
|
load = sa.Column(sa.Integer, server_default='0', nullable=False)
|
|
|
|
@property
|
|
def is_active(self):
|
|
return not utils.is_agent_down(self.heartbeat_timestamp)
|