def add_peer_nodes_to_cluster(peers, mnode=None): """Adds the given peer nodes to cluster Args: peers (list) : list of peer nodes to be attached to cluster Kwargs: mnode (str): Node on which cmd has to be executed. If None, defaults to servers[0]. Returns: bool: True, if peer nodes are attached to cluster False, otherwise Example: add_peer_nodes_to_cluster(['peer_node1','peer_node2']) """ if mnode is None: mnode = tc.servers[0] if not isinstance(peers, list): peers = [peers] ret = start_glusterd(servers=peers) if not ret: tc.logger.error("glusterd did not start in peer nodes") return False ret = peer_probe_servers(servers=peers, mnode=mnode) if not ret: tc.logger.error("Unable to do peer probe on peer machines") return False return True
def setup_vol(volname='', dist='', rep='', dispd='', red='', stripe='', \ trans='', servers=''): """ Setup a gluster volume for testing. It first formats the back-end bricks and then creates a trusted storage pool by doing peer probe. And then it creates a volume of specified configuration. When the volume is created, it sets a global flag to indicate that the volume is created. If another testcase calls this function for the second time with same volume name, the function checks for the flag and if found, will return True. Returns True on success and False for failure. """ if servers == '': servers = tc.servers volinfo = get_volume_info(server=servers[0]) if volinfo is not None and volname in volinfo.keys(): tc.logger.debug("volume %s already exists in %s. Returning..." \ % (volname, servers[0])) return True ret = env_setup_servers(servers=servers) if not ret: tc.logger.error("Formatting backend bricks failed. Aborting...") return False ret = start_glusterd(servers) if not ret: tc.logger.error("glusterd did not start in at least one server") return False time.sleep(5) ret = peer_probe_servers(servers[1:], mnode=servers[0]) if not ret: tc.logger.error("Unable to peer probe one or more machines") return False if rep != 1 and dispd != 1: tc.logger.warning("Both replica count and disperse count is specified") tc.logger.warning("Ignoring the disperse and using the replica count") dispd = 1 red = 1 ret = create_volume(volname, dist, rep, stripe, trans, servers, \ dispd=dispd, red=red) if ret[0] != 0: tc.logger.error("Unable to create volume %s" % volname) return False time.sleep(2) ret = start_volume(volname, servers[0]) if not ret: tc.logger.error("volume start %s failed" % volname) return False if tc.global_config["gluster"]["cluster_config"]["nfs_ganesha"]["enable"]: from distaflibs.gluster.ganesha import vol_set_ganesha ret = vol_set_ganesha(volname) if not ret: tc.logger.error("failed to set the ganesha option for %s" % volname) return False tc.global_flag[volname] = True return True
def setup_vol(volname='', dist='', rep='', dispd='', red='', stripe='', \ trans='', servers=''): """ Setup a gluster volume for testing. It first formats the back-end bricks and then creates a trusted storage pool by doing peer probe. And then it creates a volume of specified configuration. When the volume is created, it sets a global flag to indicate that the volume is created. If another testcase calls this function for the second time with same volume name, the function checks for the flag and if found, will return True. Returns True on success and False for failure. """ if servers == '': servers = tc.servers volinfo = get_volume_info(server=servers[0]) if volinfo is not None and volname in volinfo.keys(): tc.logger.debug("volume %s already exists in %s. Returning..." \ % (volname, servers[0])) return True ret = env_setup_servers(servers=servers) if not ret: tc.logger.error("Formatting backend bricks failed. Aborting...") return False ret = start_glusterd(servers) if not ret: tc.logger.error("glusterd did not start in at least one server") return False time.sleep(5) ret = peer_probe_servers(servers[1:], mnode=servers[0]) if not ret: tc.logger.error("Unable to peer probe one or more machines") return False if rep != 1 and dispd != 1: tc.logger.warning("Both replica count and disperse count is specified") tc.logger.warning("Ignoring the disperse and using the replica count") dispd = 1 red = 1 ret = create_volume(volname, dist, rep, stripe, trans, servers, \ dispd=dispd, red=red) if ret[0] != 0: tc.logger.error("Unable to create volume %s" % volname) return False time.sleep(2) ret = start_volume(volname, servers[0]) if not ret: tc.logger.error("volume start %s failed" % volname) return False tc.global_flag[volname] = True return True
def setup_vol(volname, mnode=None, dist=1, rep=1, dispd=1, red=1, stripe=1, trans="tcp", servers=None): """ Setup a gluster volume for testing. It first formats the back-end bricks and then creates a trusted storage pool by doing peer probe. And then it creates a volume of specified configuration. When the volume is created, it sets a global flag to indicate that the volume is created. If another testcase calls this function for the second time with same volume name, the function checks for the flag and if found, will return True. Args: volname(str): volume name that has to be created Kwargs: mnode(str): server on which command has to be execeuted, defaults to tc.servers[0] dist(int): distribute count, defaults to 1 rep(int): replica count, defaults to 1 stripe(int): stripe count, defaults to 1 trans(str): transport type, defaults to tcp servers(list): servers on which volume has to be created, defaults to number of servers in pool list, if that is None, then takes tc.servers disp(int): disperse count, defaults to 1 dispd(int): disperse-data count, defaults to 1 red(int): rdundancy count, defaults to 1 Returns: bool: True on success and False for failure. """ if servers is None: servers = tc.servers[:] if mnode is None: mnode = tc.servers[0] volinfo = get_volume_info(mnode=mnode) if volinfo is not None and volname in volinfo.keys(): tc.logger.debug("volume %s already exists in %s. Returning..." \ % (volname, servers[0])) return True ret = env_setup_servers(servers=servers) if not ret: tc.logger.error("Formatting backend bricks failed. Aborting...") return False ret = start_glusterd(servers) if not ret: tc.logger.error("glusterd did not start in at least one server") return False time.sleep(5) ret = peer_probe_servers(servers[1:], mnode=mnode) if not ret: tc.logger.error("Unable to peer probe one or more machines") return False if rep != 1 and dispd != 1: tc.logger.warning("Both replica count and disperse count is specified") tc.logger.warning("Ignoring the disperse and using the replica count") dispd = 1 red = 1 ret = create_volume(volname, mnode, dist, rep, stripe, trans, servers, dispd=dispd, red=red) if ret[0] != 0: tc.logger.error("Unable to create volume %s" % volname) return False time.sleep(2) ret = start_volume(volname, mnode) if not ret: tc.logger.error("volume start %s failed" % volname) return False if tc.global_config["gluster"]["cluster_config"]["nfs_ganesha"]["enable"]: from distaflibs.gluster.ganesha import vol_set_ganesha ret = vol_set_ganesha(volname) if not ret: tc.logger.error("failed to set the ganesha option for %s" % volname) return False tc.global_flag[volname] = True return True