Skip to content

Commit dd624fe

Browse files
committed
CFY-7569: use a temporary directory by default
1 parent 5463a66 commit dd624fe

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ docs/_build/
5757
*COMMIT_MSG
5858

5959
.qbcache/
60+
61+
.idea/
62+

agent_packager/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""Script to run Cloudify's Agent Packager via command line
44
55
Usage:
6-
cfy-ap [--config=<path> --force --dryrun --no-validation -v]
6+
cfy-ap [--config=<path> --force --dryrun --no-validation -v --env=<env_path>]
77
cfy-ap --version
88
99
Options:
@@ -12,6 +12,7 @@
1212
-f --force Forces deletion and creation of venv and tar file.
1313
-d --dryrun Prints out the modules to be installed without actually installing them.
1414
-n --no-validation Does not validate that all modules were installed correctly.
15+
-e --env=<env_path> Virtualenv to use (defaults to a temporary directory)
1516
-v --verbose verbose level logging
1617
--version Display current version
1718
"""
@@ -47,7 +48,8 @@ def _run(test_options=None):
4748
force=options.get('--force'),
4849
dryrun=options.get('--dryrun'),
4950
no_validate=options.get('--no-validation'),
50-
verbose=options.get('--verbose')
51+
verbose=options.get('--verbose'),
52+
virtualenv=options.get('--env')
5153
)
5254

5355
def main():

agent_packager/packager.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import shutil
77
import os
88
import sys
9+
import tempfile
910

1011
import utils
1112
import codes
1213

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

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

333334

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

0 commit comments

Comments
 (0)