From 3d06aeabbf58b20bd5b034f35cd00e686945db5a Mon Sep 17 00:00:00 2001 From: Jens Rosenboom Date: Wed, 8 Feb 2017 14:37:04 +0000 Subject: [PATCH] Install openstackclient into virtualenv There may be issues caused by updated OpenStack python libraries being picked up by other services when we install python-openstackclient globally. So instead install it into its own virtualenv and create a symlink to the resulting binary. Change-Id: I43d9baf13dda20d39d3c52faf1f2322eee4884a3 Partial-Bug: 1661708 --- recipes/client.rb | 10 ++++++++++ spec/client_spec.rb | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/recipes/client.rb b/recipes/client.rb index 9662ccea..e61a326d 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -4,6 +4,7 @@ # Recipe:: client # # Copyright 2014, IBM Corp. +# Copyright 2017, cloudbau GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,6 +21,15 @@ python_runtime '2' +python_virtualenv '/opt/osc' do + system_site_packages true +end + python_package 'python-openstackclient' do version node['openstack']['common']['client_version'] + virtualenv '/opt/osc' +end + +link '/usr/local/bin/openstack' do + to '/opt/osc/bin/openstack' end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index a2d31dd9..49ca1288 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -13,9 +13,19 @@ describe 'openstack-common::client' do expect(chef_run).to install_python_runtime('2') end + it do + expect(chef_run).to create_python_virtualenv('/opt/osc') + .with(system_site_packages: true) + end + it do expect(chef_run).to install_python_package('python-openstackclient') .with(version: '3.6.0') end + + it do + expect(chef_run).to create_link('/usr/local/bin/openstack') + .with(to: '/opt/osc/bin/openstack') + end end end