Example #1
0
def get_overcloud_node_services_table(hostname):
    """
    get services table from overcloud node

       returns :
auditd.service|loaded|active|running|SecurityAuditingService
auth-rpcgss-module.service|loaded|inactivedead|KernelModulesupportingRPCSEC_GSS
blk-availability.service|loaded|active|exited|Availabilityofblockdevices
brandbot.service|loaded|inactivedead|FlexibleBrandingService
certmonger.service|loaded|active|running|CertificatemonitoringandPKIenrollment
cinder-lvm-losetup.service|loaded|inactivedead|CinderLVMlosetup
cloud-config.service|loaded|active|exited|Applythesettingsspecifiedincloud-con
cloud-final.service|loaded|active|exited|Executeclouduser/finalscripts
cloud-init-local.service|loaded|active|exited|Initialcloud-initjob(pre-network)
cloud-init.service|loaded|active|exited|Initialcloud-initjob(metadataservicecr)

    :return: dataframe of overcloud node services
    """

    ssh_client = overcloud.overcloud_ssh_client(hostname)
    output = sh.execute(
        "systemctl -a --no-pager --plain --no-legend|"
        "sed \'s/\\s\\s/|/g\'|sed \'s/||*/|/g\'|sed \'s@ @@g\'",
        ssh_client=ssh_client).stdout
    stream = six.StringIO(output)
    table = pandas.read_csv(stream, sep='|', header=None, skiprows=0)
    table.replace(to_replace=' ', value="", regex=True, inplace=True)
    table.columns = [
        'UNIT', 'loaded_state', 'active_state', 'low_level_state',
        'UNIT_DESCRIPTION'
    ]
    table['overcloud_node'] = hostname

    LOG.debug("Got overcloud nodes services status :\n%s", table)
    return table
Example #2
0
    def discover_overcloud_nodes(self):
        if overcloud.has_overcloud():
            for server in overcloud.list_overcloud_nodes():
                config = overcloud.overcloud_host_config(server.name)
                ssh_client = overcloud.overcloud_ssh_client(server.name)
                node = self.add_node(address=config.hostname,
                                     group='overcloud',
                                     ssh_client=ssh_client)

                group = node.name.split('-', 1)[0]
                if group == node.name:
                    LOG.warning("Unable to get node group name node name: %r",
                                node.name)
                else:
                    self.add_node(hostname=node.name, group=group)
        else:
            super(TripleoTopology, self).discover_nodes()
Example #3
0
def get_overcloud_node_processes_table(hostname):
    """
    get processes tables from overcloud node

       returns :
[root@controller-0 ~]# ps -axw -o "%U" -o "|%p" -o "|%P" -o "|%C" -o "|%z" -o
"|%x" -o "|%c" -o "|%a" |grep -v ps|head
USER    |    PID|   PPID|%CPU|   VSZ|    TIME|COMMAND        |COMMAND
|overcloud_node
root    |      1|      0| 1.3|246892|01:08:57|systemd        |/usr/lib/systemd
controller-0 ...
/systemd --switched-root --system --deserialize 18
root    |      2|      0| 0.0|     0|00:00:00|kthreadd       |[kthreadd]
root    |      3|      2| 0.0|     0|00:00:00|rcu_gp         |[rcu_gp]
root    |      4|      2| 0.0|     0|00:00:00|rcu_par_gp     |[rcu_par_gp]
root    |      6|      2| 0.0|     0|00:00:00|kworker/0:0H-ev|[kworker/0:0H
-events_highpri]
root    |      8|      2| 0.0|     0|00:00:00|mm_percpu_wq   |[mm_percpu_wq]
root    |      9|      2| 0.0|     0|00:00:06|ksoftirqd/0    |[ksoftirqd/0]
root    |     10|      2| 0.0|     0|00:04:28|rcu_sched      |[rcu_sched]
root    |     11|      2| 0.0|     0|00:00:05|migration/0    |[migration/0]

    :return: dataframe of overcloud node processes dataframe
    """

    ssh_client = overcloud.overcloud_ssh_client(hostname)
    output = sh.execute(
        "ps -axw -o \"%U\" -o \"DELIM%p\" -o \"DELIM%P\" -o \"DELIM%C\" -o "
        "\"DELIM%z\" -o \"DELIM%x\" -o \"DELIM%c\" -o \"DELIM%a\" |grep -v "
        "ps|sed 's/\"/''/g'",
        ssh_client=ssh_client).stdout
    stream = io.StringIO(output)
    table: pandas.DataFrame = pandas.read_csv(stream,
                                              sep='DELIM',
                                              header=None,
                                              skiprows=1)
    table.replace(to_replace=' ', value="", regex=True, inplace=True)
    table.columns = [
        'USER', 'PID', 'PPID', 'CPU', 'VSZ', 'TIME', 'PROCESS', 'PROCESS_ARGS'
    ]
    # pylint: disable=unsupported-assignment-operation
    table['overcloud_node'] = hostname

    LOG.debug("Successfully got overcloud nodes processes status table")
    return table
