You are viewing a plain text version of this content. The canonical link for it is here.
Posted to tashi-commits@incubator.apache.org by st...@apache.org on 2012/06/17 05:16:02 UTC
svn commit: r1351049 [1/2] - in /incubator/tashi/trunk/src: tashi/
tashi/accounting/ tashi/agents/ tashi/client/ tashi/clustermanager/
tashi/clustermanager/data/ tashi/dfs/ tashi/messaging/ tashi/nodemanager/
tashi/nodemanager/vmcontrol/ tashi/rpycserv...
Author: stroucki
Date: Sun Jun 17 05:16:00 2012
New Revision: 1351049
URL: http://svn.apache.org/viewvc?rev=1351049&view=rev
Log:
clean using pydev
don't overlay system builtin names (id etc.), except for object methods
fix spacing (in Zoni)
fix incorrect variable names
prefix unused return values with 2 underscores
eliminate wild imports
eliminate unused imports
tashi-client: use soft config
fix missing formal parameters
Modified:
incubator/tashi/trunk/src/tashi/accounting/accounting.py
incubator/tashi/trunk/src/tashi/agents/dhcpdns.py
incubator/tashi/trunk/src/tashi/agents/mauiwiki.py
incubator/tashi/trunk/src/tashi/client/tashi-client.py
incubator/tashi/trunk/src/tashi/clustermanager/clustermanager.py
incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py
incubator/tashi/trunk/src/tashi/clustermanager/data/datainterface.py
incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py
incubator/tashi/trunk/src/tashi/clustermanager/data/getentoverride.py
incubator/tashi/trunk/src/tashi/clustermanager/data/ldapoverride.py
incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py
incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py
incubator/tashi/trunk/src/tashi/connectionmanager.py
incubator/tashi/trunk/src/tashi/dfs/vfs.py
incubator/tashi/trunk/src/tashi/messaging/gangliapublisher.py
incubator/tashi/trunk/src/tashi/messaging/messagingloghandler.py
incubator/tashi/trunk/src/tashi/nodemanager/nodemanager.py
incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py
incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py
incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py
incubator/tashi/trunk/src/tashi/parallel.py
incubator/tashi/trunk/src/tashi/rpycservices/rpyctypes.py
incubator/tashi/trunk/src/tashi/util.py
incubator/tashi/trunk/src/tashi/utils/pseudoDes.py
incubator/tashi/trunk/src/zoni/agents/dhcpdns.py
incubator/tashi/trunk/src/zoni/bootstrap/bootstrapinterface.py
incubator/tashi/trunk/src/zoni/bootstrap/pxe.py
incubator/tashi/trunk/src/zoni/client/zoni-cli.py
incubator/tashi/trunk/src/zoni/data/infostore.py
incubator/tashi/trunk/src/zoni/data/reservation.py
incubator/tashi/trunk/src/zoni/data/reservationmanagementinterface.py
incubator/tashi/trunk/src/zoni/data/resourcequerysql.py
incubator/tashi/trunk/src/zoni/data/usermanagement.py
incubator/tashi/trunk/src/zoni/data/usermanagementinterface.py
incubator/tashi/trunk/src/zoni/extra/util.py
incubator/tashi/trunk/src/zoni/hardware/apcswitchedrackpdu.py
incubator/tashi/trunk/src/zoni/hardware/delldrac.py
incubator/tashi/trunk/src/zoni/hardware/dellswitch.py
incubator/tashi/trunk/src/zoni/hardware/f10s50switch.py
incubator/tashi/trunk/src/zoni/hardware/hpilo.py
incubator/tashi/trunk/src/zoni/hardware/hpswitch.py
incubator/tashi/trunk/src/zoni/hardware/hwswitchinterface.py
incubator/tashi/trunk/src/zoni/hardware/ipmi.py
incubator/tashi/trunk/src/zoni/hardware/raritanpdu.py
incubator/tashi/trunk/src/zoni/hardware/systemmanagement.py
incubator/tashi/trunk/src/zoni/hardware/systemmanagementinterface.py
incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py
incubator/tashi/trunk/src/zoni/install/dnsdhcp/zoniDnsDhcpSetup.py
incubator/tashi/trunk/src/zoni/install/pxe/zoniPxeSetup.py
incubator/tashi/trunk/src/zoni/install/www/zoniWebSetup.py
incubator/tashi/trunk/src/zoni/services/pcvciservice.py
incubator/tashi/trunk/src/zoni/services/zonimanager.py
incubator/tashi/trunk/src/zoni/version.py
Modified: incubator/tashi/trunk/src/tashi/accounting/accounting.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/accounting/accounting.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/accounting/accounting.py (original)
+++ incubator/tashi/trunk/src/tashi/accounting/accounting.py Sun Jun 17 05:16:00 2012
@@ -18,9 +18,7 @@
# under the License.
import os
-import time
import sys
-import signal
import logging.config
from tashi.rpycservices import rpycservices
@@ -28,7 +26,7 @@ from rpyc.utils.server import ThreadedSe
#from rpyc.utils.authenticators import TlsliteVdbAuthenticator
#from tashi.rpycservices.rpyctypes import *
-from tashi.util import createClient, instantiateImplementation, boolean, debugConsole
+from tashi.util import createClient, instantiateImplementation, debugConsole
from tashi.utils.config import Config
import tashi
@@ -47,13 +45,14 @@ class Accounting(object):
name = name.lower()
if (name.startswith("hook")):
try:
- self.hooks.append(instantiateImplementation(value, config, cmclient, False))
+ self.hooks.append(instantiateImplementation(value, self.config, self.cm, False))
except:
self.log.exception("Failed to load hook %s" % (value))
def initAccountingServer(self):
service = instantiateImplementation(self.config.get("Accounting", "service"), self.config)
+ #XXXstroucki: disabled authAndEncrypt for now
#if boolean(self.config.get("Security", "authAndEncrypt")):
if False:
pass
Modified: incubator/tashi/trunk/src/tashi/agents/dhcpdns.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/agents/dhcpdns.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/dhcpdns.py (original)
+++ incubator/tashi/trunk/src/tashi/agents/dhcpdns.py Sun Jun 17 05:16:00 2012
@@ -22,7 +22,7 @@ import socket
import subprocess
import time
from instancehook import InstanceHook
-from tashi.rpycservices.rpyctypes import Instance, NetworkConfiguration
+from tashi.rpycservices.rpyctypes import Instance
from tashi import boolean
class DhcpDns(InstanceHook):
@@ -62,12 +62,12 @@ class DhcpDns(InstanceHook):
self.usedIPs = {}
for network in self.ipRange:
ipRange = self.ipRange[network]
- (min, max) = ipRange.split("-")
- min = min.strip()
- max = max.strip()
- ipNum = self.strToIp(min)
- self.ipMin[network] = self.strToIp(min)
- self.ipMax[network] = self.strToIp(max)
+ (ipMin, ipMax) = ipRange.split("-")
+ ipMin = ipMin.strip()
+ ipMax = ipMax.strip()
+ ipNum = self.strToIp(ipMin)
+ self.ipMin[network] = self.strToIp(ipMin)
+ self.ipMax[network] = self.strToIp(ipMax)
self.currentIP[network] = self.ipMin[network]
instances = self.client.getInstances()
@@ -78,7 +78,7 @@ class DhcpDns(InstanceHook):
ipNum = self.strToIp(ip)
self.log.info('Added %s->%s during reinitialization' % (i.name, ip))
self.usedIPs[ipNum] = ip
- except Exception, e:
+ except Exception:
pass
def strToIp(self, s):
@@ -138,7 +138,7 @@ class DhcpDns(InstanceHook):
stdin.write("set hardware-type = 00:00:00:01\n") # Ethernet
stdin.write("create\n")
stdin.close()
- output = stdout.read()
+ __output = stdout.read()
stdout.close()
def removeDhcp(self, name, ipaddr=None):
@@ -157,7 +157,7 @@ class DhcpDns(InstanceHook):
stdin.write("open\n")
stdin.write("remove\n")
stdin.close()
- output = stdout.read()
+ __output = stdout.read()
stdout.close()
def addDns(self, name, ip):
@@ -180,15 +180,15 @@ class DhcpDns(InstanceHook):
stdin.write("update add %s %d IN PTR %s.%s.\n" % (reverseIpStr, self.dnsExpire, name, self.dnsDomain))
stdin.write("\n")
stdin.close()
- output = stdout.read()
+ __output = stdout.read()
stdout.close()
finally:
os.kill(child.pid, signal.SIGTERM)
- (pid, status) = os.waitpid(child.pid, os.WNOHANG)
+ (pid, __status) = os.waitpid(child.pid, os.WNOHANG)
while (pid == 0):
time.sleep(0.5)
os.kill(child.pid, signal.SIGTERM)
- (pid, status) = os.waitpid(child.pid, os.WNOHANG)
+ (pid, __status) = os.waitpid(child.pid, os.WNOHANG)
def removeDns(self, name):
cmd = "nsupdate"
@@ -207,15 +207,15 @@ class DhcpDns(InstanceHook):
stdin.write("update delete %s.%s A\n" % (name, self.dnsDomain))
stdin.write("\n")
stdin.close()
- output = stdout.read()
+ __output = stdout.read()
stdout.close()
finally:
os.kill(child.pid, signal.SIGTERM)
- (pid, status) = os.waitpid(child.pid, os.WNOHANG)
+ (pid, __status) = os.waitpid(child.pid, os.WNOHANG)
while (pid == 0):
time.sleep(0.5)
os.kill(child.pid, signal.SIGTERM)
- (pid, status) = os.waitpid(child.pid, os.WNOHANG)
+ (pid, __status) = os.waitpid(child.pid, os.WNOHANG)
def doUpdate(self, instance):
newInstance = Instance()
@@ -240,7 +240,7 @@ class DhcpDns(InstanceHook):
dhcpName = instance.name + "-nic%d" % (i)
self.log.info("Adding %s:{%s->%s} to DHCP" % (dhcpName, nic.mac, ip))
self.addDhcp(dhcpName, ip, nic.mac)
- except Exception, e:
+ except Exception:
self.log.exception("Failed to add host %s to DHCP/DNS" % (instance.name))
self.doUpdate(instance)
@@ -257,7 +257,7 @@ class DhcpDns(InstanceHook):
# we must have double-assigned the same IP
# address. How does this happen?
del self.usedIPs[ipNum]
- except Exception, e:
+ except Exception:
self.log.exception("Failed to remove host %s, ip %s from pool of usedIPs" % (instance.name, ip))
try:
if (i == 0):
@@ -265,7 +265,7 @@ class DhcpDns(InstanceHook):
else:
dhcpName = instance.name + "-nic%d" % (i)
self.removeDhcp(dhcpName)
- except Exception, e:
+ except Exception:
self.log.exception("Failed to remove host %s from DHCP" % (instance.name))
try:
# XXXstroucki: this can fail if the resolver can't
@@ -273,5 +273,5 @@ class DhcpDns(InstanceHook):
# the hostname should be then pushed onto a list
# to try again next time.
self.removeDns(instance.name)
- except Exception, e:
+ except Exception:
self.log.exception("Failed to remove host %s from DNS" % (instance.name))
Modified: incubator/tashi/trunk/src/tashi/agents/mauiwiki.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/agents/mauiwiki.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/mauiwiki.py (original)
+++ incubator/tashi/trunk/src/tashi/agents/mauiwiki.py Sun Jun 17 05:16:00 2012
@@ -22,9 +22,11 @@
# This code is unmaintained.
# XXXstroucki former file mauipacket.py
-import subprocess
+#import subprocess
import time
-import tashi.utils.pseudoDes
+import SocketServer
+from tashi.utils import pseudoDes
+from tashi.rpycservices.rpyctypes import HostState, InstanceState
class MauiPacket:
def __init__(self, key=0):
@@ -91,7 +93,7 @@ class MauiPacket:
self.auth = auth
if key != None:
self.key = key
- self.timstamp=timestamp
+ self.timestamp=timestamp
self.fixup()
def fixup(self):
datastring = "TS=%i AUTH=%s DT=%s"%(self.timestamp, self.auth, (' '.join(self.data)))
@@ -124,19 +126,12 @@ data:
return s
# XXXstroucki original file mauiwiki.py
-import time
-import hashlib
-import sys
-import subprocess
-import socket, SocketServer
-from socket import gethostname
-import os
import threading
import logging.config
from tashi.parallel import synchronizedmethod
from tashi.services.ttypes import *
-from tashi.util import getConfig, createClient, instantiateImplementation, boolean
+from tashi.util import getConfig, createClient, instantiateImplementation
#from tashi.agents.mauipacket import MauiPacket
import tashi.util
@@ -164,24 +159,24 @@ class InstanceHooks():
def postDestroy(self, inst):
for hook in self.hooks:
hook.postDestroy(inst)
- def idToInst(self, id):
+ def idToInst(self, _id):
instances = self.client.getInstances()
print 'instances ', instances
- insts = [i for i in instances if str(i.id)==str(id)]
+ insts = [i for i in instances if str(i.id)==str(_id)]
if len(insts) == 0:
- raise "No instance with ID %s"%id
+ raise "No instance with ID %s"%_id
if len(insts) > 1:
- raise "Multiple instances with ID %s"%id
+ raise "Multiple instances with ID %s"%_id
inst = insts[0]
return inst
- def destroyById(self, id):
- inst = self.idToInst(id)
- self.client.destroyVm(int(id))
+ def destroyById(self, _id):
+ inst = self.idToInst(_id)
+ self.client.destroyVm(int(_id))
self.postDestroy(inst)
- def activateById(self, id, host):
- inst = self.idToInst(id)
+ def activateById(self, _id, host):
+ inst = self.idToInst(_id)
self.preCreate(inst)
- self.client.activateVm(int(id), host)
+ self.client.activateVm(int(_id), host)
def cmplists(a, b):
for i in range(len(a)):
@@ -408,8 +403,8 @@ class TashiConnection(threading.Thread):
if j.updateTime >= updatetime and j.id in joblist]
jl = {}
for job in jobs:
- id = "%s.%i"%(job.name, job.id)
- jl[id] = {'STATE':self.wikiInstanceState(job),
+ _id = "%s.%i"%(job.name, job.id)
+ jl[_id] = {'STATE':self.wikiInstanceState(job),
'UNAME':self.users[job.userId].name,
'GNAME':self.users[job.userId].name,
'UPDATETIME':int(job.updateTime),
@@ -420,14 +415,14 @@ class TashiConnection(threading.Thread):
'RMEM':str(job.memory),
'WCLIMIT':str(self.defaultJobTime)}
if job.hostId != None:
- jl[id]['TASKLIST'] = self.hosts[job.hostId].name
+ jl[_id]['TASKLIST'] = self.hosts[job.hostId].name
return jl
@synchronizedmethod
- def activateById(self, id, host):
- if not self.instances.has_key(id):
+ def activateById(self, _id, host):
+ if not self.instances.has_key(_id):
raise "no such instance"
- self.ihooks.activateById(id, host)
- self.instances[id].state=InstanceState.Activating
+ self.ihooks.activateById(_id, host)
+ self.instances[_id].state=InstanceState.Activating
class MauiListener(SocketServer.StreamRequestHandler):
def setup(self):
Modified: incubator/tashi/trunk/src/tashi/client/tashi-client.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/client/tashi-client.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/client/tashi-client.py (original)
+++ incubator/tashi/trunk/src/tashi/client/tashi-client.py Sun Jun 17 05:16:00 2012
@@ -21,8 +21,10 @@ import os.path
import random
import sys
import types
-from tashi.rpycservices.rpyctypes import *
-from tashi import vmStates, hostStates, boolean, getConfig, stringPartition, createClient
+from tashi.rpycservices.rpyctypes import NetworkConfiguration,\
+ DiskConfiguration, HostState, Instance, Host, TashiException
+from tashi.utils.config import Config
+from tashi import vmStates, hostStates, boolean, stringPartition, createClient
users = {}
networks = {}
@@ -116,7 +118,7 @@ def parseDisks(arg):
disks = []
for strDisk in strDisks:
strDisk = strDisk.strip()
- (l, s, r) = stringPartition(strDisk, ":")
+ (l, __s, r) = stringPartition(strDisk, ":")
if (r == ""):
r = "False"
r = boolean(r)
@@ -132,12 +134,12 @@ def parseNics(arg):
nics = []
for strNic in strNics:
strNic = strNic.strip()
- (l, s, r) = stringPartition(strNic, ":")
+ (l, __s, r) = stringPartition(strNic, ":")
n = l
if (n == ''):
n = getDefaultNetwork()
n = int(n)
- (l, s, r) = stringPartition(r, ":")
+ (l, __s, r) = stringPartition(r, ":")
ip = l
if (ip == ''):
ip = None
@@ -156,7 +158,7 @@ def parseHints(arg):
hints = {}
for strHint in strHints:
strHint = strHint.strip()
- (l, s, r) = stringPartition(strHint, "=")
+ (l, __s, r) = stringPartition(strHint, "=")
hints[l] = r
return hints
except:
@@ -420,9 +422,9 @@ def transformState(obj):
except:
obj.state = 'Unknown'
-def genKeys(list):
+def genKeys(_list):
keys = {}
- for row in list:
+ for row in _list:
for item in row.__dict__.keys():
keys[item] = item
if ('id' in keys):
@@ -432,12 +434,12 @@ def genKeys(list):
keys = keys.values()
return keys
-def makeTable(list, keys=None):
- (consoleWidth, consoleHeight) = (9999, 9999)
+def makeTable(_list, keys=None):
+ (consoleWidth, __consoleHeight) = (9999, 9999)
try:
# XXXpipe: get number of rows and column on current window
stdout = os.popen("stty size")
- r = stdout.read()
+ __r = stdout.read()
stdout.close()
except:
pass
@@ -559,7 +561,7 @@ def main():
if (len(sys.argv) < 2):
usage()
function = matchFunction(sys.argv[1])
- (config, configFiles) = getConfig(["Client"])
+ config = Config(["Client"])
# build a structure of possible arguments
possibleArgs = {}
Modified: incubator/tashi/trunk/src/tashi/clustermanager/clustermanager.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/clustermanager.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/clustermanager.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/clustermanager.py Sun Jun 17 05:16:00 2012
@@ -19,7 +19,6 @@
import os
import sys
-import time
import logging.config
from tashi.util import boolean, instantiateImplementation, debugConsole
Modified: incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/clustermanagerservice.py Sun Jun 17 05:16:00 2012
@@ -19,7 +19,6 @@ import logging
import threading
import time
-from tashi.rpycservices import rpycservices
from tashi.rpycservices.rpyctypes import Errors, InstanceState, Instance, HostState, TashiException
from tashi import boolean, ConnectionManager, vmStates, hostStates, version, scrubString
@@ -498,7 +497,7 @@ class ClusterManagerService(object):
try:
# Notify the target
- vmId = self.proxy[targetHost.name].receiveVm(instance, cookie)
+ __vmid = self.proxy[targetHost.name].receiveVm(instance, cookie)
except Exception:
self.log.exception('receiveVm failed')
raise
Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/datainterface.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/datainterface.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/datainterface.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/datainterface.py Sun Jun 17 05:16:00 2012
@@ -43,7 +43,7 @@ class DataInterface(object):
def getHosts(self):
raise NotImplementedError
- def getHost(self, id):
+ def getHost(self, _id):
raise NotImplementedError
def getImages(self):
@@ -52,19 +52,19 @@ class DataInterface(object):
def getInstances(self):
raise NotImplementedError
- def getInstance(self, id):
+ def getInstance(self, _id):
raise NotImplementedError
def getNetworks(self):
raise NotImplementedError
- def getNetwork(self, id):
+ def getNetwork(self, _id):
raise NotImplementedError
def getUsers(self):
raise NotImplementedError
- def getUser(self, id):
+ def getUser(self, _id):
raise NotImplementedError
def registerHost(self, hostname, memory, cores, version):
Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/fromconfig.py Sun Jun 17 05:16:00 2012
@@ -169,47 +169,47 @@ class FromConfig(DataInterface):
def getHosts(self):
return self.hosts
- def getHost(self, id):
- host = self.hosts.get(id, None)
+ def getHost(self, _id):
+ host = self.hosts.get(_id, None)
if (not host):
- raise TashiException(d={'errno':Errors.NoSuchHostId,'msg':"No such hostId - %s" % (id)})
+ raise TashiException(d={'errno':Errors.NoSuchHostId,'msg':"No such hostId - %s" % (_id)})
return host
def getInstances(self):
return self.instances
- def getInstance(self, id):
- instance = self.instances.get(id, None)
+ def getInstance(self, _id):
+ instance = self.instances.get(_id, None)
if (not instance):
- raise TashiException(d={'errno':Errors.NoSuchInstanceId,'msg':"No such instanceId - %d" % (id)})
+ raise TashiException(d={'errno':Errors.NoSuchInstanceId,'msg':"No such instanceId - %d" % (_id)})
return instance
def getNetworks(self):
return self.networks
- def getNetwork(self, id):
- return self.networks[id]
+ def getNetwork(self, _id):
+ return self.networks[_id]
def getUsers(self):
return self.users
- def getUser(self, id):
- return self.users[id]
+ def getUser(self, _id):
+ return self.users[_id]
def registerHost(self, hostname, memory, cores, version):
self.hostLock.acquire()
- for id in self.hosts.keys():
- if self.hosts[id].name == hostname:
- host = Host(d={'id':id,'name':hostname,'state':HostState.Normal,'memory':memory,'cores':cores,'version':version})
- self.hosts[id] = host
+ for _id in self.hosts.keys():
+ if self.hosts[_id].name == hostname:
+ host = Host(d={'id':_id,'name':hostname,'state':HostState.Normal,'memory':memory,'cores':cores,'version':version})
+ self.hosts[_id] = host
self.save()
self.hostLock.release()
- return id, True
- id = self.getNewId("hosts")
- self.hosts[id] = Host(d={'id':id,'name':hostname,'state':HostState.Normal,'memory':memory,'cores':cores,'version':version})
+ return _id, True
+ _id = self.getNewId("hosts")
+ self.hosts[_id] = Host(d={'id':_id,'name':hostname,'state':HostState.Normal,'memory':memory,'cores':cores,'version':version})
self.save()
self.hostLock.release()
- return id, False
+ return _id, False
def unregisterHost(self, hostId):
self.hostLock.acquire()
@@ -224,10 +224,10 @@ class FromConfig(DataInterface):
maxId = 0
l = []
if(table == "hosts"):
- for id in self.hosts.keys():
- l.append(id)
- if id >= maxId:
- maxId = id
+ for _id in self.hosts.keys():
+ l.append(_id)
+ if _id >= maxId:
+ maxId = _id
l.sort() # sort to enable comparing with range output
# check if some id is released:
t = range(maxId + 1)
@@ -245,9 +245,9 @@ class FromConfig(DataInterface):
# and in what order does it get loaded
fileName = "./etc/Tashi.cfg"
if not os.path.exists(fileName):
- file = open(fileName, "w")
- file.write("[FromConfig]")
- file.close()
+ filehandle = open(fileName, "w")
+ filehandle.write("[FromConfig]")
+ filehandle.close()
parser = ConfigParser.ConfigParser()
parser.read(fileName)
@@ -255,7 +255,7 @@ class FromConfig(DataInterface):
parser.add_section("FromConfig")
hostsInFile = []
- for (name, value) in parser.items("FromConfig"):
+ for (name, __value) in parser.items("FromConfig"):
name = name.lower()
if (name.startswith("host")):
hostsInFile.append(name)
Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/getentoverride.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/getentoverride.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/getentoverride.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/getentoverride.py Sun Jun 17 05:16:00 2012
@@ -75,20 +75,20 @@ class GetentOverride(DataInterface):
def getHosts(self):
return self.baseDataObject.getHosts()
- def getHost(self, id):
- return self.baseDataObject.getHost(id)
+ def getHost(self, _id):
+ return self.baseDataObject.getHost(_id)
def getInstances(self):
return self.baseDataObject.getInstances()
- def getInstance(self, id):
- return self.baseDataObject.getInstance(id)
+ def getInstance(self, _id):
+ return self.baseDataObject.getInstance(_id)
def getNetworks(self):
return self.baseDataObject.getNetworks()
- def getNetwork(self, id):
- return self.baseDataObject.getNetwork(id)
+ def getNetwork(self, _id):
+ return self.baseDataObject.getNetwork(_id)
def getImages(self):
count = 0
@@ -109,12 +109,12 @@ class GetentOverride(DataInterface):
try:
for l in p.stdout.xreadlines():
ws = l.strip().split(":")
- id = int(ws[2])
+ _id = int(ws[2])
name = ws[0]
user = User()
- user.id = id
+ user.id = _id
user.name = name
- myUsers[id] = user
+ myUsers[_id] = user
self.users = myUsers
self.lastUserUpdate = now
finally:
@@ -124,9 +124,9 @@ class GetentOverride(DataInterface):
self.fetchFromGetent()
return self.users
- def getUser(self, id):
+ def getUser(self, _id):
self.fetchFromGetent()
- return self.users[id]
+ return self.users[_id]
def registerHost(self, hostname, memory, cores, version):
return self.baseDataObject.registerHost(hostname, memory, cores, version)
Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/ldapoverride.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/ldapoverride.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/ldapoverride.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/ldapoverride.py Sun Jun 17 05:16:00 2012
@@ -19,9 +19,8 @@ import subprocess
import time
#XXXstroucki getImages requires os?
import os
-from tashi.rpycservices.rpyctypes import Errors, Network, Host, User, Instance, TashiException, LocalImages, DiskConfiguration, NetworkConfiguration
-from tashi.util import stringPartition, boolean, instantiateImplementation, humanReadable
-from tashi.rpycservices.rpyctypes import User
+from tashi.rpycservices.rpyctypes import User, LocalImages
+from tashi.util import instantiateImplementation, humanReadable
from tashi.clustermanager.data import DataInterface
class LdapOverride(DataInterface):
@@ -57,20 +56,20 @@ class LdapOverride(DataInterface):
def getHosts(self):
return self.baseDataObject.getHosts()
- def getHost(self, id):
- return self.baseDataObject.getHost(id)
+ def getHost(self, _id):
+ return self.baseDataObject.getHost(_id)
def getInstances(self):
return self.baseDataObject.getInstances()
- def getInstance(self, id):
- return self.baseDataObject.getInstance(id)
+ def getInstance(self, _id):
+ return self.baseDataObject.getInstance(_id)
def getNetworks(self):
return self.baseDataObject.getNetworks()
- def getNetwork(self, id):
- return self.baseDataObject.getNetwork(id)
+ def getNetwork(self, _id):
+ return self.baseDataObject.getNetwork(_id)
def getImages(self):
count = 0
@@ -101,7 +100,7 @@ class LdapOverride(DataInterface):
myUsers[user.id] = user
thisUser = {}
else:
- (key, sep, val) = l.partition(":")
+ (key, __sep, val) = l.partition(":")
key = key.strip()
val = val.strip()
thisUser[key] = val
@@ -116,9 +115,9 @@ class LdapOverride(DataInterface):
self.fetchFromLdap()
return self.users
- def getUser(self, id):
+ def getUser(self, _id):
self.fetchFromLdap()
- return self.users[id]
+ return self.users[_id]
def registerHost(self, hostname, memory, cores, version):
return self.baseDataObject.registerHost(hostname, memory, cores, version)
Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/pickled.py Sun Jun 17 05:16:00 2012
@@ -41,14 +41,14 @@ class Pickled(FromConfig):
def cleanInstances(self):
ci = {}
- for ignore, i in self.instances.items():
+ for __ignore, i in self.instances.items():
i2 = Instance(d=i.__dict__)
ci[i2.id] = i2
return ci
def cleanHosts(self):
ch = {}
- for ignore, h in self.hosts.items():
+ for __ignore, h in self.hosts.items():
h2 = Host(d=h.__dict__)
ch[h2.id] = h2
return ch
@@ -59,9 +59,9 @@ class Pickled(FromConfig):
# XXXstroucki could be better
tempfile = "%s.new" % filename
- file = open(tempfile, "w")
- cPickle.dump((self.cleanHosts(), self.cleanInstances(), self.networks, self.users), file)
- file.close()
+ filehandle = open(tempfile, "w")
+ cPickle.dump((self.cleanHosts(), self.cleanInstances(), self.networks, self.users), filehandle)
+ filehandle.close()
try:
os.rename(tempfile, filename)
except OSError:
@@ -72,20 +72,20 @@ class Pickled(FromConfig):
def load(self):
if (os.access(self.file, os.F_OK)):
- file = open(self.file, "r")
- (hosts, instances, networks, users) = cPickle.load(file)
- file.close()
+ filehandle = open(self.file, "r")
+ (hosts, instances, networks, users) = cPickle.load(filehandle)
+ filehandle.close()
else:
(hosts, instances, networks, users) = ({}, {}, {}, {})
self.hosts = hosts
self.instances = instances
self.networks = networks
self.users = users
- for ignore, i in self.instances.items():
+ for __ignore, i in self.instances.items():
if (i.id >= self.maxInstanceId):
self.maxInstanceId = i.id + 1
i._lock = threading.Lock()
self.lockNames[i._lock] = "i%d" % (i.id)
- for ignore, h in self.hosts.items():
+ for __ignore, h in self.hosts.items():
h._lock = threading.Lock()
self.lockNames[h._lock] = "h%d" % (h.id)
Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py Sun Jun 17 05:16:00 2012
@@ -254,14 +254,14 @@ class SQL(DataInterface):
def getHost(self, in_id):
try:
- id = int(in_id)
+ _id = int(in_id)
except:
self.log.exception("Argument to getHost was not integer: %s" % in_id)
- cur = self.executeStatement("SELECT * FROM hosts WHERE id = %d" % id)
+ cur = self.executeStatement("SELECT * FROM hosts WHERE id = %d" % _id)
r = cur.fetchone()
if (r == None):
- raise TashiException(d={'errno':Errors.NoSuchHostId,'msg':"No such hostId - %s" % (id)})
+ raise TashiException(d={'errno':Errors.NoSuchHostId,'msg':"No such hostId - %s" % (_id)})
host = self.makeListHost(r)
return host
@@ -276,16 +276,16 @@ class SQL(DataInterface):
def getInstance(self, in_id):
try:
- id = int(in_id)
+ _id = int(in_id)
except:
self.log.exception("Argument to getInstance was not integer: %s" % in_id)
- cur = self.executeStatement("SELECT * FROM instances WHERE id = %d" % (id))
+ cur = self.executeStatement("SELECT * FROM instances WHERE id = %d" % (_id))
# XXXstroucki should only return one row.
# what about migration? should it be enforced?
r = cur.fetchone()
if (not r):
- raise TashiException(d={'errno':Errors.NoSuchInstanceId, 'msg':"No such instanceId - %d" % (id)})
+ raise TashiException(d={'errno':Errors.NoSuchInstanceId, 'msg':"No such instanceId - %d" % (_id)})
instance = self.makeListInstance(r)
return instance
@@ -298,8 +298,8 @@ class SQL(DataInterface):
networks[network.id] = network
return networks
- def getNetwork(self, id):
- cur = self.executeStatement("SELECT * FROM networks WHERE id = %d" % (id))
+ def getNetwork(self, _id):
+ cur = self.executeStatement("SELECT * FROM networks WHERE id = %d" % (_id))
r = cur.fetchone()
network = Network(d={'id':r[0], 'name':r[1]})
return network
@@ -325,8 +325,8 @@ class SQL(DataInterface):
users[user.id] = user
return users
- def getUser(self, id):
- cur = self.executeStatement("SELECT * FROM users WHERE id = %d" % (id))
+ def getUser(self, _id):
+ cur = self.executeStatement("SELECT * FROM users WHERE id = %d" % (_id))
r = cur.fetchone()
user = User(d={'id':r[0], 'name':r[1], 'passwd':r[2]})
return user
@@ -337,20 +337,20 @@ class SQL(DataInterface):
res = cur.fetchall()
for r in res:
if r[1] == hostname:
- id = r[0]
- self.log.warning("Host %s already registered, update will be done" % id)
+ _id = r[0]
+ self.log.warning("Host %s already registered, update will be done" % _id)
s = ""
- host = Host(d={'id': id, 'up': 0, 'decayed': 0, 'state': 1, 'name': hostname, 'memory':memory, 'cores': cores, 'version':version})
+ host = Host(d={'id': _id, 'up': 0, 'decayed': 0, 'state': 1, 'name': hostname, 'memory':memory, 'cores': cores, 'version':version})
l = self.makeHostList(host)
for e in range(0, len(self.hostOrder)):
s = s + self.hostOrder[e] + "=" + l[e]
if (e < len(self.hostOrder)-1):
s = s + ", "
- self.executeStatement("UPDATE hosts SET %s WHERE id = %d" % (s, id))
+ self.executeStatement("UPDATE hosts SET %s WHERE id = %d" % (s, _id))
self.hostLock.release()
return r[0], True
- id = self.getNewId("hosts")
- host = Host(d={'id': id, 'up': 0, 'decayed': 0, 'state': 1, 'name': hostname, 'memory':memory, 'cores': cores, 'version':version})
+ _id = self.getNewId("hosts")
+ host = Host(d={'id': _id, 'up': 0, 'decayed': 0, 'state': 1, 'name': hostname, 'memory':memory, 'cores': cores, 'version':version})
l = self.makeHostList(host)
self.executeStatement("INSERT INTO hosts VALUES (%s, %s, %s, %s, %s, %s, %s, %s)" % tuple(l))
self.hostLock.release()
@@ -374,10 +374,10 @@ class SQL(DataInterface):
maxId = 0 # the first id would be 1
l = []
for r in res:
- id = r[0]
- l.append(id)
- if id >= maxId:
- maxId = id
+ _id = r[0]
+ l.append(_id)
+ if _id >= maxId:
+ maxId = _id
l.sort() # sort to enable comparing with range output
# check if some id is released:
t = range(maxId + 1)
Modified: incubator/tashi/trunk/src/tashi/connectionmanager.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/connectionmanager.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/connectionmanager.py (original)
+++ incubator/tashi/trunk/src/tashi/connectionmanager.py Sun Jun 17 05:16:00 2012
@@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-from tashi.rpycservices import rpycservices
from tashi import Connection
#from tashi.rpycservices.rpyctypes import *
Modified: incubator/tashi/trunk/src/tashi/dfs/vfs.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/dfs/vfs.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/dfs/vfs.py (original)
+++ incubator/tashi/trunk/src/tashi/dfs/vfs.py Sun Jun 17 05:16:00 2012
@@ -18,7 +18,6 @@
# implementation of dfs interface functions
import shutil
-import os
import os.path
from dfsinterface import DfsInterface
Modified: incubator/tashi/trunk/src/tashi/messaging/gangliapublisher.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/messaging/gangliapublisher.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/messaging/gangliapublisher.py (original)
+++ incubator/tashi/trunk/src/tashi/messaging/gangliapublisher.py Sun Jun 17 05:16:00 2012
@@ -17,7 +17,6 @@
import os
import time
-import types
from tashi import scrubString
Modified: incubator/tashi/trunk/src/tashi/messaging/messagingloghandler.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/messaging/messagingloghandler.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/messaging/messagingloghandler.py (original)
+++ incubator/tashi/trunk/src/tashi/messaging/messagingloghandler.py Sun Jun 17 05:16:00 2012
@@ -34,7 +34,9 @@ class MessagingLogHandler(logging.Handle
try:
key = "log_%s_%d_%d" % (self.name, self.msgIndex, int(time.time()*1000))
val = self.format(record)
- tashi.publisher.publish({key:val})
+ #XXXstroucki publisher does not exist
+ (_,_) = (key,val)
+ #tashi.publisher.publish({key:val})
self.msgIndex = self.msgIndex + 1
except Exception, e:
print e
Modified: incubator/tashi/trunk/src/tashi/nodemanager/nodemanager.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/nodemanager.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/nodemanager.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/nodemanager.py Sun Jun 17 05:16:00 2012
@@ -18,10 +18,8 @@
# under the License.
import logging.config
-import signal
import sys
import os
-import time
from tashi.util import instantiateImplementation, debugConsole
import tashi
Modified: incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/nodemanagerservice.py Sun Jun 17 05:16:00 2012
@@ -20,7 +20,6 @@ import socket
import threading
import time
-from tashi.rpycservices import rpycservices
from tashi.rpycservices.rpyctypes import InstanceState, TashiException, Errors, Instance
from tashi import boolean, vmStates, ConnectionManager
import tashi
@@ -102,7 +101,6 @@ class NodeManagerService(object):
# send data to CM
# XXXstroucki adapt this for accounting?
def __flushNotifyCM(self):
- start = time.time()
# send data to CM, adding message to buffer if
# it fails
try:
@@ -209,14 +207,16 @@ class NodeManagerService(object):
instance = self.instances.get(vmId, None)
if (not instance):
continue
- id = instance.id
+ _id = instance.id
stats = self.vmm.getStats(vmId)
for stat in stats:
- publishList.append({"vm_%d_%s" % (id, stat):stats[stat]})
+ publishList.append({"vm_%d_%s" % (_id, stat):stats[stat]})
except:
self.log.exception('statsThread threw an exception')
if (len(publishList) > 0):
- tashi.publisher.publishList(publishList)
+ # XXXstroucki: no publisher currently
+ pass
+ #tashi.publisher.publishList(publishList)
except:
self.log.exception('statsThread threw an exception')
time.sleep(self.statsInterval)
@@ -224,7 +224,8 @@ class NodeManagerService(object):
def __registerHost(self):
hostname = socket.gethostname()
# populate some defaults
- # XXXstroucki: I think it's better if the nodemanager fills these in properly when registering with the clustermanager
+ # XXXstroucki: I think it's better if the nodemanager fills these in
+ # properly when registering with the clustermanager
memory = 0
cores = 0
version = "empty"
Modified: incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/qemu.py Sun Jun 17 05:16:00 2012
@@ -50,12 +50,12 @@ def controlConsole(child, port):
output = child.monitorFd
#print "listen"
select.select([ls], [], [])
- (s, clientAddr) = listenSocket.accept()
+ (s, __clientAddr) = listenSocket.accept()
while s:
if (output != -1):
- (rl, wl, el) = select.select([s, output], [], [])
+ (rl, __wl, __el) = select.select([s, output], [], [])
else:
- (rl, wl, el) = select.select([s], [], [])
+ (rl, __wl, __el) = select.select([s], [], [])
if (len(rl) > 0):
if (rl[0] == s):
#print "from s"
@@ -150,6 +150,7 @@ class Qemu(VmControlInterface):
for f in os.listdir("/proc"):
try:
+ # XXXstroucki: pydev complains about bin being built-in
bin = os.readlink("/proc/%s/exe" % (f))
if (bin.find(real_bin) != -1):
pids.append(int(f))
@@ -223,7 +224,7 @@ class Qemu(VmControlInterface):
scratchName = "lv%s" % name
log.info("Removing any scratch for %s" % (name))
cmd = "/sbin/lvremove --quiet -f %s/%s" % (self.scratchVg, scratchName)
- result = subprocess.Popen(cmd.split(), executable=cmd.split()[0], stdout=subprocess.PIPE, stderr=open(os.devnull, "w"), close_fds=True).wait()
+ __result = subprocess.Popen(cmd.split(), executable=cmd.split()[0], stdout=subprocess.PIPE, stderr=open(os.devnull, "w"), close_fds=True).wait()
except:
log.warning("Problem cleaning scratch volumes")
pass
@@ -314,7 +315,7 @@ class Qemu(VmControlInterface):
monitorFd = child.monitorFd
buf = ""
try:
- (rlist, wlist, xlist) = select.select([monitorFd], [], [], 0.0)
+ (rlist, __wlist, __xlist) = select.select([monitorFd], [], [], 0.0)
while (len(rlist) > 0):
c = os.read(monitorFd, 1)
if (c == ""):
@@ -322,7 +323,7 @@ class Qemu(VmControlInterface):
child.errorBit = True
raise RuntimeError
buf = buf + c
- (rlist, wlist, xlist) = select.select([monitorFd], [], [], 0.0)
+ (rlist, __wlist, __xlist) = select.select([monitorFd], [], [], 0.0)
finally:
child.monitorHistory.append(buf)
return buf
@@ -337,7 +338,7 @@ class Qemu(VmControlInterface):
while (buf[-(len(needle)):] != needle):
#print "[BUF]: %s" % (buf)
#print "[NEE]: %s" % (needle)
- (rlist, wlist, xlist) = select.select([monitorFd], [], [], timeout)
+ (rlist, __wlist, __xlist) = select.select([monitorFd], [], [], timeout)
if (len(rlist) == 0):
log.error("Timeout getting results from monitor on FD %s for vmId %d" % (monitorFd, child.pid))
child.errorBit = True
@@ -487,7 +488,7 @@ class Qemu(VmControlInterface):
# XXXstroucki check for capacity
cmd = "/sbin/lvcreate --quiet -n%s -L %dG %s" % (scratchName, scratchSize, self.scratchVg)
# XXXstroucki check result
- result = subprocess.Popen(cmd.split(), executable=cmd.split()[0], stdout=subprocess.PIPE).wait()
+ __result = subprocess.Popen(cmd.split(), executable=cmd.split()[0], stdout=subprocess.PIPE).wait()
index += 1
thisDiskList = [ "file=/dev/%s/%s" % (self.scratchVg, scratchName) ]
@@ -710,7 +711,6 @@ class Qemu(VmControlInterface):
return vmId
def __checkPortListening(self, port):
- lc = 0
# XXXpipe: find whether something is listening yet on the port
(stdin, stdout) = os.popen2("netstat -ln | grep 0.0.0.0:%d | wc -l" % (port))
stdin.close()
@@ -766,7 +766,9 @@ class Qemu(VmControlInterface):
try:
child = self.__getChildFromPid(vmId)
except:
- log.error("Failed to get child info; transportCookie = %s; hostname = %s" % (str(cPickle.loads(transportCookie)), socket.hostname()))
+ # XXXstroucki: Does hostname contain the peer hostname?
+ log.error("Failed to get child info; transportCookie = %s; hostname = %s" %
+ (str(cPickle.loads(transportCookie)), _hostname))
raise
try:
self.__getPtyInfo(child, True)
@@ -936,10 +938,10 @@ class Qemu(VmControlInterface):
if (child):
res = self.__enterCommand(child, "info blockstats")
for l in res.split("\n"):
- (device, sep, data) = stringPartition(l, ": ")
+ (device, __sep, data) = stringPartition(l, ": ")
if (data != ""):
for field in data.split(" "):
- (label, sep, val) = stringPartition(field, "=")
+ (label, __sep, val) = stringPartition(field, "=")
if (val != ""):
self.stats[vmId]['%s_%s_per_s' % (device, label)] = (float(val) - float(self.stats[vmId].get('%s_%s' % (device, label), 0)))/self.statsInterval
self.stats[vmId]['%s_%s' % (device, label)] = int(val)
@@ -964,7 +966,7 @@ class Qemu(VmControlInterface):
f.close()
for l in netData:
if (l.find(self.ifPrefix) != -1):
- (dev, sep, ld) = stringPartition(l, ":")
+ (dev, __sep, ld) = stringPartition(l, ":")
dev = dev.strip()
ws = ld.split()
recvBytes = float(ws[0])
Modified: incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py (original)
+++ incubator/tashi/trunk/src/tashi/nodemanager/vmcontrol/xenpv.py Sun Jun 17 05:16:00 2012
@@ -15,37 +15,35 @@
# specific language governing permissions and limitations
# under the License.
-import os
import os.path
import cPickle
-import subprocess # FIXME: should switch os.system to this
+import subprocess
import time
import threading
import logging
import socket
from vmcontrolinterface import VmControlInterface
-from tashi.rpycservices.rpyctypes import Errors, InstanceState, TashiException
+from tashi.rpycservices.rpyctypes import InstanceState
from tashi.rpycservices.rpyctypes import Instance, Host
-from tashi import boolean, convertExceptions, ConnectionManager, version
+from tashi import version
from tashi.util import broken
-import tashi.parallel
-from tashi.parallel import synchronized, synchronizedmethod
+from tashi.parallel import synchronizedmethod
log = logging.getLogger(__file__)
# FIXME: these should throw errors on failure
def domIdToName(domid):
# XXXpipe: get domain name from id
- f = os.popen("/usr/sbin/xm domname %i"%domid)
+ f = os.popen("/usr/sbin/xm domname %i"% domid)
name = f.readline().strip()
f.close()
return name
def domNameToId(domname):
# XXXpipe: get domain id from name
- f = os.popen("/usr/sbin/xm domid %s"%domname)
+ f = os.popen("/usr/sbin/xm domid %s"% domname)
name = f.readline().strip()
f.close()
return int(name)
@@ -55,10 +53,10 @@ def nameToId(domname, prefix='tashi'):
if domname[0:(len(prefix))] != prefix:
return None
try:
- id = int(domname[len(prefix):])
+ _id = int(domname[len(prefix):])
except:
return None
- return id
+ return _id
# Try to do a listVms call using info from xend
@@ -80,12 +78,12 @@ def listVms(prefix='tashi'):
vminfo[fields[i]] = line[i]
# if the name begins with our prefix, get the id,
# otherwise skip this record
- id = nameToId(vminfo['name'], prefix)
- if id == None:
+ _id = nameToId(vminfo['name'], prefix)
+ if _id == None:
continue
# fill in the instance object
- instance.id = int(id)
+ instance.id = int(_id)
instance.vmId = int(vminfo['vmId'])
instance.state = InstanceState.Running
if(vminfo['state'][2] !='-'):
@@ -142,8 +140,8 @@ class XenPV(VmControlInterface, threadin
self.nm.vmStateChange(a.vmId, a.state, InstanceState.Exited)
for vmId in vmlist.keys():
if not self.newvms.has_key(vmId):
+ # FIXME: log this
print 'WARNING: found vm that should be managed, but is not'
- # FIXME: log that
def run(self):
@@ -155,7 +153,7 @@ class XenPV(VmControlInterface, threadin
# a lot easier
########################################
def createXenConfig(self, vmName,
- image, macAddr, netID, memory, cores, hints, id):
+ image, macAddr, netID, memory, cores, hints, _id):
bootstr = None
rootconfig = None
diskconfig = None
@@ -171,6 +169,7 @@ class XenPV(VmControlInterface, threadin
disk0 = 'tap:%s' % self.disktype
diskU = 'xvda1'
+ # XXXstroucki: use soft config
try:
bridgeformat = self.config.get('XenPV', 'defaultBridgeFormat')
except:
@@ -360,9 +359,9 @@ extra='xencons=tty'
r = os.system(cmd)
# self.deleteXenConfig(name)
if r != 0:
+ # FIXME: log/handle error
print 'WARNING: "%s" returned %i' % ( cmd, r)
raise Exception, 'WARNING: "%s" returned %i' % ( cmd, r)
- # FIXME: log/handle error
vmId = domNameToId(name)
self.newvms[vmId] = instance
instance.vmId = vmId
@@ -387,7 +386,7 @@ extra='xencons=tty'
instance = self.newvms[vmId]
instance.suspendCookie = suspendCookie
infof = self.dfs.open(infofile, "w")
- name = domIdToName(vmId)
+ #name = domIdToName(vmId)
cPickle.dump(instance, infof)
infof.close()
@@ -416,7 +415,7 @@ extra='xencons=tty'
self.dfs.unlink(infofile)
self.dfs.copyFrom(source, tmpfile)
- r = os.system("/usr/sbin/xm restore %s"%(tmpfile))
+ __r = os.system("/usr/sbin/xm restore %s"%(tmpfile))
os.unlink(tmpfile)
# FIXME: if the vmName function changes, suspended vms will become invalid
Modified: incubator/tashi/trunk/src/tashi/parallel.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/parallel.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/parallel.py (original)
+++ incubator/tashi/trunk/src/tashi/parallel.py Sun Jun 17 05:16:00 2012
@@ -34,7 +34,8 @@ class ThreadPool(Queue.Queue):
def __init__(self, size=8, maxsize=0):
Queue.Queue.__init__(self, maxsize)
for i in range(size):
- thread = threading.Thread(target=self._worker)
+ name = "parallel.ThreadPool#%s" % (i)
+ thread = threading.Thread(name=name, target=self._worker)
thread.setDaemon(True)
thread.start()
def _worker(self):
@@ -129,9 +130,9 @@ class TestThreadPool(unittest.TestCase):
time.sleep(sleep)
queue.put(None)
tt = time.time()
- for i in range(4):
+ for _ in range(4):
slowfunc()
- for i in range(4):
+ for _ in range(4):
queue.get()
tt = time.time() - tt
self.assertAlmostEqual(tt, 4, 1)
@@ -143,9 +144,9 @@ class TestThreadPool(unittest.TestCase):
time.sleep(sleep)
queue.put(None)
tt = time.time()
- for i in range(8):
+ for _ in range(8):
slowthreadfunc()
- for i in range(8):
+ for _ in range(8):
queue.get()
tt = time.time() - tt
self.assertAlmostEqual(tt, 1, 1)
@@ -158,9 +159,9 @@ class TestThreadPool(unittest.TestCase):
time.sleep(sleep)
queue.put(None)
tt = time.time()
- for i in range(8):
+ for _ in range(8):
slowpoolfunc()
- for i in range(8):
+ for _ in range(8):
queue.get()
tt = time.time() - tt
self.assertAlmostEqual(tt, 2, 1)
@@ -175,9 +176,9 @@ class TestThreadPool(unittest.TestCase):
queue.put(None)
sc = slowclass()
tt = time.time()
- for i in range(4):
+ for _ in range(4):
sc.beslow()
- for i in range(4):
+ for _ in range(4):
queue.get()
tt = time.time() - tt
self.assertAlmostEqual(tt, 4, 1)
@@ -193,9 +194,9 @@ class TestThreadPool(unittest.TestCase):
queue.put(None)
sc = slowclass()
tt = time.time()
- for i in range(4):
+ for _ in range(4):
sc.beslow()
- for i in range(4):
+ for _ in range(4):
queue.get()
tt = time.time() - tt
self.assertAlmostEqual(tt, 1, 1)
@@ -211,9 +212,9 @@ class TestThreadPool(unittest.TestCase):
queue.put(None)
sc = slowclass()
tt = time.time()
- for i in range(16):
+ for _ in range(16):
sc.beslow()
- for i in range(16):
+ for _ in range(16):
queue.get()
tt = time.time() - tt
self.assertAlmostEqual(tt, 2, 1)
@@ -228,9 +229,9 @@ class TestThreadPool(unittest.TestCase):
def slowthreadfunc():
addtoqueue()
tt = time.time()
- for i in range(4):
+ for _ in range(4):
slowthreadfunc()
- for i in range(4):
+ for _ in range(4):
queue.get()
tt = time.time() - tt
self.assertAlmostEqual(tt, 4, 1)
@@ -254,10 +255,10 @@ class TestThreadPool(unittest.TestCase):
def slowthreadfunc2():
atc.addtoqueue2()
tt = time.time()
- for i in range(4):
+ for _ in range(4):
slowthreadfunc1()
slowthreadfunc2()
- for i in range(8):
+ for _ in range(8):
queue.get()
tt = time.time() - tt
self.assertAlmostEqual(tt, 8, 1)
@@ -279,10 +280,10 @@ class TestThreadPool(unittest.TestCase):
def slowthreadfunc2():
atc.addtoqueue2()
tt = time.time()
- for i in range(4):
+ for _ in range(4):
slowthreadfunc1()
slowthreadfunc2()
- for i in range(8):
+ for _ in range(8):
queue.get()
tt = time.time() - tt
self.assertAlmostEqual(tt, 1, 1)
Modified: incubator/tashi/trunk/src/tashi/rpycservices/rpyctypes.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/rpycservices/rpyctypes.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/rpycservices/rpyctypes.py (original)
+++ incubator/tashi/trunk/src/tashi/rpycservices/rpyctypes.py Sun Jun 17 05:16:00 2012
@@ -15,6 +15,8 @@
# specific language governing permissions and limitations
# under the License.
+# XXXstroucki: shouldn't this be tashitypes.py instead?
+
class Errors(object):
ConvertedException = 1
NoSuchInstanceId = 2
Modified: incubator/tashi/trunk/src/tashi/util.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/util.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/util.py (original)
+++ incubator/tashi/trunk/src/tashi/util.py Sun Jun 17 05:16:00 2012
@@ -25,11 +25,10 @@ import os
import signal
#import struct
import sys
-import threading
+#import threading
import time
import traceback
import types
-import getpass
import functools
from tashi.rpycservices import rpycservices
@@ -90,14 +89,14 @@ def timed(oldFunc):
return res
return newFunc
-def editAndContinue(file, mod, name):
+def editAndContinue(filespec, mod, name):
def wrapper(oldFunc):
persist = {}
persist['lastMod'] = time.time()
persist['oldFunc'] = oldFunc
persist['func'] = oldFunc
def newFunc(*args, **kw):
- modTime = os.stat(file)[8]
+ modTime = os.stat(filespec)[8]
if (modTime > persist['lastMod']):
persist['lastMod'] = modTime
space = {}
@@ -185,6 +184,7 @@ def boolean(value):
def instantiateImplementation(className, *args):
"""Create an instance of an object with the given class name and list
of args to __init__"""
+ obj = None
if (className.rfind(".") != -1):
package = className[:className.rfind(".")]
cmd = "import %s\n" % (package)
@@ -233,13 +233,12 @@ def __getShellFn():
def debugConsole(globalDict):
"""A debugging console that optionally uses pysh"""
def realDebugConsole(globalDict):
- import os
try :
import atexit
(calltype, shellfn) = __getShellFn()
def resetConsole():
# XXXpipe: make input window sane
- (stdin, stdout) = os.popen2("reset")
+ (__stdin, stdout) = os.popen2("reset")
stdout.read()
atexit.register(resetConsole)
if calltype == 1:
@@ -250,12 +249,12 @@ def debugConsole(globalDict):
dbgshell(user_ns=globalDict)
except Exception, e:
CONSOLE_TEXT=">>> "
- input = " "
- while (input != ""):
+ inputline = " "
+ while (inputline != ""):
sys.stdout.write(CONSOLE_TEXT)
- input = sys.stdin.readline()
+ inputline = sys.stdin.readline()
try:
- exec(input) in globalDict
+ exec(inputline) in globalDict
except Exception, e:
sys.stdout.write(str(e) + "\n")
Modified: incubator/tashi/trunk/src/tashi/utils/pseudoDes.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/utils/pseudoDes.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/utils/pseudoDes.py (original)
+++ incubator/tashi/trunk/src/tashi/utils/pseudoDes.py Sun Jun 17 05:16:00 2012
@@ -27,7 +27,7 @@ def crc(short, char):
short = short & 0xffff
char = char & 0xff
value = short ^ (char << 8)
- for i in range(0, 8):
+ for __i in range(0, 8):
if value & 0x8000:
value = (value << 1) ^ 4129
else:
Modified: incubator/tashi/trunk/src/zoni/agents/dhcpdns.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/agents/dhcpdns.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/agents/dhcpdns.py (original)
+++ incubator/tashi/trunk/src/zoni/agents/dhcpdns.py Sun Jun 17 05:16:00 2012
@@ -27,6 +27,7 @@ import time
#from instancehook import InstanceHook
#from tashi.services.ttypes import Instance, NetworkConfiguration
#from tashi import boolean
+from tashi.rpycservices.rpyctypes import Instance
class DhcpDns():
Modified: incubator/tashi/trunk/src/zoni/bootstrap/bootstrapinterface.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/bootstrap/bootstrapinterface.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/bootstrap/bootstrapinterface.py (original)
+++ incubator/tashi/trunk/src/zoni/bootstrap/bootstrapinterface.py Sun Jun 17 05:16:00 2012
@@ -18,10 +18,6 @@
# $Id$
#
-import sys
-import os
-import optparse
-
class BootStrapInterface(object):
""" Interface description for booting
Modified: incubator/tashi/trunk/src/zoni/bootstrap/pxe.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/bootstrap/pxe.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/bootstrap/pxe.py (original)
+++ incubator/tashi/trunk/src/zoni/bootstrap/pxe.py Sun Jun 17 05:16:00 2012
@@ -22,7 +22,6 @@ import os
import sys
import string
import datetime
-import subprocess
import MySQLdb
import traceback
import logging
Modified: incubator/tashi/trunk/src/zoni/client/zoni-cli.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/client/zoni-cli.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/client/zoni-cli.py (original)
+++ incubator/tashi/trunk/src/zoni/client/zoni-cli.py Sun Jun 17 05:16:00 2012
@@ -20,43 +20,36 @@
#
# $Id$
#
-import os
-import sys
+
import optparse
import socket
import logging.config
import getpass
+import os
+import sys
import re
+import string
import subprocess
-
-
#from zoni import *
#from zoni.data.resourcequerysql import ResourceQuerySql
-import zoni
-from zoni.data.resourcequerysql import *
-
-from zoni.data.usermanagementinterface import UserManagementInterface
-from zoni.data.usermanagementinterface import UserManagementInterface
+#import zoni
+#from zoni.data.resourcequerysql import *
-from zoni.bootstrap.bootstrapinterface import BootStrapInterface
from zoni.bootstrap.pxe import Pxe
-from zoni.hardware.systemmanagementinterface import SystemManagementInterface
from zoni.hardware.ipmi import Ipmi
-from zoni.hardware.hwswitchinterface import HwSwitchInterface
from zoni.hardware.dellswitch import HwDellSwitch
from zoni.hardware.raritanpdu import raritanDominionPx
from zoni.hardware.delldrac import dellDrac
+import zoni.hardware.systemmanagement
+from zoni.data import usermanagement
from zoni.agents.dhcpdns import DhcpDns
-from zoni.hardware.systemmanagement import SystemManagement
-
-
-from zoni.extra.util import *
-from zoni.version import *
+from zoni.extra.util import validIp, validMac
+from zoni.version import version, revision
-from tashi.util import instantiateImplementation, signalHandler
+from tashi.util import instantiateImplementation, getConfig
#import zoni.data.usermanagement
#from usermanagement import UserManagement
@@ -71,7 +64,7 @@ def main():
(configs, configFiles) = getConfig()
logging.config.fileConfig(configFiles)
- log = logging.getLogger(os.path.basename(__file__))
+ #log = logging.getLogger(os.path.basename(__file__))
#logit(configs['logFile'], "Starting Zoni client")
#logit(configs['logFile'], "Loading config file")
@@ -432,7 +425,7 @@ def main():
userId = usermgt.getUserId(options.userName)
if userId:
- reservationId = reservation.createReservation(userId, options.reservationDuration, options.myNotes + " " + str(string.join(args[0:len(args)])))
+ __reservationId = reservation.createReservation(userId, options.reservationDuration, options.myNotes + " " + str(string.join(args[0:len(args)])))
else:
print "user doesn't exist"
@@ -739,7 +732,7 @@ def main():
try:
socket.gethostbyname(hostName)
sys.stdout.write("[Success]\n")
- except Exception, e:
+ except Exception:
sys.stdout.write("[Fail]\n")
else:
mesg = "ERROR: Malformed IP Address\n"
@@ -762,7 +755,7 @@ def main():
try:
socket.gethostbyname(hostName)
sys.stdout.write("[Fail]\n")
- except Exception, e:
+ except Exception:
sys.stdout.write("[Success]\n")
if options.removeDhcp:
dhcpdns.removeDhcp(hostName)
Modified: incubator/tashi/trunk/src/zoni/data/infostore.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/data/infostore.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/data/infostore.py (original)
+++ incubator/tashi/trunk/src/zoni/data/infostore.py Sun Jun 17 05:16:00 2012
@@ -18,10 +18,6 @@
# $Id$
#
-import sys
-import os
-import optparse
-
class InfoStore (object):
""" Interface description for query system resources
Modified: incubator/tashi/trunk/src/zoni/data/reservation.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/data/reservation.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/data/reservation.py (original)
+++ incubator/tashi/trunk/src/zoni/data/reservation.py Sun Jun 17 05:16:00 2012
@@ -18,7 +18,6 @@
# $Id:$
#
-import sys
import os
import string
import logging
@@ -88,9 +87,9 @@ class reservationMysql(ReservationManage
def delReservation (self, userId):
raise NotImplementedError
- def defineReservation():
+ def defineReservation(self):
raise NotImplementedError
- def showReservation():
+ def showReservation(self):
raise NotImplementedError
Modified: incubator/tashi/trunk/src/zoni/data/reservationmanagementinterface.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/data/reservationmanagementinterface.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/data/reservationmanagementinterface.py (original)
+++ incubator/tashi/trunk/src/zoni/data/reservationmanagementinterface.py Sun Jun 17 05:16:00 2012
@@ -18,9 +18,6 @@
# $Id:$
#
-import sys
-import os
-
class ReservationManagementInterface(object):
""" Interface description for reservation management
@@ -50,9 +47,9 @@ class ReservationManagementInterface(obj
def delReservation (self, userId):
raise NotImplementedError
- def defineReservation():
+ def defineReservation(self):
raise NotImplementedError
- def showReservation():
+ def showReservation(self):
raise NotImplementedError
Modified: incubator/tashi/trunk/src/zoni/data/resourcequerysql.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/data/resourcequerysql.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/data/resourcequerysql.py (original)
+++ incubator/tashi/trunk/src/zoni/data/resourcequerysql.py Sun Jun 17 05:16:00 2012
@@ -22,16 +22,13 @@ import os
import sys
import string
import MySQLdb
-import subprocess
import traceback
import logging
-import threading
import time
import usermanagement
from zoni.data.infostore import InfoStore
-from zoni.extra.util import checkSuper, createKey
-from zoni.agents.dhcpdns import DhcpDns
+from zoni.extra.util import createKey
class ResourceQuerySql(InfoStore):
def __init__(self, config, verbose=None):
@@ -80,7 +77,7 @@ class ResourceQuerySql(InfoStore):
vlans = []
for val in vlanInfo.split(","):
try:
- ret = self.getVlanId(val.split(":")[0])
+ __ret = self.getVlanId(val.split(":")[0])
vlans.append(val)
except Exception, e:
print e
@@ -96,7 +93,7 @@ class ResourceQuerySql(InfoStore):
domainKey = createKey(name)
query = "insert into domaininfo (domain_name, domain_desc, domain_key) values ('%s','%s', '%s')" % (name, desc, domainKey)
try:
- result = self.insertDb(query)
+ __result = self.insertDb(query)
mesg = "Adding domain %s(%s)" % (name, desc)
self.log.info(mesg)
except Exception, e:
@@ -112,7 +109,7 @@ class ResourceQuerySql(InfoStore):
vlanType = i.split(":")[1]
query = "insert into domainmembermap values (%d, %d, '%s')" % (domainId, vlanId, vlanType)
try:
- result = self.insertDb(query)
+ __result = self.insertDb(query)
except Exception, e:
print e
@@ -133,16 +130,16 @@ class ResourceQuerySql(InfoStore):
mesg = "Removing domain %s" % (name)
self.log.info(mesg)
query = "delete from domaininfo where domain_name = '%s'" % (name)
- result = self.__deleteDb(query)
+ __result = self.__deleteDb(query)
# Need to remove any vlans attached to this domain
query = "delete from domainmembermap where domain_id = '%s'" % (domainId)
- result = self.__deleteDb(query)
+ __result = self.__deleteDb(query)
def showDomains(self):
usermgt = eval("usermanagement.%s" % (self.config['userManagement']) + "()")
query = "select r.reservation_id, r.user_id, d.domain_name, d.domain_desc from domaininfo d, allocationinfo a, reservationinfo r where d.domain_id = a.domain_id and a.reservation_id = r.reservation_id"
result = self.selectDb(query)
- desc = result.description
+ #desc = result.description
if result.rowcount > 0:
print "%s\t%s\t%s\t%s" % (result.description[0][0], result.description[1][0], result.description[2][0], result.description[3][0])
print "------------------------------------------------------------"
@@ -173,7 +170,7 @@ class ResourceQuerySql(InfoStore):
return -1
query = "insert into vlaninfo (vlan_num, vlan_desc) values ('%s','%s')" % (vnumber, desc)
try:
- result = self.insertDb(query)
+ __result = self.insertDb(query)
mesg = "Adding vlan %s(%s)" % (vnumber, desc)
self.log.info(mesg)
except Exception, e:
@@ -290,8 +287,6 @@ class ResourceQuerySql(InfoStore):
def showResources(self, cmdargs):
-
- queryopt = ""
defaultFields = "mac_addr, location, num_procs, num_cores, clock_speed, mem_total "
#defaultFields = "*"
@@ -310,20 +305,21 @@ class ResourceQuerySql(InfoStore):
# header
print line
- sum = {}
+ _sum = {}
for row in result.fetchall():
line = ""
- sum['totProc'] = sum.get('totProc', 0)
- sum['totProc'] += int(row[2])
- sum['totCores'] = sum.get('totCores', 0)
- sum['totCores'] += int(row[3])
- sum['totMemory'] = sum.get('totMemory', 0)
- sum['totMemory'] += int(row[5])
+ _sum['totProc'] = _sum.get('totProc', 0)
+ _sum['totProc'] += int(row[2])
+ _sum['totCores'] = _sum.get('totCores', 0)
+ _sum['totCores'] += int(row[3])
+ _sum['totMemory'] = _sum.get('totMemory', 0)
+ _sum['totMemory'] += int(row[5])
for val in row:
line += str(val).center(20)
print line
- print "\n%s systems registered - %d procs | %d cores | %d bytes RAM" % (str(result.rowcount), sum['totProc'], sum['totCores'], sum['totMemory'],)
+ print "\n%s systems registered - %d procs | %d cores | %d bytes RAM" % \
+ (str(result.rowcount), _sum['totProc'], _sum['totCores'], _sum['totMemory'],)
def getAvailableResources(self):
# Maybe should add a status flag?
@@ -508,7 +504,7 @@ class ResourceQuerySql(InfoStore):
result = self.selectDb(query)
print "NODE ALLOCATION\n"
- sum = {}
+ _sum = {}
if self.verbose:
print "%-5s%-10s%-10s%-10s%-13s%-12s%-10s%-34s%-20s%s" % ("Res", "User", "Host", "Domain", "Cores/Mem","Expiration", "Hostname", "Boot Image Name", "Vlan Member", "Notes")
else:
@@ -533,10 +529,10 @@ class ResourceQuerySql(InfoStore):
allocation_id = i[11]
userName = usermgt.getUserName(uid)
combined_notes = str(rnotes) + "|" + str(anotes)
- sum['totCores'] = sum.get('totCores', 0)
- sum['totCores'] += cores
- sum['totMemory'] = sum.get('totMemory', 0)
- sum['totMemory'] += memory
+ _sum['totCores'] = _sum.get('totCores', 0)
+ _sum['totCores'] += cores
+ _sum['totMemory'] = _sum.get('totMemory', 0)
+ _sum['totMemory'] += memory
if self.verbose:
query = "select v.vlan_num, m.vlan_type from vlaninfo v, vlanmembermap m where v.vlan_id = m.vlan_id and allocation_id = '%d' order by vlan_num asc" % allocation_id
vlanRes = self.selectDb(query)
@@ -550,7 +546,7 @@ class ResourceQuerySql(InfoStore):
print "%-5s%-10s%-10s%-10s%-2s/%-10s%-12s%-10s%-34s%-20s%s" % (resId, userName, host, domain, cores, memory,expire, hostname, image_name, vlanMember,combined_notes)
else:
print "%-10s%-10s%-10s%-2s/%-10s%-12s%s" % (userName, host, domain, cores, memory,expire, combined_notes)
- print "\n%s systems allocated - %d cores| %d bytes RAM" % (str(result.rowcount), sum['totCores'], sum['totMemory'])
+ print "\n%s systems allocated - %d cores| %d bytes RAM" % (str(result.rowcount), _sum['totCores'], _sum['totMemory'])
def showReservation(self, userId=None):
#from IPython.Shell import IPShellEmbed
@@ -612,7 +608,7 @@ class ResourceQuerySql(InfoStore):
query = "select image_name from imageinfo"
result = self.selectDb(query)
row = result.fetchall()
- desc = result.description
+ #desc = result.description
imagelist = []
for i in row:
@@ -625,7 +621,7 @@ class ResourceQuerySql(InfoStore):
query = "select image_name, dist, dist_ver from imageinfo"
result = self.selectDb(query)
row = result.fetchall()
- desc = result.description
+ #desc = result.description
for i in row:
print i
@@ -786,7 +782,7 @@ class ResourceQuerySql(InfoStore):
cursor.execute (query)
self.conn.commit()
row = cursor.fetchall()
- desc = cursor.description
+ #desc = cursor.description
except MySQLdb.OperationalError, e:
msg = "%s : %s" % (e[1], query)
self.log.error(msg)
@@ -867,12 +863,12 @@ class ResourceQuerySql(InfoStore):
return cursor
- def updateReservation (self, reservationId, userId=None, reservationDuration=None, vlanIsolate=None, allocationNotes=None):
+ def updateReservation (self, reservationId, userId=None, resDuration=None, vlanIsolate=None, allocationNotes=None):
mesg = "Updating reservation %s" % (str(reservationId))
self.log.info(mesg)
- if reservationDuration:
+ if resDuration:
if len(resDuration) == 8:
expireDate = resDuration
elif len(resDuration) < 4:
@@ -887,7 +883,7 @@ class ResourceQuerySql(InfoStore):
mesg = "Updating reservationDuration :" + resDuration
self.log.info(mesg)
- query = "update reservationinfo set reservation_exiration = \"" + expireDate_ + "\" where reservation_id = \"" + str(reservationId) + "\""
+ query = "update reservationinfo set reservation_expiration = \"" + expireDate + "\" where reservation_id = \"" + str(reservationId) + "\""
self.__updateDb(query)
if allocationNotes:
@@ -1043,7 +1039,7 @@ class ResourceQuerySql(InfoStore):
vId = self.getVlanId(v)
query = "delete from vlanmembermap where allocation_id = '%s' and vlan_id = '%s'" % (allocationId, vId)
- result = self.insertDb(query)
+ __result = self.insertDb(query)
mesg = "Removing vlan %s from node %s" % (v, nodeName)
self.log.info(mesg)
@@ -1126,7 +1122,7 @@ class ResourceQuerySql(InfoStore):
# imagemap db should be sys_id instead of mac_addr
# change later
- cur_image = host['pxe_image_name']
+ #cur_image = host['pxe_image_name']
# Get the id of the new image
query = "select image_id from imageinfo where image_name = " + "\"" + image + "\""
row = self.__queryDb(query)
@@ -1207,7 +1203,7 @@ class ResourceQuerySql(InfoStore):
return cap
# print out data in a consistent format
- def __showIt(data):
+ def __showIt(self, data):
pass
Modified: incubator/tashi/trunk/src/zoni/data/usermanagement.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/data/usermanagement.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/data/usermanagement.py (original)
+++ incubator/tashi/trunk/src/zoni/data/usermanagement.py Sun Jun 17 05:16:00 2012
@@ -18,7 +18,6 @@
# $Id$
#
-import sys
import os
from usermanagementinterface import UserManagementInterface
Modified: incubator/tashi/trunk/src/zoni/data/usermanagementinterface.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/data/usermanagementinterface.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/data/usermanagementinterface.py (original)
+++ incubator/tashi/trunk/src/zoni/data/usermanagementinterface.py Sun Jun 17 05:16:00 2012
@@ -18,9 +18,6 @@
# $Id$
#
-import sys
-import os
-
class UserManagementInterface(object):
""" Interface description for user management
Modified: incubator/tashi/trunk/src/zoni/extra/util.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/extra/util.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/extra/util.py (original)
+++ incubator/tashi/trunk/src/zoni/extra/util.py Sun Jun 17 05:16:00 2012
@@ -27,7 +27,6 @@ import shutil
import re
import threading
import subprocess
-import logging
def loadConfigFile(parser):
#parser = ConfigParser.ConfigParser()
@@ -218,38 +217,43 @@ def createKey(name):
f.close()
return val
-
def __getShellFn():
- if sys.version_info < (2, 6, 1):
+ try:
from IPython.Shell import IPShellEmbed
- return IPShellEmbed()
- else:
+ return (1, IPShellEmbed)
+ except ImportError:
import IPython
- return IPython.embed()
+ return (2, IPython.embed)
def debugConsole(globalDict):
"""A debugging console that optionally uses pysh"""
def realDebugConsole(globalDict):
try :
import atexit
- shellfn = __getShellFn()
+ (calltype, shellfn) = __getShellFn()
def resetConsole():
# XXXpipe: make input window sane
- (stdin, stdout) = os.popen2("reset")
+ (__stdin, stdout) = os.popen2("reset")
stdout.read()
- dbgshell = shellfn()
atexit.register(resetConsole)
- dbgshell(local_ns=globalDict, global_ns=globalDict)
- except Exception:
+ if calltype == 1:
+ dbgshell=shellfn(user_ns=globalDict)
+ dbgshell()
+ elif calltype == 2:
+ dbgshell=shellfn
+ dbgshell(user_ns=globalDict)
+ except Exception, e:
CONSOLE_TEXT=">>> "
- input = " "
- while (input != ""):
+ inputline = " "
+ while (inputline != ""):
sys.stdout.write(CONSOLE_TEXT)
- input = sys.stdin.readline()
+ inputline = sys.stdin.readline()
try:
- exec(input) in globalDict
+ exec(inputline) in globalDict
except Exception, e:
sys.stdout.write(str(e) + "\n")
+
+ os._exit(0)
+
if (os.getenv("DEBUG", "0") == "1"):
threading.Thread(target=lambda: realDebugConsole(globalDict)).start()
-
Modified: incubator/tashi/trunk/src/zoni/hardware/apcswitchedrackpdu.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/apcswitchedrackpdu.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/apcswitchedrackpdu.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/apcswitchedrackpdu.py Sun Jun 17 05:16:00 2012
@@ -18,8 +18,6 @@
# $Id$
#
-import sys
-import os
import warnings
warnings.filterwarnings("ignore")
@@ -46,7 +44,7 @@ class apcSwitchedRackPdu(SystemManagemen
def getPowerStatus(self):
thisoid = eval(str(self.oid_status) + "," + str(self.port))
- errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
+ __errorIndication, __errorStatus, __errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
cmdgen.CommunityData('my-agent', self.user, 0), \
cmdgen.UdpTransportTarget((self.pdu_name, 161)), thisoid)
output = varBinds[0][1]
@@ -81,7 +79,7 @@ class apcSwitchedRackPdu(SystemManagemen
def powerOn(self):
thisoid = eval(str(self.oid_status) + "," + str(self.port))
- errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().setCmd( \
+ __errorIndication, __errorStatus, __errorIndex, __varBinds = cmdgen.CommandGenerator().setCmd( \
cmdgen.CommunityData('my-agent', self.user, 1), \
cmdgen.UdpTransportTarget((self.pdu_name, 161)), \
(thisoid, rfc1902.Integer('1')))
@@ -89,7 +87,7 @@ class apcSwitchedRackPdu(SystemManagemen
def powerOff(self):
thisoid = eval(str(self.oid_status) + "," + str(self.port))
- errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().setCmd( \
+ __errorIndication, __errorStatus, __errorIndex, __varBinds = cmdgen.CommandGenerator().setCmd( \
cmdgen.CommunityData('my-agent', self.user, 1), \
cmdgen.UdpTransportTarget((self.pdu_name, 161)), \
(thisoid, rfc1902.Integer('2')))
Modified: incubator/tashi/trunk/src/zoni/hardware/delldrac.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/delldrac.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/delldrac.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/delldrac.py Sun Jun 17 05:16:00 2012
@@ -19,14 +19,13 @@
#
import sys
-import os
import pexpect
import time
import logging
import tempfile
from systemmanagementinterface import SystemManagementInterface
-from zoni.extra.util import timeF, log
+from zoni.extra.util import timeF
class dellDrac(SystemManagementInterface):
@@ -116,19 +115,19 @@ class dellDrac(SystemManagementInterface
child = self.__login()
child.logfile = fout
- cmd = "racadm serveraction -m " + self.server + " powerup"
+ cmd = "racadm serveraction -m %s powerup" % (self.server)
child.sendline(cmd)
- i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+ __i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
fout.seek(0)
- self.log.info("Hardware power on : %s", self.hostname)
+ self.log.info("Hardware power on : %s" % self.hostname)
for val in fout.readlines():
if "OK" in val:
code = 1
if "ALREADY POWER-ON" in val:
code = 1
- self.log.info("Hardware already powered on : %s", self.hostname)
+ self.log.info("Hardware already powered on : %s" % self.hostname)
if code < 1:
- self.log.info("Hardware power on failed : %s", self.hostname)
+ self.log.info("Hardware power on failed : %s" % self.hostname)
fout.close()
child.terminate()
return code
@@ -139,11 +138,11 @@ class dellDrac(SystemManagementInterface
fout = tempfile.TemporaryFile()
child = self.__login()
child.logfile = fout
- cmd = "racadm serveraction -m " + self.server + " powerdown"
+ cmd = "racadm serveraction -m %s powerdown" % (self.server)
child.sendline(cmd)
- i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+ __i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
fout.seek(0)
- self.log.info("Hardware power off : %s", self.hostname)
+ self.log.info("Hardware power off : %s" % self.hostname)
for val in fout.readlines():
if "OK" in val:
code = 1
@@ -164,7 +163,7 @@ class dellDrac(SystemManagementInterface
child.logfile = fout
cmd = "racadm serveraction -m " + self.server + " graceshutdown"
child.sendline(cmd)
- i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+ __i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
fout.seek(0)
self.log.info("Hardware power off (soft): %s", self.hostname)
@@ -188,7 +187,7 @@ class dellDrac(SystemManagementInterface
child.logfile = fout
cmd = "racadm serveraction -m " + self.server + " powercycle"
child.sendline(cmd)
- i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+ __i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
fout.seek(0)
self.log.info("Hardware power cycle : %s", self.hostname)
for val in fout.readlines():
@@ -208,7 +207,7 @@ class dellDrac(SystemManagementInterface
child.logfile = fout
cmd = "racadm serveraction -m " + self.server + " hardreset"
child.sendline(cmd)
- i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+ __i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
fout.seek(0)
for val in fout.readlines():
if "OK" in val:
@@ -225,5 +224,5 @@ class dellDrac(SystemManagementInterface
child = self.__login()
cmd = "connect -F " + self.server
child.sendline(cmd)
- i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
+ __i=child.expect(['DRAC/MC:', pexpect.EOF, pexpect.TIMEOUT])
child.terminate()
Modified: incubator/tashi/trunk/src/zoni/hardware/dellswitch.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/hardware/dellswitch.py?rev=1351049&r1=1351048&r2=1351049&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/hardware/dellswitch.py (original)
+++ incubator/tashi/trunk/src/zoni/hardware/dellswitch.py Sun Jun 17 05:16:00 2012
@@ -18,24 +18,22 @@
# $Id$
#
-import os
-import sys
+
import pexpect
import datetime
-import time
import thread
-import string
-import getpass
import socket
import tempfile
+import os
import logging
+import sys
+import time
+import string
-#import zoni
-from zoni.data.resourcequerysql import *
from zoni.hardware.hwswitchinterface import HwSwitchInterface
from zoni.data.resourcequerysql import ResourceQuerySql
from zoni.agents.dhcpdns import DhcpDns
-from zoni.extra.util import *
+from zoni.extra.util import normalizeMac
''' Using pexpect to control switches because couldn't get snmp to work
@@ -261,10 +259,10 @@ class HwDellSwitch(HwSwitchInterface):
i=child.expect(['console','#', 'Name:', pexpect.EOF, pexpect.TIMEOUT], timeout=2)
i=child.expect(['console','#', 'Name:', pexpect.EOF, pexpect.TIMEOUT], timeout=2)
- except EOF:
+ except pexpect.EOF:
print "EOF", i
#child.sendline()
- except TIMEOUT:
+ except pexpect.TIMEOUT:
print "TIMEOUT", i
#child.interact(escape_character='\x1d', input_filter=None, output_filter=None)
@@ -463,16 +461,16 @@ class HwDellSwitch(HwSwitchInterface):
child = self.__login()
cmd = "copy running-config startup-config"
child.sendline(cmd)
- i = child.expect(['y/n', pexpect.EOF, pexpect.TIMEOUT])
+ __i = child.expect(['y/n', pexpect.EOF, pexpect.TIMEOUT])
child.sendline("y")
child.terminate()
- def __saveConfig(self):
- cmd = "copy running-config startup-config"
- child.sendline(cmd)
- i = child.expect(['y/n', pexpect.EOF, pexpect.TIMEOUT])
- child.sendline("y")
- child.terminate()
+# def __saveConfig(self):
+# cmd = "copy running-config startup-config"
+# child.sendline(cmd)
+# __i = child.expect(['y/n', pexpect.EOF, pexpect.TIMEOUT])
+# child.sendline("y")
+# child.terminate()
def registerToZoni(self, user, password, host):
@@ -511,7 +509,7 @@ class HwDellSwitch(HwSwitchInterface):
child.sendline(cmd)
val = host + "#"
tval = host + ">"
- i = child.expect([val, tval, '\n\r\n\r', "--More--", pexpect.EOF, pexpect.TIMEOUT])
+ __i = child.expect([val, tval, '\n\r\n\r', "--More--", pexpect.EOF, pexpect.TIMEOUT])
cmd = "show version"
child.sendline(cmd)
i = child.expect([val, tval, '\n\r\n\r', pexpect.EOF, pexpect.TIMEOUT])
@@ -547,19 +545,19 @@ class HwDellSwitch(HwSwitchInterface):
user = "public"
oid = eval("1,3,6,1,4,1,674,10895,3000,1,2,100,1,0")
- errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
+ __errorIndication, __errorStatus, __errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
cmdgen.CommunityData('my-agent', user, 0), \
cmdgen.UdpTransportTarget((host, 161)), oid)
a['hw_model'] = str(varBinds[0][1])
oid = eval("1,3,6,1,4,1,674,10895,3000,1,2,100,3,0")
- errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
+ __errorIndication, __errorStatus, __errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
cmdgen.CommunityData('my-agent', user, 0), \
cmdgen.UdpTransportTarget((host, 161)), oid)
a['hw_make'] = str(varBinds[0][1])
oid = eval("1,3,6,1,4,1,674,10895,3000,1,2,100,4,0")
- errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
+ __errorIndication, __errorStatus, __errorIndex, varBinds = cmdgen.CommandGenerator().getCmd( \
cmdgen.CommunityData('my-agent', user, 0), \
cmdgen.UdpTransportTarget((host, 161)), oid)
a['hw_version_sw'] = str(varBinds[0][1])