aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-04-24 13:39:46 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-24 13:39:46 +0000
commit8f9a20b2908124655712b7688ba6b1b641b1608a (patch)
tree7f6786e4bc4a7105a53b110a26e7494f779ad83c
parent41a7dcb1ed23cc6b22769cc8b68c5b3e4bb2499a (diff)
parent03b4f1fb8136f12f9f7c80ee6dff771384916b7e (diff)
Merge "Add support for requirements.txt for pip deps"
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Definitions/remote_scripts.json2
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Environments/requirements.txt1
-rw-r--r--ms/command-executor/src/main/python/command_executor_handler.py16
3 files changed, 13 insertions, 6 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Definitions/remote_scripts.json b/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Definitions/remote_scripts.json
index da09e4f39..d78176f4c 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Definitions/remote_scripts.json
+++ b/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Definitions/remote_scripts.json
@@ -143,7 +143,7 @@
{
"type": "pip",
"package": [
- "ansible"
+ "requirements.txt"
]
},
{
diff --git a/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Environments/requirements.txt b/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Environments/requirements.txt
new file mode 100644
index 000000000..cabb1f519
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/remote_scripts/Environments/requirements.txt
@@ -0,0 +1 @@
+ansible \ No newline at end of file
diff --git a/ms/command-executor/src/main/python/command_executor_handler.py b/ms/command-executor/src/main/python/command_executor_handler.py
index 9eb36fb2d..1fb3e2679 100644
--- a/ms/command-executor/src/main/python/command_executor_handler.py
+++ b/ms/command-executor/src/main/python/command_executor_handler.py
@@ -24,6 +24,8 @@ import venv
import utils
import proto.CommandExecutor_pb2 as CommandExecutor_pb2
+REQUIREMENTS_TXT = "requirements.txt"
+
class CommandExecutorHandler():
@@ -80,12 +82,12 @@ class CommandExecutorHandler():
for package in request.packages:
if package.type == type:
f.write("Installed %s packages:\r\n" % CommandExecutor_pb2.PackageType.Name(type))
- for python_package in package.package:
- f.write(" %s\r\n" % python_package)
+ for p in package.package:
+ f.write(" %s\r\n" % p)
if package.type == CommandExecutor_pb2.pip:
- success = self.install_python_packages(python_package, results)
+ success = self.install_python_packages(p, results)
else:
- success = self.install_ansible_packages(python_package, results)
+ success = self.install_ansible_packages(p, results)
if not success:
f.close()
os.remove(self.installed)
@@ -95,7 +97,11 @@ class CommandExecutorHandler():
def install_python_packages(self, package, results):
self.logger.info(
"{} - Install Python package({}) in Python Virtual Environment".format(self.blueprint_id, package))
- command = ["pip", "install", package]
+
+ if REQUIREMENTS_TXT == package:
+ command = ["pip", "install", "-r", self.venv_home + "/Environments/" + REQUIREMENTS_TXT]
+ else:
+ command = ["pip", "install", package]
env = dict(os.environ)
if "https_proxy" in os.environ: