<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Tiger Server servermgrd library for Python</title>
	<atom:link href="http://www.dreness.com/blog/?feed=rss2&#038;p=38" rel="self" type="application/rss+xml" />
	<link>http://www.dreness.com/blog/?p=38</link>
	<description>dre's technical blog</description>
	<lastBuildDate>Tue, 07 Sep 2010 04:29:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-43</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Sat, 30 Aug 2008 15:55:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-43</guid>
		<description>Ah cool thanks for the link :-)

Just let you know minor update to it, 0.5.0, it&#039;s got logging ability now but should still maintain backwards computability with your scripts or with very little change.</description>
		<content:encoded><![CDATA[<p>Ah cool thanks for the link :-)</p>
<p>Just let you know minor update to it, 0.5.0, it&#8217;s got logging ability now but should still maintain backwards computability with your scripts or with very little change.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dre</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-42</link>
		<dc:creator>dre</dc:creator>
		<pubDate>Wed, 13 Aug 2008 19:20:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-42</guid>
		<description>@ felimwhiteley: fantastic! This is a great example of why open source is cool :)

Also, I&#039;ve added a link to your blog to my site.

Cheers!</description>
		<content:encoded><![CDATA[<p>@ felimwhiteley: fantastic! This is a great example of why open source is cool :)</p>
<p>Also, I&#8217;ve added a link to your blog to my site.</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-41</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Tue, 12 Aug 2008 11:32:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-41</guid>
		<description>Hi Dre,

I&#039;ve finally chosen LGPL, means any changes to the lib if distributed must be given back but folk are free to use it in commercial software, think it meets the halfway point quiet well. I have modified it from yours a bit, as it can be used by multiple apps at once, say Cacti for graphs and Nagios for checking. Anyway please feel free to ask for any changes and I didn&#039;t know your full name to credit you. I did search but couldn&#039;t find it.

http://code.google.com/p/libsrvrmgrd-osx/</description>
		<content:encoded><![CDATA[<p>Hi Dre,</p>
<p>I&#8217;ve finally chosen LGPL, means any changes to the lib if distributed must be given back but folk are free to use it in commercial software, think it meets the halfway point quiet well. I have modified it from yours a bit, as it can be used by multiple apps at once, say Cacti for graphs and Nagios for checking. Anyway please feel free to ask for any changes and I didn&#8217;t know your full name to credit you. I did search but couldn&#8217;t find it.</p>
<p><a href="http://code.google.com/p/libsrvrmgrd-osx/" rel="nofollow">http://code.google.com/p/libsrvrmgrd-osx/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-40</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Sat, 05 Jul 2008 20:52:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-40</guid>
		<description>Excellent, glad you are up for it. I guess this is were my slightly biased Linux to BSD ratio shows through. Maybe an option is to dual license it then, although I still prefer GPL as it does force contributing back, as the next [insert rich IT person&#039;s name here] walks off with it and makes millions lol

I&#039;ll let you know once I get it set up etc. anyway. And thanks for the initial idea ! :-)</description>
		<content:encoded><![CDATA[<p>Excellent, glad you are up for it. I guess this is were my slightly biased Linux to BSD ratio shows through. Maybe an option is to dual license it then, although I still prefer GPL as it does force contributing back, as the next [insert rich IT person's name here] walks off with it and makes millions lol</p>
<p>I&#8217;ll let you know once I get it set up etc. anyway. And thanks for the initial idea ! :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dre</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-39</link>
		<dc:creator>dre</dc:creator>
		<pubDate>Sat, 05 Jul 2008 19:34:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-39</guid>
		<description>Heya,

I&#039;m all for sharing! I haven&#039;t actually touched this in a while, and at this point it might be fair to say you&#039;ve spent more time on this than I have :) Since I didn&#039;t put a license on it, I&#039;ll leave it up to you. One comment: GPL is actually too restrictive for some uses; basically it prevents use in closed-source software (and there is plenty legitimately closed-source software :) If the goal is to make the code as useful as possible, then I would aim for a BSD style license.</description>
		<content:encoded><![CDATA[<p>Heya,</p>
<p>I&#8217;m all for sharing! I haven&#8217;t actually touched this in a while, and at this point it might be fair to say you&#8217;ve spent more time on this than I have :) Since I didn&#8217;t put a license on it, I&#8217;ll leave it up to you. One comment: GPL is actually too restrictive for some uses; basically it prevents use in closed-source software (and there is plenty legitimately closed-source software :) If the goal is to make the code as useful as possible, then I would aim for a BSD style license.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-38</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Sat, 05 Jul 2008 17:20:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-38</guid>
		<description>Dre a quick question on this code, I was gonna stick it and a  bunch of scripts into Google-code, would you have issue with me tagging it as GPL ? My thinking is it&#039;d be nice if it was useful to others and they fixed/improved/modified it they&#039;d give it back. I&#039;m not sure I could claim my changes are fantastic but I&#039;d certainly like it to stay open as a useful tool to folk.</description>
		<content:encoded><![CDATA[<p>Dre a quick question on this code, I was gonna stick it and a  bunch of scripts into Google-code, would you have issue with me tagging it as GPL ? My thinking is it&#8217;d be nice if it was useful to others and they fixed/improved/modified it they&#8217;d give it back. I&#8217;m not sure I could claim my changes are fantastic but I&#8217;d certainly like it to stay open as a useful tool to folk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-33</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Wed, 17 Oct 2007 22:02:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-33</guid>
		<description>Hi Again,

Just in case you have Leopard. Had to modify code a bit. They stick a faux header at the top of the packet, so need to split it off when we reach the end of it at &quot;\r\n\r\n&quot; sequence. Also they implement realms to gain access and have changed the order of when it ask for a password. The code is hideously ugly... but it works :-) Oh and the if re.match(&quot;SupportsBinaryPlist&quot; checks to see if it is in fact leopard, otherwise it performs the older method which I&#039;ve tested back to Panther.

Anyway here&#039;s the code !


def download_file(url, webuser = None, webpass = None):
        from urllib2 import (HTTPPasswordMgr, HTTPBasicAuthHandler, build_opener, install_opener, urlopen, HTTPError)
        password_mgr = HTTPPasswordMgr()
        password_mgr.add_password(&quot;Server Admin&quot;, url, webuser, webpass)
        handler = HTTPBasicAuthHandler(password_mgr)
        opener = build_opener(handler)
        install_opener(opener)
        request =  urllib2.Request(url)
        if webuser:
                base64string = base64.encodestring(&#039;%s:%s&#039; % (webuser, webpass))[:-1]
                request.add_header(&quot;Authorization&quot;, &quot;Basic %s&quot; % base64string)
                request.add_header(&#039;WWW-Authenticate&#039;, &#039;Basic realm=&quot;Server Admin&quot;&#039;)
        try:
                htmlFile = urllib2.urlopen(request)
                htmlData = htmlFile.read()
                htmlFile.close()
                if re.match(&quot;SupportsBinaryPlist&quot;, htmlData):
                        xmlDump = re.split(&quot;\r\n\r\n&quot;, htmlData, 1)
                        return xmlDump[1]
                else:
                        return htmlData
        except HTTPError, e:
                print e.code
                print e.headers
                sys.exit(2)</description>
		<content:encoded><![CDATA[<p>Hi Again,</p>
<p>Just in case you have Leopard. Had to modify code a bit. They stick a faux header at the top of the packet, so need to split it off when we reach the end of it at &#8220;\r\n\r\n&#8221; sequence. Also they implement realms to gain access and have changed the order of when it ask for a password. The code is hideously ugly&#8230; but it works :-) Oh and the if re.match(&#8220;SupportsBinaryPlist&#8221; checks to see if it is in fact leopard, otherwise it performs the older method which I&#8217;ve tested back to Panther.</p>
<p>Anyway here&#8217;s the code !</p>
<p>def download_file(url, webuser = None, webpass = None):<br />
        from urllib2 import (HTTPPasswordMgr, HTTPBasicAuthHandler, build_opener, install_opener, urlopen, HTTPError)<br />
        password_mgr = HTTPPasswordMgr()<br />
        password_mgr.add_password(&#8220;Server Admin&#8221;, url, webuser, webpass)<br />
        handler = HTTPBasicAuthHandler(password_mgr)<br />
        opener = build_opener(handler)<br />
        install_opener(opener)<br />
        request =  urllib2.Request(url)<br />
        if webuser:<br />
                base64string = base64.encodestring(&#8216;%s:%s&#8217; % (webuser, webpass))[:-1]<br />
                request.add_header(&#8220;Authorization&#8221;, &#8220;Basic %s&#8221; % base64string)<br />
                request.add_header(&#8216;WWW-Authenticate&#8217;, &#8216;Basic realm=&#8221;Server Admin&#8221;&#8216;)<br />
        try:<br />
                htmlFile = urllib2.urlopen(request)<br />
                htmlData = htmlFile.read()<br />
                htmlFile.close()<br />
                if re.match(&#8220;SupportsBinaryPlist&#8221;, htmlData):<br />
                        xmlDump = re.split(&#8220;\r\n\r\n&#8221;, htmlData, 1)<br />
                        return xmlDump[1]<br />
                else:<br />
                        return htmlData<br />
        except HTTPError, e:<br />
                print e.code<br />
                print e.headers<br />
                sys.exit(2)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-32</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Sun, 29 Jul 2007 23:10:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-32</guid>
		<description>Meant to thank you. I&#039;m not sure what I was doing but I was pretty close... Anyway works like a charm now :-)</description>
		<content:encoded><![CDATA[<p>Meant to thank you. I&#8217;m not sure what I was doing but I was pretty close&#8230; Anyway works like a charm now :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dre</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-31</link>
		<dc:creator>dre</dc:creator>
		<pubDate>Mon, 23 Jul 2007 23:15:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-31</guid>
		<description>Felimwhiteley:

These data structures allow targeting of nested items in a fairly straight-forward fashion. Take another look at all the Dock examples in the first half of the article. For example:

pl[&#039;persistent-apps&#039;][0][&#039;GUID&#039;]

This is a reference to the &quot;GUID&quot; key in the 1st array element (0-based index) of the persistent-apps key of the &quot;pl&quot; plist object. You can nest as far down as you need to, and you may need to have some logic for deciding which &#039;branches&#039; you are interested in, etc.

Another thing that may help is to retrieve the entire plist result from the remote server and then view it in a structured form, so you can see the indenting of each block. In the Mac OS X Developer tools you will find a utility called Property List Editor that can provide a hierarchical view of your plist.

Hope this helps!</description>
		<content:encoded><![CDATA[<p>Felimwhiteley:</p>
<p>These data structures allow targeting of nested items in a fairly straight-forward fashion. Take another look at all the Dock examples in the first half of the article. For example:</p>
<p>pl['persistent-apps'][0]['GUID']</p>
<p>This is a reference to the &#8220;GUID&#8221; key in the 1st array element (0-based index) of the persistent-apps key of the &#8220;pl&#8221; plist object. You can nest as far down as you need to, and you may need to have some logic for deciding which &#8216;branches&#8217; you are interested in, etc.</p>
<p>Another thing that may help is to retrieve the entire plist result from the remote server and then view it in a structured form, so you can see the indenting of each block. In the Mac OS X Developer tools you will find a utility called Property List Editor that can provide a hierarchical view of your plist.</p>
<p>Hope this helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-30</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Mon, 23 Jul 2007 15:41:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-30</guid>
		<description>Dre I wonder if you have a chnce to help me understand something with the returned info from srvrmgrdIO.

I am trying to get info from this command on CPU Temprature:

request = srvrmgrdIO.buildXML(&#039;status&#039;, &#039;&#039;, &#039;&#039;)
pl = srvrmgrdIO.sendXML(&#039;servermgr_xserve&#039;, request, server, port, webuser, webpass)

# print len(pl)
#
print &quot;******&quot;

for s in pl :
        print s

print &quot;******&quot;

for s in pl[&#039;Status&#039;] :
        print s

print &quot;******&quot;

I&#039;ve stuck in some lines to try understand what is happening at each branch. In all of your examples it&#039;s bene nice in that it was not nested very deeply. Unfortunatly when I use pl[&#039;Status&#039;] I have a Temprature section I need to get into then about another two below it. I&#039;ve been puzzled by this, I&#039;m sure there is a way but being so green on Python I&#039;m stumped.

I&#039;m half tempted to just 

print `pl[&#039;Status&#039;]` and use BASH/Grep/SED etc. to prune out what I need but that defeats the purpose.

HAve you any pointers ? I&#039;m sorry to bother you with this but finding code like this out on the web has been impossible.</description>
		<content:encoded><![CDATA[<p>Dre I wonder if you have a chnce to help me understand something with the returned info from srvrmgrdIO.</p>
<p>I am trying to get info from this command on CPU Temprature:</p>
<p>request = srvrmgrdIO.buildXML(&#8216;status&#8217;, &#8221;, &#8221;)<br />
pl = srvrmgrdIO.sendXML(&#8216;servermgr_xserve&#8217;, request, server, port, webuser, webpass)</p>
<p># print len(pl)<br />
#<br />
print &#8220;******&#8221;</p>
<p>for s in pl :<br />
        print s</p>
<p>print &#8220;******&#8221;</p>
<p>for s in pl['Status'] :<br />
        print s</p>
<p>print &#8220;******&#8221;</p>
<p>I&#8217;ve stuck in some lines to try understand what is happening at each branch. In all of your examples it&#8217;s bene nice in that it was not nested very deeply. Unfortunatly when I use pl['Status'] I have a Temprature section I need to get into then about another two below it. I&#8217;ve been puzzled by this, I&#8217;m sure there is a way but being so green on Python I&#8217;m stumped.</p>
<p>I&#8217;m half tempted to just </p>
<p>print `pl['Status']` and use BASH/Grep/SED etc. to prune out what I need but that defeats the purpose.</p>
<p>HAve you any pointers ? I&#8217;m sorry to bother you with this but finding code like this out on the web has been impossible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-29</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Sun, 22 Jul 2007 09:44:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-29</guid>
		<description>You are very welcome. Trust me if it weren&#039;t for your code this never would have been possible. Start of last week I knew no python :-)

I made a couple more minor edits to make it a bit more usable.

def sendXML ( servermgrdModule, request, server, port, webuser, webpass ) :
  url = &#039;https://&#039;+server+&#039;:&#039;+port+&#039;/commands/&#039;+servermgrdModule+&#039;?input=&#039;+urllib.quote(request)
  #print &quot;*** DEBUG ***&quot;
  #print url
  #print &quot;*** DEBUG ***&quot;
  xmlresult = request_data(url, webuser, webpass)
  xmlFauxFile = StringIO.StringIO(xmlresult)
  return plistlib.Plist.fromFile(xmlFauxFile)

So it doesn&#039;t have it stored in the library, then you would need to edit your test code to having a few lines like this:

import sys

server = sys.argv[1]
port = sys.argv[2]
webuser = sys.argv[3]
webpass = sys.argv[4]

So we can enter them at command line. Reason I added port, I was testing this via a rmeote SSL Tunnel, so I had set up port 8311 localhost to point to the server&#039;s port 311.

Then any check code needs to use:

print &#039;network bytes / second over the last 15 minutes:&#039;
request = srvrmgrdIO.buildXML(&#039;getHistory&#039;, &#039;v1+v2&#039;, &#039;900&#039;)
pl = srvrmgrdIO.sendXML(&#039;servermgr_info&#039;, request, server, port, webuser, webpass)
for s in pl[&#039;samplesArray&#039;] :
  print s[&#039;v2&#039;], &#039;at&#039;, time.ctime(s[&#039;t&#039;])
print &quot;&quot;

Thanks again for your code :-)</description>
		<content:encoded><![CDATA[<p>You are very welcome. Trust me if it weren&#8217;t for your code this never would have been possible. Start of last week I knew no python :-)</p>
<p>I made a couple more minor edits to make it a bit more usable.</p>
<p>def sendXML ( servermgrdModule, request, server, port, webuser, webpass ) :<br />
  url = &#8216;https://&#8217;+server+&#8217;:'+port+&#8217;/commands/&#8217;+servermgrdModule+&#8217;?input=&#8217;+urllib.quote(request)<br />
  #print &#8220;*** DEBUG ***&#8221;<br />
  #print url<br />
  #print &#8220;*** DEBUG ***&#8221;<br />
  xmlresult = request_data(url, webuser, webpass)<br />
  xmlFauxFile = StringIO.StringIO(xmlresult)<br />
  return plistlib.Plist.fromFile(xmlFauxFile)</p>
<p>So it doesn&#8217;t have it stored in the library, then you would need to edit your test code to having a few lines like this:</p>
<p>import sys</p>
<p>server = sys.argv[1]<br />
port = sys.argv[2]<br />
webuser = sys.argv[3]<br />
webpass = sys.argv[4]</p>
<p>So we can enter them at command line. Reason I added port, I was testing this via a rmeote SSL Tunnel, so I had set up port 8311 localhost to point to the server&#8217;s port 311.</p>
<p>Then any check code needs to use:</p>
<p>print &#8216;network bytes / second over the last 15 minutes:&#8217;<br />
request = srvrmgrdIO.buildXML(&#8216;getHistory&#8217;, &#8216;v1+v2&#8242;, &#8217;900&#8242;)<br />
pl = srvrmgrdIO.sendXML(&#8216;servermgr_info&#8217;, request, server, port, webuser, webpass)<br />
for s in pl['samplesArray'] :<br />
  print s['v2'], &#8216;at&#8217;, time.ctime(s['t'])<br />
print &#8220;&#8221;</p>
<p>Thanks again for your code :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dre</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-28</link>
		<dc:creator>dre</dc:creator>
		<pubDate>Sat, 21 Jul 2007 06:47:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-28</guid>
		<description>Felimwhiteley:

I haven&#039;t tested this yet, but it looks great! Since you&#039;ve done all the hard work, I will probably roll this new functionality into the existing code, allowing it to work either locally or remotely.

Thanks!</description>
		<content:encoded><![CDATA[<p>Felimwhiteley:</p>
<p>I haven&#8217;t tested this yet, but it looks great! Since you&#8217;ve done all the hard work, I will probably roll this new functionality into the existing code, allowing it to work either locally or remotely.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-27</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Thu, 19 Jul 2007 12:49:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-27</guid>
		<description>Don&#039;t know if you want this code or not but I have modified your srvrmgrdIO as you suggested... First off I really do not know Python.. this is a hobbled together collection of code from various sites and some help from some good friends, but it works. I added in and extra def and modified the sendXML. I can run your test example above against a remote server and it works perfectly the same. I know for sure this can be done better but maybe it&#039;ll help someone else out.

Thanks for your intial code it&#039;s saved my bacon :-)


def download_file(url, webuser = None, webpass = None):
  request =  urllib2.Request(url)
  if webuser:
      base64string = base64.encodestring(&#039;%s:%s&#039; % (webuser, webpass))[:-1]
      request.add_header(&quot;Authorization&quot;, &quot;Basic %s&quot; % base64string)
  htmlFile = urllib2.urlopen(request)
  htmlData = htmlFile.read()
  htmlFile.close()

  return htmlData

def sendXML ( servermgrdModule, request ) :
  webuser = &quot;some_admin_on_server&quot;
  webpass = &quot;the_password&quot;
  url = &#039;https://mac_server_address:311/commands/&#039;+servermgrdModule+&#039;?input=&#039;+urllib.quote(request)
  xmlresult = download_file(url, webuser, webpass)
  xmlFauxFile = StringIO.StringIO(xmlresult)
  return plistlib.Plist.fromFile(xmlFauxFile)</description>
		<content:encoded><![CDATA[<p>Don&#8217;t know if you want this code or not but I have modified your srvrmgrdIO as you suggested&#8230; First off I really do not know Python.. this is a hobbled together collection of code from various sites and some help from some good friends, but it works. I added in and extra def and modified the sendXML. I can run your test example above against a remote server and it works perfectly the same. I know for sure this can be done better but maybe it&#8217;ll help someone else out.</p>
<p>Thanks for your intial code it&#8217;s saved my bacon :-)</p>
<p>def download_file(url, webuser = None, webpass = None):<br />
  request =  urllib2.Request(url)<br />
  if webuser:<br />
      base64string = base64.encodestring(&#8216;%s:%s&#8217; % (webuser, webpass))[:-1]<br />
      request.add_header(&#8220;Authorization&#8221;, &#8220;Basic %s&#8221; % base64string)<br />
  htmlFile = urllib2.urlopen(request)<br />
  htmlData = htmlFile.read()<br />
  htmlFile.close()</p>
<p>  return htmlData</p>
<p>def sendXML ( servermgrdModule, request ) :<br />
  webuser = &#8220;some_admin_on_server&#8221;<br />
  webpass = &#8220;the_password&#8221;<br />
  url = &#8216;https://mac_server_address:311/commands/&#8217;+servermgrdModule+&#8217;?input=&#8217;+urllib.quote(request)<br />
  xmlresult = download_file(url, webuser, webpass)<br />
  xmlFauxFile = StringIO.StringIO(xmlresult)<br />
  return plistlib.Plist.fromFile(xmlFauxFile)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-26</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Tue, 17 Jul 2007 22:54:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-26</guid>
		<description>Ah cheers for the response Dre, I&#039;m probably going to have to... better get my python learning up to scratch asap. I have to monitor multiple Servers across multiple sites, so avoiding installing anything is a major factor. Thanks for the code though, it&#039;ll really make it doable, and cheers for the pointers too :-)</description>
		<content:encoded><![CDATA[<p>Ah cheers for the response Dre, I&#8217;m probably going to have to&#8230; better get my python learning up to scratch asap. I have to monitor multiple Servers across multiple sites, so avoiding installing anything is a major factor. Thanks for the code though, it&#8217;ll really make it doable, and cheers for the pointers too :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dre</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-25</link>
		<dc:creator>dre</dc:creator>
		<pubDate>Tue, 17 Jul 2007 22:14:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-25</guid>
		<description>Felimwhiteley:

The srvrmgrdIO library needs to run on the Mac OS X Server itself, as it is currently written. This is because the library executes another command line tool (servermgrd) and then communicates with it via stdin / stdout.

However, servermgrd also supports an xml protocol via http which provides all the same functionality (https://your.server:311). The sendXML function could be re-written to communicate with a remote Mac OS X Server by doing xml communication with servermgrd via https on port 311 instead of local communication with servermgrd via popen2.

My purpose for writing this library was to feed data to a local Net SNMP daemon, which can be queried remotely, so I have no need to add remote querying to srvrmgrdIO.

If you want to add this, check out urllib2 (in the python standard library). Remember that you&#039;ll need to authenticate to the servermgrd xml interface using an admin username and password.

Good luck :)</description>
		<content:encoded><![CDATA[<p>Felimwhiteley:</p>
<p>The srvrmgrdIO library needs to run on the Mac OS X Server itself, as it is currently written. This is because the library executes another command line tool (servermgrd) and then communicates with it via stdin / stdout.</p>
<p>However, servermgrd also supports an xml protocol via http which provides all the same functionality (<a href="https://your.server:311" rel="nofollow">https://your.server:311</a>). The sendXML function could be re-written to communicate with a remote Mac OS X Server by doing xml communication with servermgrd via https on port 311 instead of local communication with servermgrd via popen2.</p>
<p>My purpose for writing this library was to feed data to a local Net SNMP daemon, which can be queried remotely, so I have no need to add remote querying to srvrmgrdIO.</p>
<p>If you want to add this, check out urllib2 (in the python standard library). Remember that you&#8217;ll need to authenticate to the servermgrd xml interface using an admin username and password.</p>
<p>Good luck :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felimwhiteley</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-24</link>
		<dc:creator>felimwhiteley</dc:creator>
		<pubDate>Tue, 17 Jul 2007 13:50:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-24</guid>
		<description>Does this work for a remote server at all ? It&#039;s very cool libraries. I&#039;m trying to run them from a separate  (non Mac) box. Python is not my strong point so any pointers would be welcome. Appreciate the code though !

:-)</description>
		<content:encoded><![CDATA[<p>Does this work for a remote server at all ? It&#8217;s very cool libraries. I&#8217;m trying to run them from a separate  (non Mac) box. Python is not my strong point so any pointers would be welcome. Appreciate the code though !</p>
<p>:-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: filipp</title>
		<link>http://www.dreness.com/blog/?p=38&#038;cpage=1#comment-20</link>
		<dc:creator>filipp</dc:creator>
		<pubDate>Tue, 12 Jun 2007 06:18:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.dreness.com/blog/archives/38#comment-20</guid>
		<description>Very cool, thanks for sharing!

This reminds me of an idea I had of creating a cross-platform Server Admin. Python would be perfect for this since it runs on anything and also has GUI bindings.

plistlib is very cool. Thanks for bringing it up, I had no idea it even existed. I&#039;m working on alot of plist processing  right now and the solution I&#039;m using involves alot of XSLT. I also came up with another one, similar to plistlib using ObjC and the NSPropertyListSerialization class.</description>
		<content:encoded><![CDATA[<p>Very cool, thanks for sharing!</p>
<p>This reminds me of an idea I had of creating a cross-platform Server Admin. Python would be perfect for this since it runs on anything and also has GUI bindings.</p>
<p>plistlib is very cool. Thanks for bringing it up, I had no idea it even existed. I&#8217;m working on alot of plist processing  right now and the solution I&#8217;m using involves alot of XSLT. I also came up with another one, similar to plistlib using ObjC and the NSPropertyListSerialization class.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
