Boards info lr_version and mac_addr.
Change-Id: Id916e383b9f89f3685ec61efc2e93352ef920410
This commit is contained in:
parent
4eb2314533
commit
e4cc384154
|
@ -34,7 +34,7 @@ from oslo_log import log as logging
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
_DEFAULT_RETURN_FIELDS = ('name', 'code', 'status', 'uuid', 'session', 'type',
|
||||
'fleet')
|
||||
'fleet', 'lr_version', 'mac_addr')
|
||||
_DEFAULT_WEBSERVICE_RETURN_FIELDS = ('name', 'uuid', 'port', 'board_uuid',
|
||||
'extra')
|
||||
|
||||
|
@ -53,6 +53,8 @@ class Board(base.APIBase):
|
|||
project = types.uuid
|
||||
fleet = types.uuid
|
||||
mobile = types.boolean
|
||||
lr_version = wsme.wsattr(wtypes.text)
|
||||
mac_addr = wsme.wsattr(wtypes.text)
|
||||
links = wsme.wsattr([link.Link], readonly=True)
|
||||
location = wsme.wsattr([loc.Location])
|
||||
extra = types.jsontype
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# 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.
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b98819997377'
|
||||
down_revision = 'f28f3f4494b3'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('boards', sa.Column('lr_version',
|
||||
sa.String(length=20), nullable=True))
|
||||
op.add_column('boards', sa.Column('mac_addr',
|
||||
sa.String(length=20), nullable=True))
|
||||
# ### end Alembic commands ###
|
|
@ -152,6 +152,8 @@ class Board(Base):
|
|||
owner = Column(String(36))
|
||||
project = Column(String(36))
|
||||
fleet = Column(String(36), ForeignKey('fleets.uuid'), nullable=True)
|
||||
lr_version = Column(String(20), nullable=True)
|
||||
mac_addr = Column(String(20), nullable=True)
|
||||
mobile = Column(Boolean, default=False)
|
||||
config = Column(JSONEncodedDict)
|
||||
extra = Column(JSONEncodedDict)
|
||||
|
|
|
@ -40,6 +40,8 @@ class Board(base.IotronicObject):
|
|||
'owner': obj_utils.str_or_none,
|
||||
'project': obj_utils.str_or_none,
|
||||
'fleet': obj_utils.str_or_none,
|
||||
'lr_version': obj_utils.str_or_none,
|
||||
'mac_addr': obj_utils.str_or_none,
|
||||
'mobile': bool,
|
||||
'config': obj_utils.dict_or_none,
|
||||
'extra': obj_utils.dict_or_none,
|
||||
|
|
|
@ -122,7 +122,7 @@ def board_on_leave(session_id):
|
|||
LOG.debug('session %s not found', session_id)
|
||||
|
||||
|
||||
def connection(uuid, session):
|
||||
def connection(uuid, session, info=None):
|
||||
LOG.debug('Received registration from %s with session %s',
|
||||
uuid, session)
|
||||
try:
|
||||
|
@ -151,6 +151,16 @@ def connection(uuid, session):
|
|||
LOG.debug('new session for %s saved %s', board.uuid,
|
||||
session.session_id)
|
||||
board.status = states.ONLINE
|
||||
|
||||
if info:
|
||||
LOG.debug('board infos %s', info)
|
||||
if 'lr_version' in info:
|
||||
if board.lr_version != info['lr_version']:
|
||||
board.lr_version = info['lr_version']
|
||||
if 'mac_addr' in info:
|
||||
if board.mac_addr != info['mac_addr']:
|
||||
board.mac_addr = info['mac_addr']
|
||||
|
||||
board.save()
|
||||
LOG.info('Board %s (%s) is now %s', board.uuid,
|
||||
board.name, states.ONLINE)
|
||||
|
|
Loading…
Reference in New Issue