forked from sudarsku/openstack-sqe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
60 lines (49 loc) · 1.52 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
import os
from fabric.api import task, local
from fabs.common import timed, virtual
from fabs.common import logger as log
from fabs import LVENV, CVENV, LAB
from fabs import coi, tempest, snap, devstack, redhat, coverage
@timed
def venv(private=False):
log.info("Installing packages from requirements")
# local("sudo apt-get install -y $(cat requirements_packages)")
venv_path = CVENV
if private:
venv_path = LVENV
if not os.path.exists(venv_path):
log.info("Creating virtual environment in {dir}".format(dir=venv_path))
local("virtualenv --setuptools %s" % venv_path)
else:
log.info("Virtual environment in {dir} already exists".format(dir=venv_path))
@timed
@virtual
def requirements():
log.info("Installing python modules from requirements")
local("pip install -Ur requirements")
@task
@virtual
def flake8():
''' Make a PEP8 check for code '''
local("flake8 --max-line-length=120 --show-source --exclude=.env1 . || echo")
@task
@virtual
def test():
''' For testing purposes only '''
log.info("Testing something")
a = local("which python")
print a.real_command
@task(default=True)
@timed
def init(private=False):
''' Prepare virtualenv and install all requirements '''
venv(private=private)
requirements()
@task
@timed
@virtual
def destroy():
''' Destroying all lab machines and networks '''
log.info("Destroying lab {lab}".format(lab=LAB))
local("python ./tools/cloud/create.py -l {lab} -x".format(lab=LAB))