Esempio n. 1
0
 def __detach_worker(self, eventid, lvolstruct):
     failed = []
     try:
         nodes = hsvr_dag.create_dag_from_lvolstruct(lvolstruct, True)
         failed = dag.dag_execute(nodes, mynode.mynode_undo, noop, \
             self.dag_worker, mydaglogger)
         for n, ei in failed:
             t, v, tr = ei
             raise t, v
         self.event_record.set_event_status_and_result(eventid, EVENT_STATUS['DONE'], \
            0, needlock = True)
     except xmlrpclib.Fault, inst:
         self.event_record.set_event_status_and_result(eventid, EVENT_STATUS['ERROR'], \
            inst.faultCode, needlock = True)
Esempio n. 2
0
 def __attach_worker(self, eventid, lvolstruct):
     failed = []
     try:
         nodes = hsvr_dag.create_dag_from_lvolstruct(lvolstruct, False)
         failed = dag.dag_execute(nodes, mynode.mynode_do, \
             mynode.mynode_undo, self.dag_worker, mydaglogger)
         for n, ei in failed:
             t, v, tr = ei
             raise t, v
         self.event_record.set_event_status_and_result(eventid, EVENT_STATUS['DONE'],\
             0, needlock = True)
     except Exception:
         if failed:
             for n, ei in failed:
                 t, v, tr = ei
                 logger.error(traceback.format_exception(t, v, tr))
         else:
             logger.error(traceback.format_exc())
         self.event_record.set_event_status_and_result(eventid, EVENT_STATUS['ERROR'], \
             500, needlock = True)
     return 0
Esempio n. 3
0
 def __mirror_worker(self, eventid, mirrorid, add_lvolstruct, remove_lvolstruct):
     class MdadmNode(mynode.MyNode):
         def __init__(self, op, mirrordev, component):
             self.md_op = op
             self.md_mirrordev = mirrordev
             self.md_component = component
             mynode.MyNode.__init__(self, "mdadm:%s:%s:%s" % \
                 (op, mirrordev, component))
         def do(self):
             try:
                 executecommand("mdadm --manage --%s %s %s" % \
                     (self.md_op, self.md_mirrordev, \
                     self.md_component))
             except:
                 if self.md_op == "fail" or self.md_op == "remove":
                     # pass through dext remove.
                     # if fail/remove fail by already removed, it is OK and dext remove should be OK.
                     # otherwise dext remove will fail and return error to the caller
                     return
                 else:
                     raise
     def get_dext_path_from_lvolstruct(l):
         return getDextDevPath(l['lvolspec']['ssvrid'], l['lvolid'])
     failed = []
     try:
         mirrordev = getMirrorDevPath(mirrorid)
         add_path = get_dext_path_from_lvolstruct(add_lvolstruct)
         mdadd_node = MdadmNode("add", mirrordev, add_path)
         add_nodes = hsvr_dag.create_dag_from_lvolstruct(add_lvolstruct, \
             False)
         for n in add_nodes:
             mdadd_node.add_antecedent(n)
         remove_nodes = []
         if remove_lvolstruct['lvolid'] != 0:
             remove_path = get_dext_path_from_lvolstruct(remove_lvolstruct)
             if os.path.exists(remove_path):
                 mdfail_node = MdadmNode("fail", mirrordev, remove_path)
                 mdremove_node = MdadmNode("remove", mirrordev, remove_path)
             else:
                 mdfail_node = mynode.MyNode("mdfail_dummy")
                 mdremove_node = mynode.MyNode("mdremove_dummy")
             mdremove_node.add_antecedent(mdfail_node)
             if remove_lvolstruct['lvolid'] != add_lvolstruct['lvolid']:
                 remove_nodes = hsvr_dag.create_dag_from_lvolstruct( \
                     remove_lvolstruct, True)
                 for n in remove_nodes:
                     n.add_antecedent(mdremove_node)
             nodes = add_nodes + remove_nodes + \
                 [mdfail_node, mdadd_node, mdremove_node]
             mdadd_node.add_antecedent(mdremove_node)
         else: # add only
             nodes = add_nodes + [mdadd_node]
         def replace_do(n):
             if not n in remove_nodes:
                 mynode.mynode_do(n)
             else:
                 mynode.mynode_undo(n)
         def replace_undo(n):
             if not n in remove_nodes:
                 mynode.mynode_undo(n)
         failed = dag.dag_execute(nodes, replace_do, replace_undo, \
             self.dag_worker, mydaglogger)
         for n, ei in failed:
             t, v, tr = ei
             raise t, v
     except Exception:
         self.event_record.set_event_status_and_result(eventid, EVENT_STATUS['ERROR'], \
             500, needlock = True)
         if failed:
             for n, ei in failed:
                 t, v, tr = ei
                 logger.error(traceback.format_exception(t, v, tr))
         logger.error(traceback.format_exc())
     return 0