#
# Copyright (C) 2002 Cluster File Systems, Inc.
# Author: Robert Read <rread@clusterfs.com>
-# : Ravindranadh Chowdary Sahukara <s-ravindranadh_chowdary@hp.com>
-
# This file is part of Lustre, http://www.lustre.org.
#
# Lustre is free software; you can redistribute it and/or
#
# Maximum number of devices to search for.
# (the /dev/loop* nodes need to be created beforehand)
-
MAX_LOOP_DEVICES = 256
first_cleanup_error = 0
if not first_cleanup_error:
first_cleanup_error = rc
+
def usage():
print """usage: lconf config.xml
config.xml Lustre configuration in xml format.
--get <url> URL to fetch a config file
--node <nodename> Load config for <nodename>
--d | --cleanup Cleans up config. (Shutdown)
+-d | --cleanup Cleans up config. (Shutdown)
-f | --force Forced unmounting and/or obd detach during cleanup
-v | --verbose Print system commands as they are run
-h | --help Print this help
config file is doing what it should be doing. (Implies -v)
--nomod Skip load/unload module step.
--nosetup Skip device setup/cleanup step.
---reformat Reformat all devices (without question)
---dump <file> Dump the kernel debug log before portals is unloaded
---start [client|MDS|OST] Start the client|MDS|OST services (bug is there need to fixit)
---stop [client|MDS|OST] Stop the client|MDS|OST services (bug is there need to fix it)
+--reformat Reformat all devices (without question)
+--dump <file> Dump the kernel debug log before portals is unloaded
--startlevel <num> Specify the level of services to start with (default 0)
--endlevel <num> Specify the level of services to end with (default 100)
Levels are aproximatly like:
70 - mountpoint
"""
TODO = """
---ldap server LDAP server with lustre config database
+--ldap server LDAP server with lustre config database
--makeldiff Translate xml source to LDIFF
This are perhaps not needed:
--lustre="src dir" Base directory of lustre sources. Used to search
self._gdb = 0
self._nomod = 0
self._nosetup = 0
- self._start= ""
- self._stop= 0
self._force = 0
# parameters
self._modules = None
if flag: self._nosetup = flag
return self._nosetup
- def start(self, flag = None):
- if flag: self._start= flag
- return self._start
-
- def stop(self, flag = None):
- if flag: self._stop= flag
- return self._stop
-
def force(self, flag = None):
if flag: self._force = flag
return self._force
if val: self._end_level = int(val)
return self._end_level
+
+
config = Config()
# ============================================================
self.lctl = 'lctl'
else:
raise CommandError('lctl', "unable to find lctl binary.")
-
+
def run(self, cmds):
"""
run lctl
self.run(cmds)
- # delete a route
+ # add a route to a range
def del_route(self, net, gw, lo, hi):
cmds = """
ignore_errors
ip = string.split(addr, ':')[1]
return ip
-
def get_local_address(net_type, wildcard):
"""Return the local address for the network type."""
local = ""
msg = string.join(map(str,args))
print self.module_name + ":", self.name, self.uuid, msg
+
def lookup_server(self, srv_uuid):
""" Lookup a server's network information """
net = get_ost_net(self.dom_node.parentNode, srv_uuid)
ret, out = run(TCP_ACCEPTOR, '-s', self.send_mem, '-r', self.recv_mem, self.port)
if ret:
raise CommandError(TCP_ACCEPTOR, out, ret)
-
ret = self.dom_node.getElementsByTagName('route_tbl')
for a in ret:
for r in a.getElementsByTagName('route'):
lctl.network(self.net_type, self.nid)
lctl.newdev(attach = "ptlrpc RPCDEV")
-
-
def cleanup(self):
self.info(self.net_type, self.nid, self.port)
ret = self.dom_node.getElementsByTagName('route_tbl')
if not srv:
panic("no server for nid", lo)
else:
-
try:
lctl.disconnect(srv.net_type, srv.nid, srv.port, srv.uuid)
except CommandError, e:
print "del_route failed: ", self.name
e.dump()
cleanup_error(e.rc)
+
try:
lctl.cleanup("RPCDEV", "")
except CommandError, e:
def __init__(self,dom_node):
Module.__init__(self, 'LOV', dom_node)
self.mds_uuid = get_first_ref(dom_node, 'mds')
- self.mdc_uuid = get_first_ref(dom_node, 'mdc')
mds= lookup(dom_node.parentNode, self.mds_uuid)
- self.mdc = lookup(dom_node.parentNode, self.mdc_uuid)
- if mds:
- self.mds_name = getName(mds)
-
+ self.mds_name = getName(mds)
devs = dom_node.getElementsByTagName('devices')
if len(devs) > 0:
dev_node = devs[0]
n.prepare()
else:
panic('osc not found:', osc_uuid)
- mdc_uuid = get_first_ref(self.dom_node,'mdc')
- self.info(mdc_uuid, self.stripe_cnt, self.stripe_sz, self.stripe_off, self.pattern, self.devlist,self.mds_name)
- lctl.newdev(attach="lov %s %s" % (self.name, self.uuid), setup ="%s" % (mdc_uuid))
+ mdc_uuid = prepare_mdc(self.dom_node.parentNode, self.mds_uuid)
+ self.info(self.mds_uuid, self.stripe_cnt, self.stripe_sz,
+ self.stripe_off, self.pattern, self.devlist, self.mds_name)
+ lctl.newdev(attach="lov %s %s" % (self.name, self.uuid),
+ setup ="%s" % (mdc_uuid))
def cleanup(self):
for osc_uuid in self.devlist:
else:
panic('osc not found:', osc_uuid)
Module.cleanup(self)
- n = MDC(self.mdc)
- global mdc_cleaned
- mdc_cleaned = None
- n.cleanup()
+ cleanup_mdc(self.dom_node.parentNode, self.mds_uuid)
def load_module(self):
panic('osc not found:', osc_uuid)
Module.load_module(self)
+
def cleanup_module(self):
Module.cleanup_module(self)
for osc_uuid in self.devlist:
def prepare(self):
lov = self.lov
- oscUUIDs=""
- for i in range(len(lov.devlist)):
- oscUUIDs=oscUUIDs+" "+lov.devlist[i]
- self.info(lov.mds_uuid, lov.stripe_cnt, lov.stripe_sz, lov.stripe_off, lov.pattern, oscUUIDs)
-
- lctl.lov_setconfig(lov.uuid, lov.mds_name, lov.stripe_cnt, lov.stripe_sz, lov.stripe_off, lov.pattern, oscUUIDs)
+ self.info(lov.mds_uuid, lov.stripe_cnt, lov.stripe_sz, lov.stripe_off,
+ lov.pattern, lov.devlist, lov.mds_name)
+ lctl.lov_setconfig(lov.uuid, lov.mds_name, lov.stripe_cnt,
+ lov.stripe_sz, lov.stripe_off, lov.pattern,
+ string.join(lov.devlist))
def cleanup(self):
#nothing to do here
self.add_module('lustre/extN', 'extN')
self.add_module('lustre/mds', 'mds')
self.add_module('lustre/mds', 'mds_%s' % (self.fstype))
-
+
def prepare(self):
self.info(self.devname, self.fstype, self.format)
blkdev = block_dev(self.devname, self.size, self.fstype, self.format)
Module.cleanup(self)
clean_loop(self.devname)
-mdc_cleaned = None
# Very unusual case, as there is no MDC element in the XML anymore
# Builds itself from an MDS node
class MDC(Module):
def __init__(self,dom_node):
- Module.__init__(self, 'MDC', dom_node)
- self.mds_uuid = get_first_ref(dom_node,'mds')
+ self.mds = MDS(dom_node)
self.dom_node = dom_node
self.module_name = 'MDC'
self.kmodule_list = []
self._server = None
self._connected = 0
+
host = socket.gethostname()
+ self.name = 'MDC_'+host
+ self.uuid = self.name+'_UUID'
- self.net_uuid = get_first_ref(dom_node, 'network')
- net = get_osc_net(dom_node,self.net_uuid)
- self._server = Network(net)
- self.add_module('lustre/mdc','mdc')
- self.mdcname = get_attr(dom_node, 'name')
- self.mdcuuid = get_attr(dom_node, 'uuid')
+ self.lookup_server(self.mds.uuid)
+ self.add_module('lustre/mdc', 'mdc')
def prepare(self):
- self.info(self.uuid)
+ self.info(self.mds.uuid)
srv = self.get_server()
lctl.connect(srv.net_type, srv.nid, srv.port, srv.uuid, srv.send_mem, srv.recv_mem)
lctl.newdev(attach="mdc %s %s" % (self.name, self.uuid),
- setup ="%s %s" %(self.mds_uuid, srv.uuid))
-
- def cleanup(self):
- global mdc_cleaned
- if not mdc_cleaned:
- srv = self.get_server()
- if local_net(srv):
- Module.cleanup(self)
- mdc_cleaned = 'yes'
- else:
- self.info(self.uuid)
- r = find_route(srv)
- if r:
- try:
- lctl.del_route_host(r[0], srv.uuid, r[1], r[2])
- except CommandError, e:
- print "del_route failed: ", self.name
- e.dump()
- cleanup_error(e.rc)
- Module.cleanup(self)
-
+ setup ="%s %s" %(self.mds.uuid, srv.uuid))
+
class OBD(Module):
def __init__(self, dom_node):
Module.__init__(self, 'OBD', dom_node)
def __init__(self,dom_node):
Module.__init__(self, 'OSC', dom_node)
self.obd_uuid = get_first_ref(dom_node, 'obd')
-
- self.net_uuid = get_first_ref(dom_node,'network')
- net = get_osc_net(dom_node,self.net_uuid)
- self._server = Network(net)
+ self.ost_uuid = get_first_ref(dom_node, 'ost')
+ self.lookup_server(self.ost_uuid)
self.add_module('lustre/osc', 'osc')
def prepare(self):
- self.info(self.obd_uuid,self.uuid)
+ self.info(self.obd_uuid, self.ost_uuid)
srv = self.get_server()
if local_net(srv):
lctl.connect(srv.net_type, srv.nid, srv.port, srv.uuid, srv.send_mem, srv.recv_mem)
e.dump()
cleanup_error(e.rc)
Module.cleanup(self)
-
-
+
class Mountpoint(Module):
def __init__(self,dom_node):
Module.__init__(self, 'MTPT', dom_node)
- self.dom_node = dom_node
self.path = get_text(dom_node, 'path')
- self.mdc_uuid = get_first_ref(dom_node, 'mdc')
+ self.mds_uuid = get_first_ref(dom_node, 'mds')
self.lov_uuid = get_first_ref(dom_node, 'osc')
self.add_module('lustre/mdc', 'mdc')
self.add_module('lustre/llite', 'llite')
l = lookup(self.dom_node.parentNode, self.lov_uuid)
self.osc = VOSC(l)
- m = lookup(self.dom_node.parentNode, self.mdc_uuid)
- self.mdc = MDC(m)
def prepare(self):
- self.mdc.prepare()
self.osc.prepare()
- self.info(self.path, self.mdc_uuid,self.lov_uuid)
+ mdc_uuid = prepare_mdc(self.dom_node.parentNode, self.mds_uuid)
+
+ self.info(self.path, self.mds_uuid,self.lov_uuid)
cmd = "mount -t lustre_lite -o osc=%s,mdc=%s none %s" % \
- (self.lov_uuid, self.mdc_uuid, self.path)
+ (self.lov_uuid, mdc_uuid, self.path)
run("mkdir", self.path)
ret, val = run(cmd)
if ret:
panic("mount failed:", self.path)
def cleanup(self):
- self.info(self.path, self.mdc_uuid,self.lov_uuid)
+ self.info(self.path, self.mds_uuid,self.lov_uuid)
if config.force():
(rc, out) = run("umount -f", self.path)
else:
log("umount failed, cleanup will most likely not work.")
l = lookup(self.dom_node.parentNode, self.lov_uuid)
self.osc.cleanup()
- self.mdc.cleanup()
+ cleanup_mdc(self.dom_node.parentNode, self.mds_uuid)
def load_module(self):
self.osc.load_module()
return None
return lookup(dom_node, uuid)
-def get_osc_net(dom_node, uuid):
- uuid = get_first_ref(dom_node,'network')
- if not uuid:
- return None
- return lookup(dom_node.parentNode,uuid)
-
def nid2server(dom_node, nid):
netlist = dom_node.getElementsByTagName('network')
for net_node in netlist:
ret = 0
return ret
-
-
#
# return list of services in a profile. list is a list of tuples
# [(level, dom_node),]
if getName(nd) == name:
return nd
return None
-
+
############################################################
# MDC UUID hack -
mdc_uuid = mdc.uuid
return mdc_uuid
-
+mdc_cleaned = None
+def cleanup_mdc(dom_node, mds_uuid):
+ global mdc_cleaned
+ mds_node = lookup(dom_node, mds_uuid);
+ if not mds_node:
+ panic("no mds:", mds_uuid)
+ if not mdc_cleaned:
+ mdc = MDC(mds_node)
+ mdc.cleanup()
+ mdc_uuid = None
+ mdc_cleaned = 'yes'
+
############################################################
# routing ("rooting")
debug('Service:', type, getName(dom_node), getUUID(dom_node))
# there must be a more dynamic way of doing this...
n = None
- if config._start or config._stop:
- if config._start == "client" or config._stop == "client":
- if type == 'ldlm':
- n = LDLM(dom_node)
- elif type == 'lov':
- n = LOV(dom_node)
- elif type == 'network':
- n = Network(dom_node)
- elif type == 'osc':
- n = VOSC(dom_node)
- elif type == 'mdc':
- n = MDC(dom_node)
- elif type == 'mountpoint':
- n = Mountpoint(dom_node)
- else:
- return
- #panic ("unknown service type:", type)
-
- elif config._start == "MDS" or config._stop == "MDS":
- if type == 'ldlm':
- n = LDLM(dom_node)
- elif type == 'lovconfig':
- n = LOVConfig(dom_node)
- elif type == 'network':
- n = Network(dom_node)
- elif type == 'mds':
- n = MDS(dom_node)
- else:
- return
- #panic ("unknown service type:", type)
-
- elif config._start == "OST" or config._stop == "OST":
- if type == 'ldlm':
- n = LDLM(dom_node)
- elif type == 'network':
- n = Network(dom_node)
- elif type == 'obd':
- n = OBD(dom_node)
- elif type == 'ost':
- n = OST(dom_node)
- else:
- return
- #panic ("unknown service type:", type)
+ if type == 'ldlm':
+ n = LDLM(dom_node)
+ elif type == 'lov':
+ n = LOV(dom_node)
+ elif type == 'lovconfig':
+ n = LOVConfig(dom_node)
+ elif type == 'network':
+ n = Network(dom_node)
+ elif type == 'obd':
+ n = OBD(dom_node)
+ elif type == 'ost':
+ n = OST(dom_node)
+ elif type == 'mds':
+ n = MDS(dom_node)
+ elif type == 'osc':
+ n = VOSC(dom_node)
+ elif type == 'mdc':
+ n = MDC(dom_node)
+ elif type == 'mountpoint':
+ n = Mountpoint(dom_node)
else:
- if type == 'ldlm':
- n = LDLM(dom_node)
- elif type == 'lov':
- n = LOV(dom_node)
- elif type == 'lovconfig':
- n = LOVConfig(dom_node)
- elif type == 'network':
- n = Network(dom_node)
- elif type == 'obd':
- n = OBD(dom_node)
- elif type == 'ost':
- n = OST(dom_node)
- elif type == 'mds':
- n = MDS(dom_node)
- elif type == 'osc':
- n = VOSC(dom_node)
- elif type == 'mdc':
- n = MDC(dom_node)
- elif type == 'mountpoint':
- n = Mountpoint(dom_node)
- else:
- panic ("unknown service type:", type)
+ panic ("unknown service type:", type)
if module_flag:
if config.nomod():
return
if config.cleanup():
- if n:
- n.cleanup_module()
+ n.cleanup_module()
else:
- if n:
- n.load_module()
+ n.load_module()
else:
if config.nosetup():
return
if config.cleanup():
- if n:
- n.cleanup()
+ n.cleanup()
else:
- if n:
- n.prepare()
+ n.prepare()
#
# Prepare the system to run lustre using a particular profile
long_opts = ["ldap", "reformat", "lustre=", "verbose", "gdb",
"portals=", "makeldiff", "cleanup", "noexec",
"help", "node=", "nomod", "nosetup",
- "dump=", "force", "start=", "stop=", "startlevel=", "endlevel="]
+ "dump=", "force", "startlevel=", "endlevel="]
opts = []
args = []
try:
opts, args = getopt.getopt(argv, short_opts, long_opts)
-
except getopt.error:
print "invalid opt"
usage()
config.portals = a
if o == "--lustre":
config.lustre = a
- if o == "--reformat":
+ if o == "--reformat":
config.reformat(1)
- if o == "--node":
+ if o == "--node":
config.node(a)
- if o == "--gdb":
+ if o == "--gdb":
config.gdb(1)
- if o == "--nomod":
+ if o == "--nomod":
config.nomod(1)
- if o == "--nosetup":
+ if o == "--nosetup":
config.nosetup(1)
- if o == "--dump":
+ if o == "--dump":
config.dump_file(a)
- if o in ("-f", "--force"):
+ if o in ("-f", "--force"):
config.force(1)
if o in ("--startlevel",):
config.startlevel(a)
if o in ("--endlevel",):
config.endlevel(a)
- if o == "--start":
- config.start(a)
- if o == "--stop":
- config.stop(a)
- config.cleanup(1)
return args
for dir in DEFAULT_PATH:
add_to_path(dir)
-
-
# Initialize or shutdown lustre according to a configuration file
# * prepare the system for lustre
# * configure devices with lctl
sanitise_path()
args = parse_cmdline(sys.argv[1:])
- if config.start() or config.stop():
- if not os.access("/etc/lustre/config.xml", os.R_OK ):
- print 'File not found or readable:', "/etc/lustre/config.xml"
- sys.exit(1)
- dom = xml.dom.minidom.parse("/etc/lustre/config.xml")
- elif len(args) > 0:
+ if len(args) > 0:
if not os.access(args[0], os.R_OK):
print 'File not found or readable:', args[0]
sys.exit(1)
print e
except CommandError, e:
e.dump()
- sys.exit(e.rc)
+ sys.exit(e.rc)
if first_cleanup_error:
sys.exit(first_cleanup_error)
def warning(*args):
msg = string.join(map(str,args))
print "Warning: ", msg
-
+
#
# manage names and uuids
# need to initialize this by walking tree to ensure
def osc(self, name, uuid, obd_uuid, net_uuid):
osc = self.newService("osc", name, uuid)
- osc.appendChild(self.ref("network", net_uuid))
+ osc.appendChild(self.ref("ost", net_uuid))
osc.appendChild(self.ref("obd", obd_uuid))
return osc
mds.appendChild(self.ref("failover", failover_uuid))
return mds
- def mdc(self, name, uuid, mds_uuid, net_uuid):
- mdc = self.newService("mdc",name,uuid)
- mdc.appendChild(self.ref("mds",mds_uuid))
- mdc.appendChild(self.ref("network",net_uuid))
- return mdc
-
- def mountpoint(self, name, uuid, mdc_uuid, osc_uuid, path):
+ def mountpoint(self, name, uuid, mds_uuid, osc_uuid, path):
mtpt = self.newService("mountpoint", name, uuid)
- mtpt.appendChild(self.ref("mdc", mdc_uuid))
+ mtpt.appendChild(self.ref("mds", mds_uuid))
mtpt.appendChild(self.ref("osc", osc_uuid))
self.addElement(mtpt, "path", path)
return mtpt
if options.has_key('obdtype'):
obdtype = options['obdtype']
-
if obdtype == 'obdecho':
fstype = ''
else:
obd = gen.obd(obdname, obd_uuid, fstype, obdtype, devname, get_format_flag(options), size)
ost = gen.ost(ostname, ost_uuid, obd_uuid, net_uuid)
- osc = gen.osc(oscname, osc_uuid, obd_uuid, net_uuid)
+ osc = gen.osc(oscname, osc_uuid, obd_uuid, ost_uuid)
if lovname:
lov = findByName(lustre, lovname, "lov")
lov_uuid = name2uuid(lustre, lov_name, tag='osc', fatal=1)
uuid = new_uuid(name)
- mdc_name = new_name('MDC_'+mds_name)
- mdc_uuid = new_uuid(mdc_name)
- lovnode = lookup(lustre,lov_uuid)
-
-
- mdsnode = lookup(lustre,mds_uuid)
- ref = mdsnode.getElementsByTagName('network_ref')
- net_uuid = ref[0].getAttribute('uuidref')
-
- mdc = gen.mdc(mdc_name,mdc_uuid,mds_uuid,net_uuid)
- lustre.appendChild(mdc)
-
-
- lovnode.appendChild(gen.ref("mdc",mdc_uuid))
-
-
- mtpt = gen.mountpoint(name, uuid, mdc_uuid, lov_uuid, path)
-
+ mtpt = gen.mountpoint(name, uuid, mds_uuid, lov_uuid, path)
node = findByName(lustre, node_name, "node")
if not node:
error('node:', node_name, "not found.")