def pool_creation_flow(stdurl, pool_params, num_of_disks, disk_type): list_cntrl = list_controller(stdurl) if list_cntrl[0] == 'FAILED': return ['FAILED', list_cntrl[1]] controllers_ip, num_of_Nodes = get_node_IP(list_cntrl[1]) logging.debug('num_of_Nodes: %s, controllers_ip: %s', \ num_of_Nodes, controllers_ip) if num_of_Nodes == 1: NODE1_IP = controllers_ip[0] elif num_of_Nodes == 2: NODE1_IP = controllers_ip[0] NODE2_IP = controllers_ip[1] else: logging.debug( 'Number of Nodes are more than 2, please revisit the code') exit() cntrl_info = get_controller_info(NODE1_IP, list_cntrl[1]) if cntrl_info[0] == 'FAILED': return ["FAILED", cntrl_info[1]] status, ctrl_name, ctrl_id, ctrl_ip, ctrl_cluster_id, ctrl_disks, \ site_id = get_value(cntrl_info) logging.info('Controller details is as follows:') logging.debug('status: %s, ctrl_name: %s, ctrl_id: %s, ctrl_ip: %s', \ status, ctrl_name, ctrl_id, ctrl_ip) logging.debug('ctrl_cluster_id: %s, ctrl_disks: %s, site_id: %s', \ ctrl_cluster_id, ctrl_disks, site_id) #Checking Node state if status.lower() == 'maintenance' and num_of_Nodes == 2: logging.debug('Node1 is in maintenance, checking status of Node2') cntrl_info = get_controller_info(NODE2_IP, list_cntrl[1]) if cntrl_info[0] == 'FAILED': return ["FAILED", cntrl_info[1]] status, ctrl_name, ctrl_id, ctrl_ip, ctrl_cluster_id, ctrl_disks, \ site_id = get_value(cntrl_info) if status.lower() == 'maintenance': msg = 'Both nodes are in maintenance, testcase cannot proceed' return ['FAILED', msg] elif status.lower() == 'maintenance' and num_of_Nodes == 1: msg = 'The single node in HAgroup is in maintenance, '\ 'testcase cannot proceed' return ['FAILED', msg] free_disks = getFreeDisk(ctrl_disks) if free_disks[0] == 'FAILED': return ['FAILED', free_disks[1]] disklist_id = getDiskToAllocate(free_disks[1], num_of_disks, disk_type) if disklist_id[0] == 'FAILED': return ['FAILED', disklist_id[1]] disklist_id = disklist_id[1] logging.debug('disklist_id: %s', disklist_id) #forming pool requried parameters for pool creation req_ids = {'siteid': site_id, 'clusterid': ctrl_cluster_id, \ 'controllerid': ctrl_id, 'diskslist': disklist_id } final_pool_params = dict(pool_params.items() + req_ids.items()) pool_creation = create_pool(final_pool_params, stdurl) if pool_creation[0] == 'FAILED': return ['FAILED', pool_creation[1]] return ["PASSED", 'Successfully created pool']
def pool_creation_flow(stdurl, pool_name, num_of_disks, disk_type, pool_type): list_cntrl = list_controller(stdurl) if list_cntrl[0] == 'FAILED': return ['FAILED', list_cntrl[1]] controllers_ip, num_of_Nodes = get_node_IP(list_cntrl[1]) logging.debug('num_of_Nodes: %s, controllers_ip: %s', \ num_of_Nodes, controllers_ip) if num_of_Nodes == 1: NODE1_IP = controllers_ip[0] elif num_of_Nodes == 2: NODE1_IP = controllers_ip[0] NODE2_IP = controllers_ip[1] else: logging.debug('Number of Nodes are more than 2, please revisit the code') exit() cntrl_info = get_controller_info(NODE1_IP, list_cntrl[1]) if cntrl_info[0] == 'FAILED': return ["FAILED", cntrl_info[1]] status, ctrl_name, ctrl_id, ctrl_ip, ctrl_cluster_id, ctrl_disks, \ site_id = get_value(cntrl_info) logging.info('Controller details is as follows:') logging.debug('status: %s, ctrl_name: %s, ctrl_id: %s, ctrl_ip: %s', \ status, ctrl_name, ctrl_id, ctrl_ip) logging.debug('ctrl_cluster_id: %s, ctrl_disks: %s, site_id: %s', \ ctrl_cluster_id, ctrl_disks, site_id) free_disks = getFreeDisk(ctrl_disks) if free_disks[0] == 'FAILED': return ['FAILED', free_disks[1]] disklist_id = getDiskToAllocate(free_disks[1], num_of_disks, disk_type) if disklist_id[0] == 'FAILED': return ['FAILED', disklist_id[1]] disklist_id = disklist_id[1] logging.debug('disklist_id: %s', disklist_id) #forming pool requried parameters for pool creation pool_params = {'name': pool_name, 'siteid': site_id, \ 'clusterid': ctrl_cluster_id, 'controllerid': ctrl_id, \ 'iops': 5000, 'diskslist': disklist_id, 'grouptype': pool_type} pool_creation = create_pool(pool_params, stdurl) if pool_creation[0] == 'FAILED': return ['FAILED', pool_creation[1]] return ["PASSED", 'Successfully created pool of raid type "%s" '\ 'with pool name "%s"' %(pool_type, pool_name)]
###---getting pool id---------------------------------------------------------- startTime = ctime() list_cntrl = list_controller(STDURL) controllers = verify_list_controller(list_cntrl, startTime) controllers_ip, num_of_Nodes = get_node_IP(controllers) if num_of_Nodes == 1: NODE1_IP = controllers_ip[0] elif num_of_Nodes == 2: NODE1_IP = controllers_ip[0] NODE2_IP = controllers_ip[1] else: logging.debug('No support yet for clusters with greater than 2 nodes') exit() get_info = get_controller_info(NODE1_IP, controllers) verify_get_controller_info(get_info, startTime) status, ctrl_name, ctrl_id, ctrl_ip, ctrl_cluster_id, ctrl_disks, \ site_id = get_value(get_info) if status.lower() == 'maintenance' and num_of_Nodes == 2: logging.debug('Node1 is in maintenance, checking status of Node2') get_info = get_controller_info(NODE2_IP, controllers) verify_get_controller_info(get_info, startTime) status, ctrl_name, ctrl_id, ctrl_ip, ctrl_cluster_id, ctrl_disks, \ site_id = get_value(get_info) if status.lower() == 'maintenance': logging.error('Both nodes are in maintenance, testcase cannot proceed') is_blocked(startTime, FOOTER_MSG, BLOCKED_MSG) elif status.lower() == 'maintenance' and num_of_Nodes == 1: logging.error('The single node in HAgroup is in maintenance, testcase '\