Mac で OpenStack コマンドラインクライアントを使う

Mac で OpenStack クライアントをインストールして使おうとしたら色々とハマったのでメモ。

■ 概要

Mac で OpenStack コマンドラインクライアントを使い、OpenStackを操作する。

MacVMware Fusion で動作している CentOS 仮想マシン上で動作している OpenStack へ、Mac のターミナルから OpenStack クライアントを用いてAPIを叩けるようにする。

環境:
 Mac OS X El Captitan 10.11.6
 VMware Fusion 8 (Mac上で動作)
 CentOS 7 (VMware上で動作)
 OpenStack Mitaka (CentOS上で動作)

※最終的にはクライアント使えるようになったが、よくわからないまま色々試したらできたという感じなので、あまり参考にならないかもしれない。

■ OpenStack コマンドラインクライアントのインストール

OpenStack Docs を参考にする

OpenStackクライアントのインストール方法は、基本的にはOpenStack Docsのここを参考に進める。

Docs の書いてある通りにいけば、Macの場合は

# easy_install pip

を実行して、

# pip install python-openstackclient

でインストール完了となる簡単なもの。

だが、実際はそう甘くはなかった。

なぜかOpenStack Docs の通りにはインストールができない

まずは easy_install pip をやってみる。

# easy_install pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 9.0.0
Downloading https://pypi.python.org/packages/5e/53/eaef47e5e2f75677c9de0737acc84b659b78a71c4086f424f55346a341b5/pip-9.0.0.tar.gz#md5=def0a8e3db26f896c128d063591bd008
Processing pip-9.0.0.tar.gz
Writing /tmp/easy_install-e8Eela/pip-9.0.0/setup.cfg
Running pip-9.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-e8Eela/pip-9.0.0/egg-dist-tmp-JFSa7W
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.landscape.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
warning: no previously-included files found matching 'appveyor.yml'
no previously-included directories found matching '.github'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
  File "build/bdist.macosx-10.11-intel/egg/pip/_vendor/html5lib/treewalkers/etree.py", line 13
    from pip._vendor. import string_types
                           ^
SyntaxError: invalid syntax

  File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/_vendor/html5lib/treewalkers/etree.py", line 13
    from pip._vendor. import string_types
                           ^
SyntaxError: invalid syntax

Adding pip 9.0.0 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
# 

……SyntaxError が出ているが、よく分からないのでとりあえず無視。

次に openstack クライアントをインストール。

# pip install python-openstackclient
Collecting python-openstackclient
  Downloading python_openstackclient-3.3.0-py2.py3-none-any.whl (600kB)
    100% |################################| 604kB 203kB/s 
Collecting pbr>=1.6 (from python-openstackclient)
  Downloading pbr-1.10.0-py2.py3-none-any.whl (96kB)
    100% |################################| 102kB 117kB/s 
Collecting keystoneauth1>=2.10.0 (from python-openstackclient)
  Downloading keystoneauth1-2.15.0-py2.py3-none-any.whl (235kB)
    100% |################################| 235kB 68kB/s 
Collecting Babel>=2.3.4 (from python-openstackclient)
  Downloading Babel-2.3.4-py2.py3-none-any.whl (7.1MB)
    100% |################################| 7.1MB 76kB/s 
Collecting python-keystoneclient!=2.1.0,>=2.0.0 (from python-openstackclient)
  Downloading python_keystoneclient-3.6.0-py2.py3-none-any.whl (368kB)
    100% |################################| 368kB 97kB/s 
Collecting python-novaclient!=2.33.0,>=2.29.0 (from python-openstackclient)
  Downloading python_novaclient-6.0.0-py2.py3-none-any.whl (359kB)
    100% |################################| 368kB 179kB/s 
Collecting python-glanceclient>=2.5.0 (from python-openstackclient)
  Downloading python_glanceclient-2.5.0-py2.py3-none-any.whl (175kB)
    100% |################################| 184kB 186kB/s 
