README 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. SCOM API package offers modules for accessing COMAR over D-Bus without pain and
  2. common methods/classes for SCOM scripts.
  3. Here are some examples for accessing SCOM:
  4. import scom
  5. link = scom.Link()
  6. # Localize strings
  7. link.setLocale()
  8. # Never use authentication agent (GUI)
  9. link.useAgent(False)
  10. # Get a list of packages that provide system.service method
  11. packages = list(link.System.Service)
  12. # Start a service
  13. link.System.Service["kdebase"].start()
  14. # Stop all services and ignore replies from packages.
  15. link.System.Service.stop(quiet=True)
  16. Asynchronous calls:
  17. import gobject
  18. import dbus.mainloop.glib
  19. dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
  20. mainloop = gobject.MainLoop()
  21. import scom
  22. link = scom.Link()
  23. # Localize strings
  24. link.setLocale()
  25. # Use authentication agent (GUI)
  26. link.useAgent()
  27. # Make an asynchronous call to get service information
  28. def handler(package, exception, result):
  29. if exception:
  30. print ("%s error: %s" % (package, exception))
  31. else:
  32. print ("%s result: %s" % (package, result))
  33. link.System.Service.info(async=handler)
  34. mainloop.run()
  35. Connecting SCOM service on alternate destination:
  36. import scom
  37. link = scom.Link(alternate=True)
  38. This will simply try to connect tr.org.pardus.scom2 instead
  39. of tr.org.pardus.scom
  40. Connecting to alternative DBus server:
  41. import scom
  42. link = scom.Link(socket="/mnt/target/var/run/dbus/system_bus_socket")