Skip to main content

Tool to manage remote systems and services

Project description

Remote Resources MaNaGeMeNT

Intro

This tool helps you manage remote machines and services running on that. It is targeted to Linux based machines. All is done via SSH connection, that means SSH server must be running there already.

from rrmngmnt import Host, RootUser

h = Host("10.11.12.13")
h.users.append(RootUser('123456'))

exec = h.executor()
# Run with sudo
exec = h.executor(sudo=True)

print exec.run_cmd(['echo', 'Hello World'])

Using SSH key for authentication

from rrmngmnt import Host, UserWithPKey

h = Host("10.11.12.13")
user = UserWithPKey('user', '/path/to/pkey'))

h.executor(user).run_cmd(['echo', 'Use pkey for auth instead of password'])

Using SSH key with disabled algorithms on paramiko SSHClient connect (Used when connecting to machines using old SSH)

from rrmngmnt import Host, UserWithPKey, RemoteExecutorFactory

h = Host("10.11.12.13")
h.executor_factory = RemoteExecutorFactory(disabled_algorithms=dict(pubkeys=['rsa-sha2-256', 'rsa-sha2-512'])
user = UserWithPKey('user', '/path/to/pkey'))

h.executor(user).run_cmd(['echo', 'Use pkey and disabled algorithms for old openSSH connection'])

Using with SSH ProxyCommand .. code:: python

proxy_command = ‘some proxy command’ h = Host(hostname=”hostname”) host.executor_factory = ssh.RemoteExecutorFactory(sock=proxy_command) h.executor(user).run_cmd([‘echo’, ‘Use SSH with ProxyCommand’])

Features

List of provided interfaces to manage resources on machine, and examples.

Filesystem

Basic file operations, you can find there subset of python ‘os’ module related to files.

print h.fs.exists("/path/to/file")
h.fs.chown("/path/to/file", "root", "root")
h.fs.chmod("/path/to/file", "644")
h.fs.unlink("/path/to/file")

In additional there are methods to fetch / put file from / to remote system to / from local system.

h.fs.get("/path/to/remote/file", "/path/to/local/file/or/target/dir")
h.fs.put("/path/to/local/file", "/path/to/remote/file/or/target/dir")

There is one special method which allows transfer file between hosts.

h1.fs.transfer(
    "/path/to/file/on/h1",
    h2, "/path/to/file/on/h2/or/target/dir",
)

You can also mount devices.

with h.fs.mount_point(
    '//example.com/share', opts='ro,guest',
    fstype='cifs', target='/mnt/netdisk'
) as mp:
    h.fs.listdir(mp.target) # list mounted directory
    mp.remount('rw,sync,guest') # remount with different options
    h.fs.touch('%s/new_file' % mp.target) # touch file

Firewall

Allows to manage firewall configurarion. Check which firewall service is running on host (firewalld/iptables) and make configure this service.

h.firewall.is_active('iptables')
h.firewall.chain('OUTPUT').list_rules()
h.firewall.chain('OUTPUT').add_rule('1.1.1.1', 'DROP')

Network

It allows to manage network configuration.

print h.network.hostname
h.network.hostname = "my.machine.org"
print h.network.all_interfaces()
print h.network.list_bridges()

Package Management

It encapsulates various package managements. It is able to determine which package management to use. You can still specify package management explicitly.

Implemented managements:

  • APT

  • YUM

  • DNF

  • RPM

# install htop package using implicit management
h.package_management.install('htop')
# remove htop package using rpm explicitly
h.package_management('rpm').remove('htop')

System Services

You can toggle system services, it encapsulates various service managements. It is able to determine which service management to use in most cases.

Implemented managements:

  • Systemd

  • SysVinit

  • InitCtl

if h.service('httpd').status():
    h.service('httpd').stop()
if h.service('httpd').is_enabled():
    h.service('httpd').disable()

Operating System Info

Host provide os attribute which allows obtain basic operating system info. Note that os.release_info depends on systemd init system.

print h.os.distribution
# Distribution(distname='Fedora', version='23', id='Twenty Three')

print h.os.release_info
# {'HOME_URL': 'https://fedoraproject.org/',
#  'ID': 'fedora',
#  'NAME': 'Fedora',
#  'PRETTY_NAME': 'Fedora 23 (Workstation Edition)',
#  'VARIANT': 'Workstation Edition',
#  'VARIANT_ID': 'workstation',
#  'VERSION': '23 (Workstation Edition)',
#  'VERSION_ID': '23',
#  ...
# }

print h.os.release_str
# Fedora release 23 (Twenty Three)

Storage Management

It is in PROGRESS state. Planed are NFS & LVM services.

Power Management

Give you possibility to control host power state, you can restart, poweron, poweroff host and get host power status.

Implemented managements:

  • SSH

  • IPMI

ipmi_user = User(pm_user, pm_password)
ipmi_params = {
    'pm_if_type': 'lan',
    'pm_address': 'test-mgmt.testdomain',
    'user': ipmi_user
}
h.add_power_manager(
    power_manager.IPMI_TYPE, **ipmi_params
)
# restart host via ipmitool
h.power_manager.restart()

Requires

  • paramiko

  • netaddr

  • six

Install

pip install python-rrmngmnt

Test

tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_rrmngmnt-0.2.2.tar.gz (152.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_rrmngmnt-0.2.2-py3-none-any.whl (50.1 kB view details)

Uploaded Python 3

File details

Details for the file python_rrmngmnt-0.2.2.tar.gz.

File metadata

  • Download URL: python_rrmngmnt-0.2.2.tar.gz
  • Upload date:
  • Size: 152.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_rrmngmnt-0.2.2.tar.gz
Algorithm Hash digest
SHA256 5f8e61ca33cffc9084eadf69a83f05d59f7a5a2fd349cc5cc664698c0c672b39
MD5 3d2f0d880a42f9482a28bf23993a4907
BLAKE2b-256 21bac6625d8754f9f963f854fdd7b731d174ae23bf663da0e7dc4bdcc1ba0ca8

See more details on using hashes here.

File details

Details for the file python_rrmngmnt-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: python_rrmngmnt-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 50.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_rrmngmnt-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 353c5cf03c46ba27c7a70065e0417816115212af722d03a7cea49bb3eb3432ae
MD5 938a79af8cf9e1e59dc35e52ec7cdda1
BLAKE2b-256 7c4c1296147b5c157c79a83ddb9d8e76a0f96c8dfc086d25de1b7ed104511efd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page