Generate VirtualHost configuration file (Apache 2v2/2v4)

gen_vhost is toolset for generation virtual host configuration file.

Developed in python code: 100%.

The README is used to introduce the modules and provide instructions on how to install the modules, any machine dependencies it may have and any other information that should be provided before the modules are installed.

Python package GitHub issues Documentation Status GitHub contributors

gen_vhost

gen_vhost package

Subpackages

gen_vhost.pro package
Submodules
gen_vhost.pro.read_template module
Module
read_template.py
Copyright
Copyright (C) 2017 Vladimir Roncevic <elektron.ronca@gmail.com> gen_vhost is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. gen_vhost is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Info
Defined class ReadTemplate with attribute(s) and method(s). Created API for read a template file and return a content.
class gen_vhost.pro.read_template.ReadTemplate(verbose=False)[source]

Bases: ats_utilities.config_io.base_check.FileChecking

Defined class ReadTemplate with attribute(s) and method(s). Created API for read a template file and return a content. It defines:

attributes:
GEN_VERBOSE - console text indicator for process-phase.
TEMPLATE_DIR - template dir path.
__template_dir - absolute file path of template dir.
methods:
__init__ - initial constructor.
get_template_dir - getter for template directory object.
read - read a template and return a string representation.
__str__ - dunder method for ReadTemplate.
GEN_VERBOSE = 'GEN_VHOST::PRO::READ_TEMPLATE'
TEMPLATE_DIR = '/../conf/template/'
VERBOSE = 'ATS_UTILITIES'
get_template_dir()[source]

Getter for template directory.

Returns:template directory path | None.
Return type:<str> | <NoneType>
read(template_module, verbose=False)[source]

Read template structure.

Parameters:
  • template_module (<str>) – template module name.
  • verbose (<bool>) – enable/disable verbose option.
Returns:

template content for setup module | None.

Return type:

<str> | <NoneType>

Exceptions:

ATSTypeError | ATSBadCallError

gen_vhost.pro.write_template module
Module
write_template.py
Copyright
Copyright (C) 2017 Vladimir Roncevic <elektron.ronca@gmail.com> gen_vhost is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. gen_vhost is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Info
Defined class WriteTemplate with attribute(s) and method(s). Created API for writing a template content with parameters.
class gen_vhost.pro.write_template.WriteTemplate(verbose=False)[source]

Bases: ats_utilities.config_io.base_check.FileChecking

Defined class WriteTemplate with attribute(s) and method(s). Created API for writing a template content with parameters. It defines:

attributes:
GEN_VERBOSE - console text indicator for process-phase.
MOD - module key for template.
MODLC - module key lower case for template.
DATE - date key for template.
YEAR - year key for template.
PORTS - ports key for template.
SERVER - server key for template.
ROOT_DOC - root doc key for template.
ADMIN_EMAIL - administrator email key for template.
TARGET_DIR - target directory key for template.
URL - url key for template.
methods:
__init__ - initial constructor.
write - write a template content with parameters.
__str__ - dunder method for WriteTemplate.
ADMIN_EMAIL = 'admin_email'
DATE = 'date'
GEN_VERBOSE = 'GEN_VHOST::PRO::WRITE_TEMPLATE'
MOD = 'mod'
MODLC = 'modlc'
PORTS = 'ports'
ROOT_DOC = 'root_doc'
SERVER = 'server_name'
TARGET_DIR = 'target_dir'
URL = 'url'
VERBOSE = 'ATS_UTILITIES'
YEAR = 'year'
write(module_content, module_name, module_file, verbose=False)[source]

Write a template content with parameters to a file.

Parameters:
  • module_content (<str>) – template content.
  • module_name (<str>) – file name.
Returns:

boolean status, True (success) | False.

Return type:

<bool>

Exception:

ATSBadCallError | ATSTypeError

Module contents
Module
__init__.py
Copyright
Copyright (C) 2017 Vladimir Roncevic <elektron.ronca@gmail.com> gen_vhost is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. gen_vhost is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Info
Defined class VHost with attribute(s) and method(s). Generate virtual host configuration module by template and parameters.
class gen_vhost.pro.VHost(verbose=False)[source]

Bases: ats_utilities.config_io.base_check.FileChecking

