From 34bdc7df903b86e1e3bf6c836642de745274c3ef Mon Sep 17 00:00:00 2001 From: Anshul Jain Date: Thu, 13 Oct 2016 08:52:10 +0000 Subject: [PATCH] DIB element to support cinder local attach/detach functionality This element adds python-brick-cinderclient-ext to the make customized image to support cinder local attach/detach functionality. Currently it has the dependency on known bug, which would be resolved with next release of python-brick-cinderclient-ext. Change-Id: Idfe83bafa2843c781c18b83f1a3aece3ae852f78 --- elements/python-brickclient/README.rst | 34 +++++++++++++++++++ elements/python-brickclient/element-deps | 2 ++ .../python-brickclient/package-installs.yaml | 3 ++ elements/python-brickclient/pkg-map | 14 ++++++++ .../post-install.d/55-brick-client-install | 33 ++++++++++++++++++ 5 files changed, 86 insertions(+) create mode 100644 elements/python-brickclient/README.rst create mode 100644 elements/python-brickclient/element-deps create mode 100644 elements/python-brickclient/package-installs.yaml create mode 100644 elements/python-brickclient/pkg-map create mode 100755 elements/python-brickclient/post-install.d/55-brick-client-install diff --git a/elements/python-brickclient/README.rst b/elements/python-brickclient/README.rst new file mode 100644 index 000000000..24612815d --- /dev/null +++ b/elements/python-brickclient/README.rst @@ -0,0 +1,34 @@ +python-brickclient +================== + +* This element is aimed for providing cinder local attach/detach functionality. +* Currently the feature has a dependency on a known bug + "https://launchpad.net/bugs/1623549", which has been resolved and will be part + of the upstream with the next release of python-brick-cinderclient-ext. + Note: Current version of python-brick-cinderclient-ext i.e. 0.2.0 requires and update + to be made in Line32 fo below script. + /usr/share/python-brickclient/venv/lib/python2.7/site-packages/brick_cinderclient_ext/__init__.py + update "brick-python-cinderclient-ext" to "python-brick-cinderclient-ext". + +* Usage: + Pass the below shell script to parameter 'user-data' and set 'config-drive=true' + at the time of provisioning the node via nova-boot to make cinder local + attach/detach commands talk to your cloud controller. + [Example of Config Drive Script] + #!/bin/bash + FILE="/etc/bash.bashrc" + [ ! -f "$FILE" ] && touch "$FILE" + echo 'export OS_AUTH_URL="http://:5000/v2.0"' >> "$FILE" + echo 'export OS_PASSWORD="password"' >> "$FILE" + echo 'export OS_USERNAME="demo"' >> "$FILE" + echo 'export OS_TENANT_NAME="demo"' >> "$FILE" + echo 'export OS_PROJECT_NAME="demo"' >> "$FILE" + exec bash + To attach: /usr/share/python-brickclient/venv/bin/cinder local-attach + To detach: /usr/share/python-brickclient/venv/bin/cinder local-detach + +* Alternatively, the same action can be completed manually at the node which does + not require setting up of config drive such as: + /usr/share/python-brickclient/venv/bin/cinder --os-username demo --os-password \ + password --os-tenant-name demo --os-project-name demo \ + --os-auth-url=http://:5000/v2.0 local-attach diff --git a/elements/python-brickclient/element-deps b/elements/python-brickclient/element-deps new file mode 100644 index 000000000..d397eed2a --- /dev/null +++ b/elements/python-brickclient/element-deps @@ -0,0 +1,2 @@ +package-installs +pip-and-virtualenv diff --git a/elements/python-brickclient/package-installs.yaml b/elements/python-brickclient/package-installs.yaml new file mode 100644 index 000000000..7e371d23e --- /dev/null +++ b/elements/python-brickclient/package-installs.yaml @@ -0,0 +1,3 @@ +libssl-dev: +libffi-dev: +python-dev: diff --git a/elements/python-brickclient/pkg-map b/elements/python-brickclient/pkg-map new file mode 100644 index 000000000..9f9058e19 --- /dev/null +++ b/elements/python-brickclient/pkg-map @@ -0,0 +1,14 @@ +{ + "family": { + "redhat": { + "python-dev": "python2-devel", + "libssl-dev": "openssl-devel", + "libffi-dev": "libffi-devel" + } + }, + "default": { + "python-dev": "python-dev", + "libssl-dev": "libssl-dev", + "libffi-dev": "libffi-dev" + } +} diff --git a/elements/python-brickclient/post-install.d/55-brick-client-install b/elements/python-brickclient/post-install.d/55-brick-client-install new file mode 100755 index 000000000..8e8a19fc6 --- /dev/null +++ b/elements/python-brickclient/post-install.d/55-brick-client-install @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Copyright 2016 Hewlett Packard Enterprise Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then + set -x +fi + +set -eu +set -o pipefail + +PBCDIR=/usr/share/python-brickclient +mkdir $PBCDIR + +# create the virtual environment +virtualenv $PBCDIR/venv + +# Install the required packages inside virtual env +$PBCDIR/venv/bin/pip install python-brick-cinderclient-ext + +ln -s $PBCDIR/venv/bin/python-brickclient /usr/local/bin/python-brickclient