Revision b63ed789 scripts/gnt-cluster

b/scripts/gnt-cluster
27 27
from ganeti import opcodes
28 28
from ganeti import constants
29 29
from ganeti import errors
30
from ganeti import utils
30 31

  
31 32

  
32 33
def InitCluster(opts, args):
......
191 192
  """
192 193
  op = opcodes.OpVerifyDisks()
193 194
  result = SubmitOpCode(op)
194
  if not isinstance(result, tuple) or len(result) != 2:
195
  if not isinstance(result, tuple) or len(result) != 4:
195 196
    raise errors.ProgrammerError("Unknown result type for OpVerifyDisks")
196 197

  
197
  nodes, instances = result
198
  nodes, nlvm, instances, missing = result
199

  
198 200
  if nodes:
199 201
    print "Nodes unreachable or with bad data:"
200 202
    for name in nodes:
201 203
      print "\t%s" % name
202 204
  retcode = constants.EXIT_SUCCESS
205

  
206
  if nlvm:
207
    for node, text in nlvm.iteritems():
208
      print ("Error on node %s: LVM error: %s" %
209
             (node, text[-400:].encode('string_escape')))
210
      retcode |= 1
211
      print "You need to fix these nodes first before fixing instances"
212

  
203 213
  if instances:
204 214
    for iname in instances:
215
      if iname in missing:
216
        continue
205 217
      op = opcodes.OpActivateInstanceDisks(instance_name=iname)
206 218
      try:
207 219
        print "Activating disks for instance '%s'" % iname
......
209 221
      except errors.GenericError, err:
210 222
        nret, msg = FormatError(err)
211 223
        retcode |= nret
212
        print >>sys.stderr, ("Error activating disks for instance %s: %s" %
213
                             (iname, msg))
224
        print >> sys.stderr, ("Error activating disks for instance %s: %s" %
225
                              (iname, msg))
226

  
227
  if missing:
228
    for iname, ival in missing.iteritems():
229
      all_missing = utils.all(ival, lambda x: x[0] in nlvm)
230
      if all_missing:
231
        print ("Instance %s cannot be verified as it lives on"
232
               " broken nodes" % iname)
233
      else:
234
        print "Instance %s has missing logical volumes:" % iname
235
        ival.sort()
236
        for node, vol in ival:
237
          if node in nlvm:
238
            print ("\tbroken node %s /dev/xenvg/%s" % (node, vol))
239
          else:
240
            print ("\t%s /dev/xenvg/%s" % (node, vol))
241
    print ("You need to run replace_disks for all the above"
242
           " instances, if this message persist after fixing nodes.")
243
    retcode |= 1
214 244

  
215 245
  return retcode
216 246

  

Also available in: Unified diff