fixed the TODO of live action
This commit is contained in:
parent
2c67e3be93
commit
09d92e818c
|
@ -239,15 +239,30 @@ class ActionView(View):
|
||||||
raise ResourceNotFound("There aren't any disk in this device {}".format(device))
|
raise ResourceNotFound("There aren't any disk in this device {}".format(device))
|
||||||
return usage_time_hdd, serial_number
|
return usage_time_hdd, serial_number
|
||||||
|
|
||||||
|
def get_hid(self, snapshot):
|
||||||
|
device = snapshot.get('device') # type: Computer
|
||||||
|
components = snapshot.get('components')
|
||||||
|
if not device:
|
||||||
|
return None
|
||||||
|
macs = [c.serial_number for c in components
|
||||||
|
if c.type == 'NetworkAdapter' and c.serial_number is not None]
|
||||||
|
macs.sort()
|
||||||
|
mac = ''
|
||||||
|
hid = device.hid
|
||||||
|
if macs:
|
||||||
|
mac = "-{mac}".format(mac=macs[0])
|
||||||
|
hid += mac
|
||||||
|
return hid
|
||||||
|
|
||||||
def live(self, snapshot):
|
def live(self, snapshot):
|
||||||
"""If the device.allocated == True, then this snapshot create an action live."""
|
"""If the device.allocated == True, then this snapshot create an action live."""
|
||||||
device = snapshot.get('device') # type: Computer
|
# TODO @cayop dependency of pulls 83
|
||||||
# TODO @cayop dependency of pulls 85 and 83
|
# if the pr/83 is merged, then you need change this way for get the device
|
||||||
# if the pr/85 and pr/83 is merged, then you need change this way for get the device
|
hid = self.get_hid(snapshot)
|
||||||
if not device.hid or not Device.query.filter(Device.hid==device.hid).count():
|
if not hid or not Device.query.filter(Device.hid==hid).count():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
device = Device.query.filter(Device.hid==device.hid).one()
|
device = Device.query.filter(Device.hid==hid).one()
|
||||||
|
|
||||||
if not device.allocated:
|
if not device.allocated:
|
||||||
return None
|
return None
|
||||||
|
|
Reference in New Issue