Collecting python-cinderclient!=1.7.0,!=1.7.1,>=1.6.0 (from python-openstackclient)
  Downloading python_cinderclient-1.9.0-py2.py3-none-any.whl (295kB)
    100% |################################| 296kB 112kB/s 
Collecting osc-lib>=1.0.2 (from python-openstackclient)
  Downloading osc_lib-1.2.0-py2-none-any.whl (66kB)
    100% |################################| 71kB 92kB/s 
Collecting six>=1.9.0 (from python-openstackclient)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting oslo.utils>=3.16.0 (from python-openstackclient)
  Downloading oslo.utils-3.18.0-py2.py3-none-any.whl (96kB)
    100% |################################| 102kB 100kB/s 
Collecting oslo.i18n>=2.1.0 (from python-openstackclient)
  Downloading oslo.i18n-3.10.0-py2.py3-none-any.whl (41kB)
    100% |################################| 51kB 104kB/s 
Collecting openstacksdk>=0.9.7 (from python-openstackclient)
  Downloading openstacksdk-0.9.9-py2.py3-none-any.whl (522kB)
    100% |################################| 532kB 172kB/s 
Collecting cliff>=2.2.0 (from python-openstackclient)
  Downloading cliff-2.2.0-py2-none-any.whl (44kB)
    100% |################################| 51kB 110kB/s 
Collecting stevedore>=1.17.1 (from keystoneauth1>=2.10.0->python-openstackclient)
  Downloading stevedore-1.18.0-py2.py3-none-any.whl
Collecting requests>=2.10.0 (from keystoneauth1>=2.10.0->python-openstackclient)
  Downloading requests-2.11.1-py2.py3-none-any.whl (514kB)
    100% |################################| 522kB 135kB/s 
Collecting positional>=1.1.1 (from keystoneauth1>=2.10.0->python-openstackclient)
  Downloading positional-1.1.1.tar.gz
Collecting iso8601>=0.1.11 (from keystoneauth1>=2.10.0->python-openstackclient)
  Downloading iso8601-0.1.11-py2.py3-none-any.whl
Requirement already satisfied: pytz>=0a in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from Babel>=2.3.4->python-openstackclient)
Collecting oslo.serialization>=1.10.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient)
  Downloading oslo.serialization-2.14.0-py2.py3-none-any.whl
Collecting debtcollector>=1.2.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient)
  Downloading debtcollector-1.9.0-py2.py3-none-any.whl
Collecting oslo.config>=3.14.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient)
  Downloading oslo.config-3.19.0-py2.py3-none-any.whl (99kB)
    100% |################################| 102kB 147kB/s 
Collecting simplejson>=2.2.0 (from python-novaclient!=2.33.0,>=2.29.0->python-openstackclient)
  Downloading simplejson-3.10.0.tar.gz (77kB)
    100% |################################| 81kB 133kB/s 
Collecting PrettyTable<0.8,>=0.7 (from python-novaclient!=2.33.0,>=2.29.0->python-openstackclient)
  Downloading prettytable-0.7.2.zip
Collecting warlock!=1.3.0,<2,>=1.0.1 (from python-glanceclient>=2.5.0->python-openstackclient)
  Downloading warlock-1.2.0.tar.gz
Collecting os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1 (from osc-lib>=1.0.2->python-openstackclient)
  Downloading os_client_config-1.22.0-py2.py3-none-any.whl (59kB)
    100% |################################| 61kB 164kB/s 
Requirement already satisfied: pyparsing>=2.0.1 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from oslo.utils>=3.16.0->python-openstackclient)
Collecting funcsigs>=0.4; python_version == "2.7" or python_version == "2.6" (from oslo.utils>=3.16.0->python-openstackclient)
  Downloading funcsigs-1.0.2-py2.py3-none-any.whl
Collecting netifaces>=0.10.4 (from oslo.utils>=3.16.0->python-openstackclient)
  Downloading netifaces-0.10.5.tar.gz