Defined class VHost with attribute(s) and method(s). Generate virtual host configuration module by template and parameters. It defines:

attributes:
GEN_VERBOSE - console text indicator for process-phase.
PRO_STRUCTURE - project setup (template, module).
__reader - reader API.
__writer - writer API.
__config - project setup in dict format.
methods:
__init__ - initial constructor.
get_reader - getter for template reader.
get_writer - getter for template writer.
gen_vh_module - generate virtual host file.
select_pro_type - select project type.
__str__ - dunder method for VHost.
GEN_VERBOSE = 'GEN_VHOST::PRO::VHOST'
PRO_STRUCTURE = '/../conf/project.yaml'
VERBOSE = 'ATS_UTILITIES'
gen_vh_module(module_name, verbose=False)[source]

Generate setup.py for module package.

Parameters:
  • module_name (<str>) – parameter package name.
  • verbose (<bool>) – enable/disable verbose option.
Returns:

boolean status, True (success) | False.

Return type:

<bool>

Exceptions:

ATSTypeError | ATSBadCallError

get_reader()[source]

Getter for template reader.

Returns:template reader object.
Return type:<ReadTemplate>
Exceptions:None
get_writer()[source]

Getter for template writer.

Returns:template writer object.
Return type:<WriteTemplate>
Exceptions:None
select_pro_type(verbose=False)[source]

Select project type.

Parameters:verbose (<bool>) – enable/disable verbose option.
Returns:template type | None.
Return type:<str> | <NoneType>
Exceptions:None

Module contents

Module
__init__.py
Copyright
Copyright (C) 2017 Vladimir Roncevic <elektron.ronca@gmail.com> gen_vhost is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. gen_vhost is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Info
Defined class GenVHost with attribute(s) and method(s). Load a base info, create an CLI interface and run operation(s).
class gen_vhost.GenVHost(verbose=False)[source]

Bases: ats_utilities.cli.cfg_cli.CfgCLI

Defined class GenVHost with attribute(s) and method(s). Load a base info, create an CLI interface and run operation(s). It defines:

attributes:
__metaclass__ - setting cooperative metaclasses.
GEN_VERBOSE - console text indicator for process-phase.
CONFIG - configuration file path.
LOG - tool log file path.
OPS - list of tool options.
logger - logger object API.
methods:
__init__ - initial constructor.
process - process and run tool option(s).
__str__ - dunder method for GenVHost.
CONFIG = '/conf/gen_vhost.cfg'
GEN_VERBOSE = 'GEN_VHOST'
LOG = '/log/gen_vhost.log'
OPS = ['-g', '--gen', '-v', '--verbose', '--version']
VERBOSE = 'ATS_UTILITIES'
process(verbose=False)[source]

Process and run operation.

Parameters:verbose (<bool>) – enable/disable verbose option.
Returns:boolean status, True (success) | False.
Return type:<bool>
Exceptions:None

Installation

Install Python2 Package Install Python3 Package

Navigate to release page download and extract release archive.

To install this set of modules type the following:

tar xvzf gen_vhost-x.y.z.tar.gz
cd gen_vhost-x.y.z
#python2
pip install -r requirements.txt
python setup.py install_lib
python setup.py install_egg_info
python setup.py install_data
#python3
pip3 install -r requirements.txt
python3 setup.py install_lib
python3 setup.py install_egg_info
python3 setup.py install_data

You can use Docker to create image/container, or You can use pip to install:

#python2
pip install gen_vhost
#python3
pip3 install gen_vhost

GitHub docker checker

Dependencies

gen_vhost requires next modules and libraries:

Tool structure

gen_vhost is based on OOP:

Code structure:

gen_vhost/
├── conf/
│   ├── gen_vhost.cfg
│   ├── gen_vhost_util.cfg
│   ├── project.yaml
│   └── template/
│       ├── vhost_perl.template
│       ├── vhost_php.template
│       ├── vhost_python.template
│       ├── vhost_ruby.template
│       └── vhost_static.template
├── __init__.py
├── log/
│   └── gen_vhost.log
├── pro/
│   ├── __init__.py
│   ├── read_template.py
│   └── write_template.py
└── run/
    └── gen_vhost_run.py

Indices and tables