| Server IP : 182.53.201.61 / Your IP : 216.73.217.175 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/smolt-1.4/ |
Upload File : |
#!/usr/bin/python
import sqlite
import sys
from urllib import urlencode
debug = True
smoonURL = "http://localhost:8080"
conn = sqlite.connect("/home/mmcgrath/hg/smolt/devdata.sqlite")
cursor = conn.cursor()
def selectQuery(query):
""" Run query and return the results """
try:
cursor.execute(query)
except sqlite.Error, err:
if debug == True:
print "%s" % err
print "Query: %s" % query
sys.exit(1)
return cursor
hosts = selectQuery('select * from host;')
for host in hosts:
UUID = host[1]
LSB = host[2]
OS = host[3]
platform = host[4]
bogomips = host[5]
systemMemory = host[6]
systemSwap = host[7]
vendor = host[8]
model = host[9]
CPU = host[10]
numCpus = host[11]
cpuSpeed = host[12]
language = host[13]
defaultRunlevel = host[14]
postData = urlencode({
'UUID' : UUID,
'OS' : OS,
'platform' : platform,
'bogomips' : bogomips,
'systemMemory' : systemMemory,
'systemSwap' : systemSwap,
'vendor' : vendor,
'system' : model,
'CPUVendor' : CPU.split(' - ')[0].strip(),
'CPUModel' : CPU.split(' - ')[1].strip(),
'numCPUs' : numCpus,
'CPUSpeed' : cpuSpeed,
'language' : language,
'defaultRunlevel' : defaultRunlevel })
# print 'wget -qO- %s/add --post-data "%s"' % (smoonURL, postData)
devices = selectQuery('select host_links.host_u_u_id as UUID, device.description, device.bus, device.class, device.driver from host_links, device where host_links.device_id=device.id;')
for device in devices:
UUID = device[0]
try:
description = device[1].split('|')[1]
except:
description = device[1]
bus = device[2]
type = device[3]
driver = device[4]
postData = urlencode({
'UUID' : UUID,
'Description' : description,
'Bus' : bus,
'Class' : type,
'Driver' : driver,
'VendorID' : '0x0',
'DeviceID' : '0x0'
})
print 'wget -qO- %s/addDevice --post-data "%s"' % (smoonURL, postData)