README 1.5 KB
Newer Older
1 2
SCOM API package offers modules for accessing COMAR over D-Bus without pain and 
common methods/classes for SCOM scripts.
Bahadır Kandemir's avatar
Bahadır Kandemir committed
3

4
Here are some examples for accessing SCOM:
Bahadır Kandemir's avatar
Bahadır Kandemir committed
5

6 7
    import scom
    link = scom.Link()
Bahadır Kandemir's avatar
Bahadır Kandemir committed
8

9 10 11
    # Localize strings
    link.setLocale()

12 13 14
    # Never use authentication agent (GUI)
    link.useAgent(False)

Bahadır Kandemir's avatar
Bahadır Kandemir committed
15 16 17 18 19 20
    # Get a list of packages that provide system.service method
    packages = list(link.System.Service)

    # Start a service
    link.System.Service["kdebase"].start()

Ozan Çağlayan's avatar
Ozan Çağlayan committed
21
    # Stop all services and ignore replies from packages.
22
    link.System.Service.stop(quiet=True)
Bahadır Kandemir's avatar
Bahadır Kandemir committed
23

Ozan Çağlayan's avatar
Ozan Çağlayan committed
24
Asynchronous calls:
Bahadır Kandemir's avatar
Bahadır Kandemir committed
25 26 27 28 29 30

    import gobject
    import dbus.mainloop.glib
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    mainloop = gobject.MainLoop()

31 32
    import scom
    link = scom.Link()
Bahadır Kandemir's avatar
Bahadır Kandemir committed
33

34 35 36
    # Localize strings
    link.setLocale()

Bahadır Kandemir's avatar
Bahadır Kandemir committed
37 38 39
    # Use authentication agent (GUI)
    link.useAgent()

Bahadır Kandemir's avatar
Bahadır Kandemir committed
40 41 42
    # Make an asynchronous call to get service information
    def handler(package, exception, result):
        if exception:
43
            print ("%s error: %s" % (package, exception))
Bahadır Kandemir's avatar
Bahadır Kandemir committed
44
        else:
45
            print ("%s result: %s" % (package, result))
Bahadır Kandemir's avatar
Bahadır Kandemir committed
46 47 48
    link.System.Service.info(async=handler)

    mainloop.run()
49

50
Connecting SCOM service on alternate destination:
51

52 53
    import scom
    link = scom.Link(alternate=True)
54

55 56
This will simply try to connect tr.org.pardus.scom2 instead 
of tr.org.pardus.scom
57

Bahadır Kandemir's avatar
Bahadır Kandemir committed
58 59
Connecting to alternative DBus server:

60 61
    import scom
    link = scom.Link(socket="/mnt/target/var/run/dbus/system_bus_socket")