Browse Source

Boards info lr_version and mac_addr.

Change-Id: Id916e383b9f89f3685ec61efc2e93352ef920410
tags/0.4.7
Fabio Verboso 1 year ago
parent
commit
e4cc384154
5 changed files with 46 additions and 2 deletions
  1. +3
    -1
      iotronic/api/controllers/v1/board.py
  2. +28
    -0
      iotronic/db/sqlalchemy/alembic/versions/b98819997377_boards_lr_data.py
  3. +2
    -0
      iotronic/db/sqlalchemy/models.py
  4. +2
    -0
      iotronic/objects/board.py
  5. +11
    -1
      iotronic/wamp/functions.py

+ 3
- 1
iotronic/api/controllers/v1/board.py View File

@@ -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

+ 28
- 0
iotronic/db/sqlalchemy/alembic/versions/b98819997377_boards_lr_data.py View File

@@ -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 ###

+ 2
- 0
iotronic/db/sqlalchemy/models.py View File

@@ -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)

+ 2
- 0
iotronic/objects/board.py View File

@@ -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,

+ 11
- 1
iotronic/wamp/functions.py View File

@@ -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…
Cancel
Save