Collecting netaddr!=0.7.16,>=0.7.13 (from oslo.utils>=3.16.0->python-openstackclient)
  Downloading netaddr-0.7.18-py2.py3-none-any.whl (1.5MB)
    100% |################################| 1.5MB 123kB/s 
Collecting monotonic>=0.6 (from oslo.utils>=3.16.0->python-openstackclient)
  Downloading monotonic-1.2-py2.py3-none-any.whl
Collecting PyYAML>=3.1.0 (from cliff>=2.2.0->python-openstackclient)
  Downloading PyYAML-3.12.tar.gz (253kB)
    100% |################################| 256kB 143kB/s 
Collecting unicodecsv>=0.8.0; python_version < "3.0" (from cliff>=2.2.0->python-openstackclient)
  Downloading unicodecsv-0.14.1.tar.gz
Collecting cmd2>=0.6.7 (from cliff>=2.2.0->python-openstackclient)
  Downloading cmd2-0.6.9.tar.gz (367kB)
    100% |################################| 368kB 120kB/s 
Collecting wrapt (from positional>=1.1.1->keystoneauth1>=2.10.0->python-openstackclient)
  Downloading wrapt-1.10.8.tar.gz
Collecting msgpack-python>=0.4.0 (from oslo.serialization>=1.10.0->python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient)
  Downloading msgpack-python-0.4.8.tar.gz (113kB)
    100% |################################| 122kB 110kB/s 
Collecting rfc3986>=0.2.2 (from oslo.config>=3.14.0->python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient)
  Downloading rfc3986-0.4.1-py2.py3-none-any.whl
Collecting jsonschema<3,>=0.7 (from warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient)
  Downloading jsonschema-2.5.1-py2.py3-none-any.whl
Collecting jsonpatch<2,>=0.10 (from warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient)
  Downloading jsonpatch-1.14-py2.py3-none-any.whl
Collecting requestsexceptions>=1.1.1 (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->osc-lib>=1.0.2->python-openstackclient)
  Downloading requestsexceptions-1.1.3-py2.py3-none-any.whl
Collecting appdirs>=1.3.0 (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->osc-lib>=1.0.2->python-openstackclient)
  Downloading appdirs-1.4.0-py2.py3-none-any.whl
Collecting functools32; python_version == "2.7" (from jsonschema<3,>=0.7->warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient)
  Downloading functools32-3.2.3-2.zip
Collecting jsonpointer>=1.9 (from jsonpatch<2,>=0.10->warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient)
  Downloading jsonpointer-1.10-py2-none-any.whl
Installing collected packages: pbr, six, stevedore, requests, wrapt, positional, iso8601, keystoneauth1, Babel, funcsigs, netifaces, netaddr, debtcollector, monotonic, oslo.i18n, oslo.utils, msgpack-python, oslo.serialization, rfc3986, oslo.config, python-keystoneclient, simplejson, PrettyTable, python-novaclient, functools32, jsonschema, jsonpointer, jsonpatch, warlock, python-glanceclient, python-cinderclient, requestsexceptions, PyYAML, appdirs, os-client-config, unicodecsv, cmd2, cliff, osc-lib, openstacksdk, python-openstackclient
  Found existing installation: six 1.4.1
    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/req/req_install.py", line 752, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-9.0.0-py2.7.egg/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-ufqDGr-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
 

エラーでインストールに失敗した。

OSError: [Errno 1] Operation not permitted: '/tmp/pip-ufqDGr-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info

どうやら six とかいうのが原因らしい(何がどう問題なのか理解していない)。

暫定対処でのインストール

色々ググったところ、sixをとりあえず無視してopenstackclientをインストールすればよさそうだと分かった。
以下でリトライする。

# pip install python-openstackclient --upgrade --ignore-installed six

# pip install python-openstackclient --upgrade --ignore-installed six
Collecting python-openstackclient
  Using cached python_openstackclient-3.3.0-py2.py3-none-any.whl
Collecting six
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting pbr>=1.6 (from python-openstackclient)
  Using cached pbr-1.10.0-py2.py3-none-any.whl
