Giter VIP home page Giter VIP logo

python-rrmngmnt's Introduction

Build Status Code Coverage Code Health

python-rrmngmnt

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()
print exec.run_cmd(['echo', 'Hello World'])

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",
)

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

python setup.py devop

Test

tox

python-rrmngmnt's People

Contributors

cynepco3hahue avatar ilpinto avatar lukas-bednar avatar machacekondra avatar myakove avatar nellyc avatar petr-balogh avatar raztamir avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.