示例#1
0
import PiClusterTools as pct
import sqlite3 as lite

masterip = "urania.eecs.uc.edu"

print "Building a map of the network..."
subprocess.check_output('nmap -sn 192.168.0.0/24 -oG - | grep -v "^#" | cut -d " " -f 2 > all-hosts.txt', shell=True)
print "Isolating the head node..."
subprocess.check_output('grep -v \"^192.168.0.1$\" < all-hosts.txt > workers.txt', shell=True)

print "Isolating reachable hosts and removing the switch..."
subprocess.check_output('parallel-ssh -h workers.txt -t 0 -p 100 -P \'sudo ifconfig -a | grep HWaddr\' | grep HWaddr > pi-data.txt', shell=True)

inf = open('pi-data.txt', 'r')

pct.initTable()

# Parse the data on live, accessible nodes.  The data will be in the form:
# 192.168.0.12: eth0      Link encap:Ethernet  HWaddr cc:cc:cc:cc:cc:01
for line in inf:
    tokens = re.split('\s+', line)
    myip = tokens[0].replace(':', '')
    mymac = tokens[5]
    myname = pct.nameFromMac(mymac)
    myport = pct.portFromMac(mymac)

    pct.buildServices(mymac, myip, masterip)
    
print "Restarting xinetd"
subprocess.check_output("sudo /etc/init.d/xinetd restart", shell=True)
inf.close()
示例#2
0
#!/usr/bin/python

import os.path
import subprocess
import sys
from random import randint
import xkcdPasswd
import PiClusterTools as pct


username = sys.argv[1]

pct.initUserTable()

if pct.isUserRegistered(username) == False:
    pct.registerUserOnMin(username)
示例#3
0
import PiClusterTools as pct
import sqlite3 as lite

masterip = "urania.eecs.uc.edu"

print "Building a map of the network..."
subprocess.check_output('nmap -sn 192.168.0.0/24 -oG - | grep -v "^#" | cut -d " " -f 2 > all-hosts.txt', shell=True)
print "Isolating the head node..."
subprocess.check_output('grep -v \"^192.168.0.1$\" < all-hosts.txt > workers.txt', shell=True)

print "Isolating reachable hosts and removing the switch..."
subprocess.check_output('parallel-ssh -h workers.txt -t 0 -p 100 -P \'sudo ifconfig -a | grep HWaddr\' | grep HWaddr > pi-data.txt', shell=True)

inf = open('pi-data.txt', 'r')

pct.initTable()

# Parse the data on live, accessible nodes.  The data will be in the form:
# 192.168.0.12: eth0      Link encap:Ethernet  HWaddr cc:cc:cc:cc:cc:01
for line in inf:
    tokens = re.split('\s+', line)
    myip = tokens[0].replace(':', '')
    mymac = tokens[5]
    myname = pct.nameFromMac(mymac)
    myport = pct.portFromMac(mymac)

    if (pct.isMacRegistered(mymac)):
        print myname + " already registered..."
    else:
        pct.buildServices(mymac, myip, masterip)
        pct.registerMac(mymac, myip)
示例#4
0
#!/usr/bin/python

import os.path
import subprocess
import sys
from random import randint
import xkcdPasswd
import PiClusterTools as pct

username = sys.argv[1]

if (pct.isUserRegistered(username)):
    pct.deleteUser(username)