Browse Source

Boards info lr_version and mac_addr.

Change-Id: Id916e383b9f89f3685ec61efc2e93352ef920410
tags/0.4.7
Fabio Verboso 6 months ago
parent
commit
e4cc384154

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

@@ -34,7 +34,7 @@ from oslo_log import log as logging
34 34
 LOG = logging.getLogger(__name__)
35 35
 
36 36
 _DEFAULT_RETURN_FIELDS = ('name', 'code', 'status', 'uuid', 'session', 'type',
37
-                          'fleet')
37
+                          'fleet', 'lr_version', 'mac_addr')
38 38
 _DEFAULT_WEBSERVICE_RETURN_FIELDS = ('name', 'uuid', 'port', 'board_uuid',
39 39
                                      'extra')
40 40
 
@@ -53,6 +53,8 @@ class Board(base.APIBase):
53 53
     project = types.uuid
54 54
     fleet = types.uuid
55 55
     mobile = types.boolean
56
+    lr_version = wsme.wsattr(wtypes.text)
57
+    mac_addr = wsme.wsattr(wtypes.text)
56 58
     links = wsme.wsattr([link.Link], readonly=True)
57 59
     location = wsme.wsattr([loc.Location])
58 60
     extra = types.jsontype

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

@@ -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.
15
+revision = 'b98819997377'
16
+down_revision = 'f28f3f4494b3'
17
+
18
+from alembic import op
19
+import sqlalchemy as sa
20
+
21
+
22
+def 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 ###

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

@@ -152,6 +152,8 @@ class Board(Base):
152 152
     owner = Column(String(36))
153 153
     project = Column(String(36))
154 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 157
     mobile = Column(Boolean, default=False)
156 158
     config = Column(JSONEncodedDict)
157 159
     extra = Column(JSONEncodedDict)

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

@@ -40,6 +40,8 @@ class Board(base.IotronicObject):
40 40
         'owner': obj_utils.str_or_none,
41 41
         'project': obj_utils.str_or_none,
42 42
         'fleet': obj_utils.str_or_none,
43
+        'lr_version': obj_utils.str_or_none,
44
+        'mac_addr': obj_utils.str_or_none,
43 45
         'mobile': bool,
44 46
         'config': obj_utils.dict_or_none,
45 47
         'extra': obj_utils.dict_or_none,

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

@@ -122,7 +122,7 @@ def board_on_leave(session_id):
122 122
         LOG.debug('session %s not found', session_id)
123 123
 
124 124
 
125
-def connection(uuid, session):
125
+def connection(uuid, session, info=None):
126 126
     LOG.debug('Received registration from %s with session %s',
127 127
               uuid, session)
128 128
     try:
@@ -151,6 +151,16 @@ def connection(uuid, session):
151 151
     LOG.debug('new session for %s saved %s', board.uuid,
152 152
               session.session_id)
153 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 164
     board.save()
155 165
     LOG.info('Board %s (%s) is now  %s', board.uuid,
156 166
              board.name, states.ONLINE)

Loading…
Cancel
Save