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 rg...@apache.org on 2010/11/30 18:42:12 UTC
svn commit: r1040690 - in /incubator/tashi/branches/zoni-dev/trunk: etc/
src/zoni/client/ src/zoni/data/ src/zoni/install/db/
src/zoni/system/registration/register/ src/zoni/system/registration/www/
Author: rgass
Date: Tue Nov 30 18:42:11 2010
New Revision: 1040690
URL: http://svn.apache.org/viewvc?rev=1040690&view=rev
Log:
Committing all minor changes and small additions.
Modified:
incubator/tashi/branches/zoni-dev/trunk/etc/ZoniDefaults.cfg
incubator/tashi/branches/zoni-dev/trunk/src/zoni/client/zoni-cli.py
incubator/tashi/branches/zoni-dev/trunk/src/zoni/data/resourcequerysql.py
incubator/tashi/branches/zoni-dev/trunk/src/zoni/install/db/zoniDbSetup.py
incubator/tashi/branches/zoni-dev/trunk/src/zoni/system/registration/register/register_node
incubator/tashi/branches/zoni-dev/trunk/src/zoni/system/registration/www/zoni-register.php
Modified: incubator/tashi/branches/zoni-dev/trunk/etc/ZoniDefaults.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/etc/ZoniDefaults.cfg?rev=1040690&r1=1040689&r2=1040690&view=diff
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/etc/ZoniDefaults.cfg (original)
+++ incubator/tashi/branches/zoni-dev/trunk/etc/ZoniDefaults.cfg Tue Nov 30 18:42:11 2010
@@ -71,7 +71,8 @@ ZONI_IPMI_NETWORK = 10.10.16.0/20
VLAN_MAX = 4095
[hardware]
-HARDWARE_CONTROL = ["ipmi", "drac", "pdu"]
+# Hardware control available for the cluster
+HARDWARE_CONTROL = {"ipmi": {"class":"zoni.hardware.ipmi.Ipmi"}, "drac": {"class":"zoni.hardware.delldrac.dellDrac"}, "pdu":{"class": "zoni.hardware.raritanpdu.raritanDominionPx"}}
HARDWARE_PDU = "raritan"
HARDWARE_DRAC = "DELL DRAC"
Modified: incubator/tashi/branches/zoni-dev/trunk/src/zoni/client/zoni-cli.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/client/zoni-cli.py?rev=1040690&r1=1040689&r2=1040690&view=diff
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/client/zoni-cli.py (original)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/client/zoni-cli.py Tue Nov 30 18:42:11 2010
@@ -1,4 +1,5 @@
#! /usr/bin/env python
+
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -19,7 +20,6 @@
#
# $Id$
#
-
import os
import sys
import optparse
@@ -49,10 +49,13 @@ from zoni.hardware.raritanpdu import rar
from zoni.hardware.delldrac import dellDrac
from zoni.agents.dhcpdns import DhcpDns
+from zoni.hardware.systemmanagement import SystemManagement
+
from zoni.extra.util import *
from zoni.version import *
+from tashi.util import instantiateImplementation, signalHandler
#import zoni.data.usermanagement
#from usermanagement import UserManagement
@@ -86,7 +89,7 @@ def main():
# Hardware controller
group = optparse.OptionGroup(parser, "Hardware control", "Options for node power control")
- group.add_option("--hw", dest="hardwareType", help="Make hardware call to ipmi|drac|pdu")
+ #group.add_option("--hw", dest="hardwareType", help="Make hardware call to ipmi|drac|pdu")
group.add_option("--powerStatus", "--powerstatus", dest="POWERSTATUS", help="Get power status on node", action="store_true", default=False)
group.add_option("--reboot", "--reboot", dest="REBOOTNODE", help="Reboot node (Soft)", action="store_true", default=False)
group.add_option("--powerCycle", "--powercycle", dest="POWERCYCLE", help="Power Cycle (Hard)", action="store_true", default=False)
@@ -101,6 +104,7 @@ def main():
group.add_option("-R", "--showReservation", "--showreservation", dest="showReservation", help="Show current node reservations", action="store_true", default=False)
group.add_option("-A", "--showAllocation", "--showallocation", dest="showAllocation", help="Show current node allocation", action="store_true", default=False)
group.add_option("-S", "--showResources", dest="showResources", help="Show available resources to choose from", action="store_true", default=False)
+ group.add_option("--getResources", "--getresources", dest="getResources", help="Get available resources to choose from", action="store_true", default=False)
group.add_option("-p", "--procs", dest="numProcs", help="Set number of processors" )
group.add_option("-c", "--clock", dest="clockSpeed", help="Processor clock" )
group.add_option("--memory", dest="numMemory", help="Amount of memory (Bytes)" )
@@ -187,82 +191,94 @@ def main():
cmdargs = {}
# setup db connection
- query = zoni.data.resourcequerysql.ResourceQuerySql(configs, options.verbosity)
+ #print "starting tread"
+ #threading.Thread(daemon=True, target=self.dbKeepAlive()).start()
+ #print "after tread"
+
+ data = instantiateImplementation("zoni.data.resourcequerysql.ResourceQuerySql", configs, options.verbosity)
+ #query = zoni.data.resourcequerysql.ResourceQuerySql(configs, options.verbosity)
# Get host info
host=None
if options.nodeName:
- host = query.getHostInfo(options.nodeName)
+ host = data.getHostInfo(options.nodeName)
#print host
# Hardware control
- if options.hardwareType:
-
- if (options.hardwareType) and options.hardwareType not in configs['hardware_control']:
- mesg = "Non support hardware type specified\n"
- mesg += "Supported types:\n"
- mesg += str(configs['hardware_control'])
- mesg += "\n\n"
- sys.stdout.write(mesg)
- exit()
+ #if options.hardwareType:
+ #hardware = zoni.hardware.systemmanagement.SystemManagement(configs,data)
+ #hardware.test("r1r2u29", "getPowerStatus", "test", "tes1t")
+ #hardware.getPowerStatus("r1r2u29")
+ #hardware.powerOn()
+ #hardware.powerOff("r1r2u29")
+ #hardware.runCmd("r1r2u29", "getPowerStatus", "test", "tes1t")
+ #exit()
+
+ #if (options.hardwareType) and options.hardwareType not in configs['hardware_control']:
+ #mesg = "Non support hardware type specified\n"
+ #mesg += "Supported types:\n"
+ #mesg += str(configs['hardware_control'])
+ #mesg += "\n\n"
+ #sys.stdout.write(mesg)
+ #exit()
+#
+ #if (options.hardwareType) and options.nodeName:
+ ##host = data.getHostInfo(options.nodeName)
+ #if options.hardwareType == "ipmi":
+ #hw = Ipmi(options.nodeName, host["ipmi_user"], host["ipmi_password"])
+#
+ #if options.hardwareType == "pdu":
+ #hw = raritanDominionPx(configs, host)
+#
+ #if options.hardwareType == "drac":
+ ## Check if node has drac card
+ #if "drac_name" in host:
+ #hw = dellDrac(host)
+ #else:
+ #mesg = "Host (" + options.nodeName + ") does not have a DRAC card!!\n"
+ #sys.stdout.write(mesg)
+ #exit(1)
- if (options.hardwareType) and options.nodeName:
- #host = query.getHostInfo(options.nodeName)
- if options.hardwareType == "ipmi":
- hw = Ipmi(options.nodeName, host["ipmi_user"], host["ipmi_password"])
-
- if options.hardwareType == "pdu":
- hw = raritanDominionPx(configs, host)
-
- if options.hardwareType == "drac":
- # Check if node has drac card
- if "drac_name" in host:
- hw = dellDrac(host)
- else:
- mesg = "Host (" + options.nodeName + ") does not have a DRAC card!!\n"
- sys.stdout.write(mesg)
- exit(1)
+ if (options.REBOOTNODE or options.POWERCYCLE or options.POWEROFF or \
+ options.POWERON or options.POWERSTATUS or options.CONSOLE or \
+ options.POWERRESET) and options.nodeName:
- if options.verbosity:
- hw.setVerbose(True)
+ hw = zoni.hardware.systemmanagement.SystemManagement(configs,data)
+ if options.verbosity:
+ hw.setVerbose(True)
- if options.REBOOTNODE:
- hw.powerReset()
- exit()
- if options.POWERCYCLE:
- hw.powerCycle()
- exit()
- if options.POWEROFF:
- hw.powerOff()
- exit()
- if options.POWERON:
- hw.powerOn()
- exit()
- if options.POWERRESET:
- hw.powerReset()
- exit()
- if options.POWERSTATUS:
- hw.getPowerStatus()
- exit()
- if options.CONSOLE:
- hw.activateConsole()
- exit()
- hw.getPowerStatus()
+ if options.REBOOTNODE:
+ hw.powerReset(options.nodeName)
+ exit()
+ if options.POWERCYCLE:
+ hw.powerCycle(options.nodeName)
+ exit()
+ if options.POWEROFF:
+ hw.powerOff(options.nodeName)
+ exit()
+ if options.POWERON:
+ hw.powerOn(options.nodeName)
+ exit()
+ if options.POWERRESET:
+ hw.powerReset(options.nodeName)
+ exit()
+ if options.POWERSTATUS:
+ hw.getPowerStatus(options.nodeName)
+ exit()
+ if options.CONSOLE:
+ hw.activateConsole(options.nodeName)
+ exit()
+ hw.getPowerStatus(options.nodeName)
- if (options.hardwareType) and not options.nodeName:
- mesg = "\nMISSSING OPTION: Node name required -n or --nodeName\n"
- parser.print_help();
- sys.stderr.write(mesg)
- exit()
if (options.REBOOTNODE or options.POWERCYCLE or options.POWEROFF or \
options.POWERON or options.POWERSTATUS or options.CONSOLE or \
- options.POWERRESET) and not options.hardwareType:
+ options.POWERRESET) and not options.nodeName:
parser.print_help()
- usage = "\nMISSING OPTION: When specifying hardware parameters, you need the --hw option\n"
- print usage
+ mesg = "\nMISSSING OPTION: Node name required -n or --nodeName\n"
+ print mesg
exit()
# Query Interface
@@ -285,6 +301,13 @@ def main():
parser.print_help()
exit()
+ if options.getResources:
+ print "ALL resources"
+ print data.getAvailableResources()
+ key = "3Lf7Qy1oJZue1q/e3ZQbfg=="
+ print "Tashi Resources"
+ print data.getMyResources(key)
+
# Show current allocations
if (options.showAllocation) or (options.show and re.match(".lloca.*", args[0])):
if options.uid:
@@ -292,7 +315,7 @@ def main():
else:
nameorid = options.userName
- query.showAllocation(nameorid)
+ data.showAllocation(nameorid)
exit()
# Show current reservation
@@ -302,20 +325,20 @@ def main():
else:
nameorid = options.userName
- query.showReservation(nameorid)
+ data.showReservation(nameorid)
# Print all Resources
if options.showResources or (options.show and re.match(".esour.*", args[0])):
- query.showResources(cmdargs)
+ data.showResources(cmdargs)
# Show PXE images
#if (options.show and re.match(".esour.*", args[0])):
if options.showPxeImages or (options.show and re.match("pxei.*", args[0])):
- query.showPxeImages()
+ data.showPxeImages()
# Show machine to PXE image mapping
if options.showPxeImageMap or (options.show and re.match("pxem.*", args[0])):
- query.showPxeImagesToSystemMap(cmdargs)
+ data.showPxeImagesToSystemMap(cmdargs)
if (len(sys.argv) == 1):
parser.print_help()
@@ -324,7 +347,7 @@ def main():
# Delete reservation
if (options.delReservation):
- query.removeReservation(options.delReservation)
+ data.removeReservation(options.delReservation)
exit()
# Specify usermanagement, ldap or files
@@ -332,24 +355,26 @@ def main():
if (options.rgasstest):
+ #data.getHardwareCapabilities(options.nodeName)
#pdu = raritanDominionPx(host)
#print pdu
#bootit = pxe.Pxe(configs, options.verbosity)
- #bootit.createPxeUpdateFile(query.getPxeImages())
+ #bootit.createPxeUpdateFile(data.getPxeImages())
#bootit.updatePxe()
#print "host is ", host
#drac = dellDrac("drac-r2r1c3", 1)
- #drac.getPowerStatus()
+ drac = dellDrac(configs, options.nodeName, host)
+ drac.getPowerStatus()
#drac.powerOff()
#drac.powerOn()
#drac.powerCycle()
#drac.powerReset()
#drac.getPowerStatus()
- print "host is ", host
- pdu = raritanDominionPx(configs, host)
- print "pdu", pdu
- pdu.getPowerStatus()
- exit()
+ #print "host is ", host
+ #pdu = raritanDominionPx(configs, options.nodeName, host)
+ #print "pdu", pdu
+ #pdu.getPowerStatus()
+ #exit()
# Create a reservation for a user
if (options.addReservation):
@@ -367,16 +392,16 @@ def main():
if not options.uid:
userId = usermgt.getUserId(options.userName)
- reservationId = query.addReservation(userId, options.reservationDuration, options.myNotes + " " + str(string.join(args[0:len(args)])))
+ reservationId = data.addReservation(userId, options.reservationDuration, options.myNotes + " " + str(string.join(args[0:len(args)])))
# Allocate node to user
if (options.allocateNode):
if options.reservationId and options.domain and options.vlanInfo and options.nodeName and options.imageName:
- host = query.getHostInfo(options.nodeName)
+ host = data.getHostInfo(options.nodeName)
# optparse does not pass multiple args that are quoted anymore?
# Used to work with python 2.5.2. Doesn't work with python 2.6.5.
- query.allocateNode(options.reservationId, options.domain, host['sys_id'], options.vlanInfo, options.imageName, options.myNotes + " " + str(string.join(args[0:len(args)])))
+ data.allocateNode(options.reservationId, options.domain, host['sys_id'], options.vlanInfo, options.imageName, options.myNotes + " " + str(string.join(args[0:len(args)])))
else:
mesg = "USAGE: %s --allocateNode --nodeName nodeName --domain domainname --reservationId ID --vlanInfo vlanNums:info, --imageName imagename [--notes]\n" % (sys.argv[0])
mesg += "Options\n"
@@ -405,7 +430,7 @@ def main():
exit()
print host['sys_id']
- query.allocateNode(options.reservationId, host['sys_id'], options.hostName, vlanNum, options.ipAddr, options.Notes)
+ data.allocateNode(options.reservationId, host['sys_id'], options.hostName, vlanNum, options.ipAddr, options.Notes)
exit()
# Update allocation
@@ -430,7 +455,7 @@ def main():
userId = usermgt.getUserId(options.userName)
print options.reservationId, userId, options.reservationDuration, options.vlanIsolate, options.Notes
- query.updateReservation(options.reservationId, userId, options.reservationDuration, options.vlanIsolate, options.Notes)
+ data.updateReservation(options.reservationId, userId, options.reservationDuration, options.vlanIsolate, options.Notes)
# Release node allocation
if (options.releaseNode):
@@ -441,7 +466,7 @@ def main():
sys.stderr.write(mesg)
exit()
- query.releaseNode(options.nodeName)
+ data.releaseNode(options.nodeName)
# Assign image to host
#if (options.assignImage):
@@ -449,54 +474,54 @@ def main():
#usage = "Node not specified. Please specify a node with --nodeName or -n"
#print usage
#exit()
- #if query.assignImagetoHost(host, options.assignImage):
+ #if data.assignImagetoHost(host, options.assignImage):
#print "ERROR"
#exit()
#
# Update PXE
#bootit = pxe.Pxe(configs, options.verbosity)
- #bootit.createPxeUpdateFile(query.getPxeImages())
+ #bootit.createPxeUpdateFile(data.getPxeImages())
#bootit.updatePxe()
# Add image to database
if (options.addImage):
- query.addImage(options.addImage)
+ data.addImage(options.addImage)
# Delete PXE image
if (options.delImage):
- query.delImage(options.delImage)
+ data.delImage(options.delImage)
# Domain interface
if (options.showDomains):
- query.showDomains()
+ idata.showDomains()
if (options.addDomain):
if len(args) > 2 and options.reservationId:
- query.addDomain(args[0], string.join(args[1:len(args)]), options.reservationId)
+ data.addDomain(args[0], string.join(args[1:len(args)]), options.reservationId)
else:
mesg = "USAGE: %s --addDomain domainname domaindesc --reservationId ID\n" % (sys.argv[0])
sys.stdout.write(mesg)
exit()
if (options.removeDomain):
if len(args) > 0:
- query.removeDomain(args[0])
+ data.removeDomain(args[0])
else:
mesg = "USAGE: %s --removeDomain domainname \n" % (sys.argv[0])
sys.stdout.write(mesg)
exit()
if (options.showVlans):
- query.showVlans()
+ data.showVlans()
if (options.addVlan):
print len(args)
if len(args) > 0:
- query.addVlan(args[0], string.join(args[1:len(args)]))
+ data.addVlan(args[0], string.join(args[1:len(args)]))
else:
mesg = "USAGE: %s --addVlan vlanNumber [VlanDesc]\n" % (sys.argv[0])
sys.stdout.write(mesg)
exit()
if (options.removeVlan):
if len(args) > 1:
- query.removeVlan(args[0])
+ data.removeVlan(args[0])
else:
mesg = "USAGE: %s --removeVlan VlanNumber\n" % (sys.argv[0])
sys.stdout.write(mesg)
@@ -505,7 +530,7 @@ def main():
if (options.assignVlan):
print len(args)
if len(args) > 0:
- query.assignVlan(options.assignVlan, args[0], options.forcefully)
+ data.assignVlan(options.assignVlan, args[0], options.forcefully)
else:
mesg = "USAGE: %s --assignVlan vlannum DomainName\n" % (sys.argv[0])
sys.stdout.write(mesg)
@@ -523,14 +548,14 @@ def main():
# We can specify port/switch combinations here
if options.switchPort:
- host = query.getSwitchInfo(options.switchPort.split(":")[0])
+ host = data.getSwitchInfo(options.switchPort.split(":")[0])
if len(options.switchPort.split(":")) > 1:
host['hw_port'] = options.switchPort.split(":")[1]
host['location'] = options.switchPort
if options.interactiveSwitchConfig:
- host = query.getSwitchInfo(options.interactiveSwitchConfig)
+ host = data.getSwitchInfo(options.interactiveSwitchConfig)
HwSwitch = HwDellSwitch
hwswitch = HwSwitch(configs, host)
@@ -543,9 +568,9 @@ def main():
if options.disableHostPort and (options.nodeName or options.switchPort):
hwswitch.disableHostPort()
if options.createVlanId:
- hwswitch.createVlans(options.createVlanId, query.getAllSwitches(), query)
+ hwswitch.createVlans(options.createVlanId, data.getAllSwitches(), data)
if options.removeVlanId:
- hwswitch.removeVlans(options.removeVlanId, query.getAllSwitches(), query)
+ hwswitch.removeVlans(options.removeVlanId, data.getAllSwitches(), data)
if options.add2Vlan and (options.nodeName or options.switchPort):
hwswitch.addNodeToVlan(options.add2Vlan)
@@ -594,7 +619,7 @@ def main():
data = hw.registerToZoni(args[1], password, args[2])
# Register to DB
- #query.registerHardware(data)
+ #data.registerHardware(data)
# Zoni Helper
if options.addDns or options.removeDns or options.addDhcp or options.removeDhcp or options.addCname or options.removeCname:
Modified: incubator/tashi/branches/zoni-dev/trunk/src/zoni/data/resourcequerysql.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/data/resourcequerysql.py?rev=1040690&r1=1040689&r2=1040690&view=diff
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/data/resourcequerysql.py (original)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/data/resourcequerysql.py Tue Nov 30 18:42:11 2010
@@ -25,10 +25,12 @@ 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
+from zoni.extra.util import checkSuper, createKey
from zoni.agents.dhcpdns import DhcpDns
class ResourceQuerySql(InfoStore):
@@ -39,32 +41,36 @@ class ResourceQuerySql(InfoStore):
self.user = config['dbUser']
self.passwd = config['dbPassword']
self.db = config['dbInst']
- #self.log = logging.getLogger(os.path.basename(__name__))
+ self.port = config['dbPort']
+ self._isDb = 1
+ self.vlan_max = config['vlanMax']
+ if self.port == "":
+ self.port = 3306
self.log = logging.getLogger(__name__)
- self.tftpRootDir = config['tftpRootDir']
- self.tftpImageDir = config['tftpImageDir']
- self.tftpBootOptionsDir = config['tftpBootOptionsDir']
-
-
- if config['dbPort'] == "":
- config['dbPort'] = 3306
-
- self.port = config['dbPort']
+ self.conn = self.createConn()
- self.vlan_max = config['vlan_max']
- #self.vlan_reserved = config['vlan_reserved']
+ def createConn(self):
# Connect to DB
try:
- self.conn = MySQLdb.connect(host = self.host, port = self.port, user = self.user, passwd = self.passwd, db = self.db)
+ return MySQLdb.connect(host = self.host, port = self.port, user = self.user, passwd = self.passwd, db = self.db)
+ #return MySQLdb.connect(host = self.config['dbHost'], port = self.config['dbPort'], user = self.config['dbUser'], passwd = self.config['dbPassword'], db = self.config['dbInst'])
+
except MySQLdb.OperationalError, e:
if e[0] == 2005:
print "ERROR :" + str(e[1])
- exit(1)
+ return
else:
print "ERROR : ", e
- exit(1)
+ return
+
+ def keepAlive(self):
+ while True:
+ if not self.conn.open:
+ self.log.info("Reinitializing DB connection")
+ self.conn = self.createConn()
+ time.sleep(10)
def getNote(self):
return "Created by Zoni"
@@ -81,11 +87,12 @@ class ResourceQuerySql(InfoStore):
if desc == None:
desc = self.getNote()
- print name
if self.__checkDup("domaininfo", "domain_name", name):
self.log.error("Domain (%s) already exists" % (name))
return -1
- query = "insert into domaininfo (domain_name, domain_desc, reservation_id) values ('%s','%s', '%s')" % (name, desc, reservationId)
+ # Create a key for the reservation
+ domainKey = createKey(name)
+ query = "insert into domaininfo (domain_name, domain_desc, domain_key, reservation_id) values ('%s','%s', '%s', '%s')" % (name, desc, domainKey, reservationId)
try:
result = self.__insertDb(query)
mesg = "Adding domain %s(%s)" % (name, desc)
@@ -103,13 +110,16 @@ class ResourceQuerySql(InfoStore):
# Need to remove any vlans attached to this domain
def showDomains(self):
- query = "select domain_name, domain_desc from domaininfo"
+ 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
if result.rowcount > 0:
- print "%s\t%s\n-------------------------------------" % (result.description[0][0], result.description[1][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 "------------------------------------------------------------"
for row in result.fetchall():
- print "%s\t\t%s" % (row[0], row[1])
+ resName = usermgt.getUserName(row[1])
+ print "%s\t\t%s\t%s\t\t%s" % (row[0], resName, row[2], row[3])
return 0
else:
mesg = "No Domains exist"
@@ -184,6 +194,11 @@ class ResourceQuerySql(InfoStore):
def __getSomething(self, fieldname, table, critField, crit):
query = "select %s from %s where %s = '%s'" % (fieldname, table, critField, crit)
result = self.__selectDb(query)
+ if result.rowcount == 0:
+ mesg = "No entry for '%s' found" % (crit)
+ self.log.error(mesg)
+ #return []
+ return -1
return result.fetchall()[0][0]
@@ -266,13 +281,71 @@ class ResourceQuerySql(InfoStore):
print line
print str(result.rowcount) + " systems returned"
- #mysql -h rodimus -u reader irp-cluster -e "select * from sysinfo where location like 'r1%' and num_procs = 1"
+ def getAvailableResources(self):
+ # Maybe should add a status flag?
+ query = "select sys_id from allocationinfo"
+ result = self.__selectDb(query)
+ allocatedNodes = []
+ if result.rowcount:
+ for i in result.fetchall()[0]:
+ allocatedNodes.append(i)
+
+ query = "select sys_id, location, num_procs, num_cores, mem_total, clock_speed, proc_model from sysinfo where state_id = 0 or state_id = 1"
+ result = self.__selectDb(query)
+ desc = result.description
+ res = {}
+ for i in result.fetchall():
+ sys_id = int(i[0])
+ if sys_id not in allocatedNodes:
+ location = i[1]
+ res[location] = res.get(location, {})
+ res[location][desc[0][0]] = sys_id
+ res[location][desc[1][0]] = location
+ res[location][desc[2][0]] = int(i[2])
+ res[location][desc[3][0]] = int(i[3])
+ res[location][desc[4][0]] = int(i[4])
+ res[location][desc[5][0]] = int(i[5])
+ res[location][desc[6][0]] = i[6]
+
+ return res
+
+ def getMyResources(self, key):
+ query = "select s.sys_id, s.location, s.num_procs, s.num_cores, s.mem_total, s.clock_speed, s.proc_model from sysinfo s, allocationinfo a, domaininfo d where a.sys_id = s.sys_id and a.domain_id = d.domain_id and d.domain_key = '%s'" % key
+ result = self.__selectDb(query)
+ desc = result.description
+ res = {}
+ for i in result.fetchall():
+ sys_id = int(i[0])
+ location = i[1]
+ res[location] = res.get(location, {})
+ res[location][desc[0][0]] = sys_id
+ res[location][desc[1][0]] = location
+ res[location][desc[2][0]] = int(i[2])
+ res[location][desc[3][0]] = int(i[3])
+ res[location][desc[4][0]] = int(i[4])
+ res[location][desc[5][0]] = int(i[5])
+ res[location][desc[6][0]] = i[6]
+
+ return res
+
+ def getDomainFromKey(self, key):
+ return self.__getSomething("domain_name", "domaininfo", "domain_key", key)
+
+ def getDomainIdFromKey(self, key):
+ return self.__getSomething("domain_id", "domaininfo", "domain_key", key)
+
+ def getKeyFromDomain(self, domain):
+ return self.__getSomething("domain_key", "domaininfo", "domain_name", domain)
+
def getLocationFromSysId (self, nodeId):
query = "select location from sysinfo where sys_id = \"" + str(nodeId) + "\""
result = self.__selectDb(query)
return result.fetchall()[0][0]
+ def getSysIdFromLocation(self, location):
+ return self.__getSomething("sys_id", "sysinfo", "location", location)
+
def getMacFromSysId(self, nodeId):
query = "select mac_addr from sysinfo where sys_id = \"" + str(nodeId) + "\""
result = self.__selectDb(query)
@@ -291,14 +364,6 @@ class ResourceQuerySql(InfoStore):
for switch in result.fetchall():
switchList.append(switch[0])
- # Use static list until we get all switches installed
- #switchList = ['sw1-r1r2', 'sw0-r1r1', 'sw0-r1r2', 'sw0-r1r3', 'sw0-r1r4', 'sw0-r2r3', 'sw0-r3r3', 'sw0-r3r2', 'sw0-r2r1c3', 'sw2-r1r2']
- #switchList = ['sw2-r1r2']
- #switchList = ['sw1-r1r2']
-
-
- print switchList
-
return switchList
def getAvailableVlan(self):
@@ -374,12 +439,6 @@ class ResourceQuerySql(InfoStore):
return ip_addr
- #def showArchive(self):
- #query = "select * from allocationarchive"
- #result = self.__selectDb(query)
- #for i in result:
- #print i
-
def showAllocation(self, userId=None):
#from IPython.Shell import IPShellEmbed
#shell = IPShellEmbed(argv="")
@@ -406,14 +465,11 @@ class ResourceQuerySql(InfoStore):
query += "order by r.reservation_id asc, s.location"
- print query
result = self.__selectDb(query)
- print "NODE ALLOCATION"
- print "---------------------------------------------------------------------------------"
+ print "NODE ALLOCATION\n"
if self.verbose:
- #print "Res_id\tUser \tNode \tCores\tMemory \tExpiration\t\tVLAN\tHOSTNAME \tIPADDR \t\tReservationNotes|AllocationNotes"
- print "%-5s%-10s%-11s%-12s%-12s%-5s%-15s%-18s%-24s%s" % ("Res", "User", "Host", "Cores/Mem","Expiration", "Vlan", "Hostname", "IP Addr", "Boot Image Name", "Notes")
+ print "%-5s%-10s%-10s%-13s%-12s%-15s%-18s%-24s%-20s%s" % ("Res", "User", "Host", "Cores/Mem","Expiration", "Hostname", "IP Addr", "Boot Image Name", "Vlan Member", "Notes")
else:
print "%-10s%-10s%-13s%-12s%s" % ("User", "Node", "Cores/Mem","Expiration", "Notes")
@@ -429,18 +485,25 @@ class ResourceQuerySql(InfoStore):
rnotes = i[6]
resId= i[7]
hostname = i[8]
+ if hostname == None:
+ hostname = host
anotes = i[9]
image_name = i[10]
userName = usermgt.getUserName(uid)
combined_notes = str(rnotes) + "|" + str(anotes)
if self.verbose:
- vlanId = 1000
+ query = "select vlan_num from vlaninfo v, domainmembermap m, domaininfo d where v.vlan_id = m.vlan_id and d.domain_id = m.domain_id and d.domain_name = '%s'" % (domain);
+ vlanRes = self.__selectDb(query)
+ vlanList = []
+ for i in vlanRes.fetchall():
+ vlanList.append(str(i[0]))
+
+ vlanMember = string.join(vlanList, ",")
ip_addr = "10.0.0.10"
- print "%-5s%-10s%-10s%-2s/%-10s%-12s%-5s%-15s%-18s%-24s%s" % (resId, userName, host, cores, memory,expire, vlanId, hostname, ip_addr, image_name, combined_notes)
+ print "%-5s%-10s%-10s%-2s/%-10s%-12s%-15s%-18s%-24s%-20s%s" % (resId, userName, host, cores, memory,expire, hostname, ip_addr, image_name, vlanMember,combined_notes)
else:
print "%-10s%-10s%-2s/%-10s%-12s%s" % (userName, host, cores, memory,expire, combined_notes)
- print "---------------------------------------------------------------------------------"
- print str(result.rowcount) + " systems returned"
+ print "\n%s systems returned" % (str(result.rowcount))
def showReservation(self, userId=None):
#from IPython.Shell import IPShellEmbed
@@ -499,11 +562,10 @@ class ResourceQuerySql(InfoStore):
def getPxeImages(self):
- cursor = self.conn.cursor ()
- line = "select image_name from imageinfo"
- cursor.execute (line)
- row = cursor.fetchall()
- desc = cursor.description
+ query = "select image_name from imageinfo"
+ result = self.__selectDb(query)
+ row = result.fetchall()
+ desc = result.description
imagelist = []
for i in row:
@@ -513,22 +575,20 @@ class ResourceQuerySql(InfoStore):
def showPxeImages(self):
- cursor = self.conn.cursor ()
- line = "select image_name, dist, dist_ver from imageinfo"
- cursor.execute (line)
- row = cursor.fetchall()
- desc = cursor.description
+ query = "select image_name, dist, dist_ver from imageinfo"
+ result = self.__selectDb(query)
+ row = result.fetchall()
+ desc = result.description
for i in row:
print i
- cursor.close ()
def showPxeImagesToSystemMap(self, cmdargs):
- extra = "l.mac_addr = j.mac_addr and j.image_id = i.image_id"
+ extra = "j.image_id = i.image_id"
queryopt = self.__create_queryopts(cmdargs, extra=extra)
- query = "select l.location, j.mac_addr, i.image_name from sysinfo l , imageinfo i, imagemap j " + queryopt + " order by l.location"
+ query = "select s.location, s.mac_addr, i.image_name from sysinfo s , imageinfo i, imagemap j " + queryopt + " order by s.location"
#print query
result = self.__selectDb(query)
@@ -551,11 +611,11 @@ class ResourceQuerySql(InfoStore):
result = self.__selectDb(query)
if result.rowcount > 1:
print "Multiple entries for system exist. Please correct"
- exit()
+ return
if result.rowcount < 1:
mesg = "node does not exist :" + str(node) + "\n"
sys.stderr.write(mesg)
- exit()
+ return
for i in result.fetchall():
host['mac_addr'] = host.get("mac_addr", "")
@@ -585,7 +645,7 @@ class ResourceQuerySql(InfoStore):
result = self.__selectDb(query)
if result.rowcount> 1:
print "Multiple entries for system exist. Please correct"
- exit()
+ return
for i in result.fetchall():
host['ipmi_user'] = i[0]
host['ipmi_password'] = i[1]
@@ -646,9 +706,7 @@ class ResourceQuerySql(InfoStore):
# Get switch info
#switchList = self.getAllSwitches()
query = "select h.hw_id, h.hw_name, h.hw_model, h.hw_ipaddr, h.hw_userid, h.hw_password from hardwareinfo h where h.hw_name = \"" + str(switchName) + "\""
- #print "query is ", query
result = self.__selectDb(query)
- #desc = cursor.description
for i in result.fetchall():
host['hw_id'] = int(i[0])
host['hw_name'] = i[1]
@@ -659,6 +717,7 @@ class ResourceQuerySql(InfoStore):
return host
def __queryDb(self, query):
+ self.conn.ping(True)
cursor = self.conn.cursor()
try:
cursor.execute (query)
@@ -673,6 +732,7 @@ class ResourceQuerySql(InfoStore):
return row
def execQuery(self, query):
+ self.conn.ping(True)
cursor = self.conn.cursor()
try:
cursor.execute (query)
@@ -683,10 +743,11 @@ class ResourceQuerySql(InfoStore):
msg = "%s : %s" % (e[1], query)
self.log.error(msg)
#traceback.print_exc(sys.exc_info())
- exit()
+ return
return cursor
def __selectDb(self, query):
+ self.conn.ping(True)
cursor = self.conn.cursor()
try:
cursor.execute (query)
@@ -700,6 +761,7 @@ class ResourceQuerySql(InfoStore):
return cursor
def __deleteDb(self, query):
+ self.conn.ping(True)
cursor = self.conn.cursor()
try:
cursor.execute (query)
@@ -713,6 +775,7 @@ class ResourceQuerySql(InfoStore):
return cursor
def __updateDb(self, query):
+ self.conn.ping(True)
cursor = self.conn.cursor()
try:
cursor.execute (query)
@@ -726,6 +789,7 @@ class ResourceQuerySql(InfoStore):
return cursor
def __insertDb(self, query):
+ self.conn.ping(True)
cursor = self.conn.cursor()
try:
cursor.execute (query)
@@ -756,7 +820,7 @@ class ResourceQuerySql(InfoStore):
else:
mesg = "ERROR: Invalid reservation duration"
self.log.error(mesg)
- exit()
+ return
mesg = "Updating reservationDuration :" + resDuration
self.log.info(mesg)
@@ -799,19 +863,18 @@ class ResourceQuerySql(InfoStore):
else:
mesg = "ERROR: Invalid reservation duration\n"
self.log.info(mesg)
- exit()
+ return
- # create reservation
# Create the reservation
print userId, expireDate,reservationNotes
- query = "insert into reservationinfo (user_id, reservation_expiration, notes) values (\"" + str(userId) + "\", " + str(expireDate) + ", \"" + str(reservationNotes) + "\")"
- mesg = "Creating new reservation : " + query
+ query = "insert into reservationinfo (user_id, reservation_expiration, notes) values ('%s', '%s', '%s')" % (str(userId), str(expireDate), str(reservationNotes))
+ mesg = "Creating new reservation : %s" % query
self.log.info(mesg)
self.__insertDb(query)
# Get the res_id
query = "select max(reservation_id) from reservationinfo"
res_id = self.__selectDb(query).fetchone()[0]
- mesg = " Reservation created - ID :" + str(res_id)
+ mesg = " Reservation created - ID : %s" % str(res_id)
self.log.info(mesg)
return res_id
@@ -854,6 +917,12 @@ class ResourceQuerySql(InfoStore):
mesg = "Domain does not exist: %s(%s)" % (domainId, domain)
self.log.error(mesg)
return -1
+
+ imageId = self.__getSomething("image_id", "imageinfo", "image_name", imageName)
+ if len(self.__checkDup("imageinfo", "image_id", imageId)) == 0:
+ mesg = "Image does not exist: %s(%s)" % (imageName, imageId)
+ self.log.error(mesg)
+ return -1
# Check that all the vlans exist
for i in vlanInfo.split(","):
@@ -881,9 +950,15 @@ class ResourceQuerySql(InfoStore):
self.log.info(mesg)
# Insert into imagemap
- image_id = self.__getSomething("image_id", "imageinfo", "image_name", imageName)
- query = "insert into imagemap (allocation_id, image_id) values ('%s', '%s')" % (allocationId, image_id)
+ query = "insert into imagemap (allocation_id, image_id) values ('%s', '%s')" % (allocationId, imageId)
result = self.__insertDb(query)
+
+ self.__updateSysState(sysId, 1)
+
+
+ def __updateSysState(self, sysId, stateId):
+ query = "update sysinfo set state_id = '%s' where sys_id = '%s'" % (stateId, sysId)
+ return self.__updateDb(query)
def rgasstest(self, vlan_num):
query = "select * from vlaninfo where vlan_num = " + vlan_num
@@ -897,64 +972,28 @@ class ResourceQuerySql(InfoStore):
self.__updateDb(query)
query = "delete from allocationinfo where reservation_id = " + str(res)
self.__updateDb(query)
+
- @checkSuper
- def releaseNode(self, nodeName):
+ def releaseNode(self, location):
# Get the nodeId
- query = "select sys_id, r.reservation_id, a.ip_addr, hostname, vlan_id, a.notes, r.notes,r.user_id from allocationinfo a, sysinfo s, reservationinfo r where a.sys_id = s.sys_id and a.reservation_id = r.reservation_id and location = \"" + nodeName + "\""
- print query
+ sysId = self.__getSomething("sys_id", "sysinfo", "location", location)
+ query = "select * from allocationinfo where sys_id = '%s'" % (sysId)
result = self.__selectDb(query)
if result.rowcount == 0:
- mesg = "ERROR: Node not allocated\n"
- sys.stderr.write(mesg)
- exit(1)
+ mesg = "Node %s not allocated" % (location)
+ self.log.error(mesg)
+ return
if result.rowcount > 1:
- mesg = "WARNING: Node allocated multiple times (" + str(result.rowcount) + ")"
+ mesg = "Node %s allocated multiple times(%s)" % (location, str(result.rowcount))
self.log.warning(mesg)
+ return
- val = result.fetchone()
- nodeId = int(val[0])
- resId = int(val[1])
- ip_addr = val[2]
- hostName = val[3]
- vlan_id = int(val[4])
- allocation_notes = val[5]
- reservation_notes = val[6]
- user_id = val[7]
-
- print "hostname is ", hostName
- # Assign IP address to node
- dhcpdns = DhcpDns(self.config, verbose=1)
- dnscheck = dhcpdns.removeDns(hostName)
- dhcpdns.removeDhcp(hostName)
-
- '''
- query = "select reservation_id, notes from reservationinfo where sys_id = " + str(nodeId)
- result = self.__selectDb(query)
- for i in result:
- print i
- print result.rowcount
- if result.rowcount == 0:
- mesg = "No Reservation for this node.\n Please check"
- logit(self.logFile, mesg)
- exit(1)
- if result.rowcount > 1:
- mesg = "WARNING: Multiple reservations exist (" + str(result.rowcount) + ")"
- logit(self.logFile, mesg)
-
- resId = int(result.fetchone()[0])
- res_notes = int(result.fetchone()[1])
-
- print resId, res_notes
- '''
-
# Eventually should add count =1 so deletes do get out of control
- query = "delete from allocationinfo where reservation_id = " + str(resId) + " and sys_id = " + str(nodeId)
+ query = "delete from allocationinfo where sys_id = '%s'" % (sysId)
result = self.__deleteDb(query)
-
- # Archive node release
- #reservation_type = "release"
- #self.archiveAllocation(nodeId, ip_addr, hostName, vlan_id, user_id, reservation_type, reservation_notes, allocation_notes)
+ # Set state to available
+ self.__updateSysState(sysId, 0)
+ return
def addImage(self, imageName):
name = ""
@@ -973,7 +1012,7 @@ class ResourceQuerySql(InfoStore):
if result.rowcount > 0:
mesg = "ERROR: Image already exists\n"
sys.stderr.write(mesg)
- exit()
+ return
if name == "":
mesg = "ERROR: Image details not specified\n"
@@ -981,7 +1020,7 @@ class ResourceQuerySql(InfoStore):
mesg = "Example amd64-rgass-testing:Ubuntu:8.04\n"
mesg += "or amd64-rgass-testing::\n"
sys.stderr.write(mesg)
- exit()
+ return
query = "insert into imageinfo (image_name, dist, dist_ver) values(\"" + name + "\", \"" + dist + "\", \"" + dist_ver + "\")"
self.__insertDb(query)
@@ -993,7 +1032,7 @@ class ResourceQuerySql(InfoStore):
if result.rowcount == 0:
mesg = "ERROR: No images match your entry\n"
sys.stderr.write(mesg)
- exit()
+ return
def assignImagetoHost(self, host, image):
# imagemap db should be sys_id instead of mac_addr
@@ -1006,7 +1045,7 @@ class ResourceQuerySql(InfoStore):
if len(row) < 1:
mesg = "ERROR: Image \"" + image + "\" does not exist"
self.log.error(mesg)
- exit()
+ return
new_image_id = str(row[0][0])
# check for entry and delete in exists
@@ -1023,6 +1062,7 @@ class ResourceQuerySql(InfoStore):
# Update tftp link
+ # XXX move to pxe.py
mac_addr = "01-" + string.lower(string.replace(host['mac_addr'], ":", "-"))
maclink = self.tftpImageDir + "/" + mac_addr
#print "mac link is ", maclink
@@ -1055,6 +1095,33 @@ class ResourceQuerySql(InfoStore):
return 0
+
+ def getHardwareCapabilities(self, nodeName):
+ ''' getHardwareCapabilities return a list of lists with
+ [0] = hw method
+ [1] = hw method userid
+ [2] = hw method password '''
+
+ sysId = self.getSysIdFromLocation(nodeName)
+ query = "select h.hw_type, h.hw_userid, h.hw_password from hardwareinfo h, portmap p where p.hw_id = h.hw_id and p.sys_id = '%s'" % sysId
+ result = self.__selectDb(query)
+ cap = []
+ val = []
+ for i in result.fetchall():
+ if i[0] in self.config['hardwareControl']:
+ val.append(i)
+
+ # order the hardware capabilities according to order in config file
+ for i in [j for j in self.config['hardwareControl']]:
+ for j in val:
+ if i in j:
+ cap.append(j)
+ return cap
+
+ # print out data in a consistent format
+ def __showIt(data):
+ pass
+
def registerHardware(self, data):
Modified: incubator/tashi/branches/zoni-dev/trunk/src/zoni/install/db/zoniDbSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/install/db/zoniDbSetup.py?rev=1040690&r1=1040689&r2=1040690&view=diff
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/install/db/zoniDbSetup.py (original)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/install/db/zoniDbSetup.py Tue Nov 30 18:42:11 2010
@@ -129,7 +129,7 @@ def createTables(conn):
''' Create Tables '''
# Create sysinfo
sys.stdout.write(" Creating sysinfo...")
- execQuery(conn, "CREATE TABLE IF NOT EXISTS `sysinfo` (`sys_id` int(11) unsigned NOT NULL auto_increment, `mac_addr` char(64) NOT NULL, `num_procs` int(10) unsigned default NULL, `num_cores` int(10) unsigned default NULL, `mem_sticks` int(10) unsigned default NULL, `mem_slots` int(10) unsigned default NULL, `mem_total` int(10) unsigned default NULL, `mem_limit` int(10) unsigned default NULL, `clock_speed` int(10) unsigned default NULL, `sys_vendor` text, `sys_model` text, `proc_vendor` char(64) default NULL, `proc_model` char(128) default NULL, `proc_cache` char(32) default NULL, `system_serial_number` char(128) default NULL, `chassis_serial_number` char(128) default NULL, `system_uuid` char(254) default NULL, `cpu_flags` text, `location` text, `bios_rev` char(32) default NULL, `ip_addr` varchar(64) NOT NULL, `init_checkin` timestamp NOT NULL default CURRENT_TIMESTAMP, `last_update` timestamp, state_id int(11) DEFAULT 1,max_reservation int(10) default -1, PRIMARY KEY (`sys
_id`))")
+ execQuery(conn, "CREATE TABLE IF NOT EXISTS `sysinfo` (`sys_id` int(11) unsigned NOT NULL auto_increment, `mac_addr` char(64) NOT NULL, `num_procs` int(10) unsigned default NULL, `num_cores` int(10) unsigned default NULL, `mem_sticks` int(10) unsigned default NULL, `mem_slots` int(10) unsigned default NULL, `mem_total` int(10) unsigned default NULL, `mem_limit` int(10) unsigned default NULL, `clock_speed` int(10) unsigned default NULL, `sys_vendor` text, `sys_model` text, `proc_vendor` char(64) default NULL, `proc_model` char(128) default NULL, `proc_cache` char(32) default NULL, `system_serial_number` char(128) default NULL, `chassis_serial_number` char(128) default NULL, `system_uuid` char(254) default NULL, `cpu_flags` text, `location` text, `bios_rev` char(32) default NULL, `ip_addr` varchar(64) NOT NULL, `init_checkin` timestamp NOT NULL default 0, `last_update` timestamp not null default 0 on update CURRENT_TIMESTAMP, state_id int(11) DEFAULT 1,max_reservation int(10)
default -1, PRIMARY KEY (`sys_id`))")
sys.stdout.write("Success\n")
# Create hardwareinfo
@@ -154,7 +154,7 @@ def createTables(conn):
sys.stdout.write("Success\n")
# Create domaininfo
sys.stdout.write(" Creating domaininfo...")
- execQuery(conn, "CREATE TABLE IF NOT EXISTS `domaininfo` ( `domain_id` int(11) unsigned NOT NULL auto_increment, `domain_name` varchar(64) NOT NULL, `domain_desc` varchar(256) NOT NULL, `reservation_id` int(11) unsigned NOT NULL, PRIMARY KEY (`domain_id`), INDEX (reservation_id), FOREIGN KEY (reservation_id) REFERENCES reservationinfo(reservation_id) on DELETE CASCADE) ENGINE=INNODB")
+ execQuery(conn, "CREATE TABLE IF NOT EXISTS `domaininfo` ( `domain_id` int(11) unsigned NOT NULL auto_increment, `domain_name` varchar(64) NOT NULL, `domain_key` varchar(1024) NULL, `domain_desc` varchar(256) NOT NULL, `reservation_id` int(11) unsigned NOT NULL, PRIMARY KEY (`domain_id`), INDEX (reservation_id), FOREIGN KEY (reservation_id) REFERENCES reservationinfo(reservation_id) on DELETE CASCADE) ENGINE=INNODB")
sys.stdout.write("Success\n")
# Create domainmap
sys.stdout.write(" Creating domainmembermap...")
@@ -166,7 +166,7 @@ def createTables(conn):
sys.stdout.write("Success\n")
# Create allocationinfo
sys.stdout.write(" Creating allocationinfo...")
- execQuery(conn, "CREATE TABLE IF NOT EXISTS `allocationinfo` ( `allocation_id` int(11) unsigned NOT NULL auto_increment, `sys_id` int(11) unsigned NOT NULL, `reservation_id` int(11) unsigned NOT NULL, `pool_id` int(11) unsigned NULL, `hostname` varchar(64) default NULL, `domain_id` int(11) unsigned NOT NULL, `notes` tinytext, PRIMARY KEY (`allocation_id`), INDEX (domain_id), FOREIGN KEY (domain_id) REFERENCES domaininfo (domain_id) on DELETE CASCADE) ENGINE=INNODB")
+ execQuery(conn, "CREATE TABLE IF NOT EXISTS `allocationinfo` ( `allocation_id` int(11) unsigned NOT NULL auto_increment, `sys_id` int(11) unsigned NOT NULL, `reservation_id` int(11) unsigned NOT NULL, `pool_id` int(11) unsigned NULL, `hostname` varchar(64) default NULL, `domain_id` int(11) unsigned NOT NULL, `notes` tinytext, `expire_time` timestamp default 0 NOT NULL, PRIMARY KEY (`allocation_id`), INDEX (domain_id), FOREIGN KEY (domain_id) REFERENCES domaininfo (domain_id) on DELETE CASCADE) ENGINE=INNODB")
sys.stdout.write("Success\n")
# Create imagemap
sys.stdout.write(" Creating imagemap...")
@@ -280,7 +280,7 @@ def addInitialConfig(conn, config):
# Get the domainId
vlanId = str(checkVal[1][0][0])
else:
- r = execQuery(conn, "INSERT into `reservationinfo` (user_id, reservation_expiration, notes) values (0, '9999-12-31', 'Zoni Default Registration')")
+ r = execQuery(conn, "INSERT into `reservationinfo` (user_id, reservation_expiration, notes) values (0, '9999-12-31', 'Zoni Default')")
vlanId = str(r.lastrowid)
sys.stdout.write("Success\n")
Modified: incubator/tashi/branches/zoni-dev/trunk/src/zoni/system/registration/register/register_node
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/system/registration/register/register_node?rev=1040690&r1=1040689&r2=1040690&view=diff
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/system/registration/register/register_node (original)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/system/registration/register/register_node Tue Nov 30 18:42:11 2010
@@ -242,7 +242,6 @@ if [ $? -eq 0 ];then
vlan_disable=$(ipmitool lan print | grep -i "Vlan" | awk -F ": " '{print $2}')
# Add IPMI info
-VERBOSE=1
wget -O/outfile.txt "http://${IMAGE_URL}/zoni-register.php?action=add_ipmi&verbose=${VERBOSE}&mac=$MAC&location=${location}&ip_addr=${IPADDR}&ipmi_mac=${ipmi_mac}&ipmi_ver=${ipmi_ver}&ipmi_rev=${ipmi_rev}"
IPMI_ADDR=$(cat /outfile.txt | grep IPMI_ADDR | awk '{print $2}')
IPMI_PASSWORD=$(cat /outfile.txt | grep IPMI_PASSWORD | awk '{print $2}')
Modified: incubator/tashi/branches/zoni-dev/trunk/src/zoni/system/registration/www/zoni-register.php
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/system/registration/www/zoni-register.php?rev=1040690&r1=1040689&r2=1040690&view=diff
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/system/registration/www/zoni-register.php (original)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/system/registration/www/zoni-register.php Tue Nov 30 18:42:11 2010
@@ -20,6 +20,7 @@
#
include("include/zoni_www_registration.conf");
include("include/zoni_functions.php");
+ $PYTHONPATH=$G['ZONI_BASE_DIR'] . "/src"
$G = init_globals();
$verbose = (isset($_GET['verbose'])) ? $_GET['verbose']: 0;
@@ -138,7 +139,7 @@
$query .= "(mac_addr, num_procs, num_cores, mem_total, ";
$query .= "clock_speed, sys_vendor, sys_model, proc_vendor, ";
$query .= "proc_model, proc_cache, bios_rev, system_serial_number, ";
- $query .= "chassis_serial_number, system_uuid, last_update, ";
+ $query .= "chassis_serial_number, system_uuid, init_checkin, ";
$query .= "cpu_flags)";
$query .= " values ('$mac_addr', '$num_procs', '$num_cores', ";
$query .= " '$mem_total', '$clock_speed', '$sys_vendor', ";
@@ -165,7 +166,6 @@
$query .= "bios_rev = '$bios_rev', ";
$query .= "chassis_serial_number = '$chassis_serial_number', ";
$query .= "system_uuid = '$system_uuid', ";
- $query .= "last_update= NOW(), ";
$query .= "cpu_flags = '$cpu_flags' ";
$query .= " where system_serial_number = '$system_serial_number'";
DEBUG($verbose, "<br>query is $query <br>\n");
@@ -305,6 +305,7 @@
$query .= "hw_version_fw = '$ipmi_rev' ";
$query .= "where hw_mac = '$ipmi_mac'";
$result = $myconn->run_query($query);
+ DEBUG($verbose, "UPDATING THE HARDWEARE INFO");
DEBUG($verbose, $query, $result);
}
@@ -319,9 +320,8 @@
print "IPMI_GATEWAY $ipmi_gateway\n";
print "IPMI name is $ipmi_name address is $ipmi_addr\n";
-
- print shell_exec("PYTHONPATH=/usr/local/tashi/src zoni --addDns $ipmi_name $ipmi_addr");
- print shell_exec("PYTHONPATH=/usr/local/tashi/src zoni --addDhcp $ipmi_name $ipmi_addr $mac_addr");
+ print shell_exec("PYTHONPATH=$PYTHONPATH zoni --addDns $ipmi_name $ipmi_addr");
+ print shell_exec("PYTHONPATH=$PYTHONPATH zoni --addDhcp $ipmi_name $ipmi_addr $mac_addr");
#print shell_exec("cd /var/www/cluster-admin/scripts-prs/; sudo ./remove_dns ${location}-ipmi");
#print shell_exec("cd /var/www/cluster-admin/scripts-prs/; sudo ./remove_rdns ${location}-ipmi $ipmi_addr");
#print shell_exec("cd /var/www/cluster-admin/scripts-prs/; sudo ./add_dns ${location}-ipmi $ipmi_addr");
@@ -378,8 +378,8 @@
DEBUG($verbose, "doing the dns and dhcp updates");
#print shell_exec("cd {$G['ZONI_BASE_DIR']}; sudo ./bin/zoni-cli.py --addDns $location $ip_addr");
#print shell_exec("cd {$G['ZONI_BASE_DIR']}; sudo ./bin/zoni-cli.py --addDhcp $location $ip_addr $mac_addr");
- print shell_exec("PYTHONPATH=/usr/local/tashi/src zoni --addDns $location $ip_addr");
- print shell_exec("PYTHONPATH=/usr/local/tashi/src zoni --addDhcp $location $ip_addr $mac_addr");
+ print shell_exec("PYTHONPATH=$PYTHONPATH zoni --addDns $location $ip_addr");
+ print shell_exec("PYTHONPATH=$PYTHONPATH zoni --addDhcp $location $ip_addr $mac_addr");
}
# set next boot image after allocation setup