Collecting keystoneauth1>=2.10.0 (from python-openstackclient)
  Using cached keystoneauth1-2.15.0-py2.py3-none-any.whl
Collecting Babel>=2.3.4 (from python-openstackclient)
  Using cached Babel-2.3.4-py2.py3-none-any.whl
Collecting python-keystoneclient!=2.1.0,>=2.0.0 (from python-openstackclient)
  Using cached python_keystoneclient-3.6.0-py2.py3-none-any.whl
Collecting python-novaclient!=2.33.0,>=2.29.0 (from python-openstackclient)
  Using cached python_novaclient-6.0.0-py2.py3-none-any.whl
Collecting python-glanceclient>=2.5.0 (from python-openstackclient)
  Using cached python_glanceclient-2.5.0-py2.py3-none-any.whl
Collecting python-cinderclient!=1.7.0,!=1.7.1,>=1.6.0 (from python-openstackclient)
  Using cached python_cinderclient-1.9.0-py2.py3-none-any.whl
Collecting osc-lib>=1.0.2 (from python-openstackclient)
  Using cached osc_lib-1.2.0-py2-none-any.whl
Collecting oslo.utils>=3.16.0 (from python-openstackclient)
  Using cached oslo.utils-3.18.0-py2.py3-none-any.whl
Collecting oslo.i18n>=2.1.0 (from python-openstackclient)
  Using cached oslo.i18n-3.10.0-py2.py3-none-any.whl
Collecting openstacksdk>=0.9.7 (from python-openstackclient)
  Using cached openstacksdk-0.9.9-py2.py3-none-any.whl
Collecting cliff>=2.2.0 (from python-openstackclient)
  Using cached cliff-2.2.0-py2-none-any.whl
Collecting stevedore>=1.17.1 (from keystoneauth1>=2.10.0->python-openstackclient)
  Using cached stevedore-1.18.0-py2.py3-none-any.whl
Collecting requests>=2.10.0 (from keystoneauth1>=2.10.0->python-openstackclient)
  Using cached requests-2.11.1-py2.py3-none-any.whl
Collecting positional>=1.1.1 (from keystoneauth1>=2.10.0->python-openstackclient)
  Using cached positional-1.1.1.tar.gz
Collecting iso8601>=0.1.11 (from keystoneauth1>=2.10.0->python-openstackclient)
  Using cached iso8601-0.1.11-py2.py3-none-any.whl
Collecting pytz>=0a (from Babel>=2.3.4->python-openstackclient)
  Downloading pytz-2016.7-py2.py3-none-any.whl (480kB)
    100% |################################| 481kB 147kB/s 
Collecting oslo.serialization>=1.10.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient)
  Using cached oslo.serialization-2.14.0-py2.py3-none-any.whl
Collecting debtcollector>=1.2.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient)
  Using cached debtcollector-1.9.0-py2.py3-none-any.whl
Collecting oslo.config>=3.14.0 (from python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient)
  Using cached oslo.config-3.19.0-py2.py3-none-any.whl
Collecting simplejson>=2.2.0 (from python-novaclient!=2.33.0,>=2.29.0->python-openstackclient)
  Using cached simplejson-3.10.0.tar.gz
Collecting PrettyTable<0.8,>=0.7 (from python-novaclient!=2.33.0,>=2.29.0->python-openstackclient)
  Using cached prettytable-0.7.2.zip
Collecting warlock!=1.3.0,<2,>=1.0.1 (from python-glanceclient>=2.5.0->python-openstackclient)
  Using cached warlock-1.2.0.tar.gz
Collecting os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1 (from osc-lib>=1.0.2->python-openstackclient)
  Using cached os_client_config-1.22.0-py2.py3-none-any.whl
Collecting pyparsing>=2.0.1 (from oslo.utils>=3.16.0->python-openstackclient)
  Downloading pyparsing-2.1.10-py2.py3-none-any.whl (56kB)
    100% |################################| 61kB 184kB/s 
