def get_route_table(os_faults_steps, nodes): """Return route tables for each node.""" result = os_faults_steps.execute_cmd(nodes, 'ip r') tables = {} for node_result in result: node = nodes_steps.get_node_by_result(node_result, os_faults_steps) tables[node.fqdn] = node_result.payload['stdout_lines'] return tables
def test_huge_pages_usage(os_faults_steps, computes): """Verify if vRrouter uses Huge Pages.""" result = os_faults_steps.execute_cmd(computes, 'grep Huge /proc/meminfo') for node_result in result: node = nodes_steps.get_node_by_result(node_result, os_faults_steps) data = {} for line in node_result.payload['stdout_lines']: key, value = line.split(':', 1) data[key] = value.strip() assert_that(data, has_entries( HugePages_Total=is_not('0'), # TODO(gdyuldin): investigate this check correctness # AnonHugePages='0 kB' ), node.fqdn)
def get_interface_table(os_faults_steps, nodes): """Return interface table for each node. Format: {u'node-5.test.domain.local': [ {'name': u'vif0/3', u'HWaddr': u'00:00:5e:00:01:00', u'Flags': u'PL3L2D', ....}, {.....} ]} """ cmd = "vif --list" result = os_faults_steps.execute_cmd(nodes, cmd) tables = {} for node_result in result: node = nodes_steps.get_node_by_result(node_result, os_faults_steps) table = [] iface = {} for line in node_result.payload['stdout_lines']: if not line.strip(): if iface: table.append(iface) iface = {} else: if ':' not in line or line.startswith('Flags:'): continue elif line[0] != ' ': name, key, value = line.split(None, 2) key = key.strip(':') iface['name'] = name pairs = {key: value} else: pairs = line.split() start = next(i for i, pair in enumerate(pairs) if ':' in pair) prefix = u'_'.join(pairs[:start]) pairs = [u'{}_{}'.format(prefix, p) for p in pairs[start:]] pairs = dict(x.split(':', 1) for x in pairs) iface.update(pairs) if iface: table.append(iface) tables[node.fqdn] = table return tables
def get_devices(os_faults_steps, nodes): result = os_faults_steps.execute_cmd( nodes, '{} --status'.format(settings.DPDK_NEC_BIND_CMD), check=False) node_statuses = {} for node_result in result: node = nodes_steps.get_node_by_result(node_result, os_faults_steps) statuses = {} if node_result.status == stepler_config.STATUS_OK: lines = node_result.payload['stdout_lines'] for empty, section in itertools.groupby( lines, key=lambda x: x.strip() == ''): if empty: continue section = tuple(section) name = section[0] ifaces = [x for x in section[2:] if x.strip() != '<none>'] statuses[name] = ifaces node_statuses[node.fqdn] = statuses return node_statuses
def get_sriov_devices(os_faults_steps, computes): """Return computes with sriov neutron agents and them ifaces data. Example output: {'node-4.test.domain.local': {"ens11f1": {"sriov_numvfs": 7}}} """ cmd = "grep -v 0 /sys/class/net/*/device/sriov_numvfs" result = os_faults_steps.execute_cmd(computes, cmd, check=False) mapping = {} for node_result in result: node = nodes_steps.get_node_by_result(node_result, os_faults_steps) if node_result.status == stepler_config.STATUS_OK: node_data = {} for line in node_result.payload['stdout_lines']: path, sriov_numvfs = line.split(':') sriov_numvfs = int(sriov_numvfs) iface = path.split('/')[4] node_data[iface] = {'sriov_numvfs': sriov_numvfs} mapping[node.fqdn] = node_data return mapping
def get_services_statuses(os_faults_steps): """Function to retrieve contrail services statuses on each node. It returns an AttrDict: {'node-1.test.domain.local': [ {'name': service1', 'status': 'active', 'section': 'Contrail Database'}, {'name': service2', 'status': 'active', 'section': 'Contrail Database'}, ] 'node-2.test.domain.local': [...], ...} """ cmd = 'contrail-status' nodes = os_faults_steps.get_nodes_by_cmd('which ' + cmd) results = collections.defaultdict(list) for node_result in os_faults_steps.execute_cmd(nodes, cmd): node = nodes_steps.get_node_by_result(node_result, os_faults_steps) for service in parse_result(node_result.payload['stdout_lines']): results[node.fqdn].append(service) return attrdict.AttrDict(results)