Seite 1 von 1

GELÖST: descrption auslesen mit python backend...

Verfasst: 30 Okt 2020, 15:32
von ksmz
Hallo Leute,

ich bekomms einfach nicht gebacken die Group description einer gruppe auszulesen, hat jemand einen Tipp?

group_getObjects(id="test") gibt mir keine object-attribute für description....

VG
Andreas

Lösung:
Kompletter Code unter: https://github.com/kratzersmz/opsi-teska-wakeup

Code: Alles auswählen

.....
wakeupsactive = backending.group_getObjects(id="wakeup",description="on")

# check if wakeup is active(True)
isactive = True
try:
  test = wakeupsactive[0]
except IndexError:
  isactive = False

if isactive:
  wakeups = backending.group_getObjects(parentGroupId="wakeup")
  for wakeup in wakeups:
    # check it time fits to wakeup-name, e.g. 07-00
    if (currenttime == wakeup.id):
      # check if wakeups weekday is empty. If so, assume 1..5.
      if len(wakeup.description) == 0 and int(currentweekday) in range(1,5):
        wakeGroup(backending,wakeup.id)
      # if currentweekday is in string wakeupdays in description for wakeup, e.g. wakeup description 1,3,6 (Monday, Wednesday, Saturday) 
      elif str(currentweekday) in wakeup.description:
        wakeGroup(backending,wakeup.id)

Re: Group description auslesen mit python backend...

Verfasst: 02 Nov 2020, 18:13
von j.schneider
In einem Python-Skript?
Bitte mal ein bisschen mehr Code posten.

Re: Group description auslesen mit python backend...

Verfasst: 03 Nov 2020, 21:47
von ksmz
Hallo,

danke für die Rückmeldung. Ja in einem Python script

hatte jetzt mal alles so runtergeschrieben ohne auf syntax gross zu achten. Müsste das so funktionieren? Ich hab nichts wirklich passendes in der Doku gefunden....

Code: Alles auswählen

wakeupdays = backending.group_getObjecs(id=wakeup, type="Hostgroup")[0]
# check if wakeups weekday is empty. If so, assume 1..5.
wakeupDesc = wakeupdays.getDescription()
VG
Andreas