Subclassing ansible.utils.display.Display in custom callback plugin

39 views
Skip to first unread message

piete...@gmail.com

unread,
Jul 7, 2020, 6:19:18 AM7/7/20
to Ansible Project
Hi all,

please allow me to ask for any help here...
I once wrote a custom callback plugin, where I subclassed ansible.utils.display.Display so I could overrule it's display() method to manipulate the message to be printed, and then call super(Display, self).display(.....
Since Ansible 2.8 the Display object is now a singleton, instantiated right at 'ansible-playbook'. This means a cannot modify the Display.display() anymore  right ?

Any ideas on how to call a customized display() method ?

Thanks in advance for any help.

Pieter.

piete...@gmail.com

unread,
Jul 7, 2020, 9:32:24 AM7/7/20
to Ansible Project
To answer myself...   I figured this simple solution :

in '__init__()'
    ....
    self.realdisplay = self._display.display
    self._display.display = self.display

then add a 'display()' method that intercept my message, and then calls 'self.realdisplay()'

Gonna run some tests now.  Thanks for your time so far...

Pieter


Op dinsdag 7 juli 2020 om 12:19:18 UTC+2 schreef piete...@gmail.com:

Nagesh sheregar

unread,
Jul 7, 2020, 10:04:32 AM7/7/20
to ansible...@googlegroups.com, piete...@gmail.com
Hi peter,

if you don't mind please send me output, i would like to get something like below 

Socket Locator Status Size Max Supported Frequency Technology
PROC 1 DIMM 3  Good, In Use 32.00 GB 2666 MHz RDIMM

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bb33b941-7efb-4ec8-83ce-82e2dfb8db92n%40googlegroups.com.

piete...@gmail.com

unread,
Jul 7, 2020, 10:31:11 AM7/7/20
to Ansible Project
Hi ,

excuse me, but I don't get the question here...  How can I help you ?

Op dinsdag 7 juli 2020 om 16:04:32 UTC+2 schreef nage...@gmail.com:

Nagesh sheregar

unread,
Jul 7, 2020, 10:48:32 AM7/7/20
to ansible...@googlegroups.com, piete...@gmail.com
Hi Pieter,

sorry for the confus,

i would like to see output like below:

Socket LocatorStatusSizeMax Supported FrequencyTechnology
PROC 1 DIMM 3 Good, In Use32.00 GB2666 MHzRDIMM

now i am getting below output and it's hard to read so do you have any example plugin which can show like above

socket 9:
            frequency: 1600 MHz
            hp_smart_memory: 'Yes'
            minimum_voltage: 1.50 v
            part:
              number: 647651-081
            ranks: 1
            size: 8192 MB
            socket: 9
            status: Good, In Use
            technology: RDIMM
            type: DIMM DDR3


piete...@gmail.com

unread,
Jul 8, 2020, 9:00:58 AM7/8/20
to Ansible Project
sent offline email to Nagesh with code samples

Op dinsdag 7 juli 2020 om 16:48:32 UTC+2 schreef nage...@gmail.com:
Reply all
Reply to author
Forward
0 new messages