summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Verboso <fverboso@unime.it>2019-02-04 11:42:35 +0100
committerFabio Verboso <fverboso@unime.it>2019-02-04 11:42:35 +0100
commite4cc3841543a9a5f98b79e8a7a7b92403478f1c3 (patch)
treebe38c0c56b05d094cdfac50a129c1e827174509d
parent4eb23145334b512a0807d48337b7518920bef8b2 (diff)
Boards info lr_version and mac_addr.
Notes
Notes (review): Code-Review+2: Fabio Verboso <fverboso@unime.it> Workflow+1: Fabio Verboso <fverboso@unime.it> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 04 Feb 2019 10:59:51 +0000 Reviewed-on: https://review.openstack.org/634662 Project: openstack/iotronic Branch: refs/heads/master
-rw-r--r--iotronic/api/controllers/v1/board.py4
-rw-r--r--iotronic/db/sqlalchemy/alembic/versions/b98819997377_boards_lr_data.py28
-rw-r--r--iotronic/db/sqlalchemy/models.py2
-rw-r--r--iotronic/objects/board.py2
-rw-r--r--iotronic/wamp/functions.py12
5 files changed, 46 insertions, 2 deletions
diff --git a/iotronic/api/controllers/v1/board.py b/iotronic/api/controllers/v1/board.py
index 0473b27..a02590d 100644
--- a/iotronic/api/controllers/v1/board.py
+++ b/iotronic/api/controllers/v1/board.py
@@ -34,7 +34,7 @@ from oslo_log import log as logging
34LOG = logging.getLogger(__name__) 34LOG = logging.getLogger(__name__)
35 35
36_DEFAULT_RETURN_FIELDS = ('name', 'code', 'status', 'uuid', 'session', 'type', 36_DEFAULT_RETURN_FIELDS = ('name', 'code', 'status', 'uuid', 'session', 'type',
37 'fleet') 37 'fleet', 'lr_version', 'mac_addr')
38_DEFAULT_WEBSERVICE_RETURN_FIELDS = ('name', 'uuid', 'port', 'board_uuid', 38_DEFAULT_WEBSERVICE_RETURN_FIELDS = ('name', 'uuid', 'port', 'board_uuid',
39 'extra') 39 'extra')
40 40
@@ -53,6 +53,8 @@ class Board(base.APIBase):
53 project = types.uuid 53 project = types.uuid
54 fleet = types.uuid 54 fleet = types.uuid
55 mobile = types.boolean 55 mobile = types.boolean
56 lr_version = wsme.wsattr(wtypes.text)
57 mac_addr = wsme.wsattr(wtypes.text)
56 links = wsme.wsattr([link.Link], readonly=True) 58 links = wsme.wsattr([link.Link], readonly=True)
57 location = wsme.wsattr([loc.Location]) 59 location = wsme.wsattr([loc.Location])
58 extra = types.jsontype 60 extra = types.jsontype
diff --git a/iotronic/db/sqlalchemy/alembic/versions/b98819997377_boards_lr_data.py b/iotronic/db/sqlalchemy/alembic/versions/b98819997377_boards_lr_data.py
new file mode 100644
index 0000000..ab349ae
--- /dev/null
+++ b/iotronic/db/sqlalchemy/alembic/versions/b98819997377_boards_lr_data.py
@@ -0,0 +1,28 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13
14# revision identifiers, used by Alembic.
15revision = 'b98819997377'
16down_revision = 'f28f3f4494b3'
17
18from alembic import op
19import sqlalchemy as sa
20
21
22def upgrade():
23 # ### commands auto generated by Alembic - please adjust! ###
24 op.add_column('boards', sa.Column('lr_version',
25 sa.String(length=20), nullable=True))
26 op.add_column('boards', sa.Column('mac_addr',
27 sa.String(length=20), nullable=True))
28 # ### end Alembic commands ###
diff --git a/iotronic/db/sqlalchemy/models.py b/iotronic/db/sqlalchemy/models.py
index 01d2ced..a907630 100644
--- a/iotronic/db/sqlalchemy/models.py
+++ b/iotronic/db/sqlalchemy/models.py
@@ -152,6 +152,8 @@ class Board(Base):
152 owner = Column(String(36)) 152 owner = Column(String(36))
153 project = Column(String(36)) 153 project = Column(String(36))
154 fleet = Column(String(36), ForeignKey('fleets.uuid'), nullable=True) 154 fleet = Column(String(36), ForeignKey('fleets.uuid'), nullable=True)
155 lr_version = Column(String(20), nullable=True)
156 mac_addr = Column(String(20), nullable=True)
155 mobile = Column(Boolean, default=False) 157 mobile = Column(Boolean, default=False)
156 config = Column(JSONEncodedDict) 158 config = Column(JSONEncodedDict)
157 extra = Column(JSONEncodedDict) 159 extra = Column(JSONEncodedDict)
diff --git a/iotronic/objects/board.py b/iotronic/objects/board.py
index fe0e6d2..17c15f4 100644
--- a/iotronic/objects/board.py
+++ b/iotronic/objects/board.py
@@ -40,6 +40,8 @@ class Board(base.IotronicObject):
40 'owner': obj_utils.str_or_none, 40 'owner': obj_utils.str_or_none,
41 'project': obj_utils.str_or_none, 41 'project': obj_utils.str_or_none,
42 'fleet': obj_utils.str_or_none, 42 'fleet': obj_utils.str_or_none,
43 'lr_version': obj_utils.str_or_none,
44 'mac_addr': obj_utils.str_or_none,
43 'mobile': bool, 45 'mobile': bool,
44 'config': obj_utils.dict_or_none, 46 'config': obj_utils.dict_or_none,
45 'extra': obj_utils.dict_or_none, 47 'extra': obj_utils.dict_or_none,
diff --git a/iotronic/wamp/functions.py b/iotronic/wamp/functions.py
index 6b39d29..0a3db60 100644
--- a/iotronic/wamp/functions.py
+++ b/iotronic/wamp/functions.py
@@ -122,7 +122,7 @@ def board_on_leave(session_id):
122 LOG.debug('session %s not found', session_id) 122 LOG.debug('session %s not found', session_id)
123 123
124 124
125def connection(uuid, session): 125def connection(uuid, session, info=None):
126 LOG.debug('Received registration from %s with session %s', 126 LOG.debug('Received registration from %s with session %s',
127 uuid, session) 127 uuid, session)
128 try: 128 try:
@@ -151,6 +151,16 @@ def connection(uuid, session):
151 LOG.debug('new session for %s saved %s', board.uuid, 151 LOG.debug('new session for %s saved %s', board.uuid,
152 session.session_id) 152 session.session_id)
153 board.status = states.ONLINE 153 board.status = states.ONLINE
154
155 if info:
156 LOG.debug('board infos %s', info)
157 if 'lr_version' in info:
158 if board.lr_version != info['lr_version']:
159 board.lr_version = info['lr_version']
160 if 'mac_addr' in info:
161 if board.mac_addr != info['mac_addr']:
162 board.mac_addr = info['mac_addr']
163
154 board.save() 164 board.save()
155 LOG.info('Board %s (%s) is now %s', board.uuid, 165 LOG.info('Board %s (%s) is now %s', board.uuid,
156 board.name, states.ONLINE) 166 board.name, states.ONLINE)