コード例 #1
0
 def add_resource_mirror():
     # 添加mirror禁止输入的参数
     list_add_mirror_forbid = [args.diskless, args.size]
     if not args.add_mirror:
         return
     if any(list_add_mirror_forbid):
         return
     if all(list_auto_required) and not any(list_manual_required):
         #For GUI
         if args.gui:
             handle = SocketSend
             handle.send_result(stor_action.add_mirror_auto,args.resource,args.num)
             return True
         else:
             stor_action.add_mirror_auto(args.resource,args.num)
             return True
     elif all(list_manual_required) and not any(list_auto_required):
         try:
             is_args_correct()
         except NodeLessThanSPError:
             print('The number of nodes does not meet the requirements')
             return True
         else:
             #For GUI
             if args.gui:
                 handle = SocketSend
                 handle.send_result(stor_action.add_mirror_manual,args.resource,args.node,args.storagepool)
                 return True
             else:
                 stor_action.add_mirror_manual(args.resource,args.node,args.storagepool)
                 return True
コード例 #2
0
 def create_normal_resource():
     #正常创建resource禁止输入的参数
     list_normal_forbid = [args.diskless, args.add_mirror]
     if not args.size:
         return
     if any(list_normal_forbid):
         return
     if all(list_auto_required) and not any(list_manual_required):
         #For GUI
         if args.gui:
             handle = SocketSend
             handle.send_result(stor_action.create_res_auto,args.resource, args.size, args.num)
             return True
         #CLI
         else:
             stor_action.create_res_auto(args.resource, args.size, args.num)
             return True
     elif all(list_manual_required) and not any(list_auto_required):
         try:
             is_args_correct()
         except NodeLessThanSPError:
             print('The number of nodes and storage pools do not meet the requirements')
             return True
         else:
             #For GUI
             if args.gui:
                 handle = SocketSend
                 handle.send_result(stor_action.create_res_manual,args.resource,args.size,args.node,args.storagepool)
                 return True
             #CLI
             else:
                 stor_action.create_res_manual(args.resource,args.size,args.node,args.storagepool)
                 return True
コード例 #3
0
 def node_create():
     if args.gui:
         handle = SocketSend
         handle.send_result(stor_action.create_node,args.node, args.ip, args.nodetype)
     elif args.node and args.nodetype and args.ip:
         stor_action.create_node(args.node, args.ip, args.nodetype)
     else:
         parser_create.print_help()
コード例 #4
0
        def snap_create():
            args = self.args
            parser = self.storagepool_create

            if args.storagepool and args.node:
                if args.lvm:
                    stor_action.create_storagepool_lvm(args.node, args.storagepool, args.lvm)
                elif args.tlv:
                    stor_action.create_storagepool_thinlv(args.node, args.storagepool, args.tlv)
            else:
                parser.print_help()
コード例 #5
0
 def excute():#判断是否指定节点
     if args.node:
         if args.gui:
             print('for gui')
         else:
             stor_action.delete_resource_des(args.node, args.resource)
     elif not args.node:
         if args.gui:
             print('for gui')
         else:
             stor_action.delete_resource_all(args.resource)
コード例 #6
0
 def create_diskless_resource():
     list_diskless_forbid = [args.auto, args.num, args.storagepool, args.add_mirror,args.size]
     if not args.node:
         return
     if not any(list_diskless_forbid):
         if args.gui:
             handle = SocketSend
             handle.send_result(stor_action.create_res_diskless,args.node, args.resource)
             return True
         else:
             stor_action.create_res_diskless(args.node, args.resource)
             return True
コード例 #7
0
 def storagepool_create():
     if args.storagepool and args.node:
         if args.lvm:
             if args.gui:
                 handle = SocketSend
                 handle.send_result(stor_action.create_storagepool_lvm,args.node, args.storagepool, args.lvm)
             else:
                 stor_action.create_storagepool_lvm(args.node, args.storagepool, args.lvm)
         elif args.tlv:
             if args.gui:
                 handle = SocketSend
                 handle.send_result(stor_action.create_storagepool_thinlv,args.node, args.storagepool, args.tlv)
             else:
                 stor_action.create_storagepool_thinlv(args.node, args.storagepool, args.tlv)
         else:
             parser_create.print_help()
     else:
         parser_create.print_help()
コード例 #8
0
 def _delete_comfirm():#命名,是否删除
     if stor_action.confirm_del():
         excute()
     else:
         print('Delete canceled')
コード例 #9
0
 def excute():
     if args.gui:
         print('for gui')
     else:
         stor_action.delete_storagepool(args.node, args.storagepool)
コード例 #10
0
 def excute():
     if args.gui:
         print('for gui delete node')
     else:
         stor_action.delete_node(args.node)