summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--iotronic/api/controllers/v1/board.py4
-rw-r--r--iotronic/db/sqlalchemy/alembic/versions/b98819997377_boards_lr_data.py7
-rw-r--r--iotronic/db/sqlalchemy/models.py2
-rw-r--r--iotronic/objects/board.py2
-rw-r--r--iotronic/wamp/functions.py5
5 files changed, 12 insertions, 8 deletions
diff --git a/iotronic/api/controllers/v1/board.py b/iotronic/api/controllers/v1/board.py
index a02590d..f7eb215 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', 'lr_version', 'mac_addr') 37 'fleet', 'lr_version', 'connectivity')
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
@@ -54,7 +54,7 @@ class Board(base.APIBase):
54 fleet = types.uuid 54 fleet = types.uuid
55 mobile = types.boolean 55 mobile = types.boolean
56 lr_version = wsme.wsattr(wtypes.text) 56 lr_version = wsme.wsattr(wtypes.text)
57 mac_addr = wsme.wsattr(wtypes.text) 57 connectivity = types.jsontype
58 links = wsme.wsattr([link.Link], readonly=True) 58 links = wsme.wsattr([link.Link], readonly=True)
59 location = wsme.wsattr([loc.Location]) 59 location = wsme.wsattr([loc.Location])
60 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
index ab349ae..ac5c8ec 100644
--- a/iotronic/db/sqlalchemy/alembic/versions/b98819997377_boards_lr_data.py
+++ b/iotronic/db/sqlalchemy/alembic/versions/b98819997377_boards_lr_data.py
@@ -16,6 +16,7 @@ revision = 'b98819997377'
16down_revision = 'f28f3f4494b3' 16down_revision = 'f28f3f4494b3'
17 17
18from alembic import op 18from alembic import op
19import iotronic.db.sqlalchemy.models
19import sqlalchemy as sa 20import sqlalchemy as sa
20 21
21 22
@@ -23,6 +24,8 @@ def upgrade():
23 # ### commands auto generated by Alembic - please adjust! ### 24 # ### commands auto generated by Alembic - please adjust! ###
24 op.add_column('boards', sa.Column('lr_version', 25 op.add_column('boards', sa.Column('lr_version',
25 sa.String(length=20), nullable=True)) 26 sa.String(length=20), nullable=True))
26 op.add_column('boards', sa.Column('mac_addr', 27 op.add_column('boards',
27 sa.String(length=20), nullable=True)) 28 sa.Column('connectivity',
29 iotronic.db.sqlalchemy.models.JSONEncodedDict(),
30 nullable=True))
28 # ### end Alembic commands ### 31 # ### end Alembic commands ###
diff --git a/iotronic/db/sqlalchemy/models.py b/iotronic/db/sqlalchemy/models.py
index a907630..2170c62 100644
--- a/iotronic/db/sqlalchemy/models.py
+++ b/iotronic/db/sqlalchemy/models.py
@@ -153,7 +153,7 @@ class Board(Base):
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) 155 lr_version = Column(String(20), nullable=True)
156 mac_addr = Column(String(20), nullable=True) 156 connectivity = Column(JSONEncodedDict)
157 mobile = Column(Boolean, default=False) 157 mobile = Column(Boolean, default=False)
158 config = Column(JSONEncodedDict) 158 config = Column(JSONEncodedDict)
159 extra = Column(JSONEncodedDict) 159 extra = Column(JSONEncodedDict)
diff --git a/iotronic/objects/board.py b/iotronic/objects/board.py
index 17c15f4..cabfddb 100644
--- a/iotronic/objects/board.py
+++ b/iotronic/objects/board.py
@@ -41,7 +41,7 @@ class Board(base.IotronicObject):
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, 43 'lr_version': obj_utils.str_or_none,
44 'mac_addr': obj_utils.str_or_none, 44 'connectivity': obj_utils.dict_or_none,
45 'mobile': bool, 45 'mobile': bool,
46 'config': obj_utils.dict_or_none, 46 'config': obj_utils.dict_or_none,
47 '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 0a3db60..a47d81d 100644
--- a/iotronic/wamp/functions.py
+++ b/iotronic/wamp/functions.py
@@ -157,9 +157,10 @@ def connection(uuid, session, info=None):
157 if 'lr_version' in info: 157 if 'lr_version' in info:
158 if board.lr_version != info['lr_version']: 158 if board.lr_version != info['lr_version']:
159 board.lr_version = info['lr_version'] 159 board.lr_version = info['lr_version']
160 if 'connectivity' in info:
161 board.connectivity = info['connectivity']
160 if 'mac_addr' in info: 162 if 'mac_addr' in info:
161 if board.mac_addr != info['mac_addr']: 163 board.connectivity = {"mac_addr": info['mac_addr']}
162 board.mac_addr = info['mac_addr']
163 164
164 board.save() 165 board.save()
165 LOG.info('Board %s (%s) is now %s', board.uuid, 166 LOG.info('Board %s (%s) is now %s', board.uuid,