Wie konfiguriere ich den OpenStack Client (OSC)

OpenStack Client (auch bekannt als OSC) ist ein Befehlszeilen-Client für OpenStack, der den Befehlssatz für Compute, Identity, Image, Object Storage und Block Storage APIs in einer einzigen Shell mit einer einheitlichen Befehlsstruktur zusammenführt.

In diesem Kapitel wird beschrieben, wie der OCS installiert und konfiguriert wird.

Voraussetzungen

  • Grundkenntnisse des Linux Betriebssystems (shell)
  • Zugriff auf laufende Linux-VM (In unserem Beispiel Ubuntu) mit geöffnetem Port (Egress 443) zum OpenStack API
  • Application Credentials (cloud.yaml)

Die Auszuführenden Schritte sind:

  • Installation python-openstackclient und python-keystoneclient packages
  • Konfiguration der Authentication (Application Credentials)

Bemerkung

Wir empfehlen python venv or/and pyenv. Python Version 3.5.6 ist aus eigener Erfahrung aktuell am besten geeignet.

Steps:

1) install pyenv

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bashrc
exec "$SHELL"

2.) install python 3.5.x version into pyenv

sudo apt update
sudo apt install build-essential libbz2-dev libreadline-dev libssl-dev zlib1g-dev libsqlite3-dev wget curl libncurses5-dev libncursesw5-dev xz-utils libffi-dev liblzma-dev
pyenv install 3.5.6 # takes a couple of minutes
echo '3.5.6' > ~/.python-version
# you can use virtualenv from within pyenv as well...

3.) install all openstack clients

cd ~/  # this is important to guarantee the pyenv installed python 3.5.6 is used
pip install -U pip
pip install -U \
 gnocchiclient \
 "pankoclient<0.6.0" \
 "python-barbicanclient<4.8.0" \
 "python-cinderclient<4.0.1" \
 python-cloudkittyclient \
 "python-glanceclient<2.14.0" \
 "python-heatclient<1.17.0" \
 "python-keystoneclient<3.18.0" \
 "python-magnumclient<2.11.0" \
 "python-mistralclient<3.8.0" \
 "python-neutronclient<6.10.0" \
 "python-novaclient<11.1.0" \
 "python-octaviaclient<1.7.0" \
 "python-openstackclient<3.18.0" \
 "python-swiftclient<3.7.0"

Tipp

Um die neuesten Port Forwarding Features im Python OpenStack Client nutzen zu können müssen Sie auch das folgende Packet installieren:

#Install customized python_openstack client with port forwarding support
pip install https://s3.ewstorage.ch/pub/python_openstackclient-3.19.1.dev82-py2.py3-none-any.whl

4.) extend bash_completion

openstack complete | sudo tee /etc/bash_completion.d/osc.bash_completion > /dev/null
. /etc/bash_completion

5.) Configure Application Credentials

mkdir -p ~/.config/openstack

# Paste your clouds.yaml file content or copy it to
vim ~/.config/openstack/clouds.yaml

# Define default connection
export OS_CLOUD=openstack

Bemerkung

OS_CLOUD=openstack bezieht sich auf den Konfigurationsblock in Ihrer Datei clouds.yaml, wobei Sie auch mehrere Blöcke haben können! Falls Sie die Variable OS_CLOUD nicht exportieren, können Sie auch in der Command Line den Cloud Konfigurationsblock mitgeben. Zum Beispiel openstack –os-cloud=openstack image list

Beispiel: clouds.yaml

6.) Test the configuration and connectivity

openstack image list
+--------------------------------------+----------------------------------------+--------+
| ID                                   | Name                                   | Status |
+--------------------------------------+----------------------------------------+--------+
| 09f60296-b845-4385-9adf-be9281866257 | CentOS 7.6                             | active |
| dfaa74e1-6e3a-4ec6-b2f7-5aadfc65761e | CirrOS 0.4.0                           | active |
| 62303abb-bcd3-4604-aedb-e282f1eef863 | Red Hat Enterprise Linux 7             | active |
| 6cbf2896-db07-4936-af5b-a0ed4b349f2b | Ubuntu 16.04                           | active |
| ddd20f25-ec89-44cf-aa01-8a8fd181c95f | Ubuntu 18.04                           | active |
| 406de35a-8473-4b43-9fc7-0d90fa153351 | Windows Server 2016                    | active |
| ffb46e0f-0445-4ffa-aec2-3d4f128e2f9d | Windows Server 2019                    | active |
| ac55797f-25a5-4eed-be4f-19dc4be21adf | snap-hle-u1804                         | active |
| 782c4208-36a8-4630-a792-839533c512bf | snap-hle-u1804                         | active |
| 2c087d07-1428-4ace-a67b-d7e10159a02b | snap-vm-win2019-nodisk                 | active |
| bc3a6538-e552-4d20-8f4a-5e43e503b30b | snap-vm1-win2019-m-flavor              | active |
| 4d601262-85b1-4a3f-9b0e-67ad88fb9e12 | snap-vm2-win2019-s-flavor-cneb         | active |
| fe00c862-3b91-4c5b-b449-eaa6f2fcbe66 | snap-vm3-win2016-s-flavor-cnx15k-600GB | active |
| c25babcf-5712-446f-a669-5e41638105a8 | snap-vm4-win2019-s-flavor-cn2k-200GB   | active |
| 1b5cc4b6-d730-4e40-88a5-d44eccf6eb37 | snap-vm5-win2019-m-flavor              | active |
| b711eb35-c6c1-42ae-a506-c3f66ca6e938 | snap2-vm4-win2019-s-flavor-cn2k-200GB  | active |
+--------------------------------------+----------------------------------------+--------+

Herzlichen Glückwunsch, Ihr OpenStack-Client funktioniert!

Weitere Informationen zu den verfügbaren Befehlen finden Sie auf den folgenden Internetseite: OpenStackClient User Manual