Collecting funcsigs>=0.4; python_version == "2.7" or python_version == "2.6" (from oslo.utils>=3.16.0->python-openstackclient)
  Using cached funcsigs-1.0.2-py2.py3-none-any.whl
Collecting netifaces>=0.10.4 (from oslo.utils>=3.16.0->python-openstackclient)
  Using cached netifaces-0.10.5.tar.gz
Collecting netaddr!=0.7.16,>=0.7.13 (from oslo.utils>=3.16.0->python-openstackclient)
  Using cached netaddr-0.7.18-py2.py3-none-any.whl
Collecting monotonic>=0.6 (from oslo.utils>=3.16.0->python-openstackclient)
  Using cached monotonic-1.2-py2.py3-none-any.whl
Collecting PyYAML>=3.1.0 (from cliff>=2.2.0->python-openstackclient)
  Using cached PyYAML-3.12.tar.gz
Collecting unicodecsv>=0.8.0; python_version < "3.0" (from cliff>=2.2.0->python-openstackclient)
  Using cached unicodecsv-0.14.1.tar.gz
Collecting cmd2>=0.6.7 (from cliff>=2.2.0->python-openstackclient)
  Using cached cmd2-0.6.9.tar.gz
Collecting wrapt (from positional>=1.1.1->keystoneauth1>=2.10.0->python-openstackclient)
  Using cached wrapt-1.10.8.tar.gz
Collecting msgpack-python>=0.4.0 (from oslo.serialization>=1.10.0->python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient)
  Using cached msgpack-python-0.4.8.tar.gz
Collecting rfc3986>=0.2.2 (from oslo.config>=3.14.0->python-keystoneclient!=2.1.0,>=2.0.0->python-openstackclient)
  Using cached rfc3986-0.4.1-py2.py3-none-any.whl
Collecting jsonschema<3,>=0.7 (from warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient)
  Using cached jsonschema-2.5.1-py2.py3-none-any.whl
Collecting jsonpatch<2,>=0.10 (from warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient)
  Using cached jsonpatch-1.14-py2.py3-none-any.whl
Collecting requestsexceptions>=1.1.1 (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->osc-lib>=1.0.2->python-openstackclient)
  Using cached requestsexceptions-1.1.3-py2.py3-none-any.whl
Collecting appdirs>=1.3.0 (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->osc-lib>=1.0.2->python-openstackclient)
  Using cached appdirs-1.4.0-py2.py3-none-any.whl
Collecting functools32; python_version == "2.7" (from jsonschema<3,>=0.7->warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient)
  Using cached functools32-3.2.3-2.zip
Collecting jsonpointer>=1.9 (from jsonpatch<2,>=0.10->warlock!=1.3.0,<2,>=1.0.1->python-glanceclient>=2.5.0->python-openstackclient)
  Using cached jsonpointer-1.10-py2-none-any.whl
Installing collected packages: pbr, six, stevedore, requests, wrapt, positional, iso8601, keystoneauth1, pytz, Babel, pyparsing, funcsigs, netifaces, netaddr, debtcollector, monotonic, oslo.i18n, oslo.utils, msgpack-python, oslo.serialization, rfc3986, oslo.config, python-keystoneclient, simplejson, PrettyTable, python-novaclient, functools32, jsonschema, jsonpointer, jsonpatch, warlock, python-glanceclient, python-cinderclient, requestsexceptions, PyYAML, appdirs, os-client-config, unicodecsv, cmd2, cliff, osc-lib, openstacksdk, python-openstackclient
  Running setup.py install for wrapt ... done
  Running setup.py install for positional ... done
  Running setup.py install for netifaces ... done
  Running setup.py install for msgpack-python ... done
  Running setup.py install for simplejson ... done
  Running setup.py install for PrettyTable ... done
  Running setup.py install for functools32 ... done
  Running setup.py install for warlock ... done
  Running setup.py install for PyYAML ... done
  Running setup.py install for unicodecsv ... done
  Running setup.py install for cmd2 ... done
Successfully installed Babel-2.3.4 PrettyTable-0.7.2 PyYAML-3.12 appdirs-1.4.0 cliff-2.2.0 cmd2-0.6.9 debtcollector-1.9.0 funcsigs-1.0.2 functools32-3.2.3.post2 iso8601-0.1.11 jsonpatch-1.14 jsonpointer-1.10 jsonschema-2.5.1 keystoneauth1-2.15.0 monotonic-1.2 msgpack-python-0.4.8 netaddr-0.7.18 netifaces-0.10.5 openstacksdk-0.9.9 os-client-config-1.22.0 osc-lib-1.2.0 oslo.config-3.19.0 oslo.i18n-3.10.0 oslo.serialization-2.14.0 oslo.utils-3.18.0 pbr-1.10.0 positional-1.1.1 pyparsing-2.1.10 python-cinderclient-1.9.0 python-glanceclient-2.5.0 python-keystoneclient-3.6.0 python-novaclient-6.0.0 python-openstackclient-3.3.0 pytz-2016.7 requests-2.11.1 requestsexceptions-1.1.3 rfc3986-0.4.1 simplejson-3.10.0 six-1.10.0 stevedore-1.18.0 unicodecsv-0.14.1 warlock-1.2.0 wrapt-1.10.8
# 

インストールできたようにみえる。
本当に使えるようになったか試してみる。そのために環境変数の設定をする。

APIアクセスするための環境変数の設定

OpenStack クライアントでAPIを叩くためには、環境変数の設定が必要となる。
その手順はこのDocsに記載されている。

ダッシュボードにアクセスして、rc.shファイルをダウンロードする。
f:id:nashikachi:20161106222821j:plain
画像では、OpenStack RC v2.0 と OpenStack RC v3 の2つがあるが、今回はとりあえずv3を選んだ。

"プロジェクト名-openrc.sh"という名前のファイルをダウンロードしたら、スクリプトを実行する。
ここで求められるパスワードは、対象のOpenStackユーザのパスワード。

# source /tmp/Test1-openrc.sh 
Please enter your OpenStack Password: 
# 

これで環境変数の設定は完了。

コマンドラインツールを試してみる

いよいよコマンドラインツールで OpenStack の API を叩いてみる。
インスタンスは何も作っていないが、まずは nova list を実行してみる。空の表が表示されれば成功。

# nova list
Traceback (most recent call last):
  File "/usr/local/bin/nova", line 7, in <module>
    from novaclient.shell import main
  File "/Library/Python/2.7/site-packages/novaclient/shell.py", line 44, in <module>
    import novaclient.auth_plugin
  File "/Library/Python/2.7/site-packages/novaclient/auth_plugin.py", line 23, in <module>
    from novaclient import utils
  File "/Library/Python/2.7/site-packages/novaclient/utils.py", line 22, in <module>
    from oslo_serialization import jsonutils
  File "/Library/Python/2.7/site-packages/oslo_serialization/jsonutils.py", line 44, in <module>
    import six.moves.xmlrpc_client as xmlrpclib
ImportError: No module named xmlrpc_client
#

またもエラー発生……。
このエラーにもかなり苦戦した。
色々調べたところ、これも結局 six とかいうツール(?)が原因で発生しているらしい。

sixのバージョンアップ

結論を述べると、six を 1.10.0 にバージョンアップさせると解決した(元は 1.4.1 だった)。
このページを参考にして対処した。
よく分からないまま対処したため、six も 1.10.0 以降のバージョンが既にあったかもしれない。

まず、参考にしたページに書いてあるリンクから、six の 1.10.0 をダウンロード。
https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55

次に解凍してinstallを実行。

# tar -zxvf six-1.10.0.tar.gz 
x six-1.10.0/
x six-1.10.0/six.egg-info/
x six-1.10.0/six.egg-info/top_level.txt
x six-1.10.0/six.egg-info/SOURCES.txt
x six-1.10.0/six.egg-info/dependency_links.txt
x six-1.10.0/six.egg-info/PKG-INFO
x six-1.10.0/CHANGES
x six-1.10.0/six.py
x six-1.10.0/documentation/
x six-1.10.0/documentation/conf.py
x six-1.10.0/documentation/Makefile
x six-1.10.0/documentation/index.rst
x six-1.10.0/LICENSE
x six-1.10.0/README
x six-1.10.0/MANIFEST.in
x six-1.10.0/setup.cfg
x six-1.10.0/test_six.py
x six-1.10.0/PKG-INFO
x six-1.10.0/setup.py
#
# python ./six-1.10.0/setup.py install
Traceback (most recent call last):
  File "./six-1.10.0/setup.py", line 19, in <module>
    with open("README", "r") as fp:
IOError: [Errno 2] No such file or directory: 'README'
# 

しかしエラー。

ただ、これは実行時のディレクトリを変更すれば通った(実行時の相対パスの問題?)。

# cd ./six-1.10.0
# python ./setup.py install
running install
Checking .pth file support in /Library/Python/2.7/site-packages/
/usr/bin/python -E -c pass
TEST PASSED: /Library/Python/2.7/site-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing six.egg-info/PKG-INFO
writing top-level names to six.egg-info/top_level.txt
writing dependency_links to six.egg-info/dependency_links.txt
reading manifest file 'six.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'documentation/_build'
writing manifest file 'six.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.11-intel/egg
running install_lib
running build_py
creating build
creating build/lib
copying six.py -> build/lib
creating build/bdist.macosx-10.11-intel
creating build/bdist.macosx-10.11-intel/egg
copying build/lib/six.py -> build/bdist.macosx-10.11-intel/egg
byte-compiling build/bdist.macosx-10.11-intel/egg/six.py to six.pyc
creating build/bdist.macosx-10.11-intel/egg/EGG-INFO
copying six.egg-info/PKG-INFO -> build/bdist.macosx-10.11-intel/egg/EGG-INFO
copying six.egg-info/SOURCES.txt -> build/bdist.macosx-10.11-intel/egg/EGG-INFO
copying six.egg-info/dependency_links.txt -> build/bdist.macosx-10.11-intel/egg/EGG-INFO
copying six.egg-info/top_level.txt -> build/bdist.macosx-10.11-intel/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
six: module references __path__
creating dist
creating 'dist/six-1.10.0-py2.7.egg' and adding 'build/bdist.macosx-10.11-intel/egg' to it
removing 'build/bdist.macosx-10.11-intel/egg' (and everything under it)
Processing six-1.10.0-py2.7.egg
creating /Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg
Extracting six-1.10.0-py2.7.egg to /Library/Python/2.7/site-packages
Adding six 1.10.0 to easy-install.pth file

Installed /Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg
Processing dependencies for six==1.10.0
Finished processing dependencies for six==1.10.0
#

問題なくインストールできたようだ。

再びコマンドラインツールを試してみる

six をアップデートしたので、もう一度コマンドラインツールを試してみる。

# nova list
+----+------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+----+------+--------+------------+-------------+----------+
+----+------+--------+------------+-------------+----------+
#

ようやく成功!
インスタンスは作っていないので、空の表が表示された。

neutron のインストール

neutron も試してみる。
neutron は別途インストールしないといけないそうなので、インストールする。

# pip install python-neutronclient
Collecting python-neutronclient
  Downloading python_neutronclient-6.0.0-py2.py3-none-any.whl (287kB)
    100% |################################| 296kB 102kB/s 
