Exemplo n.º 1
0
 def __init__(self, osd_id):
     self.cli = host_helpers.CLIHelper()
     self.config = {}
     cexpr = re.compile(r'\s*"(\S+)":\s+"(\S+)".*')
     for line in self.cli.ceph_daemon_config_show(osd_id=osd_id):
         ret = re.match(cexpr, line)
         if ret:
             self.config[ret.group(1)] = ret.group(2)
Exemplo n.º 2
0
    def vendor(self):
        out = host_helpers.CLIHelper().lscpu()
        if not out:
            return

        for line in out:
            if line.startswith("Vendor ID:"):
                return re.search(r'Vendor ID:\s+(.+)', line).group(1).lower()
Exemplo n.º 3
0
    def version(self):
        """Returns string kernel version."""
        uname = host_helpers.CLIHelper().uname()
        if uname:
            ret = re.compile(r"^Linux\s+\S+\s+(\S+)\s+.+").match(uname)
            if ret:
                self._kernel_version = ret[1]

        return self._kernel_version
Exemplo n.º 4
0
    def ps_units(self):
        """ Units identified from running processes. """
        units = set()
        for line in host_helpers.CLIHelper().ps():
            if "unit-" in line:
                ret = re.compile(r".+jujud-unit-(\S+)-(\d+).*").match(line)
                if ret:
                    units.add(JujuUnit(ret[2], ret[1]))

        return units
Exemplo n.º 5
0
    def get_date_secs(cls, datestring=None):
        if datestring:
            cmd = ["date", "--utc", "--date={}".format(datestring), "+%s"]
            date_in_secs = subprocess.check_output(cmd)
        else:
            date_in_secs = host_helpers.CLIHelper().date() or 0
            if date_in_secs:
                date_in_secs = date_in_secs.strip()

        return int(date_in_secs)
Exemplo n.º 6
0
 def __init__(self, daemon_type):
     self.daemon_type = daemon_type
     self.cli = host_helpers.CLIHelper()
     self.date_in_secs = self.get_date_secs()
     self._version_info = None
     self._etime = None
     self._rss = None
     # create file-based caches of useful commands so they can be searched.
     self.cli_cache = {'ps': self.cli.ps()}
     for cmd, output in self.cli_cache.items():
         self.cli_cache[cmd] = utils.mktemp_dump('\n'.join(output))
Exemplo n.º 7
0
 def __init__(self):
     cli = host_helpers.CLIHelper()
     out = cli.ovs_appctl_dpctl_show(datapath='system@ovs-system')
     cexpr = re.compile(r'\s*lookups: hit:(\S+) missed:(\S+) lost:(\S+)')
     self.fields = {'hit': 0, 'missed': 0, 'lost': 0}
     for line in out:
         ret = re.match(cexpr, line)
         if ret:
             self.fields['hit'] = int(ret.group(1))
             self.fields['missed'] = int(ret.group(2))
             self.fields['lost'] = int(ret.group(3))
Exemplo n.º 8
0
 def __init__(self):
     self._property_cache = {}
     # save to file so we can search it later
     cli = host_helpers.CLIHelper()
     self._f_report = mktemp_dump(''.join(cli.rabbitmqctl_report()))
     searcher = FileSearcher()
     searcher.add_search_term(self.connections_searchdef, self._f_report)
     searcher.add_search_term(self.memory_searchdef, self._f_report)
     searcher.add_search_term(self.cluster_partition_handling_searchdef,
                              self._f_report)
     searcher.add_search_term(self.queues_searchdef, self._f_report)
     self.results = searcher.search()
Exemplo n.º 9
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.ceph_config = CephConfig()
     self.bcache = BcacheBase()
     self._local_osds = None
     self.apt_check = host_helpers.APTPackageChecksBase(
         core_pkgs=CEPH_PKGS_CORE, other_pkgs=CEPH_PKGS_OTHER)
     self.cluster = CephCluster()
     self.cli = host_helpers.CLIHelper()
     # create file-based caches of useful commands so they can be searched.
     self.cli_cache = {
         'ceph_volume_lvm_list': self.cli.ceph_volume_lvm_list()
     }
     for cmd, output in self.cli_cache.items():
         self.cli_cache[cmd] = utils.mktemp_dump('\n'.join(output))
