Re: Help using the Cobbler API in triggers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Garrett Honeycutt wrote:
My goal is to access a variable within Cobbler, $hostname for example,
and use that in a trigger that is run whenever a system is added. Below
is some pseudo code to demonstrate my aim.

os.system("/usr/local/sbin/dostuff.sh $hostname")

Cobbler passes the name of the system as the first argument to the command. If your system name is the hostname, then in python you can just use something simple like:

machine = sys.argv[1]

If your system name is not the hostname then you can query the hostname of the system from Cobbler. Here is some python code I've been using:

from cobbler import api
cobbler_api = api.BootAPI()
systems = cobbler_api.systems()
box = systems.find(sys.argv[1])

I'm sure there are other (and probably better) ways as well.

--
Jennifer Cranfill
Systems Engineer
Sony Pictures Imageworks

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux