Whamcloud - gitweb
* support for toenal
[fs/lustre-release.git] / lustre / utils / lmc
index 2d1ad26..6f34b2b 100755 (executable)
@@ -64,7 +64,7 @@ Commands:
    specifies the node to modify.
 
 --net hostname nettype [port, recv_buf, send_buf]
-   Nettype is either tcp, elan, or gm.
+   Nettype is either tcp, toe, elan, or gm.
    Requires --node
 
 --route net gw lo [hi]
@@ -87,6 +87,7 @@ Commands:
    When used on "host", the device will be initialized and the OST
    will be enabled. On client nodes, the OSC will be avaiable.
    Requires --node
+   Optional --obduuid Specifies the UUID used for the obd. 
    If --lov lov_name is used, this device is added to lov. 
 
 --mtpt /mnt/point mds_name lov_name|osc_name 
@@ -109,9 +110,13 @@ Options:
 
 def error(*args):
     msg = string.join(map(str,args))
-    print msg
+    print "Error: ", msg
     sys.exit(1)
     
+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
@@ -329,11 +334,11 @@ def mds2node(lustre, mds_name):
     mds = findByName(lustre, mds_name, 'mds')
     ref = mds.getElementsByTagName('node_ref')
     if not ref:
-        error("no node found for:", mds_name)
+        error("mds2node:", "no node_ref found for", '"'+mds_name+'"')
     node_uuid = ref[0].getAttribute('uuidref')
     node = lookup(lustre, node_uuid)
     if not node:
-        error("no node found for :", mds_name)
+        error('mds2node:', "no node found for :", '"'+mds_name+'"')
     return node
 
 
@@ -341,7 +346,7 @@ def name2uuid(lustre, name, tag="",  fatal=1):
     ret = findByName(lustre, name, tag)
     if not ret:
         if fatal:
-            error('name2uuid:', name, "not found.")
+            error('name2uuid:', '"'+name+'"', tag, 'element not found.')
         else:
             return ""
     return getUUID(ret)
@@ -353,7 +358,7 @@ def get_net_uuid(lustre, node_name):
     """ get a network uuid for a node_name """
     node = findByName(lustre, node_name, "node")
     if not node:
-        error ("node not found:", node_name)
+        error ('get_net_uuid:', '"'+node_name+'"', "node element not found.")
     net = node.getElementsByTagName('network')
     if net:
         return getUUID(net[0])
@@ -418,7 +423,7 @@ def add_net(gen, lustre, options, args):
     port = 0
     tcpbuf = 0
 
-    if net_type == 'tcp':
+    if net_type in ('tcp', 'toe'):
         if len(args) > 2:
             port = int(args[2])
         else:
@@ -480,6 +485,8 @@ def add_mds(gen, lustre, options, args):
         error("--mds requires a --node argument")
 
     mds_name = new_name(options['mds'])
+    if mds_name != options['mds']:
+        warning("name:", options['mds'], "already used. using:", mds_name)
     devname = args[0]
     if len(args) > 1:
         size = args[1]
@@ -488,7 +495,7 @@ def add_mds(gen, lustre, options, args):
 
     mds_uuid = new_uuid(mds_name)
 
-    node_uuid = name2uuid(lustre, node_name)
+    node_uuid = name2uuid(lustre, node_name, 'node')
 
     node = findByName(lustre, node_name, "node")
     node_add_profile(gen, node, "mds", mds_uuid)
@@ -519,7 +526,6 @@ def add_ost(gen, lustre, options, args):
 
     if options.has_key('obdtype'):
         obdtype = options['obdtype']
-
     if obdtype == 'obdecho':
         fstype = ''
     else:
@@ -532,7 +538,13 @@ def add_ost(gen, lustre, options, args):
     obdname = new_name('OBD_'+ node_name)
     oscname = new_name('OSC_'+ node_name)
     ostname = new_name('OST_'+ node_name)
-    obd_uuid = new_uuid(obdname)
+    if options.has_key('obduuid'):
+        obd_uuid = options['obduuid']
+        obd = lookup(lustre, obd_uuid)
+        if obd:
+            error("Duplicate OBD UUID:", obd_uuid)
+    else:
+        obd_uuid = new_uuid(obdname)
     ost_uuid = new_uuid(ostname)
     osc_uuid = new_uuid(oscname)
 
@@ -547,7 +559,7 @@ def add_ost(gen, lustre, options, args):
     if lovname:
         lov = findByName(lustre, lovname, "lov")
         if not lov:
-            error("LOV:", lovname, "not found.")
+            error('add_ost:', '"'+lovname+'"', "lov element not found.")
         lov_add_osc(gen, lov, osc_uuid)
 
     node = findByName(lustre, node_name, "node")
@@ -569,7 +581,7 @@ def add_osc(gen, lustre, options, args):
         node_name = options['node']
     else:
         error("--osc requires a --node argument")
-    osc_uuid = name2uuid(lustre, osc_name)
+    osc_uuid = name2uuid(lustre, osc_name) # either 'osc' or 'lov'
     node = findByName(lustre, node_name, "node")
     node_add_profile(gen, node, 'osc', osc_uuid)
 
@@ -579,7 +591,10 @@ def add_lov(gen, lustre, options, args):
     if len(args) < 4:
         usage()
 
-    name = options['lov']
+    name = new_name(options['lov'])
+    if name != options['lov']:
+        warning("name:", options['lov'], "already used. using:", name)
+
     mds_name = args[0]
     stripe_sz = args[1]
     stripe_count = args[2]
@@ -590,7 +605,7 @@ def add_lov(gen, lustre, options, args):
     if ret:
         error("LOV: ", name, " already exists.")
 
-    mds_uuid = name2uuid(lustre, mds_name)
+    mds_uuid = name2uuid(lustre, mds_name, 'mds')
     lov = gen.lov(name, uuid, mds_uuid, stripe_sz, stripe_count, pattern)
     lustre.appendChild(lov)
     
@@ -624,7 +639,7 @@ def add_mtpt(gen, lustre, options, args):
     if ret:
         error("MOUNTPOINT: ", name, " already exists.")
 
-    mds_uuid = name2uuid(lustre, mds_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='osc', fatal=1)
@@ -645,7 +660,7 @@ def parse_cmdline(argv):
     short_opts = "ho:i:m:"
     long_opts = ["ost", "osc", "mtpt", "lov=", "node=", "mds=", "net", "tcpbuf=",
                  "route", "router", "merge=", "format", "reformat", "output=",
-                 "obdtype=", "in=", "help", "batch="]
+                 "obdtype=", "obduuid=", "in=", "help", "batch="]
     opts = []
     args = []
     options = {}
@@ -656,10 +671,7 @@ def parse_cmdline(argv):
         usage()
 
     for o, a in opts:
-        if o in ("-h", "--help"):
-            usage()
-        if o in ("-o", "--output"):
-            options['output'] = a
+        # Commands to create new devices
         if o == "--ost":
             options['ost'] = 1
         if o == "--osc":
@@ -678,12 +690,22 @@ def parse_cmdline(argv):
             options['router'] = 1
         if o == "--lov":
             options['lov'] = a
-        if o in ("-m", "--merge"):
-            options['merge'] = a
+
+        # Options for commands
         if o == "--obdtype":
             options['obdtype'] = a
+        if o == "--obduuid":
+            options['obduuid'] = a
         if o == "--tcpbuf":
             options['tcpbuf'] = a
+
+        # lmc options
+        if o in ("-h", "--help"):
+            usage()
+        if o in ("-o", "--output"):
+            options['output'] = a
+        if o in ("-m", "--merge"):
+            options['merge'] = a
         if o == "--format":
             options['format'] = 1
         if o  == "--reformat":