summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexis de Talhouët <adetalhouet89@gmail.com>2019-04-19 09:31:54 -0400
committerAlexis de Talhouët <adetalhouet89@gmail.com>2019-04-22 14:23:12 +0000
commit03b4f1fb8136f12f9f7c80ee6dff771384916b7e (patch)
treea62ffc40b50f537c8250b27cc5f8285050070376
parentf6c08adeb3ec6af94fc75eb4e8f0853ce5f38c97 (diff)
Add support for requirements.txt for pip deps
Change-Id: I10bbe95a4d06ce9361d3ab6553953022e1196a3d Issue-ID: CCCSDK-125 Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
-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: