Skip to content

Automatically set Asset Tag on created Devices #18683

Answered by ziggekatten
MalteMagnussen asked this question in Q&A
Discussion options

You must be logged in to vote

The Event Rule sends an dict with some info (the "data" object/variable), where the object id of the device is one.

An example to attach to an Create Event Rule:

from dcim.models import Device
class SetAssetTag(Script):
    class Meta:
        name = "Event trigger that sets Asset tag"
        description = "Event trigger that sets Asset tag" 
        commit_default = True
        scheduling_enabled = False

    def run(self, data, commit):
        # If run through UI this is empty and just returns
        if data == {}:
            return
        #log the Event Rule data
        self.log_info(data)
        device = Device.objects.get(id=data['id'])
        device.snapshot()
        devic…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@MalteMagnussen
Comment options

@ziggekatten
Comment options

@MalteMagnussen
Comment options

@ziggekatten
Comment options

Answer selected by MalteMagnussen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants