Tom said he would like to see an example SIF Agent using Iron Python.
We'll... since I'm always up for learning yet another programming language, I
gave it a shot. I used the Iron
Python 1.0 beta 1 distribution(which runs on .Net 2.0). Here's the
code...
from Edustructures.SifWorks import *
from Edustructures.SifWorks.Infra import *
Adk.Initialize()
agent = Agent( "SimpleGetZoneStatus" )
agent.Initialize()
zone = agent.ZoneFactory.GetInstance( "TestZone",
"http://localhost:8080/TestZone" )
zone.Connect( ProvisioningFlags.Register )
zs = zone.GetZoneStatus()
print "Received response from zone %1s (%2s:%3s)"
% (zs.ZoneId,zs.SIF_Vendor.SIF_Product,zs.SIF_Vendor.SIF_Version)
for sn in zs.SIF_SIFNodes.GetSIF_SIFNodes():
print "Agent %1s" % (sn.SIF_Name)
for v in sn.GetSIF_Versions():
print " supports version %1s" % (v)
Being
a newbie to Iron Python, I'm not sure what the best way is to add a reference to
the ADK, which is a single assembly, Edustructures.SIFWorks.Adk.dll. What I did
was I opened up the Iron Python Console, ran "import clr" and then ran
"clr.AddReference("Edustructures.SifWorks.Adk") before running this
script.
Also, I'm not sure if I used the best string formatting method,
but it worked. If someone has a better way to do it, please let me
know.
Tagged:
sif
|
python
Posted
01-05-2006 1:14
by
admin