Ejemplo n.º 1
0
# -*- coding: utf-8 -*-
'''
    :codauthor: :email:`Mike Place <*****@*****.**>`
'''

# Import Salt Testing libs
from salttesting import TestCase, skipIf
from salttesting.helpers import ensure_in_syspath
from salttesting.mock import MagicMock, patch, call

ensure_in_syspath('../../')

from salt.modules import ps

HAS_PSUTIL = ps.__virtual__()

if HAS_PSUTIL:
    import psutil

    STUB_CPU_TIMES = psutil._compat.namedtuple('cputimes',
                                               'user nice system idle')(1, 2,
                                                                        3, 4)
    STUB_VIRT_MEM = psutil._compat.namedtuple(
        'vmem', 'total available percent used free')(1000, 500, 50, 500, 500)
    STUB_SWAP_MEM = psutil._compat.namedtuple(
        'swap', 'total used free percent sin sout')(1000, 500, 500, 50, 0, 0)
    STUB_PHY_MEM_USAGE = psutil._compat.namedtuple(
        'usage', 'total used free percent')(1000, 500, 500, 50)
    STUB_DISK_PARTITION = psutil._compat.namedtuple(
        'partition', 'device mountpoint fstype, opts')(
            '/dev/disk0s2', '/', 'hfs',
Ejemplo n.º 2
0
# Import Python libs
from __future__ import absolute_import

# Import Salt Testing libs
from salttesting import TestCase, skipIf
from salttesting.helpers import ensure_in_syspath
from salttesting.mock import MagicMock, patch, call, Mock

ensure_in_syspath('../../')

# Import Salt libs
from salt.modules import ps
import salt.ext.six as six

ps_virtual = ps.__virtual__()
if ps_virtual is True or isinstance(ps_virtual, six.string_types):
    HAS_PSUTIL = True
else:
    HAS_PSUTIL = False
HAS_PSUTIL_VERSION = False

# Import 3rd-party libs
# pylint: disable=import-error,unused-import
from salt.ext.six.moves import range  # pylint: disable=redefined-builtin
if HAS_PSUTIL:
    import salt.utils.psutil_compat as psutil
    from collections import namedtuple

    PSUTIL2 = psutil.version_info >= (2, 0)
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
"""
    :codauthor: :email:`Mike Place <*****@*****.**>`
"""

# Import Salt Testing libs
from salttesting import TestCase, skipIf
from salttesting.helpers import ensure_in_syspath
from salttesting.mock import MagicMock, patch, call

ensure_in_syspath("../../")

from salt.modules import ps

HAS_PSUTIL = ps.__virtual__()

if HAS_PSUTIL:
    import psutil

    STUB_CPU_TIMES = psutil._compat.namedtuple("cputimes", "user nice system idle")(1, 2, 3, 4)
    STUB_VIRT_MEM = psutil._compat.namedtuple("vmem", "total available percent used free")(1000, 500, 50, 500, 500)
    STUB_SWAP_MEM = psutil._compat.namedtuple("swap", "total used free percent sin sout")(1000, 500, 500, 50, 0, 0)
    STUB_PHY_MEM_USAGE = psutil._compat.namedtuple("usage", "total used free percent")(1000, 500, 500, 50)
    STUB_DISK_PARTITION = psutil._compat.namedtuple("partition", "device mountpoint fstype, opts")(
        "/dev/disk0s2", "/", "hfs", "rw,local,rootfs,dovolfs,journaled,multilabel"
    )
    STUB_DISK_USAGE = psutil._compat.namedtuple("usage", "total used free percent")(1000, 500, 500, 50)
    STUB_NETWORK_IO = psutil._compat.namedtuple(
        "iostat", "bytes_sent, bytes_recv, packets_sent, packets_recv, errin errout dropin dropout"
    )(1000, 2000, 500, 600, 1, 2, 3, 4)
    STUB_DISK_IO = psutil._compat.namedtuple(
Ejemplo n.º 4
0
# Import Python libs
from __future__ import absolute_import

# Import Salt Testing libs
from salttesting import TestCase, skipIf
from salttesting.helpers import ensure_in_syspath
from salttesting.mock import MagicMock, patch, call, Mock

ensure_in_syspath('../../')

# Import Salt libs
from salt.modules import ps
import salt.ext.six as six

ps_virtual = ps.__virtual__()
if ps_virtual is True or isinstance(ps_virtual, six.string_types):
    HAS_PSUTIL = True
else:
    HAS_PSUTIL = False
HAS_PSUTIL_VERSION = False

# Import 3rd-party libs
# pylint: disable=import-error,unused-import
from salt.ext.six.moves import range  # pylint: disable=redefined-builtin
if HAS_PSUTIL:
    import salt.utils.psutil_compat as psutil
    from collections import namedtuple

    PSUTIL2 = psutil.version_info >= (2, 0)