Skip to content

Commit

Permalink
CFY-7569: use a temporary directory by default
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-s committed Mar 8, 2018
1 parent 5463a66 commit dd624fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ docs/_build/
*COMMIT_MSG

.qbcache/

.idea/

6 changes: 4 additions & 2 deletions agent_packager/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Script to run Cloudify's Agent Packager via command line
Usage:
cfy-ap [--config=<path> --force --dryrun --no-validation -v]
cfy-ap [--config=<path> --force --dryrun --no-validation -v --env=<env_path>]
cfy-ap --version
Options:
Expand All @@ -12,6 +12,7 @@
-f --force Forces deletion and creation of venv and tar file.
-d --dryrun Prints out the modules to be installed without actually installing them.
-n --no-validation Does not validate that all modules were installed correctly.
-e --env=<env_path> Virtualenv to use (defaults to a temporary directory)
-v --verbose verbose level logging
--version Display current version
"""
Expand Down Expand Up @@ -47,7 +48,8 @@ def _run(test_options=None):
force=options.get('--force'),
dryrun=options.get('--dryrun'),
no_validate=options.get('--no-validation'),
verbose=options.get('--verbose')
verbose=options.get('--verbose'),
virtualenv=options.get('--env')
)

def main():
Expand Down
9 changes: 4 additions & 5 deletions agent_packager/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import shutil
import os
import sys
import tempfile

import utils
import codes

DEFAULT_CONFIG_FILE = 'config.yaml'
DEFAULT_OUTPUT_TAR_PATH = '{0}-{1}-agent.tar.gz'
DEFAULT_VENV_PATH = 'cloudify/env'

PREINSTALL_MODULES = [
'setuptools==36.8.0'
Expand Down Expand Up @@ -62,6 +62,7 @@ def _import_config(config_file=DEFAULT_CONFIG_FILE):
:param string config_file: path to config file
"""
config_file = os.path.expanduser(config_file)
lgr.debug('Importing config: {0}...'.format(config_file))
try:
with open(config_file, 'r') as c:
Expand Down Expand Up @@ -332,16 +333,14 @@ def _name_archive(distro, release, version, milestone, build):


def create(config=None, config_file=None, force=False, dryrun=False,
no_validate=False, verbose=True):
no_validate=False, verbose=True, virtualenv=None):
"""Creates an agent package (tar.gz)
This will try to identify the distribution of the host you're running on.
If it can't identify it for some reason, you'll have to supply a
`distribution` (e.g. Ubuntu) config object in the config.yaml.
The same goes for the `release` (e.g. Trusty).
A virtualenv will be created under cloudify/env.
The order of the modules' installation is as follows:
cloudify-rest-service
cloudify-plugins-common
Expand Down Expand Up @@ -385,7 +384,7 @@ def create(config=None, config_file=None, force=False, dryrun=False,
'({0})'.format(ex.message))
sys.exit(codes.errors['could_not_identify_distribution'])
python = config.get('python_path', '/usr/bin/python')
venv = DEFAULT_VENV_PATH
venv = virtualenv or tempfile.mkdtemp(prefix='agent-packager')
venv_already_exists = utils.is_virtualenv(venv)
destination_tar = config.get('output_tar', _name_archive(**name_params))

Expand Down

0 comments on commit dd624fe

Please sign in to comment.