Use Swift venv Python interpreter

The use of activate_this to access the venv libraries means that the
system site packages are also included when the scripts swift_rings.py
and swift_rings_check.py are run.

This commit updates the interpreter directive for those scripts, when
Swift is deployed in a venv, to use the venv's interpreter.

Change-Id: I3ff0bf60c9ca695cddc28b05a8e8cc67d5f240e5
Closes-bug: 1538993
This commit is contained in:
git-harry 2016-01-28 10:00:12 +00:00
parent 9004e12ec5
commit a82e4821fd
4 changed files with 10 additions and 24 deletions

View File

@ -51,7 +51,7 @@
- swift-rings-contents - swift-rings-contents
- name: "build rings for account/container from contents files" - name: "build rings for account/container from contents files"
command: "/usr/bin/python /etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/{{ item }}.contents" command: "/etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/{{ item }}.contents"
with_items: with_items:
- account - account
- container - container
@ -65,7 +65,7 @@
- swift-rings-build - swift-rings-build
- name: "build rings for account/container from contents files" - name: "build rings for account/container from contents files"
command: "/usr/bin/python /etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/{{ item[0] }}.contents -r {{ item[1] }}" command: "/etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/{{ item[0] }}.contents -r {{ item[1] }}"
with_nested: with_nested:
- [ 'account', 'container' ] - [ 'account', 'container' ]
- "{{ swift_managed_regions }}" - "{{ swift_managed_regions }}"
@ -79,7 +79,7 @@
- swift-rings-build - swift-rings-build
- name: "build rings for storage policies from contents files" - name: "build rings for storage policies from contents files"
command: "/usr/bin/python /etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/object-{{ item.policy.index }}.contents" command: "/etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/object-{{ item.policy.index }}.contents"
with_items: with_items:
- "{{ swift.storage_policies }}" - "{{ swift.storage_policies }}"
when: swift_managed_regions is not defined when: swift_managed_regions is not defined
@ -92,7 +92,7 @@
- swift-rings-build - swift-rings-build
- name: "build rings for storage policies from contents files" - name: "build rings for storage policies from contents files"
command: "/usr/bin/python /etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/object-{{ item[0].policy.index }}.contents -r {{ item[1] }}" command: "/etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/object-{{ item[0].policy.index }}.contents -r {{ item[1] }}"
with_nested: with_nested:
- "{{ swift.storage_policies }}" - "{{ swift.storage_policies }}"
- "{{ swift_managed_regions }}" - "{{ swift_managed_regions }}"

View File

@ -44,7 +44,7 @@
- swift-rings-scripts - swift-rings-scripts
- name: "Ensure contents file matches ring after ring sync for account/container" - name: "Ensure contents file matches ring after ring sync for account/container"
command: "/usr/bin/python /etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/{{ item }}.contents" command: "/etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/{{ item }}.contents"
with_items: with_items:
- account - account
- container - container
@ -58,7 +58,7 @@
- swift-rings-check - swift-rings-check
- name: "Ensure contents file matches ring after ring sync for account/container" - name: "Ensure contents file matches ring after ring sync for account/container"
command: "/usr/bin/python /etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/{{ item[0] }}.contents -r {{ item[1] }}" command: "/etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/{{ item[0] }}.contents -r {{ item[1] }}"
with_nested: with_nested:
- [ 'account', 'container' ] - [ 'account', 'container' ]
- "{{ swift_managed_regions }}" - "{{ swift_managed_regions }}"
@ -72,7 +72,7 @@
- swift-rings-check - swift-rings-check
- name: "Ensure contents file matches ring after ring sync for storage policies" - name: "Ensure contents file matches ring after ring sync for storage policies"
command: "/usr/bin/python /etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/object-{{ item.policy.index }}.contents" command: "/etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/object-{{ item.policy.index }}.contents"
with_items: with_items:
- "{{ swift.storage_policies }}" - "{{ swift.storage_policies }}"
when: swift_managed_regions is not defined when: swift_managed_regions is not defined
@ -85,7 +85,7 @@
- swift-rings-check - swift-rings-check
- name: "Ensure contents file matches ring after ring sync for storage policies" - name: "Ensure contents file matches ring after ring sync for storage policies"
command: "/usr/bin/python /etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/object-{{ item[0].policy.index }}.contents -r {{ item[1] }}" command: "/etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/object-{{ item[0].policy.index }}.contents -r {{ item[1] }}"
with_nested: with_nested:
- "{{ swift.storage_policies }}" - "{{ swift.storage_policies }}"
- "{{ swift_managed_regions }}" - "{{ swift_managed_regions }}"

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!{{ swift_venv_enabled | bool | ternary(swift_venv_bin + "/", "/usr/bin/env ") }}python
# Copyright 2014, Rackspace US, Inc. # Copyright 2014, Rackspace US, Inc.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -19,13 +19,6 @@ from os.path import exists
import os import os
{% if swift_venv_enabled | bool %}
activate_this = os.path.expanduser("{{ swift_venv_bin }}/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))
{% endif %}
from swift.cli.ringbuilder import main as rb_main from swift.cli.ringbuilder import main as rb_main
import json import json

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!{{ swift_venv_enabled | bool | ternary(swift_venv_bin + "/", "/usr/bin/env ") }}python
# Copyright 2014, Rackspace US, Inc. # Copyright 2014, Rackspace US, Inc.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -19,13 +19,6 @@ from os.path import exists
import os import os
{% if swift_venv_enabled | bool %}
activate_this = os.path.expanduser("{{ swift_venv_bin }}/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))
{% endif %}
import json import json
import pickle import pickle
import sys import sys