Exemplo n.º 10
0
    def __init__(self):
        self.cli = host_helpers.CLIHelper()
        # create file-based caches of useful commands so they can be searched.
        self.cli_cache = {'ceph_versions': self.cli.ceph_versions()}
        for cmd, output in self.cli_cache.items():
            self.cli_cache[cmd] = utils.mktemp_dump('\n'.join(output))

        self.crush_map = CephCrushMap()
        self._large_omap_pgs = {}
        self._bad_meta_osds = []
        self._cluster_osds = []
        self._cluster_mons = []
        self._mon_dump = None
        self._osd_dump = None
        self._pg_dump = None
        self._osd_df_tree = None
        self._osds_pgs = {}
Exemplo n.º 11
0
    def instances(self):
        if self._instances is not None:
            return self._instances

        instances = {}
        for line in host_helpers.CLIHelper().ps():
            ret = re.compile('.+product=OpenStack Nova.+').match(line)
            if ret:
                name = None
                uuid = None

                expr = r'.+uuid\s+([a-z0-9\-]+)[\s,]+.+'
                ret = re.compile(expr).match(ret[0])
                if ret:
                    uuid = ret[1]

                expr = r'.+\s+-name\s+guest=(instance-\w+)[,]*.*\s+.+'
                ret = re.compile(expr).match(ret[0])
                if ret:
                    name = ret[1]

                if not all([name, uuid]):
                    continue

                guest = NovaInstance(uuid, name)
                ret = re.compile(r'mac=([a-z0-9:]+)').findall(line)
                if ret:
                    for mac in ret:
                        # convert libvirt to local/native
                        mac = 'fe' + mac[2:]
                        _port = self.nethelp.get_interface_with_hwaddr(mac)
                        if _port:
                            guest.add_port(_port)

                ret = re.compile(r'.+\s-m\s+(\d+)').search(line)
                if ret:
                    guest.memory_mbytes = int(ret.group(1))

                instances[uuid] = guest

        if not instances:
            return {}

        self._instances = instances
        return self._instances
Exemplo n.º 12
0
    def ovs_cleanup_run_manually(self):
        """ Allow one run on node boot/reboot but not after. """
        run_manually = False
        start_count = 0
        cli = host_helpers.CLIHelper()
        cexpr = re.compile(r"Started OpenStack Neutron OVS cleanup.")
        for line in cli.journalctl(unit="neutron-ovs-cleanup"):
            if re.compile("-- Reboot --").match(line):
                # reset after reboot
                run_manually = False
                start_count = 0
            elif cexpr.search(line):
                if start_count:
                    run_manually = True

                start_count += 1

        return run_manually
Exemplo n.º 13
0
 def test_get_interface_with_speed_exists(self, mock_cli):
     cli = host_helpers.CLIHelper()
     orig_ip_addr = cli.ip_addr()
     orig_ip_link = cli.ip_link()
     mock_cli.return_value = mock.MagicMock()
     mock_cli.return_value.ethtool.return_value = ['Speed: 100000Mb/s\n']
     mock_cli.return_value.ip_addr.return_value = orig_ip_addr
     mock_cli.return_value.ip_link.return_value = orig_ip_link
     expected = {
         'br-ens3': {
             'addresses': ['10.0.0.128'],
             'hwaddr': '22:c2:7b:1c:12:1b',
             'state': 'UP',
             'speed': '100000Mb/s'
         }
     }
     helper = host_helpers.HostNetworkingHelper()
     iface = helper.get_interface_with_addr('10.0.0.128')
     self.assertEqual(iface.to_dict(), expected)
Exemplo n.º 14
0
 def crm_status(self):
     return host_helpers.CLIHelper().pacemaker_crm_status
Exemplo n.º 15
0
 def __init__(self, name, nethelper):
     self.name = name
     self.cli = host_helpers.CLIHelper()
     self.nethelper = nethelper
Exemplo n.º 16
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.cli = host_helpers.CLIHelper()
     self.net_helper = host_helpers.HostNetworkingHelper()
Exemplo n.º 17
0
 def __init__(self):
     self.cli = host_helpers.CLIHelper()
     self._crush_rules = {}
     self._osd_crush_dump = None
     self._ceph_report = None
Exemplo n.º 18
0
 def setUp(self):
     self.snaps_list = host_helpers.CLIHelper().snap_list_all()
     super().setUp()