Requirement already satisfied: os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: Babel>=2.3.4 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: keystoneauth1>=2.10.0 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: pbr>=1.6 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: simplejson>=2.2.0 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: netaddr!=0.7.16,>=0.7.12 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: debtcollector>=1.2.0 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: osc-lib>=1.0.2 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: requests>=2.10.0 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: six>=1.9.0 in /Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg (from python-neutronclient)
Requirement already satisfied: oslo.utils>=3.16.0 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: oslo.i18n>=2.1.0 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: oslo.serialization>=1.10.0 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: iso8601>=0.1.11 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: cliff!=1.16.0,!=1.17.0,>=1.15.0 in /Library/Python/2.7/site-packages (from python-neutronclient)
Requirement already satisfied: requestsexceptions>=1.1.1 in /Library/Python/2.7/site-packages (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->python-neutronclient)
Requirement already satisfied: PyYAML>=3.1.0 in /Library/Python/2.7/site-packages (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->python-neutronclient)
Requirement already satisfied: appdirs>=1.3.0 in /Library/Python/2.7/site-packages (from os-client-config!=1.19.0,!=1.19.1,!=1.20.0,!=1.20.1,!=1.21.0,>=1.13.1->python-neutronclient)
Requirement already satisfied: pytz>=0a in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from Babel>=2.3.4->python-neutronclient)
Requirement already satisfied: stevedore>=1.17.1 in /Library/Python/2.7/site-packages (from keystoneauth1>=2.10.0->python-neutronclient)
Requirement already satisfied: positional>=1.1.1 in /Library/Python/2.7/site-packages (from keystoneauth1>=2.10.0->python-neutronclient)
Requirement already satisfied: wrapt>=1.7.0 in /Library/Python/2.7/site-packages (from debtcollector>=1.2.0->python-neutronclient)
Requirement already satisfied: funcsigs>=0.4; python_version == "2.7" or python_version == "2.6" in /Library/Python/2.7/site-packages (from debtcollector>=1.2.0->python-neutronclient)
Requirement already satisfied: pyparsing>=2.0.1 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from oslo.utils>=3.16.0->python-neutronclient)
Requirement already satisfied: netifaces>=0.10.4 in /Library/Python/2.7/site-packages (from oslo.utils>=3.16.0->python-neutronclient)
Requirement already satisfied: monotonic>=0.6 in /Library/Python/2.7/site-packages (from oslo.utils>=3.16.0->python-neutronclient)
Requirement already satisfied: msgpack-python>=0.4.0 in /Library/Python/2.7/site-packages (from oslo.serialization>=1.10.0->python-neutronclient)
Requirement already satisfied: unicodecsv>=0.8.0; python_version < "3.0" in /Library/Python/2.7/site-packages (from cliff!=1.16.0,!=1.17.0,>=1.15.0->python-neutronclient)
Requirement already satisfied: PrettyTable<0.8,>=0.7 in /Library/Python/2.7/site-packages (from cliff!=1.16.0,!=1.17.0,>=1.15.0->python-neutronclient)
Requirement already satisfied: cmd2>=0.6.7 in /Library/Python/2.7/site-packages (from cliff!=1.16.0,!=1.17.0,>=1.15.0->python-neutronclient)
Installing collected packages: python-neutronclient
Successfully installed python-neutronclient-6.0.0
#

インストールできたので、ネットワークを表示させてみる。
既に2つのネットワークを作成していたので、それが表示されるはず。

# neutron net-list
+--------------------------------------+--------------+------------------------------------------------------+
| id                                   | name         | subnets                                              |
+--------------------------------------+--------------+------------------------------------------------------+
| b0ff4813-7896-4c2e-bd5a-cf33159b7224 | Test-Private | 5ec5b9a5-4311-4451-81fb-fe9885db85ab 10.1.1.0/24     |
| 1a6c8232-7d66-4eda-b1a0-7364324bd7b4 | Public       | 78d72dae-bdf8-4fef-b877-bbe16ae11c9a 192.168.11.0/24 |
+--------------------------------------+--------------+------------------------------------------------------+
# 

これも成功。
ようやく、OpenStack コマンドラインツールの準備が完了した。

■まとめ

OpenStackコマンドラインツールのインストールは、OpenStack Docs を見る限りMacはとても楽そうに見えたが、全然そうではなかった。
今回は Mac が El Captitan で、OpenStack が Mitaka という組み合わせだったが、それぞれが別のバージョンだとまた違ったエラーに巻き込まれる可能性も高いと思う。