def get_server_pods(index): """ Get machine ids for server pods: returns list of machine ids. """ machine_ids = [] server_pod_keys = Conf.search(index, GconfKeys.NODE_CONST.value, GconfKeys.NAME_CONST.value, Const.COMPONENT_RGW.value) for key in server_pod_keys: machine_id = key.split('>')[1] # Add machine id to list machine_ids.append(machine_id) return machine_ids
def get_data_pods(index): """ Get machine ids for data pods: returns list of machine ids. """ machine_ids = [] # Sample output of the serach API # ex: Conf.search("cortx", "node", "services", Const.SERVICE_MOTR_IO.value) # ['node>5f3dc3a153454a918277ee4a2c57f36b>components[1]>services[0]', # 'node>6203a14bde204e8ea798ad9d42583fb5>components[1]>services[0]', 'node>8cc8b13101e34b3ca1e51ed6e3228d5b>components[1]>services[0]'] data_pod_keys = Conf.search(index, GconfKeys.NODE_CONST.value, GconfKeys.SERVICE_CONST.value, Const.SERVICE_MOTR_IO.value) for key in data_pod_keys: machine_id = key.split('>')[1] # Add machine id to list machine_ids.append(machine_id) return machine_ids
def get_control_nodes(index): """ Returns list of machine_ids for control-node. Args: index(str): index of conf file parent key : node search key: name search val: csm Returns: list: list of node_ids >>> Conf.search("cortx", 'node', 'name', 'csm') ['node>a3710eee36644f2fb60ba19486664495>components[1]>name'] """ node_ids = [] try: node_key = Conf.search(index, GconfKeys.NODE_CONST.value, GconfKeys.NAME_CONST.value, Const.COMPONENT_CSM.value) for key in node_key: value = key.split('>')[1] node_ids.append(value) except Exception as e: Log.error(f"Unable to fetch control node machine-id. Error:{e}") return node_ids
def search(args): """Returns list of keys matching to the criteria.""" return Conf.search(ConfCli._index, args.parent_key, args.search_key, args.search_val)
def test_conf_store_search_keys(self): """Test conf store search key API by passing None value.""" keys = Conf.search('dict', 'k2', 'k5', None) expected = ['k2>k4>k5[0]', 'k2>k4>k5[1]', 'k2>k4>k5[2]'] self.assertListEqual(expected, keys)