--node node_name
--mds mds_name
--dev path
+ --fstype extN|ext3
--size size
--add lov
-add ost
--node node_name
- --obd obd_name
+ --ost ost_name
--lov lov_name
--dev path
--size size
- --obduuid uuid
+ --fstype extN|ext3
+ --ostuuid uuid
--add mtpt - Mountpoint
--node node_name
--path /mnt/point
--mds mds_name
- --obd obd_name OR --lov lovname
+ --ost ost_name OR --lov lov_name
"""
sys.exit(1)
def network(self, name, uuid, hostname, net, port=0, tcpbuf=0):
"""create <network> node"""
network = self.newService("network", name, uuid)
- network.setAttribute("type", net);
- self.addElement(network, "server", hostname)
+ network.setAttribute("nettype", net);
+ self.addElement(network, "nid", hostname)
if port:
self.addElement(network, "port", "%d" %(port))
if tcpbuf:
- self.addElement(network, "send_mem", "%d" %(tcpbuf))
- self.addElement(network, "recv_mem", "%d" %(tcpbuf))
+ self.addElement(network, "sendmem", "%d" %(tcpbuf))
+ self.addElement(network, "recvmem", "%d" %(tcpbuf))
return network
ref.setAttribute("hi", hi)
return ref
- def node(self, name, uuid):
+ def profile(self, name, uuid):
+ """ create a host """
+ profile = self.newService("profile", name, uuid)
+ return profile
+
+ def node(self, name, uuid, prof_uuid):
""" create a host """
node = self.newService("node", name, uuid)
- self.addElement(node, 'profile')
+ node.appendChild(self.ref("profile", prof_uuid))
return node
def ldlm(self, name, uuid):
ldlm = self.newService("ldlm", name, uuid)
return ldlm
- def obd(self, name, uuid, fs, obdtype, devname, format, ost_uuid, dev_size=0):
- obd = self.newService("obd", name, uuid)
- obd.setAttribute('type', obdtype)
- self.addElement(obd, 'active_target', ost_uuid)
+ def osd(self, name, uuid, fs, osdtype, devname, format, ost_uuid, net_uuid, dev_size=0):
+ osd = self.newService("osd", name, uuid)
+ osd.setAttribute('osdtype', osdtype)
+ osd.appendChild(self.ref("target", ost_uuid))
+ osd.appendChild(self.ref("network", net_uuid))
if fs:
- self.addElement(obd, "fstype", fs)
+ self.addElement(osd, "fstype", fs)
if devname:
- dev = self.addElement(obd, "device", devname)
- if (dev_size):
- dev.setAttribute("size", "%s" % (dev_size))
- self.addElement(obd, "autoformat", format)
- return obd
-
-# def osc(self, name, uuid, obd_uuid, net_uuid):
-# osc = self.newService("osc", name, uuid)
-# osc.appendChild(self.ref("ost", net_uuid))
-# osc.appendChild(self.ref("obd", obd_uuid))
-# return osc
+ dev = self.addElement(osd, "devpath", devname)
+ self.addElement(osd, "autoformat", format)
+ if dev_size:
+ self.addElement(osd, "devsize", "%s" % (dev_size))
+ return osd
def cobd(self, name, uuid, real_uuid, cache_uuid):
cobd = self.newService("cobd", name, uuid)
- cobd.appendChild(self.ref("real_obd",real_uuid))
- cobd.appendChild(self.ref("cache_obd",cache_uuid))
+ cobd.appendChild(self.ref("realobd",real_uuid))
+ cobd.appendChild(self.ref("cacheobd",cache_uuid))
return cobd
- def ost(self, name, uuid, obd_uuid, net_uuid):
+ def ost(self, name, uuid, osd_uuid):
ost = self.newService("ost", name, uuid)
- ost.appendChild(self.ref("network", net_uuid))
- ost.appendChild(self.ref("obd", obd_uuid))
+ ost.appendChild(self.ref("active", osd_uuid))
return ost
+ def oss(self, name, uuid):
+ oss = self.newService("oss", name, uuid)
+ return oss
+
def lov(self, name, uuid, mds_uuid, stripe_sz, stripe_cnt, pattern):
lov = self.newService("lov", name, uuid)
lov.appendChild(self.ref("mds", mds_uuid))
- devs = self.addElement(lov, "devices" )
- devs.setAttribute("stripesize", stripe_sz)
- devs.setAttribute("stripecount", stripe_cnt)
- devs.setAttribute("pattern", pattern)
+ lov.setAttribute("stripesize", str(stripe_sz))
+ lov.setAttribute("stripecount", str(stripe_cnt))
+ lov.setAttribute("stripepattern", str(pattern))
return lov
def lovconfig(self, name, uuid, lov_uuid):
lovconfig.appendChild(self.ref("lov", lov_uuid))
return lovconfig
- def mds(self, name, uuid, fs, devname, format, net_uuid, node_uuid,
- failover_uuid = "", dev_size=0 ):
+ def mds(self, name, uuid, mdd_uuid):
mds = self.newService("mds", name, uuid)
- self.addElement(mds, "fstype", fs)
- dev = self.addElement(mds, "device", devname)
- if dev_size:
- dev.setAttribute("size", "%s" % (dev_size))
- self.addElement(mds, "autoformat", format)
- mds.appendChild(self.ref("network", net_uuid))
- mds.appendChild(self.ref("node", node_uuid))
- if failover_uuid:
- mds.appendChild(self.ref("failover", failover_uuid))
+ mds.appendChild(self.ref("active",mdd_uuid))
return mds
+ def mdsdev(self, name, uuid, fs, devname, format, net_uuid, node_uuid,
+ mds_uuid, dev_size=0 ):
+ mdd = self.newService("mdsdev", name, uuid)
+ self.addElement(mdd, "fstype", fs)
+ dev = self.addElement(mdd, "devpath", devname)
+ self.addElement(mdd, "autoformat", format)
+ if dev_size:
+ self.addElement(mdd, "devsize", "%s" % (dev_size))
+ mdd.appendChild(self.ref("network", net_uuid))
+ mdd.appendChild(self.ref("target", mds_uuid))
+ return mdd
+
def mountpoint(self, name, uuid, mds_uuid, osc_uuid, path):
mtpt = self.newService("mountpoint", name, uuid)
mtpt.appendChild(self.ref("mds", mds_uuid))
return mtpt
def echo_client(self, name, uuid, osc_uuid):
- ec = self.newService("echo_client", name, uuid)
+ ec = self.newService("echoclient", name, uuid)
ec.appendChild(self.ref("obd", osc_uuid))
return ec
n = lookup(n, uuid)
if n: return n
return None
-
-
-def mds2node(lustre, mds_name):
- """ Find the node a MDS is configured on """
- mds = findByName(lustre, mds_name, 'mds')
- ref = mds.getElementsByTagName('node_ref')
- if not ref:
- error("mds2node:", "no node_ref found for", '"'+mds_name+'"')
- node_uuid = ref[0].getAttribute('uuidref')
- node = lookup(lustre, node_uuid)
- if not node:
- error('mds2node:', "no node found for :", '"'+mds_name+'"')
- return node
def name2uuid(lustre, name, tag="", fatal=1):
def lov_add_obd(gen, lov, osc_uuid):
- devs = lov.getElementsByTagName('devices')
- if len(devs) == 1:
- devs[0].appendChild(gen.ref("obd", osc_uuid))
- else:
- error("No devices element found for LOV:", lov)
-
+ lov.appendChild(gen.ref("obd", osc_uuid))
+def ref_exists(profile, uuid):
+ elist = profile.childNodes
+ for e in elist:
+ if e.nodeType == e.ELEMENT_NODE:
+ ref = e.getAttribute('uuidref')
+ if ref == uuid:
+ return 1
+ return 0
+
+# ensure that uuid is not already in the profile
+# return true if uuid is added
def node_add_profile(gen, node, ref, uuid):
- ret = node.getElementsByTagName('profile')
+ refname = "%s_ref" % "profile"
+ ret = node.getElementsByTagName(refname)
if not ret:
- error('node has no profile:', node)
- ret[0].appendChild(gen.ref(ref, uuid))
+ error('node has no profile ref:', node)
+ prof_uuid = ret[0].getAttribute('uuidref')
+ profile = lookup(node.parentNode, prof_uuid)
+ if not profile:
+ error("no profile found:", prof_uuid)
+ if ref_exists(profile, uuid):
+ return 0
+ profile.appendChild(gen.ref(ref, uuid))
+ return 1
def get_attr(dom_node, attr, default=""):
v = dom_node.getAttribute(attr)
#
def do_add_node(gen, lustre, options, node_name):
uuid = new_uuid(node_name)
- node = gen.node(node_name, uuid)
+ prof_name = new_name("PROFILE_" + node_name)
+ prof_uuid = new_uuid(prof_name)
+ profile = gen.profile(prof_name, prof_uuid)
+ node = gen.node(node_name, uuid, prof_uuid)
+ lustre.appendChild(node)
+ lustre.appendChild(profile)
+
node_add_profile(gen, node, 'ldlm', ldlm_uuid)
if has_option(options, 'router'):
node.setAttribute('router', '1')
node.setAttribute('timeout', get_option(options, 'timeout'))
if has_option(options, 'recovery_upcall'):
node.setAttribute('recovery_upcall', get_option(options, 'recovery_upcall'))
- lustre.appendChild(node)
return node
""" create a node with a network config """
node_name = get_option(options, 'node')
-
ret = findByName(lustre, node_name, "node")
if ret:
print "Node:", node_name, "exists."
nid = get_option(options, 'nid')
net_type = get_option(options, 'nettype')
- if net_type == 'tcp':
+ if net_type in ('tcp', 'toe'):
port = get_option_int(options, 'port', DEFAULT_PORT)
tcpbuf = get_option_int(options, 'tcpbuf', 0)
elif net_type in ('elan', 'gm'):
netlist = node.getElementsByTagName('network')
net = netlist[0]
- rlist = net.getElementsByTagName('route_tbl')
+ rlist = net.getElementsByTagName('routetbl')
if len(rlist) > 0:
rtbl = rlist[0]
else:
- rtbl = gen.addElement(net, 'route_tbl')
+ rtbl = gen.addElement(net, 'routetbl')
rtbl.appendChild(gen.route(net_type, gw, lo, hi))
def add_mds(gen, lustre, options):
node_name = get_option(options, 'node')
- mds_orig = get_option(options, 'mds')
- mds_name = new_name(mds_orig)
- if mds_name != mds_orig:
- warning("name:", mds_orig, "already used. using:", mds_name)
+ mds_name = get_option(options, 'mds')
+ mdd_name = new_name("MDD_" + mds_name +"_" + node_name)
+ mdd_uuid = new_uuid(mdd_name)
+
+ mds_uuid = name2uuid(lustre, mds_name, fatal=0)
+ if not mds_uuid:
+ mds_uuid = new_uuid(mds_name)
+ mds = gen.mds(mds_name, mds_uuid, mdd_uuid)
+ lustre.appendChild(mds)
+
devname = get_option(options, 'dev')
size = get_option(options, 'size', 0)
fstype = get_option(options, 'fstype', 'extN')
- mds_uuid = new_uuid(mds_name)
-
node_uuid = name2uuid(lustre, node_name, 'node')
node = findByName(lustre, node_name, "node")
- node_add_profile(gen, node, "mds", mds_uuid)
+ node_add_profile(gen, node, "mdsdev", mdd_uuid)
net_uuid = get_net_uuid(lustre, node_name)
if not net_uuid:
error("NODE: ", node_name, "not found")
- mds = gen.mds(mds_name, mds_uuid, fstype, devname, get_format_flag(options),
- net_uuid, node_uuid, dev_size=size)
- lustre.appendChild(mds)
+ mdd = gen.mdsdev(mdd_name, mdd_uuid, fstype, devname, get_format_flag(options),
+ net_uuid, node_uuid, mds_uuid, dev_size=size)
+ lustre.appendChild(mdd)
def add_ost(gen, lustre, options):
node_name = get_option(options, 'node')
lovname = get_option(options, 'lov', '')
- obdtype = get_option(options, 'obdtype', 'obdfilter')
+ osdtype = get_option(options, 'osdtype', 'obdfilter', deprecated_tag="obdtype")
- if obdtype == 'obdecho':
+ if osdtype == 'obdecho':
fstype = ''
devname = ''
size = 0
size = get_option(options, 'size', 0)
fstype = get_option(options, 'fstype', 'extN')
- obdname = get_option(options, 'obd', 'OBD_'+ node_name)
- obdname = new_name(obdname)
- ostname = new_name('OST_'+ obdname)
- if options.has_key('obduuid'):
- obd_uuid = options['obduuid']
- obd = lookup(lustre, obd_uuid)
- if obd:
- error("Duplicate OBD UUID:", obd_uuid)
+ ostname = get_option(options, 'ost', '', deprecated_tag='obd')
+ if not ostname:
+ ostname = new_name('OST_'+ node_name)
+
+ osdname = new_name("OSD_" + ostname)
+ osd_uuid = get_option(options, 'osduuid', '', deprecated_tag = 'obduuid')
+ if osd_uuid and lookup(lustre, osd_uuid):
+ error("Duplicate OBD UUID:", osd_uuid)
else:
- obd_uuid = new_uuid(obdname)
- ost_uuid = new_uuid(ostname)
+ osd_uuid = new_uuid(osdname)
+
+ ost_uuid = name2uuid(lustre, ostname, fatal=0)
+ if not ost_uuid:
+ ost_uuid = new_uuid(ostname)
+ ost = gen.ost(ostname, ost_uuid, osd_uuid)
+ lustre.appendChild(ost)
+ if lovname:
+ lov = findByName(lustre, lovname, "lov")
+ if not lov:
+ error('add_ost:', '"'+lovname+'"', "lov element not found.")
+ lov_add_obd(gen, lov, ost_uuid)
net_uuid = get_net_uuid(lustre, node_name)
if not net_uuid:
- error("NODE: ", node_name, "not found")
-
- obd = gen.obd(obdname, obd_uuid, fstype, obdtype, devname, get_format_flag(options), ost_uuid,
- size)
- ost = gen.ost(ostname, ost_uuid, obd_uuid, net_uuid)
+ error("NODE: No net network interface for", node_name, "found")
- if lovname:
- lov = findByName(lustre, lovname, "lov")
- if not lov:
- error('add_ost:', '"'+lovname+'"', "lov element not found.")
- lov_add_obd(gen, lov, obd_uuid)
+ osd = gen.osd(osdname, osd_uuid, fstype, osdtype, devname, get_format_flag(options), ost_uuid,
+ net_uuid, size)
node = findByName(lustre, node_name, "node")
- node_add_profile(gen, node, 'obd', obd_uuid)
- node_add_profile(gen, node, 'ost', ost_uuid)
- lustre.appendChild(obd)
- lustre.appendChild(ost)
+## if node_add_profile(gen, node, 'oss', oss_uuid):
+## ossname = 'OSS'
+## oss_uuid = new_uuid(ossname)
+## oss = gen.oss(ossname, oss_uuid)
+## lustre.appendChild(oss)
+
+ node_add_profile(gen, node, 'osd', osd_uuid)
+ lustre.appendChild(osd)
def add_cobd(gen, lustre, options):
def add_echo_client(gen, lustre, options):
""" add an echo client to the profile for this node. """
node_name = get_option(options, 'node')
- lov_name = get_option(options, 'obd')
+ lov_name = get_option(options, 'ost')
node = findByName(lustre, node_name, 'node')
echoname = new_name('ECHO_'+ node_name)
echo_uuid = new_uuid(echoname)
- node_add_profile(gen, node, 'echo_client', echo_uuid)
+ node_add_profile(gen, node, 'echoclient', echo_uuid)
lov_uuid = name2uuid(lustre, lov_name, tag='lov', fatal=0)
if not lov_uuid:
- lov_uuid = name2uuid(lustre, lov_name, tag='obd', fatal=1)
+ lov_uuid = name2uuid(lustre, lov_name, tag='ost', fatal=1)
echo = gen.echo_client(echoname, echo_uuid, lov_uuid)
lustre.appendChild(echo)
warning("name:", lov_orig, "already used. using:", name)
mds_name = get_option(options, 'mds')
- stripe_sz = get_option(options, 'stripe_sz')
- stripe_cnt = get_option(options, 'stripe_cnt', 0)
- pattern = get_option(options, 'stripe_pattern', 0)
+ stripe_sz = get_option_int(options, 'stripe_sz')
+ stripe_cnt = get_option_int(options, 'stripe_cnt', 0)
+ pattern = get_option_int(options, 'stripe_pattern', 0)
uuid = new_uuid(name)
ret = findByName(lustre, name, "lov")
lov = gen.lov(name, uuid, mds_uuid, stripe_sz, stripe_cnt, pattern)
lustre.appendChild(lov)
- # add an lovconfig entry to the mds profile
+ # add an lovconfig entry to the active mdsdev profile
lovconfig_name = new_name('LVCFG_' + name)
lovconfig_uuid = new_uuid(lovconfig_name)
- node = mds2node(lustre, mds_name)
- node_add_profile(gen, node, "lovconfig", lovconfig_uuid)
+ mds = findByName(lustre, mds_name)
+ mds.appendChild(gen.ref("lovconfig", lovconfig_uuid))
lovconfig = gen.lovconfig(lovconfig_name, lovconfig_uuid, uuid)
lustre.appendChild(lovconfig)
mds_name = get_option(options, 'mds')
lov_name = get_option(options, 'lov', '')
if lov_name == '':
- lov_name = get_option(options, 'obd', '')
+ lov_name = get_option(options, 'ost', '', deprecated_tag='obd')
if lov_name == '':
- error("--add mtpt requires either --lov lov_name or --obd obd_name")
+ error("--add mtpt requires either --lov lov_name or --ost ost_name")
name = new_name('MNT_'+ node_name)
mds_uuid = name2uuid(lustre, mds_name, tag='mds')
lov_uuid = name2uuid(lustre, lov_name, tag='lov', fatal=0)
if not lov_uuid:
- lov_uuid = name2uuid(lustre, lov_name, tag='obd', fatal=1)
+ lov_uuid = name2uuid(lustre, lov_name, tag='ost', fatal=1)
uuid = new_uuid(name)
mtpt = gen.mountpoint(name, uuid, mds_uuid, lov_uuid, path)
node_add_profile(gen, node, "mountpoint", uuid)
lustre.appendChild(mtpt)
+# obsolete, leaving behind for reference
def add_oscref(gen, lustre, options):
""" create mtpt on a node """
node_name = get_option(options, 'node')
return 1
return 0
-def get_option(options, tag, default = None):
+def get_option(options, tag, default = None, deprecated_tag=None):
"""Look for tag in options hash and return the value if set. If not
set, then if return default it is set, otherwise exception."""
if options.has_key(tag):
return options[tag]
+ elif deprecated_tag and options.has_key(deprecated_tag):
+ warning('--'+deprecated_tag, " is deprecated, please use:", '--'+tag)
+ return options[deprecated_tag]
elif default != None:
return default
else:
- raise OptionError("--add %s requires --%s value" % (options['add'], tag))
+ raise OptionError("--add %s requires --%s <value>" % (options['add'], tag))
# this exception should print an error like '--add blah requires --<tag> value'
def get_option_int(options, tag, default = None):
"""Return an integer option. Raise exception if the value is not an int"""
val = get_option(options, tag, default)
- return int(val)
+ try:
+ n = int(val)
+ except ValueError:
+ raise OptionError("--%s <num> (value must be integer)" % (tag))
+ return n
def parse_cmdline(argv):
short_opts = "ho:i:m:"
long_opts = ["add=", "node=", "nettype=", "nid=", "tcpbuf=", "port=",
"echo_client=", "stripe_sz=", "stripe_cnt=", "stripe_pattern=",
"mds=", "route", "router", "merge=", "format", "reformat", "output=",
- "dev=", "size=", "obd=", "obdtype=", "obduuid=", "in=",
- "path=", "help", "batch=", "lov=", "gw=", "lo=", "hi=",
- "oscref", "osc=", "real_obd=", "cache_obd=", "fstype=",
+ "dev=", "size=", "obd=", "ost=", "obdtype=", "osdtype=", "obduuid=", "in=",
+ "osduuid=", "path=", "help", "batch=", "lov=", "gw=", "lo=", "hi=",
+ "osc=", "real_obd=", "cache_obd=", "fstype=",
"timeout=", "recovery_upcall="]
opts = []
args = []
options['mds'] = a
if o == "--obd":
options['obd'] = a
+ if o == "--ost":
+ options['ost'] = a
# node options
if o == "--timeout":
options['osc'] = a
if o == "--obdtype":
options['obdtype'] = a
+ if o == "--osdtype":
+ options['osdtype'] = a
if o == "--fstype":
options['fstype'] = a
if o == "--obduuid":
options['obduuid'] = a
+ if o == "--osduuid":
+ options['osduuid'] = a
# lov options
if o == "--stripe_sz":
if o == "--format":
options['format'] = 1
if o == "--reformat":
+ warning("the lmc --reformat option is not supported. Use lconf --reformat")
options['reformat'] = 1
if o == "--batch":
options['batch'] = a
add_node(gen, lustre, options)
elif devtype == 'echo_client':
add_echo_client(gen, lustre, options)
- elif devtype == 'oscref':
- add_oscref(gen, lustre, options)
elif devtype == 'cobd':
add_cobd(gen, lustre, options)
else:
if __name__ == "__main__":
main()
-
-