kharnam / devopsipy

DevOps oriented generic framework in Python 3
MIT License
0 stars 0 forks source link

DevOpsiPy Project

Abstract

Project aims to create generic, DevOps oriented framework in Python 3


Usage

Copy module to your project directory:

git clone git@github.com:kharnam/devopsipy.git

In your modules:
logger.py
main.py module:

from devopsipy import logger

log = logger.set_logger('MyCoolProject')
log.info('The first message from MyCoolProject Main module')

test.py module:

# Close to module top
import logging
log = logging.getLogger(__name__)
log.info('Logging from MyCoolProject Test module')

_host_base.py_

from devopsipy.host_base import HostBase

l_host = HostBase('localhost')
r_host = HostBase('my_remote_machine.example.com', ssh_user='user', ssh_key_file='~/.ssh/id_rsa')

l_host.run('uptime', print_pstate=True)
r_host.run(['mkdir test', 'cd test', 'ls -l'], print_stdout=True)

Current functionality

logger.py

Fully functional pre-configured logging facility

/tmp/logs# ll HostBaseTest_20181015_221711 -rw-r--r-- 1 kharnam wheel 12K 15 Oct 22:17 HostBaseTest_20181015_221711.debug.log -rw-r--r-- 1 kharnam wheel 2.6K 15 Oct 22:17 HostBaseTest_20181015_221711.info.log -rw-r--r-- 1 kharnam wheel 0B 15 Oct 22:17 HostBaseTest_20181015_221711.error.log



---
_**host_base.py**_

Module represents generic Linux host functionality
* Class HostBase
* HostBase State
* HostBase State Functions
* HostBase State Actions

---
_**utils.py**_

Module provides generic auxiliary functionality, like the folloowing:
* create_symlinks_to_files()
* yaml_to_dic()
* create_dir()
* is_dir_exist()
* save_data_to_file()
* load_data_from_file()
* get_caller()
* get_random_string()
* set_env_vars()
* replace_string_in_file()