now boards receive their location
Change-Id: I9808505e7e0d80f1e4c91788ea3ec59d90e32c56
This commit is contained in:
parent
e575619368
commit
b77c12a7d6
|
@ -114,7 +114,10 @@ class ConductorEndpoint(object):
|
||||||
prov.conf_registration_agent(self.ragent.wsurl)
|
prov.conf_registration_agent(self.ragent.wsurl)
|
||||||
|
|
||||||
prov.conf_main_agent(agent.wsurl)
|
prov.conf_main_agent(agent.wsurl)
|
||||||
|
loc = objects.Location.list_by_board_uuid(ctx, board.uuid)[0]
|
||||||
|
prov.conf_location(loc)
|
||||||
board.config = prov.get_config()
|
board.config = prov.get_config()
|
||||||
|
|
||||||
board.status = states.OFFLINE
|
board.status = states.OFFLINE
|
||||||
board.save()
|
board.save()
|
||||||
|
|
||||||
|
|
|
@ -75,3 +75,8 @@ class Provisioner(object):
|
||||||
if 'board' not in self.config['iotronic']:
|
if 'board' not in self.config['iotronic']:
|
||||||
self.config['iotronic']['board'] = {}
|
self.config['iotronic']['board'] = {}
|
||||||
self.config['iotronic']['board']['token'] = "<REGISTRATION-TOKEN>"
|
self.config['iotronic']['board']['token'] = "<REGISTRATION-TOKEN>"
|
||||||
|
|
||||||
|
def conf_location(self, location):
|
||||||
|
if "location" not in self.config['iotronic']['board']:
|
||||||
|
self.config['iotronic']['board']['location'] = {}
|
||||||
|
self.config['iotronic']['board']['location'] = location.get_geo()
|
||||||
|
|
|
@ -59,6 +59,23 @@ class Location(base.IotronicObject):
|
||||||
location = Location._from_db_object(cls(context), db_location)
|
location = Location._from_db_object(cls(context), db_location)
|
||||||
return location
|
return location
|
||||||
|
|
||||||
|
def get_geo(self):
|
||||||
|
|
||||||
|
updated = self._attr_to_primitive('updated_at')
|
||||||
|
created = self._attr_to_primitive('created_at')
|
||||||
|
|
||||||
|
geo = {
|
||||||
|
'longitude': self.longitude,
|
||||||
|
'latitude': self.latitude,
|
||||||
|
'altitude': self.altitude,
|
||||||
|
}
|
||||||
|
if updated is None:
|
||||||
|
geo['updated_at'] = created
|
||||||
|
else:
|
||||||
|
geo['updated_at'] = updated
|
||||||
|
|
||||||
|
return geo
|
||||||
|
|
||||||
# @base.remotable_classmethod
|
# @base.remotable_classmethod
|
||||||
# def get(cls, context, location_id):
|
# def get(cls, context, location_id):
|
||||||
# """Find a location based on its id or uuid and return
|
# """Find a location based on its id or uuid and return
|
||||||
|
@ -199,24 +216,25 @@ class Location(base.IotronicObject):
|
||||||
|
|
||||||
self.obj_reset_changes()
|
self.obj_reset_changes()
|
||||||
|
|
||||||
# @base.remotable
|
# @base.remotable
|
||||||
# def refresh(self, context=None):
|
# def refresh(self, context=None):
|
||||||
# """Loads updates for this Location.
|
# """Loads updates for this Location.
|
||||||
#
|
#
|
||||||
# Loads a location with the same uuid from the database and
|
# Loads a location with the same uuid from the database and
|
||||||
# checks for updated attributes. Updates are applied from
|
# checks for updated attributes. Updates are applied from
|
||||||
# the loaded location column by column, if there are any updates.
|
# the loaded location column by column, if there are any updates.
|
||||||
#
|
#
|
||||||
# :param context: Security context. NOTE: This should only
|
# :param context: Security context. NOTE: This should only
|
||||||
# be used internally by the indirection_api.
|
# be used internally by the indirection_api.
|
||||||
# Unfortunately, RPC requires context as the first
|
# Unfortunately, RPC requires context as the first
|
||||||
# argument, even though we don't use it.
|
# argument, even though we don't use it.
|
||||||
# A context should be set when instantiating the
|
# A context should be set when instantiating the
|
||||||
# object, e.g.: Location(context)
|
# object, e.g.: Location(context)
|
||||||
# """
|
# """
|
||||||
# current = self.__class__.get_by_uuid(self._context, uuid=self.uuid)
|
# current = self.__class__.get_by_uuid(self._context,
|
||||||
# for field in self.fields:
|
# uuid=self.uuid)
|
||||||
# if (hasattr(
|
# for field in self.fields:
|
||||||
# self, base.get_attrname(field))
|
# if (hasattr(
|
||||||
# and self[field] != current[field]):
|
# self, base.get_attrname(field))
|
||||||
# self[field] = current[field]
|
# and self[field] != current[field]):
|
||||||
|
# self[field] = current[field]
|
||||||
|
|
Loading…
Reference in New Issue