Skip to content

Commit

Permalink
feat(itam): render group software config within device rendered config
Browse files Browse the repository at this point in the history
!22 #43
  • Loading branch information
jon-nfc committed Jun 7, 2024
1 parent 0c382a7 commit 460eff1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions app/itam/models/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from access.fields import *
from access.models import TenancyObject

from core.mixin.history_save import SaveHistory
from app.helpers.merge_software import merge_software

from core.mixin.history_save import SaveHistory

from itam.models.device_common import DeviceCommonFields, DeviceCommonFieldsName
from itam.models.device_models import DeviceModel
Expand Down Expand Up @@ -94,6 +95,9 @@ def get_configuration(self, id):
"software": []
}

host_software = []
group_software = []

for software in softwares:

if software.action:
Expand All @@ -115,7 +119,7 @@ def get_configuration(self, id):
if software.version:
software_action['version'] = software.version.name

config['software'] = config['software'] + [ software_action ]
host_software += [ software_action ]

config: dict = config

Expand All @@ -131,7 +135,15 @@ def get_configuration(self, id):

if rendered_config:

config.update(json.loads(group.group.render_config()))
config.update(json.loads(rendered_config))

rendered_config: dict = json.loads(rendered_config)

if 'software' in rendered_config.keys():

group_software = group_software + rendered_config['software']

config['software'] = merge_software(group_software, host_software)

return config

Expand Down

0 comments on commit 460eff1

Please sign in to comment.