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
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
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()
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()
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)
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
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()
def _delete_comfirm():#命名,是否删除 if stor_action.confirm_del(): excute() else: print('Delete canceled')
def excute(): if args.gui: print('for gui') else: stor_action.delete_storagepool(args.node, args.storagepool)
def excute(): if args.gui: print('for gui delete node') else: stor_action.delete_node(args.node)