Skip to content

Commit

Permalink
Support for assets in the scan form. Requires https://github.com/alle…
Browse files Browse the repository at this point in the history
  • Loading branch information
Radomir Dopieralski committed Aug 23, 2013
1 parent ff1c8f8 commit 8886a6a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/ralph/scan/data.py
Expand Up @@ -11,6 +11,7 @@


from django.db import models as db
from django.conf import settings

from ralph.discovery.models_component import (
ComponentModel,
Expand Down Expand Up @@ -285,9 +286,10 @@ def get_device_data(device):
data['system_cores_count'] = system.cores_count
if system.model:
data['system_family'] = system.model.family

# Some details of the device are still not returned:
# TODO asset
if 'ralph_assets' in settings.INSTALLED_APPS:
from ralph_assets.api_ralph import get_asset
asset = get_asset(device.id)['asset_id']
data['asset'] = asset['asset_id'] if asset else None
return data


Expand All @@ -297,9 +299,6 @@ def set_device_data(device, data):
in accordance with the meaning of the particular fields.
"""

# Some details of the device are still not updated:
# TODO asset

keys = {
'sn': 'serial_number',
'name': 'hostname',
Expand Down Expand Up @@ -554,6 +553,9 @@ def set_device_data(device, data):
for subdevice in device.child_set.exclude(id__in=subdevice_ids):
subdevice.parent = None
subdevice.save()
if 'asset' in data and 'ralph_assets' in settings.INSTALLED_APPS:
from ralph_assets.api_ralph import assign_asset
assign_asset(device.id, data['asset'] or None)


def device_from_data(data):
Expand Down

0 comments on commit 8886a6a

Please sign in to comment.