Example #4
0
def get_pcs_resources_table(hostname='controller-0'):
    """
    get pcs status from a controller and parse it
    to have it's resources states in check
       returns :
       rabbitmq-bundle-0    (ocf::heartbeat:rabbitmq-cluster):      Started con
       troller-0
       rabbitmq-bundle-1    (ocf::heartbeat:rabbitmq-cluster):      Started con
       troller-1
       rabbitmq-bundle-2    (ocf::heartbeat:rabbitmq-cluster):      Started con
       troller-2
       galera-bundle-0      (ocf::heartbeat:galera):        Master controller-0
       galera-bundle-1      (ocf::heartbeat:galera):        Master controller-1
       galera-bundle-2      (ocf::heartbeat:galera):        Master controller-2
       redis-bundle-0       (ocf::heartbeat:redis): Master controller-0
       redis-bundle-1       (ocf::heartbeat:redis): Slave controller-1
       redis-bundle-2       (ocf::heartbeat:redis): Slave controller-2
     ip-192.168.24.6        (ocf::heartbeat:IPaddr2):       Started controller-
     0
     ip-10.0.0.101  (ocf::heartbeat:IPaddr2):       Started controller-1
     ip-172.17.1.12 (ocf::heartbeat:IPaddr2):       Started controller-2
     ip-172.17.1.22 (ocf::heartbeat:IPaddr2):       Started controller-0
     ip-172.17.3.22 (ocf::heartbeat:IPaddr2):       Started controller-1
     ip-172.17.4.30 (ocf::heartbeat:IPaddr2):       Started controller-2
       haproxy-bundle-docker-0      (ocf::heartbeat:docker):        Started con
       troller-0
       haproxy-bundle-docker-1      (ocf::heartbeat:docker):        Started con
       troller-1
       haproxy-bundle-docker-2      (ocf::heartbeat:docker):        Started con
       troller-2
       openstack-cinder-volume-docker-0     (ocf::heartbeat:docker):        Sta
       rted controller-0

    :return: dataframe of pcs resources stats table
    """
    ssh_client = overcloud.overcloud_ssh_client(hostname)
    output = sh.execute("sudo pcs status | grep ocf",
                        ssh_client=ssh_client).stdout
    stream = six.StringIO(output)
    table = pandas.read_csv(stream, delim_whitespace=True, header=None)
    table.columns = [
        'resource', 'resource_type', 'resource_state', 'overcloud_node'
    ]
    LOG.debug("Got pcs status :\n%s", table)
    return table
Example #5
0
 def test_overcloud_group(self):
     for server in overcloud.list_overcloud_nodes():
         ssh_client = overcloud.overcloud_ssh_client(server.name)
         name = sh.get_hostname(ssh_client=ssh_client).split('.')[0]
         node = self.topology.get_node(name)
         self.assertIs(node.ssh_client, ssh_client)
         self.assertEqual(name, node.name)
         groups = ['overcloud']
         group = name.split('-', 1)[0]
         if group != name:
             groups.append(group)
         for group in groups:
             nodes = self.topology.get_group(group)
             self.assertIn(node, nodes)
             self.assertIn(group, node.groups)
         host_config = overcloud.overcloud_host_config(name)
         self.assertEqual(host_config.hostname,
                          str(node.public_ip))
Example #6
0
def get_overcloud_node_services_table(hostname):
    """
    get services table from overcloud node

       returns :
auditd.service|loaded|active|running|SecurityAuditingService
auth-rpcgss-module.service|loaded|inactivedead|KernelModulesupportingRPCSEC_GSS
blk-availability.service|loaded|active|exited|Availabilityofblockdevices
brandbot.service|loaded|inactivedead|FlexibleBrandingService
certmonger.service|loaded|active|running|CertificatemonitoringandPKIenrollment
cinder-lvm-losetup.service|loaded|inactivedead|CinderLVMlosetup
cloud-config.service|loaded|active|exited|Applythesettingsspecifiedincloud-con
cloud-final.service|loaded|active|exited|Executeclouduser/finalscripts
cloud-init-local.service|loaded|active|exited|Initialcloud-initjob(pre-network)
cloud-init.service|loaded|active|exited|Initialcloud-initjob(metadataservicecr)

    :return: dataframe of overcloud node services
    """
    ssh_client = overcloud.overcloud_ssh_client(hostname)
    units = sh.list_systemd_units(all=True,
                                  ssh_client=ssh_client).without_attributes(
        load='not-found')

    data: typing.Dict[str, list] = {'UNIT': [],
                                    'loaded_state': [],
                                    'active_state': [],
                                    'low_level_state': [],
                                    'UNIT_DESCRIPTION': []}
    for unit in units:
        data['UNIT'].append(unit.unit)
        data['loaded_state'].append(unit.load)
        data['active_state'].append(unit.active)
        data['low_level_state'].append(unit.sub)
        data['UNIT_DESCRIPTION'].append(unit.description)
    table = pandas.DataFrame.from_dict(data)
    table.replace(to_replace=' ', value="", regex=True, inplace=True)
    table['overcloud_node'] = hostname

    LOG.debug("Got overcloud nodes services status :\n%s", table)
    return table
Example #7
0
 def test_overcloud_ssh_client_connection(self):
     hostname = overcloud.find_overcloud_node().name
     ssh_client = overcloud.overcloud_ssh_client(hostname=hostname)
     ssh_client.connect()